h_test_1 0.0.22 → 0.0.23
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/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.cjs +1 -1
- package/functions/snarkjs/getMerkleTreeSiblingsAndRootHashes.mjs +69 -67
- package/package.json +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLogic.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLogic.mjs +18 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("../../data-structures/merkle-tree/MerkleTree.cjs"),A=require("../../data-structures/merkle-tree/getPatchedAccessTokenMerkleTree.cjs"),S=require("../../webworker/performTaskWithWorker.cjs"),m=require("../../webworker/worker.registry.cjs"),h=require("../../webworker/zkProofWorker/zkProofWorker.types.cjs"),u=require("./fetchMerkleTreeSiblings.cjs"),H=require("../utils/amounts.utils.cjs"),P=require("../../crypto/poseidon.cjs"),C=require("../../constants/vite.constants.cjs"),R=require("./fetchOnChainRootHashes.cjs"),p=async(e,a)=>{const o=e.getRootHash();if(console.log("pre calculate access token siblings and root hash",{rootHash:o,patchedMerkleTree:e}),o===void 0)throw new Error("Root hash not available from patched merkle tree");const s=await S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,data:{accessKey:a,merkleTreeAccessTokenSerialized:e.toJSON()}}});return{accessTokenSiblings:s.accessTokenSiblings,accessTokenSiblingSides:s.accessTokenSiblingSides,rootHashAccessToken:o}},_=async(e,a,o,s,i,n)=>{console.log("hinkalDeposit sa5");const r=o.getAccessKey();console.log("hinkalDeposit sa6",{accessKey:r});const t=A.getPatchedAccessTokenMerkleTree(a,r,i,n),g=e.getRootHash();if(g===void 0)throw new Error("Root hash not available from hinkal merkle tree");let l,c;return C.isNode?(l=await p(t,r),c=await S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:s,merkleTreeSerialized:e.toJSON()}}})):[l,c]=await Promise.all([p(t,r),S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES,data:{inputUtxosSerialized:s,merkleTreeSerialized:e.toJSON()}}})]),{inCommitmentSiblings:c.inCommitmentSiblings,inCommitmentSiblingSides:c.inCommitmentSiblingSides,accessTokenSiblings:l.accessTokenSiblings,accessTokenSiblingSides:l.accessTokenSiblingSides,rootHashHinkal:g,rootHashAccessToken:l.rootHashAccessToken}},N=async(e,a,o,s,i)=>{console.log("hinkalDeposit sa3");const n=a.getAccessKey();if(console.log("hinkalDeposit sa4",{accessKey:n}),!i||s){const g=W.MerkleTree.create(P.poseidonFunction,0n),l=A.getPatchedAccessTokenMerkleTree(g,n,s,i);console.log("pre calculating access token siblings and root hash",{accessKey:n});const[c,k]=await Promise.all([p(l,n),u.fetchMerkleTreeSiblings(e,o,n)]);return console.log("post calculating access token siblings and root hash",{accessTokenResult:c,siblingsResponse:k}),{inCommitmentSiblings:k.inCommitmentSiblings,inCommitmentSiblingSides:k.inCommitmentSiblingSides,accessTokenSiblings:c.accessTokenSiblings,accessTokenSiblingSides:c.accessTokenSiblingSides,rootHashHinkal:H.toBigInt(k.rootHashHinkal),rootHashAccessToken:c.rootHashAccessToken}}const t=await u.fetchMerkleTreeSiblings(e,o,n);return{inCommitmentSiblings:t.inCommitmentSiblings,inCommitmentSiblingSides:t.inCommitmentSiblingSides,accessTokenSiblings:t.accessTokenSiblings,accessTokenSiblingSides:t.accessTokenSiblingSides,rootHashHinkal:H.toBigInt(t.rootHashHinkal),rootHashAccessToken:H.toBigInt(t.rootHashAccessToken)}},I=async(e,a,o)=>{if(!a||!o)return!1;try{const s=a.getRootHash(),i=o.getRootHash();if(!s||!i)return!1;const{hinkalRootHash:n,accessTokenRootHash:r}=await R.fetchOnChainRootHashes(e);return s===n&&i===r}catch{return!1}},y=async(e,a,o,s,i,n,r)=>{const t=await I(e,n,r);return console.log("hinkalDeposit sa2",{isLocalFresh:t}),t?_(n,r,a,o,s,i):N(e,a,o,s,i)},M=async(e,a,o,s,i,n,r,t,g)=>{if(C.isNode){const{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:k,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d}=await y(e,s,i,n,r,a,o),f=await S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:i,onChainCreation:t,proverVersion:g}}});return{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:k,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d,inNullifiers:f}}else{const[{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:k,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d},f]=await Promise.all([y(e,s,i,n,r,a,o),S.performTaskWithWorker({type:m.WorkerVariant.ZKProof,payload:{type:h.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS,data:{inputUtxosSerialized:i,onChainCreation:t,proverVersion:g}}})]);return{inCommitmentSiblings:l,inCommitmentSiblingSides:c,accessTokenSiblings:k,accessTokenSiblingSides:T,rootHashHinkal:b,rootHashAccessToken:d,inNullifiers:f}}};exports.getDataFromWorkers=M;exports.getMerkleTreeSiblingsAndRootHashes=y;
|
|
@@ -4,15 +4,15 @@ import { performTaskWithWorker as g } from "../../webworker/performTaskWithWorke
|
|
|
4
4
|
import { WorkerVariant as k } from "../../webworker/worker.registry.mjs";
|
|
5
5
|
import { ZKProofWorkerActionType as h } from "../../webworker/zkProofWorker/zkProofWorker.types.mjs";
|
|
6
6
|
import { fetchMerkleTreeSiblings as C } from "./fetchMerkleTreeSiblings.mjs";
|
|
7
|
-
import { toBigInt as
|
|
7
|
+
import { toBigInt as H } from "../utils/amounts.utils.mjs";
|
|
8
8
|
import { poseidonFunction as I } from "../../crypto/poseidon.mjs";
|
|
9
9
|
import { isNode as N } from "../../constants/vite.constants.mjs";
|
|
10
10
|
import { fetchOnChainRootHashes as _ } from "./fetchOnChainRootHashes.mjs";
|
|
11
11
|
const p = async (o, a) => {
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
12
|
+
const s = o.getRootHash();
|
|
13
|
+
if (console.log("pre calculate access token siblings and root hash", { rootHash: s, patchedMerkleTree: o }), s === void 0)
|
|
14
14
|
throw new Error("Root hash not available from patched merkle tree");
|
|
15
|
-
const
|
|
15
|
+
const e = await g({
|
|
16
16
|
type: k.ZKProof,
|
|
17
17
|
payload: {
|
|
18
18
|
type: h.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES,
|
|
@@ -23,28 +23,28 @@ const p = async (o, a) => {
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
return {
|
|
26
|
-
accessTokenSiblings:
|
|
27
|
-
accessTokenSiblingSides:
|
|
28
|
-
rootHashAccessToken:
|
|
26
|
+
accessTokenSiblings: e.accessTokenSiblings,
|
|
27
|
+
accessTokenSiblingSides: e.accessTokenSiblingSides,
|
|
28
|
+
rootHashAccessToken: s
|
|
29
29
|
};
|
|
30
|
-
}, w = async (o, a, e,
|
|
30
|
+
}, w = async (o, a, s, e, n, i) => {
|
|
31
31
|
console.log("hinkalDeposit sa5");
|
|
32
|
-
const c =
|
|
32
|
+
const c = s.getAccessKey();
|
|
33
33
|
console.log("hinkalDeposit sa6", { accessKey: c });
|
|
34
34
|
const t = A(
|
|
35
35
|
a,
|
|
36
36
|
c,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
),
|
|
40
|
-
if (
|
|
37
|
+
n,
|
|
38
|
+
i
|
|
39
|
+
), S = o.getRootHash();
|
|
40
|
+
if (S === void 0)
|
|
41
41
|
throw new Error("Root hash not available from hinkal merkle tree");
|
|
42
42
|
let r, l;
|
|
43
43
|
return N ? (r = await p(t, c), l = await g({
|
|
44
44
|
type: k.ZKProof,
|
|
45
45
|
payload: {
|
|
46
46
|
type: h.CALC_COMMITMENTS_SIBLING_AND_SIDES,
|
|
47
|
-
data: { inputUtxosSerialized:
|
|
47
|
+
data: { inputUtxosSerialized: e, merkleTreeSerialized: o.toJSON() }
|
|
48
48
|
}
|
|
49
49
|
})) : [r, l] = await Promise.all([
|
|
50
50
|
p(t, c),
|
|
@@ -52,7 +52,7 @@ const p = async (o, a) => {
|
|
|
52
52
|
type: k.ZKProof,
|
|
53
53
|
payload: {
|
|
54
54
|
type: h.CALC_COMMITMENTS_SIBLING_AND_SIDES,
|
|
55
|
-
data: { inputUtxosSerialized:
|
|
55
|
+
data: { inputUtxosSerialized: e, merkleTreeSerialized: o.toJSON() }
|
|
56
56
|
}
|
|
57
57
|
})
|
|
58
58
|
]), {
|
|
@@ -60,132 +60,134 @@ const p = async (o, a) => {
|
|
|
60
60
|
inCommitmentSiblingSides: l.inCommitmentSiblingSides,
|
|
61
61
|
accessTokenSiblings: r.accessTokenSiblings,
|
|
62
62
|
accessTokenSiblingSides: r.accessTokenSiblingSides,
|
|
63
|
-
rootHashHinkal:
|
|
63
|
+
rootHashHinkal: S,
|
|
64
64
|
rootHashAccessToken: r.rootHashAccessToken
|
|
65
65
|
};
|
|
66
|
-
}, D = async (o, a,
|
|
66
|
+
}, D = async (o, a, s, e, n) => {
|
|
67
67
|
console.log("hinkalDeposit sa3");
|
|
68
|
-
const
|
|
69
|
-
if (console.log("hinkalDeposit sa4", { accessKey:
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
const i = a.getAccessKey();
|
|
69
|
+
if (console.log("hinkalDeposit sa4", { accessKey: i }), !n || e) {
|
|
70
|
+
const S = R.create(I, 0n), r = A(
|
|
71
|
+
S,
|
|
72
|
+
i,
|
|
73
|
+
e,
|
|
74
|
+
n
|
|
75
|
+
);
|
|
76
|
+
console.log("pre calculating access token siblings and root hash", { accessKey: i });
|
|
77
|
+
const [l, m] = await Promise.all([
|
|
78
|
+
p(r, i),
|
|
79
|
+
C(o, s, i)
|
|
78
80
|
]);
|
|
79
|
-
return {
|
|
80
|
-
inCommitmentSiblings:
|
|
81
|
-
inCommitmentSiblingSides:
|
|
81
|
+
return console.log("post calculating access token siblings and root hash", { accessTokenResult: l, siblingsResponse: m }), {
|
|
82
|
+
inCommitmentSiblings: m.inCommitmentSiblings,
|
|
83
|
+
inCommitmentSiblingSides: m.inCommitmentSiblingSides,
|
|
82
84
|
accessTokenSiblings: l.accessTokenSiblings,
|
|
83
85
|
accessTokenSiblingSides: l.accessTokenSiblingSides,
|
|
84
|
-
rootHashHinkal:
|
|
86
|
+
rootHashHinkal: H(m.rootHashHinkal),
|
|
85
87
|
rootHashAccessToken: l.rootHashAccessToken
|
|
86
88
|
};
|
|
87
89
|
}
|
|
88
|
-
const t = await C(o,
|
|
90
|
+
const t = await C(o, s, i);
|
|
89
91
|
return {
|
|
90
92
|
inCommitmentSiblings: t.inCommitmentSiblings,
|
|
91
93
|
inCommitmentSiblingSides: t.inCommitmentSiblingSides,
|
|
92
94
|
accessTokenSiblings: t.accessTokenSiblings,
|
|
93
95
|
accessTokenSiblingSides: t.accessTokenSiblingSides,
|
|
94
|
-
rootHashHinkal:
|
|
95
|
-
rootHashAccessToken:
|
|
96
|
+
rootHashHinkal: H(t.rootHashHinkal),
|
|
97
|
+
rootHashAccessToken: H(t.rootHashAccessToken)
|
|
96
98
|
};
|
|
97
|
-
}, L = async (o, a,
|
|
98
|
-
if (!a || !
|
|
99
|
+
}, L = async (o, a, s) => {
|
|
100
|
+
if (!a || !s)
|
|
99
101
|
return !1;
|
|
100
102
|
try {
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
103
|
+
const e = a.getRootHash(), n = s.getRootHash();
|
|
104
|
+
if (!e || !n)
|
|
103
105
|
return !1;
|
|
104
|
-
const { hinkalRootHash:
|
|
105
|
-
return
|
|
106
|
+
const { hinkalRootHash: i, accessTokenRootHash: c } = await _(o);
|
|
107
|
+
return e === i && n === c;
|
|
106
108
|
} catch {
|
|
107
109
|
return !1;
|
|
108
110
|
}
|
|
109
|
-
}, y = async (o, a, e,
|
|
110
|
-
const t = await L(o,
|
|
111
|
+
}, y = async (o, a, s, e, n, i, c) => {
|
|
112
|
+
const t = await L(o, i, c);
|
|
111
113
|
return console.log("hinkalDeposit sa2", { isLocalFresh: t }), t ? w(
|
|
112
|
-
|
|
114
|
+
i,
|
|
113
115
|
c,
|
|
114
116
|
a,
|
|
115
|
-
e,
|
|
116
117
|
s,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
e,
|
|
119
|
+
n
|
|
120
|
+
) : D(o, a, s, e, n);
|
|
121
|
+
}, v = async (o, a, s, e, n, i, c, t, S) => {
|
|
120
122
|
if (N) {
|
|
121
123
|
const {
|
|
122
124
|
inCommitmentSiblings: r,
|
|
123
125
|
inCommitmentSiblingSides: l,
|
|
124
|
-
accessTokenSiblings:
|
|
126
|
+
accessTokenSiblings: m,
|
|
125
127
|
accessTokenSiblingSides: b,
|
|
126
128
|
rootHashHinkal: T,
|
|
127
|
-
rootHashAccessToken:
|
|
129
|
+
rootHashAccessToken: d
|
|
128
130
|
} = await y(
|
|
129
131
|
o,
|
|
130
|
-
|
|
131
|
-
i,
|
|
132
|
+
e,
|
|
132
133
|
n,
|
|
134
|
+
i,
|
|
133
135
|
c,
|
|
134
136
|
a,
|
|
135
|
-
|
|
136
|
-
),
|
|
137
|
+
s
|
|
138
|
+
), f = await g({
|
|
137
139
|
type: k.ZKProof,
|
|
138
140
|
payload: {
|
|
139
141
|
type: h.BUILD_IN_NULLIFIERS,
|
|
140
|
-
data: { inputUtxosSerialized:
|
|
142
|
+
data: { inputUtxosSerialized: n, onChainCreation: t, proverVersion: S }
|
|
141
143
|
}
|
|
142
144
|
});
|
|
143
145
|
return {
|
|
144
146
|
inCommitmentSiblings: r,
|
|
145
147
|
inCommitmentSiblingSides: l,
|
|
146
|
-
accessTokenSiblings:
|
|
148
|
+
accessTokenSiblings: m,
|
|
147
149
|
accessTokenSiblingSides: b,
|
|
148
150
|
rootHashHinkal: T,
|
|
149
|
-
rootHashAccessToken:
|
|
150
|
-
inNullifiers:
|
|
151
|
+
rootHashAccessToken: d,
|
|
152
|
+
inNullifiers: f
|
|
151
153
|
};
|
|
152
154
|
} else {
|
|
153
155
|
const [
|
|
154
156
|
{
|
|
155
157
|
inCommitmentSiblings: r,
|
|
156
158
|
inCommitmentSiblingSides: l,
|
|
157
|
-
accessTokenSiblings:
|
|
159
|
+
accessTokenSiblings: m,
|
|
158
160
|
accessTokenSiblingSides: b,
|
|
159
161
|
rootHashHinkal: T,
|
|
160
|
-
rootHashAccessToken:
|
|
162
|
+
rootHashAccessToken: d
|
|
161
163
|
},
|
|
162
|
-
|
|
164
|
+
f
|
|
163
165
|
] = await Promise.all([
|
|
164
166
|
y(
|
|
165
167
|
o,
|
|
166
|
-
|
|
167
|
-
i,
|
|
168
|
+
e,
|
|
168
169
|
n,
|
|
170
|
+
i,
|
|
169
171
|
c,
|
|
170
172
|
a,
|
|
171
|
-
|
|
173
|
+
s
|
|
172
174
|
),
|
|
173
175
|
g({
|
|
174
176
|
type: k.ZKProof,
|
|
175
177
|
payload: {
|
|
176
178
|
type: h.BUILD_IN_NULLIFIERS,
|
|
177
|
-
data: { inputUtxosSerialized:
|
|
179
|
+
data: { inputUtxosSerialized: n, onChainCreation: t, proverVersion: S }
|
|
178
180
|
}
|
|
179
181
|
})
|
|
180
182
|
]);
|
|
181
183
|
return {
|
|
182
184
|
inCommitmentSiblings: r,
|
|
183
185
|
inCommitmentSiblingSides: l,
|
|
184
|
-
accessTokenSiblings:
|
|
186
|
+
accessTokenSiblings: m,
|
|
185
187
|
accessTokenSiblingSides: b,
|
|
186
188
|
rootHashHinkal: T,
|
|
187
|
-
rootHashAccessToken:
|
|
188
|
-
inNullifiers:
|
|
189
|
+
rootHashAccessToken: d,
|
|
190
|
+
inNullifiers: f
|
|
189
191
|
};
|
|
190
192
|
}
|
|
191
193
|
};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const r=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-2a1CGTor.js").href:new URL("../../assets/zkProofWorkerLauncher-2a1CGTor.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("../../crypto/preProcessing.cjs"),S=require("../../data-structures/utxo/Utxo.cjs"),m=require("../../functions/snarkjs/common.snarkjs.cjs"),C=require("../workerProxy.cjs"),d=require("./zkProofWorker.types.cjs"),u=require("../../functions/utils/merkleTree.utils.cjs"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("../../crypto/preProcessing.cjs"),S=require("../../data-structures/utxo/Utxo.cjs"),m=require("../../functions/snarkjs/common.snarkjs.cjs"),C=require("../workerProxy.cjs"),d=require("./zkProofWorker.types.cjs"),u=require("../../functions/utils/merkleTree.utils.cjs"),c=new C.WorkerProxy,k=o=>{const{inputUtxosSerialized:e,merkleTreeSerialized:t}=o.data,a=u.contructMerkleTreeFromSerialized(t),s=e.map(n=>n.map(l=>new S.Utxo(l))),{inCommitmentSiblings:r,inCommitmentSiblingSides:i}=m.calcCommitmentsSiblingAndSides(s,a);c.postMessageToMainThread({inCommitmentSiblings:r,inCommitmentSiblingSides:i})},p=o=>{const{accessKey:e,merkleTreeAccessTokenSerialized:t}=o.data;console.log("worker code a1",{accessKey:e,merkleTreeAccessTokenSerialized:t});const a=u.contructMerkleTreeFromSerialized(t);console.log("worker code a2",{merkleTree:a});const{accessTokenSiblings:s,accessTokenSiblingSides:r}=m.calcAccessTokenSiblingsAndSides(e,a);console.log("worker code a3",{accessTokenSiblings:s,accessTokenSiblingSides:r}),c.postMessageToMainThread({accessTokenSiblings:s,accessTokenSiblingSides:r})},T=o=>{const{inputUtxosSerialized:e,onChainCreation:t,proverVersion:a}=o.data,s=e.map(i=>i.map(n=>new S.Utxo(n)));let r=[];a==="v1x0"?r=s.map((i,n)=>i.map(l=>t[n]?"0":l.getNullifier())):r=s.map(i=>i.map(n=>n.amount===0n?"0":n.getNullifier())),c.postMessageToMainThread(r)},g=async o=>{try{await A.preProcessing();const{type:e}=o.payload;switch(e){case d.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES:k(o.payload);return;case d.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES:p(o.payload);return;case d.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS:T(o.payload);return;default:throw Error(`Unknown worker message type ${e}`)}}catch(e){console.error(e),c.postErrorToMainThread(e)}};c.attachWorkerSideOnMessage(g);exports.default=c;exports.handleBuildInNullifiers=T;exports.handleCalcAccessTokenSiblingAndSides=p;exports.handleCalcCommitmentsSiblingAndSides=k;exports.onWorkerMessage=g;
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import { preProcessing as S } from "../../crypto/preProcessing.mjs";
|
|
2
|
-
import { Utxo as
|
|
2
|
+
import { Utxo as d } from "../../data-structures/utxo/Utxo.mjs";
|
|
3
3
|
import { calcCommitmentsSiblingAndSides as T, calcAccessTokenSiblingsAndSides as g } from "../../functions/snarkjs/common.snarkjs.mjs";
|
|
4
4
|
import { WorkerProxy as k } from "../workerProxy.mjs";
|
|
5
5
|
import { ZKProofWorkerActionType as m } from "./zkProofWorker.types.mjs";
|
|
6
|
-
import { contructMerkleTreeFromSerialized as
|
|
6
|
+
import { contructMerkleTreeFromSerialized as p } from "../../functions/utils/merkleTree.utils.mjs";
|
|
7
7
|
const c = new k(), u = (o) => {
|
|
8
|
-
const { inputUtxosSerialized: e, merkleTreeSerialized: t } = o.data, a =
|
|
9
|
-
(
|
|
10
|
-
), { inCommitmentSiblings:
|
|
11
|
-
c.postMessageToMainThread({ inCommitmentSiblings:
|
|
8
|
+
const { inputUtxosSerialized: e, merkleTreeSerialized: t } = o.data, a = p(t), s = e.map(
|
|
9
|
+
(n) => n.map((l) => new d(l))
|
|
10
|
+
), { inCommitmentSiblings: r, inCommitmentSiblingSides: i } = T(s, a);
|
|
11
|
+
c.postMessageToMainThread({ inCommitmentSiblings: r, inCommitmentSiblingSides: i });
|
|
12
12
|
}, C = (o) => {
|
|
13
|
-
const { accessKey: e, merkleTreeAccessTokenSerialized: t } = o.data
|
|
14
|
-
|
|
13
|
+
const { accessKey: e, merkleTreeAccessTokenSerialized: t } = o.data;
|
|
14
|
+
console.log("worker code a1", { accessKey: e, merkleTreeAccessTokenSerialized: t });
|
|
15
|
+
const a = p(t);
|
|
16
|
+
console.log("worker code a2", { merkleTree: a });
|
|
17
|
+
const { accessTokenSiblings: s, accessTokenSiblingSides: r } = g(e, a);
|
|
18
|
+
console.log("worker code a3", { accessTokenSiblings: s, accessTokenSiblingSides: r }), c.postMessageToMainThread({ accessTokenSiblings: s, accessTokenSiblingSides: r });
|
|
15
19
|
}, f = (o) => {
|
|
16
|
-
const { inputUtxosSerialized: e, onChainCreation: t, proverVersion: a } = o.data,
|
|
17
|
-
(
|
|
20
|
+
const { inputUtxosSerialized: e, onChainCreation: t, proverVersion: a } = o.data, s = e.map(
|
|
21
|
+
(i) => i.map((n) => new d(n))
|
|
18
22
|
);
|
|
19
|
-
let
|
|
20
|
-
a === "v1x0" ?
|
|
21
|
-
(
|
|
22
|
-
) :
|
|
23
|
+
let r = [];
|
|
24
|
+
a === "v1x0" ? r = s.map(
|
|
25
|
+
(i, n) => i.map((l) => t[n] ? "0" : l.getNullifier())
|
|
26
|
+
) : r = s.map((i) => i.map((n) => n.amount === 0n ? "0" : n.getNullifier())), c.postMessageToMainThread(r);
|
|
23
27
|
}, A = async (o) => {
|
|
24
28
|
try {
|
|
25
29
|
await S();
|