Single Service kNN Authentication

In the most paper[1], kNN authentication is partitioned into two parts:

  • use the traditional incremental kNN find algorithm ( best first search) to find the kth point (data).
  • use a circle with the query point as its center and the distance between the kth point and the query point as the radius to create a traditional range query
  • use the mature range query authentication method to construct the verification objects by which the client can reconstruct the root hash value.

However, we want an algorithm that can both compute the results of kNN and construct the verification objects during the traverse of MR-tree. Normally the best first search will destroy the order of the sub-trees and nodes so that it will incur that the verification process will be difficult to reconstruct the root hash value.
In range query authentication, we process the depth first search to the MR-tree to see whether the internal node is intersect with the query range. The whole structure can be written recursively. And the object in VO is in recursive pattern. The objects in the same sub-tree are put between the two '[' and ']' bracket.

(MBR Value, HashValue)=RootHash(VerObj VO) //Client
  1. Set str=∅ and MBR=NULL
  2. While VO still has entries
  3. Get next entry eV from VO
  4. If eV is a data object P
  5. If P overlaps the query, Add P to the result set
  6. Enlarge MBR to include P
  7. str = str | P
  8. If eV is a pair of MBR/digest (MBR_c, H_c)
  9. Enlarge MBR to include MBR_c
  10. str = str | MBR_c | H_c
  11. If eV is [
  12. (MBR_c, H_c) = RootHash(VO)
  13. Enlarge MBR to include MBR_c
  14. str = str | MBR_c | H_c
  15. If eV is ], Return (MBR, hash(str))

The RootHash algorithm merges all of the objects between the brackets and recursively compute the internal node's MBR and hash value.

Method in top-k query authentication[2]

Algorithm 1: kSKQ Processing and VO Generation over MIR-tree
Input: A kSKQ request, MIR-tree
Output: The result set and VO
1 Put each entry Ri in the root into a priority queue and initialize VO with (1)
  ‘[’; (2) each Ri and H(Ri); (3)the inverted file associated with the root; (4) ‘]’;
2 while k objects have not been found do
3   Pick the entry with the smallest ranking score from the priority queue;
4   if the picked entry is an MBR Ri then
5   Put each Rj (or Oj) in Ri’s child node into the priority queue again;
6   Replace Ri and H(Ri) with (1) ‘[’; (2) each Rj and H(Rj) (or Oj) in Ri’s child node;    
     (3) the inverted file associated with Ri’s child node; (4) ‘]’ in VO;
7   else
8    //the picked entry is an object Oi
9   Put Oi into the result set;
10 Return the result set and VO;

As in kNN, the extra documents(inverted file) are not in the record. The VO only contains MBR and hash value. The core thinking is similar to the range query. In range query, the internal node needs to expand its sub-trees while it intersects with the query range. In kNN query, we replace the intersection process with the nearest process. We find the nearest nodes or data points by using the function: minimumDistance. And replace the nearest node with its corresponding sub-tree nodes in the VO list. There is only one problem is that in the implementing process, the VO list must contains both the String '[' ']' objects and the MR-tree node objects.
We need to transform all of the node objects into its corresponding String objects for the client's verification.
The sample JAVA implementation of kNN query with construction of VO is below:

    public void securenearestNeighborQuery(int k, final IShape query,HashMap<String, String> hashnode,HashMap<String, String> hashdata,LinkedList VO)
    {
        if (query.getDimension() != m_dimension) throw new IllegalArgumentException("nearestNeighborQuery: Shape has the wrong number of dimensions.");
        Node n = readNode(m_rootID);
        //add the root entry with nearest distance
        VO.add(new NNEntry(n,0.0));

        
        int minindex = 0;
        int counter = 0;
        double knearest = 0.0;
        while(counter<k) {
            double min = 9999999;
            //first find the nearest distance and index
            NNEntry t = null;
            for(int i=0;i<VO.size();i++) {
                Object item = VO.get(i);
                if(!(item instanceof String))
                {
                    t = (NNEntry)item;
                    double mindis = t.m_minDist;
                    if(mindis < min) {
                        min = mindis;
                        minindex = i;
                    }
                }
            }
            //t is the closest entry
            t = (NNEntry)VO.get(minindex);
            if(t.m_pEntry instanceof Node) {
                VO.remove(minindex);
                n = (Node)t.m_pEntry;
                VO.add(minindex,"[");
                //expand the children of t and add them to the linkedlist VO
                for (int cChild = 0; cChild < n.m_children; cChild++) {
                    IEntry e;
                    if(n.m_level != 0)
                    {
                        e = readNode(n.m_pIdentifier[cChild]);
                    }
                    else
                    {
                        e = new Data(n.m_pData[cChild], n.m_pMBR[cChild], n.m_pIdentifier[cChild]);
                    }
                    NNEntry e2 = new NNEntry(e,query.getMinimumDistance(e.getShape()));
                    VO.add(minindex+cChild+1,e2);
                }
                VO.add(minindex+n.m_children+1,"]");
            }
            //the entry is a point not a node!
            else {
                t.m_minDist = 10000000;
                Data d = (Data)t.m_pEntry;
                System.out.println(d.getIdentifier());
                counter++;
                knearest = t.m_minDist;
            }
        }
        //transform all of the non-string entry to String format in VO
        for(int it=0;it<VO.size();it++) {
            Object item = VO.get(it);
            if(item instanceof NNEntry)
            {
                VO.remove(it);
                NNEntry entry = (NNEntry)item;
                if(entry.m_pEntry instanceof Node) {
                    Node node = (Node)entry.m_pEntry;
                    VO.add(it,"("+node.getShape().toString()+hashnode.get(""+node.m_identifier)+")");//non expanded internal node
                }
                else {
                    Data data = (Data)entry.m_pEntry;
                    VO.add(it,data.getShape().toString());//data points in expanded node
                }
            }
        }
    }

[1] Authenticated indexing for outsourced spatial databases
[2] Authentication of Top-k Spatial Keyword Queries in Outsourced Databases

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,711评论 5 468
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 83,932评论 2 376
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,770评论 0 330
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,799评论 1 271
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,697评论 5 359
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,069评论 1 276
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,535评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,200评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,353评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,290评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,331评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,020评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,610评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,694评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,927评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,330评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,904评论 2 341

推荐阅读更多精彩内容

  • 文/山雨 小草的倔强 靠着那顽强的生命力 要么屈服 要么生长 花儿的炫美 靠着那傲娇的芬芳 要么枯...
    如影泡幻阅读 120评论 0 3
  • 8个球,里面2黑6白,求摸出2黑2白的概率 假设是黑黑白白的顺序,可以算得,第一次概率是2/8,8个球,2个黑球第...
    徒劳的写阅读 1,354评论 0 0
  • 舍末逐本阅读 479评论 0 2
  • 1.为什么要敏捷?有什么收益? 知道敏捷很早以前的事情了,从XP出现不久时候就开始就已经在关注了,XP的不少...
    数行者阅读 510评论 0 3