Commit 2bfa7a857707dbc8be5e4797eccfaeefe06e86ff
remove crypto module, for small browserify bundles
Dominic Tarr committed on 7/30/2016, 2:13:55 AMParent: 35f01e244d51a175bff0cc2e1b9ff04b86c9f868
Files changed
index.js | changed |
sodium.js | changed |
util.js | changed |
index.js | ||
---|---|---|
@@ -1,8 +1,6 @@ | ||
1 | 1 | var deepEqual = require('deep-equal') |
2 | 2 | |
3 | -var createHmac = require('hmac') | |
4 | - | |
5 | 3 | var sodium = require('chloride') |
6 | 4 | var ssbref = require('ssb-ref') |
7 | 5 | |
8 | 6 | var pb = require('private-box') |
@@ -130,13 +128,8 @@ | ||
130 | 128 | } |
131 | 129 | |
132 | 130 | // OTHER CRYTPO FUNCTIONS |
133 | 131 | |
134 | -exports.hmac = function (data, key) { //no longer used, pretty sure. | |
135 | - return createHmac(createHash, 64, key) | |
136 | - .update(data).digest('base64')+'.sha256.hmac' | |
137 | -} | |
138 | - | |
139 | 132 | exports.signObj = function (keys, obj) { |
140 | 133 | var _obj = clone(obj) |
141 | 134 | var b = new Buffer(JSON.stringify(_obj, null, 2)) |
142 | 135 | _obj.signature = exports.sign(keys, b) |
@@ -173,4 +166,7 @@ | ||
173 | 166 | if(msg) return JSON.parse(''+msg) |
174 | 167 | } |
175 | 168 | |
176 | 169 | |
170 | + | |
171 | + | |
172 | + |
sodium.js | ||
---|---|---|
@@ -1,14 +1,14 @@ | ||
1 | 1 | |
2 | 2 | var sodium = require('chloride') |
3 | -var crypto = require('crypto') | |
4 | 3 | |
5 | 4 | module.exports = { |
6 | 5 | |
7 | 6 | curves: ['ed25519'], |
8 | 7 | |
9 | 8 | generate: function (seed) { |
10 | - var keys = sodium.crypto_sign_seed_keypair(seed || crypto.randomBytes(32)) | |
9 | + seed = seed || sodium.randombytes(seed = new Buffer(32)) | |
10 | + var keys = seed ? sodium.crypto_sign_seed_keypair(seed) : sodium.crypto_sign_keypair() | |
11 | 11 | return { |
12 | 12 | curve: 'ed25519', |
13 | 13 | public: keys.publicKey, |
14 | 14 | |
@@ -26,4 +26,7 @@ | ||
26 | 26 | return sodium.crypto_sign_verify_detached(sig, message, public) |
27 | 27 | } |
28 | 28 | |
29 | 29 | } |
30 | + | |
31 | + | |
32 | + |
util.js | ||
---|---|---|
@@ -1,13 +1,13 @@ | ||
1 | -var crypto = require('crypto') | |
1 | +var cl = require('chloride') | |
2 | 2 | |
3 | 3 | exports.hash = function (data, enc) { |
4 | 4 | data = ( |
5 | 5 | 'string' === typeof data && enc == null |
6 | 6 | ? new Buffer(data, 'binary') |
7 | 7 | : new Buffer(data, enc) |
8 | 8 | ) |
9 | - return crypto.createHash('sha256').update(data).digest('base64')+'.sha256' | |
9 | + return cl.crypto_hash_sha256(data).toString('base64')+'.sha256' | |
10 | 10 | } |
11 | 11 | |
12 | 12 | exports.hasSigil = function hasSigil (s) { |
13 | 13 | return /^(@|%|&)/.test(s) |
@@ -63,4 +63,5 @@ | ||
63 | 63 | //} |
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | + |
Built with git-ssb-web