1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8939],{59155:(t,a,e)=>{let l;e.d(a,{Bw:()=>k,O8:()=>aL,Wp:()=>ah,X5:()=>ap,Zh:()=>tD,k1:()=>a_,mG:()=>$,tK:()=>af});let o=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function i(t,a){if(!a||10==a)return BigInt(t);if(16==a)if("0x"==t.slice(0,2))return BigInt(t);else return BigInt("0x"+t)}function c(t){let a=t.toString(16);return(a.length-1)*4+o[parseInt(a[0],16)]}function n(t){return BigInt(t)<BigInt(0)}function d(t){return!t}function r(t,a){return BigInt(t)<<BigInt(a)}function s(t,a){return BigInt(t)>>BigInt(a)}function _(t){return(BigInt(t)&BigInt(1))==BigInt(1)}function f(t){let a=BigInt(t),e=[];for(;a;)a&BigInt(1)?e.push(1):e.push(0),a>>=BigInt(1);return e}function u(t){if(t>BigInt(Number.MAX_SAFE_INTEGER))throw Error("Number too big");return Number(t)}function g(t,a){return BigInt(t)+BigInt(a)}function L(t,a){return BigInt(t)-BigInt(a)}function p(t){return-BigInt(t)}function h(t,a){return BigInt(t)*BigInt(a)}function m(t,a){return BigInt(t)**BigInt(a)}function b(t,a){return BigInt(t)/BigInt(a)}function x(t,a){return BigInt(t)%BigInt(a)}function y(t,a){return BigInt(t)==BigInt(a)}function F(t,a){return BigInt(t)>BigInt(a)}function C(t,a){return BigInt(t)>=BigInt(a)}function B(t,a){return BigInt(t)&BigInt(a)}function P(t,a,e,l){let o="0000000"+e.toString(16),i=new Uint32Array(t.buffer,t.byteOffset+a,l/4),c=((o.length-7)*4-1>>5)+1;for(let t=0;t<c;t++)i[t]=parseInt(o.substring(o.length-8*t-8,o.length-8*t),16);for(let t=c;t<i.length;t++)i[t]=0;for(let a=4*i.length;a<l;a++)t[a]=u(B(s(e,8*a),255))}function A(t,a,e,l){let o="0000000"+e.toString(16),i=new DataView(t.buffer,t.byteOffset+a,l),c=((o.length-7)*4-1>>5)+1;for(let t=0;t<c;t++)i.setUint32(l-4*t-4,parseInt(o.substring(o.length-8*t-8,o.length-8*t),16),!1);for(let t=0;t<l/4-c;t++)i[t]=0}function q(t,a,e){e=e||t.byteLength,a=a||0;let l=new Uint32Array(t.buffer,t.byteOffset+a,e/4),o=Array(e/4);return l.forEach((t,a)=>o[o.length-a-1]=t.toString(16).padStart(8,"0")),i(o.join(""),16)}function v(t,a,e){e=e||t.byteLength,a=a||0;let l=new DataView(t.buffer,t.byteOffset+a,e),o=Array(e/4);for(let t=0;t<e/4;t++)o[t]=l.getUint32(4*t,!1).toString(16).padStart(8,"0");return i(o.join(""),16)}function I(t,a){return t.toString(a)}function O(t){let a=new Uint8Array(Math.floor((c(t)-1)/8)+1);return P(a,0,t,a.byteLength),a}let E=i(0),w=i(1);var M=Object.freeze({__proto__:null,abs:function(t){return BigInt(t)>=0?BigInt(t):-BigInt(t)},add:g,band:B,bitLength:c,bits:f,bor:function(t,a){return BigInt(t)|BigInt(a)},bxor:function(t,a){return BigInt(t)^BigInt(a)},div:b,e:i,eq:y,exp:function(t,a){return BigInt(t)**BigInt(a)},fromArray:function(t,a){let e=BigInt(0);a=BigInt(a);for(let l=0;l<t.length;l++)e=e*a+BigInt(t[l]);return e},fromRprBE:v,fromRprLE:q,fromString:i,geq:C,gt:F,isNegative:n,isOdd:_,isZero:d,land:function(t,a){return BigInt(t)&&BigInt(a)},leq:function(t,a){return BigInt(t)<=BigInt(a)},lnot:function(t){return!BigInt(t)},lor:function(t,a){return BigInt(t)||BigInt(a)},lt:function(t,a){return BigInt(t)<BigInt(a)},mod:x,mul:h,naf:function(t){let a=BigInt(t),e=[];for(;a;){if(a&BigInt(1)){let t=2-Number(a%BigInt(4));e.push(t),a-=BigInt(t)}else e.push(0);a>>=BigInt(1)}return e},neg:p,neq:function(t,a){return BigInt(t)!=BigInt(a)},one:w,pow:m,shiftLeft:r,shiftRight:s,shl:r,shr:s,square:function(t){return BigInt(t)*BigInt(t)},sub:L,toArray:function(t,a){let e=[],l=BigInt(t);for(a=BigInt(a);l;)e.unshift(Number(l%a)),l/=a;return e},toLEBuff:O,toNumber:u,toRprBE:A,toRprLE:P,toString:I,zero:E});let S=[];for(let t=0;t<256;t++)S[t]=function(t,a){let e=0,l=t;for(let t=0;t<8;t++)e<<=1,e|=1&l,l>>=1;return e}(t,8);function z(t,a,e){if(d(e))return t.one;let l=f(e);if(0==l.length)return t.one;let o=a;for(let e=l.length-2;e>=0;e--)o=t.square(o),l[e]&&(o=t.mul(o,a));return o}function T(t,a,e,l,o){t[a]=t[a]+t[e]>>>0,t[o]=(t[o]^t[a])>>>0,t[o]=(t[o]<<16|t[o]>>>16&65535)>>>0,t[l]=t[l]+t[o]>>>0,t[e]=(t[e]^t[l])>>>0,t[e]=(t[e]<<12|t[e]>>>20&4095)>>>0,t[a]=t[a]+t[e]>>>0,t[o]=(t[o]^t[a])>>>0,t[o]=(t[o]<<8|t[o]>>>24&255)>>>0,t[l]=t[l]+t[o]>>>0,t[e]=(t[e]^t[l])>>>0,t[e]=(t[e]<<7|t[e]>>>25&127)>>>0}class k{constructor(t){t=t||[0,0,0,0,0,0,0,0],this.state=[0x61707865,0x3320646e,0x79622d32,0x6b206574,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],0,0,0,0],this.idx=16,this.buff=Array(16)}nextU32(){return 16==this.idx&&this.update(),this.buff[this.idx++]}nextU64(){return g(h(this.nextU32(),0x100000000),this.nextU32())}nextBool(){return(1&this.nextU32())==1}update(){for(let t=0;t<16;t++)this.buff[t]=this.state[t];for(let a=0;a<10;a++){var t;T(t=this.buff,0,4,8,12),T(t,1,5,9,13),T(t,2,6,10,14),T(t,3,7,11,15),T(t,0,5,10,15),T(t,1,6,11,12),T(t,2,7,8,13),T(t,3,4,9,14)}for(let t=0;t<16;t++)this.buff[t]=this.buff[t]+this.state[t]>>>0;this.idx=0,this.state[12]=this.state[12]+1>>>0,0!=this.state[12]||(this.state[13]=this.state[13]+1>>>0,0!=this.state[13]||(this.state[14]=this.state[14]+1>>>0,0==this.state[14]&&(this.state[15]=this.state[15]+1>>>0)))}}function G(t){let a=new Uint8Array(t);if(void 0!==globalThis.crypto)globalThis.crypto.getRandomValues(a);else for(let e=0;e<t;e++)a[e]=0x100000000*Math.random()>>>0;return a}let N=null;function R(){return N||(N=new k(function(){let t=new Uint32Array(G(32).buffer),a=[];for(let e=0;e<8;e++)a.push(t[e]);return a}()))}class j{constructor(t,a,e){this.F=a,this.G=t,this.opMulGF=e;let l=a.sqrt_t||a.t,o=a.sqrt_s||a.s,i=a.one;for(;a.eq(a.pow(i,a.half),a.one);)i=a.add(i,a.one);this.w=Array(o+1),this.wi=Array(o+1),this.w[o]=this.F.pow(i,l),this.wi[o]=this.F.inv(this.w[o]);let c=o-1;for(;c>=0;)this.w[c]=this.F.square(this.w[c+1]),this.wi[c]=this.F.square(this.wi[c+1]),c--;this.roots=[],this._setRoots(Math.min(o,15))}_setRoots(t){for(let a=t;a>=0&&!this.roots[a];a--){let t=this.F.one,e=1<<a,l=Array(e);for(let o=0;o<e;o++)l[o]=t,t=this.F.mul(t,this.w[a]);this.roots[a]=l}}fft(t){if(t.length<=1)return t;let a=U(t.length-1)+1;this._setRoots(a);let e=1<<a;if(t.length!=e)throw Error("Size must be multiple of 2");return Z(this,t,a,0,1)}ifft(t){if(t.length<=1)return t;let a=U(t.length-1)+1;this._setRoots(a);let e=1<<a;if(t.length!=e)throw Error("Size must be multiple of 2");let l=Z(this,t,a,0,1),o=this.F.inv(this.F.mulScalar(this.F.one,e)),i=Array(e);for(let t=0;t<e;t++)i[t]=this.opMulGF(l[(e-t)%e],o);return i}}function U(t){return((0xffff0000&t)!=0?(t&=0xffff0000,16):0)|((0xff00ff00&t)!=0?(t&=0xff00ff00,8):0)|((0xf0f0f0f0&t)!=0?(t&=0xf0f0f0f0,4):0)|((0xcccccccc&t)!=0?(t&=0xcccccccc,2):0)|(0xaaaaaaaa&t)!=0}function Z(t,a,e,l,o){let i=1<<e;if(1==i)return[a[l]];
1if(2==i)return[t.G.add(a[l],a[l+o]),t.G.sub(a[l],a[l+o])];let c=i>>1,n=Z(t,a,e-1,l,2*o),d=Z(t,a,e-1,l+o,2*o),r=Array(i);for(let a=0;a<c;a++)r[a]=t.G.add(n[a],t.opMulGF(d[a],t.roots[e][a])),r[a+c]=t.G.sub(n[a],t.opMulGF(d[a],t.roots[e][a]));return r}class ${constructor(t){this.type="F1",this.one=BigInt(1),this.zero=BigInt(0),this.p=BigInt(t),this.m=1,this.negone=this.p-this.one,this.two=BigInt(2),this.half=this.p>>this.one,this.bitLength=c(this.p),this.mask=(this.one<<BigInt(this.bitLength))-this.one,this.n64=Math.floor((this.bitLength-1)/64)+1,this.n32=2*this.n64,this.n8=8*this.n64,this.R=this.e(this.one<<BigInt(64*this.n64)),this.Ri=this.inv(this.R);const a=this.negone>>this.one;this.nqr=this.two;let e=this.pow(this.nqr,a);for(;!this.eq(e,this.negone);)this.nqr=this.nqr+this.one,e=this.pow(this.nqr,a);for(this.s=0,this.t=this.negone;(this.t&this.one)==this.zero;)this.s=this.s+1,this.t=this.t>>this.one;this.nqr_to_t=this.pow(this.nqr,this.t),function(t){if(t.m%2==1)if(y(x(t.p,4),1))if(y(x(t.p,8),1))if(y(x(t.p,16),1)){var a,e,l=t;for(l.sqrt_q=m(l.p,l.m),l.sqrt_s=0,l.sqrt_t=L(l.sqrt_q,1);!_(l.sqrt_t);)l.sqrt_s=l.sqrt_s+1,l.sqrt_t=b(l.sqrt_t,2);let o=l.one;for(;l.eq(o,l.one);){let t=l.random();l.sqrt_z=l.pow(t,l.sqrt_t),o=l.pow(l.sqrt_z,2**(l.sqrt_s-1))}l.sqrt_tm1d2=b(L(l.sqrt_t,1),2),l.sqrt=function(t){if(this.isZero(t))return this.zero;let a=this.pow(t,this.sqrt_tm1d2),e=this.pow(this.mul(this.square(a),t),2**(this.sqrt_s-1));if(this.eq(e,this.negone))return null;let l=this.sqrt_s,o=this.mul(t,a),i=this.mul(o,a),c=this.sqrt_z;for(;!this.eq(i,this.one);){let t=this.square(i),e=1;for(;!this.eq(t,this.one);)t=this.square(t),e++;a=c;for(let t=0;t<l-e-1;t++)a=this.square(a);c=this.square(a),i=this.mul(i,c),o=this.mul(o,a),l=e}return this.geq(o,this.zero)?o:this.neg(o)}}else if(y(x(t.p,16),9))t.sqrt=function(){throw Error("Sqrt alg 4 not implemented")};else throw Error("Field withot sqrt");else if(y(x(t.p,8),5))t.sqrt=function(){throw Error("Sqrt alg 3 not implemented")};else throw Error("Field withot sqrt");else{y(x(t.p,4),3)&&((a=t).sqrt_q=m(a.p,a.m),a.sqrt_e1=b(L(a.sqrt_q,3),4),a.sqrt=function(t){if(this.isZero(t))return this.zero;let e=this.pow(t,this.sqrt_e1),l=this.mul(this.square(e),t);if(this.eq(l,this.negone))return null;let o=this.mul(e,t);return a.geq(o,a.zero)?o:a.neg(o)})}else{let a=x(m(t.p,t.m/2),4);1==a?t.sqrt=function(){throw Error("Sqrt alg 10 not implemented")}:3==a?((e=t).sqrt_q=m(e.p,e.m/2),e.sqrt_e34=b(L(e.sqrt_q,3),4),e.sqrt_e12=b(L(e.sqrt_q,1),2),e.frobenius=function(t,a){return t%2==1?e.conjugate(a):a},e.sqrt=function(t){let a,e=this.pow(t,this.sqrt_e34),l=this.mul(this.square(e),t),o=this.mul(this.frobenius(1,l),l);if(this.eq(o,this.negone))return null;let i=this.mul(e,t);if(this.eq(l,this.negone))a=this.mul(i,[this.F.zero,this.F.one]);else{let t=this.pow(this.add(this.one,l),this.sqrt_e12);a=this.mul(t,i)}return this.geq(a,this.zero)?a:this.neg(a)}):t.sqrt=function(){throw Error("Sqrt alg 8 not implemented")}}}(this),this.FFT=new j(this,this,this.mul.bind(this)),this.fft=this.FFT.fft.bind(this.FFT),this.ifft=this.FFT.ifft.bind(this.FFT),this.w=this.FFT.w,this.wi=this.FFT.wi,this.shift=this.square(this.nqr),this.k=this.exp(this.nqr,2**this.s)}e(t,a){let e;if(a?16==a&&(e=BigInt("0x"+t)):e=BigInt(t),!(e<0))return e>=this.p?e%this.p:e;{let t=-e;return t>=this.p&&(t%=this.p),this.p-t}}add(t,a){let e=t+a;return e>=this.p?e-this.p:e}sub(t,a){return t>=a?t-a:this.p-a+t}neg(t){return t?this.p-t:t}mul(t,a){return t*a%this.p}mulScalar(t,a){return t*this.e(a)%this.p}square(t){return t*t%this.p}eq(t,a){return t==a}neq(t,a){return t!=a}lt(t,a){return(t>this.half?t-this.p:t)<(a>this.half?a-this.p:a)}gt(t,a){return(t>this.half?t-this.p:t)>(a>this.half?a-this.p:a)}leq(t,a){return(t>this.half?t-this.p:t)<=(a>this.half?a-this.p:a)}geq(t,a){return(t>this.half?t-this.p:t)>=(a>this.half?a-this.p:a)}div(t,a){return this.mul(t,this.inv(a))}idiv(t,a){if(!a)throw Error("Division by zero");return t/a}inv(t){if(!t)throw Error("Division by zero");let a=this.zero,e=this.p,l=this.one,o=t%this.p;for(;o;){let t=e/o;[a,l]=[l,a-t*l],[e,o]=[o,e-t*o]}return a<this.zero&&(a+=this.p),a}mod(t,a){return t%a}pow(t,a){return z(this,t,a)}exp(t,a){return z(this,t,a)}band(t,a){let e=t&a&this.mask;return e>=this.p?e-this.p:e}bor(t,a){let e=(t|a)&this.mask;return e>=this.p?e-this.p:e}bxor(t,a){let e=(t^a)&this.mask;return e>=this.p?e-this.p:e}bnot(t){let a=t^this.mask;return a>=this.p?a-this.p:a}shl(t,a){if(Number(a)<this.bitLength){let e=t<<a&this.mask;return e>=this.p?e-this.p:e}{let e=this.p-a;return Number(e)<this.bitLength?t>>e:this.zero}}
1shr(t,a){if(Number(a)<this.bitLength)return t>>a;{let e=this.p-a;if(!(Number(e)<this.bitLength))return 0;{let a=t<<e&this.mask;return a>=this.p?a-this.p:a}}}land(t,a){return t&&a?this.one:this.zero}lor(t,a){return t||a?this.one:this.zero}lnot(t){return t?this.zero:this.one}sqrt_old(t){if(t==this.zero)return this.zero;if(this.pow(t,this.negone>>this.one)!=this.one)return null;let a=this.s,e=this.nqr_to_t,l=this.pow(t,this.t),o=this.pow(t,this.add(this.t,this.one)>>this.one);for(;l!=this.one;){let t=this.square(l),i=1;for(;t!=this.one;)i++,t=this.square(t);let c=e;for(let t=0;t<a-i-1;t++)c=this.square(c);a=i,e=this.square(c),l=this.mul(l,e),o=this.mul(o,c)}return o>this.p>>this.one&&(o=this.neg(o)),o}normalize(t,a){if(!((t=BigInt(t,a))<0))return t>=this.p?t%this.p:t;{let a=-t;return a>=this.p&&(a%=this.p),this.p-a}}random(){let t=2*this.bitLength/8,a=this.zero;for(let e=0;e<t;e++)a=(a<<BigInt(8))+BigInt(G(1)[0]);return a%this.p}toString(t,a){return a=a||10,t>this.half&&10==a?"-"+(this.p-t).toString(a):t.toString(a)}isZero(t){return t==this.zero}fromRng(t){let a;do{a=this.zero;for(let e=0;e<this.n64;e++)a+=t.nextU64()<<BigInt(64*e);a&=this.mask}while(a>=this.p);return a*this.Ri%this.p}fft(t){return this.FFT.fft(t)}ifft(t){return this.FFT.ifft(t)}toRprLE(t,a,e){P(t,a,e,8*this.n64)}toRprBE(t,a,e){A(t,a,e,8*this.n64)}toRprBEM(t,a,e){return this.toRprBE(t,a,this.mul(this.R,e))}toRprLEM(t,a,e){return this.toRprLE(t,a,this.mul(this.R,e))}fromRprLE(t,a){return q(t,a,this.n8)}fromRprBE(t,a){return v(t,a,this.n8)}fromRprLEM(t,a){return this.mul(this.fromRprLE(t,a),this.Ri)}fromRprBEM(t,a){return this.mul(this.fromRprBE(t,a),this.Ri)}toObject(t){return t}}var Q={};Q.bigInt2BytesLE=function(t,a){let e=Array(a),l=BigInt(t);for(let t=0;t<a;t++)e[t]=Number(255n&l),l>>=8n;return e},Q.bigInt2U32LE=function(t,a){let e=Array(a),l=BigInt(t);for(let t=0;t<a;t++)e[t]=Number(4294967295n&l),l>>=32n;return e},Q.isOcamNum=function(t){return!!Array.isArray(t)&&3==t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&!!Array.isArray(t[2])};var J=function(t,a,e,l,o,i,c){let n=t.addFunction(a);n.addParam("base","i32"),n.addParam("scalar","i32"),n.addParam("scalarLength","i32"),n.addParam("r","i32"),n.addLocal("i","i32"),n.addLocal("b","i32");let d=n.getCodeBuilder(),r=d.i32_const(t.alloc(e));n.addCode(d.if(d.i32_eqz(d.getLocal("scalarLength")),[...d.call(c,d.getLocal("r")),...d.ret([])])),n.addCode(d.call(i,d.getLocal("base"),r)),n.addCode(d.call(c,d.getLocal("r"))),n.addCode(d.setLocal("i",d.getLocal("scalarLength"))),n.addCode(d.block(d.loop(d.setLocal("i",d.i32_sub(d.getLocal("i"),d.i32_const(1))),d.setLocal("b",d.i32_load8_u(d.i32_add(d.getLocal("scalar"),d.getLocal("i")))),...function(){let t=[];for(let a=0;a<8;a++)t.push(...d.call(o,d.getLocal("r"),d.getLocal("r")),...d.if(d.i32_ge_u(d.getLocal("b"),d.i32_const(128>>a)),[...d.setLocal("b",d.i32_sub(d.getLocal("b"),d.i32_const(128>>a))),...d.call(l,d.getLocal("r"),r,d.getLocal("r"))]));return t}(),d.br_if(1,d.i32_eqz(d.getLocal("i"))),d.br(0))))};function W(t,a){let e=8*t.modules[a].n64,l=t.addFunction(a+"_batchInverse");l.addParam("pIn","i32"),l.addParam("inStep","i32"),l.addParam("n","i32"),l.addParam("pOut","i32"),l.addParam("outStep","i32"),l.addLocal("itAux","i32"),l.addLocal("itIn","i32"),l.addLocal("itOut","i32"),l.addLocal("i","i32");let o=l.getCodeBuilder(),i=o.i32_const(t.alloc(e));l.addCode(o.setLocal("itAux",o.i32_load(o.i32_const(0))),o.i32_store(o.i32_const(0),o.i32_add(o.getLocal("itAux"),o.i32_mul(o.i32_add(o.getLocal("n"),o.i32_const(1)),o.i32_const(e))))),l.addCode(o.call(a+"_one",o.getLocal("itAux")),o.setLocal("itIn",o.getLocal("pIn")),o.setLocal("itAux",o.i32_add(o.getLocal("itAux"),o.i32_const(e))),o.setLocal("i",o.i32_const(0)),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("i"),o.getLocal("n"))),o.if(o.call(a+"_isZero",o.getLocal("itIn")),o.call(a+"_copy",o.i32_sub(o.getLocal("itAux"),o.i32_const(e)),o.getLocal("itAux")),o.call(a+"_mul",o.getLocal("itIn"),o.i32_sub(o.getLocal("itAux"),o.i32_const(e)),o.getLocal("itAux"))),o.setLocal("itIn",o.i32_add(o.getLocal("itIn"),o.getL
1ocal("inStep"))),o.setLocal("itAux",o.i32_add(o.getLocal("itAux"),o.i32_const(e))),o.setLocal("i",o.i32_add(o.getLocal("i"),o.i32_const(1))),o.br(0))),o.setLocal("itIn",o.i32_sub(o.getLocal("itIn"),o.getLocal("inStep"))),o.setLocal("itAux",o.i32_sub(o.getLocal("itAux"),o.i32_const(e))),o.setLocal("itOut",o.i32_add(o.getLocal("pOut"),o.i32_mul(o.i32_sub(o.getLocal("n"),o.i32_const(1)),o.getLocal("outStep")))),o.call(a+"_inverse",o.getLocal("itAux"),o.getLocal("itAux")),o.block(o.loop(o.br_if(1,o.i32_eqz(o.getLocal("i"))),o.if(o.call(a+"_isZero",o.getLocal("itIn")),[...o.call(a+"_copy",o.getLocal("itAux"),o.i32_sub(o.getLocal("itAux"),o.i32_const(e))),...o.call(a+"_zero",o.getLocal("itOut"))],[...o.call(a+"_copy",o.i32_sub(o.getLocal("itAux"),o.i32_const(e)),i),...o.call(a+"_mul",o.getLocal("itAux"),o.getLocal("itIn"),o.i32_sub(o.getLocal("itAux"),o.i32_const(e))),...o.call(a+"_mul",o.getLocal("itAux"),i,o.getLocal("itOut"))]),o.setLocal("itIn",o.i32_sub(o.getLocal("itIn"),o.getLocal("inStep"))),o.setLocal("itOut",o.i32_sub(o.getLocal("itOut"),o.getL
1ocal("outStep"))),o.setLocal("itAux",o.i32_sub(o.getLocal("itAux"),o.i32_const(e))),o.setLocal("i",o.i32_sub(o.getLocal("i"),o.i32_const(1))),o.br(0)))),l.addCode(o.i32_store(o.i32_const(0),o.getLocal("itAux")))}function D(t,a,e,l,o,i){void 0===i&&(i=l<o);let c=t.addFunction(a);c.addParam("pIn","i32"),c.addParam("n","i32"),c.addParam("pOut","i32"),c.addLocal("i","i32"),c.addLocal("itIn","i32"),c.addLocal("itOut","i32");let n=c.getCodeBuilder();i?c.addCode(n.setLocal("itIn",n.i32_add(n.getLocal("pIn"),n.i32_mul(n.i32_sub(n.getLocal("n"),n.i32_const(1)),n.i32_const(l)))),n.setLocal("itOut",n.i32_add(n.getLocal("pOut"),n.i32_mul(n.i32_sub(n.getLocal("n"),n.i32_const(1)),n.i32_const(o)))),n.setLocal("i",n.i32_const(0)),n.block(n.loop(n.br_if(1,n.i32_eq(n.getLocal("i"),n.getLocal("n"))),n.call(e,n.getLocal("itIn"),n.getLocal("itOut")),n.setLocal("itIn",n.i32_sub(n.getLocal("itIn"),n.i32_const(l))),n.setLocal("itOut",n.i32_sub(n.getLocal("itOut"),n.i32_const(o))),n.setLocal("i",n.i32_add(n.getLocal("i"),n.i32_const(1))),n.br(0)))):c.addCode(n.setLocal("itIn",n.getLocal("pIn")),n.setLocal("itOut",n.getLocal("pOut")),n.setLocal("i",n.i32_const(0)),n.block(n.loop(n.br_if(1,n.i32_eq(n.getLocal("i"),n.getLocal("n"))),n.call(e,n.getLocal("itIn"),n.getLocal("itOut")),n.setLocal("itIn",n.i32_add(n.getLocal("itIn"),n.i32_const(l))),n.setLocal("itOut",n.i32_add(n.getLocal("itOut"),n.i32_const(o))),n.setLocal("i",n.i32_add(n.getLocal("i"),n.i32_const(1))),n.br(0))))}var V={};function K(t,a){return t===a?0:t>a?1:-1}function X(t){return t%2n!==0n}function Y(t){return t%2n===0n}function H(t){return t<0n?t.toString(2).length-1:t.toString(2).length}function tt(t){return t<0n?-t:t}function ta(t){return 1n===tt(t)}function te(t,a){for(var e,l,o,i=0n,c=1n,n=a,d=tt(t);0n!==d;)e=n/d,l=i,o=n,i=c,n=d,c=l-e*c,d=o-e*d;if(!ta(n))throw Error(t.toString()+" and "+a.toString()+" are not co-prime");return(-1===K(i,0n)&&(i+=a),t<0n)?-i:i}function tl(t,a,e){if(0n===e)throw Error("Cannot take modPow with modulus 0");var l,o=1n,i=t%e;for(a<0n&&(a=-(1n*a),i=te(i,e));a>0n;){if(0n===i)return 0n;X(a)&&(o=o*i%e),a/=2n,i=(l=i)*l%e}return o}function to(t,a){var e,l;return 0n!==a&&(!!ta(a)||(0==(l=2n,(e=(e=a)>=0n?e:-e)===(l=l>=0n?l:-l)?0:e>l?1:-1)?Y(t):t%a===0n))}function ti(t,a){for(var e,l,o,i,c=t-1n,n=c,d=0;Y(n);)n/=2n,d++;t:for(o=0;o<a.length;o++)if(!(t<a[o])&&!ta(i=tl(BigInt(a[o]),n,t))&&i!==c){for(l=d-1;0!=l&&!ta(i=(e=i)*e%t);l--){;if(i===c)continue t}return!1}return!0}V.bitLength=H,V.isOdd=X,V.isNegative=function(t){return t<0n},V.abs=tt,V.isUnit=ta,V.compare=K,V.modInv=te,V.modPow=tl,V.isPrime=function(t){var a,e=!ta(a=tt(t))&&(2n===a||3n===a||5n===a||!(Y(a)||to(a,3n)||to(a,5n))&&(a<49n||void 0));if(void 0!==e)return e;var l=tt(t),o=H(l);if(o<=64)return ti(l,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var i=Math.ceil(Math.log(2)*Number(o)),c=[],n=0;n<i;n++)c.push(BigInt(n+2));return ti(l,c)},V.square=function(t){return t*t};let tc=function(t,a,e){let l,o,i,c,n,d,r,s,_,f,u,g,L,p,h,m,b,x,y=e||"int";if(t.modules[y])return y;t.modules[y]={};let F=2*a,C=8*a,B=t.addFunction(y+"_copy");B.addParam("px","i32"),B.addParam("pr","i32");let P=B.getCodeBuilder();for(let t=0;t<a;t++)B.addCode(P.i64_store(P.getLocal("pr"),8*t,P.i64_load(P.getLocal("px"),8*t)));let A=t.addFunction(y+"_zero");A.addParam("pr","i32");let q=A.getCodeBuilder();for(let t=0;t<a;t++)A.addCode(q.i64_store(q.getLocal("pr"),8*t,q.i64_const(0)));(l=t.addFunction(y+"_isZero")).addParam("px","i32"),l.setReturnType("i32"),o=l.getCodeBuilder(),l.addCode(function t(a){return 0==a?o.ret(o.i64_eqz(o.i64_load(o.getLocal("px")))):o.if(o.i64_eqz(o.i64_load(o.getLocal("px"),8*a)),t(a-1),o.ret(o.i32_const(0)))}(a-1)),l.addCode(o.ret(o.i32_const(0)));let v=t.addFunction(y+"_one");v.addParam("pr","i32");let I=v.getCodeBuilder();v.addCode(I.i64_store(I.getLocal("pr"),0,I.i64_const(1)));for(let t=1;t<a;t++)v.addCode(I.i64_store(I.getLocal("pr"),8*t,I.i64_const(0)));(i=t.addFunction(y+"_eq")).addParam("px","i32"),i.addParam("py","i32"),i.setReturnType("i32"),c=i.getCodeBuilder(),i.addCode(function t(a){return 0==a?c.ret(c.i64_eq(c.i64_load(c.getLocal("px")),c.i64_load(c.getLocal("py")))):c.if(c.i64_eq(c.i64_load(c.getLocal("px"),8*a),c.i64_load(c.getLocal("py"),8*a)),t(a-1),c.ret(c.i32_const(0)))}(a-1)),i.addCode(c.ret(c.i32_const(0))),(n=t.addFunction(y+"_gte")).addParam("px","i32"),n.addParam("py","i32"),n.setReturnType("i32"),d=n.getCodeBuilder(),n.addCode(function t(a){return 0==a?d.ret(d.i64_ge_u(d.i64_load(d.getLocal("px")),d.i64_load(d.getLocal("py")))):d.if(d.i64_lt_u(d.i64_load(d.getLocal("px"),8*a),d.i64_load(d.getLocal("py"),8*a)),d.ret(d.i32_const(0)),d.if(d.i64_gt_u(d.i64_load(d.getLocal("px"),8*a),d.i64_load(d.getLocal("py"),8*a)),d.ret(d.i32_const(1)),t(a-1)))}(a-1)),n.addCode(d.ret(d.i32_const(0)));let O=t.addFunction(y+"_add");O.addParam("x","i32"),O.addParam("y","i32"),O.addParam("r","i32"),O.setReturnType("i32"),O.addLocal("c","i64");let E=O.getCodeBuilder();
1O.addCode(E.setLocal("c",E.i64_add(E.i64_load32_u(E.getLocal("x")),E.i64_load32_u(E.getLocal("y"))))),O.addCode(E.i64_store32(E.getLocal("r"),E.getLocal("c")));for(let t=1;t<F;t++)O.addCode(E.setLocal("c",E.i64_add(E.i64_add(E.i64_load32_u(E.getLocal("x"),4*t),E.i64_load32_u(E.getLocal("y"),4*t)),E.i64_shr_u(E.getLocal("c"),E.i64_const(32))))),O.addCode(E.i64_store32(E.getLocal("r"),4*t,E.getLocal("c")));O.addCode(E.i32_wrap_i64(E.i64_shr_u(E.getLocal("c"),E.i64_const(32))));let w=t.addFunction(y+"_sub");w.addParam("x","i32"),w.addParam("y","i32"),w.addParam("r","i32"),w.setReturnType("i32"),w.addLocal("c","i64");let M=w.getCodeBuilder();w.addCode(M.setLocal("c",M.i64_sub(M.i64_load32_u(M.getLocal("x")),M.i64_load32_u(M.getLocal("y"))))),w.addCode(M.i64_store32(M.getLocal("r"),M.i64_and(M.getLocal("c"),M.i64_const("0xFFFFFFFF"))));for(let t=1;t<F;t++)w.addCode(M.setLocal("c",M.i64_add(M.i64_sub(M.i64_load32_u(M.getLocal("x"),4*t),M.i64_load32_u(M.getLocal("y"),4*t)),M.i64_shr_s(M.getLocal("c"),M.i64_const(32))))),w.addCode(M.i64_store32(M.getLocal("r"),4*t,M.i64_and(M.getLocal("c"),M.i64_const("0xFFFFFFFF"))));return w.addCode(M.i32_wrap_i64(M.i64_shr_s(M.getLocal("c"),M.i64_const(32)))),function(){let a=t.addFunction(y+"_mul");a.addParam("x","i32"),a.addParam("y","i32"),a.addParam("r","i32"),a.addLocal("c0","i64"),a.addLocal("c1","i64");for(let t=0;t<F;t++)a.addLocal("x"+t,"i64"),a.addLocal("y"+t,"i64");let e=a.getCodeBuilder(),l=[],o=[],i="c0",c="c1";for(let t=0;t<2*F-1;t++){for(let n=Math.max(0,t-F+1);n<=t&&n<F;n++){let d=t-n;a.addCode(e.setLocal(i,e.i64_add(e.i64_and(e.getLocal(i),e.i64_const(0xffffffff)),function(t,a){let i,c;return l[t]?i=e.getLocal("x"+t):(i=e.teeLocal("x"+t,e.i64_load32_u(e.getLocal("x"),4*t)),l[t]=!0),o[a]?c=e.getLocal("y"+a):(c=e.teeLocal("y"+a,e.i64_load32_u(e.getLocal("y"),4*a)),o[a]=!0),e.i64_mul(i,c)}(n,d)))),a.addCode(e.setLocal(c,e.i64_add(e.getLocal(c),e.i64_shr_u(e.getLocal(i),e.i64_const(32)))))}a.addCode(e.i64_store32(e.getLocal("r"),4*t,e.getLocal(i))),[i,c]=[c,i],a.addCode(e.setLocal(c,e.i64_shr_u(e.getLocal(i),e.i64_const(32))))}a.addCode(e.i64_store32(e.getLocal("r"),4*F*2-4,e.getLocal(i)))}(),function(){let a=t.addFunction(y+"_square");a.addParam("x","i32"),a.addParam("r","i32"),a.addLocal("c0","i64"),a.addLocal("c1","i64"),a.addLocal("c0_old","i64"),a.addLocal("c1_old","i64");for(let t=0;t<F;t++)a.addLocal("x"+t,"i64");let e=a.getCodeBuilder(),l=[];function o(t,a){let o,i;return l[t]?o=e.getLocal("x"+t):(o=e.teeLocal("x"+t,e.i64_load32_u(e.getLocal("x"),4*t)),l[t]=!0),l[a]?i=e.getLocal("x"+a):(i=e.teeLocal("x"+a,e.i64_load32_u(e.getLocal("x"),4*a)),l[a]=!0),e.i64_mul(o,i)}let i="c0_old",c="c1_old";for(let t=0;t<2*F-1;t++){a.addCode(e.setLocal("c0",e.i64_const(0)),e.setLocal("c1",e.i64_const(0)));for(let l=Math.max(0,t-F+1);l<t+1>>1&&l<F;l++){let i=t-l;a.addCode(e.setLocal("c0",e.i64_add(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),o(l,i)))),a.addCode(e.setLocal("c1",e.i64_add(e.getLocal("c1"),e.i64_shr_u(e.getLocal("c0"),e.i64_const(32)))))}a.addCode(e.setLocal("c0",e.i64_shl(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),e.i64_const(1)))),a.addCode(e.setLocal("c1",e.i64_add(e.i64_shl(e.getLocal("c1"),e.i64_const(1)),e.i64_shr_u(e.getLocal("c0"),e.i64_const(32))))),t%2==0&&(a.addCode(e.setLocal("c0",e.i64_add(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),o(t>>1,t>>1)))),a.addCode(e.setLocal("c1",e.i64_add(e.getLocal("c1"),e.i64_shr_u(e.getLocal("c0"),e.i64_const(32)))))),t>0&&(a.addCode(e.setLocal("c0",e.i64_add(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),e.i64_and(e.getLocal(i),e.i64_const(0xffffffff))))),a.addCode(e.setLocal("c1",e.i64_add(e.i64_add(e.getLocal("c1"),e.i64_shr_u(e.getLocal("c0"),e.i64_const(32))),e.getLocal(c))))),a.addCode(e.i64_store32(e.getLocal("r"),4*t,e.getLocal("c0"))),a.addCode(e.setLocal(i,e.getLocal("c1")),e.setLocal(c,e.i64_shr_u(e.getLocal(i),e.i64_const(32))))}a.addCode(e.i64_store32(e.getLocal("r"),4*F*2-4,e.getLocal(i)))}(),(r=t.addFunction(y+"_squareOld")).addParam("x","i32"),r.addParam("r","i32"),s=r.getCodeBuilder(),r.addCode(s.call(y+"_mul",s.getLocal("x"),s.getLocal("x"),s.getLocal("r"))),function(){let a,e,l=t.addFunction(y+"__mul1");l.addParam("px","i32"),l.addParam("y","i64"),l.addParam("pr","i32"),l.addLocal("c","i64");let o=l.getCodeBuilder();
1l.addCode(o.setLocal("c",o.i64_mul(o.i64_load32_u(o.getLocal("px"),0,0),o.getLocal("y")))),l.addCode(o.i64_store32(o.getLocal("pr"),0,0,o.getLocal("c")));for(let t=1;t<F;t++)l.addCode(o.setLocal("c",o.i64_add(o.i64_mul(o.i64_load32_u(o.getLocal("px"),4*t,0),o.getLocal("y")),o.i64_shr_u(o.getLocal("c"),o.i64_const(32))))),l.addCode(o.i64_store32(o.getLocal("pr"),4*t,0,o.getLocal("c")));(a=t.addFunction(y+"__add1")).addParam("x","i32"),a.addParam("y","i64"),a.addLocal("c","i64"),a.addLocal("px","i32"),e=a.getCodeBuilder(),a.addCode(e.setLocal("px",e.getLocal("x"))),a.addCode(e.setLocal("c",e.i64_add(e.i64_load32_u(e.getLocal("px"),0,0),e.getLocal("y")))),a.addCode(e.i64_store32(e.getLocal("px"),0,0,e.getLocal("c"))),a.addCode(e.setLocal("c",e.i64_shr_u(e.getLocal("c"),e.i64_const(32)))),a.addCode(e.block(e.loop(e.br_if(1,e.i64_eqz(e.getLocal("c"))),e.setLocal("px",e.i32_add(e.getLocal("px"),e.i32_const(4))),e.setLocal("c",e.i64_add(e.i64_load32_u(e.getLocal("px"),0,0),e.getLocal("c"))),e.i64_store32(e.getLocal("px"),0,0,e.getLocal("c")),e.setLocal("c",e.i64_shr_u(e.getLocal("c"),e.i64_const(32))),e.br(0))));let i=t.addFunction(y+"_div");i.addParam("x","i32"),i.addParam("y","i32"),i.addParam("c","i32"),i.addParam("r","i32"),i.addLocal("rr","i32"),i.addLocal("cc","i32"),i.addLocal("eX","i32"),i.addLocal("eY","i32"),i.addLocal("sy","i64"),i.addLocal("sx","i64"),i.addLocal("ec","i32");let c=i.getCodeBuilder(),n=c.i32_const(t.alloc(C)),d=c.i32_const(t.alloc(C)),r=c.i32_const(t.alloc(C)),s=c.getLocal("cc"),_=c.getLocal("rr"),f=t.alloc(2*C),u=c.i32_const(f),g=c.i32_const(f+C);i.addCode(c.if(c.getLocal("c"),c.setLocal("cc",c.getLocal("c")),c.setLocal("cc",d))),i.addCode(c.if(c.getLocal("r"),c.setLocal("rr",c.getLocal("r")),c.setLocal("rr",r))),i.addCode(c.call(y+"_copy",c.getLocal("x"),_)),i.addCode(c.call(y+"_copy",c.getLocal("y"),n)),i.addCode(c.call(y+"_zero",s)),i.addCode(c.call(y+"_zero",u)),i.addCode(c.setLocal("eX",c.i32_const(C-1))),i.addCode(c.setLocal("eY",c.i32_const(C-1))),i.addCode(c.block(c.loop(c.br_if(1,c.i32_or(c.i32_load8_u(c.i32_add(n,c.getLocal("eY")),0,0),c.i32_eq(c.getLocal("eY"),c.i32_const(3)))),c.setLocal("eY",c.i32_sub(c.getLocal("eY"),c.i32_const(1))),c.br(0)))),i.addCode(c.setLocal("sy",c.i64_add(c.i64_load32_u(c.i32_sub(c.i32_add(n,c.getLocal("eY")),c.i32_const(3)),0,0),c.i64_const(1)))),i.addCode(c.if(c.i64_eq(c.getLocal("sy"),c.i64_const(1)),c.drop(c.i64_div_u(c.i64_const(0),c.i64_const(0))))),i.addCode(c.block(c.loop(c.block(c.loop(c.br_if(1,c.i32_or(c.i32_load8_u(c.i32_add(_,c.getLocal("eX")),0,0),c.i32_eq(c.getLocal("eX"),c.i32_const(7)))),c.setLocal("eX",c.i32_sub(c.getLocal("eX"),c.i32_const(1))),c.br(0))),c.setLocal("sx",c.i64_load(c.i32_sub(c.i32_add(_,c.getLocal("eX")),c.i32_const(7)),0,0)),c.setLocal("sx",c.i64_div_u(c.getLocal("sx"),c.getLocal("sy"))),c.setLocal("ec",c.i32_sub(c.i32_sub(c.getLocal("eX"),c.getLocal("eY")),c.i32_const(4))),c.block(c.loop(c.br_if(1,c.i32_and(c.i64_eqz(c.i64_and(c.getLocal("sx"),c.i64_const("0xFFFFFFFF00000000"))),c.i32_ge_s(c.getLocal("ec"),c.i32_const(0)))),c.set
1Local("sx",c.i64_shr_u(c.getLocal("sx"),c.i64_const(8))),c.setLocal("ec",c.i32_add(c.getLocal("ec"),c.i32_const(1))),c.br(0))),c.if(c.i64_eqz(c.getLocal("sx")),[...c.br_if(2,c.i32_eqz(c.call(y+"_gte",_,n))),...c.setLocal("sx",c.i64_const(1)),...c.setLocal("ec",c.i32_const(0))]),c.call(y+"__mul1",n,c.getLocal("sx"),g),c.drop(c.call(y+"_sub",_,c.i32_sub(g,c.getLocal("ec")),_)),c.call(y+"__add1",c.i32_add(s,c.getLocal("ec")),c.getLocal("sx")),c.br(0))))}(),(_=t.addFunction(y+"_inverseMod")).addParam("px","i32"),_.addParam("pm","i32"),_.addParam("pr","i32"),_.addLocal("t","i32"),_.addLocal("newt","i32"),_.addLocal("r","i32"),_.addLocal("qq","i32"),_.addLocal("qr","i32"),_.addLocal("newr","i32"),_.addLocal("swp","i32"),_.addLocal("x","i32"),_.addLocal("signt","i32"),_.addLocal("signnewt","i32"),_.addLocal("signx","i32"),u=(f=_.getCodeBuilder()).i32_const(t.alloc(C)),g=f.i32_const(t.alloc(C)),L=f.i32_const(t.alloc(C)),p=f.i32_const(t.alloc(C)),h=f.i32_const(t.alloc(C)),m=f.i32_const(t.alloc(C)),b=f.i32_const(t.alloc(2*C)),x=f.i32_const(t.alloc(C)),_.addCode(f.setLocal("t",u),f.call(y+"_zero",u),f.setLocal("signt",f.i32_const(0))),_.addCode(f.setLocal("r",g),f.call(y+"_copy",f.getLocal("pm"),g)),_.addCode(f.setLocal("newt",L),f.call(y+"_one",L),f.setLocal("signnewt",f.i32_const(0))),_.addCode(f.setLocal("newr",p),f.call(y+"_copy",f.getLocal("px"),p)),_.addCode(f.setLocal("qq",h)),_.addCode(f.setLocal("qr",m)),_.addCode(f.setLocal("x",x)),_.addCode(f.block(f.loop(f.br_if(1,f.call(y+"_isZero",f.getLocal("newr"))),f.call(y+"_div",f.getLocal("r"),f.getLocal("newr"),f.getLocal("qq"),f.getLocal("qr")),f.call(y+"_mul",f.getLocal("qq"),f.getLocal("newt"),b),f.if(f.getLocal("signt"),f.if(f.getLocal("signnewt"),f.if(f.call(y+"_gte",b,f.getLocal("t")),[...f.drop(f.call(y+"_sub",b,f.getLocal("t"),f.getLocal("x"))),...f.setLocal("signx",f.i32_const(0))],[...f.drop(f.call(y+"_sub",f.getLocal("t"),b,f.getLocal("x"))),...f.setLocal("signx",f.i32_const(1))]),[...f.drop(f.call(y+"_add",b,f.getLocal("t"),f.getLocal("x"))),...f.setLocal("signx",f.i32_const(1))]),f.if(f.getLocal("signnewt"),[...f.drop(f.call(y+"_add",b,f.getLocal("t"),f.getLocal("x"))),...f.setLocal("signx",f.i32_const(0))],f.if(f.call(y+"_gte",f.getLocal("t"),b),[...f.drop(f.call(y+"_sub",f.getLocal("t"),b,f.getLocal("x"))),...f.setLocal("signx",f.i32_const(0))],[...f.drop(f.call(y+"_sub",b,f.getLocal("t"),f.getLocal("x"))),...f.setLocal("signx",f.i32_const(1))]))),f.setLocal("swp",f.getLocal("t")),f.setLocal("t",f.getLocal("newt")),f.setLocal("newt",f.getLocal("x")),f.setLocal("x",f.getLocal("swp")),f.setLocal("signt",f.getLocal("signnewt")),f.setLocal("signnewt",f.getLocal("signx")),f.setLocal("swp",f.getLocal("r")),f.setLocal("r",f.getLocal("newr")),f.setLocal("newr",f.getLocal("qr")),f.setLocal("qr",f.getLocal("swp")),f.br(0)))),_.addCode(f.if(f.getLocal("signt"),f.drop(f.call(y+"_sub",f.getLocal("pm"),f.getLocal("t"),f.getLocal("pr"))),f.call(y+"_copy",f.getLocal("t"),f.getLocal("pr")))),t.exportFunction(y+"_copy"),t.exportFunction(y+"_zero"),t.exportFunction(y+"_one"),t.exportFunction(y+"_isZero"),t.exportFunction(y+"_eq"),t.exportFunction(y+"_gte"),t.exportFunction(y+"_add"),t.exp
1ortFunction(y+"_sub"),t.exportFunction(y+"_mul"),t.exportFunction(y+"_square"),t.exportFunction(y+"_squareOld"),t.exportFunction(y+"_div"),t.exportFunction(y+"_inverseMod"),y},tn=function(t,a,e,l,o,i){void 0===i&&(i=l<o);let c=t.addFunction(a);c.addParam("pIn1","i32"),c.addParam("pIn2","i32"),c.addParam("n","i32"),c.addParam("pOut","i32"),c.addLocal("i","i32"),c.addLocal("itIn1","i32"),c.addLocal("itIn2","i32"),c.addLocal("itOut","i32");let n=c.getCodeBuilder();i?c.addCode(n.setLocal("itIn1",n.i32_add(n.getLocal("pIn1"),n.i32_mul(n.i32_sub(n.getLocal("n"),n.i32_const(1)),n.i32_const(l)))),n.setLocal("itIn2",n.i32_add(n.getLocal("pIn2"),n.i32_mul(n.i32_sub(n.getLocal("n"),n.i32_const(1)),n.i32_const(l)))),n.setLocal("itOut",n.i32_add(n.getLocal("pOut"),n.i32_mul(n.i32_sub(n.getLocal("n"),n.i32_const(1)),n.i32_const(o)))),n.setLocal("i",n.i32_const(0)),n.block(n.loop(n.br_if(1,n.i32_eq(n.getLocal("i"),n.getLocal("n"))),n.call(e,n.getLocal("itIn1"),n.getLocal("itIn2"),n.getLocal("itOut")),n.setLocal("itIn1",n.i32_sub(n.getLocal("itIn1"),n.i32_const(l))),n.setLocal("itIn2",n.i32_sub(n.getLocal("itIn2"),n.i32_const(l))),n.setLocal("itOut",n.i32_sub(n.getLocal("itOut"),n.i32_const(o))),n.setLocal("i",n.i32_add(n.getLocal("i"),n.i32_const(1))),n.br(0)))):c.addCode(n.setLocal("itIn1",n.getLocal("pIn1")),n.setLocal("itIn2",n.getLocal("pIn2")),n.setLocal("itOut",n.getLocal("pOut")),n.setLocal("i",n.i32_const(0)),n.block(n.loop(n.br_if(1,n.i32_eq(n.getLocal("i"),n.getLocal("n"))),n.call(e,n.getLocal("itIn1"),n.getLocal("itIn2"),n.getLocal("itOut")),n.setLocal("itIn1",n.i32_add(n.getLocal("itIn1"),n.i32_const(l))),n.setLocal("itIn2",n.i32_add(n.getLocal("itIn2"),n.i32_const(l))),n.setLocal("itOut",n.i32_add(n.getLocal("itOut"),n.i32_const(o))),n.setLocal("i",n.i32_add(n.getLocal("i"),n.i32_const(1))),n.br(0))))},{bitLength:td,modInv:tr,modPow:ts,isPrime:t_,isOdd:tf,square:tu}=V;var tg=function(t,a,e,l){let o,i,c,n,d,r,s,_,f,u,g,L,p,h,m,b,x,y,F,C,B,P,A,q,v,I,O,E,w,M,S,z,T,k=BigInt(a),G=Math.floor((td(k-1n)-1)/64)+1,N=2*G,R=8*G,j=e||"f1m";if(t.modules[j])return j;let U=tc(t,G,l),Z=t.alloc(R,Q.bigInt2BytesLE(k,R)),$=t.alloc(Q.bigInt2BytesLE(tu(1n<<BigInt(64*G))%k,R)),V=t.alloc(Q.bigInt2BytesLE((1n<<BigInt(64*G))%k,R)),K=t.alloc(Q.bigInt2BytesLE(0n,R)),X=k-1n,Y=X>>1n,H=t.alloc(R,Q.bigInt2BytesLE(Y,R)),tt=t.alloc(R,Q.bigInt2BytesLE(Y+1n,R));t.modules[j]={pq:Z,pR2:$,n64:G,q:k,pOne:V,pZero:K,pePlusOne:tt};let ta=2n;if(t_(k))for(;ts(ta,Y,k)!==X;)ta+=1n;let te=0,tl=X;for(;!tf(tl)&&0n!==tl;)te++,tl>>=1n;let to=t.alloc(R,Q.bigInt2BytesLE(tl,R)),ti=ts(ta,tl,k),tg=t.alloc(Q.bigInt2BytesLE((ti<<BigInt(64*G))%k,R)),tL=tl+1n>>1n,tp=t.alloc(R,Q.bigInt2BytesLE(tL,R));if(t.exportFunction(U+"_copy",j+"_copy"),t.exportFunction(U+"_zero",j+"_zero"),t.exportFunction(U+"_isZero",j+"_isZero"),t.exportFunction(U+"_eq",j+"_eq"),(o=t.addFunction(j+"_isOne")).addParam("x","i32"),o.setReturnType("i32"),i=o.getCodeBuilder(),o.addCode(i.ret(i.call(U+"_eq",i.getLocal("x"),i.i32_const(V)))),(c=t.addFunction(j+"_add")).addParam("x","i32"),c.addParam("y","i32"),c.addParam("r","i32"),n=c.getCodeBuilder(),c.addCode(n.if(n.call(U+"_add",n.getLocal("x"),n.getLocal("y"),n.getLocal("r")),n.drop(n.call(U+"_sub",n.getLocal("r"),n.i32_const(Z),n.getLocal("r"))),n.if(n.call(U+"_gte",n.getLocal("r"),n.i32_const(Z)),n.drop(n.call(U+"_sub",n.getLocal("r"),n.i32_const(Z),n.getLocal("r")))))),(d=t.addFunction(j+"_sub")).addParam("x","i32"),d.addParam("y","i32"),d.addParam("r","i32"),r=d.getCodeBuilder(),d.addCode(r.if(r.call(U+"_sub",r.getLocal("x"),r.getLocal("y"),r.getLocal("r")),r.drop(r.call(U+"_add",r.getLocal("r"),r.i32_const(Z),r.getLocal("r"))))),(s=t.addFunction(j+"_neg")).addParam("x","i32"),s.addParam("r","i32"),_=s.getCodeBuilder(),s.addCode(_.call(j+"_sub",_.i32_const(K),_.getLocal("x"),_.getLocal("r"))),function(){let a=t.alloc(N*N*8),e=t.addFunction(j+"_mReduct");e.addParam("t","i32"),e.addParam("r","i32"),e.addLocal("np32","i64"),e.addLocal("c","i64"),e.addLocal("m","i64");let l=e.getCodeBuilder(),o=Number(4294967296n-tr(k,4294967296n));e.addCode(l.setLocal("np32",l.i64_const(o)));for(let t=0;t<N;t++){e.addCode(l.setLocal("c",l.i64_const(0))),e.addCode(l.setLocal("m",l.i64_and(l.i64_mul(l.i64_load32_u(l.getLocal("t"),4*t),l.getLocal("np32")),l.i64_const("0xFFFFFFFF"))));for(let a=0;a<N;a++)e.addCode(l.setLocal("c",l.i64_add(l.i64_add(l.i64_load32_u(l.getLocal("t"),(t+a)*4),l.i64_shr_u(l.getLocal("c"),l.i64_const(32))),l.i64_mul(l.i64_load32_u(l.i32_const(Z),4*a),l.getLocal("m"))))),e.addCode(l.i64_store32(l.getLocal("t"),(t+a)*4,l.getLocal("c")));e.addCode(l.i64_store32(l.i32_const(a),4*t,l.i64_shr_u(l.getLocal("c"),l.i64_const(32))))}e.addCode(l.call(j+"_add",l.i32_const(a),l.i32_add(l.getLocal("t"),l.i32_const(4*N)),l.getLocal("r")))}(),function(){let a=t.addFunction(j+"_mul");a.addParam("x","i32"),a.addParam("y","i32"),a.addParam("r","i32"),a.addLocal("c0","i64"),a.addLocal("c1","i64"),a.addLocal("np32","i64");for(let t=0;t<N;t++)a.addLocal("x"+t,"i64"),a.addLocal("y"+t,"i64"),a.addLocal("m"+t,"i64"),a.addLocal("q"+t,"i64");let e=a.getCodeBuilder(),l=Number(4294967296n-tr(k,4294967296n));a.addCode(e.setLocal("np32",e.i64_const(l)));let o=[],i=[],c=[];function n(t,a){let l,o;return c[t]?l=e.getLocal("q"+t):(l=e.teeLocal("q"+t,e.i64_load32_u(e.i32_const(0),Z+4*t)),c[t]=!0),o=e.getLocal("m"+a),e.i64_mul(l,o)}let d="c0",r="c1";for(let t=0;t<2*N-1;t++){for(let l=Math.max(0,t-N+1);l<=t&&l<N;l++){let c=t-l;a.addCode(e.setLocal(d,e.i64_add(e.i64_and(e.getLocal(d),e.i64_const(0xffffffff)),function(t,a){let l,c;return o[t]?l=e.getLocal("x"+t):(l=e.teeLocal("x"+t,e.i64_load32_u(e.getLocal("x"),4*t)),o[t]=!0),i[a]?c=e.getLocal("y"+a):(c=e.teeLocal("y"+a,e.i64_load32_u(e.getLocal("y"),4*a)),i[a]=!0),e.i64_mul(l,c)}(l,c)))),a.addCode(e.setLocal(r,e.i64_add(e.getLocal(r),e.i64_shr_u(e.getLocal(d),e.i64_const(32)))))}for(let l=Math.max(1,t-N+1);l<=t&&l<N;l++){let o=t-l;a.addCode(e.setLocal(d,e.i64_add(e.i64_and(e.getLocal(d),e.i64_const(0xffffffff)),n(l,o)))),a.addCode(e.setLocal(r,e.i64_add(e.getLocal(r),e.i64_shr_u(e.getLocal(d),e.i64_const(32)))))}t<N&&(a.addCode(e.setLocal("m"+t,e.i64_and(e.i64_mul(e.i64_and(e.getLocal(d),e.i64_const(0xffffffff)),e.getLocal("np32")),e.i64_const("0xFFFFFFFF")))),a.addCode(e.setLocal(d,e.i64_add(e.i64_and(e.getLocal(d),e.i64_const(0xffffffff)),n(0,t)))),a.addCode(e.setLocal(r,e.i64_add(e.getLocal(r),e.i64_shr_u(e.getLocal(d),e.i64_const(32)))))),t>=N&&a.addCode(e.i64_store32(e.getLocal("r"),(t-N)*4,e.getLocal(d))),[d,r]=[r,d],a.addCode(e.setLocal(r,e.i64_shr_u(e.getLocal(d),e.i64_const(32))))}a.addCode(e.i64_store32(e.getLocal("r"),4*N-4,e.getLocal(d))),a.addCode(e.if(e.i32_wrap_i64(e.getLocal(r)),e.drop(e.call(U+"_sub",e.getLocal("r"),e.i32_const(Z),e.getLocal("r"))),e.if(e.call(U+"_gte",e.getLocal("r"),e.i32_const(Z)),e.drop(e.call(U+"_sub",e.getLocal("r"),e.i32_const(Z),e.getLocal("r"))))))}(),function(){let a=t.addFunction(j+"_square");a.addParam("x","i32"),a.addParam("r","i32"),a.addLocal("c0","i64"),a.addLocal("c1","i64"),a.addLocal("c0_old","i64"),a.addLocal("c1_old","i64"),a.addLocal("np32","i64");for(let t=0;t<N;t++)a.addLocal("x"+t,"i64"),a.addLocal("m"+t,"i64"),a.addLocal("q"+t,"i64");let e=a.getCodeBuilder(),l=Number(4294967296n-tr(k,4294967296n));a.addCode(e.setLocal("np32",e.i64_const(l)));let o=[],i=[];function c(t,a){let l,i;return o[t]?l=e.getLocal("x"+t):(l=e.teeLocal("x"+t,e.i64_load32_u(e.getLocal("x"),4*t)),o[t]=!0),o[a]?i=e.getLocal("x"+a):(i=e.teeLocal("x"+a,e.i64_load32_u(e.getLocal("x"),4*a)
1),o[a]=!0),e.i64_mul(l,i)}function n(t,a){let l,o;return i[t]?l=e.getLocal("q"+t):(l=e.teeLocal("q"+t,e.i64_load32_u(e.i32_const(0),Z+4*t)),i[t]=!0),o=e.getLocal("m"+a),e.i64_mul(l,o)}let d="c0_old",r="c1_old";for(let t=0;t<2*N-1;t++){a.addCode(e.setLocal("c0",e.i64_const(0)),e.setLocal("c1",e.i64_const(0)));for(let l=Math.max(0,t-N+1);l<t+1>>1&&l<N;l++){let o=t-l;a.addCode(e.setLocal("c0",e.i64_add(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),c(l,o)))),a.addCode(e.setLocal("c1",e.i64_add(e.getLocal("c1"),e.i64_shr_u(e.getLocal("c0"),e.i64_const(32)))))}a.addCode(e.setLocal("c0",e.i64_shl(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),e.i64_const(1)))),a.addCode(e.setLocal("c1",e.i64_add(e.i64_shl(e.getLocal("c1"),e.i64_const(1)),e.i64_shr_u(e.getLocal("c0"),e.i64_const(32))))),t%2==0&&(a.addCode(e.setLocal("c0",e.i64_add(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),c(t>>1,t>>1)))),a.addCode(e.setLocal("c1",e.i64_add(e.getLocal("c1"),e.i64_shr_u(e.getLocal("c0"),e.i64_const(32)))))),t>0&&(a.addCode(e.setLocal("c0",e.i64_add(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),e.i64_and(e.getLocal(d),e.i64_const(0xffffffff))))),a.addCode(e.setLocal("c1",e.i64_add(e.i64_add(e.getLocal("c1"),e.i64_shr_u(e.getLocal("c0"),e.i64_const(32))),e.getLocal(r)))));for(let l=Math.max(1,t-N+1);l<=t&&l<N;l++){let o=t-l;a.addCode(e.setLocal("c0",e.i64_add(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),n(l,o)))),a.addCode(e.setLocal("c1",e.i64_add(e.getLocal("c1"),e.i64_shr_u(e.getLocal("c0"),e.i64_const(32)))))}t<N&&(a.addCode(e.setLocal("m"+t,e.i64_and(e.i64_mul(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),e.getLocal("np32")),e.i64_const("0xFFFFFFFF")))),a.addCode(e.setLocal("c0",e.i64_add(e.i64_and(e.getLocal("c0"),e.i64_const(0xffffffff)),n(0,t)))),a.addCode(e.setLocal("c1",e.i64_add(e.getLocal("c1"),e.i64_shr_u(e.getLocal("c0"),e.i64_const(32)))))),t>=N&&a.addCode(e.i64_store32(e.getLocal("r"),(t-N)*4,e.getLocal("c0"))),a.addCode(e.setLocal(d,e.getLocal("c1")),e.setLocal(r,e.i64_shr_u(e.getLocal(d),e.i64_const(32))))}a.addCode(e.i64_store32(e.getLocal("r"),4*N-4,e.getLocal(d))),a.addCode(e.if(e.i32_wrap_i64(e.getLocal(r)),e.drop(e.call(U+"_sub",e.getLocal("r"),e.i32_const(Z),e.getLocal("r"))),e.if(e.call(U+"_gte",e.getLocal("r"),e.i32_const(Z)),e.drop(e.call(U+"_sub",e.getLocal("r"),e.i32_const(Z),e.getLocal("r"))))))}(),(f=t.addFunction(j+"_squareOld")).addParam("x","i32"),f.addParam("r","i32"),u=f.getCodeBuilder(),f.addCode(u.call(j+"_mul",u.getLocal("x"),u.getLocal("x"),u.getLocal("r"))),(g=t.addFunction(j+"_toMontgomery")).addParam("x","i32"),g.addParam("r","i32"),L=g.getCodeBuilder(),g.addCode(L.call(j+"_mul",L.getLocal("x"),L.i32_const($),L.getLocal("r"))),p=t.alloc(2*R),(h=t.addFunction(j+"_fromMontgomery")).addParam("x","i32"),h.addParam("r","i32"),m=h.getCodeBuilder(),h.addCode(m.call(U+"_copy",m.getLocal("x"),m.i32_const(p))),h.addCode(m.call(U+"_zero",m.i32_const(p+R))),h.addCode(m.call(j+"_mReduct",m.i32_const(p),m.getLocal("r"))),(b=t.addFunction(j+"_isNegative")).addParam("x","i32"),b.setReturnType("i32"),y=(x=b.getCodeBuilder()).i32_const(t.alloc(R)),b.addCode(x.call(j+"_fromMontgomery",x.getLocal("x"),y),x.call(U+"_gte",y,x.i32_const(tt))),(F=t.addFunction(j+"_sign")).addParam("x","i32"),F.setReturnType("i32"),B=(C=F.getCodeBuilder()).i32_const(t.alloc(R)),F.addCode(C.if(C.call(U+"_isZero",C.getLocal("x")),C.ret(C.i32_const(0))),C.call(j+"_fromMontgomery",C.getLocal("x"),B),C.if(C.call(U+"_gte",B,C.i32_const(tt)),C.ret(C.i32_const(-1))),C.ret(C.i32_const(1))),(P=t.addFunction(j+"_inverse")).addParam("x","i32"),P.addParam("r","i32"),A=P.getCodeBuilder(),P.addCode(A.call(j+"_fromMontgomery",A.getLocal("x"),A.getLocal("r"))),P.addCode(A.call(U+"_inverseMod",A.getLocal("r"),A.i32_const(Z),A.getLocal("r"))),P.addCode(A.call(j+"_toMontgomery",A.getLocal("r"),A.getLocal("r"))),(q=t.addFunction(j+"_one")).addParam("pr","i32"),v=q.getCodeBuilder(),q.addCode(v.call(U+"_copy",v.i32_const(V),v.getLocal("pr"))),(I=t.addFunction(j+"_load")).addParam("scalar","i32"),I.addParam("scalarLen","i32"),I.addParam("r","i32"),I.addLocal("p","i32"),I.addLocal("l","i32"),I.addLocal("i","i32"),I.addLocal("j","i32"),E=(O=I.getCodeBuilder()).i32_const(t.alloc(R)),w=t.alloc(R),M=O.i32_const(w),I.addCode(O.call(U+"_zero",O.getLocal("r")),O.setLocal("i",O.i32_const(R)),O.setLocal("p",O.getLocal("scalar")),O.block(O.loop(O.br_if(1,O.i32_gt_u(O.getLocal("i"),O.getLocal("scalarLen"))),O.if(O.i32_eq(O.getLocal("i"),O.i32_const(R)),O.call(j+"_one",E),O.call(j+"_mul",E,O.i32_const($),E)),O.call(j+"_mul",O.getLocal("p"),E,M),O.call(j+"_add",O.getLocal("r"),M,O.getLocal("r")),O.setLocal("p",O.i32_add(O.getLocal("p"),O.i32_const(R))),O.setLocal("i",O.i32_add(O.getLocal("i"),O.i32_const(R))),O.br(0))
1),O.setLocal("l",O.i32_rem_u(O.getLocal("scalarLen"),O.i32_const(R))),O.if(O.i32_eqz(O.getLocal("l")),O.ret([])),O.call(U+"_zero",M),O.setLocal("j",O.i32_const(0)),O.block(O.loop(O.br_if(1,O.i32_eq(O.getLocal("j"),O.getLocal("l"))),O.i32_store8(O.getLocal("j"),w,O.i32_load8_u(O.getLocal("p"))),O.setLocal("p",O.i32_add(O.getLocal("p"),O.i32_const(1))),O.setLocal("j",O.i32_add(O.getLocal("j"),O.i32_const(1))),O.br(0))),O.if(O.i32_eq(O.getLocal("i"),O.i32_const(R)),O.call(j+"_one",E),O.call(j+"_mul",E,O.i32_const($),E)),O.call(j+"_mul",M,E,M),O.call(j+"_add",O.getLocal("r"),M,O.getLocal("r"))),(S=t.addFunction(j+"_timesScalar")).addParam("x","i32"),S.addParam("scalar","i32"),S.addParam("scalarLen","i32"),S.addParam("r","i32"),T=(z=S.getCodeBuilder()).i32_const(t.alloc(R)),S.addCode(z.call(j+"_load",z.getLocal("scalar"),z.getLocal("scalarLen"),T),z.call(j+"_toMontgomery",T,T),z.call(j+"_mul",z.getLocal("x"),T,z.getLocal("r"))),W(t,j),D(t,j+"_batchToMontgomery",j+"_toMontgomery",R,R),D(t,j+"_batchFromMontgomery",j+"_fromMontgomery",R,R),D(t,j+"_batchNeg",j+"_neg",R,R),tn(t,j+"_batchAdd",j+"_add",R,R),tn(t,j+"_batchSub",j+"_sub",R,R),tn(t,j+"_batchMul",j+"_mul",R,R),t.exportFunction(j+"_add"),t.exp
1ortFunction(j+"_sub"),t.exportFunction(j+"_neg"),t.exportFunction(j+"_isNegative"),t.exportFunction(j+"_isOne"),t.exportFunction(j+"_sign"),t.exportFunction(j+"_mReduct"),t.exportFunction(j+"_mul"),t.exportFunction(j+"_square"),t.exportFunction(j+"_squareOld"),t.exportFunction(j+"_fromMontgomery"),t.exportFunction(j+"_toMontgomery"),t.exportFunction(j+"_inverse"),t.exportFunction(j+"_one"),t.exportFunction(j+"_load"),t.exportFunction(j+"_timesScalar"),J(t,j+"_exp",R,j+"_mul",j+"_square",U+"_copy",j+"_one"),t.exportFunction(j+"_exp"),t.exportFunction(j+"_batchInverse"),t_(k)){let a,e,l,o,i,c,n,d,r,s,_,f;(a=t.addFunction(j+"_sqrt")).addParam("n","i32"),a.addParam("r","i32"),a.addLocal("m","i32"),a.addLocal("i","i32"),a.addLocal("j","i32"),l=(e=a.getCodeBuilder()).i32_const(V),o=e.i32_const(t.alloc(R)),i=e.i32_const(t.alloc(R)),c=e.i32_const(t.alloc(R)),n=e.i32_const(t.alloc(R)),d=e.i32_const(t.alloc(R)),a.addCode(e.if(e.call(j+"_isZero",e.getLocal("n")),e.ret(e.call(j+"_zero",e.getLocal("r")))),e.setLocal("m",e.i32_const(te)),e.call(j+"_copy",e.i32_const(tg),o),e.call(j+"_exp",e.getLocal("n"),e.i32_const(to),e.i32_const(R),i),e.call(j+"_exp",e.getLocal("n"),e.i32_const(tp),e.i32_const(R),c),e.block(e.loop(e.br_if(1,e.call(j+"_eq",i,l)),e.call(j+"_square",i,n),e.setLocal("i",e.i32_const(1)),e.block(e.loop(e.br_if(1,e.call(j+"_eq",n,l)),e.call(j+"_square",n,n),e.setLocal("i",e.i32_add(e.getLocal("i"),e.i32_const(1))),e.br(0))),e.call(j+"_copy",o,d),e.setLocal("j",e.i32_sub(e.i32_sub(e.getLocal("m"),e.getLocal("i")),e.i32_const(1))),e.block(e.loop(e.br_if(1,e.i32_eqz(e.getLocal("j"))),e.call(j+"_square",d,d),e.setLocal("j",e.i32_sub(e.getLocal("j"),e.i32_const(1))),e.br(0))),e.setLocal("m",e.getLocal("i")),e.call(j+"_square",d,o),e.call(j+"_mul",i,o,i),e.call(j+"_mul",c,d,c),e.br(0))),e.if(e.call(j+"_isNegative",c),e.call(j+"_neg",c,e.getLocal("r")),e.call(j+"_copy",c,e.getLocal("r")))),(r=t.addFunction(j+"_isSquare")).addParam("n","i32"),r.setReturnType("i32"),_=(s=r.getCodeBuilder()).i32_const(V),f=s.i32_const(t.alloc(R)),r.addCode(s.if(s.call(j+"_isZero",s.getLocal("n")),s.ret(s.i32_const(1))),s.call(j+"_exp",s.getLocal("n"),s.i32_const(H),s.i32_const(R),f),s.call(j+"_eq",f,_)),t.exportFunction(j+"_sqrt"),t.exportFunction(j+"_isSquare")}return t.exportFunction(j+"_batchToMontgomery"),t.exportFunction(j+"_batchFromMontgomery"),j};let{bitLength:tL}=V;var tp=function(t,a,e,l,o){let i,c,n,d,r,s,_,f,u,g=BigInt(a),L=Math.floor((tL(g-1n)-1)/64)+1,p=e||"f1";if(t.modules[p])return p;t.modules[p]={n64:L};let h=o||"int",m=tg(t,g,l,h),b=t.modules[m].pR2,x=t.modules[m].pq,y=t.modules[m].pePlusOne;return i=t.alloc(8*L),(c=t.addFunction(p+"_mul")).addParam("x","i32"),c.addParam("y","i32"),c.addParam("r","i32"),n=c.getCodeBuilder(),c.addCode(n.call(m+"_mul",n.getLocal("x"),n.getLocal("y"),n.i32_const(i))),c.addCode(n.call(m+"_mul",n.i32_const(i),n.i32_const(b),n.getLocal("r"))),(d=t.addFunction(p+"_square")).addParam("x","i32"),d.addParam("r","i32"),r=d.getCodeBuilder(),d.addCode(r.call(p+"_mul",r.getLocal("x"),r.getLocal("x"),r.getLocal("r"))),(s=t.addFunction(p+"_inverse")).addParam("x","i32"),s.addParam("r","i32"),_=s.getCodeBuilder(),s.addCode(_.call(h+"_inverseMod",_.getLocal("x"),_.i32_const(x),_.getLocal("r"))),(f=t.addFunction(p+"_isNegative")).addParam("x","i32"),f.setReturnType("i32"),u=f.getCodeBuilder(),f.addCode(u.call(h+"_gte",u.getLocal("x"),u.i32_const(y))),t.exportFunction(m+"_add",p+"_add"),t.exp
1ortFunction(m+"_sub",p+"_sub"),t.exportFunction(m+"_neg",p+"_neg"),t.exportFunction(p+"_mul"),t.exportFunction(p+"_square"),t.exportFunction(p+"_inverse"),t.exportFunction(p+"_isNegative"),t.exportFunction(m+"_copy",p+"_copy"),t.exportFunction(m+"_zero",p+"_zero"),t.exportFunction(m+"_one",p+"_one"),t.exportFunction(m+"_isZero",p+"_isZero"),t.exportFunction(m+"_eq",p+"_eq"),p},th=function(t,a,e,l){let o,i,c,n,d,r,s,_,f,u,g,L,p,h,m,b,x,y,F,C,B,P,A,q,v,I,O,E,w,M,S,z,T,k,G,N,R,j,U,Z,$,D,V,K,X,Y,H,tt,ta,te,tl,to,ti,tc,tn,td,tr,ts,t_,tf,tu,tg,tL,tp,th,tm,tb,tx,ty,tF,tC,tB,tP,tA,tq,tv,tI,tO,tE,tw,tM,tS,tz,tT,tk,tG,tN,tR,tj,tU,tZ,t$,tQ,tJ,tW,tD,tV,tK,tX,tY,tH,t2,t3,t0,t1,t4,t6,t8,t7,t5,t9,at,aa,ae,al,ao,ai,ac,an,ad,ar,as,a_,af,au,ag,aL,ap,ah,am,ab,ax,ay,aF,aC,aB,aP,aA,aq,av,aI,aO,aE,aw;if(t.modules[e])return e;let aM=8*t.modules[l].n64,aS=t.modules[l].q;return t.modules[e]={n64:2*t.modules[l].n64},(o=t.addFunction(e+"_isZero")).addParam("x","i32"),o.setReturnType("i32"),c=(i=o.getCodeBuilder()).getLocal("x"),n=i.i32_add(i.getLocal("x"),i.i32_const(aM)),o.addCode(i.i32_and(i.call(l+"_isZero",c),i.call(l+"_isZero",n))),(d=t.addFunction(e+"_isOne")).addParam("x","i32"),d.setReturnType("i32"),s=(r=d.getCodeBuilder()).getLocal("x"),_=r.i32_add(r.getLocal("x"),r.i32_const(aM)),d.addCode(r.ret(r.i32_and(r.call(l+"_isOne",s),r.call(l+"_isZero",_)))),(f=t.addFunction(e+"_zero")).addParam("x","i32"),g=(u=f.getCodeBuilder()).getLocal("x"),L=u.i32_add(u.getLocal("x"),u.i32_const(aM)),f.addCode(u.call(l+"_zero",g),u.call(l+"_zero",L)),(p=t.addFunction(e+"_one")).addParam("x","i32"),m=(h=p.getCodeBuilder()).getLocal("x"),b=h.i32_add(h.getLocal("x"),h.i32_const(aM)),p.addCode(h.call(l+"_one",m),h.call(l+"_zero",b)),(x=t.addFunction(e+"_copy")).addParam("x","i32"),x.addParam("r","i32"),F=(y=x.getCodeBuilder()).getLocal("x"),C=y.i32_add(y.getLocal("x"),y.i32_const(aM)),B=y.getLocal("r"),P=y.i32_add(y.getLocal("r"),y.i32_const(aM)),x.addCode(y.call(l+"_copy",F,B),y.call(l+"_copy",C,P)),(A=t.addFunction(e+"_mul")).addParam("x","i32"),A.addParam("y","i32"),A.addParam("r","i32"),v=(q=A.getCodeBuilder()).getLocal("x"),I=q.i32_add(q.getLocal("x"),q.i32_const(aM)),O=q.getLocal("y"),E=q.i32_add(q.getLocal("y"),q.i32_const(aM)),w=q.getLocal("r"),M=q.i32_add(q.getLocal("r"),q.i32_const(aM)),S=q.i32_const(t.alloc(aM)),z=q.i32_const(t.alloc(aM)),T=q.i32_const(t.alloc(aM)),k=q.i32_const(t.alloc(aM)),A.addCode(q.call(l+"_mul",v,O,S),q.call(l+"_mul",I,E,z),q.call(l+"_add",v,I,T),q.call(l+"_add",O,E,k),q.call(l+"_mul",T,k,T),q.call(a,z,w),q.call(l+"_add",S,w,w),q.call(l+"_add",S,z,M),q.call(l+"_sub",T,M,M)),(G=t.addFunction(e+"_mul1")).addParam("x","i32"),G.addParam("y","i32"),G.addParam("r","i32"),R=(N=G.getCodeBuilder()).getLocal("x"),j=N.i32_add(N.getLocal("x"),N.i32_const(aM)),U=N.getLocal("y"),Z=N.getLocal("r"),$=N.i32_add(N.getLocal("r"),N.i32_const(aM)),G.addCode(N.call(l+"_mul",R,U,Z),N.call(l+"_mul",j,U,$)),(D=t.addFunction(e+"_square")).addParam("x","i32"),D.addParam("r","i32"),K=(V=D.getCodeBuilder()).getLocal("x"),X=V.i32_add(V.getLocal("x"),V.i32_const(aM)),Y=V.getLocal("r"),H=V.i32_add(V.getLocal("r"),V.i32_const(aM)),tt=V.i32_const(t.alloc(aM)),ta=V.i32_const(t.alloc(aM)),te=V.i32_const(t.alloc(aM)),tl=V.i32_const(t.alloc(aM)),D.addCode(V.call(l+"_mul",K,X,tt),V.call(l+"_add",K,X,ta),V.call(a,X,te),V.call(l+"_add",K,te,te),V.call(a,tt,tl),V.call(l+"_add",tl,tt,tl),V.call(l+"_mul",ta,te,Y),V.call(l+"_sub",Y,tl,Y),V.call(l+"_add",tt,tt,H)),(to=t.addFunction(e+"_add")).addParam("x","i32"),to.addParam("y","i32"),to.addParam("r","i32"),tc=(ti=to.getCodeBuilder()).getLocal("x"),tn=ti.i32_add(ti.getLocal("x"),ti.i32_const(aM)),td=ti.getLocal("y"),tr=ti.i32_add(ti.getLocal("y"),ti.i32_const(aM)),ts=ti.getLocal("r"),t_=ti.i32_add(ti.getLocal("r"),ti.i32_const(aM)),to.addCode(ti.call(l+"_add",tc,td,ts),ti.call(l+"_add",tn,tr,t_)),(tf=t.addFunction(e+"_sub")).addParam("x","i32"),tf.addParam("y","i32"),tf.addParam("r","i32"),tg=(tu=tf.getCodeBuilder()).getLocal("x"),tL=tu.i32_add(tu.getLocal("x"),tu.i32_const(aM)),tp=tu.getLocal("y"),th=tu.i32_add(tu.getLocal("y"),tu.i32_const(aM)),tm=tu.getLocal("r"),tb=tu.i32_add(tu.getLocal("r"),tu.i32_const(aM)),tf.addCode(tu.call(l+"_sub",tg,tp,tm),tu.call(l+"_sub",tL,th,tb)),(tx=t.addFunction(e+"_neg")).addParam("x","i32"),tx.addParam("r","i32"),tF=(ty=tx.getCodeBuilder()).getLocal("x"),tC=ty.i32_add(ty.getLocal("x"),ty.i32_const(aM)),tB=ty.getLocal("r"),tP=ty.i32_add(ty.getLocal("r"),ty.i32_const(aM)),tx.addCode(ty.call(l+"_neg",tF,tB),ty.call(l+"_neg",tC,tP)),(tA=t.addFunction(e+"_conjugate")).addParam("x","i32"),tA.addParam("r","i32"),tv=(tq=tA.getCodeBuilder()).getLocal("x"),tI=tq.i32_add(tq.getLocal("x"),tq.i32_const(aM)),tO=tq.getLocal("r"),tE=tq.i32_add(tq.getLocal("r"),tq.i32_const(aM)),tA.addCode(tq.call(l+"_copy",tv,tO),tq.call(l+"_neg",tI,tE)),(tw=t.addFunction(e+"_toMontgomery")).addParam("x","i32"),tw.addParam("r","i32"),tS=(tM=tw.getCodeBuilder()).getLocal("x"),tz=tM.i32_add(tM.getL
1ocal("x"),tM.i32_const(aM)),tT=tM.getLocal("r"),tk=tM.i32_add(tM.getLocal("r"),tM.i32_const(aM)),tw.addCode(tM.call(l+"_toMontgomery",tS,tT),tM.call(l+"_toMontgomery",tz,tk)),(tG=t.addFunction(e+"_fromMontgomery")).addParam("x","i32"),tG.addParam("r","i32"),tR=(tN=tG.getCodeBuilder()).getLocal("x"),tj=tN.i32_add(tN.getLocal("x"),tN.i32_const(aM)),tU=tN.getLocal("r"),tZ=tN.i32_add(tN.getLocal("r"),tN.i32_const(aM)),tG.addCode(tN.call(l+"_fromMontgomery",tR,tU),tN.call(l+"_fromMontgomery",tj,tZ)),(t$=t.addFunction(e+"_eq")).addParam("x","i32"),t$.addParam("y","i32"),t$.setReturnType("i32"),tJ=(tQ=t$.getCodeBuilder()).getLocal("x"),tW=tQ.i32_add(tQ.getLocal("x"),tQ.i32_const(aM)),tD=tQ.getLocal("y"),tV=tQ.i32_add(tQ.getLocal("y"),tQ.i32_const(aM)),t$.addCode(tQ.i32_and(tQ.call(l+"_eq",tJ,tD),tQ.call(l+"_eq",tW,tV))),(tK=t.addFunction(e+"_inverse")).addParam("x","i32"),tK.addParam("r","i32"),tY=(tX=tK.getCodeBuilder()).getLocal("x"),tH=tX.i32_add(tX.getLocal("x"),tX.i32_const(aM)),t2=tX.getLocal("r"),t3=tX.i32_add(tX.getLocal("r"),tX.i32_const(aM)),t0=tX.i32_const(t.alloc(aM)),t1=tX.i32_const(t.alloc(aM)),t4=tX.i32_const(t.alloc(aM)),t6=tX.i32_const(t.alloc(aM)),tK.addCode(tX.call(l+"_square",tY,t0),tX.call(l+"_square",tH,t1),tX.call(a,t1,t4),tX.call(l+"_sub",t0,t4,t4),tX.call(l+"_inverse",t4,t6),tX.call(l+"_mul",tY,t6,t2),tX.call(l+"_mul",tH,t6,t3),tX.call(l+"_neg",t3,t3)),(t8=t.addFunction(e+"_timesScalar")).addParam("x","i32"),t8.addParam("scalar","i32"),t8.addParam("scalarLen","i32"),t8.addParam("r","i32"),t5=(t7=t8.getCodeBuilder()).getLocal("x"),t9=t7.i32_add(t7.getLocal("x"),t7.i32_const(aM)),at=t7.getLocal("r"),aa=t7.i32_add(t7.getLocal("r"),t7.i32_const(aM)),t8.addCode(t7.call(l+"_timesScalar",t5,t7.getLocal("scalar"),t7.getLocal("scalarLen"),at),t7.call(l+"_timesScalar",t9,t7.getLocal("scalar"),t7.getLocal("scalarLen"),aa)),(ae=t.addFunction(e+"_sign")).addParam("x","i32"),ae.addLocal("s","i32"),ae.setReturnType("i32"),ao=(al=ae.getCodeBuilder()).getLocal("x"),ai=al.i32_add(al.getLocal("x"),al.i32_const(aM)),ae.addCode(al.setLocal("s",al.call(l+"_sign",ai)),al.if(al.getLocal("s"),al.ret(al.getLocal("s"))),al.ret(al.call(l+"_sign",ao))),(ac=t.addFunction(e+"_isNegative")).addParam("x","i32"),ac.setReturnType("i32"),ad=(an=ac.getCodeBuilder()).getLocal("x"),ar=an.i32_add(an.getLocal("x"),an.i32_const(aM)),ac.addCode(an.if(an.call(l+"_isZero",ar),an.ret(an.call(l+"_isNegative",ad))),an.ret(an.call(l+"_isNegative",ar))),t.exportFunction(e+"_isZero"),t.exportFunction(e+"_isOne"),t.exportFunction(e+"_zero"),t.exportFunction(e+"_one"),t.exportFunction(e+"_copy"),t.exportFunction(e+"_mul"),t.exportFunction(e+"_mul1"),t.exp
1ortFunction(e+"_square"),t.exportFunction(e+"_add"),t.exportFunction(e+"_sub"),t.exportFunction(e+"_neg"),t.exportFunction(e+"_sign"),t.exportFunction(e+"_conjugate"),t.exportFunction(e+"_fromMontgomery"),t.exportFunction(e+"_toMontgomery"),t.exportFunction(e+"_eq"),t.exportFunction(e+"_inverse"),W(t,e),J(t,e+"_exp",2*aM,e+"_mul",e+"_square",e+"_copy",e+"_one"),(as=t.addFunction(e+"_sqrt")).addParam("a","i32"),as.addParam("pr","i32"),af=(a_=as.getCodeBuilder()).i32_const(t.alloc(Q.bigInt2BytesLE((BigInt(aS||0)-3n)/4n,aM))),au=a_.i32_const(t.alloc(Q.bigInt2BytesLE((BigInt(aS||0)-1n)/2n,aM))),ag=a_.getLocal("a"),aL=a_.i32_const(t.alloc(2*aM)),ap=a_.i32_const(t.alloc(2*aM)),ah=a_.i32_const(t.alloc(2*aM)),am=t.alloc(2*aM),ab=a_.i32_const(am),ax=a_.i32_const(am),ay=a_.i32_const(am+aM),aF=a_.i32_const(t.alloc(2*aM)),aC=a_.i32_const(t.alloc(2*aM)),as.addCode(a_.call(e+"_one",ab),a_.call(e+"_neg",ab,ab),a_.call(e+"_exp",ag,af,a_.i32_const(aM),aL),a_.call(e+"_square",aL,ap),a_.call(e+"_mul",ag,ap,ap),a_.call(e+"_conjugate",ap,ah),a_.call(e+"_mul",ah,ap,ah),a_.if(a_.call(e+"_eq",ah,ab),a_.unreachable()),a_.call(e+"_mul",aL,ag,aF),a_.if(a_.call(e+"_eq",ap,ab),[...a_.call(l+"_zero",ax),...a_.call(l+"_one",ay),...a_.call(e+"_mul",ab,aF,a_.getLocal("pr"))],[...a_.call(e+"_one",aC),...a_.call(e+"_add",aC,ap,aC),...a_.call(e+"_exp",aC,au,a_.i32_const(aM),aC),...a_.call(e+"_mul",aC,aF,a_.getLocal("pr"))])),(aB=t.addFunction(e+"_isSquare")).addParam("a","i32"),aB.setReturnType("i32"),aA=(aP=aB.getCodeBuilder()).i32_const(t.alloc(Q.bigInt2BytesLE((BigInt(aS||0)-3n)/4n,aM))),aq=aP.getLocal("a"),av=aP.i32_const(t.alloc(2*aM)),aI=aP.i32_const(t.alloc(2*aM)),aO=aP.i32_const(t.alloc(2*aM)),aE=t.alloc(2*aM),aw=aP.i32_const(aE),aB.addCode(aP.call(e+"_one",aw),aP.call(e+"_neg",aw,aw),aP.call(e+"_exp",aq,aA,aP.i32_const(aM),av),aP.call(e+"_square",av,aI),aP.call(e+"_mul",aq,aI,aI),aP.call(e+"_conjugate",aI,aO),aP.call(e+"_mul",aO,aI,aO),aP.if(aP.call(e+"_eq",aO,aw),aP.ret(aP.i32_const(0))),aP.ret(aP.i32_const(1))),t.exportFunction(e+"_exp"),t.exp
1ortFunction(e+"_timesScalar"),t.exportFunction(e+"_batchInverse"),t.exportFunction(e+"_sqrt"),t.exportFunction(e+"_isSquare"),t.exportFunction(e+"_isNegative"),e},tm=function(t,a,e,l){let o,i,c,n,d,r,s,_,f,u,g,L,p,h,m,b,x,y,F,C,B,P,A,q,v,I,O,E,w,M,S,z,T,k,G,N,R,j,U,Z,$,Q,D,V,K,X,Y,H,tt,ta,te,tl,to,ti,tc,tn,td,tr,ts,t_,tf,tu,tg,tL,tp,th,tm,tb,tx,ty,tF,tC,tB,tP,tA,tq,tv,tI,tO,tE,tw,tM,tS,tz,tT,tk,tG,tN,tR,tj,tU,tZ,t$,tQ,tJ,tW,tD,tV,tK,tX,tY,tH,t2,t3,t0,t1,t4,t6,t8,t7,t5,t9,at,aa,ae,al,ao,ai,ac,an,ad,ar,as,a_,af,au,ag,aL,ap,ah,am,ab,ax,ay,aF,aC,aB,aP,aA,aq,av,aI,aO,aE,aw,aM,aS,az,aT,ak,aG,aN,aR,aj,aU,aZ,a$,aQ;if(t.modules[e])return e;let aJ=8*t.modules[l].n64;return t.modules[e]={n64:3*t.modules[l].n64},(o=t.addFunction(e+"_isZero")).addParam("x","i32"),o.setReturnType("i32"),c=(i=o.getCodeBuilder()).getLocal("x"),n=i.i32_add(i.getLocal("x"),i.i32_const(aJ)),d=i.i32_add(i.getLocal("x"),i.i32_const(2*aJ)),o.addCode(i.i32_and(i.i32_and(i.call(l+"_isZero",c),i.call(l+"_isZero",n)),i.call(l+"_isZero",d))),(r=t.addFunction(e+"_isOne")).addParam("x","i32"),r.setReturnType("i32"),_=(s=r.getCodeBuilder()).getLocal("x"),f=s.i32_add(s.getLocal("x"),s.i32_const(aJ)),u=s.i32_add(s.getLocal("x"),s.i32_const(2*aJ)),r.addCode(s.ret(s.i32_and(s.i32_and(s.call(l+"_isOne",_),s.call(l+"_isZero",f)),s.call(l+"_isZero",u)))),(g=t.addFunction(e+"_zero")).addParam("x","i32"),p=(L=g.getCodeBuilder()).getLocal("x"),h=L.i32_add(L.getLocal("x"),L.i32_const(aJ)),m=L.i32_add(L.getLocal("x"),L.i32_const(2*aJ)),g.addCode(L.call(l+"_zero",p),L.call(l+"_zero",h),L.call(l+"_zero",m)),(b=t.addFunction(e+"_one")).addParam("x","i32"),y=(x=b.getCodeBuilder()).getLocal("x"),F=x.i32_add(x.getLocal("x"),x.i32_const(aJ)),C=x.i32_add(x.getLocal("x"),x.i32_const(2*aJ)),b.addCode(x.call(l+"_one",y),x.call(l+"_zero",F),x.call(l+"_zero",C)),(B=t.addFunction(e+"_copy")).addParam("x","i32"),B.addParam("r","i32"),A=(P=B.getCodeBuilder()).getLocal("x"),q=P.i32_add(P.getLocal("x"),P.i32_const(aJ)),v=P.i32_add(P.getLocal("x"),P.i32_const(2*aJ)),I=P.getLocal("r"),O=P.i32_add(P.getLocal("r"),P.i32_const(aJ)),E=P.i32_add(P.getLocal("r"),P.i32_const(2*aJ)),B.addCode(P.call(l+"_copy",A,I),P.call(l+"_copy",q,O),P.call(l+"_copy",v,E)),(w=t.addFunction(e+"_mul")).addParam("x","i32"),w.addParam("y","i32"),w.addParam("r","i32"),S=(M=w.getCodeBuilder()).getLocal("x"),z=M.i32_add(M.getLocal("x"),M.i32_const(aJ)),T=M.i32_add(M.getLocal("x"),M.i32_const(2*aJ)),k=M.getLocal("y"),G=M.i32_add(M.getLocal("y"),M.i32_const(aJ)),N=M.i32_add(M.getLocal("y"),M.i32_const(2*aJ)),R=M.getLocal("r"),j=M.i32_add(M.getLocal("r"),M.i32_const(aJ)),U=M.i32_add(M.getLocal("r"),M.i32_const(2*aJ)),Z=M.i32_const(t.alloc(aJ)),$=M.i32_const(t.alloc(aJ)),Q=M.i32_const(t.alloc(aJ)),D=M.i32_const(t.alloc(aJ)),V=M.i32_const(t.alloc(aJ)),K=M.i32_const(t.alloc(aJ)),X=M.i32_const(t.alloc(aJ)),Y=M.i32_const(t.alloc(aJ)),H=M.i32_const(t.alloc(aJ)),tt=M.i32_const(t.alloc(aJ)),ta=M.i32_const(t.alloc(aJ)),te=M.i32_const(t.alloc(aJ)),tl=M.i32_const(t.alloc(aJ)),w.addCode(M.call(l+"_mul",S,k,Z),M.call(l+"_mul",z,G,$),M.call(l+"_mul",T,N,Q),M.call(l+"_add",S,z,D),M.call(l+"_add",k,G,V),M.call(l+"_add",S,T,K),M.call(l+"_add",k,N,X),M.call(l+"_add",z,T,Y),M.call(l+"_add",G,N,H),M.call(l+"_add",Z,$,tt),M.call(l+"_add",Z,Q,ta),M.call(l+"_add",$,Q,te),M.call(l+"_mul",Y,H,R),M.call(l+"_sub",R,te,R),M.call(a,R,R),M.call(l+"_add",Z,R,R),M.call(l+"_mul",D,V,j),M.call(l+"_sub",j,tt,j),M.call(a,Q,tl),M.call(l+"_add",j,tl,j),M.call(l+"_mul",K,X,U),M.call(l+"_sub",U,ta,U),M.call(l+"_add",U,$,U)),(to=t.addFunction(e+"_square")).addParam("x","i32"),to.addParam("r","i32"),tc=(ti=to.getCodeBuilder()).getLocal("x"),tn=ti.i32_add(ti.getLocal("x"),ti.i32_const(aJ)),td=ti.i32_add(ti.getLocal("x"),ti.i32_const(2*aJ)),tr=ti.getLocal("r"),ts=ti.i32_add(ti.getLocal("r"),ti.i32_const(aJ)),t_=ti.i32_add(ti.getLocal("r"),ti.i32_const(2*aJ)),tf=ti.i32_const(t.alloc(aJ)),tu=ti.i32_const(t.alloc(aJ)),tg=ti.i32_const(t.alloc(aJ)),tL=ti.i32_const(t.alloc(aJ)),tp=ti.i32_const(t.alloc(aJ)),th=ti.i32_const(t.alloc(aJ)),tm=ti.i32_const(t.alloc(aJ)),to.addCode(ti.call(l+"_square",tc,tf),ti.call(l+"_mul",tc,tn,tu),ti.call(l+"_add",tu,tu,tg),ti.call(l+"_sub",tc,tn,tL),ti.call(l+"_add",tL,td,tL),ti.call(l+"_square",tL,tL),ti.call(l+"_mul",tn,td,tp),ti.call(l+"_add",tp,tp,th),ti.call(l+"_square",td,tm),ti.call(a,th,tr),ti.call(l+"_add",tf,tr,tr),ti.call(a,tm,ts),ti.call(l+"_add",tg,ts,ts),ti.call(l+"_add",tf,tm,t_),ti.call(l+"_sub",th,t_,t_),ti.call(l+"_add",tL,t_,t_),ti.call(l+"_add",tg,t_,t_)),(tb=t.addFunction(e+"_add")).addParam("x","i32"),tb.addParam("y","i32"),tb.addParam("r","i32"),ty=(tx=tb.getCodeBuilder()).getLocal("x"),tF=tx.i32_add(tx.getL
1ocal("x"),tx.i32_const(aJ)),tC=tx.i32_add(tx.getLocal("x"),tx.i32_const(2*aJ)),tB=tx.getLocal("y"),tP=tx.i32_add(tx.getLocal("y"),tx.i32_const(aJ)),tA=tx.i32_add(tx.getLocal("y"),tx.i32_const(2*aJ)),tq=tx.getLocal("r"),tv=tx.i32_add(tx.getLocal("r"),tx.i32_const(aJ)),tI=tx.i32_add(tx.getLocal("r"),tx.i32_const(2*aJ)),tb.addCode(tx.call(l+"_add",ty,tB,tq),tx.call(l+"_add",tF,tP,tv),tx.call(l+"_add",tC,tA,tI)),(tO=t.addFunction(e+"_sub")).addParam("x","i32"),tO.addParam("y","i32"),tO.addParam("r","i32"),tw=(tE=tO.getCodeBuilder()).getLocal("x"),tM=tE.i32_add(tE.getLocal("x"),tE.i32_const(aJ)),tS=tE.i32_add(tE.getLocal("x"),tE.i32_const(2*aJ)),tz=tE.getLocal("y"),tT=tE.i32_add(tE.getLocal("y"),tE.i32_const(aJ)),tk=tE.i32_add(tE.getLocal("y"),tE.i32_const(2*aJ)),tG=tE.getLocal("r"),tN=tE.i32_add(tE.getLocal("r"),tE.i32_const(aJ)),tR=tE.i32_add(tE.getLocal("r"),tE.i32_const(2*aJ)),tO.addCode(tE.call(l+"_sub",tw,tz,tG),tE.call(l+"_sub",tM,tT,tN),tE.call(l+"_sub",tS,tk,tR)),(tj=t.addFunction(e+"_neg")).addParam("x","i32"),tj.addParam("r","i32"),tZ=(tU=tj.getCodeBuilder()).getLocal("x"),t$=tU.i32_add(tU.getLocal("x"),tU.i32_const(aJ)),tQ=tU.i32_add(tU.getLocal("x"),tU.i32_const(2*aJ)),tJ=tU.getLocal("r"),tW=tU.i32_add(tU.getLocal("r"),tU.i32_const(aJ)),tD=tU.i32_add(tU.getLocal("r"),tU.i32_const(2*aJ)),tj.addCode(tU.call(l+"_neg",tZ,tJ),tU.call(l+"_neg",t$,tW),tU.call(l+"_neg",tQ,tD)),(tV=t.addFunction(e+"_sign")).addParam("x","i32"),tV.addLocal("s","i32"),tV.setReturnType("i32"),tX=(tK=tV.getCodeBuilder()).getLocal("x"),tY=tK.i32_add(tK.getLocal("x"),tK.i32_const(aJ)),tH=tK.i32_add(tK.getLocal("x"),tK.i32_const(2*aJ)),tV.addCode(tK.setLocal("s",tK.call(l+"_sign",tH)),tK.if(tK.getLocal("s"),tK.ret(tK.getLocal("s"))),tK.setLocal("s",tK.call(l+"_sign",tY)),tK.if(tK.getLocal("s"),tK.ret(tK.getLocal("s"))),tK.ret(tK.call(l+"_sign",tX))),(t2=t.addFunction(e+"_toMontgomery")).addParam("x","i32"),t2.addParam("r","i32"),t0=(t3=t2.getCodeBuilder()).getLocal("x"),t1=t3.i32_add(t3.getLocal("x"),t3.i32_const(aJ)),t4=t3.i32_add(t3.getLocal("x"),t3.i32_const(2*aJ)),t6=t3.getLocal("r"),t8=t3.i32_add(t3.getLocal("r"),t3.i32_const(aJ)),t7=t3.i32_add(t3.getLocal("r"),t3.i32_const(2*aJ)),t2.addCode(t3.call(l+"_toMontgomery",t0,t6),t3.call(l+"_toMontgomery",t1,t8),t3.call(l+"_toMontgomery",t4,t7)),(t5=t.addFunction(e+"_fromMontgomery")).addParam("x","i32"),t5.addParam("r","i32"),at=(t9=t5.getCodeBuilder()).getLocal("x"),aa=t9.i32_add(t9.getLocal("x"),t9.i32_const(aJ)),ae=t9.i32_add(t9.getLocal("x"),t9.i32_const(2*aJ)),al=t9.getLocal("r"),ao=t9.i32_add(t9.getLocal("r"),t9.i32_const(aJ)),ai=t9.i32_add(t9.getLocal("r"),t9.i32_const(2*aJ)),t5.addCode(t9.call(l+"_fromMontgomery",at,al),t9.call(l+"_fromMontgomery",aa,ao),t9.call(l+"_fromMontgomery",ae,ai)),(ac=t.addFunction(e+"_eq")).addParam("x","i32"),ac.addParam("y","i32"),ac.setReturnType("i32"),ad=(an=ac.getCodeBuilder()).getLocal("x"),ar=an.i32_add(an.getLocal("x"),an.i32_const(aJ)),as=an.i32_add(an.getLocal("x"),an.i32_const(2*aJ)),a_=an.getLocal("y"),af=an.i32_add(an.getLocal("y"),an.i32_const(aJ)),au=an.i32_add(an.getLocal("y"),an.i32_const(2*aJ)),ac.addCode(an.i32_and(an.i32_and(an.call(l+"_eq",ad,a_),an.call(l+"_eq",ar,af)),an.call(l+"_eq",as,au))),(ag=t.addFunction(e+"_inverse")).addParam("x","i32"),ag.addParam("r","i32"),ap=(aL=ag.getCodeBuilder()).getLocal("x"),ah=aL.i32_add(aL.getLocal("x"),aL.i32_const(aJ)),am=aL.i32_add(aL.getLocal("x"),aL.i32_const(2*aJ)),ab=aL.getLocal("r"),ax=aL.i32_add(aL.getLocal("r"),aL.i32_const(aJ)),ay=aL.i32_add(aL.getLocal("r"),aL.i32_const(2*aJ)),aF=aL.i32_const(t.alloc(aJ)),aC=aL.i32_const(t.alloc(aJ)),aB=aL.i32_const(t.alloc(aJ)),aP=aL.i32_const(t.alloc(aJ)),aA=aL.i32_const(t.alloc(aJ)),aq=aL.i32_const(t.alloc(aJ)),av=aL.i32_const(t.alloc(aJ)),aI=aL.i32_const(t.alloc(aJ)),aO=aL.i32_const(t.alloc(aJ)),aE=aL.i32_const(t.alloc(aJ)),aw=aL.i32_const(t.alloc(aJ)),ag.addCode(aL.call(l+"_square",ap,aF),aL.call(l+"_square",ah,aC),aL.call(l+"_square",am,aB),aL.call(l+"_mul",ap,ah,aP),aL.call(l+"_mul",ap,am,aA),aL.call(l+"_mul",ah,am,aq),aL.call(a,aq,av),aL.call(l+"_sub",aF,av,av),aL.call(a,aB,aI),aL.call(l+"_sub",aI,aP,aI),aL.call(l+"_sub",aC,aA,aO),aL.call(l+"_mul",am,aI,aE),aL.call(l+"_mul",ah,aO,aw),aL.call(l+"_add",aE,aw,aE),aL.call(a,aE,aE),aL.call(l+"_mul",ap,av,aw),aL.call(l+"_add",aw,aE,aE),aL.call(l+"_inverse",aE,aE),aL.call(l+"_mul",aE,av,ab),aL.call(l+"_mul",aE,aI,ax),aL.call(l+"_mul",aE,aO,ay)),(aM=t.addFunction(e+"_timesScalar")).addParam("x","i32"),aM.addParam("scalar","i32"),aM.addParam("scalarLen","i32"),aM.addParam("r","i32"),az=(aS=aM.getCodeBuilder()).getLocal("x"),aT=aS.i32_add(aS.getL
1ocal("x"),aS.i32_const(aJ)),ak=aS.i32_add(aS.getLocal("x"),aS.i32_const(2*aJ)),aG=aS.getLocal("r"),aN=aS.i32_add(aS.getLocal("r"),aS.i32_const(aJ)),aR=aS.i32_add(aS.getLocal("r"),aS.i32_const(2*aJ)),aM.addCode(aS.call(l+"_timesScalar",az,aS.getLocal("scalar"),aS.getLocal("scalarLen"),aG),aS.call(l+"_timesScalar",aT,aS.getLocal("scalar"),aS.getLocal("scalarLen"),aN),aS.call(l+"_timesScalar",ak,aS.getLocal("scalar"),aS.getLocal("scalarLen"),aR)),(aj=t.addFunction(e+"_isNegative")).addParam("x","i32"),aj.setReturnType("i32"),aZ=(aU=aj.getCodeBuilder()).getLocal("x"),a$=aU.i32_add(aU.getLocal("x"),aU.i32_const(aJ)),aQ=aU.i32_add(aU.getLocal("x"),aU.i32_const(2*aJ)),aj.addCode(aU.if(aU.call(l+"_isZero",aQ),aU.if(aU.call(l+"_isZero",a$),aU.ret(aU.call(l+"_isNegative",aZ)),aU.ret(aU.call(l+"_isNegative",a$)))),aU.ret(aU.call(l+"_isNegative",aQ))),t.exportFunction(e+"_isZero"),t.exportFunction(e+"_isOne"),t.exportFunction(e+"_zero"),t.exportFunction(e+"_one"),t.exportFunction(e+"_copy"),t.exportFunction(e+"_mul"),t.exportFunction(e+"_square"),t.exportFunction(e+"_add"),t.exp
1ortFunction(e+"_sub"),t.exportFunction(e+"_neg"),t.exportFunction(e+"_sign"),t.exportFunction(e+"_fromMontgomery"),t.exportFunction(e+"_toMontgomery"),t.exportFunction(e+"_eq"),t.exportFunction(e+"_inverse"),W(t,e),J(t,e+"_exp",3*aJ,e+"_mul",e+"_square",e+"_copy",e+"_one"),t.exportFunction(e+"_exp"),t.exportFunction(e+"_timesScalar"),t.exportFunction(e+"_batchInverse"),t.exportFunction(e+"_isNegative"),e};let tb=function(t,a,e,l,o,i,c,n){let d=t.addFunction(a);d.addParam("base","i32"),d.addParam("scalar","i32"),d.addParam("scalarLength","i32"),d.addParam("r","i32"),d.addLocal("old0","i32"),d.addLocal("nbits","i32"),d.addLocal("i","i32"),d.addLocal("last","i32"),d.addLocal("cur","i32"),d.addLocal("carry","i32"),d.addLocal("p","i32");let r=d.getCodeBuilder(),s=r.i32_const(t.alloc(e));function _(t){return r.i32_and(r.i32_shr_u(r.i32_load(r.i32_add(r.getLocal("scalar"),r.i32_and(r.i32_shr_u(t,r.i32_const(3)),r.i32_const(0xfffffffc)))),r.i32_and(t,r.i32_const(31))),r.i32_const(1))}function f(t){return[...r.i32_store8(r.getLocal("p"),r.i32_const(t)),...r.setLocal("p",r.i32_add(r.getLocal("p"),r.i32_const(1)))]}d.addCode(r.if(r.i32_eqz(r.getLocal("scalarLength")),[...r.call(n,r.getLocal("r")),...r.ret([])]),r.setLocal("nbits",r.i32_shl(r.getLocal("scalarLength"),r.i32_const(3))),r.setLocal("old0",r.i32_load(r.i32_const(0))),r.setLocal("p",r.getLocal("old0")),r.i32_store(r.i32_const(0),r.i32_and(r.i32_add(r.i32_add(r.getLocal("old0"),r.i32_const(32)),r.getLocal("nbits")),r.i32_const(0xfffffff8))),r.setLocal("i",r.i32_const(1)),r.setLocal("last",_(r.i32_const(0))),r.setLocal("carry",r.i32_const(0)),r.block(r.loop(r.br_if(1,r.i32_eq(r.getLocal("i"),r.getLocal("nbits"))),r.setLocal("cur",_(r.getLocal("i"))),r.if(r.getLocal("last"),r.if(r.getLocal("cur"),r.if(r.getLocal("carry"),[...r.setLocal("last",r.i32_const(0)),...r.setLocal("carry",r.i32_const(1)),...f(1)],[...r.setLocal("last",r.i32_const(0)),...r.setLocal("carry",r.i32_const(1)),...f(255)]),r.if(r.getLocal("carry"),[...r.setLocal("last",r.i32_const(0)),...r.setLocal("carry",r.i32_const(1)),...f(255)],[...r.setLocal("last",r.i32_const(0)),...r.setLocal("carry",r.i32_const(0)),...f(1)])),r.if(r.getLocal("cur"),r.if(r.getLocal("carry"),[...r.setLocal("last",r.i32_const(0)),...r.setLocal("carry",r.i32_const(1)),...f(0)],[...r.setLocal("last",r.i32_const(1)),...r.setLocal("carry",r.i32_const(0)),...f(0)]),r.if(r.getLocal("carry"),[...r.setLocal("last",r.i32_const(1)),...r.setLocal("carry",r.i32_const(0)),...f(0)],[...r.setLocal("last",r.i32_const(0)),...r.setLocal("carry",r.i32_const(0)),...f(0)]))),r.setLocal("i",r.i32_add(r.getLocal("i"),r.i32_const(1))),r.br(0))),r.if(r.getLocal("last"),r.if(r.getLocal("carry"),[...f(255),...f(0),...f(1)],[...f(1)]),r.if(r.getLocal("carry"),[...f(0),...f(1)])),r.setLocal("p",r.i32_sub(r.getLocal("p"),r.i32_const(1))),r.call(c,r.getLocal("base"),s),r.call(n,r.getLocal("r")),r.block(r.loop(r.call(o,r.getLocal("r"),r.getLocal("r")),r.setLocal("cur",r.i32_load8_u(r.getLocal("p"))),r.if(r.getLocal("cur"),r.if(r.i32_eq(r.getLocal("cur"),r.i32_const(1)),r.call(l,r.getLocal("r"),s,r.getLocal("r")),r.call(i,r.getLocal("r"),s,r.getLocal("r")))),r.br_if(1,r.i32_eq(r.getLocal("old0"),r.getLocal("p"))),r.setLocal("p",r.i32_sub(r.getLocal("p"),r.i32_const(1))),r.br(0))),r.i32_store(r.i32_const(0),r.getLocal("old0")))},tx=function(t,a,e,l,o){let i,c,n,d,r,s,_,f,u,g,L=8*t.modules[a].n64;(i=t.addFunction(e+"_getChunk")).addParam("pScalar","i32"),i.addParam("scalarSize","i32"),i.addParam("startBit","i32"),i.addParam("chunkSize","i32"),i.addLocal("bitsToEnd","i32"),i.addLocal("mask","i32"),i.setReturnType("i32"),c=i.getCodeBuilder(),i.addCode(c.setLocal("bitsToEnd",c.i32_sub(c.i32_mul(c.getLocal("scalarSize"),c.i32_const(8)),c.getLocal("startBit"))),c.if(c.i32_gt_s(c.getLocal("chunkSize"),c.getLocal("bitsToEnd")),c.setLocal("mask",c.i32_sub(c.i32_shl(c.i32_const(1),c.getLocal("bitsToEnd")),c.i32_const(1))),c.setLocal("mask",c.i32_sub(c.i32_shl(c.i32_const(1),c.getLocal("chunkSize")),c.i32_const(1)))),c.i32_and(c.i32_shr_u(c.i32_load(c.i32_add(c.getLocal("pScalar"),c.i32_shr_u(c.getLocal("startBit"),c.i32_const(3))),0,0),c.i32_and(c.getLocal("startBit"),c.i32_const(7))),c.getLocal("mask"))),(n=t.addFunction(e+"_reduceTable")).addParam("pTable","i32"),n.addParam("p","i32"),n.addLocal("half","i32"),n.addLocal("it1","i32"),n.addLocal("it2","i32"),n.addLocal("pAcc","i32"),d=n.getCodeBuilder(),n.addCode(d.if(d.i32_eq(d.getLocal("p"),d.i32_const(1)),d.ret([])),d.setLocal("half",d.i32_shl(d.i32_const(1),d.i32_sub(d.getLocal("p"),d.i32_const(1)))),d.setLocal("it1",d.getLocal("pTable")),d.setLocal("it2",d.i32_add(d.getLocal("pTable"),d.i32_mul(d.getLocal("half"),d.i32_const(L)))),d.setLocal("pAcc",d.i32_sub(d.getLocal("it2"),d.i32_const(L))),d.block(d.loop(d.br_if(1,d.i32_eq(d.getLocal("it1"),d.getL
1ocal("pAcc"))),d.call(a+"_add",d.getLocal("it1"),d.getLocal("it2"),d.getLocal("it1")),d.call(a+"_add",d.getLocal("pAcc"),d.getLocal("it2"),d.getLocal("pAcc")),d.setLocal("it1",d.i32_add(d.getLocal("it1"),d.i32_const(L))),d.setLocal("it2",d.i32_add(d.getLocal("it2"),d.i32_const(L))),d.br(0))),d.call(e+"_reduceTable",d.getLocal("pTable"),d.i32_sub(d.getLocal("p"),d.i32_const(1))),d.setLocal("p",d.i32_sub(d.getLocal("p"),d.i32_const(1))),d.block(d.loop(d.br_if(1,d.i32_eqz(d.getLocal("p"))),d.call(a+"_double",d.getLocal("pAcc"),d.getLocal("pAcc")),d.setLocal("p",d.i32_sub(d.getLocal("p"),d.i32_const(1))),d.br(0))),d.call(a+"_add",d.getLocal("pTable"),d.getLocal("pAcc"),d.getLocal("pTable"))),(r=t.addFunction(e+"_chunk")).addParam("pBases","i32"),r.addParam("pScalars","i32"),r.addParam("scalarSize","i32"),r.addParam("n","i32"),r.addParam("startBit","i32"),r.addParam("chunkSize","i32"),r.addParam("pr","i32"),r.addLocal("nChunks","i32"),r.addLocal("itScalar","i32"),r.addLocal("endScalar","i32"),r.addLocal("itBase","i32"),r.addLocal("i","i32"),r.addLocal("j","i32"),r.addLocal("nTable","i32"),r.addLocal("pTable","i32"),r.addLocal("idx","i32"),r.addLocal("pIdxTable","i32"),s=r.getCodeBuilder(),r.addCode(s.if(s.i32_eqz(s.getLocal("n")),[...s.call(a+"_zero",s.getLocal("pr")),...s.ret([])]),s.setLocal("nTable",s.i32_shl(s.i32_const(1),s.getLocal("chunkSize"))),s.setLocal("pTable",s.i32_load(s.i32_const(0))),s.i32_store(s.i32_const(0),s.i32_add(s.getLocal("pTable"),s.i32_mul(s.getLocal("nTable"),s.i32_const(L)))),s.setLocal("j",s.i32_const(0)),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal("j"),s.getLocal("nTable"))),s.call(a+"_zero",s.i32_add(s.getLocal("pTable"),s.i32_mul(s.getLocal("j"),s.i32_const(L)))),s.setLocal("j",s.i32_add(s.getLocal("j"),s.i32_const(1))),s.br(0))),s.setLocal("itBase",s.getLocal("pBases")),s.setLocal("itScalar",s.getLocal("pScalars")),s.setLocal("endScalar",s.i32_add(s.getLocal("pScalars"),s.i32_mul(s.getLocal("n"),s.getLocal("scalarSize")))),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal("itScalar"),s.getLocal("endScalar"))),s.setLocal("idx",s.call(e+"_getChunk",s.getLocal("itScalar"),s.getLocal("scalarSize"),s.getLocal("startBit"),s.getLocal("chunkSize"))),s.if(s.getLocal("idx"),[...s.setLocal("pIdxTable",s.i32_add(s.getLocal("pTable"),s.i32_mul(s.i32_sub(s.getLocal("idx"),s.i32_const(1)),s.i32_const(L)))),...s.call(l,s.getLocal("pIdxTable"),s.getLocal("itBase"),s.getLocal("pIdxTable"))]),s.setLocal("itScalar",s.i32_add(s.getLocal("itScalar"),s.getLocal("scalarSize"))),s.setLocal("itBase",s.i32_add(s.getLocal("itBase"),s.i32_const(o))),s.br(0))),s.call(e+"_reduceTable",s.getLocal("pTable"),s.getLocal("chunkSize")),s.call(a+"_copy",s.getLocal("pTable"),s.getLocal("pr")),s.i32_store(s.i32_const(0),s.getLocal("pTable"))),(_=t.addFunction(e)).addParam("pBases","i32"),_.addParam("pScalars","i32"),_.addParam("scalarSize","i32"),_.addParam("n","i32"),_.addParam("pr","i32"),_.addLocal("chunkSize","i32"),_.addLocal("nChunks","i32"),_.addLocal("itScalar","i32"),_.addLocal("endScalar","i32"),_.addLocal("itBase","i32"),_.addLocal("itBit","i32"),_.addLocal("i","i32"),_.addLocal("j","i32"),_.addLocal("nTable","i32"),_.addLocal("pTable","i32"),_.addLocal("idx","i32"),_.addLocal("pIdxTable","i32"),u=(f=_.getCodeBuilder()).i32_const(t.alloc(L)),g=t.alloc([17,17,17,17,17,17,17,17,17,17,16,16,15,14,13,13,12,11,10,9,8,7,7,6,5,4,3,2,1,1,1,1]),_.addCode(f.call(a+"_zero",f.getLocal("pr")),f.if(f.i32_eqz(f.getLocal("n")),f.ret([])),f.setLocal("chunkSize",f.i32_load8_u(f.i32_clz(f.getLocal("n")),g)),f.setLocal("nChunks",f.i32_add(f.i32_div_u(f.i32_sub(f.i32_shl(f.getLocal("scalarSize"),f.i32_const(3)),f.i32_const(1)),f.getLocal("chunkSize")),f.i32_const(1))),f.setLocal("itBit",f.i32_mul(f.i32_sub(f.getLocal("nChunks"),f.i32_const(1)),f.getLocal("chunkSize"))),f.block(f.loop(f.br_if(1,f.i32_lt_s(f.getLocal("itBit"),f.i32_const(0))),f.if(f.i32_eqz(f.call(a+"_isZero",f.getLocal("pr"))),[...f.setLocal("j",f.i32_const(0)),...f.block(f.loop(f.br_if(1,f.i32_eq(f.getLocal("j"),f.getLocal("chunkSize"))),f.call(a+"_double",f.getLocal("pr"),f.getLocal("pr")),f.setLocal("j",f.i32_add(f.getLocal("j"),f.i32_const(1))),f.br(0))
1)]),f.call(e+"_chunk",f.getLocal("pBases"),f.getLocal("pScalars"),f.getLocal("scalarSize"),f.getLocal("n"),f.getLocal("itBit"),f.getLocal("chunkSize"),u),f.call(a+"_add",f.getLocal("pr"),u,f.getLocal("pr")),f.setLocal("itBit",f.i32_sub(f.getLocal("itBit"),f.getLocal("chunkSize"))),f.br(0)))),t.exportFunction(e),t.exportFunction(e+"_chunk")};var ty=function(t,a,e,l){let o,i,c,n,d,r,s,_,f,u,g,L,p,h,m,b,x,y,F,C,B,P,A,q,v,I,O,E,w,M,S,z,T,k,G,N,R,j,U,Z,$,Q,J,W,V,K,X,Y,H,tt,ta,te,tl,to,ti,tc,tn,td,tr,ts,t_,tf,tu,tg,tL,tp,th,tm,ty,tF,tC,tB,tP,tA,tq,tv,tI,tO,tE,tw,tM,tS,tz,tT,tk,tG,tN,tR,tj,tU,tZ,t$,tQ,tJ,tW,tD,tV,tK,tX,tY,tH,t2,t3,t0,t1,t4,t6,t8,t7,t5,t9,at,aa,ae,al,ao,ai,ac,an,ad,ar,as,a_,af,au,ag,aL,ap,ah,am,ab,ax,ay,aF,aC,aB,aP,aA,aq,av,aI,aO,aE,aw,aM,aS,az,aT,ak,aG,aN,aR,aj,aU,aZ,a$,aQ,aJ,aW,aD,aV,aK,aX,aY,aH,a2,a3,a0,a1,a4,a6,a8,a7,a5,a9,et,ea,ee,el,eo,ei,ec,en,ed,er,es,e_,ef,eu,eg,eL,ep,eh,em,eb,ex,ey,eF,eC,eB,eP,eA,eq,ev,eI,eO,eE,ew,eM,eS,ez,eT,ek,eG,eN,eR,ej,eU,eZ,e$,eQ,eJ,eW=t.modules[e].n64,eD=8*eW;if(t.modules[a])return a;t.modules[a]={n64:3*eW},(o=t.addFunction(a+"_isZeroAffine")).addParam("p1","i32"),o.setReturnType("i32"),i=o.getCodeBuilder(),o.addCode(i.i32_and(i.call(e+"_isZero",i.getLocal("p1")),i.call(e+"_isZero",i.i32_add(i.getLocal("p1"),i.i32_const(eD))))),(c=t.addFunction(a+"_isZero")).addParam("p1","i32"),c.setReturnType("i32"),n=c.getCodeBuilder(),c.addCode(n.call(e+"_isZero",n.i32_add(n.getLocal("p1"),n.i32_const(2*eD)))),(d=t.addFunction(a+"_zeroAffine")).addParam("pr","i32"),r=d.getCodeBuilder(),d.addCode(r.call(e+"_zero",r.getLocal("pr"))),d.addCode(r.call(e+"_zero",r.i32_add(r.getLocal("pr"),r.i32_const(eD)))),(s=t.addFunction(a+"_zero")).addParam("pr","i32"),_=s.getCodeBuilder(),s.addCode(_.call(e+"_zero",_.getLocal("pr"))),s.addCode(_.call(e+"_one",_.i32_add(_.getLocal("pr"),_.i32_const(eD)))),s.addCode(_.call(e+"_zero",_.i32_add(_.getLocal("pr"),_.i32_const(2*eD))));let eV=t.addFunction(a+"_copyAffine");eV.addParam("ps","i32"),eV.addParam("pd","i32");let eK=eV.getCodeBuilder();for(let t=0;t<2*eW;t++)eV.addCode(eK.i64_store(eK.getLocal("pd"),8*t,eK.i64_load(eK.getLocal("ps"),8*t)));let eX=t.addFunction(a+"_copy");eX.addParam("ps","i32"),eX.addParam("pd","i32");let eY=eX.getCodeBuilder();for(let t=0;t<3*eW;t++)eX.addCode(eY.i64_store(eY.getLocal("pd"),8*t,eY.i64_load(eY.getLocal("ps"),8*t)));(f=t.addFunction(a+"_toJacobian")).addParam("p1","i32"),f.addParam("pr","i32"),g=(u=f.getCodeBuilder()).getLocal("p1"),L=u.i32_add(u.getLocal("p1"),u.i32_const(eD)),p=u.getLocal("pr"),h=u.i32_add(u.getLocal("pr"),u.i32_const(eD)),m=u.i32_add(u.getLocal("pr"),u.i32_const(2*eD)),f.addCode(u.if(u.call(a+"_isZeroAffine",u.getLocal("p1")),u.call(a+"_zero",u.getLocal("pr")),[...u.call(e+"_one",m),...u.call(e+"_copy",L,h),...u.call(e+"_copy",g,p)])),(b=t.addFunction(a+"_eqAffine")).addParam("p1","i32"),b.addParam("p2","i32"),b.setReturnType("i32"),b.addLocal("z1","i32"),x=b.getCodeBuilder(),b.addCode(x.ret(x.i32_and(x.call(e+"_eq",x.getLocal("p1"),x.getLocal("p2")),x.call(e+"_eq",x.i32_add(x.getLocal("p1"),x.i32_const(eD)),x.i32_add(x.getLocal("p2"),x.i32_const(eD)))))),(y=t.addFunction(a+"_eqMixed")).addParam("p1","i32"),y.addParam("p2","i32"),y.setReturnType("i32"),y.addLocal("z1","i32"),C=(F=y.getCodeBuilder()).getLocal("p1"),B=F.i32_add(F.getLocal("p1"),F.i32_const(eD)),y.addCode(F.setLocal("z1",F.i32_add(F.getLocal("p1"),F.i32_const(2*eD)))),P=F.getLocal("z1"),A=F.getLocal("p2"),q=F.i32_add(F.getLocal("p2"),F.i32_const(eD)),v=F.i32_const(t.alloc(eD)),I=F.i32_const(t.alloc(eD)),O=F.i32_const(t.alloc(eD)),E=F.i32_const(t.alloc(eD)),y.addCode(F.if(F.call(a+"_isZero",F.getLocal("p1")),F.ret(F.call(a+"_isZeroAffine",F.getLocal("p2")))),F.if(F.call(a+"_isZeroAffine",F.getLocal("p2")),F.ret(F.i32_const(0))),F.if(F.call(e+"_isOne",P),F.ret(F.call(a+"_eqAffine",F.getLocal("p1"),F.getLocal("p2")))),F.call(e+"_square",P,v),F.call(e+"_mul",A,v,I),F.call(e+"_mul",P,v,O),F.call(e+"_mul",q,O,E),F.if(F.call(e+"_eq",C,I),F.if(F.call(e+"_eq",B,E),F.ret(F.i32_const(1)))),F.ret(F.i32_const(0))),(w=t.addFunction(a+"_eq")).addParam("p1","i32"),w.addParam("p2","i32"),w.setReturnType("i32"),w.addLocal("z1","i32"),w.addLocal("z2","i32"),S=(M=w.getCodeBuilder()).getLocal("p1"),z=M.i32_add(M.getLocal("p1"),M.i32_const(eD)),w.addCode(M.setLocal("z1",M.i32_add(M.getLocal("p1"),M.i32_const(2*eD)))),T=M.getLocal("z1"),k=M.getLocal("p2"),G=M.i32_add(M.getLocal("p2"),M.i32_const(eD)),w.addCode(M.setLocal("z2",M.i32_add(M.getLocal("p2"),M.i32_const(2*eD)))),N=M.getLocal("z2"),R=M.i32_const(t.alloc(eD)),j=M.i32_const(t.alloc(eD)),U=M.i32_const(t.alloc(eD)),Z=M.i32_const(t.alloc(eD)),$=M.i32_const(t.alloc(eD)),Q=M.i32_const(t.alloc(eD)),J=
1M.i32_const(t.alloc(eD)),W=M.i32_const(t.alloc(eD)),w.addCode(M.if(M.call(a+"_isZero",M.getLocal("p1")),M.ret(M.call(a+"_isZero",M.getLocal("p2")))),M.if(M.call(a+"_isZero",M.getLocal("p2")),M.ret(M.i32_const(0))),M.if(M.call(e+"_isOne",T),M.ret(M.call(a+"_eqMixed",M.getLocal("p2"),M.getLocal("p1")))),M.if(M.call(e+"_isOne",N),M.ret(M.call(a+"_eqMixed",M.getLocal("p1"),M.getLocal("p2")))),M.call(e+"_square",T,R),M.call(e+"_square",N,j),M.call(e+"_mul",S,j,U),M.call(e+"_mul",k,R,Z),M.call(e+"_mul",T,R,$),M.call(e+"_mul",N,j,Q),M.call(e+"_mul",z,Q,J),M.call(e+"_mul",G,$,W),M.if(M.call(e+"_eq",U,Z),M.if(M.call(e+"_eq",J,W),M.ret(M.i32_const(1)))),M.ret(M.i32_const(0))),(V=t.addFunction(a+"_doubleAffine")).addParam("p1","i32"),V.addParam("pr","i32"),X=(K=V.getCodeBuilder()).getLocal("p1"),Y=K.i32_add(K.getLocal("p1"),K.i32_const(eD)),H=K.getLocal("pr"),tt=K.i32_add(K.getLocal("pr"),K.i32_const(eD)),ta=K.i32_add(K.getLocal("pr"),K.i32_const(2*eD)),te=K.i32_const(t.alloc(eD)),tl=K.i32_const(t.alloc(eD)),to=K.i32_const(t.alloc(eD)),ti=K.i32_const(t.alloc(eD)),tc=K.i32_const(t.alloc(eD)),tn=K.i32_const(t.alloc(eD)),V.addCode(K.if(K.call(a+"_isZeroAffine",K.getLocal("p1")),[...K.call(a+"_toJacobian",K.getLocal("p1"),K.getLocal("pr")),...K.ret([])]),K.call(e+"_square",X,te),K.call(e+"_square",Y,tl),K.call(e+"_square",tl,to),K.call(e+"_add",X,tl,ti),K.call(e+"_square",ti,ti),K.call(e+"_sub",ti,te,ti),K.call(e+"_sub",ti,to,ti),K.call(e+"_add",ti,ti,ti),K.call(e+"_add",te,te,tc),K.call(e+"_add",tc,te,tc),K.call(e+"_add",Y,Y,ta),K.call(e+"_square",tc,H),K.call(e+"_sub",H,ti,H),K.call(e+"_sub",H,ti,H),K.call(e+"_add",to,to,tn),K.call(e+"_add",tn,tn,tn),K.call(e+"_add",tn,tn,tn),K.call(e+"_sub",ti,H,tt),K.call(e+"_mul",tt,tc,tt),K.call(e+"_sub",tt,tn,tt)),(td=t.addFunction(a+"_double")).addParam("p1","i32"),td.addParam("pr","i32"),ts=(tr=td.getCodeBuilder()).getLocal("p1"),t_=tr.i32_add(tr.getLocal("p1"),tr.i32_const(eD)),tf=tr.i32_add(tr.getLocal("p1"),tr.i32_const(2*eD)),tu=tr.getLocal("pr"),tg=tr.i32_add(tr.getLocal("pr"),tr.i32_const(eD)),tL=tr.i32_add(tr.getLocal("pr"),tr.i32_const(2*eD)),tp=tr.i32_const(t.alloc(eD)),th=tr.i32_const(t.alloc(eD)),tm=tr.i32_const(t.alloc(eD)),ty=tr.i32_const(t.alloc(eD)),tF=tr.i32_const(t.alloc(eD)),tC=tr.i32_const(t.alloc(eD)),tB=tr.i32_const(t.alloc(eD)),tP=tr.i32_const(t.alloc(eD)),td.addCode(tr.if(tr.call(a+"_isZero",tr.getLocal("p1")),[...tr.call(a+"_copy",tr.getLocal("p1"),tr.getLocal("pr")),...tr.ret([])]),tr.if(tr.call(e+"_isOne",tf),[...tr.ret(tr.call(a+"_doubleAffine",tr.getLocal("p1"),tr.getLocal("pr"))),...tr.ret([])]),tr.call(e+"_square",ts,tp),tr.call(e+"_square",t_,th),tr.call(e+"_square",th,tm),tr.call(e+"_add",ts,th,ty),tr.call(e+"_square",ty,ty),tr.call(e+"_sub",ty,tp,ty),tr.call(e+"_sub",ty,tm,ty),tr.call(e+"_add",ty,ty,ty),tr.call(e+"_add",tp,tp,tF),tr.call(e+"_add",tF,tp,tF),tr.call(e+"_square",tF,tC),tr.call(e+"_mul",t_,tf,tB),tr.call(e+"_add",ty,ty,tu),tr.call(e+"_sub",tC,tu,tu),tr.call(e+"_add",tm,tm,tP),tr.call(e+"_add",tP,tP,tP),tr.call(e+"_add",tP,tP,tP),tr.call(e+"_sub",ty,tu,tg),tr.call(e+"_mul",tg,tF,tg),tr.call(e+"_sub",tg,tP,tg),tr.call(e+"_add",tB,tB,tL)),(tA=t.addFunction(a+"_addAffine")).addParam("p1","i32"),tA.addParam("p2","i32"),tA.addParam("pr","i32"),tA.addLocal("z1","i32"),tv=(tq=tA.getCodeBuilder()).getLocal("p1"),tI=tq.i32_add(tq.getLocal("p1"),tq.i32_const(eD)),tA.addCode(tq.setLocal("z1",tq.i32_add(tq.getLocal("p1"),tq.i32_const(2*eD)))),tO=tq.getLocal("p2"),tE=tq.i32_add(tq.getLocal("p2"),tq.i32_const(eD)),tw=tq.getLocal("pr"),tM=tq.i32_add(tq.getLocal("pr"),tq.i32_const(eD)),tS=tq.i32_add(tq.getLocal("pr"),tq.i32_const(2*eD)),tz=tq.i32_const(t.alloc(eD)),tT=tq.i32_const(t.alloc(eD)),tk=tq.i32_const(t.alloc(eD)),tG=tq.i32_const(t.alloc(eD)),tN=tq.i32_const(t.alloc(eD)),tR=tq.i32_const(t.alloc(eD)),tj=tq.i32_const(t.alloc(eD)),tU=tq.i32_const(t.alloc(eD)),tZ=tq.i32_const(t.alloc(eD)),t$=tq.i32_const(t.alloc(eD)),tA.addCode(tq.if(tq.call(a+"_isZeroAffine",tq.getLocal("p1")),[...tq.call(a+"_copyAffine",tq.getLocal("p2"),tq.getLocal("pr")),...tq.call(e+"_one",tq.i32_add(tq.getLocal("pr"),tq.i32_const(2*eD))),...tq.ret([])]),tq.if(tq.call(a+"_isZeroAffine",tq.getLocal("p2")),[...tq.call(a+"_copyAffine",tq.getLocal("p1"),tq.getLocal("pr")),...tq.call(e+"_one",tq.i32_add(tq.getLocal("pr"),tq.i32_const(2*eD))),...tq.ret([])]),tq.if(tq.call(e+"_eq",tv,tO),tq.if(tq.call(e+"_eq",tI,tE),[...tq.call(a+"_doubleAffine",tq.getLocal("p2"),tq.getLocal("pr")),...tq.ret([])])),tq.call(e+"_sub",tO,tv,tz),tq.call(e+"_sub",tE,tI,tk),tq.call(e+"_square",tz,tT),tq.call(e+"_add",tT,tT,tG),tq.call(e+"_add",tG,tG,tG),tq.call(e+"_mul",tz,tG,tN),tq.call(e+"_add",tk,tk,tR),tq.call(e+"_mul",tv,tG,tU),tq.call(e+"_square",tR,tj),tq.call(e+"_add",tU,tU,tZ),tq.call(e+"_sub",tj,tN,tw),tq.call(e+"_sub",tw,tZ,tw),tq.call(e+"_mul",tI,tN,t$),tq.call(e+"_add",t$,t$,t$),tq.call(e+"_sub",tU,tw,tM),tq.call(e+"_mul",tM,tR,tM),tq.call(e+"_sub",tM,t$,tM),tq.call(e+"_add",tz,tz,tS)),(tQ=t.addFunction(a+"_addMixed")).addParam("p1","i32"),tQ.addParam("p2","i32"),tQ.addParam("pr","i32"),tQ.addLocal("z1","i32"),tW=(tJ=tQ.getCodeBuilder()).getLocal("p1"),tD=tJ.i32_add(tJ.getLocal("p1"),tJ.i32_const(eD)),tQ.addCode(tJ.setLocal("z1",tJ.i32_add(tJ.getLocal("p1"),tJ.i32_const(2*eD)))),tV=tJ.getLocal("z1"),tK=tJ.getLocal("p2"),tX=tJ.i32_add(tJ.getLocal("p2"),tJ.i32_const(eD)),tY=tJ.getLocal("pr"),tH=tJ.i32_add(tJ.getLocal("pr"),tJ.i32_const(eD)),t2
1=tJ.i32_add(tJ.getLocal("pr"),tJ.i32_const(2*eD)),t3=tJ.i32_const(t.alloc(eD)),t0=tJ.i32_const(t.alloc(eD)),t1=tJ.i32_const(t.alloc(eD)),t4=tJ.i32_const(t.alloc(eD)),t6=tJ.i32_const(t.alloc(eD)),t8=tJ.i32_const(t.alloc(eD)),t7=tJ.i32_const(t.alloc(eD)),t5=tJ.i32_const(t.alloc(eD)),t9=tJ.i32_const(t.alloc(eD)),at=tJ.i32_const(t.alloc(eD)),aa=tJ.i32_const(t.alloc(eD)),ae=tJ.i32_const(t.alloc(eD)),al=tJ.i32_const(t.alloc(eD)),ao=tJ.i32_const(t.alloc(eD)),tQ.addCode(tJ.if(tJ.call(a+"_isZero",tJ.getLocal("p1")),[...tJ.call(a+"_copyAffine",tJ.getLocal("p2"),tJ.getLocal("pr")),...tJ.call(e+"_one",tJ.i32_add(tJ.getLocal("pr"),tJ.i32_const(2*eD))),...tJ.ret([])]),tJ.if(tJ.call(a+"_isZeroAffine",tJ.getLocal("p2")),[...tJ.call(a+"_copy",tJ.getLocal("p1"),tJ.getLocal("pr")),...tJ.ret([])]),tJ.if(tJ.call(e+"_isOne",tV),[...tJ.call(a+"_addAffine",tW,tK,tY),...tJ.ret([])]),tJ.call(e+"_square",tV,t3),tJ.call(e+"_mul",tK,t3,t0),tJ.call(e+"_mul",tV,t3,t1),tJ.call(e+"_mul",tX,t1,t4),tJ.if(tJ.call(e+"_eq",tW,t0),tJ.if(tJ.call(e+"_eq",tD,t4),[...tJ.call(a+"_doubleAffine",tJ.getLocal("p2"),tJ.getLocal("pr")),...tJ.ret([])])),tJ.call(e+"_sub",t0,tW,t6),tJ.call(e+"_sub",t4,tD,t7),tJ.call(e+"_square",t6,t8),tJ.call(e+"_add",t8,t8,t5),tJ.call(e+"_add",t5,t5,t5),tJ.call(e+"_mul",t6,t5,t9),tJ.call(e+"_add",t7,t7,at),tJ.call(e+"_mul",tW,t5,ae),tJ.call(e+"_square",at,aa),tJ.call(e+"_add",ae,ae,al),tJ.call(e+"_sub",aa,t9,tY),tJ.call(e+"_sub",tY,al,tY),tJ.call(e+"_mul",tD,t9,ao),tJ.call(e+"_add",ao,ao,ao),tJ.call(e+"_sub",ae,tY,tH),tJ.call(e+"_mul",tH,at,tH),tJ.call(e+"_sub",tH,ao,tH),tJ.call(e+"_add",tV,t6,t2),tJ.call(e+"_square",t2,t2),tJ.call(e+"_sub",t2,t3,t2),tJ.call(e+"_sub",t2,t8,t2)),(ai=t.addFunction(a+"_add")).addParam("p1","i32"),ai.addParam("p2","i32"),ai.addParam("pr","i32"),ai.addLocal("z1","i32"),ai.addLocal("z2","i32"),an=(ac=ai.getCodeBuilder()).getLocal("p1"),ad=ac.i32_add(ac.getLocal("p1"),ac.i32_const(eD)),ai.addCode(ac.setLocal("z1",ac.i32_add(ac.getLocal("p1"),ac.i32_const(2*eD)))),ar=ac.getLocal("z1"),as=ac.getLocal("p2"),a_=ac.i32_add(ac.getLocal("p2"),ac.i32_const(eD)),ai.addCode(ac.setLocal("z2",ac.i32_add(ac.getLocal("p2"),ac.i32_const(2*eD)))),af=ac.getLocal("z2"),au=ac.getLocal("pr"),ag=ac.i32_add(ac.getLocal("pr"),ac.i32_const(eD)),aL=ac.i32_add(ac.getLocal("pr"),ac.i32_const(2*eD)),ap=ac.i32_const(t.alloc(eD)),ah=ac.i32_const(t.alloc(eD)),am=ac.i32_const(t.alloc(eD)),ab=ac.i32_const(t.alloc(eD)),ax=ac.i32_const(t.alloc(eD)),ay=ac.i32_const(t.alloc(eD)),aF=ac.i32_const(t.alloc(eD)),aC=ac.i32_const(t.alloc(eD)),aB=ac.i32_const(t.alloc(eD)),aP=ac.i32_const(t.alloc(eD)),aA=ac.i32_const(t.alloc(eD)),aq=ac.i32_const(t.alloc(eD)),av=ac.i32_const(t.alloc(eD)),aI=ac.i32_const(t.alloc(eD)),aO=ac.i32_const(t.alloc(eD)),aE=ac.i32_const(t.alloc(eD)),aw=ac.i32_const(t.alloc(eD)),ai.addCode(ac.if(ac.call(a+"_isZero",ac.getLocal("p1")),[...ac.call(a+"_copy",ac.getLocal("p2"),ac.getLocal("pr")),...ac.ret([])]),ac.if(ac.call(a+"_isZero",ac.getLocal("p2")),[...ac.call(a+"_copy",ac.getLocal("p1"),ac.getLocal("pr")),...ac.ret([])]),ac.if(ac.call(e+"_isOne",ar),[...ac.call(a+"_addMixed",as,an,au),...ac.ret([])]),ac.if(ac.call(e+"_isOne",af),[...ac.call(a+"_addMixed",an,as,au),...ac.ret([])]),ac.call(e+"_square",ar,ap),ac.call(e+"_square",af,ah),ac.call(e+"_mul",an,ah,am),ac.call(e+"_mul",as,ap,ab),ac.call(e+"_mul",ar,ap,ax),ac.call(e+"_mul",af,ah,ay),ac.call(e+"_mul",ad,ay,aF),ac.call(e+"_mul",a_,ax,aC),ac.if(ac.call(e+"_eq",am,ab),ac.if(ac.call(e+"_eq",aF,aC),[...ac.call(a+"_double",ac.getLocal("p1"),ac.getLocal("pr")),...ac.ret([])])),ac.call(e+"_sub",ab,am,aB),ac.call(e+"_sub",aC,aF,aP),ac.call(e+"_add",aB,aB,aA),ac.call(e+"_square",aA,aA),ac.call(e+"_mul",aB,aA,aq),ac.call(e+"_add",aP,aP,av),ac.call(e+"_mul",am,aA,aO),ac.call(e+"_square",av,aI),ac.call(e+"_add",aO,aO,aE),ac.call(e+"_sub",aI,aq,au),ac.call(e+"_sub",au,aE,au),ac.call(e+"_mul",aF,aq,aw),ac.call(e+"_add",aw,aw,aw),ac.call(e+"_sub",aO,au,ag),ac.call(e+"_mul",ag,av,ag),ac.call(e+"_sub",ag,aw,ag),ac.call(e+"_add",ar,af,aL),ac.call(e+"_square",aL,aL),ac.call(e+"_sub",aL,ap,aL),ac.call(e+"_sub",aL,ah,aL),ac.call(e+"_mul",aL,aB,aL)),(aM=t.addFunction(a+"_negAffine")).addParam("p1","i32"),aM.addParam("pr","i32"),az=(aS=aM.getCodeBuilder()).getLocal("p1"),aT=aS.i32_add(aS.getL
1ocal("p1"),aS.i32_const(eD)),ak=aS.getLocal("pr"),aG=aS.i32_add(aS.getLocal("pr"),aS.i32_const(eD)),aM.addCode(aS.call(e+"_copy",az,ak),aS.call(e+"_neg",aT,aG)),(aN=t.addFunction(a+"_neg")).addParam("p1","i32"),aN.addParam("pr","i32"),aj=(aR=aN.getCodeBuilder()).getLocal("p1"),aU=aR.i32_add(aR.getLocal("p1"),aR.i32_const(eD)),aZ=aR.i32_add(aR.getLocal("p1"),aR.i32_const(2*eD)),a$=aR.getLocal("pr"),aQ=aR.i32_add(aR.getLocal("pr"),aR.i32_const(eD)),aJ=aR.i32_add(aR.getLocal("pr"),aR.i32_const(2*eD)),aN.addCode(aR.call(e+"_copy",aj,a$),aR.call(e+"_neg",aU,aQ),aR.call(e+"_copy",aZ,aJ)),(aW=t.addFunction(a+"_subAffine")).addParam("p1","i32"),aW.addParam("p2","i32"),aW.addParam("pr","i32"),aV=(aD=aW.getCodeBuilder()).i32_const(t.alloc(3*eD)),aW.addCode(aD.call(a+"_negAffine",aD.getLocal("p2"),aV),aD.call(a+"_addAffine",aD.getLocal("p1"),aV,aD.getLocal("pr"))),(aK=t.addFunction(a+"_subMixed")).addParam("p1","i32"),aK.addParam("p2","i32"),aK.addParam("pr","i32"),aY=(aX=aK.getCodeBuilder()).i32_const(t.alloc(3*eD)),aK.addCode(aX.call(a+"_negAffine",aX.getLocal("p2"),aY),aX.call(a+"_addMixed",aX.getLocal("p1"),aY,aX.getLocal("pr"))),(aH=t.addFunction(a+"_sub")).addParam("p1","i32"),aH.addParam("p2","i32"),aH.addParam("pr","i32"),a3=(a2=aH.getCodeBuilder()).i32_const(t.alloc(3*eD)),aH.addCode(a2.call(a+"_neg",a2.getLocal("p2"),a3),a2.call(a+"_add",a2.getLocal("p1"),a3,a2.getLocal("pr")));let eH=t.addFunction(a+"_fromMontgomeryAffine");eH.addParam("p1","i32"),eH.addParam("pr","i32");let e2=eH.getCodeBuilder();eH.addCode(e2.call(e+"_fromMontgomery",e2.getLocal("p1"),e2.getLocal("pr")));for(let t=1;t<2;t++)eH.addCode(e2.call(e+"_fromMontgomery",e2.i32_add(e2.getLocal("p1"),e2.i32_const(t*eD)),e2.i32_add(e2.getLocal("pr"),e2.i32_const(t*eD))));let e3=t.addFunction(a+"_fromMontgomery");e3.addParam("p1","i32"),e3.addParam("pr","i32");let e0=e3.getCodeBuilder();e3.addCode(e0.call(e+"_fromMontgomery",e0.getLocal("p1"),e0.getLocal("pr")));for(let t=1;t<3;t++)e3.addCode(e0.call(e+"_fromMontgomery",e0.i32_add(e0.getLocal("p1"),e0.i32_const(t*eD)),e0.i32_add(e0.getLocal("pr"),e0.i32_const(t*eD))));let e1=t.addFunction(a+"_toMontgomeryAffine");e1.addParam("p1","i32"),e1.addParam("pr","i32");let e4=e1.getCodeBuilder();e1.addCode(e4.call(e+"_toMontgomery",e4.getLocal("p1"),e4.getLocal("pr")));for(let t=1;t<2;t++)e1.addCode(e4.call(e+"_toMontgomery",e4.i32_add(e4.getLocal("p1"),e4.i32_const(t*eD)),e4.i32_add(e4.getLocal("pr"),e4.i32_const(t*eD))));let e6=t.addFunction(a+"_toMontgomery");e6.addParam("p1","i32"),e6.addParam("pr","i32");let e8=e6.getCodeBuilder();e6.addCode(e8.call(e+"_toMontgomery",e8.getLocal("p1"),e8.getLocal("pr")));for(let t=1;t<3;t++)e6.addCode(e8.call(e+"_toMontgomery",e8.i32_add(e8.getLocal("p1"),e8.i32_const(t*eD)),e8.i32_add(e8.getLocal("pr"),e8.i32_const(t*eD))));return(a0=t.addFunction(a+"_toAffine")).addParam("p1","i32"),a0.addParam("pr","i32"),a4=(a1=a0.getCodeBuilder()).getLocal("p1"),a6=a1.i32_add(a1.getLocal("p1"),a1.i32_const(eD)),a8=a1.i32_add(a1.getLocal("p1"),a1.i32_const(2*eD)),a7=a1.getLocal("pr"),a5=a1.i32_add(a1.getLocal("pr"),a1.i32_const(eD)),a9=a1.i32_const(t.alloc(eD)),et=a1.i32_const(t.alloc(eD)),ea=a1.i32_const(t.alloc(eD)),a0.addCode(a1.if(a1.call(a+"_isZero",a1.getLocal("p1")),[...a1.call(e+"_zero",a7),...a1.call(e+"_zero",a5)],[...a1.call(e+"_inverse",a8,a9),...a1.call(e+"_square",a9,et),...a1.call(e+"_mul",a9,et,ea),...a1.call(e+"_mul",a4,et,a7),...a1.call(e+"_mul",a6,ea,a5)])),(ee=t.addFunction(a+"_inCurveAffine")).addParam("pIn","i32"),ee.setReturnType("i32"),eo=(el=ee.getCodeBuilder()).getLocal("pIn"),ei=el.i32_add(el.getLocal("pIn"),el.i32_const(eD)),ec=el.i32_const(t.alloc(eD)),en=el.i32_const(t.alloc(eD)),ee.addCode(el.call(e+"_square",ei,ec),el.call(e+"_square",eo,en),el.call(e+"_mul",eo,en,en),el.call(e+"_add",en,el.i32_const(l),en),el.ret(el.call(e+"_eq",ec,en))),(ed=t.addFunction(a+"_inCurve")).addParam("pIn","i32"),ed.setReturnType("i32"),es=(er=ed.getCodeBuilder()).i32_const(t.alloc(2*eD)),ed.addCode(er.call(a+"_toAffine",er.getLocal("pIn"),es),er.ret(er.call(a+"_inCurveAffine",es))),(e_=t.addFunction(a+"_batchToAffine")).addParam("pIn","i32"),e_.addParam("n","i32"),e_.addParam("pOut","i32"),e_.addLocal("pAux","i32"),e_.addLocal("itIn","i32"),e_.addLocal("itAux","i32"),e_.addLocal("itOut","i32"),e_.addLocal("i","i32"),eu=(ef=e_.getCodeBuilder()).i32_const(t.alloc(eD)),e_.addCode(ef.setLocal("pAux",ef.i32_load(ef.i32_const(0))),ef.i32_store(ef.i32_const(0),ef.i32_add(ef.getLocal("pAux"),ef.i32_mul(ef.getLocal("n"),ef.i32_const(eD)))),ef.call(e+"_batchInverse",ef.i32_add(ef.getLocal("pIn"),ef.i32_const(2*eD)),ef.i32_const(3*eD),ef.getLocal("n"),ef.getLocal("pAux"),ef.i32_const(eD)),ef.setLocal("itIn",ef.getLocal("pIn")),ef.setLocal("itAux",ef.getLocal("pAux")),ef.setLocal("itOut",ef.getLocal("pOut")),ef.setLocal("i",ef.i32_const(0)),ef.block(ef.loop(ef.br_if(1,ef.i32_eq(ef.getLocal("i"),ef.getLocal("n"))),ef.if(ef.call(e+"_isZero",ef.getLocal("itAux")),[...ef.call(e+"_zero",ef.getLocal("itOut")),...ef.call(e+"_zero",ef.i32_add(ef.getLocal("itOut"),ef.i32_const(eD)))],[...ef.call(e+"_mul",ef.getLocal("itAux"),ef.i32_add(ef.getLocal("itIn"),ef.i32_const(eD)),eu),...ef.call(e+"_square",ef.getLocal("itAux"),ef.getLocal("itAux")),...ef.call(e+"_mul",ef.getLocal("itAux"),ef.getLocal("itIn"),ef.getLocal("itOut")),...ef.call(e+"_mul",ef.getLocal("itAux"),eu,ef.i32_add(ef.getLocal("itOut"),ef.i32_const(eD)))]),ef.setLocal("itIn",ef.i32_add(ef.getLocal("itIn"),ef.i32_const(3*eD))
1),ef.setLocal("itOut",ef.i32_add(ef.getLocal("itOut"),ef.i32_const(2*eD))),ef.setLocal("itAux",ef.i32_add(ef.getLocal("itAux"),ef.i32_const(eD))),ef.setLocal("i",ef.i32_add(ef.getLocal("i"),ef.i32_const(1))),ef.br(0))),ef.i32_store(ef.i32_const(0),ef.getLocal("pAux"))),(eg=t.addFunction(a+"_normalize")).addParam("p1","i32"),eg.addParam("pr","i32"),ep=(eL=eg.getCodeBuilder()).getLocal("p1"),eh=eL.i32_add(eL.getLocal("p1"),eL.i32_const(eD)),em=eL.i32_add(eL.getLocal("p1"),eL.i32_const(2*eD)),eb=eL.getLocal("pr"),ex=eL.i32_add(eL.getLocal("pr"),eL.i32_const(eD)),ey=eL.i32_add(eL.getLocal("pr"),eL.i32_const(2*eD)),eF=eL.i32_const(t.alloc(eD)),eC=eL.i32_const(t.alloc(eD)),eB=eL.i32_const(t.alloc(eD)),eg.addCode(eL.if(eL.call(a+"_isZero",eL.getLocal("p1")),eL.call(a+"_zero",eL.getLocal("pr")),[...eL.call(e+"_inverse",em,eF),...eL.call(e+"_square",eF,eC),...eL.call(e+"_mul",eF,eC,eB),...eL.call(e+"_mul",ep,eC,eb),...eL.call(e+"_mul",eh,eB,ex),...eL.call(e+"_one",ey)])),(eP=t.addFunction(a+"__reverseBytes")).addParam("pIn","i32"),eP.addParam("n","i32"),eP.addParam("pOut","i32"),eP.addLocal("itOut","i32"),eP.addLocal("itIn","i32"),eA=eP.getCodeBuilder(),eP.addCode(eA.setLocal("itOut",eA.i32_sub(eA.i32_add(eA.getLocal("pOut"),eA.getLocal("n")),eA.i32_const(1))),eA.setLocal("itIn",eA.getLocal("pIn")),eA.block(eA.loop(eA.br_if(1,eA.i32_lt_s(eA.getLocal("itOut"),eA.getLocal("pOut"))),eA.i32_store8(eA.getLocal("itOut"),eA.i32_load8_u(eA.getLocal("itIn"))),eA.setLocal("itOut",eA.i32_sub(eA.getLocal("itOut"),eA.i32_const(1))),eA.setLocal("itIn",eA.i32_add(eA.getLocal("itIn"),eA.i32_const(1))),eA.br(0)))),(eq=t.addFunction(a+"_LEMtoU")).addParam("pIn","i32"),eq.addParam("pOut","i32"),ev=eq.getCodeBuilder(),eI=t.alloc(2*eD),eO=ev.i32_const(eI),eE=ev.i32_const(eI),ew=ev.i32_const(eI+eD),eq.addCode(ev.if(ev.call(a+"_isZeroAffine",ev.getLocal("pIn")),[...ev.call(a+"_zeroAffine",ev.getLocal("pOut")),...ev.ret([])]),ev.call(a+"_fromMontgomeryAffine",ev.getLocal("pIn"),eO),ev.call(a+"__reverseBytes",eE,ev.i32_const(eD),ev.getLocal("pOut")),ev.call(a+"__reverseBytes",ew,ev.i32_const(eD),ev.i32_add(ev.getLocal("pOut"),ev.i32_const(eD)))),(eM=t.addFunction(a+"_LEMtoC")).addParam("pIn","i32"),eM.addParam("pOut","i32"),ez=(eS=eM.getCodeBuilder()).i32_const(t.alloc(eD)),eM.addCode(eS.if(eS.call(a+"_isZeroAffine",eS.getLocal("pIn")),[...eS.call(e+"_zero",eS.getLocal("pOut")),...eS.i32_store8(eS.getLocal("pOut"),eS.i32_const(64)),...eS.ret([])]),eS.call(e+"_fromMontgomery",eS.getLocal("pIn"),ez),eS.call(a+"__reverseBytes",ez,eS.i32_const(eD),eS.getLocal("pOut")),eS.if(eS.i32_eq(eS.call(e+"_sign",eS.i32_add(eS.getLocal("pIn"),eS.i32_const(eD))),eS.i32_const(-1)),eS.i32_store8(eS.getLocal("pOut"),eS.i32_or(eS.i32_load8_u(eS.getLocal("pOut")),eS.i32_const(128))))),(eT=t.addFunction(a+"_UtoLEM")).addParam("pIn","i32"),eT.addParam("pOut","i32"),ek=eT.getCodeBuilder(),eG=t.alloc(2*eD),eN=ek.i32_const(eG),eR=ek.i32_const(eG),ej=ek.i32_const(eG+eD),eT.addCode(ek.if(ek.i32_and(ek.i32_load8_u(ek.getLocal("pIn")),ek.i32_const(64)),[...ek.call(a+"_zeroAffine",ek.getLocal("pOut")),...ek.ret([])]),ek.call(a+"__reverseBytes",ek.getLocal("pIn"),ek.i32_const(eD),eR),ek.call(a+"__reverseBytes",ek.i32_add(ek.getLocal("pIn"),ek.i32_const(eD)),ek.i32_const(eD),ej),ek.call(a+"_toMontgomeryAffine",eN,ek.getLocal("pOut"))),(eU=t.addFunction(a+"_CtoLEM")).addParam("pIn","i32"),eU.addParam("pOut","i32"),eU.addLocal("firstByte","i32"),eU.addLocal("greatest","i32"),eZ=eU.getCodeBuilder(),e$=t.alloc(2*eD),eQ=eZ.i32_const(e$),eJ=eZ.i32_const(e$+eD),eU.addCode(eZ.setLocal("firstByte",eZ.i32_load8_u(eZ.getLocal("pIn"))),eZ.if(eZ.i32_and(eZ.getLocal("firstByte"),eZ.i32_const(64)),[...eZ.call(a+"_zeroAffine",eZ.getLocal("pOut")),...eZ.ret([])]),eZ.setLocal("greatest",eZ.i32_and(eZ.getLocal("firstByte"),eZ.i32_const(128))),eZ.call(e+"_copy",eZ.getLocal("pIn"),eJ),eZ.i32_store8(eJ,eZ.i32_and(eZ.getLocal("firstByte"),eZ.i32_const(63))),eZ.call(a+"__reverseBytes",eJ,eZ.i32_const(eD),eQ),eZ.call(e+"_toMontgomery",eQ,eZ.getLocal("pOut")),eZ.call(e+"_square",eZ.getLocal("pOut"),eJ),eZ.call(e+"_mul",eZ.getLocal("pOut"),eJ,eJ),eZ.call(e+"_add",eJ,eZ.i32_const(l),eJ),eZ.call(e+"_sqrt",eJ,eJ),eZ.call(e+"_neg",eJ,eQ),eZ.if(eZ.i32_eq(eZ.call(e+"_sign",eJ),eZ.i32_const(-1)),eZ.if(eZ.getLocal("greatest"),eZ.call(e+"_copy",eJ,eZ.i32_add(eZ.getL
1ocal("pOut"),eZ.i32_const(eD))),eZ.call(e+"_neg",eJ,eZ.i32_add(eZ.getLocal("pOut"),eZ.i32_const(eD)))),eZ.if(eZ.getLocal("greatest"),eZ.call(e+"_neg",eJ,eZ.i32_add(eZ.getLocal("pOut"),eZ.i32_const(eD))),eZ.call(e+"_copy",eJ,eZ.i32_add(eZ.getLocal("pOut"),eZ.i32_const(eD)))))),D(t,a+"_batchLEMtoU",a+"_LEMtoU",2*eD,2*eD),D(t,a+"_batchLEMtoC",a+"_LEMtoC",2*eD,eD),D(t,a+"_batchUtoLEM",a+"_UtoLEM",2*eD,2*eD),D(t,a+"_batchCtoLEM",a+"_CtoLEM",eD,2*eD,!0),D(t,a+"_batchToJacobian",a+"_toJacobian",2*eD,3*eD,!0),tx(t,a,a+"_multiexp",a+"_add",3*eD),tx(t,a,a+"_multiexpAffine",a+"_addMixed",2*eD),tb(t,a+"_timesScalar",3*eD,a+"_add",a+"_double",a+"_sub",a+"_copy",a+"_zero"),tb(t,a+"_timesScalarAffine",2*eD,a+"_addMixed",a+"_double",a+"_subMixed",a+"_copyAffine",a+"_zero"),t.exportFunction(a+"_isZero"),t.exportFunction(a+"_isZeroAffine"),t.exportFunction(a+"_eq"),t.exportFunction(a+"_eqMixed"),t.exportFunction(a+"_eqAffine"),t.exportFunction(a+"_copy"),t.exportFunction(a+"_copyAffine"),t.exportFunction(a+"_zero"),t.exportFunction(a+"_zeroAffine"),t.exportFunction(a+"_double"),t.exportFunction(a+"_doubleAffine"),t.exportFunction(a+"_add"),t.exp
1ortFunction(a+"_addMixed"),t.exportFunction(a+"_addAffine"),t.exportFunction(a+"_neg"),t.exportFunction(a+"_negAffine"),t.exportFunction(a+"_sub"),t.exportFunction(a+"_subMixed"),t.exportFunction(a+"_subAffine"),t.exportFunction(a+"_fromMontgomery"),t.exportFunction(a+"_fromMontgomeryAffine"),t.exportFunction(a+"_toMontgomery"),t.exportFunction(a+"_toMontgomeryAffine"),t.exportFunction(a+"_timesScalar"),t.exportFunction(a+"_timesScalarAffine"),t.exportFunction(a+"_normalize"),t.exportFunction(a+"_LEMtoU"),t.exportFunction(a+"_LEMtoC"),t.exportFunction(a+"_UtoLEM"),t.exportFunction(a+"_CtoLEM"),t.exportFunction(a+"_batchLEMtoU"),t.exportFunction(a+"_batchLEMtoC"),t.exportFunction(a+"_batchUtoLEM"),t.exportFunction(a+"_batchCtoLEM"),t.exportFunction(a+"_toAffine"),t.exportFunction(a+"_toJacobian"),t.exportFunction(a+"_batchToAffine"),t.exportFunction(a+"_batchToJacobian"),t.exportFunction(a+"_inCurve"),t.exportFunction(a+"_inCurveAffine"),a};let{isOdd:tF,modInv:tC,modPow:tB}=V;var tP=function(t,a,e,l,o){let i,c,n,d,r,s,_,f,u,g,L,p,h,m,b,x,y,F,C,B,P,A,q,v,I,O,E,w,M,S,z,T,k,G,N,R,j,U,Z,$,J,W,D,V,K,X=8*t.modules[l].n64,Y=8*t.modules[e].n64,H=t.modules[l].q,tt=H-1n,ta=0;for(;!tF(tt);)ta++,tt>>=1n;let te=2n;for(;1n===tB(te,H>>1n,H);)te+=1n;let tl=Array(ta+1);tl[ta]=tB(te,tt,H);let to=ta-1;for(;to>=0;)tl[to]=tB(tl[to+1],2n,H),to--;let ti=[],tc=(1n<<BigInt(8*X))%H;for(let t=0;t<tl.length;t++){let a=tl[t]*tc%H;ti.push(...Q.bigInt2BytesLE(a,X))}let tn=t.alloc(ti),td=Array(ta+1);td[0]=1n;for(let t=1;t<=ta;t++)td[t]=2n*td[t-1];let tr=[];for(let t=0;t<=ta;t++){let a=tC(td[t],H)*tc%H;tr.push(...Q.bigInt2BytesLE(a,X))}let ts=t.alloc(tr),t_=tB(te,2n,H),tf=[],tu=[];for(let t=0;t<=ta;t++){let a=tB(t_,2n**BigInt(t),H),e=tC(H+1n-a,H);tf.push(...Q.bigInt2BytesLE(a*tc%H,X)),tu.push(...Q.bigInt2BytesLE(e*tc%H,X))}let tg=t.alloc(tf),tL=t.alloc(tu),tp=Array(256);for(let t=0;t<256;t++)tp[t]=function(t){let a=0;for(let e=0;e<8;e++)t&1<<e&&(a|=128>>e);return a}(t);let th=t.alloc(tp);(i=t.addFunction(a+"__rev")).addParam("x","i32"),i.addParam("bits","i32"),i.setReturnType("i32"),c=i.getCodeBuilder(),i.addCode(c.i32_rotl(c.i32_add(c.i32_add(c.i32_shl(c.i32_load8_u(c.i32_and(c.getLocal("x"),c.i32_const(255)),th,0),c.i32_const(24)),c.i32_shl(c.i32_load8_u(c.i32_and(c.i32_shr_u(c.getLocal("x"),c.i32_const(8)),c.i32_const(255)),th,0),c.i32_const(16))),c.i32_add(c.i32_shl(c.i32_load8_u(c.i32_and(c.i32_shr_u(c.getLocal("x"),c.i32_const(16)),c.i32_const(255)),th,0),c.i32_const(8)),c.i32_load8_u(c.i32_and(c.i32_shr_u(c.getLocal("x"),c.i32_const(24)),c.i32_const(255)),th,0))),c.getLocal("bits"))),(n=t.addFunction(a+"__reversePermutation")).addParam("px","i32"),n.addParam("bits","i32"),n.addLocal("n","i32"),n.addLocal("i","i32"),n.addLocal("ri","i32"),n.addLocal("idx1","i32"),n.addLocal("idx2","i32"),r=(d=n.getCodeBuilder()).i32_const(t.alloc(Y)),n.addCode(d.setLocal("n",d.i32_shl(d.i32_const(1),d.getLocal("bits"))),d.setLocal("i",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_eq(d.getLocal("i"),d.getLocal("n"))),d.setLocal("idx1",d.i32_add(d.getLocal("px"),d.i32_mul(d.getLocal("i"),d.i32_const(Y)))),d.setLocal("ri",d.call(a+"__rev",d.getLocal("i"),d.getLocal("bits"))),d.setLocal("idx2",d.i32_add(d.getLocal("px"),d.i32_mul(d.getLocal("ri"),d.i32_const(Y)))),d.if(d.i32_lt_u(d.getLocal("i"),d.getLocal("ri")),[...d.call(e+"_copy",d.getLocal("idx1"),r),...d.call(e+"_copy",d.getLocal("idx2"),d.getLocal("idx1")),...d.call(e+"_copy",r,d.getLocal("idx2"))]),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0)))),(s=t.addFunction(a+"__fftFinal")).addParam("px","i32"),s.addParam("bits","i32"),s.addParam("reverse","i32"),s.addParam("mulFactor","i32"),s.addLocal("n","i32"),s.addLocal("ndiv2","i32"),s.addLocal("pInv2","i32"),s.addLocal("i","i32"),s.addLocal("mask","i32"),s.addLocal("idx1","i32"),s.addLocal("idx2","i32"),f=(_=s.getCodeBuilder()).i32_const(t.alloc(Y)),s.addCode(_.if(_.i32_and(_.i32_eqz(_.getLocal("reverse")),_.call(l+"_isOne",_.getLocal("mulFactor"))),_.ret([])),_.setLocal("n",_.i32_shl(_.i32_const(1),_.getLocal("bits"))),_.setLocal("mask",_.i32_sub(_.getLocal("n"),_.i32_const(1))),_.setLocal("i",_.i32_const(1)),_.setLocal("ndiv2",_.i32_shr_u(_.getLocal("n"),_.i32_const(1))),_.block(_.loop(_.br_if(1,_.i32_ge_u(_.getLocal("i"),_.getLocal("ndiv2"))),_.setLocal("idx1",_.i32_add(_.getLocal("px"),_.i32_mul(_.getLocal("i"),_.i32_const(Y)))),_.setLocal("idx2",_.i32_add(_.getLocal("px"),_.i32_mul(_.i32_sub(_.getLocal("n"),_.getLocal("i")),_.i32_const(Y)))),_.if(_.getLocal("reverse"),_.if(_.call(l+"_isOne",_.getLocal("mulFactor")),[..._.call(e+"_copy",_.getLocal("idx1"),f),..._.call(e+"_copy",_.getLocal("idx2"),_.getLocal("idx1")),..._.call(e+"_copy",f,_.getLocal("idx2"))],[..._.call(e+"_copy",_.getLocal("idx1"),f),..._.call(o,_.getLocal("idx2"),_.getLocal("mulFactor"),_.getLocal("idx1")),..._.call(o,f,_.getLocal("mulFactor"),_.getLocal("idx2"))]),_.if(_.call(l+"_isOne",_.getLocal("mulFactor")),[],[..._.call(o,_.getLocal("idx1"),_.getLocal("mulFactor"),_.getLocal("idx1")),..._.call(o,_.getLocal("idx2"),_.getLocal("mulFactor"),_.getLocal("idx2"))])),_.setLocal("i",_.i32_add(_.getLocal("i"),_.i32_const(1))),_.br(0))),_.if(_.call(l+"_isOne",_.getLocal("mulFactor")),[],[..._.call(o,_.getLocal("px"),_.getLocal("mulFactor"),_.getLocal("px")),..._.setLocal("idx2",_.i32_add(_.getLocal("px"),_.i32_mul(_.getLocal("ndiv2"),_.i32_const(Y)))),..._.call(o,_.getLocal("idx2"),_.getLocal("mulFactor"),_.getLocal("idx2"))])),(u=t.addFunction(a+"_rawfft")).addParam("px","i32"),u.addParam("bits","i32"),u.addParam("reverse","i32"),u.addParam("mulFactor","i32"),u.addLocal("s","i32"),u.addLocal("k","i32"),u.addLocal("j","i32"),u.addLocal("m","i32"),u.addLocal("mdiv2","i32"),u.addLocal("n","i32"),u.addLocal("pwm","i32"),u.addLocal("idx1","i32"),u.addLocal("idx2","i32"),L=(g=u.getCodeBuilder()).i32_const(t.alloc(X)),p=g.i32_const(t.alloc(Y)),h=g.i32_const(t.alloc(Y)),u.addCode(g.call(a+"__reversePermutation",g.getLocal("px"),g.getLocal("bits")),g.setLocal("n",g.i32_shl(g.i32_const(1),g.getLocal("bits"))),g.setLocal("s",g.i32_const(1)),g.block(g.loop(g.br_if(1,g.i32_gt_u(g.getLocal("s"),g.getLocal("bits"))),g.setLocal("m",g.i32_shl(g.i32_const(1),g.getLocal("s"))),g.setLocal("pwm",g.i32_add(g.i32_const(tn),g.i32_mul(g.getLocal("s"),g.i32_const(X)))),g.setLocal("k",g.i32_const(0)),g.block(g.loop(g.br_if(1,g.i32_ge_u(g.getLocal("k"),g.getLocal("n"))),g.call(l+"_one",L),g.setLocal("mdiv2",g.i32_shr_u(g.getLocal("m"),g.i32_const(1))),g.setLocal("j",g.i32_const(0)),g.block(g.loop(g.br_if(1,g.i32_ge_u(g.getLocal("j"),g.getLocal("mdiv2"))),g.setLocal("idx1",g.i32_add(g.getLocal("px"),g.i32_mul(g.i32_add(g.getLocal("k"),g.getLocal("j")),g.i32_const(Y)))),g.setLocal("idx2",g.i32_add(g.getLocal("idx1"),g.i32_mul(g.getLocal("mdiv2"),g.i32_const(Y)))),g.call(o,g.getLocal("idx2"),L,p),g.call(e+"_copy",g.getLocal("idx1"),h),g.call(e+"_add",h,p,g.getLocal("idx1")),g.call(e+"_sub",h,p,g.getLocal("idx2")),g.call(l+"_mul",L,g.getLocal("pwm"),L),g.setLocal("j",g.i32_add(g.getLocal("j"),g.i32_const(1))),g.br(0))
1),g.setLocal("k",g.i32_add(g.getLocal("k"),g.getLocal("m"))),g.br(0))),g.setLocal("s",g.i32_add(g.getLocal("s"),g.i32_const(1))),g.br(0))),g.call(a+"__fftFinal",g.getLocal("px"),g.getLocal("bits"),g.getLocal("reverse"),g.getLocal("mulFactor"))),(m=t.addFunction(a+"__log2")).addParam("n","i32"),m.setReturnType("i32"),m.addLocal("bits","i32"),m.addLocal("aux","i32"),b=m.getCodeBuilder(),m.addCode(b.setLocal("aux",b.i32_shr_u(b.getLocal("n"),b.i32_const(1)))),m.addCode(b.setLocal("bits",b.i32_const(0))),m.addCode(b.block(b.loop(b.br_if(1,b.i32_eqz(b.getLocal("aux"))),b.setLocal("aux",b.i32_shr_u(b.getLocal("aux"),b.i32_const(1))),b.setLocal("bits",b.i32_add(b.getLocal("bits"),b.i32_const(1))),b.br(0)))),m.addCode(b.if(b.i32_ne(b.getLocal("n"),b.i32_shl(b.i32_const(1),b.getLocal("bits"))),b.unreachable())),m.addCode(b.if(b.i32_gt_u(b.getLocal("bits"),b.i32_const(ta)),b.unreachable())),m.addCode(b.getLocal("bits")),(x=t.addFunction(a+"_fft")).addParam("px","i32"),x.addParam("n","i32"),x.addLocal("bits","i32"),F=(y=x.getCodeBuilder()).i32_const(t.alloc(X)),x.addCode(y.setLocal("bits",y.call(a+"__log2",y.getLocal("n"))),y.call(l+"_one",F),y.call(a+"_rawfft",y.getLocal("px"),y.getLocal("bits"),y.i32_const(0),F)),(C=t.addFunction(a+"_ifft")).addParam("px","i32"),C.addParam("n","i32"),C.addLocal("bits","i32"),C.addLocal("pInv2","i32"),B=C.getCodeBuilder(),C.addCode(B.setLocal("bits",B.call(a+"__log2",B.getLocal("n"))),B.setLocal("pInv2",B.i32_add(B.i32_const(ts),B.i32_mul(B.getLocal("bits"),B.i32_const(X)))),B.call(a+"_rawfft",B.getLocal("px"),B.getLocal("bits"),B.i32_const(1),B.getLocal("pInv2"))),(P=t.addFunction(a+"_fftJoin")).addParam("pBuff1","i32"),P.addParam("pBuff2","i32"),P.addParam("n","i32"),P.addParam("first","i32"),P.addParam("inc","i32"),P.addLocal("idx1","i32"),P.addLocal("idx2","i32"),P.addLocal("i","i32"),q=(A=P.getCodeBuilder()).i32_const(t.alloc(X)),v=A.i32_const(t.alloc(Y)),I=A.i32_const(t.alloc(Y)),P.addCode(A.call(l+"_copy",A.getLocal("first"),q),A.setLocal("i",A.i32_const(0)),A.block(A.loop(A.br_if(1,A.i32_eq(A.getLocal("i"),A.getLocal("n"))),A.setLocal("idx1",A.i32_add(A.getLocal("pBuff1"),A.i32_mul(A.getLocal("i"),A.i32_const(Y)))),A.setLocal("idx2",A.i32_add(A.getLocal("pBuff2"),A.i32_mul(A.getLocal("i"),A.i32_const(Y)))),A.call(o,A.getLocal("idx2"),q,v),A.call(e+"_copy",A.getLocal("idx1"),I),A.call(e+"_add",I,v,A.getLocal("idx1")),A.call(e+"_sub",I,v,A.getLocal("idx2")),A.call(l+"_mul",q,A.getLocal("inc"),q),A.setLocal("i",A.i32_add(A.getLocal("i"),A.i32_const(1))),A.br(0)))),(O=t.addFunction(a+"_fftJoinExt")).addParam("pBuff1","i32"),O.addParam("pBuff2","i32"),O.addParam("n","i32"),O.addParam("first","i32"),O.addParam("inc","i32"),O.addParam("totalBits","i32"),O.addLocal("idx1","i32"),O.addLocal("idx2","i32"),O.addLocal("i","i32"),O.addLocal("pShiftToM","i32"),w=(E=O.getCodeBuilder()).i32_const(t.alloc(X)),M=E.i32_const(t.alloc(Y)),O.addCode(E.setLocal("pShiftToM",E.i32_add(E.i32_const(tg),E.i32_mul(E.getLocal("totalBits"),E.i32_const(X)))),E.call(l+"_copy",E.getLocal("first"),w),E.setLocal("i",E.i32_const(0)),E.block(E.loop(E.br_if(1,E.i32_eq(E.getLocal("i"),E.getLocal("n"))),E.setLocal("idx1",E.i32_add(E.getLocal("pBuff1"),E.i32_mul(E.getLocal("i"),E.i32_const(Y)))),E.setLocal("idx2",E.i32_add(E.getLocal("pBuff2"),E.i32_mul(E.getLocal("i"),E.i32_const(Y)))),E.call(e+"_add",E.getLocal("idx1"),E.getLocal("idx2"),M),E.call(o,E.getLocal("idx2"),E.getLocal("pShiftToM"),E.getLocal("idx2")),E.call(e+"_add",E.getLocal("idx1"),E.getLocal("idx2"),E.getLocal("idx2")),E.call(o,E.getLocal("idx2"),w,E.getLocal("idx2")),E.call(e+"_copy",M,E.getLocal("idx1")),E.call(l+"_mul",w,E.getLocal("inc"),w),E.setLocal("i",E.i32_add(E.getLocal("i"),E.i32_const(1))),E.br(0)))),(S=t.addFunction(a+"_fftJoinExtInv")).addParam("pBuff1","i32"),S.addParam("pBuff2","i32"),S.addParam("n","i32"),S.addParam("first","i32"),S.addParam("inc","i32"),S.addParam("totalBits","i32"),S.addLocal("idx1","i32"),S.addLocal("idx2","i32"),S.addLocal("i","i32"),S.addLocal("pShiftToM","i32"),S.addLocal("pSConst","i32"),T=(z=S.getCodeBuilder()).i32_const(t.alloc(X)),k=z.i32_const(t.alloc(Y)),S.addCode(z.setLocal("pShiftToM",z.i32_add(z.i32_const(tg),z.i32_mul(z.getLocal("totalBits"),z.i32_const(X)))),z.setLocal("pSConst",z.i32_add(z.i32_const(tL),z.i32_mul(z.getLocal("totalBits"),z.i32_const(X)))),z.call(l+"_copy",z.getLocal("first"),T),z.setLocal("i",z.i32_const(0)),z.block(z.loop(z.br_if(1,z.i32_eq(z.getLocal("i"),z.getLocal("n"))),z.setLocal("idx1",z.i32_add(z.getLocal("pBuff1"),z.i32_mul(z.getLocal("i"),z.i32_const(Y)))),z.setLocal("idx2",z.i32_add(z.getLocal("pBuff2"),z.i32_mul(z.getLocal("i"),z.i32_const(Y)))),z.call(o,z.getLocal("idx2"),T,k),z.call(e+"_sub",z.getLocal("idx1"),k,z.getLocal("idx2")),z.call(o,z.getLocal("idx2"),z.getLocal("pSConst"),z.getLocal("idx2")),z.call(o,z.getLocal("idx1"),z.getLocal("pShiftToM"),z.getLocal("idx1")),z.call(e+"_sub",k,z.getLocal("idx1"),z.getLocal("idx1")),z.call(o,z.getLocal("idx1"),z.getLocal("pSConst"),z.getLocal("idx1")),z.call(l+"_mul",T,z.getLocal("inc"),T),z.setLocal("i",z.i32_add(z.getLocal("i"),z.i32_const(1))),z.br(0))
1)),(G=t.addFunction(a+"_fftMix")).addParam("pBuff","i32"),G.addParam("n","i32"),G.addParam("exp","i32"),G.addLocal("nGroups","i32"),G.addLocal("nPerGroup","i32"),G.addLocal("nPerGroupDiv2","i32"),G.addLocal("pairOffset","i32"),G.addLocal("idx1","i32"),G.addLocal("idx2","i32"),G.addLocal("i","i32"),G.addLocal("j","i32"),G.addLocal("pwm","i32"),R=(N=G.getCodeBuilder()).i32_const(t.alloc(X)),j=N.i32_const(t.alloc(Y)),U=N.i32_const(t.alloc(Y)),G.addCode(N.setLocal("nPerGroup",N.i32_shl(N.i32_const(1),N.getLocal("exp"))),N.setLocal("nPerGroupDiv2",N.i32_shr_u(N.getLocal("nPerGroup"),N.i32_const(1))),N.setLocal("nGroups",N.i32_shr_u(N.getLocal("n"),N.getLocal("exp"))),N.setLocal("pairOffset",N.i32_mul(N.getLocal("nPerGroupDiv2"),N.i32_const(Y))),N.setLocal("pwm",N.i32_add(N.i32_const(tn),N.i32_mul(N.getLocal("exp"),N.i32_const(X)))),N.setLocal("i",N.i32_const(0)),N.block(N.loop(N.br_if(1,N.i32_eq(N.getLocal("i"),N.getLocal("nGroups"))),N.call(l+"_one",R),N.setLocal("j",N.i32_const(0)),N.block(N.loop(N.br_if(1,N.i32_eq(N.getLocal("j"),N.getLocal("nPerGroupDiv2"))),N.setLocal("idx1",N.i32_add(N.getLocal("pBuff"),N.i32_mul(N.i32_add(N.i32_mul(N.getLocal("i"),N.getLocal("nPerGroup")),N.getLocal("j")),N.i32_const(Y)))),N.setLocal("idx2",N.i32_add(N.getLocal("idx1"),N.getLocal("pairOffset"))),N.call(o,N.getLocal("idx2"),R,j),N.call(e+"_copy",N.getLocal("idx1"),U),N.call(e+"_add",U,j,N.getLocal("idx1")),N.call(e+"_sub",U,j,N.getLocal("idx2")),N.call(l+"_mul",R,N.getLocal("pwm"),R),N.setLocal("j",N.i32_add(N.getLocal("j"),N.i32_const(1))),N.br(0))),N.setLocal("i",N.i32_add(N.getLocal("i"),N.i32_const(1))),N.br(0)))),(Z=t.addFunction(a+"_fftFinal")).addParam("pBuff","i32"),Z.addParam("n","i32"),Z.addParam("factor","i32"),Z.addLocal("idx1","i32"),Z.addLocal("idx2","i32"),Z.addLocal("i","i32"),Z.addLocal("ndiv2","i32"),J=($=Z.getCodeBuilder()).i32_const(t.alloc(Y)),Z.addCode($.setLocal("ndiv2",$.i32_shr_u($.getLocal("n"),$.i32_const(1))),$.if($.i32_and($.getLocal("n"),$.i32_const(1)),$.call(o,$.i32_add($.getLocal("pBuff"),$.i32_mul($.getLocal("ndiv2"),$.i32_const(Y))),$.getLocal("factor"),$.i32_add($.getLocal("pBuff"),$.i32_mul($.getLocal("ndiv2"),$.i32_const(Y))))),$.setLocal("i",$.i32_const(0)),$.block($.loop($.br_if(1,$.i32_ge_u($.getLocal("i"),$.getLocal("ndiv2"))),$.setLocal("idx1",$.i32_add($.getLocal("pBuff"),$.i32_mul($.getLocal("i"),$.i32_const(Y)))),$.setLocal("idx2",$.i32_add($.getLocal("pBuff"),$.i32_mul($.i32_sub($.i32_sub($.getLocal("n"),$.i32_const(1)),$.getLocal("i")),$.i32_const(Y)))),$.call(o,$.getLocal("idx2"),$.getLocal("factor"),J),$.call(o,$.getLocal("idx1"),$.getLocal("factor"),$.getLocal("idx2")),$.call(e+"_copy",J,$.getLocal("idx1")),$.setLocal("i",$.i32_add($.getLocal("i"),$.i32_const(1))),$.br(0)))),(W=t.addFunction(a+"_prepareLagrangeEvaluation")).addParam("pBuff1","i32"),W.addParam("pBuff2","i32"),W.addParam("n","i32"),W.addParam("first","i32"),W.addParam("inc","i32"),W.addParam("totalBits","i32"),W.addLocal("idx1","i32"),W.addLocal("idx2","i32"),W.addLocal("i","i32"),W.addLocal("pShiftToM","i32"),W.addLocal("pSConst","i32"),V=(D=W.getCodeBuilder()).i32_const(t.alloc(X)),K=D.i32_const(t.alloc(Y)),W.addCode(D.setLocal("pShiftToM",D.i32_add(D.i32_const(tg),D.i32_mul(D.getLocal("totalBits"),D.i32_const(X)))),D.setLocal("pSConst",D.i32_add(D.i32_const(tL),D.i32_mul(D.getLocal("totalBits"),D.i32_const(X)))),D.call(l+"_copy",D.getLocal("first"),V),D.setLocal("i",D.i32_const(0)),D.block(D.loop(D.br_if(1,D.i32_eq(D.getLocal("i"),D.getLocal("n"))),D.setLocal("idx1",D.i32_add(D.getLocal("pBuff1"),D.i32_mul(D.getLocal("i"),D.i32_const(Y)))),D.setLocal("idx2",D.i32_add(D.getLocal("pBuff2"),D.i32_mul(D.getLocal("i"),D.i32_const(Y)))),D.call(o,D.getLocal("idx1"),D.getLocal("pShiftToM"),K),D.call(e+"_sub",D.getLocal("idx2"),K,K),D.call(e+"_sub",D.getLocal("idx1"),D.getLocal("idx2"),D.getLocal("idx2")),D.call(o,K,D.getLocal("pSConst"),D.getLocal("idx1")),D.call(o,D.getLocal("idx2"),V,D.getLocal("idx2")),D.call(l+"_mul",V,D.getLocal("inc"),V),D.setLocal("i",D.i32_add(D.getLocal("i"),D.i32_const(1))),D.br(0)))),t.exportFunction(a+"_fft"),t.exportFunction(a+"_ifft"),t.exportFunction(a+"_rawfft"),t.exportFunction(a+"_fftJoin"),t.exp
1ortFunction(a+"_fftJoinExt"),t.exportFunction(a+"_fftJoinExtInv"),t.exportFunction(a+"_fftMix"),t.exportFunction(a+"_fftFinal"),t.exportFunction(a+"_prepareLagrangeEvaluation")},tA=function(t,a,e){let l,o,i,c,n,d=8*t.modules[e].n64;return(l=t.addFunction(a+"_zero")).addParam("px","i32"),l.addParam("n","i32"),l.addLocal("lastp","i32"),l.addLocal("p","i32"),o=l.getCodeBuilder(),l.addCode(o.setLocal("p",o.getLocal("px")),o.setLocal("lastp",o.i32_add(o.getLocal("px"),o.i32_mul(o.getLocal("n"),o.i32_const(d)))),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("p"),o.getLocal("lastp"))),o.call(e+"_zero",o.getLocal("p")),o.setLocal("p",o.i32_add(o.getLocal("p"),o.i32_const(d))),o.br(0)))),(i=t.addFunction(a+"_constructLC")).addParam("ppolynomials","i32"),i.addParam("psignals","i32"),i.addParam("nSignals","i32"),i.addParam("pres","i32"),i.addLocal("i","i32"),i.addLocal("j","i32"),i.addLocal("pp","i32"),i.addLocal("ps","i32"),i.addLocal("pd","i32"),i.addLocal("ncoefs","i32"),n=(c=i.getCodeBuilder()).i32_const(t.alloc(d)),i.addCode(c.setLocal("i",c.i32_const(0)),c.setLocal("pp",c.getLocal("ppolynomials")),c.setLocal("ps",c.getLocal("psignals")),c.block(c.loop(c.br_if(1,c.i32_eq(c.getLocal("i"),c.getLocal("nSignals"))),c.setLocal("ncoefs",c.i32_load(c.getLocal("pp"))),c.setLocal("pp",c.i32_add(c.getLocal("pp"),c.i32_const(4))),c.setLocal("j",c.i32_const(0)),c.block(c.loop(c.br_if(1,c.i32_eq(c.getLocal("j"),c.getLocal("ncoefs"))),c.setLocal("pd",c.i32_add(c.getLocal("pres"),c.i32_mul(c.i32_load(c.getLocal("pp")),c.i32_const(d)))),c.setLocal("pp",c.i32_add(c.getLocal("pp"),c.i32_const(4))),c.call(e+"_mul",c.getLocal("ps"),c.getLocal("pp"),n),c.call(e+"_add",n,c.getLocal("pd"),c.getLocal("pd")),c.setLocal("pp",c.i32_add(c.getLocal("pp"),c.i32_const(d))),c.setLocal("j",c.i32_add(c.getLocal("j"),c.i32_const(1))),c.br(0))),c.setLocal("ps",c.i32_add(c.getLocal("ps"),c.i32_const(d))),c.setLocal("i",c.i32_add(c.getLocal("i"),c.i32_const(1))),c.br(0)))),t.exportFunction(a+"_zero"),t.exportFunction(a+"_constructLC"),a},tq=function(t,a,e){let l,o,i,c,n,d,r,s,_=8*t.modules[e].n64;return(l=t.addFunction(a+"_buildABC")).addParam("pCoefs","i32"),l.addParam("nCoefs","i32"),l.addParam("pWitness","i32"),l.addParam("pA","i32"),l.addParam("pB","i32"),l.addParam("pC","i32"),l.addParam("offsetOut","i32"),l.addParam("nOut","i32"),l.addParam("offsetWitness","i32"),l.addParam("nWitness","i32"),l.addLocal("it","i32"),l.addLocal("ita","i32"),l.addLocal("itb","i32"),l.addLocal("last","i32"),l.addLocal("m","i32"),l.addLocal("c","i32"),l.addLocal("s","i32"),l.addLocal("pOut","i32"),i=(o=l.getCodeBuilder()).i32_const(t.alloc(_)),l.addCode(o.setLocal("ita",o.getLocal("pA")),o.setLocal("itb",o.getLocal("pB")),o.setLocal("last",o.i32_add(o.getLocal("pA"),o.i32_mul(o.getLocal("nOut"),o.i32_const(_)))),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("ita"),o.getLocal("last"))),o.call(e+"_zero",o.getLocal("ita")),o.call(e+"_zero",o.getLocal("itb")),o.setLocal("ita",o.i32_add(o.getLocal("ita"),o.i32_const(_))),o.setLocal("itb",o.i32_add(o.getLocal("itb"),o.i32_const(_))),o.br(0))),o.setLocal("it",o.getLocal("pCoefs")),o.setLocal("last",o.i32_add(o.getLocal("pCoefs"),o.i32_mul(o.getLocal("nCoefs"),o.i32_const(_+12)))),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("it"),o.getLocal("last"))),o.setLocal("s",o.i32_load(o.getLocal("it"),8)),o.if(o.i32_or(o.i32_lt_u(o.getLocal("s"),o.getLocal("offsetWitness")),o.i32_ge_u(o.getLocal("s"),o.i32_add(o.getLocal("offsetWitness"),o.getLocal("nWitness")))),[...o.setLocal("it",o.i32_add(o.getLocal("it"),o.i32_const(_+12))),...o.br(1)]),o.setLocal("m",o.i32_load(o.getLocal("it"))),o.if(o.i32_eq(o.getLocal("m"),o.i32_const(0)),o.setLocal("pOut",o.getLocal("pA")),o.if(o.i32_eq(o.getLocal("m"),o.i32_const(1)),o.setLocal("pOut",o.getLocal("pB")),[...o.setLocal("it",o.i32_add(o.getLocal("it"),o.i32_const(_+12))),...o.br(1)])),o.setLocal("c",o.i32_load(o.getLocal("it"),4)),o.if(o.i32_or(o.i32_lt_u(o.getLocal("c"),o.getLocal("offsetOut")),o.i32_ge_u(o.getLocal("c"),o.i32_add(o.getLocal("offsetOut"),o.getL
1ocal("nOut")))),[...o.setLocal("it",o.i32_add(o.getLocal("it"),o.i32_const(_+12))),...o.br(1)]),o.setLocal("pOut",o.i32_add(o.getLocal("pOut"),o.i32_mul(o.i32_sub(o.getLocal("c"),o.getLocal("offsetOut")),o.i32_const(_)))),o.call(e+"_mul",o.i32_add(o.getLocal("pWitness"),o.i32_mul(o.i32_sub(o.getLocal("s"),o.getLocal("offsetWitness")),o.i32_const(_))),o.i32_add(o.getLocal("it"),o.i32_const(12)),i),o.call(e+"_add",o.getLocal("pOut"),i,o.getLocal("pOut")),o.setLocal("it",o.i32_add(o.getLocal("it"),o.i32_const(_+12))),o.br(0))),o.setLocal("ita",o.getLocal("pA")),o.setLocal("itb",o.getLocal("pB")),o.setLocal("it",o.getLocal("pC")),o.setLocal("last",o.i32_add(o.getLocal("pA"),o.i32_mul(o.getLocal("nOut"),o.i32_const(_)))),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("ita"),o.getLocal("last"))),o.call(e+"_mul",o.getLocal("ita"),o.getLocal("itb"),o.getLocal("it")),o.setLocal("ita",o.i32_add(o.getLocal("ita"),o.i32_const(_))),o.setLocal("itb",o.i32_add(o.getLocal("itb"),o.i32_const(_))),o.setLocal("it",o.i32_add(o.getLocal("it"),o.i32_const(_))),o.br(0)))),(c=t.addFunction(a+"_joinABC")).addParam("pA","i32"),c.addParam("pB","i32"),c.addParam("pC","i32"),c.addParam("n","i32"),c.addParam("pP","i32"),c.addLocal("ita","i32"),c.addLocal("itb","i32"),c.addLocal("itc","i32"),c.addLocal("itp","i32"),c.addLocal("last","i32"),d=(n=c.getCodeBuilder()).i32_const(t.alloc(_)),c.addCode(n.setLocal("ita",n.getLocal("pA")),n.setLocal("itb",n.getLocal("pB")),n.setLocal("itc",n.getLocal("pC")),n.setLocal("itp",n.getLocal("pP")),n.setLocal("last",n.i32_add(n.getLocal("pA"),n.i32_mul(n.getL
1ocal("n"),n.i32_const(_)))),n.block(n.loop(n.br_if(1,n.i32_eq(n.getLocal("ita"),n.getLocal("last"))),n.call(e+"_mul",n.getLocal("ita"),n.getLocal("itb"),d),n.call(e+"_sub",d,n.getLocal("itc"),n.getLocal("itp")),n.setLocal("ita",n.i32_add(n.getLocal("ita"),n.i32_const(_))),n.setLocal("itb",n.i32_add(n.getLocal("itb"),n.i32_const(_))),n.setLocal("itc",n.i32_add(n.getLocal("itc"),n.i32_const(_))),n.setLocal("itp",n.i32_add(n.getLocal("itp"),n.i32_const(_))),n.br(0)))),(r=t.addFunction(a+"_batchAdd")).addParam("pa","i32"),r.addParam("pb","i32"),r.addParam("n","i32"),r.addParam("pr","i32"),r.addLocal("ita","i32"),r.addLocal("itb","i32"),r.addLocal("itr","i32"),r.addLocal("last","i32"),s=r.getCodeBuilder(),r.addCode(s.setLocal("ita",s.getLocal("pa")),s.setLocal("itb",s.getLocal("pb")),s.setLocal("itr",s.getLocal("pr")),s.setLocal("last",s.i32_add(s.getLocal("pa"),s.i32_mul(s.getLocal("n"),s.i32_const(_)))),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal("ita"),s.getLocal("last"))),s.call(e+"_add",s.getLocal("ita"),s.getLocal("itb"),s.getLocal("itr")),s.setLocal("ita",s.i32_add(s.getLocal("ita"),s.i32_const(_))),s.setLocal("itb",s.i32_add(s.getLocal("itb"),s.i32_const(_))),s.setLocal("itr",s.i32_add(s.getLocal("itr"),s.i32_const(_))),s.br(0)))),t.exportFunction(a+"_buildABC"),t.exportFunction(a+"_joinABC"),t.exportFunction(a+"_batchAdd"),a},tv=function(t,a,e,l,o,i,c,n){let d=t.addFunction(a);d.addParam("pIn","i32"),d.addParam("n","i32"),d.addParam("pFirst","i32"),d.addParam("pInc","i32"),d.addParam("pOut","i32"),d.addLocal("pOldFree","i32"),d.addLocal("i","i32"),d.addLocal("pFrom","i32"),d.addLocal("pTo","i32");let r=d.getCodeBuilder(),s=r.i32_const(t.alloc(c));d.addCode(r.setLocal("pFrom",r.getLocal("pIn")),r.setLocal("pTo",r.getLocal("pOut"))),d.addCode(r.call(l+"_copy",r.getLocal("pFirst"),s)),d.addCode(r.setLocal("i",r.i32_const(0)),r.block(r.loop(r.br_if(1,r.i32_eq(r.getLocal("i"),r.getLocal("n"))),r.call(n,r.getLocal("pFrom"),s,r.getLocal("pTo")),r.setLocal("pFrom",r.i32_add(r.getLocal("pFrom"),r.i32_const(o))),r.setLocal("pTo",r.i32_add(r.getLocal("pTo"),r.i32_const(i))),r.call(l+"_mul",s,r.getLocal("pInc"),s),r.setLocal("i",r.i32_add(r.getLocal("i"),r.i32_const(1))),r.br(0)))),t.exportFunction(a)};let{bitLength:tI,modInv:tO,isOdd:tE,isNegative:tw}=V,{bitLength:tM,isOdd:tS,isNegative:tz}=V;var tT=function(t,a){let e,l,o,i,c,n,d,r,s,_,f,u,g,L,p,h,m,b,x,y,F,C,B,P,A,q,v,I,O,E,w,M,S,z,T,k,G,N,R,j,U,Z,$,J,W,D,V,K,X,Y,H,tt,ta,te,tl,to,ti,tc,tn,td,tr,ts,t_,tf,tu,tL,tb,tx,tF,tC,tB,tM,tS,tz,tT,tk,tG,tN,tR,tj,tU,tZ,t$,tQ,tJ,tW,tD,tV,tK,tX,tY,tH,t2,t3,t0,t1,t4,t6,t8,t7,t5,t9,at,aa,ae,al,ao,ai,ac,an,ad,ar,as,a_,af,au,ag,aL,ap,ah,am,ab,ax,ay,aF,aC,aB,aP,aA,aq,av,aI,aO,aE,aw,aM,aS,az,aT,ak,aG,aN,aR,aj,aU,aZ,a$,aQ,aJ,aW,aD,aV,aK,aX,aY,aH,a2,a3,a0,a1,a4,a6,a8,a7,a5,a9,et,ea,ee,el,eo,ei,ec,en,ed,er,es,e_,ef,eu,eg,eL,ep,eh,em,eb,ex,ey,eF,eC,eB,eP,eA=a||"bn128";if(t.modules[eA])return eA;let eq=Math.floor((tI(0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n-1n)-1)/64)+1,ev=8*eq,eI=2*ev,eO=12*ev,eE=t.alloc(Q.bigInt2BytesLE(0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001n,ev)),ew=tg(t,0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n,"f1m");tp(t,0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001n,"fr","frm");let eM=t.alloc(Q.bigInt2BytesLE(eN(3n),ev)),eS=ty(t,"g1m","f1m",eM);tP(t,"frm","frm","frm","frm_mul"),tA(t,"pol","frm"),tq(t,"qap","frm");let ez=th(t,"f1m_neg","f2m","f1m"),eT=t.alloc([...Q.bigInt2BytesLE(eN(0x2b149d40ceb8aaae81be18991be06ac3b5b4c5e559dbefa33267e6dc24a138e5n),ev),...Q.bigInt2BytesLE(eN(0x9713b03af0fed4cd2cafadeed8fdf4a74fa084e52d1852e4a2bd0685c315d2n),ev)]),ek=ty(t,"g2m","f2m",eT);function eG(a,e){let l=t.addFunction(a);l.addParam("pG","i32"),l.addParam("pFr","i32"),l.addParam("pr","i32");let o=l.getCodeBuilder(),i=o.i32_const(t.alloc(ev));l.addCode(o.call("frm_fromMontgomery",o.getLocal("pFr"),i),o.call(e,o.getLocal("pG"),i,o.i32_const(ev),o.getLocal("pr"))),t.exportFunction(a)}function eN(t){return BigInt(t)*(1n<<BigInt(8*ev))%0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n}eG("g1m_timesFr","g1m_timesScalar"),tP(t,"g1m","g1m","frm","g1m_timesFr"),eG("g2m_timesFr","g2m_timesScalar"),tP(t,"g2m","g2m","frm","g2m_timesFr"),eG("g1m_timesFrAffine","g1m_timesScalarAffine"),eG("g2m_timesFrAffine","g2m_timesScalarAffine"),tv(t,"frm_batchApplyKey","fmr","frm",ev,ev,ev,"frm_mul"),tv(t,"g1m_batchApplyKey","g1m","frm",3*ev,3*ev,ev,"g1m_timesFr"),tv(t,"g1m_batchApplyKeyMixed","g1m","frm",2*ev,3*ev,ev,"g1m_timesFrAffine"),tv(t,"g2m_batchApplyKey","g2m","frm",2*ev*3,3*ev*2,ev,"g2m_timesFr"),tv(t,"g2m_batchApplyKeyMixed","g2m","frm",2*ev*2,3*ev*2,ev,"g2m_timesFrAffine");let eR=t.alloc([...Q.bigInt2BytesLE(eN(1n),ev),...Q.bigInt2BytesLE(eN(2n),ev),...Q.bigInt2BytesLE(eN(1n),ev)]),ej=t.alloc([...Q.bigInt2BytesLE(eN(0n),ev),...Q.bigInt2BytesLE(eN(1n),ev),...Q.bigInt2BytesLE(eN(0n),ev)]),eU=[[0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6edn,0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2n],[0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daan,0x90689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975bn],[1n,0n]],eZ=t.alloc([...Q.bigInt2BytesLE(eN(eU[0][0]),ev),...Q.bigInt2BytesLE(eN(eU[0][1]),ev),...Q.bigInt2BytesLE(eN(eU[1][0]),ev),...Q.bigInt2BytesLE(eN(eU[1][1]),ev),...Q.bigInt2BytesLE(eN(eU[2][0]),ev),...Q.bigInt2BytesLE(eN(eU[2][1]),ev)]
1),e$=[[0n,0n],[1n,0n],[0n,0n]],eQ=t.alloc([...Q.bigInt2BytesLE(eN(e$[0][0]),ev),...Q.bigInt2BytesLE(eN(e$[0][1]),ev),...Q.bigInt2BytesLE(eN(e$[1][0]),ev),...Q.bigInt2BytesLE(eN(e$[1][1]),ev),...Q.bigInt2BytesLE(eN(e$[2][0]),ev),...Q.bigInt2BytesLE(eN(e$[2][1]),ev)]),eJ=t.alloc([...Q.bigInt2BytesLE(eN(1),ev),...Q.bigInt2BytesLE(eN(0),ev),...Q.bigInt2BytesLE(eN(0),ev),...Q.bigInt2BytesLE(eN(0),ev),...Q.bigInt2BytesLE(eN(0),ev),...Q.bigInt2BytesLE(eN(0),ev),...Q.bigInt2BytesLE(eN(0),ev),...Q.bigInt2BytesLE(eN(0),ev),...Q.bigInt2BytesLE(eN(0),ev),...Q.bigInt2BytesLE(eN(0),ev),...Q.bigInt2BytesLE(eN(0),ev),...Q.bigInt2BytesLE(eN(0),ev)]),eW=t.alloc([...Q.bigInt2BytesLE(eN(9),ev),...Q.bigInt2BytesLE(eN(1),ev)]),eD=t.alloc([...Q.bigInt2BytesLE(eN(tO(2n,0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n)),ev),...Q.bigInt2BytesLE(0n,ev)]),eV=t.alloc([...Q.bigInt2BytesLE(eN(0x2b149d40ceb8aaae81be18991be06ac3b5b4c5e559dbefa33267e6dc24a138e5n),ev),...Q.bigInt2BytesLE(eN(0x9713b03af0fed4cd2cafadeed8fdf4a74fa084e52d1852e4a2bd0685c315d2n),ev)]);(e=t.addFunction(eA+"_mulNR6")).addParam("x","i32"),e.addParam("pr","i32"),l=e.getCodeBuilder(),e.addCode(l.call(ez+"_mul",l.i32_const(eW),l.getLocal("x"),l.getLocal("pr")));let eK=tm(t,eA+"_mulNR6","f6m","f2m");(o=t.addFunction(eA+"_mulNR12")).addParam("x","i32"),o.addParam("pr","i32"),i=o.getCodeBuilder(),o.addCode(i.call(ez+"_mul",i.i32_const(eW),i.i32_add(i.getLocal("x"),i.i32_const(4*ev)),i.getLocal("pr")),i.call(ez+"_copy",i.getLocal("x"),i.i32_add(i.getLocal("pr"),i.i32_const(2*ev))),i.call(ez+"_copy",i.i32_add(i.getLocal("x"),i.i32_const(2*ev)),i.i32_add(i.getLocal("pr"),i.i32_const(4*ev))));let eX=th(t,eA+"_mulNR12","ftm",eK),eY=function(t){let a=0x19d797039be763ba8n,e=[];for(;a>0n;)tE(a)?e.push(1):e.push(0),a>>=1n;return e}(0x19d797039be763ba8n),eH=t.alloc(eY),e2=3*eI,e3=eY.length-1,e0=eY.reduce((t,a)=>t+ +(0!=a),0),e1=6*ev,e4=3*ev*2+(e0+e3+1)*e2;t.modules[eA]={n64:eq,pG1gen:eR,pG1zero:ej,pG1b:eM,pG2gen:eZ,pG2zero:eQ,pG2b:eT,pq:t.modules.f1m.pq,pr:eE,pOneT:eJ,prePSize:e1,preQSize:e4,r:0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001n.toString(),q:0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n.toString()};let e6=t.alloc(e1),e8=t.alloc(e4);(c=t.addFunction(eA+"_prepAddStep")).addParam("pQ","i32"),c.addParam("pR","i32"),c.addParam("pCoef","i32"),d=(n=c.getCodeBuilder()).getLocal("pQ"),r=n.i32_add(n.getLocal("pQ"),n.i32_const(eI)),s=n.getLocal("pR"),_=n.i32_add(n.getLocal("pR"),n.i32_const(eI)),f=n.i32_add(n.getLocal("pR"),n.i32_const(2*eI)),u=n.getLocal("pCoef"),g=n.i32_add(n.getLocal("pCoef"),n.i32_const(eI)),L=n.i32_add(n.getLocal("pCoef"),n.i32_const(2*eI)),p=n.i32_const(t.alloc(eI)),h=n.i32_const(t.alloc(eI)),m=n.i32_const(t.alloc(eI)),b=n.i32_const(t.alloc(eI)),x=n.i32_const(t.alloc(eI)),y=n.i32_const(t.alloc(eI)),F=n.i32_const(t.alloc(eI)),c.addCode(n.call(ez+"_mul",d,f,g),n.call(ez+"_sub",s,g,g),n.call(ez+"_mul",r,f,p),n.call(ez+"_sub",_,p,p),n.call(ez+"_square",g,h),n.call(ez+"_square",p,m),n.call(ez+"_mul",g,h,b),n.call(ez+"_mul",s,h,x),n.call(ez+"_add",x,x,F),n.call(ez+"_mul",f,m,y),n.call(ez+"_add",b,y,y),n.call(ez+"_sub",y,F,y),n.call(ez+"_mul",g,y,s),n.call(ez+"_mul",b,_,_),n.call(ez+"_sub",x,y,F),n.call(ez+"_mul",p,F,F),n.call(ez+"_sub",F,_,_),n.call(ez+"_mul",f,b,f),n.call(ez+"_mul",g,r,F),n.call(ez+"_mul",p,d,u),n.call(ez+"_sub",u,F,u),n.call(ez+"_mul",u,n.i32_const(eW),u),n.call(ez+"_neg",p,L)),(C=t.addFunction(eA+"_prepDblStep")).addParam("pR","i32"),C.addParam("pCoef","i32"),P=(B=C.getCodeBuilder()).getLocal("pR"),A=B.i32_add(B.getLocal("pR"),B.i32_const(eI)),q=B.i32_add(B.getLocal("pR"),B.i32_const(2*eI)),v=B.getLocal("pCoef"),I=B.i32_add(B.getLocal("pCoef"),B.i32_const(eI)),O=B.i32_add(B.getLocal("pCoef"),B.i32_const(2*eI)),E=B.i32_const(t.alloc(eI)),w=B.i32_const(t.alloc(eI)),M=B.i32_const(t.alloc(eI)),S=B.i32_const(t.alloc(eI)),z=B.i32_const(t.alloc(eI)),T=B.i32_const(t.alloc(eI)),k=B.i32_const(t.alloc(eI)),G=B.i32_const(t.alloc(eI)),N=B.i32_const(t.alloc(eI)),R=B.i32_const(t.alloc(eI)),j=B.i32_const(t.alloc(eI)),U=B.i32_const(t.alloc(eI)),C.addCode(B.call(ez+"_mul",A,B.i32_const(eD),E),B.call(ez+"_mul",P,E,E),B.call(ez+"_square",A,w),B.call(ez+"_square",q,M),B.call(ez+"_add",M,M,S),B.call(ez+"_add",S,M,S),B.call(ez+"_mul",B.i32_const(eV),S,z),B.call(ez+"_add",z,z,T),B.call(ez+"_add",z,T,T),B.call(ez+"_add",w,T,k),B.call(ez+"_mul",k,B.i32_const(eD),k),B.call(ez+"_add",w,M,U),B.call(ez+"_add",A,q,G),B.call(ez+"_square",G,G),B.call(ez+"_sub",G,U,G),B.call(ez+"_sub",z,w,N),B.call(ez+"_square",P,R),B.call(ez+"_square",z,j),B.call(ez+"_sub",w,T,U),B.call(ez+"_mul",E,U,P),B.call(ez+"_add",j,j,U),B.call(ez+"_add",j,U,U),B.call(ez+"_square",k,A),B.call(ez+"_sub",A,U,A),B.call(ez+"_mul",w,G,q),B.call(ez+"_mul",B.i32_const(eW),N,v),B.call(ez+"_neg",G,I),B.call(ez+"_add",R,R,O),B.call(ez+"_add",R,O,O)),(Z=t.addFunction(eA+"_prepareG1")).addParam("pP","i32"),Z.addParam("ppreP","i32"),$=Z.getCodeBuilder(),Z.addCode($.call(eS+"_normalize",$.getLocal("pP"),$.getLocal("ppreP"))),(J=t.addFunction(eA+"_mulByQ")).addParam("p1","i32"),J.addParam("pr","i32"),D=(W=J.getCodeBuilder()).getLocal("p1"),V=W.i32_add(W.getLocal("p1"),W.i32_const(eI)),K=W.i32_add(W.getLocal("p1"),W.i32_const(2*eI)),X=W.getLocal("pr"),Y=W.i32_add(W.getLocal("pr"),W.i32_const(eI)),H=W.i32_add(W.getLocal("pr"),W.i32_const(2*eI)),tt=W.i32_const(t.alloc([...Q.bigInt2BytesLE(eN("2157546363828084301039832426943
10826099269044274347216827212613867836435027261"),ev),...Q.bigInt2BytesLE(eN("10307601595873709700152284273816112264069230130616436755625194854815875713954"),ev)])),ta=W.i32_const(t.alloc([...Q.bigInt2BytesLE(eN("2821565182194536844548159561693502659359617185244120367078079554186484126554"),ev),...Q.bigInt2BytesLE(eN("3505843767911556378687030309984248845540243509899259641013678093033130930403"),ev)])),J.addCode(W.call(ez+"_conjugate",D,X),W.call(ez+"_mul",tt,X,X),W.call(ez+"_conjugate",V,Y),W.call(ez+"_mul",ta,Y,Y),W.call(ez+"_conjugate",K,H)),(te=t.addFunction(eA+"_prepareG2")).addParam("pQ","i32"),te.addParam("ppreQ","i32"),te.addLocal("pCoef","i32"),te.addLocal("i","i32"),to=(tl=te.getCodeBuilder()).getLocal("pQ"),ti=t.alloc(3*eI),tc=tl.i32_const(ti),tn=tl.i32_const(ti),td=tl.i32_const(ti+eI),tr=tl.i32_const(ti+2*eI),ts=tl.i32_add(tl.getLocal("ppreQ"),tl.i32_const(0)),t_=tl.i32_add(tl.getLocal("ppreQ"),tl.i32_const(eI)),tf=t.alloc(3*eI),tu=tl.i32_const(tf),tL=t.alloc(3*eI),tb=tl.i32_const(tL),tx=tl.i32_const(tL+eI),te.addCode(tl.call(ek+"_normalize",to,ts),tl.call(ez+"_copy",ts,tn),tl.call(ez+"_copy",t_,td),tl.call(ez+"_one",tr)),te.addCode(tl.setLocal("pCoef",tl.i32_add(tl.getLocal("ppreQ"),tl.i32_const(3*eI))),tl.setLocal("i",tl.i32_const(eY.length-2)),tl.block(tl.loop(tl.call(eA+"_prepDblStep",tc,tl.getLocal("pCoef")),tl.setLocal("pCoef",tl.i32_add(tl.getLocal("pCoef"),tl.i32_const(e2))),tl.if(tl.i32_load8_s(tl.getLocal("i"),eH),[...tl.call(eA+"_prepAddStep",ts,tc,tl.getLocal("pCoef")),...tl.setLocal("pCoef",tl.i32_add(tl.getLocal("pCoef"),tl.i32_const(e2)))]),tl.br_if(1,tl.i32_eqz(tl.getLocal("i"))),tl.setLocal("i",tl.i32_sub(tl.getLocal("i"),tl.i32_const(1))),tl.br(0)))),te.addCode(tl.call(eA+"_mulByQ",ts,tu),tl.call(eA+"_mulByQ",tu,tb)),te.addCode(tl.call(ez+"_neg",tx,tx),tl.call(eA+"_prepAddStep",tu,tc,tl.getLocal("pCoef")),tl.setLocal("pCoef",tl.i32_add(tl.getLocal("pCoef"),tl.i32_const(e2))),tl.call(eA+"_prepAddStep",tb,tc,tl.getLocal("pCoef")),tl.setLocal("pCoef",tl.i32_add(tl.getLocal("pCoef"),tl.i32_const(e2)))),(tF=t.addFunction(eA+"__mulBy024")).addParam("pEll0","i32"),tF.addParam("pEllVW","i32"),tF.addParam("pEllVV","i32"),tF.addParam("pR","i32"),tB=(tC=tF.getCodeBuilder()).getLocal("pEll0"),tM=tC.getLocal("pEllVV"),tS=tC.getLocal("pEllVW"),tz=tC.getLocal("pR"),tT=tC.i32_add(tC.getLocal("pR"),tC.i32_const(2*ev)),tk=tC.i32_add(tC.getLocal("pR"),tC.i32_const(4*ev)),tG=tC.i32_add(tC.getLocal("pR"),tC.i32_const(6*ev)),tN=tC.i32_add(tC.getLocal("pR"),tC.i32_const(8*ev)),tR=tC.i32_add(tC.getLocal("pR"),tC.i32_const(10*ev)),tj=tC.i32_const(t.alloc(eI)),tU=tC.i32_const(t.alloc(eI)),tZ=tC.i32_const(t.alloc(eI)),t$=tC.i32_const(t.alloc(eI)),tQ=tC.i32_const(t.alloc(eI)),tJ=tC.i32_const(t.alloc(eI)),tW=tC.i32_const(t.alloc(eI)),tD=tC.i32_const(t.alloc(eI)),tV=tC.i32_const(t.alloc(eI)),tK=tC.i32_const(t.alloc(eI)),tX=tC.i32_const(t.alloc(eI)),tF.addCode(tC.call(ez+"_mul",tz,tB,tW),tC.call(ez+"_mul",tk,tM,tD),tC.call(ez+"_mul",tN,tS,tV),tC.call(ez+"_add",tz,tN,tZ),tC.call(ez+"_add",tz,tk,tU),tC.call(ez+"_add",tT,tG,t$),tC.call(ez+"_add",t$,tR,t$),tC.call(ez+"_mul",tT,tM,tK),tC.call(ez+"_add",tK,tV,tQ),tC.call(ez+"_mul",tC.i32_const(eW),tQ,tJ),tC.call(ez+"_add",tJ,tW,tz),tC.call(ez+"_mul",tR,tS,tQ),tC.call(ez+"_add",tK,tQ,tK),tC.call(ez+"_add",tQ,tD,tQ),tC.call(ez+"_mul",tC.i32_const(eW),tQ,tJ),tC.call(ez+"_mul",tT,tB,tQ),tC.call(ez+"_add",tK,tQ,tK),tC.call(ez+"_add",tJ,tQ,tT),tC.call(ez+"_add",tB,tM,tj),tC.call(ez+"_mul",tU,tj,tQ),tC.call(ez+"_add",tW,tD,tX),tC.call(ez+"_sub",tQ,tX,tQ),tC.call(ez+"_mul",tG,tS,tJ),tC.call(ez+"_add",tK,tJ,tK),tC.call(ez+"_add",tk,tN,tj),tC.call(ez+"_add",tQ,tJ,tk),tC.call(ez+"_add",tM,tS,tU),tC.call(ez+"_mul",tU,tj,tQ),tC.call(ez+"_add",tD,tV,tX),tC.call(ez+"_sub",tQ,tX,tQ),tC.call(ez+"_mul",tC.i32_const(eW),tQ,tJ),tC.call(ez+"_mul",tG,tB,tQ),tC.call(ez+"_add",tK,tQ,tK),tC.call(ez+"_add",tJ,tQ,tG),tC.call(ez+"_mul",tR,tM,tQ),tC.call(ez+"_add",tK,tQ,tK),tC.call(ez+"_mul",tC.i32_const(eW),tQ,tJ),tC.call(ez+"_add",tB,tS,tj),tC.call(ez+"_mul",tZ,tj,tQ),tC.call(ez+"_add",tW,tV,tX),tC.call(ez+"_sub",tQ,tX,tQ),tC.call(ez+"_add",tJ,tQ,tN),tC.call(ez+"_add",tB,tM,tj),tC.call(ez+"_add",tj,tS,tj),tC.call(ez+"_mul",t$,tj,tQ),tC.call(ez+"_sub",tQ,tK,tR)),(tY=t.addFunction(eA+"__mulBy024Old")).addParam("pEll0","i32"),tY.addParam("pEllVW","i32"),tY.addParam("pEllVV","i32"),tY.addParam("pR","i32"),t2=(tH=tY.getCodeBuilder()).getLocal("pEll0"),t3=tH.getLocal("pEllVV"),t0=tH.getLocal("pEllVW"),t1=tH.getLocal("pR"),t4=t.alloc(eO),t6=tH.i32_const(t4),t8=tH.i32_const(t4),t7=tH.i32_const(t4+eI),t5=tH.i32_const(t4+2*eI),t9=tH.i32_const(t4+3*eI),at=tH.i32_const(t4+4*eI),aa=tH.i32_const(t4+5*eI),tY.addCode(tH.call(ez+"_copy",t2,t8),tH.call(ez+"_zero",t7),tH.call(ez+"_copy",t3,t5),tH.call(ez+"_zero",t9),tH.call(ez+"_copy",t0,at),tH.call(ez+"_zero",aa),tH.call(eX+"_mul",t6,t1,t1)),(ae=t.addFunction(eA+"_millerLoop")).addParam("ppreP","i32"),ae.addParam("ppreQ","i32"),ae.addParam("r","i32"),ae.addLocal("pCoef","i32"),ae.addLocal("i","i32"),ao=(al=ae.getCodeBuilder()).getLocal("ppreP"),ai=al.i32_add(al.getLocal("ppreP"),al.i32_const(ev)),ac=al.getLocal("pCoef"),an=al.i32_add(al.getLocal("pCoef"),al.i32_const(eI)),ad=al.i32_add(al.getLocal("pCoef"),al.i32_const(2*eI)),ar=t.alloc(eI),as=al.i32_const(ar),a_=t.alloc(eI),af=al.i32_const(a_),au=al.getLocal("r"),ae.addCode(al.call(eX+"_one",au),al.setLocal("pCoef",al.i32_add(al.getLocal("ppreQ"),al.i32_const(3*eI))),al.setLocal("i",al.i32_const(eY.length-2)),al.block(al.loop(al.call(eX+"_square",au,au),al.call(ez+"_mul1",an,ai,as),al.call(ez+"_mul1",ad,ao,af),al.call(eA+"__mulBy024",ac,as,af,au),al.setLocal("pCoef",al.i32_add(al.getLocal("pCoef"),al.i32_const(e2))),al.if(al.i32_load8_s(al.getLocal("i"),eH),[...al.call(ez+"_mul1",an,ai,as),...al.call(ez+"_mul1",ad,ao,af),...al.call(eA+"__mulBy024",ac,as,af,au),...al.setLocal("pCoef",al.i32_add(al.getLocal("pCoef"),al.i32_const(e2)))]),al.br_if(1,al.i32_eqz(al.getLocal("i"))),al.setLocal("i",al.i32_sub(al.getLocal("i"),al.i32_const(1))),al.br(0))
1)),ae.addCode(al.call(ez+"_mul1",an,ai,as),al.call(ez+"_mul1",ad,ao,af),al.call(eA+"__mulBy024",ac,as,af,au),al.setLocal("pCoef",al.i32_add(al.getLocal("pCoef"),al.i32_const(e2))),al.call(ez+"_mul1",an,ai,as),al.call(ez+"_mul1",ad,ao,af),al.call(eA+"__mulBy024",ac,as,af,au),al.setLocal("pCoef",al.i32_add(al.getLocal("pCoef"),al.i32_const(e2))));for(let a=0;a<10;a++)!function(a){let e=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[0x1284b71c2865a7dfe8b99fdd76e68b605c521e08292f2176d60b35dadcc9e470n,0x246996f3b4fae7e6a6327cfe12150b8e747992778eeec7e5ca5cf05f80f362acn],[0x30644e72e131a0295e6dd9e7e0acccb0c28f069fbb966e3de4bd44e5607cfd49n,0n],[0x19dc81cfcc82e4bbefe9608cd0acaa90894cb38dbe55d24ae86f7d391ed4a67fn,0xabf8b60be77d7306cbeee33576139d7f03a5e397d439ec7694aa2bf4c0c101n],[0x30644e72e131a0295e6dd9e7e0acccb0c28f069fbb966e3de4bd44e5607cfd48n,0n],[0x757cab3a41d3cdc072fc0af59c61f302cfa95859526b0d41264475e420ac20fn,0xca6b035381e35b618e9b79ba4e2606ca20b7dfd71573c93e85845e34c4a5b9cn],[0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd46n,0n],[0x1ddf9756b8cbf849cf96a5d90a9accfd3b2f4c893f42a9166615563bfbb318d7n,0xbfab77f2c36b843121dc8b86f6c4ccf2307d819d98302a771c39bb757899a9bn],[0x59e26bcea0d48bacd4f263f1acdb5c4f5763473177fffffen,0n],[0x1687cca314aebb6dc866e529b0d4adcd0e34b703aa1bf84253b10eddb9a856c8n,0x2fb855bcd54a22b6b18456d34c0b44c0187dc4add09d90a0c58be1eae3bc3c46n],[0x59e26bcea0d48bacd4f263f1acdb5c4f5763473177ffffffn,0n],[0x290c83bf3d14634db120850727bb392d6a86d50bd34b19b929bc44b896723b38n,0x23bd9e3da9136a739f668e1adc9ef7f0f575ec93f71a8df953c846338c32a1abn]]],l=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[0x2fb347984f7911f74c0bec3cf559b143b78cc310c2c3330c99e39557176f553dn,0x16c9e55061ebae204ba4cc8bd75a079432ae2a1d0b7c9dce1665d51c640fcba2n],[0x30644e72e131a0295e6dd9e7e0acccb0c28f069fbb966e3de4bd44e5607cfd48n,0n],[0x856e078b755ef0abaff1c77959f25ac805ffd3d5d6942d37b746ee87bdcfb6dn,0x4f1de41b3d1766fa9f30e6dec26094f0fdf31bf98ff2631380cab2baaa586den],[0x59e26bcea0d48bacd4f263f1acdb5c4f5763473177fffffen,0n],[0x28be74d4bb943f51699582b87809d9caf71614d4b0b71f3a62e913ee1dada9e4n,0x14a88ae0cb747b99c2b86abcbe01477a54f40eb4c3f6068dedae0bcec9c7aac7n]],[[1n,0n],[0x5b54f5e64eea80180f3c0b75a181e84d33365f7be94ec72848a1f55921ea762n,0x2c145edbe7fd8aee9f3a80b03b0b1c923685d2ea1bdec763c13b4711cd2b8126n],[0x59e26bcea0d48bacd4f263f1acdb5c4f5763473177fffffen,0n],[0xbc58c6611c08dab19bee0f7b5b2444ee633094575b06bcb0e1a92bc3ccbf066n,0x23d5e999e1910a12feb0f6ef0cd21d04a44a9e08737f96e55fe3ed9d730c239fn],[0x30644e72e131a0295e6dd9e7e0acccb0c28f069fbb966e3de4bd44e5607cfd48n,0n],[0x1ee972ae6a826a7d1d9da40771b6f589de1afb54342c724fa97bda050992657fn,0x10de546ff8d4ab51d2b513cdbb25772454326430418536d15721e37e70c255c9n]]],o=t.addFunction(eA+"__frobeniusMap"+a);o.addParam("x","i32"),o.addParam("r","i32");let i=o.getCodeBuilder();for(let c=0;c<6;c++){let n=0==c?i.getLocal("x"):i.i32_add(i.getLocal("x"),i.i32_const(c*eI)),d=i.i32_add(i.getLocal("x"),i.i32_const(c*eI+ev)),r=0==c?i.getLocal("r"):i.i32_add(i.getLocal("r"),i.i32_const(c*eI)),s=i.i32_add(i.getLocal("r"),i.i32_const(c*eI+ev)),_=function(t,a){let e=BigInt(t[0]),l=BigInt(t[1]),o=BigInt(a[0]),i=BigInt(a[1]),c=[(e*o-l*i)%0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n,(e*i+l*o)%0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n];return tw(c[0])&&(c[0]=c[0]+0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n),c}(e[Math.floor(c/3)][a%12],l[c%3][a%6]),f=t.alloc([...Q.bigInt2BytesLE(eN(_[0]),32),...Q.bigInt2BytesLE(eN(_[1]),32)]);a%2==1?o.addCode(i.call(ew+"_copy",n,r),i.call(ew+"_neg",d,s),i.call(ez+"_mul",r,i.i32_const(f),r)):o.addCode(i.call(ez+"_mul",n,i.i32_const(f),r))}}(a),t.exportFunction(eA+"__frobeniusMap"+a);(ag=t.addFunction(eA+"_finalExponentiationOld")).addParam("x","i32"),ag.addParam("r","i32"),aL=t.alloc(Q.bigInt2BytesLE(0x2f4b6dc97020fddadf107d20bc842d43bf6369b1ff6a1c71015f3f7be2e1e30a73bb94fec0daf15466b2383a5d3ec3d15ad524d8f70c54efee1bd8c3b21377e563a09a1b705887e72eceaddea3790364a61f676baaf977870e88d5c6c8fef0781361e443ae77f5b63a2a2264487f2940a8b1ddb3d15062cd0fb2015dfc6668449aed3cc48a82d0d602d268c7daab6a41294c0cc4ebe5664568dfc50e1648a45a4a1e3a5195846a3ed011a337a02088ec80e0ebae8755cfe107acf3aafb40494e406f804216bb10cf430b0f37856b42db8dc5514724ee93dfb10826f0dd4a0364b9580291d2cd65664814fde37ca80bb4ea44eacc5e641bbadf423f9a2cbf813b8d145da90029baee7ddadda71c7f3811c4105262945bba1668c3be69a3c230974d83561841d766f9c9d570bb7fbe04c7e8a6c3c760c0de81def35692da361102b6b9b2b918837fa97896e84abb40a4efb7e54523a486964b64ca86f
1120n,352)),ap=ag.getCodeBuilder(),ag.addCode(ap.call(eX+"_exp",ap.getLocal("x"),ap.i32_const(aL),ap.i32_const(352),ap.getLocal("r"))),(ah=t.addFunction(eA+"__finalExponentiationFirstChunk")).addParam("x","i32"),ah.addParam("r","i32"),ab=(am=ah.getCodeBuilder()).getLocal("x"),ax=am.i32_add(ab,am.i32_const(6*ev)),ay=am.getLocal("r"),aF=t.alloc(eO),aC=am.i32_const(aF),aB=am.i32_const(aF+6*ev),aP=am.i32_const(t.alloc(eO)),aA=am.i32_const(t.alloc(eO)),aq=am.i32_const(t.alloc(eO)),ah.addCode(am.call(eK+"_copy",ab,aC),am.call(eK+"_neg",ax,aB),am.call(eX+"_inverse",ab,aP),am.call(eX+"_mul",aC,aP,aA),am.call(eA+"__frobeniusMap2",aA,aq),am.call(eX+"_mul",aA,aq,ay)),(av=t.addFunction(eA+"__cyclotomicSquare")).addParam("x","i32"),av.addParam("r","i32"),aO=(aI=av.getCodeBuilder()).getLocal("x"),aE=aI.i32_add(aI.getLocal("x"),aI.i32_const(eI)),aw=aI.i32_add(aI.getLocal("x"),aI.i32_const(2*eI)),aM=aI.i32_add(aI.getLocal("x"),aI.i32_const(3*eI)),aS=aI.i32_add(aI.getLocal("x"),aI.i32_const(4*eI)),az=aI.i32_add(aI.getLocal("x"),aI.i32_const(5*eI)),aT=aI.getLocal("r"),ak=aI.i32_add(aI.getLocal("r"),aI.i32_const(eI)),aG=aI.i32_add(aI.getLocal("r"),aI.i32_const(2*eI)),aN=aI.i32_add(aI.getLocal("r"),aI.i32_const(3*eI)),aR=aI.i32_add(aI.getLocal("r"),aI.i32_const(4*eI)),aj=aI.i32_add(aI.getLocal("r"),aI.i32_const(5*eI)),aU=aI.i32_const(t.alloc(eI)),aZ=aI.i32_const(t.alloc(eI)),a$=aI.i32_const(t.alloc(eI)),aQ=aI.i32_const(t.alloc(eI)),aJ=aI.i32_const(t.alloc(eI)),aW=aI.i32_const(t.alloc(eI)),aD=aI.i32_const(t.alloc(eI)),aV=aI.i32_const(t.alloc(eI)),av.addCode(aI.call(ez+"_mul",aO,aS,aD),aI.call(ez+"_mul",aS,aI.i32_const(eW),aU),aI.call(ez+"_add",aO,aU,aU),aI.call(ez+"_add",aO,aS,aV),aI.call(ez+"_mul",aV,aU,aU),aI.call(ez+"_mul",aI.i32_const(eW),aD,aV),aI.call(ez+"_add",aD,aV,aV),aI.call(ez+"_sub",aU,aV,aU),aI.call(ez+"_add",aD,aD,aZ),aI.call(ez+"_mul",aM,aw,aD),aI.call(ez+"_mul",aw,aI.i32_const(eW),a$),aI.call(ez+"_add",aM,a$,a$),aI.call(ez+"_add",aM,aw,aV),aI.call(ez+"_mul",aV,a$,a$),aI.call(ez+"_mul",aI.i32_const(eW),aD,aV),aI.call(ez+"_add",aD,aV,aV),aI.call(ez+"_sub",a$,aV,a$),aI.call(ez+"_add",aD,aD,aQ),aI.call(ez+"_mul",aE,az,aD),aI.call(ez+"_mul",az,aI.i32_const(eW),aJ),aI.call(ez+"_add",aE,aJ,aJ),aI.call(ez+"_add",aE,az,aV),aI.call(ez+"_mul",aV,aJ,aJ),aI.call(ez+"_mul",aI.i32_const(eW),aD,aV),aI.call(ez+"_add",aD,aV,aV),aI.call(ez+"_sub",aJ,aV,aJ),aI.call(ez+"_add",aD,aD,aW),aI.call(ez+"_sub",aU,aO,aT),aI.call(ez+"_add",aT,aT,aT),aI.call(ez+"_add",aU,aT,aT),aI.call(ez+"_add",aZ,aS,aR),aI.call(ez+"_add",aR,aR,aR),aI.call(ez+"_add",aZ,aR,aR),aI.call(ez+"_mul",aW,aI.i32_const(eW),aV),aI.call(ez+"_add",aV,aM,aN),aI.call(ez+"_add",aN,aN,aN),aI.call(ez+"_add",aV,aN,aN),aI.call(ez+"_sub",aJ,aw,aG),aI.call(ez+"_add",aG,aG,aG),aI.call(ez+"_add",aJ,aG,aG),aI.call(ez+"_sub",a$,aE,ak),aI.call(ez+"_add",ak,ak,ak),aI.call(ez+"_add",a$,ak,ak),aI.call(ez+"_add",aQ,az,aj),aI.call(ez+"_add",aj,aj,aj),aI.call(ez+"_add",aQ,aj,aj)),aK=(function(t){let a=0x44e992b44a6909f1n,e=[];for(;a>0n;){if(tE(a)){let t=2-Number(a%4n);e.push(t),a-=BigInt(t)}else e.push(0);a>>=1n}return e})(0x44e992b44a6909f1n).map(t=>-1==t?255:t),aX=t.alloc(aK),(aY=t.addFunction(eA+"__cyclotomicExp_w0")).addParam("x","i32"),aY.addParam("r","i32"),aY.addLocal("bit","i32"),aY.addLocal("i","i32"),a2=(aH=aY.getCodeBuilder()).getLocal("x"),a3=aH.getLocal("r"),a0=aH.i32_const(t.alloc(eO)),aY.addCode(aH.call(eX+"_conjugate",a2,a0),aH.call(eX+"_one",a3),aH.if(aH.teeLocal("bit",aH.i32_load8_s(aH.i32_const(aK.length-1),aX)),aH.if(aH.i32_eq(aH.getLocal("bit"),aH.i32_const(1)),aH.call(eX+"_mul",a3,a2,a3),aH.call(eX+"_mul",a3,a0,a3))),aH.setLocal("i",aH.i32_const(aK.length-2)),aH.block(aH.loop(aH.call(eA+"__cyclotomicSquare",a3,a3),aH.if(aH.teeLocal("bit",aH.i32_load8_s(aH.getLocal("i"),aX)),aH.if(aH.i32_eq(aH.getLocal("bit"),aH.i32_const(1)),aH.call(eX+"_mul",a3,a2,a3),aH.call(eX+"_mul",a3,a0,a3))),aH.br_if(1,aH.i32_eqz(aH.getLocal("i"))),aH.setLocal("i",aH.i32_sub(aH.getLocal("i"),aH.i32_const(1))),aH.br(0)))),(a1=t.addFunction(eA+"__finalExponentiationLastChunk")).addParam("x","i32"),a1.addParam("r","i32"),a6=(a4=a1.getCodeBuilder()).getLocal("x"),a8
1=a4.getLocal("r"),a7=a4.i32_const(t.alloc(eO)),a5=a4.i32_const(t.alloc(eO)),a9=a4.i32_const(t.alloc(eO)),et=a4.i32_const(t.alloc(eO)),ea=a4.i32_const(t.alloc(eO)),ee=a4.i32_const(t.alloc(eO)),el=a4.i32_const(t.alloc(eO)),eo=a4.i32_const(t.alloc(eO)),ei=a4.i32_const(t.alloc(eO)),ec=a4.i32_const(t.alloc(eO)),en=a4.i32_const(t.alloc(eO)),ed=a4.i32_const(t.alloc(eO)),er=a4.i32_const(t.alloc(eO)),es=a4.i32_const(t.alloc(eO)),e_=a4.i32_const(t.alloc(eO)),ef=a4.i32_const(t.alloc(eO)),eu=a4.i32_const(t.alloc(eO)),eg=a4.i32_const(t.alloc(eO)),eL=a4.i32_const(t.alloc(eO)),ep=a4.i32_const(t.alloc(eO)),eh=a4.i32_const(t.alloc(eO)),a1.addCode(a4.call(eA+"__cyclotomicExp_w0",a6,a7),a4.call(eX+"_conjugate",a7,a7),a4.call(eA+"__cyclotomicSquare",a7,a5),a4.call(eA+"__cyclotomicSquare",a5,a9),a4.call(eX+"_mul",a9,a5,et),a4.call(eA+"__cyclotomicExp_w0",et,ea),a4.call(eX+"_conjugate",ea,ea),a4.call(eA+"__cyclotomicSquare",ea,ee),a4.call(eA+"__cyclotomicExp_w0",ee,el),a4.call(eX+"_conjugate",el,el),a4.call(eX+"_conjugate",et,eo),a4.call(eX+"_conjugate",el,ei),a4.call(eX+"_mul",ei,ea,ec),a4.call(eX+"_mul",ec,eo,en),a4.call(eX+"_mul",en,a5,ed),a4.call(eX+"_mul",en,ea,er),a4.call(eX+"_mul",er,a6,es),a4.call(eA+"__frobeniusMap1",ed,e_),a4.call(eX+"_mul",e_,es,ef),a4.call(eA+"__frobeniusMap2",en,eu),a4.call(eX+"_mul",eu,ef,eg),a4.call(eX+"_conjugate",a6,eL),a4.call(eX+"_mul",eL,ed,ep),a4.call(eA+"__frobeniusMap3",ep,eh),a4.call(eX+"_mul",eh,eg,a8)),(em=t.addFunction(eA+"_finalExponentiation")).addParam("x","i32"),em.addParam("r","i32"),ex=(eb=em.getCodeBuilder()).getLocal("x"),ey=eb.getLocal("r"),eF=eb.i32_const(t.alloc(eO)),em.addCode(eb.call(eA+"__finalExponentiationFirstChunk",ex,eF),eb.call(eA+"__finalExponentiationLastChunk",eF,ey));for(let a=1;a<=5;a++)!function(a){let e=t.addFunction(eA+"_pairingEq"+a);for(let t=0;t<a;t++)e.addParam("p_"+t,"i32"),e.addParam("q_"+t,"i32");e.addParam("c","i32"),e.setReturnType("i32");let l=e.getCodeBuilder(),o=l.i32_const(t.alloc(eO)),i=l.i32_const(t.alloc(eO));e.addCode(l.call(eX+"_one",o));for(let t=0;t<a;t++)e.addCode(l.call(eA+"_prepareG1",l.getLocal("p_"+t),l.i32_const(e6))),e.addCode(l.call(eA+"_prepareG2",l.getLocal("q_"+t),l.i32_const(e8))),e.addCode(l.call(eA+"_millerLoop",l.i32_const(e6),l.i32_const(e8),i)),e.addCode(l.call(eX+"_mul",o,i,o));e.addCode(l.call(eA+"_finalExponentiation",o,o)),e.addCode(l.call(eX+"_eq",o,l.getLocal("c")))}(a),t.exportFunction(eA+"_pairingEq"+a);(eC=t.addFunction(eA+"_pairing")).addParam("p","i32"),eC.addParam("q","i32"),eC.addParam("r","i32"),eP=(eB=eC.getCodeBuilder()).i32_const(t.alloc(eO)),eC.addCode(eB.call(eA+"_prepareG1",eB.getLocal("p"),eB.i32_const(e6))),eC.addCode(eB.call(eA+"_prepareG2",eB.getLocal("q"),eB.i32_const(e8))),eC.addCode(eB.call(eA+"_millerLoop",eB.i32_const(e6),eB.i32_const(e8),eP)),eC.addCode(eB.call(eA+"_finalExponentiation",eP,eB.getLocal("r"))),t.exportFunction(eA+"_pairing"),t.exportFunction(eA+"_prepareG1"),t.exportFunction(eA+"_prepareG2"),t.exportFunction(eA+"_millerLoop"),t.exportFunction(eA+"_finalExponentiation"),t.exportFunction(eA+"_finalExponentiationOld"),t.exportFunction(eA+"__mulBy024"),t.exportFunction(eA+"__mulBy024Old"),t.exportFunction(eA+"__cyclotomicSquare"),t.exportFunction(eA+"__cyclotomicExp_w0")},tk=function(t,a){let e,l,o,i,c,n,d,r,s,_,f,u,g,L,p,h,m,b,x,y,F,C,B,P,A,q,v,I,O,E,w,M,S,z,T,k,G,N,R,j,U,Z,$,J,W,D,V,K,X,Y,H,tt,ta,te,tl,to,ti,tc,tn,td,tr,ts,t_,tf,tu,tL,tb,tx,tF,tC,tB,tI,tO,tE,tw,tT,tk,tG,tN,tR,tj,tU,tZ,t$,tQ,tJ,tW,tD,tV,tK,tX,tY,tH,t2,t3,t0,t1,t4,t6,t8,t7,t5,t9,at,aa,ae,al,ao,ai,ac,an,ad,ar,as,a_,af,au,ag,aL,ap,ah,am,ab,ax,ay,aF,aC,aB,aP,aA,aq,av,aI,aO,aE,aw,aM,aS,az,aT,ak,aG,aN,aR,aj,aU,aZ,a$,aQ,aJ,aW,aD,aV,aK,aX,aY,aH,a2,a3,a0,a1,a4,a6,a8,a7,a5,a9,et,ea,ee,el,eo,ei,ec,en,ed,er,es,e_,ef,eu,eg,eL,ep,eh,em,eb,ex,ey,eF,eC,eB,eP,eA,eq,ev,eI,eO,eE,ew,eM,eS,ez,eT,ek,eG,eN,eR=a||"bls12381";if(t.modules[eR])return eR;let ej=Math.floor((tM(0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn-1n)-1)/64)+1,eU=8*ej,eZ=2*eU,e$=12*eU,eQ=Math.floor((tM(0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n-1n)-1)/64)+1,eJ=8*eQ,eW=t.alloc(Q.bigInt2BytesLE(0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n,eJ)),eD=tg(t,0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn,"f1m","intq");tp(t,0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n,"fr","frm","intr");let eV=t.alloc(Q.bigInt2BytesLE(e3(4n),eU)),eK=ty(t,"g1m","f1m",eV);tP(t,"frm","frm","frm","frm_mul"),tA(t,"pol","frm"),tq(t,"qap","frm");let eX=th(t,"f1m_neg","f2m","f1m"),eY=t.alloc([...Q.bigInt2BytesLE(e3(4n),eU),...Q.bigInt2BytesLE(e3(4n),eU)]),eH=ty(t,"g2m","f2m",eY);function e2(a,e){let l=t.addFunction(a);l.addParam("pG","i32"),l.addParam("pFr","i32"),l.addParam("pr","i32");let o=l.getCodeBuilder(),i=o.i32_const(t.alloc(eJ));l.addCode(o.call("frm_fromMontgomery",o.getLocal("pFr"),i),o.call(e,o.getLocal("pG"),i,o.i32_const(eJ),o.getL
1ocal("pr"))),t.exportFunction(a)}function e3(t){return BigInt(t)*(1n<<BigInt(8*eU))%0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn}e2("g1m_timesFr","g1m_timesScalar"),tP(t,"g1m","g1m","frm","g1m_timesFr"),e2("g2m_timesFr","g2m_timesScalar"),tP(t,"g2m","g2m","frm","g2m_timesFr"),e2("g1m_timesFrAffine","g1m_timesScalarAffine"),e2("g2m_timesFrAffine","g2m_timesScalarAffine"),tv(t,"frm_batchApplyKey","fmr","frm",eJ,eJ,eJ,"frm_mul"),tv(t,"g1m_batchApplyKey","g1m","frm",3*eU,3*eU,eJ,"g1m_timesFr"),tv(t,"g1m_batchApplyKeyMixed","g1m","frm",2*eU,3*eU,eJ,"g1m_timesFrAffine"),tv(t,"g2m_batchApplyKey","g2m","frm",2*eU*3,3*eU*2,eJ,"g2m_timesFr"),tv(t,"g2m_batchApplyKeyMixed","g2m","frm",2*eU*2,3*eU*2,eJ,"g2m_timesFrAffine");let e0=t.alloc([...Q.bigInt2BytesLE(e3(0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bbn),eU),...Q.bigInt2BytesLE(e3(0x8b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1n),eU),...Q.bigInt2BytesLE(e3(1n),eU)]),e1=t.alloc([...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(1n),eU),...Q.bigInt2BytesLE(e3(0n),eU)]),e4=[[0x24aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8n,0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7en],[0xce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801n,0x606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79ben],[1n,0n]],e6=t.alloc([...Q.bigInt2BytesLE(e3(e4[0][0]),eU),...Q.bigInt2BytesLE(e3(e4[0][1]),eU),...Q.bigInt2BytesLE(e3(e4[1][0]),eU),...Q.bigInt2BytesLE(e3(e4[1][1]),eU),...Q.bigInt2BytesLE(e3(e4[2][0]),eU),...Q.bigInt2BytesLE(e3(e4[2][1]),eU)]),e8=[[0n,0n],[1n,0n],[0n,0n]],e7=t.alloc([...Q.bigInt2BytesLE(e3(e8[0][0]),eU),...Q.bigInt2BytesLE(e3(e8[0][1]),eU),...Q.bigInt2BytesLE(e3(e8[1][0]),eU),...Q.bigInt2BytesLE(e3(e8[1][1]),eU),...Q.bigInt2BytesLE(e3(e8[2][0]),eU),...Q.bigInt2BytesLE(e3(e8[2][1]),eU)]),e5=t.alloc([...Q.bigInt2BytesLE(e3(1n),eU),...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(0n),eU),...Q.bigInt2BytesLE(e3(0n),eU)]),e9=t.alloc([...Q.bigInt2BytesLE(e3(1n),eU),...Q.bigInt2BytesLE(e3(1n),eU)]);(e=t.addFunction(eX+"_mulNR")).addParam("x","i32"),e.addParam("pr","i32"),o=(l=e.getCodeBuilder()).i32_const(t.alloc(eU)),i=l.getLocal("x"),c=l.i32_add(l.getLocal("x"),l.i32_const(eU)),n=l.getLocal("pr"),d=l.i32_add(l.getLocal("pr"),l.i32_const(eU)),e.addCode(l.call(eD+"_copy",i,o),l.call(eD+"_sub",i,c,n),l.call(eD+"_add",o,c,d));let lt=tm(t,eX+"_mulNR","f6m","f2m");(r=t.addFunction(lt+"_mulNR")).addParam("x","i32"),r.addParam("pr","i32"),_=(s=r.getCodeBuilder()).i32_const(t.alloc(2*eU)),r.addCode(s.call(eX+"_copy",s.getLocal("x"),_),s.call(eX+"_mulNR",s.i32_add(s.getLocal("x"),s.i32_const(4*eU)),s.getLocal("pr")),s.call(eX+"_copy",s.i32_add(s.getLocal("x"),s.i32_const(2*eU)),s.i32_add(s.getLocal("pr"),s.i32_const(4*eU))),s.call(eX+"_copy",_,s.i32_add(s.getLocal("pr"),s.i32_const(2*eU))));let la=th(t,lt+"_mulNR","ftm",lt),le=function(t){let a=0xd201000000010000n,e=[];for(;a>0n;)tS(a)?e.push(1):e.push(0),a>>=1n;return e}(0xd201000000010000n),ll=t.alloc(le),lo=3*eZ,li=le.length-1,lc=le.reduce((t,a)=>t+ +(0!=a),0),ln=6*eU,ld=3*eU*2+(lc+li+1)*lo;t.modules[eR]={n64q:ej,n64r:eQ,n8q:eU,n8r:eJ,pG1gen:e0,pG1zero:e1,pG1b:eV,pG2gen:e6,pG2zero:e7,pG2b:eY,pq:t.modules.f1m.pq,pr:eW,pOneT:e5,r:0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n,q:0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn,prePSize:ln,preQSize:ld},(f=t.addFunction(lt+"_mul1")).addParam("pA","i32"),f.addParam("pC1","i32"),f.addParam("pR","i32"),g=(u=f.getCodeBuilder()).getLocal("pA"),L=u.i32_add(u.getLocal("pA"),u.i32_const(2*eU)),p=u.i32_add(u.getLocal("pA"),u.i32_const(4*eU)),h=u.getLocal("pC1"),m=u.getLocal("pR"),b=u.i32_add(u.getLocal("pR"),u.i32_const(2*eU)),x=u.i32_add(u.getLocal("pR"),u.i32_const(4*eU)),y=u.i32_const(t.alloc(2*eU)),F=u.i32_const(t.alloc(2*eU)),f.addCode(u.call(eX+"_add",g,L,y),u.call(eX+"_add",L,p,F),u.call(eX+"_mul",L,h,x),u.call(eX+"_mul",F,h,m),u.call(eX+"_sub",m,x,m),u.call(eX+"_mulNR",m,m),u.call(eX+"_mul",y,h,b),u.call(eX+"_sub",b,x,b)),(C=t.addFunction(lt+"_mul01")).addParam("pA","i32"),C.addParam("pC0","i32"),C.addParam("pC1","i32"),C.addParam("pR","i32"),P=(B=C.getCodeBuilder()).getLocal("pA"),A=B.i32_add(B.getLocal("pA"),B.i32_const(2*eU)),q=B.i32_add(B.getLocal("pA"),B.i32_const(4*eU)),v=B.getLocal("pC0"),I=B.getLocal("pC1"),O=B.getLocal("pR"),E=B.i32_add(B.getLocal("pR"),B.i32_const(2*eU)),w=B.i32_add(B.getLocal("pR"),B.i32_const(4*eU)),M=B.i32_const(t.alloc(2*eU)),S=B.i32_const(t.alloc(2*eU)),z=B.i32_const(t.alloc(2*eU)),T=B.i32_const(t.alloc(2*eU)),C.addCode(B.call(eX+"_mul",P,v,M),B.call(eX+"_mul",A,I,S),B.call(eX+"_add",P,A,z),B.call(eX+"_add",P,q,T),B.call(eX+"_add",A,q,O),B.call(eX+"_mul",O,I,O),B.call(eX+"_sub",O,S,O),B.call(eX+"_mulNR",O,O),B.call(eX+"_add",O,M,O),B.call(eX+"_add",v,I,E),B.call(eX+"_mul",E,z,E),B.call(eX+"_sub",E,M,E),B.call(eX+"_sub",E,S,E),B.call(eX+"_mul",T,v,w),B.call(eX+"_sub",w,M,w),B.call(eX+"_add",w,S,w)),(k=t.addFunction(la+"_mul014")).addParam("pA","i32"),k.addParam("pC0","i32"),k.addParam("pC1","i32"),k.addParam("pC4","i32"),k.addParam("pR","i32"),N=(G=k.getCodeBuilder()).getLocal("pA"),R=G.i32_add(G.getLocal("pA"),G.i32_const(6*eU)),j=G.getLocal("pC0"),U=G.getLocal("pC1"),Z=G.getLocal("pC4"),$=G.i32_const(t.alloc(6*eU)),J=G.i32_const(t.alloc(6*eU)),W=G.i32_const(t.alloc(2*eU)),D=G.getLocal("pR"),V=G.i32_add(G.getLocal("pR"),G.i32_const(6*eU)),k.addCode(G.call(lt+"_mul01",N,j,U,$),G.call(lt+"_mul1",R,Z,J),G.call(eX+"_add",U,Z,W),G.call(lt+"_add",R,N,V),G.call(lt+"_mul01",V,j,W,V),G.call(lt+"_sub",V,$,V),G.call(lt+"_sub",V,J,V),G.call(lt+"_copy",J,D),G.call(lt+"_mulNR",D,D),G.call(lt+"_add",D,$,D)),(K=t.addFunction(eR+"_ell")).addParam("pP","i32"),K.addParam("pCoefs","i32"),K.addParam("pF","i32"),Y=(X=K.getCodeBuilder()).getLocal("pP"),H=X.i32_add(X.getLocal("pP"),X.i32_const(eU)),tt=X.getLocal("pF"),ta=X.getLocal("pCoefs"),te=X.i32_add(X.getLocal("pCoefs"),X.i32_const(eU)),tl=X.i32_add(X.getLocal("pCoefs"),X.i32_const(2*eU)),to=X.i32_add(X.getLocal("pCoefs"),X.i32_const(3*eU)),ti=X.i32_add(X.getLocal("pCoefs"),X.i32_const(4*eU)),tc=t.alloc(2*eU),tn=X.i32_const(tc),td=X.i32_const(tc),tr=X.i32_const(tc+eU),ts=t.alloc(2*eU),t_=X.i32_const(ts),tf=X.i32_const(ts),tu=X.i32_const(ts+eU),K.addCode(X.call(eD+"_mul",ta,H,td),X.call(eD+"_mul",te,H,tr),X.call(eD+"_mul",tl,Y,tf),X.call(eD+"_mul",to,Y,tu),X.call(la+"_mul014",tt,ti,t_,tn,tt));let lr=t.alloc(ln),ls=t.alloc(ld);for(let a=0;a<10;a++)!function(a){let e=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8n,0xfc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3n],[0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffffn,0n],[0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2n,0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09n],[0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffen,0n],[0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995n,0x5b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116n],[0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaan,0n],[0xfc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3n,0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8n],[0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaacn,0n],[0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09n,0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2n],[0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaadn,0n],[0x5b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116n,0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995n]]],l=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[0n,0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaacn],[0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffen,0n],[0n,1n],[0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaacn,0n],[0n,0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffen]],[[1n,0n],[0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaadn,0n],[0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaacn,0n],[0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaan,0n],[0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffen,0n],[0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffffn,0n]]],o=t.addFunction(la+"_frobeniusMap"+a);o.addParam("x","i32"),o.addParam("r","i32");let i=o.getCodeBuilder();for(let c=0;c<6;c++){let n=0==c?i.getLocal("x"):i.i32_add(i.getLocal("x"),i.i32_const(c*eZ)),d=i.i32_add(i.getLocal("x"),i.i32_const(c*eZ+eU)),r=0==c?i.getLocal("r"):i.i32_add(i.getLocal("r"),i.i32_const(c*eZ)),s=i.i32_add(i.getLocal("r"),i.i32_const(c*eZ+eU)),_=function(t,a){let e=t[0],l=t[1],o=a[0],i=a[1],c=[(e*o-l*i)%0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn,(e*i+l*o)%0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn];return tz(c[0])&&(c[0]=c[0]+0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn),c}(e[Math.floor(c/3)][a%12],l[c%3][a%6]),f=t.alloc([...Q.bigInt2BytesLE(e3(_[0]),eU),...Q.bigInt2BytesLE(e3(_[1]),eU)]);a%2==1?o.addCode(i.call(eD+"_copy",n,r),i.call(eD+"_neg",d,s),i.call(eX+"_mul",r,i.i32_const(f),r)):o.addCode(i.call(eX+"_mul",n,i.i32_const(f),r))}}(a),t.exportFunction(la+"_frobeniusMap"+a);(tL=t.addFunction(eK+"_inGroupAffine")).addParam("p","i32"),tL.setReturnType("i32"),tx=(tb=tL.getCodeBuilder()).i32_const(t.alloc(Q.bigInt2BytesLE(e3(0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaacn),eU))),tF=tb.i32_const(t.alloc(Q.bigInt2BytesLE(e3(0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffen),eU))),tC=tb.i32_const(t.alloc(Q.bigInt2BytesLE((0xd201000000010000n*0xd201000000010000n-1n)/3n,16))),tB=tb.getLocal("p"),tI=tb.i32_add(tb.getLocal("p"),tb.i32_const(eU)),tO=t.alloc(3*eU),tE=tb.i32_const(tO),tw=tb.i32_const(tO),tT=tb.i32_const(tO+eU),tk=t.alloc(2*eU),tG=tb.i32_const(tk),tN=tb.i32_const(tk),tR=tb.i32_const(tk+eU),tL.addCode(tb.if(tb.call(eK+"_isZeroAffine",tb.getLocal("p")),tb.ret(tb.i32_const(1))),tb.if(tb.i32_eqz(tb.call(eK+"_inCurveAffine",tb.getLocal("p"))),tb.ret(tb.i32_const(0))),tb.call(eD+"_mul",tB,tx,tw),tb.call(eD+"_copy",tI,tT),tb.call(eD+"_mul",tB,tF,tN),tb.call(eD+"_copy",tI,tR),tb.call(eK+"_doubleAffine",tE,tE),tb.call(eK+"_subMixed",tE,tb.getLocal("p"),tE),tb.call(eK+"_subMixed",tE,tG,tE),tb.call(eK+"_timesScalar",tE,tC,tb.i32_const(16),tE),tb.ret(tb.call(eK+"_eqMixed",tE,tG))),(tj=t.addFunction(eK+"_inGroup")).addParam("pIn","i32"),tj.setReturnType("i32"),tZ=(tU=tj.getCodeBuilder()).i32_const(t.alloc(2*eU)),tj.addCode(tU.call(eK+"_toAffine",tU.getLocal("pIn"),tZ),tU.ret(tU.call(eK+"_inGroupAffine",tZ))),(t$=t.addFunction(eH+"_inGroupAffine")).addParam("p","i32"),t$.setReturnType("i32"),tQ=t$.getCodeBuilder(),tJ=tQ.i32_const(t.alloc([...Q.bigInt2BytesLE(e3(0xd0088f51cbff34d258dd3db21a5d66bb23ba5c279c2895fb39869507b587b120f55ffff58a9ffffdcff7fffffffd556n),eU),...Q.bigInt2BytesLE(e3(0xd0088f51cbff34d258dd3db21a5d66bb23ba5c279c2895fb39869507b587b120f55ffff58a9ffffdcff7fffffffd555n),eU)])),tW=tQ.i32_const(t.alloc(Q.bigInt2BytesLE(e3(0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaacn),eU))),tD=tQ.i32_const(t.alloc([...Q.bigInt2BytesLE(e3(0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2n),eU),...Q.bigInt2BytesLE(e3(0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2n),eU)])),tV=tQ.i32_const(t.alloc(Q.bigInt2BytesLE(0xd201000000010000n,8))),tK=tQ.getLocal("p"),tX=tQ.i32_add(tQ.getLocal("p"),tQ.i32_const(eZ)),tY=tQ.i32_const(t.alloc(eU)),tH=tQ.i32_const(t.alloc(eZ)),t2=tQ.i32_const(t.alloc(eZ)),t3=t.alloc(2*eZ),t0=tQ.i32_const(t3),t1=tQ.i32_const(t3),t4=tQ.i32_const(t3),t6=tQ.i32_const(t3+eU),t8=tQ.i32_const(t3+eZ),t7=tQ.i32_const(t3+eZ),t5=tQ.i32_const(t3+eZ+eU),t9=t.alloc(3*eZ),at=tQ.i32_const(t9),aa=tQ.i32_const(t9),ae=tQ.i32_const(t9),al=tQ.i32_const(t9+eU),ao=tQ.i32_const(t9+eZ),ai=tQ.i32_const(t9+eZ),ac=tQ.i32_const(t9+eZ+eU),an=tQ.i32_const(t9+2*eZ),t$.addCode(tQ.if(tQ.call(eH+"_isZeroAffine",tQ.getLocal("p")),tQ.ret(tQ.i32_const(1))),tQ.if(tQ.i32_eqz(tQ.call(eH+"_inCurveAffine",tQ.getLocal("p"))),tQ.ret(tQ.i32_const(0))),tQ.call(eX+"_mul",tK,tJ,tH),tQ.call(eX+"_mul",tX,tJ,t2),tQ.call(eX+"_mul1",tH,tW,t1),tQ.call(eX+"_neg",t2,t8),tQ.call(eX+"_neg",tH,aa),tQ.call(eX+"_mul",t2,tD,ao),tQ.call(eD+"_sub",t4,t6,tY),tQ.call(eD+"_add",t4,t6,t6),tQ.call(eD+"_copy",tY,t4),tQ.call(eD+"_sub",t7,t5,tY),tQ.call(eD+"_add",t7,t5,t5),tQ.call(eD+"_copy",tY,t7),tQ.call(eD+"_add",ae,al,tY),tQ.call(eD+"_sub",ae,al,al),tQ.call(eD+"_copy",tY,ae),tQ.call(eD+"_sub",ac,ai,tY),tQ.call(eD+"_add",ai,ac,ac),tQ.call(eD+"_copy",tY,ai),tQ.call(eX+"_one",an),tQ.call(eH+"_timesScalar",at,tV,tQ.i32_const(8),at),tQ.call(eH+"_addMixed",at,t0,at),tQ.ret(tQ.call(eH+"_eqMixed",at,tQ.getLocal("p")))),(ad=t.addFunction(eH+"_inGroup")).addParam("pIn","i32"),ad.setReturnType("i32"),as=(ar=ad.getCodeBuilder()).i32_const(t.alloc(2*eZ)),ad.addCode(ar.call(eH+"_toAffine",ar.getLocal("pIn"),as),ar.ret(ar.call(eH+"_inGroupAffine",as))),(a_=t.addFunction(eR+"_prepAddStep")).addParam("R","i32"),a_.addParam("Q","i32"),a_.addParam("r","i32"),au=(af=a_.getCodeBuilder()).getLocal("R"),ag=af.i32_add(af.getLocal("R"),af.i32_const(2*eU)),aL=af.i32_add(af.getLocal("R"),af.i32_const(4*eU)),ap=af.getLocal("Q"),ah=af.i32_add(af.getLocal("Q"),af.i32_const(2*eU)),am=af.getLocal("r"),ab=af.i32_add(af.getLocal("r"),af.i32_const(2*eU)),ax=af.i32_add(af.getLocal("r"),af.i32_const(4*eU)),ay=af.i32_const(t.alloc(eZ)),aF=af.i32_const(t.alloc(eZ)),aC=af.i32_const(t.alloc(eZ)),aB=af.i32_const(t.alloc(eZ)),aP=af.i32_const(t.alloc(eZ)),aA=af.i32_const(t.alloc(eZ)),aq=af.i32_const(t.alloc(eZ)),av=af.i32_const(t.alloc(eZ)),aI=af.i32_const(t.alloc(eZ)),aO=af.i32_const(t.alloc(eZ)),aE=af.i32_const(t.alloc(eZ)),a_.addCode(af.call(eX+"_square",aL,ay),af.call(eX+"_square",ah,aF),af.call(eX+"_mul",ay,ap,aB),af.call(eX+"_add",ah,aL,ab),af.call(eX+"_square",ab,ab),af.call(eX+"_sub",ab,aF,ab),af.call(eX+"_sub",ab,ay,ab),af.call(eX+"_mul",ab,ay,ab),af.call(eX+"_sub",aB,au,aP),af.call(eX+"_square",aP,aA),af.call(eX+"_add",aA,aA,aq),af.call(eX+"_add",aq,aq,aq),af.call(eX+"_mul",aq,aP,av),af.call(eX+"_sub",ab,ag,aI),af.call(eX+"_sub",aI,ag,aI),af.call(eX+"_mul",aI,ap,ax),af.call(eX+"_mul",aq,au,aO),af.call(eX+"_square",aI,au),af.call(eX+"_sub",au,av,au),af.call(eX+"_sub",au,aO,au),af.call(eX+"_sub",au,aO,au),af.call(eX+"_add",aL,aP,aL),af.call(eX+"_square",aL,aL),af.call(eX+"_sub",aL,ay,aL),af.call(eX+"_sub",aL,aA,aL),af.call(eX+"_add",ah,aL,am),af.call(eX+"_sub",aO,au,aE),af.call(eX+"_mul",aE,aI,aE),af.call(eX+"_mul",ag,av,aB),af.
1call(eX+"_add",aB,aB,aB),af.call(eX+"_sub",aE,aB,ag),af.call(eX+"_square",am,am),af.call(eX+"_sub",am,aF,am),af.call(eX+"_square",aL,aC),af.call(eX+"_sub",am,aC,am),af.call(eX+"_add",ax,ax,ax),af.call(eX+"_sub",ax,am,ax),af.call(eX+"_add",aL,aL,am),af.call(eX+"_neg",aI,aI),af.call(eX+"_add",aI,aI,ab)),(aw=t.addFunction(eR+"_prepDblStep")).addParam("R","i32"),aw.addParam("r","i32"),aS=(aM=aw.getCodeBuilder()).getLocal("R"),az=aM.i32_add(aM.getLocal("R"),aM.i32_const(2*eU)),aT=aM.i32_add(aM.getLocal("R"),aM.i32_const(4*eU)),ak=aM.getLocal("r"),aG=aM.i32_add(aM.getLocal("r"),aM.i32_const(2*eU)),aN=aM.i32_add(aM.getLocal("r"),aM.i32_const(4*eU)),aR=aM.i32_const(t.alloc(eZ)),aj=aM.i32_const(t.alloc(eZ)),aU=aM.i32_const(t.alloc(eZ)),aZ=aM.i32_const(t.alloc(eZ)),a$=aM.i32_const(t.alloc(eZ)),aw.addCode(aM.call(eX+"_square",aS,ak),aM.call(eX+"_square",az,aj),aM.call(eX+"_square",aj,aU),aM.call(eX+"_add",aj,aS,aG),aM.call(eX+"_square",aG,aG),aM.call(eX+"_sub",aG,ak,aG),aM.call(eX+"_sub",aG,aU,aG),aM.call(eX+"_add",aG,aG,aG),aM.call(eX+"_add",ak,ak,aZ),aM.call(eX+"_add",aZ,ak,aZ),aM.call(eX+"_add",aS,aZ,aN),aM.call(eX+"_square",aZ,a$),aM.call(eX+"_square",aT,aR),aM.call(eX+"_sub",a$,aG,aS),aM.call(eX+"_sub",aS,aG,aS),aM.call(eX+"_add",aT,az,aT),aM.call(eX+"_square",aT,aT),aM.call(eX+"_sub",aT,aj,aT),aM.call(eX+"_sub",aT,aR,aT),aM.call(eX+"_sub",aG,aS,az),aM.call(eX+"_mul",az,aZ,az),aM.call(eX+"_add",aU,aU,aU),aM.call(eX+"_add",aU,aU,aU),aM.call(eX+"_add",aU,aU,aU),aM.call(eX+"_sub",az,aU,az),aM.call(eX+"_mul",aZ,aR,aG),aM.call(eX+"_add",aG,aG,aG),aM.call(eX+"_neg",aG,aG),aM.call(eX+"_square",aN,aN),aM.call(eX+"_sub",aN,ak,aN),aM.call(eX+"_sub",aN,a$,aN),aM.call(eX+"_add",aj,aj,aj),aM.call(eX+"_add",aj,aj,aj),aM.call(eX+"_sub",aN,aj,aN),aM.call(eX+"_mul",aT,aR,ak),aM.call(eX+"_add",ak,ak,ak)),(aQ=t.addFunction(eR+"_prepareG1")).addParam("pP","i32"),aQ.addParam("ppreP","i32"),aJ=aQ.getCodeBuilder(),aQ.addCode(aJ.call(eK+"_normalize",aJ.getLocal("pP"),aJ.getLocal("ppreP"))),(aW=t.addFunction(eR+"_prepareG2")).addParam("pQ","i32"),aW.addParam("ppreQ","i32"),aW.addLocal("pCoef","i32"),aW.addLocal("i","i32"),aV=(aD=aW.getCodeBuilder()).getLocal("pQ"),aK=t.alloc(3*eZ),aX=aD.i32_const(aK),aY=aD.getLocal("ppreQ"),aW.addCode(aD.call(eH+"_normalize",aV,aY),aD.if(aD.call(eH+"_isZero",aY),aD.ret([])),aD.call(eH+"_copy",aY,aX),aD.setLocal("pCoef",aD.i32_add(aD.getLocal("ppreQ"),aD.i32_const(3*eZ)))),aW.addCode(aD.setLocal("i",aD.i32_const(le.length-2)),aD.block(aD.loop(aD.call(eR+"_prepDblStep",aX,aD.getLocal("pCoef")),aD.setLocal("pCoef",aD.i32_add(aD.getLocal("pCoef"),aD.i32_const(lo))),aD.if(aD.i32_load8_s(aD.getLocal("i"),ll),[...aD.call(eR+"_prepAddStep",aX,aY,aD.getLocal("pCoef")),...aD.setLocal("pCoef",aD.i32_add(aD.getLocal("pCoef"),aD.i32_const(lo)))]),aD.br_if(1,aD.i32_eqz(aD.getLocal("i"))),aD.setLocal("i",aD.i32_sub(aD.getLocal("i"),aD.i32_const(1))),aD.br(0)))),(aH=t.addFunction(eR+"_millerLoop")).addParam("ppreP","i32"),aH.addParam("ppreQ","i32"),aH.addParam("r","i32"),aH.addLocal("pCoef","i32"),aH.addLocal("i","i32"),a3=(a2=aH.getCodeBuilder()).getLocal("ppreP"),a0=a2.getLocal("pCoef"),a1=a2.getLocal("r"),aH.addCode(a2.call(la+"_one",a1),a2.if(a2.call(eK+"_isZero",a3),a2.ret([])),a2.if(a2.call(eK+"_isZero",a2.getLocal("ppreQ")),a2.ret([])),a2.setLocal("pCoef",a2.i32_add(a2.getLocal("ppreQ"),a2.i32_const(3*eZ))),a2.setLocal("i",a2.i32_const(le.length-2)),a2.block(a2.loop(a2.call(eR+"_ell",a3,a0,a1),a2.setLocal("pCoef",a2.i32_add(a2.getLocal("pCoef"),a2.i32_const(lo))),a2.if(a2.i32_load8_s(a2.getLocal("i"),ll),[...a2.call(eR+"_ell",a3,a0,a1),...a2.setLocal("pCoef",a2.i32_add(a2.getLocal("pCoef"),a2.i32_const(lo)))]),a2.call(la+"_square",a1,a1),a2.br_if(1,a2.i32_eq(a2.getLocal("i"),a2.i32_const(1))),a2.setLocal("i",a2.i32_sub(a2.getLocal("i"),a2.i32_const(1))),a2.br(0))),a2.call(eR+"_ell",a3,a0,a1)),aH.addCode(a2.call(la+"_conjugate",a1,a1)),(a4=t.addFunction(eR+"_finalExponentiationOld")).addParam("x","i32"),a4.addParam("r","i32"),a6=t.alloc(Q.bigInt2BytesLE(0x2ee1db5dcc825b7e1bda9c0496a1c0a89ee0193d4977b3f7d4507d07363baa13f8d14a917848517badc3a43d1073776ab353f2c30698e8cc7deada9c0aadff5e9cfee9a074e43b9a660835cc872ee83ff3a0f0f1c0ad0d6106feaf4e347aa68ad49466fa927e7bb9375331807a0dce2630d9aa4b113f414386b0e8819328148978e2b0dd39099b86e1ab656d2670d93e4d7acdd350da5359bc73ab61a0c5bf24c374693c49f570bcd2b01f3077ffb10bf24dde41064837f27611212596bc293c8d4c01f25118790f4684d0b9c40a68eb74bb22a40ee7169cdc1041296532fef459f12438dfc8e2886ef965e61a474c5c85b0129127a1b5ad0463434724538411d1676a53b5a62eb34c05739334f46c02c3f0bd0c55d3109cd15948d0a1fad20044ce6ad4c6bec3ec03ef19592004cedd556952c6d8823b19dadd7c2498345c6e5308f1c511291097db60b1749bf9b71a9f9e0100418a3ef0bc627751bbd81367066bca6a4c1b6dcfc5cceb73fc56947a403577dfa9e13c24ea820b09c1d9f7c31759c3635de3f7a3639991708e88adce88177456c49637fd7961be1a4c7e79fb02faa732e2f3ec2bea83d196283313492caa9d4aff1c910e9622d2a73f62537f2701aaef6539314043f7bbce5b78c7869aeb2181a67e49eeed2161daf3f881bd88592d767f67c4717489119226c2f011d4cab803e9d71650a6f80698e2f8491d12191a04406fbc8fbd5f48925f98630e68bfb24c0bcb9b55df57510n,544)),a8=a4.getCodeBuilder(),a4.addCode(a8.call(la+"_exp",a8.getLocal("x"),a8.i32_const(a6),a8.i32_const(544),a8.getLocal("r"))),(a7=t.addFunction(eR+"__cyclotomicSquare")).addParam("x","i32"),a7.addParam("r","i32"),a9=(a5=a7.getCodeBuilder()).getLocal("x"),et=a5.i32_add(a5.getLocal("x"),a5.i32_const(eZ)),ea=a5.i32_add(a5.getLocal("x"),a5.i32_const(2*eZ)),ee=a5.i32_add(a5.getLocal("x"),a5.i32_const(3*eZ)),el=a5.i32_add(a5.getLocal("x"),a5.i32_const(4*eZ)),eo=a5.i32_add(a5.getLocal("x"),a5.i32_const(5*eZ)),ei=a5.getLocal("r"),ec=a5.i32_add(a5.getLocal("r"),a5.i32_const(eZ)),en=a5.i32_add(a5.getLocal("r"),a5.i32_const(2*eZ)),ed=a5.i32_add(a5.getLocal("r"),a5.i32_const(3*eZ)),er=a5.i32_add(a5.getLocal("r"),a5.i32_const(4*eZ)),es=a5.i32_add(a5.getLocal("r"),a5.i32_const(5*eZ)),e_=a5.i32_const(t.alloc(eZ)),ef=a5.i32_const(t.alloc(eZ)),eu=a5.i32_const(t.alloc(eZ)),eg=a5.i32_const(t.alloc(eZ)),eL=a5.i32_const(t.alloc(eZ)),ep=a5.i32_const(t.alloc(eZ)),eh=a5.i32_const(t.alloc(eZ)),em=a5.i32_const(t.alloc(eZ)),a7.addCode(a5.call(eX+"_mul",a9,el,eh),a5.call(eX+"_mulNR",el,e_),a5.c
1all(eX+"_add",a9,e_,e_),a5.call(eX+"_add",a9,el,em),a5.call(eX+"_mul",em,e_,e_),a5.call(eX+"_mulNR",eh,em),a5.call(eX+"_add",eh,em,em),a5.call(eX+"_sub",e_,em,e_),a5.call(eX+"_add",eh,eh,ef),a5.call(eX+"_mul",ee,ea,eh),a5.call(eX+"_mulNR",ea,eu),a5.call(eX+"_add",ee,eu,eu),a5.call(eX+"_add",ee,ea,em),a5.call(eX+"_mul",em,eu,eu),a5.call(eX+"_mulNR",eh,em),a5.call(eX+"_add",eh,em,em),a5.call(eX+"_sub",eu,em,eu),a5.call(eX+"_add",eh,eh,eg),a5.call(eX+"_mul",et,eo,eh),a5.call(eX+"_mulNR",eo,eL),a5.call(eX+"_add",et,eL,eL),a5.call(eX+"_add",et,eo,em),a5.call(eX+"_mul",em,eL,eL),a5.call(eX+"_mulNR",eh,em),a5.call(eX+"_add",eh,em,em),a5.call(eX+"_sub",eL,em,eL),a5.call(eX+"_add",eh,eh,ep),a5.call(eX+"_sub",e_,a9,ei),a5.call(eX+"_add",ei,ei,ei),a5.call(eX+"_add",e_,ei,ei),a5.call(eX+"_add",ef,el,er),a5.call(eX+"_add",er,er,er),a5.call(eX+"_add",ef,er,er),a5.call(eX+"_mul",ep,a5.i32_const(e9),em),a5.call(eX+"_add",em,ee,ed),a5.call(eX+"_add",ed,ed,ed),a5.call(eX+"_add",em,ed,ed),a5.call(eX+"_sub",eL,ea,en),a5.call(eX+"_add",en,en,en),a5.call(eX+"_add",eL,en,en),a5.call(eX+"_sub",eu,et,ec),a5.call(eX+"_add",ec,ec,ec),a5.call(eX+"_add",eu,ec,ec),a5.call(eX+"_add",eg,eo,es),a5.call(eX+"_add",es,es,es),a5.call(eX+"_add",eg,es,es)),eb=(function(t){let a=0xd201000000010000n,e=[];for(;a>0n;){if(tS(a)){let t=2-Number(a%4n);e.push(t),a-=BigInt(t)}else e.push(0);a>>=1n}return e})(0xd201000000010000n).map(t=>-1==t?255:t),ex=t.alloc(eb),(ey=t.addFunction(eR+"__cyclotomicExp_w0")).addParam("x","i32"),ey.addParam("r","i32"),ey.addLocal("bit","i32"),ey.addLocal("i","i32"),eC=(eF=ey.getCodeBuilder()).getLocal("x"),eB=eF.getLocal("r"),eP=eF.i32_const(t.alloc(e$)),ey.addCode(eF.call(la+"_conjugate",eC,eP),eF.call(la+"_one",eB),eF.if(eF.teeLocal("bit",eF.i32_load8_s(eF.i32_const(eb.length-1),ex)),eF.if(eF.i32_eq(eF.getLocal("bit"),eF.i32_const(1)),eF.call(la+"_mul",eB,eC,eB),eF.call(la+"_mul",eB,eP,eB))),eF.setLocal("i",eF.i32_const(eb.length-2)),eF.block(eF.loop(eF.call(eR+"__cyclotomicSquare",eB,eB),eF.if(eF.teeLocal("bit",eF.i32_load8_s(eF.getLocal("i"),ex)),eF.if(eF.i32_eq(eF.getLocal("bit"),eF.i32_const(1)),eF.call(la+"_mul",eB,eC,eB),eF.call(la+"_mul",eB,eP,eB))),eF.br_if(1,eF.i32_eqz(eF.getLocal("i"))),eF.setLocal("i",eF.i32_sub(eF.getL
1ocal("i"),eF.i32_const(1))),eF.br(0)))),ey.addCode(eF.call(la+"_conjugate",eB,eB)),(eA=t.addFunction(eR+"_finalExponentiation")).addParam("x","i32"),eA.addParam("r","i32"),ev=(eq=eA.getCodeBuilder()).getLocal("x"),eI=eq.getLocal("r"),eO=eq.i32_const(t.alloc(e$)),eE=eq.i32_const(t.alloc(e$)),ew=eq.i32_const(t.alloc(e$)),eM=eq.i32_const(t.alloc(e$)),eS=eq.i32_const(t.alloc(e$)),ez=eq.i32_const(t.alloc(e$)),eT=eq.i32_const(t.alloc(e$)),eA.addCode(eq.call(la+"_frobeniusMap6",ev,eO),eq.call(la+"_inverse",ev,eE),eq.call(la+"_mul",eO,eE,ew),eq.call(la+"_copy",ew,eE),eq.call(la+"_frobeniusMap2",ew,ew),eq.call(la+"_mul",ew,eE,ew),eq.call(eR+"__cyclotomicSquare",ew,eE),eq.call(la+"_conjugate",eE,eE),eq.call(eR+"__cyclotomicExp_w0",ew,eM),eq.call(eR+"__cyclotomicSquare",eM,eS),eq.call(la+"_mul",eE,eM,ez),eq.call(eR+"__cyclotomicExp_w0",ez,eE),eq.call(eR+"__cyclotomicExp_w0",eE,eO),eq.call(eR+"__cyclotomicExp_w0",eO,eT),eq.call(la+"_mul",eT,eS,eT),eq.call(eR+"__cyclotomicExp_w0",eT,eS),eq.call(la+"_conjugate",ez,ez),eq.call(la+"_mul",eS,ez,eS),eq.call(la+"_mul",eS,ew,eS),eq.call(la+"_conjugate",ew,ez),eq.call(la+"_mul",eE,ew,eE),eq.call(la+"_frobeniusMap3",eE,eE),eq.call(la+"_mul",eT,ez,eT),eq.call(la+"_frobeniusMap1",eT,eT),eq.call(la+"_mul",eM,eO,eM),eq.call(la+"_frobeniusMap2",eM,eM),eq.call(la+"_mul",eM,eE,eM),eq.call(la+"_mul",eM,eT,eM),eq.call(la+"_mul",eM,eS,eI));for(let a=1;a<=5;a++)!function(a){let e=t.addFunction(eR+"_pairingEq"+a);for(let t=0;t<a;t++)e.addParam("p_"+t,"i32"),e.addParam("q_"+t,"i32");e.addParam("c","i32"),e.setReturnType("i32");let l=e.getCodeBuilder(),o=l.i32_const(t.alloc(e$)),i=l.i32_const(t.alloc(e$));e.addCode(l.call(la+"_one",o));for(let t=0;t<a;t++)e.addCode(l.call(eR+"_prepareG1",l.getLocal("p_"+t),l.i32_const(lr))),e.addCode(l.call(eR+"_prepareG2",l.getLocal("q_"+t),l.i32_const(ls))),e.addCode(l.if(l.i32_eqz(l.call(eK+"_inGroupAffine",l.i32_const(lr))),l.ret(l.i32_const(0))),l.if(l.i32_eqz(l.call(eH+"_inGroupAffine",l.i32_const(ls))),l.ret(l.i32_const(0)))),e.addCode(l.call(eR+"_millerLoop",l.i32_const(lr),l.i32_const(ls),i)),e.addCode(l.call(la+"_mul",o,i,o));e.addCode(l.call(eR+"_finalExponentiation",o,o)),e.addCode(l.call(la+"_eq",o,l.getLocal("c")))}(a),t.exportFunction(eR+"_pairingEq"+a);(ek=t.addFunction(eR+"_pairing")).addParam("p","i32"),ek.addParam("q","i32"),ek.addParam("r","i32"),eN=(eG=ek.getCodeBuilder()).i32_const(t.alloc(e$)),ek.addCode(eG.call(eR+"_prepareG1",eG.getLocal("p"),eG.i32_const(lr))),ek.addCode(eG.call(eR+"_prepareG2",eG.getLocal("q"),eG.i32_const(ls))),ek.addCode(eG.call(eR+"_millerLoop",eG.i32_const(lr),eG.i32_const(ls),eN)),ek.addCode(eG.call(eR+"_finalExponentiation",eN,eG.getLocal("r"))),t.exportFunction(eR+"_pairing"),t.exportFunction(eR+"_prepareG1"),t.exportFunction(eR+"_prepareG2"),t.exportFunction(eR+"_millerLoop"),t.exportFunction(eR+"_finalExponentiation"),t.exportFunction(eR+"_finalExponentiationOld"),t.exportFunction(eR+"__cyclotomicSquare"),t.exportFunction(eR+"__cyclotomicExp_w0"),t.exportFunction(lt+"_mul1"),t.exp
1ortFunction(lt+"_mul01"),t.exportFunction(la+"_mul014"),t.exportFunction(eK+"_inGroupAffine"),t.exportFunction(eK+"_inGroup"),t.exportFunction(eH+"_inGroupAffine"),t.exportFunction(eH+"_inGroup")};function tG(t,a){let e=t;void 0===a&&0==(a=Math.floor((c(t)-1)/8)+1)&&(a=1);let l=new Uint8Array(a),o=new DataView(l.buffer),i=0;for(;i<a;)i+4<=a?(o.setUint32(i,Number(e&BigInt(0xffffffff)),!0),i+=4,e>>=BigInt(32)):i+2<=a?(o.setUint16(i,Number(e&BigInt(65535)),!0),i+=2,e>>=BigInt(16)):(o.setUint8(i,Number(e&BigInt(255)),!0),i+=1,e>>=BigInt(8));if(e)throw Error("Number does not fit in this length");return l}function tN(t,a){if("bigint"==typeof a||void 0!==a.eq)return a.toString(10);if(a instanceof Uint8Array)return t.toString(t.e(a));if(Array.isArray(a))return a.map(tN.bind(this,t));{if("object"!=typeof a)return a;let e={};return Object.keys(a).forEach(l=>{e[l]=tN(t,a[l])}),e}}function tR(t,a){if("string"==typeof a&&/^[0-9]+$/.test(a)||"string"==typeof a&&/^0x[0-9a-fA-F]+$/.test(a))return t.e(a);if(Array.isArray(a))return a.map(tR.bind(this,t));{if("object"!=typeof a)return a;if(null===a)return null;let e={};return Object.keys(a).forEach(l=>{e[l]=tR(t,a[l])}),e}}let tj=[];for(let t=0;t<256;t++)tj[t]=function(t,a){let e=0,l=t;for(let t=0;t<8;t++)e<<=1,e|=1&l,l>>=1;return e}(t,8);function tU(t,a){return(tj[t>>>24]|tj[t>>>16&255]<<8|tj[t>>>8&255]<<16|tj[255&t]<<24)>>>32-a}function tZ(t){return((0xffff0000&t)!=0?(t&=0xffff0000,16):0)|((0xff00ff00&t)!=0?(t&=0xff00ff00,8):0)|((0xf0f0f0f0&t)!=0?(t&=0xf0f0f0f0,4):0)|((0xcccccccc&t)!=0?(t&=0xcccccccc,2):0)|(0xaaaaaaaa&t)!=0}function t$(t,a){let e=t.byteLength/a,l=tZ(e);if(e!=1<<l)throw Error("Invalid number of pointers");for(let o=0;o<e;o++){let e=tU(o,l);if(o>e){let l=t.slice(o*a,(o+1)*a);t.set(t.slice(e*a,(e+1)*a),o*a),t.set(l,e*a)}}}function tQ(t,a){let e=new Uint8Array(a*t.length);for(let l=0;l<t.length;l++)e.set(t[l],l*a);return e}function tJ(t,a){let e=t.byteLength/a,l=Array(e);for(let o=0;o<e;o++)l[o]=t.slice(o*a,o*a+a);return l}var tW=Object.freeze({__proto__:null,array2buffer:tQ,beBuff2int:function(t){let a=BigInt(0),e=t.length,l=0,o=new DataView(t.buffer,t.byteOffset,t.byteLength);for(;e>0;)e>=4?(e-=4,a+=BigInt(o.getUint32(e))<<BigInt(8*l),l+=4):e>=2?(e-=2,a+=BigInt(o.getUint16(e))<<BigInt(8*l),l+=2):(e-=1,a+=BigInt(o.getUint8(e))<<BigInt(8*l),l+=1);return a},beInt2Buff:function(t,a){let e=t,l=new Uint8Array(a),o=new DataView(l.buffer),i=a;for(;i>0;)i-4>=0?(i-=4,o.setUint32(i,Number(e&BigInt(0xffffffff))),e>>=BigInt(32)):i-2>=0?(i-=2,o.setUint16(i,Number(e&BigInt(65535))),e>>=BigInt(16)):(i-=1,o.setUint8(i,Number(e&BigInt(255))),e>>=BigInt(8));if(e)throw Error("Number does not fit in this length");return l},bitReverse:tU,buffReverseBits:t$,buffer2array:tJ,leBuff2int:function(t){let a=BigInt(0),e=0,l=new DataView(t.buffer,t.byteOffset,t.byteLength);for(;e<t.length;)e+4<=t.length?(a+=BigInt(l.getUint32(e,!0))<<BigInt(8*e),e+=4):e+2<=t.length?(a+=BigInt(l.getUint16(e,!0))<<BigInt(8*e),e+=2):(a+=BigInt(l.getUint8(e,!0))<<BigInt(8*e),e+=1);return a},leInt2Buff:tG,log2:tZ,stringifyBigInts:function t(a){if("bigint"==typeof a||void 0!==a.eq)return a.toString(10);if(a instanceof Uint8Array)return q(a,0);if(Array.isArray(a))return a.map(t);{if("object"!=typeof a)return a;let e={};return Object.keys(a).forEach(l=>{e[l]=t(a[l])}),e}},stringifyFElements:tN,unstringifyBigInts:function t(a){if("string"==typeof a&&/^[0-9]+$/.test(a)||"string"==typeof a&&/^0x[0-9a-fA-F]+$/.test(a))return BigInt(a);if(Array.isArray(a))return a.map(t);{if("object"!=typeof a)return a;if(null===a)return null;let e={};return Object.keys(a).forEach(l=>{e[l]=t(a[l])}),e}},unstringifyFElements:tR});class tD{constructor(t){this.buffers=[],this.byteLength=t;for(let a=0;a<t;a+=0x40000000){const e=Math.min(t-a,0x40000000);this.buffers.push(new Uint8Array(e))}}slice(t,a){let e;void 0===a&&(a=this.byteLength),void 0===t&&(t=0);let l=a-t,o=Math.floor(t/0x40000000);if(o==Math.floor((t+l-1)/0x40000000)||0==l)return this.buffers[o].slice(t%0x40000000,t%0x40000000+l);let i=o,c=t%0x40000000,n=l;for(;n>0;){let t=c+n>0x40000000?0x40000000-c:n,a=new Uint8Array(this.buffers[i].buffer,this.buffers[i].byteOffset+c,t);if(t==l)return a.slice();e||(e=l<=0x40000000?new Uint8Array(l):new tD(l)),e.set(a,l-n),n-=t,i++,c=0}return e}set(t,a){void 0===a&&(a=0);let e=t.byteLength;if(0==e)return;let l=Math.floor(a/0x40000000);if(l==Math.floor((a+e-1)/0x40000000))if(t instanceof tD&&1==t.buffers.length)return this.buffers[l].set(t.buffers[0],a%0x40000000);else return this.buffers[l].set(t,a%0x40000000);let o=l,i=a%0x40000000,c=e;for(;c>0;){let a=i+c>0x40000000?0x40000000-i:c,l=t.slice(e-c,e-c+a);new Uint8Array(this.buffers[o].buffer,this.buffers[o].byteOffset+i,a).set(l),c-=a,o++,i=0}}}function tV(t,a,e,l){return async function(o){let i,c=Math.floor(o.byteLength/e);if(c*e!==o.byteLength)throw Error("Invalid buffer size");let n=Math.floor(c/t.concurrency),d=[];for(let i=0;i<t.concurrency;i++){let r;if(0==(r=i<t.concurrency-1?n:c-i*n))continue;let s=[{cmd:"ALLOCSET",var:0,buff:o.slice(i*n*e,i*n*e+r*e)},{cmd:"ALLOC",var:1,len:l*r},{cmd:"CALL",fnName:a,params:[{var:0},{val:r},{var:1}]},{cmd:"GET",out:0,var:1,len:l*r}];d.push(t.queueAction(s))}let r=await Promise.all(d);i=o instanceof tD?new tD(c*l):new Uint8Array(c*l);let s=0;for(let t=0;t<r.length;t++)i.set(r[t][0],s),s+=r[t][0].byteLength;return i}}class tK{constructor(t,a,e,l){if(this.tm=t,this.prefix=a,this.p=l,this.n8=e,this.type="F1",this.m=1,this.half=s(l,w),this.bitLength=c(l),this.mask=L(r(w,this.bitLength),w),this.pOp1=t.alloc(e),this.pOp2=t.alloc(e),this.pOp3=t.alloc(e),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,this.n8),this.tm.instance.exports[a+"_one"](this.pOp1),this.one=this.tm.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.n64=Math.floor(e/8),this.n32=M
1ath.floor(e/4),8*this.n64!=this.n8)throw Error("n8 must be a multiple of 8");this.half=s(this.p,w),this.nqr=this.two;let o=this.exp(this.nqr,this.half);for(;!this.eq(o,this.negone);)this.nqr=this.add(this.nqr,this.one),o=this.exp(this.nqr,this.half);this.shift=this.mul(this.nqr,this.nqr),this.shiftInv=this.inv(this.shift),this.s=0;let i=L(this.p,w);for(;!_(i);)this.s=this.s+1,i=s(i,w);this.w=[],this.w[this.s]=this.exp(this.nqr,i);for(let t=this.s-1;t>=0;t--)this.w[t]=this.square(this.w[t+1]);if(!this.eq(this.w[0],this.one))throw Error("Error calculating roots of unity");this.batchToMontgomery=tV(t,a+"_batchToMontgomery",this.n8,this.n8),this.batchFromMontgomery=tV(t,a+"_batchFromMontgomery",this.n8,this.n8)}op2(t,a,e){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(t,a,e){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,e),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2)}op1(t,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(t,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3)}add(t,a){return this.op2("_add",t,a)}eq(t,a){return this.op2Bool("_eq",t,a)}isZero(t){return this.op1Bool("_isZero",t)}sub(t,a){return this.op2("_sub",t,a)}neg(t){return this.op1("_neg",t)}inv(t){return this.op1("_inverse",t)}toMontgomery(t){return this.op1("_toMontgomery",t)}fromMontgomery(t){return this.op1("_fromMontgomery",t)}mul(t,a){return this.op2("_mul",t,a)}div(t,a){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(t){return this.op1("_square",t)}isSquare(t){return this.op1Bool("_isSquare",t)}sqrt(t){return this.op1("_sqrt",t)}exp(t,a){return a instanceof Uint8Array||(a=O(i(a))),this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}isNegative(t){return this.op1Bool("_isNegative",t)}e(t,a){if(t instanceof Uint8Array)return t;let e=i(t,a);n(e)?(F(e=p(e),this.p)&&(e=x(e,this.p)),e=L(this.p,e)):F(e,this.p)&&(e=x(e,this.p));let l=tG(e,this.n8);return this.toMontgomery(l)}toString(t,a){return I(q(this.fromMontgomery(t),0),a)}fromRng(t){let a,e=new Uint8Array(this.n8);do{a=E;for(let e=0;e<this.n64;e++)a=g(a,r(t.nextU64(),64*e));a=B(a,this.mask)}while(C(a,this.p));return P(e,0,a,this.n8),e}random(){return this.fromRng(R())}toObject(t){return q(this.fromMontgomery(t),0)}fromObject(t){let a=new Uint8Array(this.n8);return P(a,0,t,this.n8),this.toMontgomery(a)}toRprLE(t,a,e){t.set(this.fromMontgomery(e),a)}toRprBE(t,a,e){let l=this.fromMontgomery(e);for(let t=0;t<this.n8/2;t++){let a=l[t];l[t]=l[this.n8-1-t],l[this.n8-1-t]=a}t.set(l,a)}fromRprLE(t,a){a=a||0;let e=t.slice(a,a+this.n8);return this.toMontgomery(e)}async batchInverse(t){let a,e=!1,l=this.n8,o=this.n8;Array.isArray(t)?(t=tQ(t,l),e=!0):t=t.slice(0,t.byteLength);let i=Math.floor(t.byteLength/l);if(i*l!==t.byteLength)throw Error("Invalid buffer size");let c=Math.floor(i/this.tm.concurrency),n=[];for(let a=0;a<this.tm.concurrency;a++){let e;if(0==(e=a<this.tm.concurrency-1?c:i-a*c))continue;let d=[{cmd:"ALLOCSET",var:0,buff:t.slice(a*c*l,a*c*l+e*l)},{cmd:"ALLOC",var:1,len:o*e},{cmd:"CALL",fnName:this.prefix+"_batchInverse",params:[{var:0},{val:l},{val:e},{var:1},{val:o}]},{cmd:"GET",out:0,var:1,len:o*e}];n.push(this.tm.queueAction(d))}let d=await Promise.all(n);a=t instanceof tD?new tD(i*o):new Uint8Array(i*o);let r=0;for(let t=0;t<d.length;t++)a.set(d[t][0],r),r+=d[t][0].byteLength;return e?tJ(a,o):a}}class tX{constructor(t,a,e){this.tm=t,this.prefix=a,this.F=e,this.type="F2",this.m=2*e.m,this.n8=2*this.F.n8,this.n32=2*this.F.n32,this.n64=2*this.F.n64,this.pOp1=t.alloc(2*e.n8),this.pOp2=t.alloc(2*e.n8),this.pOp3=t.alloc(2*e.n8),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=t.getBuff(this.pOp1,this.n8),this.tm.instance.exports[a+"_one"](this.pOp1),this.one=t.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one)}op2(t,a,e){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(t,a,e){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,e),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2)}op1(t,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(t,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3)}add(t,a){return this.op2("_add",t,a)}eq(t,a){return this.op2Bool("_eq",t,a)}isZero(t){return this.op1Bool("_isZero",t)}sub(t,a){return this.op2("_sub",t,a)}neg(t){return this.op1("_neg",t)}inv(t){return this.op1("_inverse",t)}isNegative(t){return this.op1Bool("_isNegative",t)}toMontgomery(t){return this.op1("_toMontgomery",t)}fromMontgomery(t){return this.op1("_fromMontgomery",t)}mul(t,a){return this.op2("_mul",t,a)}mul1(t,a){return this.op2("_mul1",t,a)}div(t,a){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(t){return this.op1("_square",t)}isSquare(t){return this.op1Bool("_isSquare",t)}sqrt(t){return this.op1("_sqrt",t)}exp(t,a){return a instanceof Uint8Array||(a=O(i(a))),this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}e(t,a){if(t instanceof Uint8Array)return t;if(Array.isArray(t)&&2==t.length){let e=this.F.e(t[0],a),l=this.F.e(t[1],a),o=new Uint8Array(2*this.F.n8);return o.set(e),o.set(l,2*this.F.n8),o}throw Error("invalid F2")}toString(t,a){let e=this.F.toString(t.slice(0,this.F.n8),a),l=this.F.toString(t.slice(this.F.n8),a);return`[${e}, ${l}]`}fromRng(t){let a=this.F.fromRng(t),e=this.F.fromRng(t),l=new Uint8Array(2*this.F.n8);return l.set(a),l.set(e,this.F.n8),l}random(){return this.fromRng(R())}toObject(t){return[this.F.toObject(t.slice(0,this.F.n8)),this.F.toObject(t.slice(this.F.n8,2*this.F.n8))]}fromObject(t){let a=new Uint8Array(2*this.F.n8),e=this.F.fromObject(t[0]),l=this.F.fromObject(t[1]);return a.set(e),a.set(l,this.F.n8),a}c1(t){return t.slice(0,this.F.n8)}c2(t){return t.slice(this.F.n8)}}class tY{constructor(t,a,e){this.tm=t,this.prefix=a,this.F=e,this.type="F3",this.m=3*e.m,this.n8=3*this.F.n8,this.n32=3*this.F.n32,this.n64=3*this.F.n64,this.pOp1=t.alloc(3*e.n8),this.pOp2=t.alloc(3*e.n8),this.pOp3=t.alloc(3*e.n8),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=t.getBuff(this.pOp1,this.n8),this.tm.instance.exports[a+"_one"](this.pOp1),this.one=t.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one)}op2(t,a,e){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(t,a,e){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,e),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2)}op1(t,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(t,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3)}eq(t,a){return this.op2Bool("_eq",t,a)}isZero(t){return this.op1Bool("_isZero",t)}add(t,a){return this.op2("_add",t,a)}sub(t,a){return this.op2("_sub",t,a)}neg(t){return this.op1("_neg",t)}inv(t){return this.op1("_inverse",t)}isNegative(t){return this.op1Bool("_isNegative",t)}toMontgomery(t){return this.op1("_toMontgomery",t)}fromMontgomery(t){return this.op1("_fromMontgomery",t)}mul(t,a){return this.op2("_mul",t,a)}div(t,a){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(t){return this.op1("_square",t)}isSquare(t){return this.op1Bool("_isSquare",t)}sqrt(t){return this.op1("_sqrt",t)}exp(t,a){return a instanceof Uint8Array||(a=O(i(a))),this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.getBuff(this.pOp3,this.n8)}e(t,a){if(t instanceof Uint8Array)return t;if(Array.isArray(t)&&3==t.length){let e=this.F.e(t[0],a),l=this.F.e(t[1],a),o=this.F.e(t[2],a),i=new Uint8Array(3*this.F.n8);return i.set(e),i.set(l,this.F.n8),i.set(o,2*this.F.n8),i}throw Error("invalid F3")}toString(t,a){let e=this.F.toString(t.slice(0,this.F.n8),a),l=this.F.toString(t.slice(this.F.n8,2*this.F.n8),a),o=this.F.toString(t.slice(2*this.F.n8),a);return`[${e}, ${l}, ${o}]`}fromRng(t){let a=this.F.fromRng(t),e=this.F.fromRng(t),l=this.F.fromRng(t),o=new Uint8Array(3*this.F.n8);return o.set(a),o.set(e,this.F.n8),o.set(l,2*this.F.n8),o}random(){return this.fromRng(R())}toObject(t){return[this.F.toObject(t.slice(0,this.F.n8)),this.F.toObject(t.slice(this.F.n8,2*this.F.n8)),this.F.toObject(t.slice(2*this.F.n8,3*this.F.n8))]}fromObject(t){let a=new Uint8Array(3*this.F.n8),e=this.F.fromObject(t[0]),l=this.F.fromObject(t[1]),o=this.F.fromObject(t[2]);return a.set(e),a.set(l,this.F.n8),a.set(o,2*this.F.n8),a}c1(t){return t.slice(0,this.F.n8)}c2(t){return t.slice(this.F.n8,2*this.F.n8)}c3(t){return t.slice(2*this.F.n8)}}class tH{constructor(t,a,e,l,o,i){this.tm=t,this.prefix=a,this.F=e,this.pOp1=t.alloc(3*e.n8),this.pOp2=t.alloc(3*e.n8),this.pOp3=t.alloc(3*e.n8),this.tm.instance.exports[a+"_zero"](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,3*e.n8),this.tm.instance.exports[a+"_zeroAffine"](this.pOp1),this.zeroAffine=this.tm.getBuff(this.pOp1,2*e.n8),this.one=this.tm.getBuff(l,3*e.n8),this.g=this.one,this.oneAffine=this.tm.getBuff(l,2*e.n8),this.gAffine=this.oneAffine,this.b=this.tm.getBuff(o,e.n8),i&&(this.cofactor=O(i)),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.batchLEMtoC=tV(t,a+"_batchLEMtoC",2*e.n8,e.n8),this.batchLEMtoU=tV(t,a+"_batchLEMtoU",2*e.n8,2*e.n8),this.batchCtoLEM=tV(t,a+"_batchCtoLEM",e.n8,2*e.n8),this.batchUtoLEM=tV(t,a+"_batchUtoLEM",2*e.n8,2*e.n8),this.batchToJacobian=tV(t,a+"_batchToJacobian",2*e.n8,3*e.n8),this.batchToAffine=tV(t,a+"_batchToAffine",3*e.n8,2*e.n8)}op2(t,a,e){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,3*this.F.n8)}op2bool(t,a,e){return this.tm.setBuff(this.pOp1,a),this.tm.setBuff(this.pOp2,e),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3)}op1(t,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,3*this.F.n8)}op1Affine(t,a){return this.tm.setBuff(this.pOp1,a),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,2*this.F.n8)}op1Bool(t,a){return this.tm.setBuff(this.pOp1,a),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3)}add(t,a){if(t.byteLength==3*this.F.n8)if(a.byteLength==3*this.F.n8)return this.op2("_add",t,a);else if(a.byteLength==2*this.F.n8)return this.op2("_addMixed",t,a);else throw Error("invalid point size");if(t.byteLength==2*this.F.n8){if(a.byteLength==3*this.F.n8)return this.op2("_addMixed",a,t);else if(a.byteLength==2*this.F.n8)return this.op2("_addAffine",t,a)}throw Error("invalid point size")}sub(t,a){if(t.byteLength==3*this.F.n8)if(a.byteLength==3*this.F.n8)return this.op2("_sub",t,a);else if(a.byteLength==2*this.F.n8)return this.op2("_subMixed",t,a);else throw Error("invalid point size");if(t.byteLength==2*this.F.n8){if(a.byteLength==3*this.F.n8)return this.op2("_subMixed",a,t);else if(a.byteLength==2*this.F.n8)return this.op2("_subAffine",t,a)}throw Error("invalid point size")}neg(t){if(t.byteLength==3*this.F.n8)return this.op1("_neg",t);if(t.byteLength==2*this.F.n8)return this.op1Affine("_negAffine",t);throw Error("invalid point size")}double(t){if(t.byteLength==3*this.F.n8)return this.op1("_double",t);if(t.byteLength==2*this.F.n8)return this.op1("_doubleAffine",t);throw Error("invalid point size")}isZero(t){if(t.byteLength==3*this.F.n8)return this.op1Bool("_isZero",t);if(t.byteLength==2*this.F.n8)return this.op1Bool("_isZeroAffine",t);throw Error("invalid point size")}
1timesScalar(t,a){let e;if(a instanceof Uint8Array||(a=O(i(a))),t.byteLength==3*this.F.n8)e=this.prefix+"_timesScalar";else if(t.byteLength==2*this.F.n8)e=this.prefix+"_timesScalarAffine";else throw Error("invalid point size");return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[e](this.pOp1,this.pOp2,a.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,3*this.F.n8)}timesFr(t,a){let e;if(t.byteLength==3*this.F.n8)e=this.prefix+"_timesFr";else if(t.byteLength==2*this.F.n8)e=this.prefix+"_timesFrAffine";else throw Error("invalid point size");return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,a),this.tm.instance.exports[e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,3*this.F.n8)}eq(t,a){if(t.byteLength==3*this.F.n8)if(a.byteLength==3*this.F.n8)return this.op2bool("_eq",t,a);else if(a.byteLength==2*this.F.n8)return this.op2bool("_eqMixed",t,a);else throw Error("invalid point size");if(t.byteLength==2*this.F.n8){if(a.byteLength==3*this.F.n8)return this.op2bool("_eqMixed",a,t);else if(a.byteLength==2*this.F.n8)return this.op2bool("_eqAffine",t,a)}throw Error("invalid point size")}toAffine(t){if(t.byteLength==3*this.F.n8)return this.op1Affine("_toAffine",t);if(t.byteLength==2*this.F.n8)return t;throw Error("invalid point size")}toJacobian(t){if(t.byteLength==3*this.F.n8)return t;if(t.byteLength==2*this.F.n8)return this.op1("_toJacobian",t);throw Error("invalid point size")}toRprUncompressed(t,a,e){if(this.tm.setBuff(this.pOp1,e),e.byteLength==3*this.F.n8)this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);else if(e.byteLength!=2*this.F.n8)throw Error("invalid point size");this.tm.instance.exports[this.prefix+"_LEMtoU"](this.pOp1,this.pOp1);let l=this.tm.getBuff(this.pOp1,2*this.F.n8);t.set(l,a)}fromRprUncompressed(t,a){let e=t.slice(a,a+2*this.F.n8);return this.tm.setBuff(this.pOp1,e),this.tm.instance.exports[this.prefix+"_UtoLEM"](this.pOp1,this.pOp1),this.tm.getBuff(this.pOp1,2*this.F.n8)}toRprCompressed(t,a,e){if(this.tm.setBuff(this.pOp1,e),e.byteLength==3*this.F.n8)this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);else if(e.byteLength!=2*this.F.n8)throw Error("invalid point size");this.tm.instance.exports[this.prefix+"_LEMtoC"](this.pOp1,this.pOp1);let l=this.tm.getBuff(this.pOp1,this.F.n8);t.set(l,a)}fromRprCompressed(t,a){let e=t.slice(a,a+this.F.n8);return this.tm.setBuff(this.pOp1,e),this.tm.instance.exports[this.prefix+"_CtoLEM"](this.pOp1,this.pOp2),this.tm.getBuff(this.pOp2,2*this.F.n8)}toUncompressed(t){let a=new Uint8Array(2*this.F.n8);return this.toRprUncompressed(a,0,t),a}toRprLEM(t,a,e){if(e.byteLength==2*this.F.n8)return void t.set(e,a);if(e.byteLength==3*this.F.n8){this.tm.setBuff(this.pOp1,e),this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);let l=this.tm.getBuff(this.pOp1,2*this.F.n8);t.set(l,a)}else throw Error("invalid point size")}fromRprLEM(t,a){return a=a||0,t.slice(a,a+2*this.F.n8)}toString(t,a){if(t.byteLength==3*this.F.n8){let e=this.F.toString(t.slice(0,this.F.n8),a),l=this.F.toString(t.slice(this.F.n8,2*this.F.n8),a),o=this.F.toString(t.slice(2*this.F.n8),a);return`[ ${e}, ${l}, ${o} ]`}if(t.byteLength==2*this.F.n8){let e=this.F.toString(t.slice(0,this.F.n8),a),l=this.F.toString(t.slice(this.F.n8),a);return`[ ${e}, ${l} ]`}throw Error("invalid point size")}isValid(t){if(this.isZero(t))return!0;let a=this.F,e=this.toAffine(t),l=e.slice(0,this.F.n8),o=e.slice(this.F.n8,2*this.F.n8),i=a.add(a.mul(a.square(l),l),this.b),c=a.square(o);return a.eq(i,c)}fromRng(t){let a,e,l=this.F,o=[];do o[0]=l.fromRng(t),a=t.nextBool(),e=l.add(l.mul(l.square(o[0]),o[0]),this.b);while(!l.isSquare(e));o[1]=l.sqrt(e),a^l.isNegative(o[1])&&(o[1]=l.neg(o[1]));let i=new Uint8Array(2*this.F.n8);return i.set(o[0]),i.set(o[1],this.F.n8),this.cofactor&&(i=this.timesScalar(i,this.cofactor)),i}toObject(t){return this.isZero(t)?[this.F.toObject(this.F.zero),this.F.toObject(this.F.one),this.F.toObject(this.F.zero)]:[this.F.toObject(t.slice(0,this.F.n8)),this.F.toObject(t.slice(this.F.n8,2*this.F.n8)),t.byteLength==3*this.F.n8?this.F.toObject(t.slice(2*this.F.n8,3*this.F.n8)):this.F.toObject(this.F.one)]}fromObject(t){let a,e=this.F.fromObject(t[0]),l=this.F.fromObject(t[1]);if(a=3==t.length?this.F.fromObject(t[2]):this.F.one,this.F.isZero(a,this.F.one))return this.zeroAffine;if(this.F.eq(a,this.F.one)){let t=new Uint8Array(2*this.F.n8);return t.set(e),t.set(l,this.F.n8),t}{let t=new Uint8Array(3*this.F.n8);return t.set(e),t.set(l,this.F.n8),t.set(a,2*this.F.n8),t}}e(t){return t instanceof Uint8Array?t:this.fromObject(t)}x(t){return this.toAffine(t).slice(0,this.F.n8)}y(t){return this.toAffine(t).slice(this.F.n8)}}class t2{constructor(){this.promise=new Promise((t,a)=>{this.reject=a,this.resolve=t})}}let t3=`(function thread(self) { 2 const MAXMEM = 32767; 3 let instance; 4 let memory; 5 6 if (self) { 7 self.onmessage = function(e) { 8 let data; 9 if (e.data) { 10 data = e.data; 11 } else { 12 data = e; 13 } 14 15 if (data[0].cmd == "INIT") { 16 init(data[0]).then(function() { 17 self.postMessage(data.result); 18 }); 19 } else if (data[0].cmd == "TERMINATE") { 20 self.close(); 21 } else { 22 const res = runTask(data); 23 self.postMessage(res); 24 } 25 }; 26 } 27 28 async function init(data) { 29 const code = new Uint8Array(data.code); 30 const wasmModule = await WebAssembly.compile(code); 31 memory = new WebAssembly.Memory({initial:data.init, maximum: MAXMEM}); 32 33 instance = await WebAssembly.instantiate(wasmModule, { 34 env: { 35 "memory": memory 36 } 37 }); 38 } 39 40 41 42 function alloc(length) { 43 const u32 = new Uint32Array(memory.buffer, 0, 1); 44 while (u32[0] & 3) u32[0]++; // Return always aligned pointers 45 const res = u32[0]; 46 u32[0] += length; 47 if (u32[0] + length > memory.buffer.byteLength) { 48 const currentPages = memory.buffer.byteLength / 0x10000; 49 let requiredPages = Math.floor((u32[0] + length) / 0x10000)+1; 50 if (requiredPages>MAXMEM) requiredPages=MAXMEM; 51 memory.grow(requiredPages-currentPages); 52 } 53 return res; 54 } 55 56 function allocBuffer(buffer) { 57 const p = alloc(buffer.byteLength); 58 setBuffer(p, buffer); 59 return p; 60 } 61 62 function getBuffer(pointer, length) { 63 const u8 = new Uint8Array(memory.buffer); 64 return new Uint8Array(u8.buffer, u8.byteOffset + pointer, length); 65 } 66 67 function setBuffer(pointer, buffer) { 68 const u8 = new Uint8Array(memory.buffer); 69 u8.set(new Uint8Array(buffer), pointer); 70 } 71 72 function runTask(task) { 73 if (task[0].cmd == "INIT") { 74 return init(task[0]); 75 } 76 const ctx = { 77 vars: [], 78 out: [] 79 }; 80 const u32a = new Uint32Array(memory.buffer, 0, 1); 81 const oldAlloc = u32a[0]; 82 for (let i=0; i<task.length; i++) { 83 switch (task[i].cmd) { 84 case "ALLOCSET": 85 ctx.vars[task[i].var] = allocBuffer(task[i].buff); 86 break; 87 case "ALLOC": 88 ctx.vars[task[i].var] = alloc(task[i].len); 89 break; 90 case "SET": 91 setBuffer(ctx.vars[task[i].var], task[i].buff); 92 break; 93 case "CALL": { 94 const params = []; 95 for (let j=0; j<task[i].params.length; j++) { 96 const p = task[i].params[j]; 97 if (typeof p.var !== "undefined") { 98 params.push(ctx.vars[p.var] + (p.offset || 0)); 99 }
99 else if (typeof p.val != "undefined") { 100 params.push(p.val); 101 } 102 } 103 instance.exports[task[i].fnName](...params); 104 break; 105 } 106 case "GET": 107 ctx.out[task[i].out] = getBuffer(ctx.vars[task[i].var], task[i].len).slice(); 108 break; 109 default: 110 throw new Error("Invalid cmd"); 111 } 112 } 113 const u32b = new Uint32Array(memory.buffer, 0, 1); 114 u32b[0] = oldAlloc; 115 return ctx.out; 116 } 117 118 119 return runTask; 120})(self)`;if(globalThis?.Blob){let t=new Blob([new TextEncoder().encode(t3)],{type:"application/javascript"});l=URL.createObjectURL(t)}else l="data:application/javascript;base64,"+globalThis.btoa(t3);async function t0(t,a){let e=new t1;e.memory=new WebAssembly.Memory({initial:25}),e.u8=new Uint8Array(e.memory.buffer),e.u32=new Uint32Array(e.memory.buffer);let o=await WebAssembly.compile(t.code);if(e.instance=await WebAssembly.instantiate(o,{env:{memory:e.memory}}),globalThis?.Worker||(a=!0),e.singleThread=a,e.initalPFree=e.u32[0],e.pq=t.pq,e.pr=t.pr,e.pG1gen=t.pG1gen,e.pG1zero=t.pG1zero,e.pG2gen=t.pG2gen,e.pG2zero=t.pG2zero,e.pOneT=t.pOneT,a)e.code=t.code,e.taskManager=function(t){let a,e;async function l(t){let l=new Uint8Array(t.code),o=await WebAssembly.compile(l);e=new WebAssembly.Memory({initial:t.init,maximum:32767}),a=await WebAssembly.instantiate(o,{env:{memory:e}})}function o(t){let a=new Uint32Array(e.buffer,0,1);for(;3&a[0];)a[0]++;let l=a[0];if(a[0]+=t,a[0]+t>e.buffer.byteLength){let l=e.buffer.byteLength/65536,o=Math.floor((a[0]+t)/65536)+1;o>32767&&(o=32767),e.grow(o-l)}return l}function i(t,a){new Uint8Array(e.buffer).set(new Uint8Array(a),t)}return function(t){if("INIT"==t[0].cmd)return l(t[0]);let c=[],n=[],d=new Uint32Array(e.buffer,0,1)[0];for(let l=0;l<t.length;l++)switch(t[l].cmd){case"ALLOCSET":c[t[l].var]=function(t){let a=o(t.byteLength);return i(a,t),a}(t[l].buff);break;case"ALLOC":c[t[l].var]=o(t[l].len);break;case"SET":i(c[t[l].var],t[l].buff);break;case"CALL":{let e=[];for(let a=0;a<t[l].params.length;a++){let o=t[l].params[a];void 0!==o.var?e.push(c[o.var]+(o.offset||0)):void 0!==o.val&&e.push(o.val)}a.exports[t[l].fnName](...e);break}case"GET":n[t[l].out]=(function(t,a){let l=new Uint8Array(e.buffer);return new Uint8Array(l.buffer,l.byteOffset+t,a)})(c[t[l].var],t[l].len).slice();break;default:throw Error("Invalid cmd")}return new Uint32Array(e.buffer,0,1)[0]=d,n}}(),await e.taskManager([{cmd:"INIT",init:25,code:e.code.slice()}]),e.concurrency=1;else{e.workers=[],e.pendingDeferreds=[],e.working=[];let a=2;"object"==typeof navigator&&navigator.hardwareConcurrency&&(a=navigator.hardwareConcurrency),0==a&&(a=2),a>64&&(a=64),e.concurrency=a;for(let t=0;t<a;t++)e.workers[t]=new Worker(l),e.workers[t].addEventListener("message",function(t){return function(a){let l;l=a&&a.data?a.data:a,e.working[t]=!1,e.pendingDeferreds[t].resolve(l),e.processWorks()}}(t)),e.working[t]=!1;let o=[];for(let a=0;a<e.workers.length;a++){let l=t.code.slice();o.push(e.postAction(a,[{cmd:"INIT",init:25,code:l}],[l.buffer]))}await Promise.all(o)}return e}class t1{constructor(){this.actionQueue=[],this.oldPFree=0}startSyncOp(){if(0!=this.oldPFree)throw Error("Sync operation in progress");this.oldPFree=this.u32[0]}endSyncOp(){if(0==this.oldPFree)throw Error("No sync operation in progress");this.u32[0]=this.oldPFree,this.oldPFree=0}postAction(t,a,e,l){if(this.working[t])throw Error("Posting a job t a working worker");return this.working[t]=!0,this.pendingDeferreds[t]=l||new t2,this.workers[t].postMessage(a,e),this.pendingDeferreds[t].promise}processWorks(){for(let t=0;t<this.workers.length&&this.actionQueue.length>0;t++)if(!1==this.working[t]){let a=this.actionQueue.shift();this.postAction(t,a.data,a.transfers,a.deferred)}}queueAction(t,a){let e=new t2;if(this.singleThread){let a=this.taskManager(t);e.resolve(a)}else this.actionQueue.push({data:t,transfers:a,deferred:e}),this.processWorks();return e.promise}resetMemory(){this.u32[0]=this.initalPFree}allocBuff(t){let a=this.alloc(t.byteLength);return this.setBuff(a,t),a}getBuff(t,a){return this.u8.slice(t,t+a)}setBuff(t,a){this.u8.set(new Uint8Array(a),t)}alloc(t){for(;3&this.u32[0];)this.u32[0]++;let a=this.u32[0];return this.u32[0]+=t,a}async terminate(){for(let t=0;t<this.workers.length;t++)this.workers[t].postMessage([{cmd:"TERMINATE"}]);await new Promise(t=>setTimeout(t,200))}}function t4(t,a){let e=t[a],l=t.Fr,o=t.tm;t[a].batchApplyKey=async function(t,i,c,n,d){let r,s,_,f,u,g;if(n=n||"affine",d=d||"affine","G1"==a)"jacobian"==n?(_=3*e.F.n8,r="g1m_batchApplyKey"):(_=2*e.F.n8,r="g1m_batchApplyKeyMixed"),f=3*e.F.n8,"jacobian"==d?u=3*e.F.n8:(s="g1m_batchToAffine",u=2*e.F.n8);else if("G2"==a)"jacobian"==n?(_=3*e.F.n8,r="g2m_batchApplyKey"):(_=2*e.F.n8,r="g2m_batchApplyKeyMixed"),f=3*e.F.n8,"jacobian"==d?u=3*e.F.n8:(s="g2m_batchToAffine",u=2*e.F.n8);else if("Fr"==a)r="frm_batchApplyKey",_=e.n8,f=e.n8,u=e.n8;else throw Error("Invalid group: "+a);let L=Math.floor(t.byteLength/_),p=Math.floor(L/o.concurrency),h=[];c=l.e(c);let m=l.e(i);for(let a=0;a<o.concurrency;a++){let e;if(0==(e=a<o.concurrency-1?p:L-a*p))continue;let i=[];i.push({cmd:"ALLOCSET",var:0,buff:t.slice(a*p*_,a*p*_+e*_)}),i.push({cmd:"ALLOCSET",var:1,buff:m}),i.push({cmd:"ALLOCSET",var:2,buff:c}),i.push({cmd:"ALLOC",var:3,len:e*Math.max(f,u)}),i.push({cmd:"CALL",fnName:r,params:[{var:0},{val:e},{var:1},{var:2},{var:3}]}),s&&i.push({cmd:"CALL",fnName:s,params:[{var:3},{val:e},{var:3}]}),i.push({cmd:"GET",out:0,var:3,len:e*u}),h.push(o.queueAction(i)),m=l.mul(m,l.exp(c,e))}let b=await Promise.all(h);g=t instanceof tD?new tD(L*u):new Uint8Array(L*u);let x=0;for(let t=0;t<b.length;t++)g.set(b[t][0],x),x+=b[t][0].byteLength;return g}}let t6=[1,1,1,1,2,3,4,5,6,7,7,8,9,10,11,12,13,13,14,15,16,16,17,17,17,17,17,17,17,17,17,17];function t8(t,a){let e=t[a],l=e.tm;async function o(t,l,o,i,c){let n,d;if(!(t instanceof Uint8Array))throw i&&i.error(`${c} _multiExpChunk buffBases is not Uint8Array`),Error(`${c} _multiExpChunk buffBases is not Uint8Array`);if(!(l instanceof Uint8Array))throw i&&i.error(`${c} _multiExpChunk buffScalars is not Uint8Array`),Error(`${c} _multiExpChunk buffScalars is not Uint8Array`);if(o=o||"affine","G1"==a)"affine"==o?(d="g1m_multiexpAffine_chunk",n=2*e.F.n8):(d="g1m_multiexp_chunk",n=3*e.F.n8);else if("G2"==a)"affine"==o?(d="g2m_multiexpAffine_chunk",n=2*e.F.n8):(d="g2m_multiexp_chunk",n=3*e.F.n8);else throw Error("Invalid group");let r=Math.floor(t.byteLength/n);if(0==r)return e.zero;let s=Math.floor(l.byteLength/r);if(s*r!=l.byteLength)throw Error("Scalar size does not match");let _=t6[tZ(r)],f=Math.floor((8*s-1)/_)+1,u=[];for(let a=0;a<f;a++){let o=[{cmd:"ALLOCSET",var:0,buff:t},{cmd:"ALLOCSET",var:1,buff:l},{cmd:"ALLOC",var:2,len:3*e.F.n8},{cmd:"CALL",fnName:d,params:[{var:0},{var:1},{val:s},{val:r},{val:a*_},{val:Math.min(8*s-a*_,_)}
120,{var:2}]},{cmd:"GET",out:0,var:2,len:3*e.F.n8}];u.push(e.tm.queueAction(o))}let g=await Promise.all(u),L=e.zero;for(let t=g.length-1;t>=0;t--){if(!e.isZero(L))for(let t=0;t<_;t++)L=e.double(L);L=e.add(L,g[t][0])}return L}async function i(t,i,c,n,d){let r,s;if("G1"==a)r="affine"==c?2*e.F.n8:3*e.F.n8;else if("G2"==a)r="affine"==c?2*e.F.n8:3*e.F.n8;else throw Error("Invalid group");let _=Math.floor(t.byteLength/r);if(0==_)return e.zero;let f=Math.floor(i.byteLength/_);if(f*_!=i.byteLength)throw Error("Scalar size does not match");let u=Math.floor((8*f-1)/t6[tZ(_)])+1;(s=Math.floor(_/(l.concurrency/u)))>4194304&&(s=4194304),s<1024&&(s=1024);let g=[];for(let a=0;a<_;a+=s){n&&n.debug(`Multiexp start: ${d}: ${a}/${_}`);let e=Math.min(_-a,s),l=t.slice(a*r,(a+e)*r),u=i.slice(a*f,(a+e)*f);g.push(o(l,u,c,n,d).then(t=>(n&&n.debug(`Multiexp end: ${d}: ${a}/${_}`),t)))}let L=await Promise.all(g),p=e.zero;for(let t=L.length-1;t>=0;t--)p=e.add(p,L[t]);return p}e.multiExp=async function(t,a,e,l){return await i(t,a,"jacobian",e,l)},e.multiExpAffine=async function(t,a,e,l){return await i(t,a,"affine",e,l)}}function t7(t,a){let e=t[a],l=t.Fr,o=e.tm;async function i(t,i,d,r,s,_){let f,u,g,L,p,h,m,b,x,y,F;d=d||"affine",r=r||"affine","G1"==a?("affine"==d?(f=2*e.F.n8,L="g1m_batchToJacobian"):f=3*e.F.n8,u=3*e.F.n8,i&&(b="g1m_fftFinal"),m="g1m_fftJoin",h="g1m_fftMix","affine"==r?(g=2*e.F.n8,p="g1m_batchToAffine"):g=3*e.F.n8):"G2"==a?("affine"==d?(f=2*e.F.n8,L="g2m_batchToJacobian"):f=3*e.F.n8,u=3*e.F.n8,i&&(b="g2m_fftFinal"),m="g2m_fftJoin",h="g2m_fftMix","affine"==r?(g=2*e.F.n8,p="g2m_batchToAffine"):g=3*e.F.n8):"Fr"==a&&(f=e.n8,u=e.n8,g=e.n8,i&&(b="frm_fftFinal"),h="frm_fftMix",m="frm_fftJoin");let C=!1;Array.isArray(t)?(t=tQ(t,f),C=!0):t=t.slice(0,t.byteLength);let B=t.byteLength/f,P=tZ(B);if(1<<P!=B)throw Error("fft must be multiple of 2");if(P==l.s+1){let a;return(a=i?await n(t,d,r,s,_):await c(t,d,r,s,_),C)?tJ(a,g):a}i&&(x=l.inv(l.e(B))),t$(t,f);let A=Math.min(16384,B),q=B/A;for(;q<o.concurrency&&A>=16;)q*=2,A/=2;let v=tZ(A),I=[];for(let a=0;a<q;a++){s&&s.debug(`${_}: fft ${P} mix start: ${a}/${q}`);let e=[];e.push({cmd:"ALLOC",var:0,len:u*A});let l=t.slice(A*a*f,A*(a+1)*f);e.push({cmd:"SET",var:0,buff:l}),L&&e.push({cmd:"CALL",fnName:L,params:[{var:0},{val:A},{var:0}]});for(let t=1;t<=v;t++)e.push({cmd:"CALL",fnName:h,params:[{var:0},{val:A},{val:t}]});v==P?(b&&(e.push({cmd:"ALLOCSET",var:1,buff:x}),e.push({cmd:"CALL",fnName:b,params:[{var:0},{val:A},{var:1}]})),p&&e.push({cmd:"CALL",fnName:p,params:[{var:0},{val:A},{var:0}]}),e.push({cmd:"GET",out:0,var:0,len:A*g})):e.push({cmd:"GET",out:0,var:0,len:u*A}),I.push(o.queueAction(e).then(t=>(s&&s.debug(`${_}: fft ${P} mix end: ${a}/${q}`),t)))}F=await Promise.all(I);for(let t=0;t<q;t++)F[t]=F[t][0];for(let t=v+1;t<=P;t++){s&&s.debug(`${_}: fft ${P} join: ${t}/${P}`);let a=1<<P-t,e=q/a,i=[];for(let c=0;c<a;c++)for(let n=0;n<e/2;n++){let d=l.exp(l.w[t],n*A),r=l.w[t],f=c*e+n,L=c*e+n+e/2,h=[];h.push({cmd:"ALLOCSET",var:0,buff:F[f]}),h.push({cmd:"ALLOCSET",var:1,buff:F[L]}),h.push({cmd:"ALLOCSET",var:2,buff:d}),h.push({cmd:"ALLOCSET",var:3,buff:r}),h.push({cmd:"CALL",fnName:m,params:[{var:0},{var:1},{val:A},{var:2},{var:3}]}),t==P?(b&&(h.push({cmd:"ALLOCSET",var:4,buff:x}),h.push({cmd:"CALL",fnName:b,params:[{var:0},{val:A},{var:4}]}),h.push({cmd:"CALL",fnName:b,params:[{var:1},{val:A},{var:4}]})),p&&(h.push({cmd:"CALL",fnName:p,params:[{var:0},{val:A},{var:0}]}),h.push({cmd:"CALL",fnName:p,params:[{var:1},{val:A},{var:1}]})),h.push({cmd:"GET",out:0,var:0,len:A*g}),h.push({cmd:"GET",out:1,var:1,len:A*g})):(h.push({cmd:"GET",out:0,var:0,len:A*u}),h.push({cmd:"GET",out:1,var:1,len:A*u})),i.push(o.queueAction(h).then(l=>(s&&s.debug(`${_}: fft ${P} join ${t}/${P} ${c+1}/${a} ${n}/${e/2}`),l)))}let c=await Promise.all(i);for(let t=0;t<a;t++)for(let a=0;a<e/2;a++){let l=t*e+a,o=t*e+a+e/2,i=c.shift();F[l]=i[0],F[o]=i[1]}}if(y=t instanceof tD?new tD(B*g):new Uint8Array(B*g),i){y.set(F[0].slice((A-1)*g));let t=g;for(let a=q-1;a>0;a--)y.set(F[a],t),t+=A*g,delete F[a];y.set(F[0].slice(0,(A-1)*g),t),delete F[0]}else for(let t=0;t<q;t++)y.set(F[t],A*g*t),delete F[t];return C?tJ(y,g):y}async function c(t,a,e,o,c){let n,r,s;n=t.slice(0,t.byteLength/2),r=t.slice(t.byteLength/2,t.byteLength);let _=[];[n,r]=await d(n,r,"fftJoinExt",l.one,l.shift,a,"jacobian",o,c),_.push(i(n,!1,"jacobian",e,o,c)),_.push(i(r,!1,"jacobian",e,o,c));let f=await Promise.all(_);return(s=f[0].byteLength>0x10000000?new tD(2*f[0].byteLength):new Uint8Array(2*f[0].byteLength)).set(f[0]),s.set(f[1],f[0].byteLength),s}async function n(t,a,e,o,c){let n,r,s;n=t.slice(0,t.byteLength/2),r=t.slice(t.byteLength/2,t.byteLength);let _=[];_.push(i(n,!0,a,"jacobian",o,c)),_.push(i(r,!0,a,"jacobian",o,c)),[n,r]=await Promise.all(_);let f=await d(n,r,"fftJoinExtInv",l.one,l.shiftInv,"jacobian",e,o,c);return(s=f[0].byteLength>0x10000000?new tD(2*f[0].byteLength):new Uint8Array(2*f[0].byteLength)).set(f[0]),s.set(f[1],f[0].byteLength),s}async function d(t,i,c,n,d,r,s,_,f){let u,g,L,p,h,m,b,x;if("G1"==a)"affine"==r?(h=2*e.F.n8,g="g1m_batchToJacobian"):h=3*e.F.n8,m=3*e.F.n8,u="g1m_"+c,"affine"==s?(L="g1m_batchToAffine",p=2*e.F.n8):p=3*e.F.n8;else if("G2"==a)"affine"==r?(h=2*e.F.n8,g="g2m_batchToJacobian"):h=3*e.F.n8,u="g2m_"+c,m=3*e.F.n8,"affine"==s?(L="g2m_batchToAffine",p=2*e.F.n8):p=3*e.F.n8;else if("Fr"==a)h=l.n8,p=l.n8,m=l.n8,u="frm_"+c;else throw Error("Invalid group");if(t.byteLength!=i.byteLength)throw Error("Invalid buffer size");let y=Math.floor(t.byteLength/h);if(y!=1<<tZ(y))throw Error("Invalid number of points");let F=Math.floor(y/o.concurrency);F<16&&(F=16),F>65536&&(F=65536);let C=[];for(let a=0;a<y;a+=F){_&&_.debug(`${f}: fftJoinExt Start: ${a}/${y}`);let e=Math.min(y-a,F),c=l.mul(n,l.exp(d,a)),r=[],s=t.slice(a*h,(a+e)*h),b=i.slice(a*h,(a+e)*h);r.push({cmd:"ALLOC",var:0,len:m*e}),r.push({cmd:"SET",var:0,buff:s}
120),r.push({cmd:"ALLOC",var:1,len:m*e}),r.push({cmd:"SET",var:1,buff:b}),r.push({cmd:"ALLOCSET",var:2,buff:c}),r.push({cmd:"ALLOCSET",var:3,buff:d}),g&&(r.push({cmd:"CALL",fnName:g,params:[{var:0},{val:e},{var:0}]}),r.push({cmd:"CALL",fnName:g,params:[{var:1},{val:e},{var:1}]})),r.push({cmd:"CALL",fnName:u,params:[{var:0},{var:1},{val:e},{var:2},{var:3},{val:l.s}]}),L&&(r.push({cmd:"CALL",fnName:L,params:[{var:0},{val:e},{var:0}]}),r.push({cmd:"CALL",fnName:L,params:[{var:1},{val:e},{var:1}]})),r.push({cmd:"GET",out:0,var:0,len:e*p}),r.push({cmd:"GET",out:1,var:1,len:e*p}),C.push(o.queueAction(r).then(t=>(_&&_.debug(`${f}: fftJoinExt End: ${a}/${y}`),t)))}let B=await Promise.all(C);y*p>0x10000000?(b=new tD(y*p),x=new tD(y*p)):(b=new Uint8Array(y*p),x=new Uint8Array(y*p));let P=0;for(let t=0;t<B.length;t++)b.set(B[t][0],P),x.set(B[t][1],P),P+=B[t][0].byteLength;return[b,x]}e.fft=async function(t,a,e,l,o){return await i(t,!1,a,e,l,o)},e.ifft=async function(t,a,e,l,o){return await i(t,!0,a,e,l,o)},e.lagrangeEvaluations=async function(t,o,c,n,r){let s,_;if(o=o||"affine",c=c||"affine","G1"==a)s="affine"==o?2*e.F.n8:3*e.F.n8;else if("G2"==a)s="affine"==o?2*e.F.n8:3*e.F.n8;else if("Fr"==a)s=l.n8;else throw Error("Invalid group");let f=t.byteLength/s,u=tZ(f);if(2**u*s!=t.byteLength)throw n&&n.error("lagrangeEvaluations iinvalid input size"),Error("lagrangeEvaluations invalid Input size");if(u<=l.s)return await e.ifft(t,o,c,n,r);if(u>l.s+1)throw n&&n.error("lagrangeEvaluations input too big"),Error("lagrangeEvaluations input too big");let g=t.slice(0,t.byteLength/2),L=t.slice(t.byteLength/2,t.byteLength),p=l.exp(l.shift,f/2),h=l.inv(l.sub(l.one,p));[g,L]=await d(g,L,"prepareLagrangeEvaluation",h,l.shiftInv,o,"jacobian",n,r+" prep");let m=[];return m.push(i(g,!0,"jacobian",c,n,r+" t0")),m.push(i(L,!0,"jacobian",c,n,r+" t1")),[g,L]=await Promise.all(m),(_=g.byteLength>0x10000000?new tD(2*g.byteLength):new Uint8Array(2*g.byteLength)).set(g),_.set(L,g.byteLength),_},e.fftMix=async function(t){let i,c,n,d=3*e.F.n8;if("G1"==a)i="g1m_fftMix",c="g1m_fftJoin";else if("G2"==a)i="g2m_fftMix",c="g2m_fftJoin";else if("Fr"==a)i="frm_fftMix",c="frm_fftJoin";else throw Error("Invalid group");let r=Math.floor(t.byteLength/d),s=tZ(r),_=1<<tZ(o.concurrency);r<=2*_&&(_=1);let f=r/_,u=tZ(f),g=[];for(let a=0;a<_;a++){let e=[],l=t.slice(a*f*d,(a+1)*f*d);e.push({cmd:"ALLOCSET",var:0,buff:l});for(let t=1;t<=u;t++)e.push({cmd:"CALL",fnName:i,params:[{var:0},{val:f},{val:t}]});e.push({cmd:"GET",out:0,var:0,len:f*d}),g.push(o.queueAction(e))}let L=await Promise.all(g),p=[];for(let t=0;t<L.length;t++)p[t]=L[t][0];for(let t=u+1;t<=s;t++){let a=1<<s-t,e=_/a,i=[];for(let n=0;n<a;n++)for(let a=0;a<e/2;a++){let r=l.exp(l.w[t],a*f),s=l.w[t],_=n*e+a,u=n*e+a+e/2,g=[];g.push({cmd:"ALLOCSET",var:0,buff:p[_]}),g.push({cmd:"ALLOCSET",var:1,buff:p[u]}),g.push({cmd:"ALLOCSET",var:2,buff:r}),g.push({cmd:"ALLOCSET",var:3,buff:s}),g.push({cmd:"CALL",fnName:c,params:[{var:0},{var:1},{val:f},{var:2},{var:3}]}),g.push({cmd:"GET",out:0,var:0,len:f*d}),g.push({cmd:"GET",out:1,var:1,len:f*d}),i.push(o.queueAction(g))}let n=await Promise.all(i);for(let t=0;t<a;t++)for(let a=0;a<e/2;a++){let l=t*e+a,o=t*e+a+e/2,i=n.shift();p[l]=i[0],p[o]=i[1]}}n=t instanceof tD?new tD(r*d):new Uint8Array(r*d);let h=0;for(let t=0;t<_;t++)n.set(p[t],h),h+=p[t].byteLength;return n},e.fftJoin=async function(t,i,c,n){let d,r,s,_=3*e.F.n8;if("G1"==a)d="g1m_fftJoin";else if("G2"==a)d="g2m_fftJoin";else if("Fr"==a)d="frm_fftJoin";else throw Error("Invalid group");if(t.byteLength!=i.byteLength)throw Error("Invalid buffer size");let f=Math.floor(t.byteLength/_);if(f!=1<<tZ(f))throw Error("Invalid number of points");let u=1<<tZ(o.concurrency);f<=2*u&&(u=1);let g=f/u,L=[];for(let a=0;a<u;a++){let e=[],r=l.mul(c,l.exp(n,a*g)),s=t.slice(a*g*_,(a+1)*g*_),f=i.slice(a*g*_,(a+1)*g*_);e.push({cmd:"ALLOCSET",var:0,buff:s}),e.push({cmd:"ALLOCSET",var:1,buff:f}),e.push({cmd:"ALLOCSET",var:2,buff:r}),e.push({cmd:"ALLOCSET",var:3,buff:n}),e.push({cmd:"CALL",fnName:d,params:[{var:0},{var:1},{val:g},{var:2},{var:3}]}),e.push({cmd:"GET",out:0,var:0,len:g*_}),e.push({cmd:"GET",out:1,var:1,len:g*_}),L.push(o.queueAction(e))}let p=await Promise.all(L);t instanceof tD?(r=new tD(f*_),s=new tD(f*_)):(r=new Uint8Array(f*_),s=new Uint8Array(f*_));let h=0;for(let t=0;t<p.length;t++)r.set(p[t][0],h),s.set(p[t][1],h),h+=p[t][0].byteLength;return[r,s]},e.fftFinal=async function(t,l){let i,c,n,d=3*e.F.n8,r=2*e.F.n8;if("G1"==a)i="g1m_fftFinal",c="g1m_batchToAffine";else if("G2"==a)i="g2m_fftFinal",c="g2m_batchToAffine";else throw Error("Invalid group");let s=Math.floor(t.byteLength/d);if(s!=1<<tZ(s))throw Error("Invalid number of points");let _=Math.floor(s/o.concurrency),f=[];for(let a=0;a<o.concurrency;a++){let e;if(0==(e=a<o.concurrency-1?_:s-a*_))continue;let n=[],u=t.slice(a*_*d,(a*_+e)*d);n.push({cmd:"ALLOCSET",var:0,buff:u}),n.push({cmd:"ALLOCSET",var:1,buff:l}),n.push({cmd:"CALL",fnName:i,params:[{var:0},{val:e},{var:1}]}),n.push({cmd:"CALL",fnName:c,params:[{var:0},{val:e},{var:0}]}),n.push({cmd:"GET",out:0,var:0,len:e*r}),f.push(o.queueAction(n))}let u=await Promise.all(f);n=t instanceof tD?new tD(s*r):new Uint8Array(s*r);let g=0;for(let t=u.length-1;t>=0;t--)n.set(u[t][0],g),g+=u[t][0].byteLength;return n}}async function t5(t){let a,e=await t0(t.wasm,t.singleThread),l={};return l.q=i(t.wasm.q.toString()),l.r=i(t.wasm.r.toString()),l.name=t.name,l.tm=e,l.prePSize=t.wasm.prePSize,l.preQSize=t.wasm.preQSize,l.Fr=new tK(e,"frm",t.n8r,t.r),l.F1=new tK(e,"f1m",t.n8q,t.q),l.F2=new tX(e,"f2m",l.F1),l.G1=new tH(e,"g1m",l.F1,t.wasm.pG1gen,t.wasm.pG1b,t.cofactorG1),l.G2=new tH(e,"g2m",l.F2,t.wasm.pG2gen,t.wasm.pG2b,t.cofactorG2),l.F6=new tY(e,"f6m",l.F2),l.F12=new tX(e,"ftm",l.F6),l.Gt=l.F12,t4(l,"G1"),t4(l,"G2"),t4(l,"Fr"),t8(l,"G1"),t8(l,"G2"),t7(l,"G1"),t7(l,"G2"),t7(l,"Fr"),a=l.tm,l.pairing=function(t,e){a.startSyncOp();let o=a.allocBuff(l.G1.toJacobian(t)),i=a.allocBuff(l.G2.toJacobian(e)),c=a.alloc(l.Gt.n8);a.instance.exports[l.name+"_pairing"](o,i,c);let n=a.getBuff(c,l.Gt.n8);return a.endSyncOp(),n},l.pairingEq=async function(){let t,e;arguments.length%2==1?(t=arguments[arguments.length-1],e=(arguments.length-1)/2):(t=l.Gt.one,e=arguments.length/2);let o=[];for(let t=0;t<e;t++){let e=[],i=l.G1.toJacobian(arguments[2*t]);e.push({cmd:"ALLOCSET",var:0,buff:i}),e.push({cmd:"ALLOC",var:1,len:l.prePSize});let c=l.G2.toJacobian(arguments[2*t+1]);e.push({cmd:"ALLOCSET",var:2,buff:c}),e.push({cmd:"ALLOC",var:3,len:l.preQSize}),e.push({cmd:"ALLOC",var:4,len:l.Gt.n8}),e.push({cmd:"CALL",fnName:l.name+"_prepareG1",params:[{var:0},{var:1}]}),e.push({cmd:"CALL",fnName:l.name+"_prepareG2",params:[{var:2},{var:3}]}),e.push({cmd:"CALL",fnName:l.name+"_millerLoop",params:[{var:1},{var:3},{var:4}]}),e.push({cmd:"GET",out:0,var:4,len:l.Gt.n8}),o.push(a.queueAction(e))}let i=await Promise.all(o);a.startSyncOp();let c=a.alloc(l.Gt.n8);a.instance.exports.ftm_one(c);for(let t=0;t<i.length;t++){let e=a.allocBuff(i[t][0]);a.instance.exports.ftm_mul(c,e,c)}a.instance.exports[l.name+"_finalExponentiation"](c,c);let n=a.allocBuff(t),d=!!a.instance.exports.ftm_eq(c,n);return a.endSyncOp(),d},l.prepareG1=function(t){this.tm.startSyncOp();let a=this.tm.allocBuff(t),e=this.tm.alloc(this.prePSize);this.tm.instance.exports[this.name+"_prepareG1"](a,e);let l=this.tm.getBuff(e,this.prePSize);return this.tm.endSyncOp(),l},l.prepareG2=function(t){this.tm.startSyncOp();let a=this.tm.allocBuff(t),e=this.tm.alloc(this.preQSize);this.tm.instance.exports[this.name+"_prepareG2"](a,e);let l=this.tm.getBuff(e,this.preQSize);return this.tm.endSyncOp(),l},l.millerLoop=function(t,a){this.tm.startSyncOp();let e=this.tm.allocBuff(t),l=this.tm.allocBuff(a),o=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+"_millerLoop"](e,l,o);let i=this.tm.getBuff(o,this.Gt.n8);return this.tm.endSyncOp(),i},l.finalExponentiation=function(t){this.tm.startSyncOp();let a=this.tm.allocBuff(t),e=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+"_finalExponentiation"](a,e);let l=this.tm.getBuff(e,this.Gt.n8);return this.tm.endSyncOp(),l},l.array2buffer=function(t,a){let e=new Uint8Array(a*t.length);for(let l=0;l<t.length;l++)e.set(t[l],l*a);return e},l.buffer2array=function(t,a){let e=t.byteLength/a,l=Array(e);for(let o=0;o<e;o++)l[o]=t.slice(o*a,o*a+a);return l},l}function t9(t){return BigInt(t)}function at(t){let a=[],e=t9(t);return a.push(Number(255n&e)),a.push(Number(e>>8n&255n)),a.push(Number(e>>16n&255n)),a.push(Number(e>>24n&255n)),a}function aa(t){let a=function(t){for(var a=[],e=0;e<t.length;e++){var l=t.charCodeAt(e);l<128?a.push(l):l<2048?a.push(192|l>>6,128|63&l):l<55296||l>=57344?a.push(224|l>>12,128|l>>6&63,128|63&l):(e++,l=65536+((1023&l)<<10|1023&t.charCodeAt(e)),a.push(240|l>>18,128|l>>
12012&63,128|l>>6&63,128|63&l))}return a}(t);return[...ai(a.length),...a]}function ae(t){let a=[],e=t9(t);if(e<0n)throw Error("Number cannot be negative");for(;0n!==e;)a.push(Number(127n&e)),e>>=7n;0==a.length&&a.push(0);for(let t=0;t<a.length-1;t++)a[t]=128|a[t];return a}function al(t){var a;let e,l,o=(a=t)<0n?a.toString(2).length-1:a.toString(2).length;t<0?(l=!0,e=(1n<<BigInt(o))+t):(l=!1,e=t9(t));let i=7-o%7,c=ae(e+((1n<<BigInt(i))-1n<<BigInt(o)));return l||(c[c.length-1]=c[c.length-1]&((1<<7-i)-1|128)),c}function ao(t){let a=t9(t);if(a>4294967295n)throw Error("Number too big");if(a>2147483647n&&(a-=4294967296n),a<-2147483648n)throw Error("Number too small");return al(a)}function ai(t){let a=t9(t);if(a>4294967295n)throw Error("Number too big");return ae(a)}function ac(t){return Array.from(t,function(t){return("0"+(255&t).toString(16)).slice(-2)}).join("")}class an{constructor(t){this.func=t,this.functionName=t.functionName,this.module=t.module}setLocal(t,a){let e=this.func.localIdxByName[t];if(void 0===e)throw Error(`Local Variable not defined: Function: ${this.functionName} local: ${t} `);return[...a,33,...ai(e)]}teeLocal(t,a){let e=this.func.localIdxByName[t];if(void 0===e)throw Error(`Local Variable not defined: Function: ${this.functionName} local: ${t} `);return[...a,34,...ai(e)]}getLocal(t){let a=this.func.localIdxByName[t];if(void 0===a)throw Error(`Local Variable not defined: Function: ${this.functionName} local: ${t} `);return[32,...ai(a)]}i64_load8_s(t,a,e){return[...t,48,void 0===e?0:e,...ai(a||0)]}i64_load8_u(t,a,e){return[...t,49,void 0===e?0:e,...ai(a||0)]}i64_load16_s(t,a,e){return[...t,50,void 0===e?1:e,...ai(a||0)]}i64_load16_u(t,a,e){return[...t,51,void 0===e?1:e,...ai(a||0)]}i64_load32_s(t,a,e){return[...t,52,void 0===e?2:e,...ai(a||0)]}i64_load32_u(t,a,e){return[...t,53,void 0===e?2:e,...ai(a||0)]}i64_load(t,a,e){return[...t,41,void 0===e?3:e,...ai(a||0)]}i64_store(t,a,e,l){let o,i,c;return Array.isArray(a)?(o=0,i=3,c=a):Array.isArray(e)?(o=a,i=3,c=e):Array.isArray(l)&&(o=a,i=e,c=l),[...t,...c,55,i,...ai(o)]}i64_store32(t,a,e,l){let o,i,c;return Array.isArray(a)?(o=0,i=2,c=a):Array.isArray(e)?(o=a,i=2,c=e):Array.isArray(l)&&(o=a,i=e,c=l),[...t,...c,62,i,...ai(o)]}i64_store16(t,a,e,l){let o,i,c;return Array.isArray(a)?(o=0,i=1,c=a):Array.isArray(e)?(o=a,i=1,c=e):Array.isArray(l)&&(o=a,i=e,c=l),[...t,...c,61,i,...ai(o)]}i64_store8(t,a,e,l){let o,i,c;return Array.isArray(a)?(o=0,i=0,c=a):Array.isArray(e)?(o=a,i=0,c=e):Array.isArray(l)&&(o=a,i=e,c=l),[...t,...c,60,i,...ai(o)]}i32_load8_s(t,a,e){return[...t,44,void 0===e?0:e,...ai(a||0)]}i32_load8_u(t,a,e){return[...t,45,void 0===e?0:e,...ai(a||0)]}i32_load16_s(t,a,e){return[...t,46,void 0===e?1:e,...ai(a||0)]}i32_load16_u(t,a,e){return[...t,47,void 0===e?1:e,...ai(a||0)]}i32_load(t,a,e){return[...t,40,void 0===e?2:e,...ai(a||0)]}i32_store(t,a,e,l){let o,i,c;return Array.isArray(a)?(o=0,i=2,c=a):Array.isArray(e)?(o=a,i=2,c=e):Array.isArray(l)&&(o=a,i=e,c=l),[...t,...c,54,i,...ai(o)]}i32_store16(t,a,e,l){let o,i,c;return Array.isArray(a)?(o=0,i=1,c=a):Array.isArray(e)?(o=a,i=1,c=e):Array.isArray(l)&&(o=a,i=e,c=l),[...t,...c,59,i,...ai(o)]}i32_store8(t,a,e,l){let o,i,c;return Array.isArray(a)?(o=0,i=0,c=a):Array.isArray(e)?(o=a,i=0,c=e):Array.isArray(l)&&(o=a,i=e,c=l),[...t,...c,58,i,...ai(o)]}call(t,...a){let e=this.module.functionIdxByName[t];if(void 0===e)throw Error(`Function not defined: Function: ${t}`);return[...[].concat(...a),16,...ai(e)]}call_indirect(t,...a){return[...[].concat(...a),...t,17,0,0]}if(t,a,e){return e?[...t,4,64,...a,5,...e,11]:[...t,4,64,...a,11]}block(t){return[2,64,...t,11]}loop(...t){return[3,64,...[].concat(...t),11]}br_if(t,a){return[...a,13,...ai(t)]}br(t){return[12,...ai(t)]}ret(t){return[...t,15]}drop(t){return[...t,26]}i64_const(t){return[66,...function(t){let a=t9(t);if(a>0xffffffffffffffffn)throw Error("Number too big");if(a>0x7fffffffffffffffn&&(a-=0x10000000000000000n),a<-0x8000000000000000n)throw Error("Number too small");return al(a)}(t)]}i32_const(t){return[65,...ao(t)]}i64_eqz(t){return[...t,80]}i64_eq(t,a){return[...t,...a,81]}i64_ne(t,a){return[...t,...a,82]}i64_lt_s(t,a){return[...t,...a,83]}i64_lt_u(t,a){return[...t,...a,84]}i64_gt_s(t,a){return[...t,...a,85]}i64_gt_u(t,a){return[...t,...a,86]}i64_le_s(t,a){return[...t,...a,87]}i64_le_u(t,a){return[...t,...a,88]}i64_ge_s(t,a){return[...t,...a,89]}i64_ge_u(t,a){return[...t,...a,90]}i64_add(t,a){return[...t,...a,124]}i64_sub(t,a){return[...t,...a,125]}i64_mul(t,a){return[...t,...a,126]}i64_div_s(t,a){return[...t,...a,127]}i64_div_u(t,a){return[...t,...a,128]}i64_rem_s(t,a){return[...t,...a,129]}i64_rem_u(t,a){return[...t,...a,130]}i64_and(t,a){return[...t,...a,131]}i64_or(t,a){return[...t,...a,132]}i64_xor(t,a){return[...t,...a,133]}i64_shl(t,a){return[...t,...a,134]}i64_shr_s(t,a){return[...t,...a,135]}i64_shr_u(t,a){return[...t,...a,136]}i64_extend_i32_s(t){return[...t,172]}i64_extend_i32_u(t){return[...t,173]}i64_clz(t){return[...t,121]}i64_ctz(t){return[...t,122]}i32_eqz(t){return[...t,69]}i32_eq(t,a){return[...t,...a,70]}i32_ne(t,a){return[...t,...a,71]}i32_lt_s(t,a){return[...t,...a,72]}i32_lt_u(t,a){return[...t,...a,73]}i32_gt_s(t,a){return[...t,...a,74]}i32_gt_u(t,a){return[...t,...a,75]}i32_le_s(t,a){return[...t,...a,76]}i32_le_u(t,a){return[...t,...a,77]}i32_ge_s(t,a){return[...t,...a,78]}i32_ge_u(t,a){return[...t,...a,79]}i32_add(t,a){return[...t,...a,106]}i32_sub(t,a){return[...t,...a,107]}i32_mul(t,a){return[...t,...a,108]}i32_div_s(t,a){return[...t,...a,109]}i32_div_u(t,a){return[...t,...a,110]}i32_rem_s(t,a){return[...t,...a,111]}i32_rem_u(t,a){return[...t,...a,112]}i32_and(t,a){return[...t,...a,113]}i32_or(t,a){return[...t,...a,114]}i32_xor(t,a){return[...t,...a,115]}i32_shl(t,a){return[...t,...a,116]}i32_shr_s(t,a){return[...t,...a,117]}i32_shr_u(t,a){return[...t,...a,118]}i32_rotl(t,a){return[...t,...a,119]}i32_rotr(t,a){return[...t,...a,120]}i32_wrap_i64(t){return[...t,167]}i32_clz(t){return[...t,103]}i32_ctz(t){return[...t,104]}unreachable(){return[0]}current_memory(){return[63,0]}comment(){return[]}}let ad={i32:127,i64:126,f32:125,f64:124,anyfunc:112,func:96,emptyblock:64};
120class ar{constructor(t,a,e,l,o){if("import"==e)this.fnType="import",this.moduleName=l,this.fieldName=o;else if("internal"==e)this.fnType="internal";else throw Error("Invalid function fnType: "+e);this.module=t,this.fnName=a,this.params=[],this.locals=[],this.localIdxByName={},this.code=[],this.returnType=null,this.nextLocal=0}addParam(t,a){if(this.localIdxByName[t])throw Error(`param already exists. Function: ${this.fnName}, Param: ${t} `);let e=this.nextLocal++;this.localIdxByName[t]=e,this.params.push({type:a})}addLocal(t,a,e){if(this.localIdxByName[t])throw Error(`local already exists. Function: ${this.fnName}, Param: ${t} `);let l=this.nextLocal++;this.localIdxByName[t]=l,this.locals.push({type:a,length:e||1})}setReturnType(t){if(this.returnType)throw Error(`returnType already defined. Function: ${this.fnName}`);this.returnType=t}getSignature(){return[96,...ai(this.params.length),...this.params.map(t=>ad[t.type]),...this.returnType?[1,ad[this.returnType]]:[0]]}getBody(){let t=this.locals.map(t=>[...ai(t.length),ad[t.type]]),a=[...ai(this.locals.length),...[].concat(...t),...this.code,11];return[...ai(a.length),...a]}addCode(...t){this.code.push(...[].concat(...t))}getCodeBuilder(){return new an(this)}}class as{constructor(){this.functions=[],this.functionIdxByName={},this.nImportFunctions=0,this.nInternalFunctions=0,this.memory={pagesSize:1,moduleName:"env",fieldName:"memory"},this.free=8,this.datas=[],this.modules={},this.exports=[],this.functionsTable=[]}build(){return this._setSignatures(),new Uint8Array([...at(0x6d736100),...at(1),...this._buildType(),...this._buildImport(),...this._buildFunctionDeclarations(),...this._buildFunctionsTable(),...this._buildExports(),...this._buildElements(),...this._buildCode(),...this._buildData()])}addFunction(t){if(void 0!==this.functionIdxByName[t])throw Error(`Function already defined: ${t}`);let a=this.functions.length;return this.functionIdxByName[t]=a,this.functions.push(new ar(this,t,"internal")),this.nInternalFunctions++,this.functions[a]}addIimportFunction(t,a,e){if(void 0!==this.functionIdxByName[t])throw Error(`Function already defined: ${t}`);if(this.functions.length>0&&"internal"==this.functions[this.functions.length-1].type)throw Error(`Import functions must be declared before internal: ${t}`);let l=e||t,o=this.functions.length;return this.functionIdxByName[t]=o,this.functions.push(new ar(this,t,"import",a,l)),this.nImportFunctions++,this.functions[o]}setMemory(t,a,e){this.memory={pagesSize:t,moduleName:a||"env",fieldName:e||"memory"}}exportFunction(t,a){let e=a||t;if(void 0===this.functionIdxByName[t])throw Error(`Function not defined: ${t}`);let l=this.functionIdxByName[t];e!=t&&(this.functionIdxByName[e]=l),this.exports.push({exportName:e,idx:l})}addFunctionToTable(t){let a=this.functionIdxByName[t];this.functionsTable.push(a)}addData(t,a){this.datas.push({offset:t,bytes:a})}alloc(t,a){let e,l;(Array.isArray(t)||ArrayBuffer.isView(t))&&void 0===a?(e=t.length,l=t):(e=t,l=a),e=(e-1>>3)+1<<3;let o=this.free;return this.free+=e,l&&this.addData(o,l),o}allocString(t){let a=new globalThis.TextEncoder().encode(t);return this.alloc([...a,0])}_setSignatures(){this.signatures=[];let t={};if(this.functionsTable.length>0){let a=this.functions[this.functionsTable[0]].getSignature();t["s_"+ac(a)]=0,this.signatures.push(a)}for(let a=0;a<this.functions.length;a++){let e=this.functions[a].getSignature(),l="s_"+ac(e);void 0===t[l]&&(t[l]=this.signatures.length,this.signatures.push(e)),this.functions[a].signatureIdx=t[l]}}_buildSection(t,a){return[t,...ai(a.length),...a]}_buildType(){return this._buildSection(1,[...ai(this.signatures.length),...[].concat(...this.signatures)])}_buildImport(){let t=[];t.push([...aa(this.memory.moduleName),...aa(this.memory.fieldName),2,0,...ai(this.memory.pagesSize)]);for(let a=0;a<this.nImportFunctions;a++)t.push([...aa(this.functions[a].moduleName),...aa(this.functions[a].fieldName),0,...ai(this.functions[a].signatureIdx)]);return this._buildSection(2,ai(t.length).concat(...t))}_buildFunctionDeclarations(){let t=[];for(let a=this.nImportFunctions;a<this.nImportFunctions+this.nInternalFunctions;a++)t.push(...ai(this.functions[a].signatureIdx));return this._buildSection(3,[...ai(t.length),...t])}_buildFunctionsTable(){return 0==this.functionsTable.length?[]:this._buildSection(4,[...ai(1),112,0,...ai(this.functionsTable.length)])}_buildElements(){if(0==this.functionsTable.length)return[];let t=[];for(let a=0;a<this.functionsTable.length;a++)t.push(...ai(this.functionsTable[a]));return this._buildSection(9,[...ai(1),...ai(0),65,...ao(0),11,...ai(this.functionsTable.length),...t])}_buildExports(){let t=[];for(let a=0;a<this.exports.length;a++)t.push([...aa(this.exports[a].exportName),0,...ai(this.exports[a].idx)]);return this._buildSection(7,ai(t.length).concat(...t))}_buildCode(){let t=[];for(let a=this.nImportFunctions;a<this.nImportFunctions+this.nInternalFunctions;a++)t.push(this.functions[a].getBody());return this._buildSection(10,ai(t.length).concat(...t))}_buildData(){let t=[];t.push([0,65,0,11,4,...at(this.free)]);for(let a=0;a<this.datas.length;a++)t.push([0,65,...ao(this.datas[a].offset),11,...ai(this.datas[a].bytes.length),...this.datas[a].bytes]);return this._buildSection(11,ai(t.length).concat(...t))}}async function a_(t,a){if(!t&&globalThis.curve_bn128)return globalThis.curve_bn128;let e=new as;e.setMemory(25),tT(e),a&&a(e);let l={};l.code=e.build(),l.pq=e.modules.f1m.pq,l.pr=e.modules.frm.pq,l.pG1gen=e.modules.bn128.pG1gen,l.pG1zero=e.modules.bn128.pG1zero,l.pG1b=e.modules.bn128.pG1b,l.pG2gen=e.modules.bn128.pG2gen,l.pG2zero=e.modules.bn128.pG2zero,l.pG2b=e.modules.bn128.pG2b,l.pOneT=e.modules.bn128.pOneT,l.prePSize=e.modules.bn128.prePSize,l.preQSize=e.modules.bn128.preQSize,l.n8q=32,l.n8r=32,l.q=e.modules.bn128.q,l.r=e.modules.bn128.r;let o={name:"bn128",wasm:l,q:i("21888242871839275222246405745257275088696311157297823662689037894645226208583"),r:i("21888242871839275222246405745257275088548364400416034343698204186575808495617"),n8q:32,n8r:32,cofactorG2:i("30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d",16),singleThread:!!t},c=await t5(o);return c.terminate=async function(){o.singleThread||(globalThis.curve_bn128=null,await this.tm.terminate())},t||(globalThis.curve_bn128=c),c}
120async function af(t,a){if(!t&&globalThis.curve_bls12381)return globalThis.curve_bls12381;let e=new as;e.setMemory(25),tk(e),a&&a(e);let l={};l.code=e.build(),l.pq=e.modules.f1m.pq,l.pr=e.modules.frm.pq,l.pG1gen=e.modules.bls12381.pG1gen,l.pG1zero=e.modules.bls12381.pG1zero,l.pG1b=e.modules.bls12381.pG1b,l.pG2gen=e.modules.bls12381.pG2gen,l.pG2zero=e.modules.bls12381.pG2zero,l.pG2b=e.modules.bls12381.pG2b,l.pOneT=e.modules.bls12381.pOneT,l.prePSize=e.modules.bls12381.prePSize,l.preQSize=e.modules.bls12381.preQSize,l.n8q=48,l.n8r=32,l.q=e.modules.bls12381.q,l.r=e.modules.bls12381.r;let o={name:"bls12381",wasm:l,q:i("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),r:i("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),n8q:48,n8r:32,cofactorG1:i("0x396c8c005555e1568c00aaab0000aaab",16),cofactorG2:i("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5",16),singleThread:!!t},c=await t5(o);return c.terminate=async function(){o.singleThread||(globalThis.curve_bls12381=null,await this.tm.terminate())},t||(globalThis.curve_bls12381=c),c}globalThis.curve_bn128=null,globalThis.curve_bls12381=null;let au=i("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),ag=i("21888242871839275222246405745257275088548364400416034343698204186575808495617");async function aL(t,a,e){let l;if(y(t,ag))l=await a_(a,e);else if(y(t,au))l=await af(a,e);else throw Error(`Curve not supported: ${I(t)}`);return l}i("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),i("21888242871839275222246405745257275088696311157297823662689037894645226208583");let ap=M,ah=tW}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.