From 0ce32bec928fda08210832fe2dd2364a0d5cc8b3 Mon Sep 17 00:00:00 2001 From: Bart Butler Date: Sun, 8 Feb 2015 21:20:07 -0800 Subject: [PATCH] Need to use compareTo when comparing BigIntegers, otherwise get a string comparison with lexical order --- src/crypto/random.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/random.js b/src/crypto/random.js index c4760823..1cd82250 100644 --- a/src/crypto/random.js +++ b/src/crypto/random.js @@ -124,7 +124,7 @@ module.exports = { var range = max.subtract(min); var r = this.getRandomBigInteger(range.bitLength()); - while (r > range) { + while (r.compareTo(range) > 0) { r = this.getRandomBigInteger(range.bitLength()); } return min.add(r);