@sabaaa1/common 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{snarkjsWorkerLauncher-CTJxY_k6.js → snarkjsWorkerLauncher-Dsmwcy9L.js} +1 -1
- package/assets/{snarkjsWorkerLogic-BTc2hrlU.js → snarkjsWorkerLogic-B9NbAQYW.js} +707 -733
- package/assets/{utxoWorkerLauncher-B6d6svhO.js → utxoWorkerLauncher-Bvb09Ewh.js} +1 -1
- package/assets/{utxoWorkerLogic-YPywVy-e.js → utxoWorkerLogic-IHmQBHcc.js} +2287 -2302
- package/assets/{zkProofWorkerLauncher-CCedBtfh.js → zkProofWorkerLauncher-CoKmCKjC.js} +1 -1
- package/assets/{zkProofWorkerLogic-B_sgmDOg.js → zkProofWorkerLogic-DB9cbXu-.js} +7 -33
- package/package.json +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +53 -40
- package/webworker/workerProxy.cjs +1 -1
- package/webworker/workerProxy.mjs +10 -36
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
|
@@ -1190,7 +1190,7 @@ const et = () => {
|
|
|
1190
1190
|
};
|
|
1191
1191
|
globalThis.process = tt;
|
|
1192
1192
|
globalThis.Buffer = xr.Buffer;
|
|
1193
|
-
const nt = import("./zkProofWorkerLogic-
|
|
1193
|
+
const nt = import("./zkProofWorkerLogic-DB9cbXu-.js");
|
|
1194
1194
|
addEventListener("message", async (f) => {
|
|
1195
1195
|
const { onWorkerMessage: h } = await nt;
|
|
1196
1196
|
h(f.data);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as Os, c as j1, a as u5, b as Gs, p as Ks } from "./zkProofWorkerLauncher-
|
|
1
|
+
import { g as Os, c as j1, a as u5, b as Gs, p as Ks } from "./zkProofWorkerLauncher-CoKmCKjC.js";
|
|
2
2
|
const Js = [0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4];
|
|
3
3
|
function $3(i, e) {
|
|
4
4
|
if (!e || e == 10)
|
|
@@ -113928,43 +113928,17 @@ class vI {
|
|
|
113928
113928
|
}
|
|
113929
113929
|
postMessageToMainThread(e) {
|
|
113930
113930
|
const a = { data: e };
|
|
113931
|
-
|
|
113932
|
-
this.onmessage(a);
|
|
113933
|
-
return;
|
|
113934
|
-
}
|
|
113935
|
-
const b = typeof self < "u" ? self : globalThis;
|
|
113936
|
-
b.postMessage && b.postMessage(e);
|
|
113931
|
+
this.onmessage ? this.onmessage(a) : postMessage(e);
|
|
113937
113932
|
}
|
|
113938
113933
|
postErrorToMainThread(e) {
|
|
113939
113934
|
const a = { data: { error: e } };
|
|
113940
|
-
|
|
113941
|
-
this.onerror(a);
|
|
113942
|
-
return;
|
|
113943
|
-
}
|
|
113944
|
-
const b = {
|
|
113945
|
-
error: !0,
|
|
113946
|
-
message: e instanceof Error ? e.message : String(e),
|
|
113947
|
-
stack: e instanceof Error ? e.stack : void 0
|
|
113948
|
-
}, o = typeof self < "u" ? self : globalThis;
|
|
113949
|
-
o.postMessage && o.postMessage(b);
|
|
113935
|
+
this.onerror ? this.onerror(a) : postMessage(e);
|
|
113950
113936
|
}
|
|
113951
113937
|
attachWorkerSideOnMessage(e) {
|
|
113952
|
-
|
|
113953
|
-
|
|
113954
|
-
|
|
113955
|
-
|
|
113956
|
-
return;
|
|
113957
|
-
}
|
|
113958
|
-
if (this.isSandbox) {
|
|
113959
|
-
this.eventEmitter.addEventListener("worker-message", (b) => {
|
|
113960
|
-
e(b.detail);
|
|
113961
|
-
});
|
|
113962
|
-
return;
|
|
113963
|
-
}
|
|
113964
|
-
const a = typeof self < "u" ? self : globalThis;
|
|
113965
|
-
a.addEventListener && a.addEventListener("message", (b) => {
|
|
113966
|
-
const o = b?.data;
|
|
113967
|
-
o && e(o);
|
|
113938
|
+
this.isNode ? this.eventEmitter.on("message", (a) => {
|
|
113939
|
+
e(a);
|
|
113940
|
+
}) : this.isSandbox && this.eventEmitter.addEventListener("worker-message", (a) => {
|
|
113941
|
+
e(a.detail);
|
|
113968
113942
|
});
|
|
113969
113943
|
}
|
|
113970
113944
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-
|
|
1
|
+
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-Dsmwcy9L.js").href:new URL("../../assets/snarkjsWorkerLauncher-Dsmwcy9L.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-
|
|
1
|
+
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-Bvb09Ewh.js").href:new URL("../../assets/utxoWorkerLauncher-Bvb09Ewh.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("buffer"),T=require("process"),k=require("../../crypto/preProcessing.cjs"),c=require("../../data-structures/crypto-keys/keys.cjs"),v=require("../../data-structures/utxo/Utxo.cjs"),p=require("../../data-structures/crypto-keys/encryptDecryptUtxo.cjs"),f=require("../../data-structures/crypto-keys/decodeUTXO.cjs"),w=require("../workerProxy.cjs"),d=require("./utxoWorker.types.cjs");globalThis.process=T;globalThis.Buffer=h.Buffer;const i=new w.WorkerProxy,g=async({data:e})=>{const{utxos:r,nullifiers:s}=e,o=r.filter(t=>{const l=new v.Utxo(t);return!s.has(l.getNullifier())});i.postMessageToMainThread({utxoConstructors:o,stealthPairCache:c.stealthPairCacheDevice.serialize(),stealthAddressCache:c.stealthAddressCacheDevice.serialize()})},U=async({data:e})=>{const r=new c.UserKeys(e.signature),s=r.getShieldedPrivateKey(),o=e.encryptedOutputs.map(t=>{try{return t.isPositive?p.decryptUtxoConstructorArgs(h.Buffer.from(t.value.slice(2),"hex"),r):f.decodeUtxoConstructorArgs(t.value,s)}catch{return}}).filter(t=>t!==void 0&&t.amount!==0n);i.postMessageToMainThread(o)},x=async({data:e})=>{const r=new c.UserKeys(e.signature),s=[],{encryptedOutputs:o}=e;let{lastOutput:t}=e;const l=r.getShieldedPrivateKey();for(let u=0;u<o.length;u+=1){const a=o[u];if(t=a.value,a.isPositive)try{const n=p.decryptUtxo(h.Buffer.from(t.slice(2),"hex"),r);if(!n.erc20TokenAddress||!n.amount||!n.stealthAddress)throw Error("bruh");s.push(a)}catch{}else try{f.checkUtxoSignature(t,l)&&s.push(a)}catch{}}i.postMessageToMainThread({additionalEncryptedOutputs:s,lastOutput:t})},y=async e=>{try{await k.preProcessing();const{type:r}=e.payload;switch(r){case d.UtxoWorkerActionType.BATCH_FILTER_UTXOS_WITH_NULLIFIER:await g(e.payload);return;case d.UtxoWorkerActionType.BUILD_UTXOS:await U(e.payload);return;case d.UtxoWorkerActionType.DECIPHER_OUTPUTS:await x(e.payload);return;default:throw Error(`Unknown worker message type ${r}`)}}catch(r){console.error(r),i.postErrorToMainThread(r)}};self.addEventListener("message",async e=>{await y(e.data)});self.addEventListener("error",e=>{console.error("Worker error:",e)});self.addEventListener("unhandledrejection",e=>{console.error("Worker unhandled rejection:",e.reason)});i.attachWorkerSideOnMessage(y);exports.default=i;exports.handleBuildUtxosMessage=U;exports.handleDecipherMessage=x;exports.handleFilterUtxosWithNullifier=g;exports.onWorkerMessage=y;
|
|
@@ -1,76 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { Buffer as h } from "buffer";
|
|
2
|
+
import f from "process";
|
|
3
|
+
import { preProcessing as y } from "../../crypto/preProcessing.mjs";
|
|
4
|
+
import { stealthPairCacheDevice as m, stealthAddressCacheDevice as g, UserKeys as u } from "../../data-structures/crypto-keys/keys.mjs";
|
|
5
|
+
import { Utxo as T } from "../../data-structures/utxo/Utxo.mjs";
|
|
6
|
+
import { decryptUtxoConstructorArgs as x, decryptUtxo as U } from "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
|
|
7
|
+
import { decodeUtxoConstructorArgs as v, checkUtxoSignature as w } from "../../data-structures/crypto-keys/decodeUTXO.mjs";
|
|
8
|
+
import { WorkerProxy as k } from "../workerProxy.mjs";
|
|
7
9
|
import { UtxoWorkerActionType as d } from "./utxoWorker.types.mjs";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
globalThis.process = f;
|
|
11
|
+
globalThis.Buffer = h;
|
|
12
|
+
const n = new k(), P = async ({ data: e }) => {
|
|
13
|
+
const { utxos: r, nullifiers: o } = e, s = r.filter((t) => {
|
|
14
|
+
const c = new T(t);
|
|
15
|
+
return !o.has(c.getNullifier());
|
|
12
16
|
});
|
|
13
|
-
|
|
14
|
-
utxoConstructors:
|
|
15
|
-
stealthPairCache:
|
|
16
|
-
stealthAddressCache:
|
|
17
|
+
n.postMessageToMainThread({
|
|
18
|
+
utxoConstructors: s,
|
|
19
|
+
stealthPairCache: m.serialize(),
|
|
20
|
+
stealthAddressCache: g.serialize()
|
|
17
21
|
});
|
|
18
|
-
},
|
|
19
|
-
const r = new
|
|
22
|
+
}, E = async ({ data: e }) => {
|
|
23
|
+
const r = new u(e.signature), o = r.getShieldedPrivateKey(), s = e.encryptedOutputs.map((t) => {
|
|
20
24
|
try {
|
|
21
|
-
return t.isPositive ?
|
|
25
|
+
return t.isPositive ? x(h.from(t.value.slice(2), "hex"), r) : v(t.value, o);
|
|
22
26
|
} catch {
|
|
23
27
|
return;
|
|
24
28
|
}
|
|
25
29
|
}).filter((t) => t !== void 0 && t.amount !== 0n);
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
const r = new
|
|
30
|
+
n.postMessageToMainThread(s);
|
|
31
|
+
}, M = async ({ data: e }) => {
|
|
32
|
+
const r = new u(e.signature), o = [], { encryptedOutputs: s } = e;
|
|
29
33
|
let { lastOutput: t } = e;
|
|
30
|
-
const
|
|
31
|
-
for (let l = 0; l <
|
|
32
|
-
const
|
|
33
|
-
if (t =
|
|
34
|
+
const c = r.getShieldedPrivateKey();
|
|
35
|
+
for (let l = 0; l < s.length; l += 1) {
|
|
36
|
+
const i = s[l];
|
|
37
|
+
if (t = i.value, i.isPositive)
|
|
34
38
|
try {
|
|
35
|
-
const a =
|
|
39
|
+
const a = U(h.from(t.slice(2), "hex"), r);
|
|
36
40
|
if (!a.erc20TokenAddress || !a.amount || !a.stealthAddress)
|
|
37
41
|
throw Error("bruh");
|
|
38
|
-
|
|
42
|
+
o.push(i);
|
|
39
43
|
} catch {
|
|
40
44
|
}
|
|
41
45
|
else
|
|
42
46
|
try {
|
|
43
|
-
|
|
47
|
+
w(t, c) && o.push(i);
|
|
44
48
|
} catch {
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
|
-
|
|
48
|
-
},
|
|
51
|
+
n.postMessageToMainThread({ additionalEncryptedOutputs: o, lastOutput: t });
|
|
52
|
+
}, p = async (e) => {
|
|
49
53
|
try {
|
|
50
|
-
await
|
|
54
|
+
await y();
|
|
51
55
|
const { type: r } = e.payload;
|
|
52
56
|
switch (r) {
|
|
53
57
|
case d.BATCH_FILTER_UTXOS_WITH_NULLIFIER:
|
|
54
|
-
await
|
|
58
|
+
await P(e.payload);
|
|
55
59
|
return;
|
|
56
60
|
case d.BUILD_UTXOS:
|
|
57
|
-
await
|
|
61
|
+
await E(e.payload);
|
|
58
62
|
return;
|
|
59
63
|
case d.DECIPHER_OUTPUTS:
|
|
60
|
-
await
|
|
64
|
+
await M(e.payload);
|
|
61
65
|
return;
|
|
62
66
|
default:
|
|
63
67
|
throw Error(`Unknown worker message type ${r}`);
|
|
64
68
|
}
|
|
65
69
|
} catch (r) {
|
|
66
|
-
console.error(r),
|
|
70
|
+
console.error(r), n.postErrorToMainThread(r);
|
|
67
71
|
}
|
|
68
72
|
};
|
|
69
|
-
|
|
73
|
+
self.addEventListener("message", async (e) => {
|
|
74
|
+
await p(e.data);
|
|
75
|
+
});
|
|
76
|
+
self.addEventListener("error", (e) => {
|
|
77
|
+
console.error("Worker error:", e);
|
|
78
|
+
});
|
|
79
|
+
self.addEventListener("unhandledrejection", (e) => {
|
|
80
|
+
console.error("Worker unhandled rejection:", e.reason);
|
|
81
|
+
});
|
|
82
|
+
n.attachWorkerSideOnMessage(p);
|
|
70
83
|
export {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
84
|
+
n as default,
|
|
85
|
+
E as handleBuildUtxosMessage,
|
|
86
|
+
M as handleDecipherMessage,
|
|
87
|
+
P as handleFilterUtxosWithNullifier,
|
|
88
|
+
p as onWorkerMessage
|
|
76
89
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class s{isNode=!1;isSandbox=!1;onmessage=null;onerror=null;_eventEmitter;get eventEmitter(){if(this._eventEmitter)return this._eventEmitter;if(this.isNode){const e=require("events");this._eventEmitter=new e}else this._eventEmitter=new EventTarget;return this._eventEmitter}constructor(){this.isNode=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,this.isSandbox=typeof window<"u"&&window.origin==="null"}terminate(){}postMessage(e){this.isNode?this.eventEmitter.emit("message",e):this.isSandbox?this.eventEmitter?.dispatchEvent(new CustomEvent("worker-message",{detail:e})):postMessage(e)}postMessageToMainThread(e){const t={data:e};this.onmessage?this.onmessage(t):postMessage(e)}postErrorToMainThread(e){const t={data:{error:e}};this.onerror?this.onerror(t):postMessage(e)}attachWorkerSideOnMessage(e){this.isNode?this.eventEmitter.on("message",t=>{e(t)}):this.isSandbox&&this.eventEmitter.addEventListener("worker-message",t=>{e(t.detail)})}}exports.WorkerProxy=s;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class i {
|
|
2
2
|
isNode = !1;
|
|
3
3
|
isSandbox = !1;
|
|
4
4
|
/**
|
|
@@ -34,47 +34,21 @@ class o {
|
|
|
34
34
|
this.isNode ? this.eventEmitter.emit("message", e) : this.isSandbox ? this.eventEmitter?.dispatchEvent(new CustomEvent("worker-message", { detail: e })) : postMessage(e);
|
|
35
35
|
}
|
|
36
36
|
postMessageToMainThread(e) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
this.onmessage(s);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const t = typeof self < "u" ? self : globalThis;
|
|
43
|
-
t.postMessage && t.postMessage(e);
|
|
37
|
+
const t = { data: e };
|
|
38
|
+
this.onmessage ? this.onmessage(t) : postMessage(e);
|
|
44
39
|
}
|
|
45
40
|
postErrorToMainThread(e) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
this.onerror(s);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const t = {
|
|
52
|
-
error: !0,
|
|
53
|
-
message: e instanceof Error ? e.message : String(e),
|
|
54
|
-
stack: e instanceof Error ? e.stack : void 0
|
|
55
|
-
}, i = typeof self < "u" ? self : globalThis;
|
|
56
|
-
i.postMessage && i.postMessage(t);
|
|
41
|
+
const t = { data: { error: e } };
|
|
42
|
+
this.onerror ? this.onerror(t) : postMessage(e);
|
|
57
43
|
}
|
|
58
44
|
attachWorkerSideOnMessage(e) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (this.isSandbox) {
|
|
66
|
-
this.eventEmitter.addEventListener("worker-message", (t) => {
|
|
67
|
-
e(t.detail);
|
|
68
|
-
});
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const s = typeof self < "u" ? self : globalThis;
|
|
72
|
-
s.addEventListener && s.addEventListener("message", (t) => {
|
|
73
|
-
const i = t?.data;
|
|
74
|
-
i && e(i);
|
|
45
|
+
this.isNode ? this.eventEmitter.on("message", (t) => {
|
|
46
|
+
e(t);
|
|
47
|
+
}) : this.isSandbox && this.eventEmitter.addEventListener("worker-message", (t) => {
|
|
48
|
+
e(t.detail);
|
|
75
49
|
});
|
|
76
50
|
}
|
|
77
51
|
}
|
|
78
52
|
export {
|
|
79
|
-
|
|
53
|
+
i as WorkerProxy
|
|
80
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-
|
|
1
|
+
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-CoKmCKjC.js").href:new URL("../../assets/zkProofWorkerLauncher-CoKmCKjC.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
|