From e8e13de4d49e2a906ff8682fe953bc8efb5043bc Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 19 Dec 2014 21:02:34 +0100 Subject: [PATCH] Restrict access to ECKey.CURVE_PARAMS. The field is almost redundant. Parameters can be fetched from ECKey.CURVE as well. --- core/src/main/java/org/bitcoinj/core/ECKey.java | 4 ++-- core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/ECKey.java b/core/src/main/java/org/bitcoinj/core/ECKey.java index fb0b4acf..dab26de7 100644 --- a/core/src/main/java/org/bitcoinj/core/ECKey.java +++ b/core/src/main/java/org/bitcoinj/core/ECKey.java @@ -112,8 +112,8 @@ public class ECKey implements EncryptableItem, Serializable { } }; - /** The parameters of the secp256k1 curve that Bitcoin uses. */ - public static final X9ECParameters CURVE_PARAMS = CustomNamedCurves.getByName("secp256k1"); + // The parameters of the secp256k1 curve that Bitcoin uses. + private static final X9ECParameters CURVE_PARAMS = CustomNamedCurves.getByName("secp256k1"); /** The parameters of the secp256k1 curve that Bitcoin uses. */ public static final ECDomainParameters CURVE; diff --git a/core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java b/core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java index 3b7d3e42..98ca25c2 100644 --- a/core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java +++ b/core/src/main/java/org/bitcoinj/crypto/BIP38PrivateKey.java @@ -153,7 +153,7 @@ public class BIP38PrivateKey extends VersionedChecksummedBytes { BigInteger seedFactor = new BigInteger(1, Sha256Hash.createDouble(seed).getBytes()); checkState(passFactor.signum() >= 0); checkState(seedFactor.signum() >= 0); - BigInteger priv = passFactor.multiply(seedFactor).mod(ECKey.CURVE_PARAMS.getN()); + BigInteger priv = passFactor.multiply(seedFactor).mod(ECKey.CURVE.getN()); return ECKey.fromPrivate(priv, compressed); } catch (GeneralSecurityException x) {