def testCPABE_enc(nodes, E): sg = SymbolDiGraphMat(nodes, rand_E=E) abe_graph = CPABESymbolDiGraph(sg) abe_graph.setup() t0 = time.clock() abe_graph.encrypt() t1 = time.clock() return t1-t0
def testCPABE_subgraph_size(nodes, E, vertices): sg = SymbolDiGraphMat(nodes, rand_E=E) abe_graph = CPABESymbolDiGraph(sg) abe_graph.setup() encMat = abe_graph.encrypt() return len(str(abe_graph.subgraph(encMat, vertices)))
def testCPABE_subgraph(nodes, E, vertices): sg = SymbolDiGraphMat(nodes, rand_E=E) abe_graph = CPABESymbolDiGraph(sg) abe_graph.setup() encMat = abe_graph.encrypt() t0 = time.clock() abe_graph.subgraph(encMat, vertices) t1 = time.clock() return t1-t0
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 ""
def testCPABE_ct(nodes, E): sg = SymbolDiGraphMat(nodes, rand_E=E) abe_graph = CPABESymbolDiGraph(sg) abe_graph.setup() encMat = abe_graph.encrypt() return len(str(encMat))