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

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

Introduction

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

Prototype

public ECFieldElement getYCoord() 

Source Link

Document

Returns the y-coordinate.

Usage

From source file:com.vvote.verifierlibrary.utils.crypto.ECUtils.java

License:Open Source License

/**
 * Convers a single ECPoint into a JSONObject. THe coordinates are stored in
 * Hex representations of their underlying BigInteger format
 * /*from   w  w  w.  j  a  v a2s  . c  o m*/
 * @param point
 * @return the JSONObject
 * @throws JSONException
 */
public static JSONObject constructJSONFromECPoint(ECPoint point) throws JSONException {
    JSONObject jpoint = new JSONObject();
    jpoint.put(CryptoConstants.EC.X, point.getXCoord().toBigInteger().toString(16));
    jpoint.put(CryptoConstants.EC.Y, point.getYCoord().toBigInteger().toString(16));

    return jpoint;
}

From source file:dorkbox.util.crypto.CryptoECC.java

License:Apache License

/**
 * @return true if publicA and publicB are NOT NULL, and are both equal to eachother
 *///  w w  w .  jav a2s.  c  o m
@SuppressWarnings({ "RedundantIfStatement", "SpellCheckingInspection" })
public static boolean compare(ECPublicKeyParameters publicA, ECPublicKeyParameters publicB) {
    if (publicA == null || publicB == null) {
        return false;
    }

    ECDomainParameters parametersA = publicA.getParameters();
    ECDomainParameters parametersB = publicB.getParameters();

    // is it the same curve?
    boolean equals = parametersA.getCurve().equals(parametersB.getCurve());
    if (!equals) {
        return false;
    }

    equals = parametersA.getG().equals(parametersB.getG());
    if (!equals) {
        return false;
    }

    equals = parametersA.getH().equals(parametersB.getH());
    if (!equals) {
        return false;
    }

    equals = parametersA.getN().equals(parametersB.getN());
    if (!equals) {
        return false;
    }

    ECPoint normalizeA = publicA.getQ().normalize();
    ECPoint normalizeB = publicB.getQ().normalize();

    ECFieldElement xCoordA = normalizeA.getXCoord();
    ECFieldElement xCoordB = normalizeB.getXCoord();

    equals = xCoordA.equals(xCoordB);
    if (!equals) {
        return false;
    }

    ECFieldElement yCoordA = normalizeA.getYCoord();
    ECFieldElement yCoordB = normalizeB.getYCoord();

    equals = yCoordA.equals(yCoordB);
    if (!equals) {
        return false;
    }

    return true;
}

From source file:dorkbox.util.serialization.EccPrivateKeySerializer.java

License:Apache License

static void serializeECPoint(ECPoint point, Output output) throws KryoException {
    if (point.isInfinity()) {
        return;/*from www  .  j  a v a  2 s.  co  m*/
    }

    ECPoint normed = point.normalize();

    byte[] X = normed.getXCoord().getEncoded();
    byte[] Y = normed.getYCoord().getEncoded();

    int length = 1 + X.length + Y.length;
    output.writeInt(length, true);

    output.write(0x04);
    output.write(X);
    output.write(Y);
}