git ssb

1+

Dominic / ssb-keys



Tree: 846e0d32e32e26a7f44d1af8f6315b457b5070a1

Files: 846e0d32e32e26a7f44d1af8f6315b457b5070a1 / sodium.js

642 bytesRaw
1
2var sodium = require('sodium').api
3var crypto = require('crypto')
4
5module.exports = {
6
7 curves: ['ed25519'],
8
9 generate: function () {
10 var keys = sodium.crypto_sign_keypair(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