# A PEKS-Based NDN Strategy for Name Privacy
## 4 Details of Implementation
### NFD Operations  
When NFD sees \"/peks_strategy\" in the name of an interest packet, it then triggers PEKS_Strategy to match with the Trapdoor table. This Trapdoor is a nested list. It contains several inner lists that hold each name component as an element. Each inner list is meant for a name. We use exhaustive search to match every PEKS ciphertexts with the Trapdoor table as shown in Algorithm 1. In the Algorithm 1, the created PEKSList[] is obtained by extracting name components of an interest name. The output becomes PEKSList[\(C_{1},C_{2},...,C_{k}\)]. Then NFD uses Test (\(P_{pub}\), \(C_{k}\), \(T_{N_{k}}\)) algorithm to check the first element of PEKSList and the first element of the first element of Trapdoor. If it is not a match, NFD moves to the next element in the Trapdoor. If it is a match and the length of PEKSList is equal to the length of the entry list inside Trapdoor, every \(C_{j}\) is checked with \(T_{N_{j}}\) in inner list. Every result with a match is marked as true in an array matchCount[]. NFD continues this iteration until the end of the PEKSList[]. Figure 8: Router’s state after producer’s first dissemination. Figure 9: Interest packet with PEKS ciphertexts. ```
Input:\(InterestName\), \(Trapdoor\), \(P_{pub}\) Require:\(i=0\), \(oldMatchCount[]=0\), \(PEKSList[]\) Output: ExactMatch or LongestMatch
1 whilenot at end of \(InterestName\)do
2 component = getComponent(InterestName)
3 PEKSList[i] = component
4 i = i +1
5 iterator = index of \(PEKSList[]\)
6 for\(row=0\)to end of \(Trapdoor[noOfRow]\) STEP 1 do
7 ifTest(\(P_{pub}\), \(PEKSList[0]\), \(Trapdoor[row][0]\))then
8
9\(matchCount[\text{iterator}]=true\)
10\(iterator=iterator+1\)
11 foriteratorto end of \(PEKSList[]\), \(col=1\)to end of \(Trapdoor[row][noOfColumn]\)\(col\gets col+1\), \(iterator\getsiterator+1\)do
12 ifTest(\(P_{pub}\), \(PEKSList[0]\), \(Trapdoor[row][col]\)) &&\(\mathcal{E}\) len of \(PEKSList[]==len\) of \(Trapdoor[row]\)then
13\(\triangleright\) Find the exact match
14\(matchCount[\text{iterator}]=true\)
15
16 else
17
18 Break
19 if\(col==iterator\)then
20\(exactMatch==false\)
21 ifall of \(matchCount==true\)then
22\(\triangleright\) Found an exact match
23\(exactMatch=true\)
24 return\(Trapdoor[\text{row}]\)
25
26 else
27 ifNo. truein\(oldMatchCount[]<No.\) truein\(matchCount[]\)then
28\(\triangleright\) Longest match found
29\(tmp=Trapdoor[row]\)
30\(exactMatch=false\)
31 update \(oldMatchCount[]\)
32
33 return\(tmp\)
```  
**Algorithm 1**Test Operation  
Then NFD checks whether all of the elements in matchCount[] are true at a condition, where the length of PEKSList[] is equal to the length of inner_list. If it is true, there is an \"Exact match\". Then NFD uses the exact match trapdoor to check CS. If there is a match, the data exists in CS and NFD will reply Data(InterestName + Content) to the consumer. If the result of Test (\(P_{pub}\), \(C_{k}\), \(T_{N_{k}}\)) algorithm is false for \(C_{k}\) and \(T_{N_{k}}\), NFD breaks the operation then store the number of match count in oldMatchCount[] list. The process continues until the end of the Trapdoor table. If there is no update in the oldMatchCount[], then it becomes \"Longest match\" trapdoor. With this trapdoor, NFD gets nexthrop from FIB. Then the packet is forwarded to the newtop by choosing the best route. If there is no single matched trapdoor, NFD will multicast the interest packet. NFD also uses a hash function to generate a hash value from the interest name and makes tuple(hash, interest name). It then stores in a temporary location. NFD uses this tuple to update the Trapdoor table. The matching process by using hash value is O(1) time. This is much faster than using polynomial-time algorithm Test (\(P_{pub}\), C, \(T_{N_{l}}\)). After NFD has received a reply data packet, it also stores data packet at a temporary location. When the producer sends trapdoor update information, it also append the hash value at the end. NFD checks the hash value in the tuple(hash, interest name) to get the interest name. Using this name, NFD retrieves data packet.