Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and fix Travis CI builds #18

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules/
.travis.yml
.gitignore
test.js
11 changes: 6 additions & 5 deletions browser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var elliptic = require('elliptic')
var BN = require('bn.js')
var Buffer = require('safe-buffer').Buffer

module.exports = function createECDH (curve) {
return new ECDH(curve)
Expand Down Expand Up @@ -61,7 +62,7 @@ ECDH.prototype.generateKeys = function (enc, format) {
ECDH.prototype.computeSecret = function (other, inenc, enc) {
inenc = inenc || 'utf8'
if (!Buffer.isBuffer(other)) {
other = new Buffer(other, inenc)
other = Buffer.from(other, inenc)
}
var otherPub = this.curve.keyFromPublic(other).getPublic()
var out = otherPub.mul(this.keys.getPrivate()).getX()
Expand All @@ -87,7 +88,7 @@ ECDH.prototype.getPrivateKey = function (enc) {
ECDH.prototype.setPublicKey = function (pub, enc) {
enc = enc || 'utf8'
if (!Buffer.isBuffer(pub)) {
pub = new Buffer(pub, enc)
pub = Buffer.from(pub, enc)
}
this.keys._importPublic(pub)
return this
Expand All @@ -96,7 +97,7 @@ ECDH.prototype.setPublicKey = function (pub, enc) {
ECDH.prototype.setPrivateKey = function (priv, enc) {
enc = enc || 'utf8'
if (!Buffer.isBuffer(priv)) {
priv = new Buffer(priv, enc)
priv = Buffer.from(priv, enc)
}

var _priv = new BN(priv)
Expand All @@ -110,9 +111,9 @@ function formatReturnValue (bn, enc, len) {
if (!Array.isArray(bn)) {
bn = bn.toArray()
}
var buf = new Buffer(bn)
var buf = Buffer.from(bn)
if (len && buf.length < len) {
var zeros = new Buffer(len - buf.length)
var zeros = Buffer.alloc(len - buf.length)
zeros.fill(0)
buf = Buffer.concat([zeros, buf])
}
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
},
"homepage": "https://github.com/crypto-browserify/createECDH",
"dependencies": {
"bn.js": "^4.1.0",
"elliptic": "^6.5.3"
"bn.js": "^5.1.3",
"elliptic": "^6.5.4",
"safe-buffer": "^5.2.1"
},
"devDependencies": {
"tap-spec": "^1.0.1",
"tape": "^3.0.1",
"tap-spec": "^5.0.0",
"tape": "^5.1.1",
"standard": "^5.4.1"
}
}