From b6d067ec935dd49fce550a25315c756ac8114b34 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 4 Jul 2018 14:30:18 -0700 Subject: [PATCH] consensus: fail early on pow check when target > 256 bits. --- lib/protocol/consensus.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/protocol/consensus.js b/lib/protocol/consensus.js index d144108a..36f8e072 100644 --- a/lib/protocol/consensus.js +++ b/lib/protocol/consensus.js @@ -323,6 +323,9 @@ exports.verifyPOW = function verifyPOW(hash, bits) { if (target.isNeg() || target.isZero()) return false; + if (target.bitLength() > 256) + return false; + const num = new BN(hash, 'le'); if (num.gt(target))