List of usage examples for org.bouncycastle.math.ec ECCurve getCofactor
public BigInteger getCofactor()
From source file:com.github.horrorho.inflatabledonkey.crypto.ec.ECPointsCompact.java
License:Open Source License
@Deprecated public static boolean satisfiesCofactor(ECCurve curve, ECPoint point) { // Patched org.bouncycastle.math.ec.ECPoint#satisfiesCofactor protected code. BigInteger h = curve.getCofactor(); return h == null || h.equals(ECConstants.ONE) || !ECAlgorithms.referenceMultiply(point, h).isInfinity(); }
From source file:dorkbox.util.serialization.EccPrivateKeySerializer.java
License:Apache License
static void serializeCurve(Output output, ECCurve curve) throws KryoException { byte[] bytes; int length;/*from ww w . j a v a 2 s.c om*/ // save out if it's a NAMED curve, or a UN-NAMED curve. If it is named, we can do less work. String curveName = curve.getClass().getSimpleName(); if (CustomNamedCurves.getByName(curveName) != null) { // we use the name instead of serializing the full curve output.writeInt(usesName, true); output.writeString(curveName); return; } else if (curveName.endsWith("Curve")) { String cleanedName = curveName.substring(0, curveName.indexOf("Curve")); if (!cleanedName.isEmpty()) { ASN1ObjectIdentifier oid = CustomNamedCurves.getOID(cleanedName); if (oid != null) { // we use the OID (instead of serializing the entire curve) output.writeInt(usesOid, true); curveName = oid.getId(); output.writeString(curveName); return; } } } // we have to serialize the ENTIRE curve. // save out the curve info BigInteger a = curve.getA().toBigInteger(); BigInteger b = curve.getB().toBigInteger(); BigInteger order = curve.getOrder(); BigInteger cofactor = curve.getCofactor(); BigInteger q = curve.getField().getCharacteristic(); ///////////// bytes = a.toByteArray(); length = bytes.length; output.writeInt(length, true); output.writeBytes(bytes, 0, length); ///////////// bytes = b.toByteArray(); length = bytes.length; output.writeInt(length, true); output.writeBytes(bytes, 0, length); ///////////// bytes = order.toByteArray(); length = bytes.length; output.writeInt(length, true); output.writeBytes(bytes, 0, length); ///////////// bytes = cofactor.toByteArray(); length = bytes.length; output.writeInt(length, true); output.writeBytes(bytes, 0, length); ///////////// bytes = q.toByteArray(); length = bytes.length; output.writeInt(length, true); output.writeBytes(bytes, 0, length); // coordinate system int coordinateSystem = curve.getCoordinateSystem(); output.writeInt(coordinateSystem, true); }