示例#1
0
文件: BenchMark.py 项目: caixl/FYP
def testKPABE_dk(nodes, E, P):
    sg = SymbolDiGraphMat(nodes, rand_E=E)
    #print nodes
    abe_graph = KPABESymbolDiGraph(sg)
    abe_graph.setup()
    dk = abe_graph.key_generation(P)
    return len(str(dk))
示例#2
0
文件: BenchMark.py 项目: caixl/FYP
def testKPABE_keygen(nodes, E, policy):
    sg = SymbolDiGraphMat(nodes, rand_E=E)
    abe_graph = KPABESymbolDiGraph(sg)
    abe_graph.setup()
    t0 = time.clock()
    abe_graph.key_generation(policy)
    t1 = time.clock()
    return t1-t0
示例#3
0
文件: BenchMark.py 项目: caixl/FYP
def testKPABE_enc(nodes, E):
    sg = SymbolDiGraphMat(nodes, rand_E=E)
    abe_graph = KPABESymbolDiGraph(sg)
    abe_graph.setup()
    t0 = time.clock()
    abe_graph.encrypt()
    t1 = time.clock()
    return t1-t0
示例#4
0
文件: BenchMark.py 项目: caixl/FYP
def testKPABE_subgraph(nodes, E, vertices):
    sg = SymbolDiGraphMat(nodes, rand_E=E)
    abe_graph = KPABESymbolDiGraph(sg)
    abe_graph.setup()
    encMat = abe_graph.encrypt()
    t0 = time.clock()
    abe_graph.subgraph(encMat, vertices)
    t1 = time.clock()
    return t1-t0
示例#5
0
文件: BenchMark.py 项目: caixl/FYP
def testKPABE_pp(nodes, E):
    sg = SymbolDiGraphMat(nodes, rand_E=E)
    abe_graph = KPABESymbolDiGraph(sg)
    pk_t, mk_t = abe_graph.setup()
    return len(str(pk_t))
示例#6
0
文件: BenchMark.py 项目: caixl/FYP
def testKPABE_subgraph_size(nodes, E, vertices):
    sg = SymbolDiGraphMat(nodes, rand_E=E)
    abe_graph = KPABESymbolDiGraph(sg)
    abe_graph.setup()
    encMat = abe_graph.encrypt()
    return len(str(abe_graph.subgraph(encMat, vertices)))
示例#7
0
文件: BenchMark.py 项目: caixl/FYP
def compare_dec_rt(N, E, K):
    nodes = []
    for i in xrange(0,N):
        nodes.append('v%d'%(i+1))
        
    attributes = []
    vertices = []
    policy = "("
    for i in xrange(0, K):
        if i!=0:
            policy+=" OR "
        policy+="v%dr"%(i+1)
        attributes.append('V%dR'%(i+1))  
        attributes.append('V%dC'%(i+1))  
        vertices.append('v%d'%(i+1))
    
    policy+=") AND ("
    
    for i in xrange(0, K):
        if i!=0:
            policy+=" OR "
        policy+="v%dc"%(i+1)
    
    policy+=")"
    
    sg = SymbolDiGraphMat(nodes, rand_E=E)
    
    cpabe_graph = CPABESymbolDiGraph(sg)
    cpabe_graph.setup()
    cpabeEncMat = cpabe_graph.encrypt()
    
    kpabe_graph = KPABESymbolDiGraph(sg)
    kpabe_graph.setup()
    kpabeEncMat = kpabe_graph.encrypt()
    
    sg = SymbolDiGraphLst(nodes,rand_E=E)
    list_graph = PairEncSymbolDiGraph(sg)
    list_graph.setup()
    pairEncList = list_graph.encrypt()
    
    
    cpabe_dk = cpabe_graph.key_generation(attributes)
    kpabe_dk = kpabe_graph.key_generation(policy)
    plist_dk = list_graph.key_generation(vertices)
    
    Q = 2
    subnodes = []
    for i in xrange(0, Q):
        subnodes.append('v%d'%(i+1)) 
    
    print "CPABE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testCPABE_dec(cpabe_graph._master_public_key, cpabe_dk, cpabeEncMat, subnodes))
    print "KPABE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testKPABE_dec(kpabe_dk, kpabeEncMat, subnodes))
    print "PAIRE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testPairEnc_dec( plist_dk, pairEncList, subnodes ))
    print ""
    
    Q = 4
    subnodes = []
    for i in xrange(0, Q):
        subnodes.append('v%d'%(i+1)) 
    
    print "CPABE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testCPABE_dec(cpabe_graph._master_public_key, cpabe_dk, cpabeEncMat, subnodes))
    print "KPABE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testKPABE_dec(kpabe_dk, kpabeEncMat, subnodes))
    print "PAIRE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testPairEnc_dec( plist_dk, pairEncList, subnodes ))
    print ""
    
    
    Q = 6
    subnodes = []
    for i in xrange(0, Q):
        subnodes.append('v%d'%(i+1)) 
    
    print "CPABE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testCPABE_dec(cpabe_graph._master_public_key,cpabe_dk, cpabeEncMat, subnodes))
    print "KPABE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testKPABE_dec(kpabe_dk, kpabeEncMat, subnodes))
    print "PAIRE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testPairEnc_dec( plist_dk, pairEncList, subnodes ))
    print ""
    
    
    Q = 8
    subnodes = []
    for i in xrange(0, Q):
        subnodes.append('v%d'%(i+1)) 
    
    print "CPABE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testCPABE_dec(cpabe_graph._master_public_key,cpabe_dk, cpabeEncMat, subnodes))
    print "KPABE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testKPABE_dec(kpabe_dk, kpabeEncMat, subnodes))
    print "PAIRE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testPairEnc_dec( plist_dk, pairEncList, subnodes ))
    print ""
    
    
    Q = 10
    subnodes = []
    for i in xrange(0, Q):
        subnodes.append('v%d'%(i+1)) 
    
    print "CPABE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testCPABE_dec(cpabe_graph._master_public_key,cpabe_dk, cpabeEncMat, subnodes))
    print "KPABE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testKPABE_dec(kpabe_dk, kpabeEncMat, subnodes))
    print "PAIRE with %d vertices and %d edges and %d queried subnodes %s s"%(N, E, Q, testPairEnc_dec( plist_dk, pairEncList, subnodes ))
    print ""
示例#8
0
文件: BenchMark.py 项目: caixl/FYP
def testKPABE_ct(nodes, E):
    sg = SymbolDiGraphMat(nodes, rand_E=E)
    abe_graph = KPABESymbolDiGraph(sg)
    abe_graph.setup()
    encMat = abe_graph.encrypt()
    return len(str(encMat))