Example #1
0
  public boolean isValid() {
    Element t0, t1;

    if (infFlag != 0) return true;

    t0 = field.getTargetField().newElement();
    t1 = field.getTargetField().newElement();
    t0.set(x).square().add(getField().getA()).mul(x).add(getField().getB());
    t1.set(y).square();

    return t0.isEqual(t1);
  }
  protected final void pointToAffine(Element Vx, Element Vy, Element z, Element z2, Element e0) {
    // Vx = Vx * z^-2
    Vx.mul(e0.set(z.invert()).square());
    // Vy = Vy * z^-3
    Vy.mul(e0.mul(z));

    z.setToOne();
    z2.setToOne();
  }
Example #3
0
  public CurveElement<?> setFromHash(byte[] source, int offset, int length) {
    infFlag = 0;
    x.setFromHash(source, offset, length);

    Element t = field.getTargetField().newElement();
    for (; ; ) {
      t.set(x).square().add(curveField.a).mul(x).add(curveField.b);
      if (t.isSqr()) break;

      x.square().add(t.setToOne());
    }
    y.set(t).sqrt();
    if (y.sign() < 0) y.negate();

    if (curveField.cofac != null) mul(curveField.cofac);

    return this;
  }