forked from meganz/webclient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnaclworker.js
More file actions
33 lines (27 loc) · 746 Bytes
/
naclworker.js
File metadata and controls
33 lines (27 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
window = this; // required, so that nacl-fast.js can be loaded as-is in a worker
importScripts('nacl-fast.js');
var have_ab = typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined';
postMessage = self.webkitPostMessage || self.postMessage;
onmessage = function(e)
{
if (e.data.length && e.data.splice)
{
var arr = e.data;
if (arr[0] === 'verify') {
postMessage(
nacl.sign.detached.verify(
arr[1],
arr[2],
arr[3]
)
);
}
else {
console.error("Unknown op: ", arr[0]);
}
}
else
{
console.error("Invalid message: ", e.data);
}
};