From f1f07df11b68eab98eb0db5a9138763ec78e6d82 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Wed, 28 Jan 2015 19:37:13 +0100 Subject: [PATCH] ECKey: extend the comment about why private keys of zero and one are now forbidden --- core/src/main/java/org/bitcoinj/core/ECKey.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/bitcoinj/core/ECKey.java b/core/src/main/java/org/bitcoinj/core/ECKey.java index afa5c2cf..e9b1cbef 100644 --- a/core/src/main/java/org/bitcoinj/core/ECKey.java +++ b/core/src/main/java/org/bitcoinj/core/ECKey.java @@ -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)); }