@@ -48,9 +48,9 @@ window.axolotl(...)
48
48
### Dependencies
49
49
50
50
libaxolotl-javascript depends on [ traceur-runtime] ( https://github.com/google/traceur-compiler ) and
51
- [ protobuf.js] ( https://github.com/dcodeIO/ProtoBuf.js ) . These dependencies are not included in the distributed package .
52
- If you installed libaxolotl-javascript using npm then there is nothing more you need to do - npm will download these
53
- dependencies for you.
51
+ [ protobuf.js] ( https://github.com/dcodeIO/ProtoBuf.js ) and [ cryptographic primitives ] ( blob/master/doc/crypto.md ) .
52
+ These dependencies are not included in the distributed package. If you installed libaxolotl-javascript using npm then
53
+ there is nothing more you need to do - npm will download these dependencies for you.
54
54
55
55
If you are using libaxolotl-javascript in the browser, you will have to provide the library's dependencies yourself. If
56
56
you're using AMD, then simply provide the location of these dependencies in your AMD configuration. Otherwise, include
@@ -192,137 +192,12 @@ Name|Type|Description
192
192
` identity ` |Identity|The identity.
193
193
` sessionState ` |String|The serialised session state.
194
194
195
- ### The Crypto interface
196
-
197
- You need to provide an implementation of the ` Crypto ` interface when instantiating Axolotl. This is an object that
198
- has the following methods.
199
-
200
- * Note that all methods may return a Promise if the operation is asynchronous.*
201
-
202
- #### generateKeyPair
203
-
204
- ```
205
- generateKeyPair() → {KeyPair}
206
- ```
207
-
208
- Generate a fresh, random [ Curve25519] ( http://en.wikipedia.org/wiki/Curve25519 ) public/private key pair suitable for use
209
- with Diffie-Hellman key agreements. The returned private key should be an ArrayBuffer consisting of 32 bytes. The
210
- returned public key should be an ArrayBuffer consisting of 33 bytes, where the first byte is equal to ` 0x05 ` .
211
-
212
- #### calculateAgreement
213
-
214
- ```
215
- calculateAgreement(theirPublicKey, ourPrivateKey) → {ArrayBuffer}
216
- ```
217
-
218
- Compute a [ Curve25519] ( http://en.wikipedia.org/wiki/Curve25519 ) Diffie-Hellman key agreement.
219
-
220
- ##### Parameters
221
-
222
- Name|Type|Description
223
- :---|:---|:----------
224
- ` theirPublicKey ` |ArrayBuffer|Their 33 byte public key.
225
- ` ourPrivateKey ` |ArrayBuffer|Our 32 byte private key.
226
-
227
- #### randomBytes
228
-
229
- ```
230
- randomBytes(byteCount) → {ArrayBuffer}
231
- ```
232
-
233
- Generate ` byteCount ` bytes of cryptographically secure random data and return as an ArrayBuffer.
234
-
235
- ##### Parameters
236
-
237
- Name|Type|Description
238
- :---|:---|:----------
239
- ` byteCount ` |Number|The number of bytes to generate.
240
-
241
- #### sign
242
-
243
- ```
244
- sign(privateKey, dataToSign) → {ArrayBuffer}
245
- ```
246
-
247
- Produce an [ Ed25519] ( http://en.wikipedia.org/wiki/EdDSA ) signature. The returned signature should be an ArrayBuffer
248
- consisting of 64 bytes.
249
-
250
- ##### Parameters
251
-
252
- Name|Type|Description
253
- :---|:---|:----------
254
- ` privateKey ` |ArrayBuffer|The 32 byte private key to use to generate the signature.
255
- ` dataToSign ` |ArrayBuffer|The data to be signed. May be any length.
256
-
257
- #### verifySignature
258
-
259
- ```
260
- verifySignature(publicKey, dataToSign, purportedSignature) → {Boolean}
261
- ```
262
-
263
- Verify an [ Ed25519] ( http://en.wikipedia.org/wiki/EdDSA ) signature.
264
-
265
- ##### Parameters
266
-
267
- Name|Type|Description
268
- :---|:---|:----------
269
- ` privateKey ` |ArrayBuffer|The 33 byte public half of the key used to produce the signature.
270
- ` dataToSign ` |ArrayBuffer|The data that was signed. May be any length.
271
- ` purportedSignature ` |ArrayBuffer|The purported signature to check.
272
-
273
- #### hmac
274
-
275
- ```
276
- hmac(key, data) → {ArrayBuffer}
277
- ```
278
-
279
- Produce a HMAC-HASH using SHA-256. The returned ArrayBuffer should consist of 32 bytes.
280
-
281
- ##### Parameters
282
-
283
- Name|Type|Description
284
- :---|:---|:----------
285
- ` key ` |ArrayBuffer|The mac key. May be any length.
286
- ` data ` |ArrayBuffer|The data to be hashed. May be any length.
287
-
288
- #### encrypt
289
-
290
- ```
291
- encrypt(key, plaintext, iv) → {ArrayBuffer}
292
- ```
293
-
294
- Encrypt the ` plaintext ` using AES-256-CBC.
295
-
296
- ##### Parameters
297
-
298
- Name|Type|Description
299
- :---|:---|:----------
300
- ` key ` |ArrayBuffer|The 32 byte cipher key.
301
- ` plaintext ` |ArrayBuffer|The data to be encrypted. May be any length.
302
- ` iv ` |ArrayBuffer|A 16 byte random initialisation vector.
303
-
304
- #### decrypt
305
-
306
- ```
307
- decrypt(key, ciphertext, iv) → {ArrayBuffer}
308
- ```
309
-
310
- Decrypt the ` ciphertext ` using AES-256-CBC.
311
-
312
- ##### Parameters
313
-
314
- Name|Type|Description
315
- :---|:---|:----------
316
- ` key ` |ArrayBuffer|The 32 byte cipher key used to encrypt the data.
317
- ` ciphertext ` |ArrayBuffer|The data to be decrypted. Should have a length that is a multiple of 16 bytes.
318
- ` iv ` |ArrayBuffer|The 16 byte initialisation vector used to encrypt the data.
319
-
320
195
### Using Axolotl
321
196
322
197
Start by instantiating Axolotl:
323
198
324
199
``` javascript
325
- var axol = axolotl (crypto, store);
200
+ var axol = axolotl (store);
326
201
```
327
202
328
203
When your application is first installed, the client will likely need to register with the server. To do this, a number
0 commit comments