Commit 4303c41cef3eb136a15a3adeffe559314bc53a3b
fix syntax bugs
Dominic Tarr committed on 11/20/2014, 7:56:59 PMParent: bda63326e87aca8b09964b6bf51fa604ae0b39f9
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -4,12 +4,12 @@ | ||
4 | 4 | var k256 = ecc.curves.k256 |
5 | 5 | var Blake2s = require('blake2s') |
6 | 6 | var mkdirp = require('mkdirp') |
7 | 7 | var path = require('path') |
8 | -var curve = ecc.curves.k256 | |
8 | +var curve = ecc.curves.k256 | |
9 | +var createHmac = require('hmac') | |
9 | 10 | |
10 | 11 | |
11 | - | |
12 | 12 | function hash (data, enc) { |
13 | 13 | return new Blake2s().update(data, enc).digest('base64') + '.blake2s' |
14 | 14 | } |
15 | 15 | |
@@ -24,9 +24,8 @@ | ||
24 | 24 | function isString(s) { |
25 | 25 | return 'string' === typeof s |
26 | 26 | } |
27 | 27 | |
28 | - | |
29 | 28 | function empty(v) { return !!v } |
30 | 29 | |
31 | 30 | function constructKeys() { |
32 | 31 | var privateKey = crypto.randomBytes(32) |
@@ -144,9 +143,9 @@ | ||
144 | 143 | // {public: Buffer, private: Buffer} |
145 | 144 | |
146 | 145 | exports.generate = function () { |
147 | 146 | return keysToBase64(ecc.restore(curve, crypto.randomBytes(32))) |
148 | -}, | |
147 | +} | |
149 | 148 | |
150 | 149 | //takes a public key and a hash and returns a signature. |
151 | 150 | //(a signature must be a node buffer) |
152 | 151 | exports.sign = function (keys, hash) { |
@@ -154,17 +153,16 @@ | ||
154 | 153 | return tag( |
155 | 154 | ecc.sign(curve, keysToBuffer(keys), hashToBuffer(hash)), |
156 | 155 | hashTag + '.k256' |
157 | 156 | ) |
158 | -}, | |
157 | +} | |
159 | 158 | |
160 | 159 | //takes a public key, signature, and a hash |
161 | 160 | //and returns true if the signature was valid. |
162 | 161 | exports.verify = function (pub, sig, hash) { |
163 | 162 | return ecc.verify(curve, keysToBuffer(pub), toBuffer(sig), hashToBuffer(hash)) |
164 | -}, | |
163 | +} | |
165 | 164 | |
166 | - | |
167 | 165 | function createHash() { |
168 | 166 | return new Blake2s() |
169 | 167 | } |
170 | 168 |
Built with git-ssb-web