git ssb

1+

Dominic / ssb-keys



Tree: 8b52b7ecea8ab1b620f0792ae50a374a609b0434

Files: 8b52b7ecea8ab1b620f0792ae50a374a609b0434 / sodium.js

712 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 (privateKey, message) {
23 return sodium.crypto_sign_detached(message, privateKey)
24 },
25
26 verify: function (publicKey, sig, message) {
27 return sodium.crypto_sign_verify_detached(sig, message, publicKey)
28 }
29
30}
31
32
33
34
35
36

Built with git-ssb-web