List of usage examples for org.bouncycastle.math.ec ECPoint getXCoord
public ECFieldElement getXCoord()
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 * /* w w w .jav a 2 s . 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 *//*from w w w . ja v a 2 s . c om*/ @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 w w w . j av a 2 s.com } 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); }