Commit d8e28e38a387d460308701a089afb9674986874c
put hash in the sign methods, more consistent with sodium
Dominic Tarr committed on 7/5/2015, 1:27:30 AMParent: 3960a137f68a96eca62ddb1394b60381b459c4a6
Files changed
eccjs.js | changed |
eccjs.js | ||
---|---|---|
@@ -1,11 +1,16 @@ | ||
1 | 1 | |
2 | 2 | |
3 | 3 | var ecc = require('eccjs') |
4 | 4 | var crypto = require('crypto') |
5 | +var Blake2s = require('blake2s') | |
5 | 6 | |
6 | 7 | var curve = ecc.curves.k256 |
7 | 8 | |
9 | +function hash (message) { | |
10 | + return new Blake2s().update(message).digest() | |
11 | +} | |
12 | + | |
8 | 13 | module.exports = { |
9 | 14 | |
10 | 15 | curves: ['k256'], |
11 | 16 | |
@@ -24,13 +29,13 @@ | ||
24 | 29 | } |
25 | 30 | }, |
26 | 31 | |
27 | 32 | sign: function (private, message) { |
28 | - return ecc.sign(curve, private, message) | |
33 | + return ecc.sign(curve, private, hash(message)) | |
29 | 34 | }, |
30 | 35 | |
31 | 36 | verify: function (public, sig, message) { |
32 | - return ecc.verify(curve, public, sig, message) | |
37 | + return ecc.verify(curve, public, sig, hash(message)) | |
33 | 38 | }, |
34 | 39 | |
35 | 40 | restore: function (seed) { |
36 | 41 | return ecc.restore(curve, seed) |
Built with git-ssb-web