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
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))
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 ""