From 98219bdd1b913a5f7059a773459c0d569e4910bd Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Thu, 11 Jul 2013 13:42:42 +0200 Subject: [PATCH] More static analysis tweaks. --- .../java/com/google/bitcoin/crypto/hd/HDKeyDerivation.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/crypto/hd/HDKeyDerivation.java b/core/src/main/java/com/google/bitcoin/crypto/hd/HDKeyDerivation.java index c6050768e..2f7acd747 100644 --- a/core/src/main/java/com/google/bitcoin/crypto/hd/HDKeyDerivation.java +++ b/core/src/main/java/com/google/bitcoin/crypto/hd/HDKeyDerivation.java @@ -114,8 +114,9 @@ public final class HDKeyDerivation { BigInteger ilInt = HDUtils.toBigInteger(il); assertLessThanN(ilInt, "Illegal derived key: I_L >= n"); byte[] keyBytes; - if (parent.hasPrivate()) { - BigInteger ki = parent.getPrivAsFieldElement().add(ilInt).mod(HDUtils.getEcParams().getN()); + final BigInteger privAsFieldElement = parent.getPrivAsFieldElement(); + if (privAsFieldElement != null) { + BigInteger ki = privAsFieldElement.add(ilInt).mod(HDUtils.getEcParams().getN()); assertNonZero(ki, "Illegal derived key: derived private key equals 0."); keyBytes = ki.toByteArray(); } else {