diff --git a/lib/crypto/point.js b/lib/crypto/point.js index f635b3e1f..85f2431e7 100644 --- a/lib/crypto/point.js +++ b/lib/crypto/point.js @@ -2,9 +2,8 @@ var BN = require('./bn'); var bufferUtil = require('../util/buffer'); -var ec = require('elliptic').curves.secp256k1; -var ecPoint = ec.curve.point.bind(ec.curve); -var ecPointFromX = ec.curve.pointFromX.bind(ec.curve); +var EC = require('elliptic').ec; +var ec = new EC('secp256k1'); /** * @@ -19,7 +18,7 @@ var ecPointFromX = ec.curve.pointFromX.bind(ec.curve); * @constructor */ var Point = function Point(x, y, isRed) { - var point = ecPoint(x, y, isRed); + var point = ec.curve.point(x, y, isRed); point.validate(); return point; }; @@ -36,7 +35,7 @@ Point.prototype = Object.getPrototypeOf(ec.curve.point()); * @returns {Point} An instance of Point */ Point.fromX = function fromX(odd, x){ - var point = ecPointFromX(odd, x); + var point = ec.curve.pointFromX(odd, x); point.validate(); return point; }; @@ -49,7 +48,7 @@ Point.fromX = function fromX(odd, x){ * @returns {Point} An instance of the base point. */ Point.getG = function getG() { - return Point(ec.curve.g.getX(), ec.curve.g.getY()); + return ec.curve.g; }; /** @@ -106,7 +105,7 @@ Point.prototype.validate = function validate() { throw new Error('Invalid x,y value for curve, cannot equal 0.'); } - var p2 = ecPointFromX(this.getY().isOdd(), this.getX()); + var p2 = ec.curve.pointFromX(this.getY().isOdd(), this.getX()); if (p2.y.cmp(this.y) !== 0) { throw new Error('Invalid y value for curve.');