Skip to content

Commit

Permalink
fix verify + change to phantomjs browser
Browse files Browse the repository at this point in the history
  • Loading branch information
matiu committed Jan 29, 2018
1 parent cc517c9 commit 01d9730
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions karma.conf.js
Expand Up @@ -3,15 +3,15 @@
module.exports = function(config) {

config.set({
browsers: ['Firefox'],

This comment has been minimized.

Copy link
@AlenaDurdova
browsers: ['PhantomJS'],
frameworks: ['mocha'],
singleRun: true,
files: [
'./tests.js'
],
plugins: [
'karma-mocha',
'karma-firefox-launcher'
'karma-phantomjs-launcher'
]
});

Expand Down
4 changes: 2 additions & 2 deletions lib/bitauth-browserify.js
Expand Up @@ -19,7 +19,7 @@ BitAuth._getPublicKeyFromPrivateKey = function(privkey) {
} else {
privKeyString = privkey;
}
var keys = ecdsa.keyFromPrivate(privKeyString, '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
15 changes: 8 additions & 7 deletions package.json
Expand Up @@ -32,6 +32,7 @@
"dependencies": {
"bs58": "^2.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

0 comments on commit 01d9730

Please sign in to comment.