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