Browse Source

add a keySet helper function for generating a set of keys for a group

Kieran Gibb 3 years ago
parent
commit
a3b1751849
No account linked to committer's email address
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      index.js

+ 9
- 0
index.js View File

@@ -9,6 +9,15 @@ class Crypto {
9 9
     return crypto.keyPair(seed)
10 10
   }
11 11
 
12
+  keySet () {
13
+    var accKey = this.accessKey()
14
+    var keys = this.unpack(accKey)
15
+    var encKey = sodium.sodium_malloc(sodium.crypto_secret_box_KEYBYTES)
16
+    sodium.crypto_hash_sha256(encKey, accKey)
17
+    keys.encKey = encKey
18
+    return keys
19
+  }
20
+
12 21
   randomBytes(length) {
13 22
     return crypto.randomBytes(length)
14 23
   }