Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Don't mutate the elliptic curve prototype with get* additions #238

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bitcore-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -2084,27 +2084,27 @@ Point.getN = function getN() {
return new BN(ec.curve.n.toArray());
};

Point.prototype._getX = Point.prototype.getX;
Point._getX = Point.prototype.getX;

/**
*
* Will return the X coordinate of the Point
*
* @returns {BN} A BN instance of the X coordinate
*/
Point.prototype.getX = function getX() {
Point.getX = function getX() {
return new BN(this._getX().toArray());
};

Point.prototype._getY = Point.prototype.getY;
Point._getY = Point.prototype.getY;

/**
*
* Will return the Y coordinate of the Point
*
* @returns {BN} A BN instance of the Y coordinate
*/
Point.prototype.getY = function getY() {
Point.getY = function getY() {
return new BN(this._getY().toArray());
};

Expand Down
8 changes: 4 additions & 4 deletions lib/crypto/point.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,27 @@ Point.getN = function getN() {
return new BN(ec.curve.n.toArray());
};

Point.prototype._getX = Point.prototype.getX;
Point._getX = Point.prototype.getX;

/**
*
* Will return the X coordinate of the Point
*
* @returns {BN} A BN instance of the X coordinate
*/
Point.prototype.getX = function getX() {
Point.getX = function getX() {
return new BN(this._getX().toArray());
};

Point.prototype._getY = Point.prototype.getY;
Point._getY = Point.prototype.getY;

/**
*
* Will return the Y coordinate of the Point
*
* @returns {BN} A BN instance of the Y coordinate
*/
Point.prototype.getY = function getY() {
Point.getY = function getY() {
return new BN(this._getY().toArray());
};

Expand Down