mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 17:26:28 +01:00
ECKey: Move compressPoint()/decompressPoint() helpers to LazyECPoint.compress()/decompress().
Deprecate the old methods.
This commit is contained in:
parent
98bc701c2b
commit
4dc4cf743d
3 changed files with 24 additions and 8 deletions
|
@ -198,19 +198,19 @@ public class ECKey implements EncryptableItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility for compressing an elliptic curve point. Returns the same point if it's already compressed.
|
* @deprecated Use {@link LazyECPoint#compress()}
|
||||||
* See the ECKey class docs for a discussion of point compression.
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static LazyECPoint compressPoint(LazyECPoint point) {
|
public static LazyECPoint compressPoint(LazyECPoint point) {
|
||||||
return point.isCompressed() ? point : new LazyECPoint(point.get(), true);
|
return point.compress();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility for decompressing an elliptic curve point. Returns the same point if it's already uncompressed.
|
* @deprecated Use {@link LazyECPoint#decompress()}
|
||||||
* See the ECKey class docs for a discussion of point compression.
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static LazyECPoint decompressPoint(LazyECPoint point) {
|
public static LazyECPoint decompressPoint(LazyECPoint point) {
|
||||||
return !point.isCompressed() ? point : new LazyECPoint(point.get(), false);
|
return point.decompress();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class DeterministicKey extends ECKey {
|
||||||
LazyECPoint publicAsPoint,
|
LazyECPoint publicAsPoint,
|
||||||
@Nullable BigInteger priv,
|
@Nullable BigInteger priv,
|
||||||
@Nullable DeterministicKey parent) {
|
@Nullable DeterministicKey parent) {
|
||||||
super(priv, compressPoint(checkNotNull(publicAsPoint)));
|
super(priv, publicAsPoint.compress());
|
||||||
checkArgument(chainCode.length == 32);
|
checkArgument(chainCode.length == 32);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.childNumberPath = HDPath.M(checkNotNull(childNumberPath));
|
this.childNumberPath = HDPath.M(checkNotNull(childNumberPath));
|
||||||
|
@ -138,7 +138,7 @@ public class DeterministicKey extends ECKey {
|
||||||
@Nullable DeterministicKey parent,
|
@Nullable DeterministicKey parent,
|
||||||
int depth,
|
int depth,
|
||||||
int parentFingerprint) {
|
int parentFingerprint) {
|
||||||
super(null, compressPoint(checkNotNull(publicAsPoint)));
|
super(null, publicAsPoint.compress());
|
||||||
checkArgument(chainCode.length == 32);
|
checkArgument(chainCode.length == 32);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.childNumberPath = HDPath.M(checkNotNull(childNumberPath));
|
this.childNumberPath = HDPath.M(checkNotNull(childNumberPath));
|
||||||
|
|
|
@ -70,6 +70,22 @@ public class LazyECPoint {
|
||||||
this.bits = null;
|
this.bits = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a compressed version of this elliptic curve point. Returns the same point if it's already compressed.
|
||||||
|
* See the {@link ECKey} class docs for a discussion of point compression.
|
||||||
|
*/
|
||||||
|
public LazyECPoint compress() {
|
||||||
|
return compressed ? this : new LazyECPoint(get(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a decompressed version of this elliptic curve point. Returns the same point if it's already compressed.
|
||||||
|
* See the {@link ECKey} class docs for a discussion of point compression.
|
||||||
|
*/
|
||||||
|
public LazyECPoint decompress() {
|
||||||
|
return !compressed ? this : new LazyECPoint(get(), false);
|
||||||
|
}
|
||||||
|
|
||||||
public ECPoint get() {
|
public ECPoint get() {
|
||||||
if (point == null)
|
if (point == null)
|
||||||
point = curve.decodePoint(bits);
|
point = curve.decodePoint(bits);
|
||||||
|
|
Loading…
Add table
Reference in a new issue