Skip to content

Commit 01d9730

Browse files
committed
fix verify + change to phantomjs browser
1 parent cc517c9 commit 01d9730

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
module.exports = function(config) {
44

55
config.set({
6-
browsers: ['Firefox'],
6+
browsers: ['PhantomJS'],
77
frameworks: ['mocha'],
88
singleRun: true,
99
files: [
1010
'./tests.js'
1111
],
1212
plugins: [
1313
'karma-mocha',
14-
'karma-firefox-launcher'
14+
'karma-phantomjs-launcher'
1515
]
1616
});
1717

lib/bitauth-browserify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ BitAuth._getPublicKeyFromPrivateKey = function(privkey) {
1919
} else {
2020
privKeyString = privkey;
2121
}
22-
var keys = ecdsa.keyFromPrivate(privKeyString, 'hex')
22+
var keys = ecdsa.keyFromPrivate(privKeyString, 'hex');
2323

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

4444
BitAuth._verifySignature = function(hashBuffer, signatureBuffer, pubkey) {
45-
return ecdsa.verify(hashBuffer.toString('hex'), signatureBuffer, pubkey);
45+
return ecdsa.verify(hashBuffer.toString('hex'), signatureBuffer, pubkey, 'hex');
4646
};
4747

4848
module.exports = BitAuth;

lib/bitauth-common.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,16 @@ BitAuth.sign = function(data, privkey) {
104104
*/
105105
BitAuth.verifySignature = function(data, pubkey, hexsignature, callback) {
106106
var dataBuffer;
107+
107108
if (!Buffer.isBuffer(data)) {
108109
dataBuffer = new Buffer(data, 'utf8');
109110
} else {
110111
dataBuffer = data;
111112
}
113+
112114
var hashBuffer = crypto.createHash('sha256').update(dataBuffer).digest();
113115
var signatureBuffer;
116+
114117
if (!Buffer.isBuffer(hexsignature)) {
115118
signatureBuffer = new Buffer(hexsignature, 'hex');
116119
} else {

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"dependencies": {
3333
"bs58": "^2.0.0",
3434
"elliptic": "=6.4.0",
35+
"karma-chrome-launcher": "^2.2.0",
3536
"secp256k1": "=1.1.5"
3637
},
3738
"devDependencies": {
@@ -41,16 +42,16 @@
4142
"bundle-collapser": "^1.2.1",
4243
"chai": "=1.9.1",
4344
"express": "^4.13.3",
44-
"gulp": "^3.8.10",
45+
"gulp": "^3.9.1",
4546
"gulp-bump": "^0.1.11",
46-
"gulp-git": "^0.5.5",
47+
"gulp-git": "^2.5.1",
4748
"gulp-mocha": "^2.0.0",
4849
"gulp-shell": "^0.2.10",
49-
"karma": "^0.13.9",
50-
"karma-firefox-launcher": "^0.1.4",
51-
"karma-mocha": "^0.1.9",
52-
"mocha": "~1.20.1",
53-
"request": "^2.65.0",
50+
"karma": "^2.0.0",
51+
"karma-mocha": "^1.3.0",
52+
"karma-phantomjs-launcher": "^1.0.4",
53+
"mocha": "^5.0.0",
54+
"request": "^2.83.0",
5455
"run-sequence": "^1.0.2",
5556
"uglify-js": "~2.4.14"
5657
},

0 commit comments

Comments
 (0)