コード例 #1
0
  private java.security.spec.ECPoint getPublicPoint(ECDSAPublicKey key) {
    if (!key.hasParameters()) {
      throw new IllegalArgumentException("Public key does not contains EC Params");
    }

    BigInteger p = key.getPrimeModulusP();
    ECCurve.Fp curve = new ECCurve.Fp(p, key.getFirstCoefA(), key.getSecondCoefB());

    ECPoint.Fp pubY = (ECPoint.Fp) curve.decodePoint(key.getPublicPointY());

    return new java.security.spec.ECPoint(
        pubY.getAffineXCoord().toBigInteger(), pubY.getAffineYCoord().toBigInteger());
  }
コード例 #2
0
  private ECParameterSpec getParams(ECDSAPublicKey key) {
    if (!key.hasParameters()) {
      throw new IllegalArgumentException("Public key does not contains EC Params");
    }

    BigInteger p = key.getPrimeModulusP();
    ECCurve.Fp curve = new ECCurve.Fp(p, key.getFirstCoefA(), key.getSecondCoefB());

    ECPoint G = curve.decodePoint(key.getBasePointG());

    BigInteger order = key.getOrderOfBasePointR();
    BigInteger coFactor = key.getCofactorF();

    EllipticCurve jcaCurve = convertCurve(curve);

    return new ECParameterSpec(
        jcaCurve,
        new java.security.spec.ECPoint(
            G.getAffineXCoord().toBigInteger(), G.getAffineYCoord().toBigInteger()),
        order,
        coFactor.intValue());
  }