diff --git a/src/main/java/im/status/wallet/SECP256k1.java b/src/main/java/im/status/wallet/SECP256k1.java index ccae43c..d6dbb1e 100644 --- a/src/main/java/im/status/wallet/SECP256k1.java +++ b/src/main/java/im/status/wallet/SECP256k1.java @@ -64,6 +64,7 @@ public class SECP256k1 { this.crypto = crypto; this.ecPointMultiplier = KeyAgreement.getInstance(ALG_EC_SVDP_DH_PLAIN_XY, false); this.tmpECPrivateKey = (ECPrivateKey) KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PRIVATE, SECP256K1_KEY_SIZE, false); + setCurveParameters(tmpECPrivateKey); } /** @@ -105,10 +106,7 @@ public class SECP256k1 { */ short derivePublicKey(byte[] privateKey, short privOff, byte[] pubOut, short pubOff) { tmpECPrivateKey.setS(privateKey, privOff, (short)(SECP256K1_KEY_SIZE/8)); - short res = derivePublicKey(tmpECPrivateKey, pubOut, pubOff); - // Unfortunately our current card does not support EC transient keys - tmpECPrivateKey.clearKey(); - return res; + return derivePublicKey(tmpECPrivateKey, pubOut, pubOff); } /** diff --git a/src/main/java/im/status/wallet/WalletApplet.java b/src/main/java/im/status/wallet/WalletApplet.java index a77fb21..6bff517 100644 --- a/src/main/java/im/status/wallet/WalletApplet.java +++ b/src/main/java/im/status/wallet/WalletApplet.java @@ -640,7 +640,7 @@ public class WalletApplet extends Applet { */ private void resetKeyStatus() { parentPrivateKey.clearKey(); - parentPublicKey.clearKey(); + secp256k1.setCurveParameters(parentPrivateKey); keyPathLen = 0; } @@ -800,7 +800,7 @@ public class WalletApplet extends Applet { pathLenOff = 0; break; case DERIVE_P1_SOURCE_PARENT: - if (!parentPublicKey.isInitialized()) { + if (!parentPrivateKey.isInitialized()) { ISOException.throwIt(ISO7816.SW_WRONG_P1P2); }