bitcore/lib/point.js

33 lines
778 B
JavaScript
Raw Normal View History

2014-08-06 21:02:42 -07:00
var bn = require('./bn');
var elliptic = require('elliptic');
var ec = elliptic.curves.secp256k1;
var Point = ec.curve.point.bind(ec.curve)
var p = ec.curve.point();
var Curve = Object.getPrototypeOf(ec.curve);
Point.prototype = Object.getPrototypeOf(p);
Point.fromX = ec.curve.pointFromX.bind(ec.curve);
2014-08-06 21:02:42 -07:00
Point.getG = function() {
var p = Point(ec.curve.g.getX(), ec.curve.g.getY());
return p;
};
Point.getN = function() {
return bn(ec.curve.n.toArray());
};
Point.prototype._getX = Point.prototype.getX;
Point.prototype.getX = function() {
var n = bn(this._getX().toArray());
return bn(this._getX().toArray());
};
Point.prototype._getY = Point.prototype.getY;
Point.prototype.getY = function() {
return bn(this._getY().toArray());
};
module.exports = Point;