git ssb

1+

Dominic / ssb-keys



Tree: cf80538bda5715b7fddc0dc1ffdab001895d0ac9

Files: cf80538bda5715b7fddc0dc1ffdab001895d0ac9 / sodium.js

659 bytesRaw
1
2var sodium = require('sodium').api
3var crypto = require('crypto')
4
5module.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