|
|
@ -1,5 +1,5 @@ |
|
|
|
var BN = require('./bn'); |
|
|
|
var point = require('./point'); |
|
|
|
var Point = require('./point'); |
|
|
|
var constants = require('./constants'); |
|
|
|
var base58check = require('./base58check'); |
|
|
|
var Random = require('./random'); |
|
|
@ -22,14 +22,14 @@ Privkey.prototype.fromRandom = function() { |
|
|
|
do { |
|
|
|
var privbuf = Random.getRandomBuffer(32); |
|
|
|
var bn = BN().fromBuffer(privbuf); |
|
|
|
var condition = bn.lt(point.getN()); |
|
|
|
var condition = bn.lt(Point.getN()); |
|
|
|
} while (!condition); |
|
|
|
this.bn = bn; |
|
|
|
return this; |
|
|
|
}; |
|
|
|
|
|
|
|
Privkey.prototype.validate = function() { |
|
|
|
if (!this.bn.lt(point.getN())) |
|
|
|
if (!this.bn.lt(Point.getN())) |
|
|
|
throw new Error('Number must be less than N'); |
|
|
|
if (typeof constants[this.networkstr] === undefined) |
|
|
|
throw new Error('Must specify the networkstr ("mainnet" or "testnet")'); |
|
|
|