	public void testCurveMismatch()
		throws Exception {
		
		// EC key on P_256
		ECParameterSpec ecParameterSpec = ECKey.Curve.P_256.toECParameterSpec();
		KeyPairGenerator generator = KeyPairGenerator.getInstance("EC");
		generator.initialize(ecParameterSpec);
		KeyPair keyPair = generator.generateKeyPair();
		ECKey ecJWK_p256 = new ECKey.Builder(ECKey.Curve.P_256, (ECPublicKey) keyPair.getPublic())
			.privateKey((ECPrivateKey) keyPair.getPrivate())
			.build();
		
		// EC key on P_384
		ecParameterSpec = ECKey.Curve.P_384.toECParameterSpec();
		generator = KeyPairGenerator.getInstance("EC");
		generator.initialize(ecParameterSpec);
		keyPair = generator.generateKeyPair();
		ECKey ecJWK_p384 = new ECKey.Builder(ECKey.Curve.P_384, (ECPublicKey) keyPair.getPublic())
			.privateKey((ECPrivateKey) keyPair.getPrivate())
			.build();
		
		
		// Try to create EC key with P_256 params, but with x and y from P_384 curve key
		
		ECPoint w = new ECPoint(ecJWK_p384.getX().decodeToBigInteger(), ecJWK_p384.getY().decodeToBigInteger());
		ECPublicKeySpec publicKeySpec = new ECPublicKeySpec(w, ECKey.Curve.P_256.toECParameterSpec());
		
		// Default Sun provider
		try {
			KeyFactory keyFactory = KeyFactory.getInstance("EC");
			keyFactory.generatePublic(publicKeySpec);
			fail();
		} catch (RuntimeException e) {
			assertEquals("Point coordinates do not match field size", e.getMessage());
		}
		
		// BouncyCastle provider
		try {
			KeyFactory keyFactory = KeyFactory.getInstance("EC", BouncyCastleProviderSingleton.getInstance());
			keyFactory.generatePublic(publicKeySpec);
			fail();
		} catch (InvalidKeySpecException e) {
			assertEquals("invalid KeySpec: x value invalid for SecP256R1FieldElement", e.getMessage());
		}
	}
The software does not verify, or incorrectly verifies, the cryptographic signature for data.