ECKey: extend the comment about why private keys of zero and one are now forbidden

This commit is contained in:
Mike Hearn 2015-01-28 19:37:13 +01:00
parent fd10654143
commit f1f07df11b

View file

@ -183,7 +183,9 @@ 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.
// Try and catch buggy callers or bad key imports, etc. Zero and one are special because these are often
// used as sentinel values and because scripting languages have a habit of auto-casting true and false to
// 1 and 0 or vice-versa. Type confusion bugs could therefore result in private keys with these values.
checkArgument(!priv.equals(BigInteger.ZERO));
checkArgument(!priv.equals(BigInteger.ONE));
}