git ssb

1+

Dominic / ssb-keys



Tree: 847fc7720a79e522843771339cac8a07a7cbb0ec

Files: 847fc7720a79e522843771339cac8a07a7cbb0ec / browser-sodium.js

727 bytesRaw
1
2var sodium = require('libsodium-wrappers')
3var crypto = require('crypto')
4
5var B = Buffer
6
7function Ui8 (b) {
8 return new Uint8Array(b)
9}
10
11module.exports = {
12
13 curves: ['ed25519'],
14
15 generate: function () {
16 var keys = sodium.crypto_sign_keypair()
17 return {
18 curve: 'ed25519',
19 public: B(keys.publicKey),
20
21 //so that this works with either sodium
22 //or libsodium-wrappers (in browser)
23 private: B(keys.privateKey || keys.secretKey)
24 }
25 },
26
27 sign: function (private, message) {
28 return B(sodium.crypto_sign_detached(Ui8(message), Ui8(private)))
29 },
30
31 verify: function (public, sig, message) {
32 return sodium.crypto_sign_verify_detached(Ui8(sig), Ui8(message), Ui8(public))
33 }
34
35}
36

Built with git-ssb-web