h_test_1 0.0.22 → 0.0.24

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