Files: f6c145b55243dd7497f5f1ce723bd4c4c4334b2f / eccjs.js
808 bytesRaw
1 | |
2 | |
3 | var ecc = require('eccjs') |
4 | var crypto = require('crypto') |
5 | |
6 | var curve = ecc.curves.k256 |
7 | |
8 | module.exports = { |
9 | |
10 | curves: ['k256'], |
11 | |
12 | generate: function () { |
13 | //we use eccjs.restore here, instead of eccjs.generate |
14 | //because we trust node's random generator much more than |
15 | //sjcl's (via crypto-browserify's polyfil this uses |
16 | //webcrypto's random generator in the browser) |
17 | |
18 | var keys = ecc.restore(curve, crypto.randomBytes(32)) |
19 | |
20 | return { |
21 | curve: 'k256', |
22 | public: keys.public, |
23 | private: keys.private |
24 | } |
25 | }, |
26 | |
27 | sign: function (private, message) { |
28 | return ecc.sign(curve, private, message) |
29 | }, |
30 | |
31 | verify: function (public, sig, message) { |
32 | return ecc.verify(curve, public, sig, message) |
33 | }, |
34 | |
35 | restore: function (seed) { |
36 | return ecc.restore(curve, seed) |
37 | } |
38 | |
39 | } |
40 |
Built with git-ssb-web