Example usage for org.bouncycastle.math.ec ECPoint getAffineYCoord

List of usage examples for org.bouncycastle.math.ec ECPoint getAffineYCoord

Introduction

In this page you can find the example usage for org.bouncycastle.math.ec ECPoint getAffineYCoord.

Prototype

public ECFieldElement getAffineYCoord() 

Source Link

Document

Returns the affine y-coordinate after checking that this point is normalized

Usage

From source file:org.cryptoworkshop.ximix.demo.ballot.Main.java

License:Apache License

public static void outputPoint(BufferedWriter cWrt, ECPoint point, boolean isLast) throws IOException {
    cWrt.write("        {");
    cWrt.newLine();//  ww w .  ja  v a2s  .co m
    cWrt.write("            \"x\" : \"" + point.getAffineXCoord().toBigInteger().toString(16) + "\",");
    cWrt.newLine();
    cWrt.write("            \"y\" : \"" + point.getAffineYCoord().toBigInteger().toString(16) + "\"");
    cWrt.newLine();
    if (isLast) {
        cWrt.write("        }");
    } else {
        cWrt.write("        },");
    }
    cWrt.newLine();
}

From source file:org.sufficientlysecure.keychain.securitytoken.SCP11bSecureMessaging.java

License:Open Source License

private static ECPublicKey newECDHPublicKey(final ECKeyFormat kf, byte[] data) throws InvalidKeySpecException,
        NoSuchAlgorithmException, InvalidParameterSpecException, NoSuchProviderException {
    if (ecdhFactory == null) {
        ecdhFactory = KeyFactory.getInstance(SCP11B_KEY_AGREEMENT_KEY_TYPE, PROVIDER);
    }//from   w  w w  .  java  2s .  co m

    final X9ECParameters params = NISTNamedCurves.getByOID(kf.getCurveOID());
    if (params == null) {
        throw new InvalidParameterSpecException("unsupported curve");
    }

    final ECCurve curve = params.getCurve();
    final ECPoint p = curve.decodePoint(data);
    if (!p.isValid()) {
        throw new InvalidKeySpecException("invalid EC point");
    }

    final java.security.spec.ECPublicKeySpec pk = new java.security.spec.ECPublicKeySpec(
            new java.security.spec.ECPoint(p.getAffineXCoord().toBigInteger(),
                    p.getAffineYCoord().toBigInteger()),
            getAlgorithmParameterSpec(kf));

    return (ECPublicKey) (ecdhFactory.generatePublic(pk));
}