Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elliptic

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elliptic - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0

lib/elliptic/eddsa/index.js

1

lib/elliptic.js

@@ -14,1 +14,2 @@ 'use strict';

elliptic.ec = require('./elliptic/ec');
elliptic.eddsa = require('./elliptic/eddsa');

@@ -50,3 +50,3 @@ 'use strict';

EdwardsCurve.prototype.pointFromX = function pointFromX(odd, x) {
EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
x = new bn(x, 16);

@@ -65,5 +65,33 @@ if (!x.red)

return this.point(x, y, curve.one);
return this.point(x, y);
};
EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
y = new bn(y, 16);
if (!y.red)
y = y.toRed(this.red);
// x^2 = (y^2 - 1) / (d y^2 + 1)
var y2 = y.redSqr();
var lhs = y2.redSub(this.one);
var rhs = y2.redMul(this.d).redAdd(this.one);
var x2 = lhs.redMul(rhs.redInvm());
if (x2.cmp(this.zero) === 0) {
if (odd)
throw new Error('invalid point');
else
return this.point(this.zero, y);
}
var x = x2.redSqrt();
if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
throw new Error('invalid point');
if (x.isOdd() !== odd)
x = x.redNeg();
return this.point(x, y);
};
EdwardsCurve.prototype.validate = function validate(point) {

@@ -371,4 +399,10 @@ if (point.isInfinity())

Point.prototype.eq = function eq(other) {
return this === other ||
this.getX().cmp(other.getX()) === 0 &&
this.getY().cmp(other.getY()) === 0;
};
// Compatibility with BaseCurve
Point.prototype.toP = Point.prototype.normalize;
Point.prototype.mixedAdd = Point.prototype.add;

2

lib/elliptic/curve/short.js

@@ -188,3 +188,3 @@ 'use strict';

ShortCurve.prototype.pointFromX = function pointFromX(odd, x) {
ShortCurve.prototype.pointFromX = function pointFromX(x, odd) {
x = new bn(x, 16);

@@ -191,0 +191,0 @@ if (!x.red)

@@ -188,3 +188,3 @@ 'use strict';

// 1.1. Let x = r + jn.
r = this.curve.pointFromX(isYOdd, r);
r = this.curve.pointFromX(r, isYOdd);
var eNeg = e.neg().mod(n);

@@ -191,0 +191,0 @@

@@ -125,3 +125,3 @@ 'use strict';

} else if ((key[0] === 0x02 || key[0] === 0x03) && key.length - 1 === len) {
this.pub = this.ec.curve.pointFromX(key[0] === 0x03, key.slice(1, 1 + len));
this.pub = this.ec.curve.pointFromX(key.slice(1, 1 + len), key[0] === 0x03);
}

@@ -128,0 +128,0 @@ };

'use strict';
var utils = exports;
var bn = require('bn.js');

@@ -151,1 +152,51 @@ utils.assert = function assert(val, msg) {

utils.getJSF = getJSF;
function lazyComputed(obj, name, computer) {
var key = '_' + name;
obj.prototype[name] = function lazyComputed() {
return this[key] !== undefined ? this[key] :
this[key] = computer.apply(this, arguments);
};
}
utils.lazyComputed = lazyComputed;
function parseBytes(bytes) {
return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
bytes;
}
utils.parseBytes = parseBytes;
function intFromLE(bytes) {
return new bn(bytes, 'hex', 'le');
}
utils.intFromLE = intFromLE;
function intToLE(num, padTo) {
var bytes = num.toArray('le');
while (bytes.length < padTo)
bytes.push(0);
return bytes;
}
utils.intToLE = intToLE;
function pointToLEYoddX(point, length) {
var enc = intToLE(point.getY(), length);
enc[length - 1] |= point.getX().isOdd() ? 0x80 : 0;
return enc;
}
utils.pointToLEYoddX = pointToLEYoddX;
function pointFromLEYoddX(curve, bytes, expectedLength) {
bytes = parseBytes(bytes);
if (expectedLength !== undefined)
utils.assert(bytes.length === expectedLength);
var lastIx = bytes.length - 1;
var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
var xIsOdd = Boolean(bytes[lastIx] & 0x80);
var y = intFromLE(normed);
return curve.pointFromY(y, xIsOdd);
}
utils.pointFromLEYoddX = pointFromLEYoddX;
{
"name": "elliptic",
"version": "3.1.0",
"version": "4.0.0",
"description": "EC cryptography",

@@ -33,3 +33,3 @@ "main": "lib/elliptic.js",

"dependencies": {
"bn.js": "^2.0.3",
"bn.js": "^2.1.0",
"brorand": "^1.0.1",

@@ -36,0 +36,0 @@ "hash.js": "^1.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc