Files: 8ebcb5459250b77731dc4bd9153842fe0de7ea62 / sodium.js
724 bytesRaw
1 | |
2 | var sodium = require('chloride') |
3 | |
4 | module.exports = { |
5 | |
6 | curves: ['ed25519'], |
7 | |
8 | generate: function (seed) { |
9 | if(!seed) sodium.randombytes(seed = new Buffer(32)) |
10 | |
11 | var keys = seed ? sodium.crypto_sign_seed_keypair(seed) : sodium.crypto_sign_keypair() |
12 | return { |
13 | curve: 'ed25519', |
14 | public: keys.publicKey, |
15 | |
16 | //so that this works with either sodium |
17 | //or libsodium-wrappers (in browser) |
18 | private: keys.privateKey || keys.secretKey |
19 | } |
20 | }, |
21 | |
22 | sign: function (privateKey, message) { |
23 | return sodium.crypto_sign_detached(message, privateKey) |
24 | }, |
25 | |
26 | verify: function (publicKey, sig, message) { |
27 | return sodium.crypto_sign_verify_detached(sig, message, publicKey) |
28 | } |
29 | |
30 | } |
31 | |
32 | |
33 | |
34 | |
35 | |
36 |
Built with git-ssb-web