From 2ed5290a4e34ea6dd1eed4e6efa12e6bb6940fb2 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Sat, 9 Aug 2014 19:03:59 -0700 Subject: [PATCH] make "new Point()" work --- lib/point.js | 7 ++++++- test/test.point.js | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/point.js b/lib/point.js index 6a301c5..27b4b1f 100644 --- a/lib/point.js +++ b/lib/point.js @@ -2,9 +2,14 @@ var bn = require('./bn'); var elliptic = require('elliptic'); var ec = elliptic.curves.secp256k1; -var Point = ec.curve.point.bind(ec.curve) +var ecpoint = ec.curve.point.bind(ec.curve) var p = ec.curve.point(); var Curve = Object.getPrototypeOf(ec.curve); + +var Point = function Point(x, y, isRed) { + return ecpoint(x, y, isRed); +}; + Point.prototype = Object.getPrototypeOf(p); Point.fromX = ec.curve.pointFromX.bind(ec.curve); diff --git a/test/test.point.js b/test/test.point.js index 272b399..bf5e078 100644 --- a/test/test.point.js +++ b/test/test.point.js @@ -8,6 +8,11 @@ describe('point', function() { var p = point(); should.exist(p); }); + + it('should create a point when called with "new"', function() { + var p = new point(); + should.exist(p); + }); describe('#getX', function() {