if (!R.multiply(n).isInfinity()) { return null;
/** * 判断生成的公钥是否合法 * * @param publicKey * @return */ private boolean checkPublicKey(ECPoint publicKey) { if (!publicKey.isInfinity()) { BigInteger x = publicKey.getXCoord().toBigInteger(); BigInteger y = publicKey.getYCoord().toBigInteger(); if (between(x, new BigInteger("0"), p) && between(y, new BigInteger("0"), p)) { BigInteger xResult = x.pow(3).add(a.multiply(x)).add(b).mod(p); BigInteger yResult = y.pow(2).mod(p); return yResult.equals(xResult) && publicKey.multiply(n).isInfinity(); } } return false; }
if (h != null) { ECPoint S = C1.multiply(h); if (S.isInfinity()) throw new IllegalStateException();
ECPoint temp = bPublicKey.add(RB.multiply(x2).normalize()).normalize(); ECPoint U = temp.multiply(ecc_bc_spec.getH().multiply(tA)).normalize(); if (U.isInfinity()) throw new IllegalStateException(); this.V = U;
ECPoint temp = aPublicKey.add(RA.multiply(x1).normalize()).normalize(); ECPoint V = temp.multiply(ecc_bc_spec.getH().multiply(tB)).normalize(); if (V.isInfinity()) throw new IllegalStateException(); this.V = V;
if (h != null) { ECPoint S = publicKey.multiply(h); if (S.isInfinity()) throw new IllegalStateException();
@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(); } }
protected boolean satisfiesCofactor() { BigInteger h = curve.getCofactor(); return h == null || h.equals(ECConstants.ONE) || !ECAlgorithms.referenceMultiply(this, h).isInfinity(); }
public boolean isNormalized() { int coord = this.getCurveCoordinateSystem(); return coord == ECCurve.COORD_AFFINE || coord == ECCurve.COORD_LAMBDA_AFFINE || isInfinity() || zs[0].isOne(); }
public ECPoint subtract(ECPoint b) { if (b.isInfinity()) { return this; } // Add -b return this.add(b.negate()); }
public ECPoint subtract(ECPoint b) { if (b.isInfinity()) { return this; } // Add -b return this.add(b.negate()); } }
public boolean isNormalized() { int coord = this.getCurveCoordinateSystem(); return coord == ECCurve.COORD_AFFINE || coord == ECCurve.COORD_LAMBDA_AFFINE || isInfinity() || zs[0].isOne(); }
public ECPoint subtract(ECPoint b) { if (b.isInfinity()) { return this; } // Add -b return this.add(b.negate()); } }
protected boolean satisfiesOrder() { if (ECConstants.ONE.equals(curve.getCofactor())) { return true; } BigInteger n = curve.getOrder(); // TODO Require order to be available for all curves return n == null || ECAlgorithms.referenceMultiply(this, n).isInfinity(); }
public byte[] agreement(BigInteger d) { // TODO thread safety of ECPoint unclear. synchronized (lock) { ECPoint P = Q.multiply(d).normalize(); if (P.isInfinity()) { throw new IllegalStateException("invalid EDCH: infinity"); } return P.getAffineXCoord().getEncoded(); } }
public BigInteger calculateAgreement( CipherParameters pubKey) { ECPublicKeyParameters pub = (ECPublicKeyParameters)pubKey; ECPoint P = pub.getQ().multiply(key.getD()).normalize(); if (P.isInfinity()) { throw new IllegalStateException("Infinity is not a valid agreement value for ECDH"); } return P.getAffineXCoord().toBigInteger(); } }
public ECPoint scaleY(ECFieldElement scale) { return isInfinity() ? this : getCurve().createRawPoint(getRawXCoord(), getRawYCoord().multiply(scale), getRawZCoords(), this.withCompression); }
public ECPoint scaleX(ECFieldElement scale) { return isInfinity() ? this : getCurve().createRawPoint(getRawXCoord().multiply(scale), getRawYCoord(), getRawZCoords(), this.withCompression); }
public ECPoint scaleX(ECFieldElement scale) { return isInfinity() ? this : getCurve().createRawPoint(getRawXCoord().multiply(scale), getRawYCoord(), getRawZCoords(), this.withCompression); }
public ECPoint scaleY(ECFieldElement scale) { return isInfinity() ? this : getCurve().createRawPoint(getRawXCoord(), getRawYCoord().multiply(scale), getRawZCoords(), this.withCompression); }