コード例 #1
0
  protected Element[] map(CipherParameters publicKey, String... ids) {
    Pairing pairing =
        PairingFactory.getPairing(((UHIBELW11PublicKeyParameters) publicKey).getParameters());

    Element[] elements = new Element[ids.length];
    for (int i = 0; i < elements.length; i++) {
      byte[] id = ids[i].getBytes();
      elements[i] = pairing.getZr().newElementFromHash(id, 0, id.length);
    }
    return elements;
  }
コード例 #2
0
  private void initialize(CurveParameters cp) {
    random = new Random(0);
    // e = PairingFactory.getPairing(cp);

    e = new TypeAPairing(random, cp);

    // Groups G1 and G2 of prime order q
    G1 = e.getG1();
    G2 = e.getGT();

    // Field Zq
    Zq = e.getZr();

    // Global system parameters: g \in G1, Z = e(g,g) \in G2
    g = ((CurveField) G1).getGen().getImmutable();
    //        if(g.isZero()){
    //            System.out.println("g es 0!! :(");
    //            System.exit(-1);
    //        }
    //        g = G1.newRandomElement().getImmutable();
    // System.out.println("g = " + ProxyMain.elementToString(g));

    Z = e.pairing(g, g).getImmutable();

    Z_ppp = Z.pow();
    g_ppp = g.pow();

    /*
    System.out.println(G1.getClass());
    System.out.println(G2.getClass());
    System.out.println(Zq.getClass());
    System.out.println(e.getClass());
    System.out.println(g.getClass());
    System.out.println(g.toBytes()[0]);
    System.out.println(Z.getClass());*/

  }