git ssb

1+

Dominic / ssb-keys



Commit 2bfa7a857707dbc8be5e4797eccfaeefe06e86ff

remove crypto module, for small browserify bundles

Dominic Tarr committed on 7/30/2016, 2:13:55 AM
Parent: 35f01e244d51a175bff0cc2e1b9ff04b86c9f868

Files changed

index.jschanged
sodium.jschanged
util.jschanged
index.jsView
@@ -1,8 +1,6 @@
11 var deepEqual = require('deep-equal')
22
3-var createHmac = require('hmac')
4-
53 var sodium = require('chloride')
64 var ssbref = require('ssb-ref')
75
86 var pb = require('private-box')
@@ -130,13 +128,8 @@
130128 }
131129
132130 // OTHER CRYTPO FUNCTIONS
133131
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-
139132 exports.signObj = function (keys, obj) {
140133 var _obj = clone(obj)
141134 var b = new Buffer(JSON.stringify(_obj, null, 2))
142135 _obj.signature = exports.sign(keys, b)
@@ -173,4 +166,7 @@
173166 if(msg) return JSON.parse(''+msg)
174167 }
175168
176169
170+
171+
172+
sodium.jsView
@@ -1,14 +1,14 @@
11
22 var sodium = require('chloride')
3-var crypto = require('crypto')
43
54 module.exports = {
65
76 curves: ['ed25519'],
87
98 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()
1111 return {
1212 curve: 'ed25519',
1313 public: keys.publicKey,
1414
@@ -26,4 +26,7 @@
2626 return sodium.crypto_sign_verify_detached(sig, message, public)
2727 }
2828
2929 }
30+
31+
32+
util.jsView
@@ -1,13 +1,13 @@
1-var crypto = require('crypto')
1+var cl = require('chloride')
22
33 exports.hash = function (data, enc) {
44 data = (
55 'string' === typeof data && enc == null
66 ? new Buffer(data, 'binary')
77 : new Buffer(data, enc)
88 )
9- return crypto.createHash('sha256').update(data).digest('base64')+'.sha256'
9+ return cl.crypto_hash_sha256(data).toString('base64')+'.sha256'
1010 }
1111
1212 exports.hasSigil = function hasSigil (s) {
1313 return /^(@|%|&)/.test(s)
@@ -63,4 +63,5 @@
6363 //}
6464
6565
6666
67+

Built with git-ssb-web