@@ -9,18 +9,21 @@ var BigInteger = require('bigi')
99var ECPubKey = require ( './ecpubkey' )
1010
1111var ecurve = require ( 'ecurve' )
12- var curve = ecurve . getCurveByName ( 'secp256k1' )
12+ var secp256k1 = ecurve . getCurveByName ( 'secp256k1' )
1313
1414function ECKey ( d , compressed ) {
1515 assert ( d . signum ( ) > 0 , 'Private key must be greater than 0' )
16- assert ( d . compareTo ( curve . n ) < 0 , 'Private key must be less than the curve order' )
16+ assert ( d . compareTo ( ECKey . curve . n ) < 0 , 'Private key must be less than the curve order' )
1717
18- var Q = curve . G . multiply ( d )
18+ var Q = ECKey . curve . G . multiply ( d )
1919
2020 this . d = d
2121 this . pub = new ECPubKey ( Q , compressed )
2222}
2323
24+ // Constants
25+ ECKey . curve = secp256k1
26+
2427// Static constructors
2528ECKey . fromWIF = function ( string ) {
2629 var payload = base58check . decode ( string )
@@ -51,7 +54,7 @@ ECKey.makeRandom = function(compressed, rng) {
5154 assert . equal ( buffer . length , 32 , 'Expected 256-bit Buffer from RNG' )
5255
5356 var d = BigInteger . fromBuffer ( buffer )
54- d = d . mod ( curve . n )
57+ d = d . mod ( ECKey . curve . n )
5558
5659 return new ECKey ( d , compressed )
5760}
@@ -75,7 +78,7 @@ ECKey.prototype.toWIF = function(network) {
7578
7679// Operations
7780ECKey . prototype . sign = function ( hash ) {
78- return ecdsa . sign ( curve , hash , this . d )
81+ return ecdsa . sign ( ECKey . curve , hash , this . d )
7982}
8083
8184module . exports = ECKey
0 commit comments