git ssb

1+

Dominic / ssb-keys



Tree: 150dab4b419db66ba26beb8087fbb9ac15b6f323

Files: 150dab4b419db66ba26beb8087fbb9ac15b6f323 / sodium.js

700 bytesRaw
1
2var sodium = require('chloride')
3
4module.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 (private, message) {
23 return sodium.crypto_sign_detached(message, private)
24 },
25
26 verify: function (public, sig, message) {
27 return sodium.crypto_sign_verify_detached(sig, message, public)
28 }
29
30}
31
32
33
34
35
36

Built with git-ssb-web