@hinkal/common 0.0.14 → 0.0.16

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 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-DhzLG43o.cjs"),g=require("./workerProxy-C2KnRvuH.cjs"),l=new g.WorkerProxy,d=async({data:e})=>{const{utxos:o,nullifiers:s}=e,n=o.filter(t=>{const a=new r.Utxo(t);return!s.has(a.getNullifier())});l.postMessageToMainThread(n)},h=async({data:e})=>{const o=new r.UserKeys(e.signature),s=o.getShieldedPrivateKey(),n=e.encryptedOutputs.map(t=>{try{return t.isPositive?r.decryptUtxoConstructorArgs(Buffer.from(t.value.slice(2),"hex"),o):r.decodeUtxoConstructorArgs(t.value,s)}catch{return}}).filter(t=>t!==void 0);l.postMessageToMainThread(n)},y=async({data:e})=>{const o=new r.UserKeys(e.signature),s=[],{encryptedOutputs:n}=e;let{lastOutput:t}=e;for(let a=0;a<n.length;a+=1){const i=n[a];if(t=i.value,i.isPositive)try{const c=r.decryptUtxo(Buffer.from(t.slice(2),"hex"),o);if(!c.erc20TokenAddress||!c.amount||!c.stealthAddress)throw Error("bruh");s.map(u=>u.value).includes(i.value)||s.push(i)}catch{r.logError("Utxo not decrypted")}else try{r.checkUtxoSignature(t,o.getShieldedPrivateKey())&&(s.map(u=>u.value).includes(i.value)||s.push(i))}catch{r.logError("Utxo not decoded")}}l.postMessageToMainThread({additionalEncryptedOutputs:s,lastOutput:t})},p=async e=>{await r.preProcessing();const{type:o}=e.payload;switch(o){case r.UtxoWorkerActionType.BATCH_FILTER_UTXOS_WITH_NULLIFIER:d(e.payload);return;case r.UtxoWorkerActionType.BUILD_UTXOS:h(e.payload);return;case r.UtxoWorkerActionType.DECIPHER_OUTPUTS:y(e.payload);return;default:throw Error(`Unknown worker message type ${o}`)}};l.attachWorkerSideOnMessage(p);exports.default=l;exports.handleBuildUtxosMessage=h;exports.handleDecipherMessage=y;exports.handleFilterUtxosWithNullifier=d;exports.onWorkerMessage=p;
@@ -1,9 +0,0 @@
1
- import { W as r } from "./index-DT99VnQG.js";
2
- const e = "" + new URL("assets/zkProofWorkerLauncher-DGaNFkI2.js", import.meta.url).href, o = "" + new URL("assets/snarkjsWorkerLauncher-CaBCnle3.js", import.meta.url).href, s = "" + new URL("assets/utxoWorkerLauncher-TRT6Cdzd.js", import.meta.url).href, a = {
3
- [r.ZKProof]: e,
4
- [r.SnarkJS]: o,
5
- [r.UTXO]: s
6
- };
7
- export {
8
- a as workerViteURL
9
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DhzLG43o.cjs"),r=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/zkProofWorkerLauncher-DGaNFkI2.js").href:new URL("assets/zkProofWorkerLauncher-DGaNFkI2.js",document.currentScript&&document.currentScript.src||document.baseURI).href),t=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/snarkjsWorkerLauncher-CaBCnle3.js").href:new URL("assets/snarkjsWorkerLauncher-CaBCnle3.js",document.currentScript&&document.currentScript.src||document.baseURI).href),n=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/utxoWorkerLauncher-TRT6Cdzd.js").href:new URL("assets/utxoWorkerLauncher-TRT6Cdzd.js",document.currentScript&&document.currentScript.src||document.baseURI).href),o={[e.WorkerVariant.ZKProof]:r,[e.WorkerVariant.SnarkJS]:t,[e.WorkerVariant.UTXO]:n};exports.workerViteURL=o;
@@ -1 +0,0 @@
1
- "use strict";class s{isNode=!1;onmessage=null;_eventEmitter;get eventEmitter(){if(this._eventEmitter)return this._eventEmitter;const e=require("events");return this._eventEmitter=new e,this._eventEmitter}constructor(){this.isNode=typeof process<"u"&&process.versions!=null&&process.versions.node!=null}terminate(){}postMessage(e){if(this.isNode){this.eventEmitter.emit("message",e);return}else postMessage(e)}postMessageToMainThread(e){if(this.isNode){const t={data:e};this.onmessage&&this.onmessage(t)}else postMessage(e)}attachWorkerSideOnMessage(e){this.isNode&&this.eventEmitter.on("message",t=>e(t))}}exports.WorkerProxy=s;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DhzLG43o.cjs"),k=require("./workerProxy-C2KnRvuH.cjs"),d=new k.WorkerProxy,p=n=>{const{inputUtxosSerialized:i,merkleTreeSerialized:t}=n.data,S=t.tree,r=new Map(Object.entries(S).map(([c,l])=>[BigInt(c),BigInt(l)])),o=e.MerkleTree.createWithData(r,BigInt(t.index),BigInt(t.count),e.poseidonFunction,25n,0n),s=i.map(c=>c.map(l=>new e.Utxo(l))),{inCommitmentSiblings:a,inCommitmentSiblingSides:m}=e.calcCommitmentsSiblingAndSides(s,o);d.postMessageToMainThread({inCommitmentSiblings:a,inCommitmentSiblingSides:m})},g=n=>{const{userSignature:i,merkleTreeAccessTokenSerialized:t}=n.data,S=new e.UserKeys(i),r=t.tree,o=new Map(Object.entries(r).map(([c,l])=>[BigInt(c),BigInt(l)])),s=e.MerkleTree.createWithData(o,BigInt(t.index),BigInt(t.count),e.poseidonFunction,25n,0n),{accessTokenSiblings:a,accessTokenSiblingSides:m}=e.calcAccessTokenSiblingsAndSides(S,s);d.postMessageToMainThread({accessTokenSiblings:a,accessTokenSiblingSides:m})},T=n=>{const{inputUtxosSerialized:i,onChainCreation:t}=n.data,r=i.map(o=>o.map(s=>new e.Utxo(s))).map((o,s)=>o.map(a=>t[s]?"0":a.getNullifier()));d.postMessageToMainThread(r)},u=async n=>{await e.preProcessing();const{type:i}=n.payload;switch(i){case e.ZKProofWorkerActionType.CALC_COMMITMENTS_SIBLING_AND_SIDES:p(n.payload);return;case e.ZKProofWorkerActionType.CALC_ACCESS_TOKEN_SIBLING_AND_SIDES:g(n.payload);return;case e.ZKProofWorkerActionType.BUILD_IN_NULLIFIERS:T(n.payload);return;default:throw Error(`Unknown worker message type ${i}`)}};d.attachWorkerSideOnMessage(u);exports.default=d;exports.handleBuildInNullifiers=T;exports.handleCalcAccessTokenSiblingAndSides=g;exports.handleCalcCommitmentsSiblingAndSides=p;exports.onWorkerMessage=u;