private static void checkSatisfy(BswabePolicy p, BswabePrv prv) { int i, l; String prvAttr; p.satisfiable = false; if (p.children == null || p.children.length == 0) { for (i = 0; i < prv.comps.size(); i++) { prvAttr = prv.comps.get(i).attr; // System.out.println("prvAtt:" + prvAttr); // System.out.println("p.attr" + p.attr); if (prvAttr.compareTo(p.attr) == 0) { // System.out.println("=staisfy="); p.satisfiable = true; p.attri = i; break; } } } else { for (i = 0; i < p.children.length; i++) checkSatisfy(p.children[i], prv); l = 0; for (i = 0; i < p.children.length; i++) if (p.children[i].satisfiable) l++; if (l >= p.k) p.satisfiable = true; } }
public static BswabeElementBoolean dec(BswabePub pub, BswabePrv prv, BswabeCph cph) { Element t; Element m; BswabeElementBoolean beb = new BswabeElementBoolean(); m = pub.p.getGT().newElement(); t = pub.p.getGT().newElement(); checkSatisfy(cph.p, prv); if (!cph.p.satisfiable) { System.err .println("cannot decrypt, attributes in key do not satisfy policy"); beb.e = null; beb.b = false; return beb; } pickSatisfyMinLeaves(cph.p, prv); decFlatten(t, cph.p, prv, pub); m = cph.cs.duplicate(); m.mul(t); /* num_muls++; */ t = pub.p.pairing(cph.c, prv.d); t.invert(); m.mul(t); /* num_muls++; */ beb.e = m; beb.b = true; return beb; }