MCPcopy Create free account
hub / github.com/AudiusProject/hedgehog / createKey

Function createKey

src/authWorker.js:16–44  ·  view source on GitHub ↗
(encryptStr, ivHex)

Source from the content-addressed store, hash-verified

14 )
15
16 const createKey = (encryptStr, ivHex) => {
17 const encryptStrBuffer = self.buffer.SlowBuffer(encryptStr)
18 const ivBuffer = self.buffer.SlowBuffer(ivHex)
19
20 const N = 32768
21 const r = 8
22 const p = 1
23 const dkLen = 32
24
25 self.scrypt(
26 encryptStrBuffer,
27 ivBuffer,
28 N,
29 r,
30 p,
31 dkLen,
32 function (error, progress, key) {
33 if (error) {
34 throw error
35 } else if (key) {
36 key = new self.buffer.SlowBuffer(key)
37 const keyHex = key.toString('hex')
38 postMessage({ keyHex, keyBuffer: key })
39 }
40 // no else clause here, the progress triggers the else clause
41 // but there's no key yet at that point
42 }
43 )
44 }
45
46 self.onmessage = (e) => {
47 if (!e) return

Callers 1

authWorker.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected