Seems like the conversion to ECPrivateKey does not work, the var type is ECPrivateKey but still throws this exception on:
public static byte[] decrypt(...
keyAgreement.init(merchantPrivateKey);
Exception in thread "main" java.security.InvalidKeyException: ECKeyAgreement requires ECPrivateKey
at org.bouncycastle.jce.provider.JCEECDHKeyAgreement.engineInit(Unknown Source)
at javax.crypto.KeyAgreement.init(KeyAgreement.java:461)
at javax.crypto.KeyAgreement.init(KeyAgreement.java:435)
at com.johndbeatty.applepay.Main.decrypt(Main.java:113)
at com.johndbeatty.applepay.Main.main(Main.java:104)
Seems like the conversion to ECPrivateKey does not work, the var type is ECPrivateKey but still throws this exception on: public static byte[] decrypt(... keyAgreement.init(merchantPrivateKey);
Exception in thread "main" java.security.InvalidKeyException: ECKeyAgreement requires ECPrivateKey at org.bouncycastle.jce.provider.JCEECDHKeyAgreement.engineInit(Unknown Source) at javax.crypto.KeyAgreement.init(KeyAgreement.java:461) at javax.crypto.KeyAgreement.init(KeyAgreement.java:435) at com.johndbeatty.applepay.Main.decrypt(Main.java:113) at com.johndbeatty.applepay.Main.main(Main.java:104)
Any idea how to fix?