3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-11 17:55:53 +00:00

ECKey: add a sanity check for private keys that are zero or one. This should never happen but there have been reports from the wild that somehow once or twice someone managed to get a private key of zero into their wallet.

This commit is contained in:
Mike Hearn 2015-01-28 16:13:24 +01:00
parent f9338519be
commit f4cce4c3c0

View File

@ -182,6 +182,11 @@ public class ECKey implements EncryptableItem, Serializable {
}
protected ECKey(@Nullable BigInteger priv, ECPoint pub) {
if (priv != null) {
// Try and catch buggy callers or bad key imports, etc.
checkArgument(!priv.equals(BigInteger.ZERO));
checkArgument(!priv.equals(BigInteger.ONE));
}
this.priv = priv;
this.pub = new LazyECPoint(checkNotNull(pub));
}