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 6.4 2 #67

Open
wants to merge 3 commits 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions karma.conf.js
Expand Up @@ -3,15 +3,15 @@
module.exports = function(config) {

config.set({
browsers: ['Firefox'],
browsers: ['PhantomJS'],
frameworks: ['mocha'],
singleRun: true,
files: [
'./tests.js'
],
plugins: [
'karma-mocha',
'karma-firefox-launcher'
'karma-phantomjs-launcher'
]
});

Expand Down
8 changes: 4 additions & 4 deletions lib/bitauth-browserify.js
@@ -1,7 +1,7 @@
'use strict';

var elliptic = require('elliptic');
var ecdsa = new elliptic.ec(elliptic.curves.secp256k1);
var EC = require('elliptic').ec;
var ecdsa = new EC('secp256k1');

var BitAuth = require('./bitauth-common');

Expand All @@ -19,7 +19,7 @@ BitAuth._getPublicKeyFromPrivateKey = function(privkey) {
} else {
privKeyString = privkey;
}
var keys = ecdsa.keyPair(privkey, 'hex');
var keys = ecdsa.keyFromPrivate(privKeyString, 'hex');

// compressed public key
var pubKey = keys.getPublic();
Expand All @@ -42,7 +42,7 @@ BitAuth._sign = function(hashBuffer, privkey) {
};

BitAuth._verifySignature = function(hashBuffer, signatureBuffer, pubkey) {
return ecdsa.verify(hashBuffer.toString('hex'), signatureBuffer, pubkey);
return ecdsa.verify(hashBuffer.toString('hex'), signatureBuffer, pubkey, 'hex');
};

module.exports = BitAuth;
3 changes: 3 additions & 0 deletions lib/bitauth-common.js
Expand Up @@ -104,13 +104,16 @@ BitAuth.sign = function(data, privkey) {
*/
BitAuth.verifySignature = function(data, pubkey, hexsignature, callback) {
var dataBuffer;

if (!Buffer.isBuffer(data)) {
dataBuffer = new Buffer(data, 'utf8');
} else {
dataBuffer = data;
}

var hashBuffer = crypto.createHash('sha256').update(dataBuffer).digest();
var signatureBuffer;

if (!Buffer.isBuffer(hexsignature)) {
signatureBuffer = new Buffer(hexsignature, 'hex');
} else {
Expand Down
17 changes: 9 additions & 8 deletions package.json
Expand Up @@ -31,7 +31,8 @@
"version": "0.3.2",
"dependencies": {
"bs58": "^2.0.0",
"elliptic": "=1.0.0",
"elliptic": "=6.4.0",
"karma-chrome-launcher": "^2.2.0",
"secp256k1": "=1.1.5"
},
"devDependencies": {
Expand All @@ -41,16 +42,16 @@
"bundle-collapser": "^1.2.1",
"chai": "=1.9.1",
"express": "^4.13.3",
"gulp": "^3.8.10",
"gulp": "^3.9.1",
"gulp-bump": "^0.1.11",
"gulp-git": "^0.5.5",
"gulp-git": "^2.5.1",
"gulp-mocha": "^2.0.0",
"gulp-shell": "^0.2.10",
"karma": "^0.13.9",
"karma-firefox-launcher": "^0.1.4",
"karma-mocha": "^0.1.9",
"mocha": "~1.20.1",
"request": "^2.65.0",
"karma": "^2.0.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.4",
"mocha": "^5.0.0",
"request": "^2.83.0",
"run-sequence": "^1.0.2",
"uglify-js": "~2.4.14"
},
Expand Down