mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 19:25:51 +00:00
ECKey: make compress/decompressPoint use non-deprecated methods and add a note that BC's tracking of compression state is going to go away.
This commit is contained in:
parent
a807994b9a
commit
2be8bc1901
@ -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.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Represents an elliptic curve public and (optionally) private key, usable for digital signatures but not encryption.
|
* <p>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
|
* 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.
|
* 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.
|
* See the ECKey class docs for a discussion of point compression.
|
||||||
*/
|
*/
|
||||||
public static ECPoint.Fp compressPoint(ECPoint uncompressed) {
|
public static ECPoint compressPoint(ECPoint uncompressed) {
|
||||||
return new ECPoint.Fp(CURVE.getCurve(), uncompressed.getX(), uncompressed.getY(), true);
|
return CURVE.getCurve().decodePoint(uncompressed.getEncoded(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility for decompressing an elliptic curve point. Returns the same point if it's already compressed.
|
* 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.
|
* See the ECKey class docs for a discussion of point compression.
|
||||||
*/
|
*/
|
||||||
public static ECPoint.Fp decompressPoint(ECPoint compressed) {
|
public static ECPoint decompressPoint(ECPoint compressed) {
|
||||||
return new ECPoint.Fp(CURVE.getCurve(), compressed.getX(), compressed.getY(), false);
|
return CURVE.getCurve().decodePoint(compressed.getEncoded(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user