Пример #1
0
    protected ECPoint decompressPoint(int yTilde, BigInteger X1) {
      ECFieldElement x = fromBigInteger(X1);
      ECFieldElement alpha = x.square().add(a).multiply(x).add(b);
      ECFieldElement beta = alpha.sqrt();

      //
      // if we can't find a sqrt we haven't got a point on the
      // curve - run!
      //
      if (beta == null) {
        throw new RuntimeException("Invalid point compression");
      }

      if (beta.testBitZero() != (yTilde == 1)) {
        // Use the other root
        beta = beta.negate();
      }

      return new ECPoint.Fp(this, x, beta, true);
    }