From 2be8bc19012116396b85afc7e94e2fba3ba39cee Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Tue, 8 Apr 2014 18:01:03 +0200 Subject: [PATCH] ECKey: make compress/decompressPoint use non-deprecated methods and add a note that BC's tracking of compression state is going to go away. --- core/src/main/java/com/google/bitcoin/core/ECKey.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/ECKey.java b/core/src/main/java/com/google/bitcoin/core/ECKey.java index f8db2c17..189cc6f7 100644 --- a/core/src/main/java/com/google/bitcoin/core/ECKey.java +++ b/core/src/main/java/com/google/bitcoin/core/ECKey.java @@ -52,6 +52,9 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; +// TODO: Move this class to tracking compression state itself. +// The Bouncy Castle guys are deprecating their own tracking of the compression state. + /** *

Represents an elliptic curve public and (optionally) private key, usable for digital signatures but not encryption. * Creating a new ECKey with the empty constructor will generate a new random keypair. Other static methods can be used @@ -151,16 +154,16 @@ public class ECKey implements EncryptableItem, Serializable { * Utility for compressing an elliptic curve point. Returns the same point if it's already compressed. * See the ECKey class docs for a discussion of point compression. */ - public static ECPoint.Fp compressPoint(ECPoint uncompressed) { - return new ECPoint.Fp(CURVE.getCurve(), uncompressed.getX(), uncompressed.getY(), true); + public static ECPoint compressPoint(ECPoint uncompressed) { + return CURVE.getCurve().decodePoint(uncompressed.getEncoded(true)); } /** * Utility for decompressing an elliptic curve point. Returns the same point if it's already compressed. * See the ECKey class docs for a discussion of point compression. */ - public static ECPoint.Fp decompressPoint(ECPoint compressed) { - return new ECPoint.Fp(CURVE.getCurve(), compressed.getX(), compressed.getY(), false); + public static ECPoint decompressPoint(ECPoint compressed) { + return CURVE.getCurve().decodePoint(compressed.getEncoded(false)); } /**