git ssb

1+

Dominic / ssb-keys



Tree: 6c7f3d57c075b5250295383f964469552f713d1d

Files: 6c7f3d57c075b5250295383f964469552f713d1d / sodium.js

661 bytesRaw
1
2var sodium = require('chloride').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