@avalabs/avalanchejs
Version:
Avalanche Platform JS Library
13 lines • 180 kB
JavaScript
"use strict";var t=require("@scure/base"),e=require("@noble/hashes/utils"),r=require("@noble/hashes/sha256"),s=require("@noble/hashes/ripemd160"),n=require("util");function o(t,e,r,s){var n,o=arguments.length,a=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,s);else for(var i=t.length-1;i>=0;i--)(n=t[i])&&(a=(o<3?n(a):o>3?n(e,r,a):n(e,r))||a);return o>3&&a&&Object.defineProperty(e,r,a),a}function a(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}const i=Symbol.for("nodejs.util.inspect.custom");function u(t){const e=t.split("-");if(e.length<2)throw new Error(`Invalid address: ${t}`);const r=e[0],s=e[1],[n,o]=d(s);return[r,n,o]}function c(t){return u(t)[2]}function d(e){const{prefix:r,words:s}=t.bech32.decode(e);return[r,t.bech32.fromWords(s)]}function p(e,r){const s=t.bech32.toWords(r);return t.bech32.encode(e,s)}function f(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function l(t,...e){if(!((r=t)instanceof Uint8Array||null!=r&&"object"==typeof r&&"Uint8Array"===r.constructor.name))throw new Error("Expected Uint8Array");var r;if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function h(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}const m=BigInt(2**32-1),x=BigInt(32);function g(t,e=!1){return e?{h:Number(t&m),l:Number(t>>x&m)}:{h:0|Number(t>>x&m),l:0|Number(t&m)}}function b(t,e=!1){let r=new Uint32Array(t.length),s=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:o,l:a}=g(t[n],e);[r[n],s[n]]=[o,a]}return[r,s]}if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function y(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!((e=t)instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name))throw new Error("expected Uint8Array, got "+typeof t);var e;return t}class w{clone(){return this._cloneInto()}}const[I,B,T]=[[],[],[]],O=BigInt(0),S=BigInt(1),v=BigInt(2),A=BigInt(7),E=BigInt(256),k=BigInt(113);for(let t=0,e=S,r=1,s=0;t<24;t++){[r,s]=[s,(2*r+3*s)%5],I.push(2*(5*s+r)),B.push((t+1)*(t+2)/2%64);let n=O;for(let t=0;t<7;t++)e=(e<<S^(e>>A)*k)%E,e&v&&(n^=S<<(S<<BigInt(t))-S);T.push(n)}const[P,D]=b(T,!0),R=(t,e,r)=>r>32?((t,e,r)=>e<<r-32|t>>>64-r)(t,e,r):((t,e,r)=>t<<r|e>>>32-r)(t,e,r),C=(t,e,r)=>r>32?((t,e,r)=>t<<r-32|e>>>64-r)
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */(t,e,r):((t,e,r)=>e<<r|t>>>32-r)(t,e,r);class N extends w{constructor(t,e,r,s=!1,n=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=s,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,f(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var o;this.state=new Uint8Array(200),this.state32=(o=this.state,new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)))}keccak(){!function(t,e=24){const r=new Uint32Array(10);for(let s=24-e;s<24;s++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const s=(e+8)%10,n=(e+2)%10,o=r[n],a=r[n+1],i=R(o,a,1)^r[s],u=C(o,a,1)^r[s+1];for(let r=0;r<50;r+=10)t[e+r]^=i,t[e+r+1]^=u}let e=t[2],n=t[3];for(let r=0;r<24;r++){const s=B[r],o=R(e,n,s),a=C(e,n,s),i=I[r];e=t[i],n=t[i+1],t[i]=o,t[i+1]=a}for(let e=0;e<50;e+=10){for(let s=0;s<10;s++)r[s]=t[e+s];for(let s=0;s<10;s++)t[e+s]^=~r[(s+2)%10]&r[(s+4)%10]}t[0]^=P[s],t[1]^=D[s]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){h(this);const{blockLen:e,state:r}=this,s=(t=y(t)).length;for(let n=0;n<s;){const o=Math.min(e-this.pos,s-n);for(let e=0;e<o;e++)r[this.pos++]^=t[n++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:s}=this;t[r]^=e,128&e&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){h(this,!1),l(t),this.finish();const e=this.state,{blockLen:r}=this;for(let s=0,n=t.length;s<n;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,n-s);t.set(e.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return f(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(function(t,e){l(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:s,rounds:n,enableXOF:o}=this;return t||(t=new N(e,r,s,o,n)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=n,t.suffix=r,t.outputLen=s,t.enableXOF=o,t.destroyed=this.destroyed,t}}const _=((t,e,r)=>function(t){const e=e=>t().update(y(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}((()=>new N(e,t,r))))(1,136,32),U=BigInt(0),V=BigInt(1),L=BigInt(2);function M(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}const F=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function q(t){if(!M(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=F[t[r]];return e}function X(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function j(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}const H=48,G=57,W=65,Z=70,K=97,$=102;function z(t){return t>=H&&t<=G?t-H:t>=W&&t<=Z?t-(W-10):t>=K&&t<=$?t-(K-10):void 0}function Y(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const s=new Uint8Array(r);for(let e=0,n=0;e<r;e++,n+=2){const r=z(t.charCodeAt(n)),o=z(t.charCodeAt(n+1));if(void 0===r||void 0===o){const e=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+n)}s[e]=16*r+o}return s}function J(t){return j(q(t))}function Q(t){if(!M(t))throw new Error("Uint8Array expected");return j(q(Uint8Array.from(t).reverse()))}function tt(t,e){return Y(t.toString(16).padStart(2*e,"0"))}function et(t,e){return tt(t,e).reverse()}function rt(t,e,r){let s;if("string"==typeof e)try{s=Y(e)}catch(r){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${r}`)}else{if(!M(e))throw new Error(`${t} must be hex string or Uint8Array`);s=Uint8Array.from(e)}const n=s.length;if("number"==typeof r&&n!==r)throw new Error(`${t} expected ${r} bytes, got ${n}`);return s}function st(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];if(!M(s))throw new Error("Uint8Array expected");e+=s.length}let r=new Uint8Array(e),s=0;for(let e=0;e<t.length;e++){const n=t[e];r.set(n,s),s+=n.length}return r}function nt(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function ot(t){let e;for(e=0;t>U;t>>=V,e+=1);return e}function at(t,e){return t>>BigInt(e)&V}const it=t=>(L<<BigInt(t-1))-V,ut=t=>new Uint8Array(t),ct=t=>Uint8Array.from(t);function dt(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let s=ut(t),n=ut(t),o=0;const a=()=>{s.fill(1),n.fill(0),o=0},i=(...t)=>r(n,s,...t),u=(t=ut())=>{n=i(ct([0]),t),s=i(),0!==t.length&&(n=i(ct([1]),t),s=i())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){s=i();const e=s.slice();r.push(e),t+=s.length}return st(...r)};return(t,e)=>{let r;for(a(),u(t);!(r=e(c()));)u();return a(),r}}const pt={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||M(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function ft(t,e,r={}){const s=(e,r,s)=>{const n=pt[r];if("function"!=typeof n)throw new Error(`Invalid validator "${r}", expected function`);const o=t[e];if(!(s&&void 0===o||n(o,t)))throw new Error(`Invalid param ${String(e)}=${o} (${typeof o}), expected ${r}`)};for(const[t,r]of Object.entries(e))s(t,r,!1);for(const[t,e]of Object.entries(r))s(t,e,!0);return t}var lt=Object.freeze({__proto__:null,bitGet:at,bitLen:ot,bitMask:it,bitSet:(t,e,r)=>t|(r?V:U)<<BigInt(e),bytesToHex:q,bytesToNumberBE:J,bytesToNumberLE:Q,concatBytes:st,createHmacDrbg:dt,ensureBytes:rt,equalBytes:function(t,e){if(t.length!==e.length)return!1;let r=0;for(let s=0;s<t.length;s++)r|=t[s]^e[s];return 0===r},hexToBytes:Y,hexToNumber:j,isBytes:M,numberToBytesBE:tt,numberToBytesLE:et,numberToHexUnpadded:X,numberToVarBytesBE:function(t){return Y(X(t))},utf8ToBytes:nt,validateObject:ft});
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ht=BigInt(0),mt=BigInt(1),xt=BigInt(2),gt=BigInt(3),bt=BigInt(4),yt=BigInt(5),wt=BigInt(8);function It(t,e){const r=t%e;return r>=ht?r:e+r}function Bt(t,e,r){if(r<=ht||e<ht)throw new Error("Expected power/modulo > 0");if(r===mt)return ht;let s=mt;for(;e>ht;)e&mt&&(s=s*t%r),t=t*t%r,e>>=mt;return s}function Tt(t,e,r){let s=t;for(;e-- >ht;)s*=s,s%=r;return s}function Ot(t,e){if(t===ht||e<=ht)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=It(t,e),s=e,n=ht,o=mt;for(;r!==ht;){const t=s%r,e=n-o*(s/r);s=r,r=t,n=o,o=e}if(s!==mt)throw new Error("invert: does not exist");return It(n,e)}function St(t){if(t%bt===gt){const e=(t+mt)/bt;return function(t,r){const s=t.pow(r,e);if(!t.eql(t.sqr(s),r))throw new Error("Cannot find square root");return s}}if(t%wt===yt){const e=(t-yt)/wt;return function(t,r){const s=t.mul(r,xt),n=t.pow(s,e),o=t.mul(r,n),a=t.mul(t.mul(o,xt),n),i=t.mul(o,t.sub(a,t.ONE));if(!t.eql(t.sqr(i),r))throw new Error("Cannot find square root");return i}}return function(t){const e=(t-mt)/xt;let r,s,n;for(r=t-mt,s=0;r%xt===ht;r/=xt,s++);for(n=xt;n<t&&Bt(n,e,t)!==t-mt;n++);if(1===s){const e=(t+mt)/bt;return function(t,r){const s=t.pow(r,e);if(!t.eql(t.sqr(s),r))throw new Error("Cannot find square root");return s}}const o=(r+mt)/xt;return function(t,a){if(t.pow(a,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let i=s,u=t.pow(t.mul(t.ONE,n),r),c=t.pow(a,o),d=t.pow(a,r);for(;!t.eql(d,t.ONE);){if(t.eql(d,t.ZERO))return t.ZERO;let e=1;for(let r=t.sqr(d);e<i&&!t.eql(r,t.ONE);e++)r=t.sqr(r);const r=t.pow(u,mt<<BigInt(i-e-1));u=t.sqr(r),c=t.mul(c,r),d=t.mul(d,u),i=e}return c}}(t)}BigInt(9),BigInt(16);const vt=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function At(t){return ft(t,vt.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}function Et(t,e,r){if(r<ht)throw new Error("Expected power > 0");if(r===ht)return t.ONE;if(r===mt)return e;let s=t.ONE,n=e;for(;r>ht;)r&mt&&(s=t.mul(s,n)),n=t.sqr(n),r>>=mt;return s}function kt(t,e){const r=new Array(e.length),s=e.reduce(((e,s,n)=>t.is0(s)?e:(r[n]=e,t.mul(e,s))),t.ONE),n=t.inv(s);return e.reduceRight(((e,s,n)=>t.is0(s)?e:(r[n]=t.mul(e,r[n]),t.mul(e,s))),n),r}function Pt(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function Dt(t,e,r=!1,s={}){if(t<=ht)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:n,nByteLength:o}=Pt(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const a=St(t),i=Object.freeze({ORDER:t,BITS:n,BYTES:o,MASK:it(n),ZERO:ht,ONE:mt,create:e=>It(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return ht<=e&&e<t},is0:t=>t===ht,isOdd:t=>(t&mt)===mt,neg:e=>It(-e,t),eql:(t,e)=>t===e,sqr:e=>It(e*e,t),add:(e,r)=>It(e+r,t),sub:(e,r)=>It(e-r,t),mul:(e,r)=>It(e*r,t),pow:(t,e)=>Et(i,t,e),div:(e,r)=>It(e*Ot(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>Ot(e,t),sqrt:s.sqrt||(t=>a(i,t)),invertBatch:t=>kt(i,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?et(t,o):tt(t,o),fromBytes:t=>{if(t.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${t.length}`);return r?Q(t):J(t)}});return Object.freeze(i)}function Rt(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Ct(t){const e=Rt(t);return e+Math.ceil(e/2)}function Nt(t,e,r=!1){const s=t.length,n=Rt(e),o=Ct(e);if(s<16||s<o||s>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${s}`);const a=It(r?J(t):Q(t),e-mt)+mt;return r?et(a,n):tt(a,n)}
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _t=BigInt(0),Ut=BigInt(1);function Vt(t){return At(t.Fp),ft(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Pt(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:Lt,hexToBytes:Mt}=lt,Ft={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=Ft;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],s=t.subarray(2,r+2);if(!r||s.length!==r)throw new e("Invalid signature integer: wrong length");if(128&s[0])throw new e("Invalid signature integer: negative");if(0===s[0]&&!(128&s[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Lt(s),l:t.subarray(r+2)}},toSig(t){const{Err:e}=Ft,r="string"==typeof t?Mt(t):t;if(!M(r))throw new Error("ui8a expected");let s=r.length;if(s<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==s-2)throw new e("Invalid signature: incorrect length");const{d:n,l:o}=Ft._parseInt(r.subarray(2)),{d:a,l:i}=Ft._parseInt(o);if(i.length)throw new e("Invalid signature: left bytes after parsing");return{r:n,s:a}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},s=e(r(t.s)),n=e(r(t.r)),o=s.length/2,a=n.length/2,i=r(o),u=r(a);return`30${r(a+o+4)}02${u}${n}02${i}${s}`}},qt=BigInt(0),Xt=BigInt(1),jt=BigInt(2),Ht=BigInt(3),Gt=BigInt(4);function Wt(t){const e=function(t){const e=Vt(t);ft(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:s,a:n}=e;if(r){if(!s.eql(n,s.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,s=e.toBytes||((t,e,s)=>{const n=e.toAffine();return st(Uint8Array.from([4]),r.toBytes(n.x),r.toBytes(n.y))}),n=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function o(t){const{a:s,b:n}=e,o=r.sqr(t),a=r.mul(o,t);return r.add(r.add(a,r.mul(t,s)),n)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(t){return"bigint"==typeof t&&qt<t&&t<e.n}function i(t){if(!a(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(t){const{allowedPrivateKeyLengths:r,nByteLength:s,wrapPrivateKey:n,n:o}=e;if(r&&"bigint"!=typeof t){if(M(t)&&(t=q(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*s,"0")}let a;try{a="bigint"==typeof t?t:J(rt("private key",t,s))}catch(e){throw new Error(`private key must be ${s} bytes, hex or bigint, not ${typeof t}`)}return n&&(a=It(a,o)),i(a),a}const c=new Map;function d(t){if(!(t instanceof p))throw new Error("ProjectivePoint expected")}class p{constructor(t,e,s){if(this.px=t,this.py=e,this.pz=s,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==s||!r.isValid(s))throw new Error("z required")}static fromAffine(t){const{x:e,y:s}=t||{};if(!t||!r.isValid(e)||!r.isValid(s))throw new Error("invalid affine point");if(t instanceof p)throw new Error("projective point not allowed");const n=t=>r.eql(t,r.ZERO);return n(e)&&n(s)?p.ZERO:new p(e,s,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(p.fromAffine)}static fromHex(t){const e=p.fromAffine(n(rt("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return p.BASE.multiply(u(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:s}=this.toAffine();if(!r.isValid(t)||!r.isValid(s))throw new Error("bad point: x or y not FE");const n=r.sqr(s),a=o(t);if(!r.eql(n,a))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){d(t);const{px:e,py:s,pz:n}=this,{px:o,py:a,pz:i}=t,u=r.eql(r.mul(e,i),r.mul(o,n)),c=r.eql(r.mul(s,i),r.mul(a,n));return u&&c}negate(){return new p(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:s}=e,n=r.mul(s,Ht),{px:o,py:a,pz:i}=this;let u=r.ZERO,c=r.ZERO,d=r.ZERO,f=r.mul(o,o),l=r.mul(a,a),h=r.mul(i,i),m=r.mul(o,a);return m=r.add(m,m),d=r.mul(o,i),d=r.add(d,d),u=r.mul(t,d),c=r.mul(n,h),c=r.add(u,c),u=r.sub(l,c),c=r.add(l,c),c=r.mul(u,c),u=r.mul(m,u),d=r.mul(n,d),h=r.mul(t,h),m=r.sub(f,h),m=r.mul(t,m),m=r.add(m,d),d=r.add(f,f),f=r.add(d,f),f=r.add(f,h),f=r.mul(f,m),c=r.add(c,f),h=r.mul(a,i),h=r.add(h,h),f=r.mul(h,m),u=r.sub(u,f),d=r.mul(h,l),d=r.add(d,d),d=r.add(d,d),new p(u,c,d)}add(t){d(t);const{px:s,py:n,pz:o}=this,{px:a,py:i,pz:u}=t;let c=r.ZERO,f=r.ZERO,l=r.ZERO;const h=e.a,m=r.mul(e.b,Ht);let x=r.mul(s,a),g=r.mul(n,i),b=r.mul(o,u),y=r.add(s,n),w=r.add(a,i);y=r.mul(y,w),w=r.add(x,g),y=r.sub(y,w),w=r.add(s,o);let I=r.add(a,u);return w=r.mul(w,I),I=r.add(x,b),w=r.sub(w,I),I=r.add(n,o),c=r.add(i,u),I=r.mul(I,c),c=r.add(g,b),I=r.sub(I,c),l=r.mul(h,w),c=r.mul(m,b),l=r.add(c,l),c=r.sub(g,l),l=r.add(g,l),f=r.mul(c,l),g=r.add(x,x),g=r.add(g,x),b=r.mul(h,b),w=r.mul(m,w),g=r.add(g,b),b=r.sub(x,b),b=r.mul(h,b),w=r.add(w,b),x=r.mul(g,w),f=r.add(f,x),x=r.mul(I,w),c=r.mul(y,c),c=r.sub(c,x),x=r.mul(y,g),l=r.mul(I,l),l=r.add(l,x),new p(c,f,l)}subtract(t){return this.add(t.negate())}is0(){return this.equals(p.ZERO)}wNAF(t){return l.wNAFCached(this,c,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(p.fromAffine)}))}multiplyUnsafe(t){const s=p.ZERO;if(t===qt)return s;if(i(t),t===Xt)return this;const{endo:n}=e;if(!n)return l.unsafeLadder(this,t);let{k1neg:o,k1:a,k2neg:u,k2:c}=n.splitScalar(t),d=s,f=s,h=this;for(;a>qt||c>qt;)a&Xt&&(d=d.add(h)),c&Xt&&(f=f.add(h)),h=h.double(),a>>=Xt,c>>=Xt;return o&&(d=d.negate()),u&&(f=f.negate()),f=new p(r.mul(f.px,n.beta),f.py,f.pz),d.add(f)}multiply(t){i(t);let s,n,o=t;const{endo:a}=e;if(a){const{k1neg:t,k1:e,k2neg:i,k2:u}=a.splitScalar(o);let{p:c,f:d}=this.wNAF(e),{p:f,f:h}=this.wNAF(u);c=l.constTimeNegate(t,c),f=l.constTimeNegate(i,f),f=new p(r.mul(f.px,a.beta),f.py,f.pz),s=c.add(f),n=d.add(h)}else{const{p:t,f:e}=this.wNAF(o);s=t,n=e}return p.normalizeZ([s,n])[0]}multiplyAndAddUnsafe(t,e,r){const s=p.BASE,n=(t,e)=>e!==qt&&e!==Xt&&t.equals(s)?t.multiply(e):t.multiplyUnsafe(e),o=n(this,e).add(n(t,r));return o.is0()?void 0:o}toAffine(t){const{px:e,py:s,pz:n}=this,o=this.is0();null==t&&(t=o?r.ONE:r.inv(n));const a=r.mul(e,t),i=r.mul(s,t),u=r.mul(n,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:i}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===Xt)return!0;if(r)return r(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===Xt?this:r?r(p,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),s(p,this,t)}toHex(t=!0){return q(this.toRawBytes(t))}}p.BASE=new p(e.Gx,e.Gy,r.ONE),p.ZERO=new p(r.ZERO,r.ONE,r.ZERO);const f=e.nBitLength,l=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},s=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let s=t.ZERO,n=e;for(;r>_t;)r&Ut&&(s=s.add(n)),n=n.double(),r>>=Ut;return s},precomputeWindow(t,e){const{windows:r,windowSize:n}=s(e),o=[];let a=t,i=a;for(let t=0;t<r;t++){i=a,o.push(i);for(let t=1;t<n;t++)i=i.add(a),o.push(i);a=i.double()}return o},wNAF(e,n,o){const{windows:a,windowSize:i}=s(e);let u=t.ZERO,c=t.BASE;const d=BigInt(2**e-1),p=2**e,f=BigInt(e);for(let t=0;t<a;t++){const e=t*i;let s=Number(o&d);o>>=f,s>i&&(s-=p,o+=Ut);const a=e,l=e+Math.abs(s)-1,h=t%2!=0,m=s<0;0===s?c=c.add(r(h,n[a])):u=u.add(r(m,n[l]))}return{p:u,f:c}},wNAFCached(t,e,r,s){const n=t._WINDOW_SIZE||1;let o=e.get(t);return o||(o=this.precomputeWindow(t,n),1!==n&&e.set(t,s(o))),this.wNAF(n,o,r)}}}(p,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:p,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:a}}function Zt(t){const e=function(t){const e=Vt(t);return ft(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:r,n:s}=e,n=r.BYTES+1,o=2*r.BYTES+1;function a(t){return It(t,s)}function i(t){return Ot(t,s)}const{ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:d,isWithinCurveOrder:p}=Wt({...e,toBytes(t,e,s){const n=e.toAffine(),o=r.toBytes(n.x),a=st;return s?a(Uint8Array.from([e.hasEvenY()?2:3]),o):a(Uint8Array.from([4]),o,r.toBytes(n.y))},fromBytes(t){const e=t.length,s=t[0],a=t.subarray(1);if(e!==n||2!==s&&3!==s){if(e===o&&4===s){return{x:r.fromBytes(a.subarray(0,r.BYTES)),y:r.fromBytes(a.subarray(r.BYTES,2*r.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${n} compressed bytes or ${o} uncompressed bytes`)}{const t=J(a);if(!(qt<(i=t)&&i<r.ORDER))throw new Error("Point is not on curve");const e=d(t);let n=r.sqrt(e);return!(1&~s)!==((n&Xt)===Xt)&&(n=r.neg(n)),{x:t,y:n}}var i}}),f=t=>q(tt(t,e.nByteLength));function l(t){return t>s>>Xt}const h=(t,e,r)=>J(t.slice(e,r));class m{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=rt("compactSignature",t,2*r),new m(h(t,0,r),h(t,r,2*r))}static fromDER(t){const{r:e,s:r}=Ft.toSig(rt("DER",t));return new m(e,r)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new m(this.r,this.s,t)}recoverPublicKey(t){const{r:s,s:n,recovery:o}=this,c=y(rt("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const d=2===o||3===o?s+e.n:s;if(d>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const p=1&o?"03":"02",l=u.fromHex(p+f(d)),h=i(d),m=a(-c*h),x=a(n*h),g=u.BASE.multiplyAndAddUnsafe(l,m,x);if(!g)throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return l(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Y(this.toDERHex())}toDERHex(){return Ft.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Y(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const x={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=Ct(e.n);return Nt(e.randomBytes(t),e.n)},precompute:(t=8,e=u.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function g(t){const e=M(t),r="string"==typeof t,s=(e||r)&&t.length;return e?s===n||s===o:r?s===2*n||s===2*o:t instanceof u}const b=e.bits2int||function(t){const r=J(t),s=8*t.length-e.nBitLength;return s>0?r>>BigInt(s):r},y=e.bits2int_modN||function(t){return a(b(t))},w=it(e.nBitLength);function I(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(qt<=t&&t<w))throw new Error(`bigint expected < 2^${e.nBitLength}`);return tt(t,e.nByteLength)}function B(t,s,n=T){if(["recovered","canonical"].some((t=>t in n)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:d}=e;let{lowS:f,prehash:h,extraEntropy:x}=n;null==f&&(f=!0),t=rt("msgHash",t),h&&(t=rt("prehashed msgHash",o(t)));const g=y(t),w=c(s),B=[I(w),I(g)];if(null!=x){const t=!0===x?d(r.BYTES):x;B.push(rt("extraEntropy",t))}const O=st(...B),S=g;return{seed:O,k2sig:function(t){const e=b(t);if(!p(e))return;const r=i(e),s=u.BASE.multiply(e).toAffine(),n=a(s.x);if(n===qt)return;const o=a(r*a(S+n*w));if(o===qt)return;let c=(s.x===n?0:2)|Number(s.y&Xt),d=o;return f&&l(o)&&(d=function(t){return l(t)?a(-t):t}(o),c^=1),new m(n,d,c)}}}const T={lowS:e.lowS,prehash:!1},O={lowS:e.lowS,prehash:!1};return u.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return u.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(g(t))throw new Error("first arg must be private key");if(!g(e))throw new Error("second arg must be public key");return u.fromHex(e).multiply(c(t)).toRawBytes(r)},sign:function(t,r,s=T){const{seed:n,k2sig:o}=B(t,r,s),a=e;return dt(a.hash.outputLen,a.nByteLength,a.hmac)(n,o)},verify:function(t,r,s,n=O){const o=t;if(r=rt("msgHash",r),s=rt("publicKey",s),"strict"in n)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:d}=n;let p,f;try{if("string"==typeof o||M(o))try{p=m.fromDER(o)}catch(t){if(!(t instanceof Ft.Err))throw t;p=m.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:t,s:e}=o;p=new m(t,e)}}f=u.fromHex(s)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&p.hasHighS())return!1;d&&(r=e.hash(r));const{r:l,s:h}=p,x=y(r),g=i(h),b=a(x*g),w=a(l*g),I=u.BASE.multiplyAndAddUnsafe(f,b,w)?.toAffine();return!!I&&a(I.x)===l},ProjectivePoint:u,Signature:m,utils:x}}function Kt(t,e){if(At(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=function(t,e){const r=t.ORDER;let s=qt;for(let t=r-Xt;t%jt===qt;t/=jt)s+=Xt;const n=s,o=jt<<n-Xt-Xt,a=o*jt,i=(r-Xt)/a,u=(i-Xt)/jt,c=a-Xt,d=o,p=t.pow(e,i),f=t.pow(e,(i+Xt)/jt);let l=(e,r)=>{let s=p,o=t.pow(r,c),a=t.sqr(o);a=t.mul(a,r);let i=t.mul(e,a);i=t.pow(i,u),i=t.mul(i,o),o=t.mul(i,r),a=t.mul(i,e);let l=t.mul(a,o);i=t.pow(l,d);let h=t.eql(i,t.ONE);o=t.mul(a,f),i=t.mul(l,s),a=t.cmov(o,a,h),l=t.cmov(i,l,h);for(let e=n;e>Xt;e--){let r=e-jt;r=jt<<r-Xt;let n=t.pow(l,r);const i=t.eql(n,t.ONE);o=t.mul(a,s),s=t.mul(s,s),n=t.mul(l,s),a=t.cmov(o,a,i),l=t.cmov(n,l,i)}return{isValid:h,value:a}};if(t.ORDER%Gt===Ht){const r=(t.ORDER-Ht)/Gt,s=t.sqrt(t.neg(e));l=(e,n)=>{let o=t.sqr(n);const a=t.mul(e,n);o=t.mul(o,a);let i=t.pow(o,r);i=t.mul(i,a);const u=t.mul(i,s),c=t.mul(t.sqr(i),n),d=t.eql(c,e);return{isValid:d,value:t.cmov(u,i,d)}}}return l}(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return s=>{let n,o,a,i,u,c,d,p;n=t.sqr(s),n=t.mul(n,e.Z),o=t.sqr(n),o=t.add(o,n),a=t.add(o,t.ONE),a=t.mul(a,e.B),i=t.cmov(e.Z,t.neg(o),!t.eql(o,t.ZERO)),i=t.mul(i,e.A),o=t.sqr(a),c=t.sqr(i),u=t.mul(c,e.A),o=t.add(o,u),o=t.mul(o,a),c=t.mul(c,i),u=t.mul(c,e.B),o=t.add(o,u),d=t.mul(n,a);const{isValid:f,value:l}=r(o,c);p=t.mul(n,s),p=t.mul(p,l),d=t.cmov(d,a,f),p=t.cmov(p,l,f);const h=t.isOdd(s)===t.isOdd(p);return p=t.cmov(t.neg(p),p,h),d=t.div(d,i),{x:d,y:p}}}const $t=J;function zt(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);const r=Array.from({length:e}).fill(0);for(let s=e-1;s>=0;s--)r[s]=255&t,t>>>=8;return new Uint8Array(r)}function Yt(t,e){const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t[s]^e[s];return r}function Jt(t){if(!M(t))throw new Error("Uint8Array expected")}function Qt(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function te(t,e,r){ft(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:n,m:o,hash:a,expand:i,DST:u}=r;Jt(t),Qt(e);const c=function(t){if(M(t))return t;if("string"==typeof t)return nt(t);throw new Error("DST must be Uint8Array or string")}(u),d=s.toString(2).length,p=Math.ceil((d+n)/8),f=e*o*p;let l;if("xmd"===i)l=function(t,e,r,s){Jt(t),Jt(e),Qt(r),e.length>255&&(e=s(st(nt("H2C-OVERSIZE-DST-"),e)));const{outputLen:n,blockLen:o}=s,a=Math.ceil(r/n);if(a>255)throw new Error("Invalid xmd length");const i=st(e,zt(e.length,1)),u=zt(0,o),c=zt(r,2),d=new Array(a),p=s(st(u,t,c,zt(0,1),i));d[0]=s(st(p,zt(1,1),i));for(let t=1;t<=a;t++){const e=[Yt(p,d[t-1]),zt(t+1,1),i];d[t]=s(st(...e))}return st(...d).slice(0,r)}(t,c,f,a);else if("xof"===i)l=function(t,e,r,s,n){if(Jt(t),Jt(e),Qt(r),e.length>255){const t=Math.ceil(2*s/8);e=n.create({dkLen:t}).update(nt("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return n.create({dkLen:r}).update(t).update(zt(r,2)).update(e).update(zt(e.length,1)).digest()}(t,c,f,n,a);else{if("_internal_pass"!==i)throw new Error('expand must be "xmd" or "xof"');l=t}const h=new Array(e);for(let t=0;t<e;t++){const e=new Array(o);for(let r=0;r<o;r++){const n=p*(r+t*o),a=l.subarray(n,n+p);e[r]=It($t(a),s)}h[t]=e}return h}function ee(t,e){const r=e.map((t=>Array.from(t).reverse()));return(e,s)=>{const[n,o,a,i]=r.map((r=>r.reduce(((r,s)=>t.add(t.mul(r,e),s)))));return e=t.div(n,o),s=t.mul(s,t.div(a,i)),{x:e,y:s}}}function re(t,e,r){if("function"!=typeof e)throw new Error("mapToCurve() must be defined");return{hashToCurve(s,n){const o=te(s,2,{...r,DST:r.DST,...n}),a=t.fromAffine(e(o[0])),i=t.fromAffine(e(o[1])),u=a.add(i).clearCofactor();return u.assertValidity(),u},encodeToCurve(s,n){const o=te(s,1,{...r,DST:r.encodeDST,...n}),a=t.fromAffine(e(o[0])).clearCofactor();return a.assertValidity(),a}}}class se extends w{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");f(t.outputLen),f(t.blockLen)}(t);const r=y(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,n=new Uint8Array(s);n.set(r.length>s?t.create().update(r).digest():r);for(let t=0;t<n.length;t++)n[t]^=54;this.iHash.update(n),this.oHash=t.create();for(let t=0;t<n.length;t++)n[t]^=106;this.oHash.update(n),n.fill(0)}update(t){return h(this),this.iHash.update(t),this}digestInto(t){h(this),l(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:s,destroyed:n,blockLen:o,outputLen:a}=this;return t.finished=s,t.destroyed=n,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ne=(t,e,r)=>new se(t,e).update(r).digest();
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
function oe(t){return{hash:t,hmac:(r,...s)=>ne(t,r,e.concatBytes(...s)),randomBytes:e.randomBytes}}ne.create=(t,e)=>new se(t,e);
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const ae=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ie=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ue=BigInt(1),ce=BigInt(2),de=(t,e)=>(t+e/ce)/e;const pe=Dt(ae,void 0,void 0,{sqrt:function(t){const e=ae,r=BigInt(3),s=BigInt(6),n=BigInt(11),o=BigInt(22),a=BigInt(23),i=BigInt(44),u=BigInt(88),c=t*t*t%e,d=c*c*t%e,p=Tt(d,r,e)*d%e,f=Tt(p,r,e)*d%e,l=Tt(f,ce,e)*c%e,h=Tt(l,n,e)*l%e,m=Tt(h,o,e)*h%e,x=Tt(m,i,e)*m%e,g=Tt(x,u,e)*x%e,b=Tt(g,i,e)*m%e,y=Tt(b,r,e)*d%e,w=Tt(y,a,e)*h%e,I=Tt(w,s,e)*c%e,B=Tt(I,ce,e);if(!pe.eql(pe.sqr(B),t))throw new Error("Cannot find square root");return B}}),fe=function(t,e){const r=e=>Zt({...t,...oe(e)});return Object.freeze({...r(e),create:r})}({a:BigInt(0),b:BigInt(7),Fp:pe,n:ie,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=ie,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),s=-ue*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),n=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,a=BigInt("0x100000000000000000000000000000000"),i=de(o*t,e),u=de(-s*t,e);let c=It(t-i*r-u*n,e),d=It(-i*s-u*o,e);const p=c>a,f=d>a;if(p&&(c=e-c),f&&(d=e-d),c>a||d>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:p,k1:c,k2neg:f,k2:d}}}},r.sha256);BigInt(0),fe.ProjectivePoint,Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));
/*! micro-eth-signer - MIT License (c) 2021 Paul Miller (paulmillr.com) */
const le=t=>fe.getPublicKey(t,!1),he=t=>fe.ProjectivePoint.fromHex(t).toRawBytes(!1);function me(t){return/^0x/i.test(t)?t:`0x${t}`}function xe(t){return t.replace(/^0x/i,"")}function ge(t){return e.hexToBytes(xe(t))}const be={fromPrivateKey:t=>("string"==typeof t&&(t=ge(t)),be.fromPublicKey(le(t))),fromPublicKey(t){const r=he(t),s=e.bytesToHex(_(r.subarray(1,65))).slice(24);return be.checksum(s)},checksum(t){const r=xe(t.toLowerCase());if(40!==r.length)throw new Error("Invalid address, must have 40 chars");const s=xe(e.bytesToHex(_(r)));let n="";for(let t=0;t<r.length;t++){const e=Number.parseInt(s[t],16);let o=r[t];e>7&&(o=o.toUpperCase()),n+=o}return me(n)},verifyChecksum(t){const r=xe(t);if(40!==r.length)throw new Error("Invalid address, must have 40 chars");if(r===r.toLowerCase()||r===r.toUpperCase())return!0;const s=e.bytesToHex(_(r.toLowerCase()));for(let t=0;t<40;t++){const e=r[t],n=Number.parseInt(s[t],16);if(n>7&&e.toUpperCase()!==e)return!1;if(n<=7&&e.toLowerCase()!==e)return!1}return!0}};function ye(t){return BigInt(Ie(t))}function we(t){return Number.parseInt(e.bytesToHex(t),16)}function Ie(t){return me(e.bytesToHex(t))}function Be(t){return 1&(t=xe(t)).length&&(t="0"+t),e.hexToBytes(t)}function Te(t,e){const r=e-t.length;if(r<=0)return t;const s=new Uint8Array(e);return s.set(t,r),s}const Oe=t=>{let e=0;for(let r=0;r<t.length;r++){let s=t[r];for(;0!==s;)e+=1&s,s>>=1}return e};class Se{}const ve="AVM",Ae="EVM",Ee="PVM",ke=[ve,Ae,Ee];var Pe,De;exports.TypeSymbols=void 0,(Pe=exports.TypeSymbols||(exports.TypeSymbols={})).Codec="codec",Pe.BaseTx="avax.BaseTx",Pe.TransferableOutput="avax.TransferableOutput",Pe.TransferableInput="avax.TransferableInput",Pe.TransferableOp="avax.TransferableOp",Pe.UTXOID="avax.UTXOID",Pe.UTXO="avax.Utxo",Pe.Id="common.Id",Pe.Address="common.Address",Pe.NodeId="common.NodeId",Pe.BlsSignature="common.BlsSignature",Pe.Int="primitives.Int",Pe.BigIntPr="primitives.BigInt",Pe.StringPr="primitives.String",Pe.Byte="primitives.Byte",Pe.Bytes="primitives.Bytes",Pe.Short="primitives.Short",Pe.Input="secp256k1fx.Input",Pe.TransferInput="secp256k1fx.TransferInput",Pe.TransferOutput="secp256k1fx.TransferOutput",Pe.OutputOwners="secp256k1fx.OutputOwners",Pe.OutputOwnersList="secp256k1fx.OutputOwnersList",Pe.Credential="secp256k1fx.Credential",Pe.Signature="secp256k1fx.Signature",Pe.SecpMintOperation="secp256k1fx.MintOperation",Pe.SecpMintOutput="secp256k1fx.MintOutput",Pe.NftFxMintOperation="nftfx.MintOperation",Pe.NftFxMintOutput="nftfx.MintOutput",Pe.NftFxTransferOperation="nftfx.TransferOperation",Pe.NftFxTransferOutput="nftfx.TransferOutput",Pe.NftFxCredential="nftfx.Credential",Pe.AvmBaseTx="avm.BaseTx",Pe.AvmExportTx="avm.ExportTx",Pe.AvmImportTx="avm.ImportTx",Pe.CreateAssetTx="avm.CreateAssetTx",Pe.OperationTx="avm.OperationTx",Pe.InitialState="avm.InitialState",Pe.AvmSignedTx="avm.SignedTx",Pe.PvmBaseTx="pvm.BaseTx",Pe.StakeableLockIn="pvm.StakeableLockIn",Pe.StakeableLockOut="pvm.StakeableLockOut",Pe.AddDelegatorTx="pvm.AddDelegatorTx",Pe.AddValidatorTx="pvm.AddValidatorTx",Pe.AddPermissionlessDelegatorTx="pvm.AddPermissionlessDelegator",Pe.AddPermissionlessValidatorTx="pvm.AddPermissionlessValidator",Pe.Validator="pvm.Validator",Pe.SubnetValidator="pvm.SubnetValidator",Pe.Signer="pvm.signer",Pe.SignerEmpty="pvm.signerEmpty",Pe.ProofOfPossession="pvm.proofOfPossession",Pe.AddSubnetValidatorTx="pvm.AddSubnetValidator",Pe.AdvanceTimeTx="pvm.AdvanceTimeTx",Pe.CreateChainTx="pvm.CreateChainTx",Pe.CreateSubnetTx="pvm.CreateSubnetTx",Pe.PvmExportTx="pvm.ExportTx",Pe.PvmImportTx="pvm.ImportTx",Pe.RewardValidatorTx="pvm.RewardValidatorTx",Pe.RemoveSubnetValidatorTx="pvm.RemoveSubnetValidator",Pe.TransformSubnetTx="pvm.TransformSubnetTx",Pe.TransferSubnetOwnershipTx="pvm.TransferSubnetOwnershipTx",Pe.L1Validator="pvm.L1Validator",Pe.ConvertSubnetToL1Tx="pvm.ConvertSubnetToL1Tx",Pe.RegisterL1ValidatorTx="pvm.RegisterL1ValidatorTx",Pe.SetL1ValidatorWeightTx="pvm.SetL1ValidatorWeightTx",Pe.IncreaseL1ValidatorBalanceTx="pvm.IncreaseL1ValidatorBalanceTx",Pe.DisableL1ValidatorTx="pvm.DisableL1ValidatorTx",Pe.PChainOwner="pvm.PChainOwner",Pe.EvmExportTx="evm.ExportTx",Pe.EvmInput="evm.Input",Pe.EvmOutput="evm.Output",Pe.EvmImportTx="evm.ImportTx",Pe.WarpMessage="warp.Message",Pe.WarpUnsignedMessage="warp.UnsignedMessage",Pe.WarpSignature="warp.Signature",exports.Address=De=class extends Se{address;_type=exports.TypeSymbols.Address;constructor(t){super(),this.address=t}static fromBytes(t){return[new De(t.slice(0,20)),t.slice(20)]}[i](t,e){return e.stylize(this.toJSON(),"string")}toJSON(t="avax"){return this.toString(t)}static fromString(t){return new De(c(t))}static fromHex(t){return new De(Be(t))}toHex(){return Ie(this.address)}toBytes(){return Te(this.address,20)}toString(t="avax"){return p(t,this.address)}value(){return this.toString()}},exports.Address=De=o([t=>{},a("design:paramtypes",[Uint8Array])],exports.Address);const Re=BigInt(2),Ce=BigInt(3);
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const Ne=BigInt(0),_e=BigInt(1),Ue=BigInt(2),Ve=BigInt(3),Le=BigInt(4),Me=BigInt(8),Fe=BigInt(16),qe=BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),Xe=Dt(qe),je=Dt(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),He=({c0:t,c1:e},{c0:r,c1:s})=>({c0:Xe.add(t,r),c1:Xe.add(e,s)}),Ge=({c0:t,c1:e},{c0:r,c1:s})=>({c0:Xe.sub(t,r),c1:Xe.sub(e,s)}),We=({c0:t,c1:e},r)=>{if("bigint"==typeof r)return{c0:Xe.mul(t,r),c1:Xe.mul(e,r)};const{c0:s,c1:n}=r;let o=Xe.mul(t,s),a=Xe.mul(e,n);return{c0:Xe.sub(o,a),c1:Xe.sub(Xe.mul(Xe.add(t,e),Xe.add(s,n)),Xe.add(o,a))}},Ze=({c0:t,c1:e})=>{const r=Xe.add(t,e),s=Xe.sub(t,e),n=Xe.add(t,t);return{c0:Xe.mul(r,s),c1:Xe.mul(n,e)}},Ke=qe*qe,$e={ORDER:Ke,BITS:ot(Ke),BYTES:Math.ceil(ot(Ke)/8),MASK:it(ot(Ke)),ZERO:{c0:Xe.ZERO,c1:Xe.ZERO},ONE:{c0:Xe.ONE,c1:Xe.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>"bigint"==typeof t&&"bigint"==typeof e,is0:({c0:t,c1:e})=>Xe.is0(t)&&Xe.is0(e),eql:({c0:t,c1:e},{c0:r,c1:s})=>Xe.eql(t,r)&&Xe.eql(e,s),neg:({c0:t,c1:e})=>({c0:Xe.neg(t),c1:Xe.neg(e)}),pow:(t,e)=>Et($e,t,e),invertBatch:t=>kt($e,t),add:He,sub:Ge,mul:We,sqr:Ze,addN:He,subN:Ge,mulN:We,sqrN:Ze,div:(t,e)=>$e.mul(t,"bigint"==typeof e?Xe.inv(Xe.create(e)):$e.inv(e)),inv:({c0:t,c1:e})=>{const r=Xe.inv(Xe.create(t*t+e*e));return{c0:Xe.mul(r,Xe.create(t)),c1:Xe.mul(r,Xe.create(-e))}},sqrt:t=>{if($e.eql(t,$e.ZERO))return $e.ZERO;const e=$e.pow(t,($e.ORDER+Me)/Fe),r=$e.div($e.sqr(e),t),s=Je,n=[s[0],s[2],s[4],s[6]].find((t=>$e.eql(t,r)));if(!n)throw new Error("No root");const o=s.indexOf(n),a=s[o/2];if(!a)throw new Error("Invalid root");const i=$e.div(e,a),u=$e.neg(i),{re:c,im:d}=$e.reim(i),{re:p,im:f}=$e.reim(u);return d>f||d===f&&c>p?i:u},isOdd:t=>{const{re:e,im:r}=$e.reim(t);return BigInt(e%Ue||e===Ne&&r%Ue)==_e},fromBytes(t){if(t.length!==$e.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:Xe.fromBytes(t.subarray(0,Xe.BYTES)),c1:Xe.fromBytes(t.subarray(Xe.BYTES))}},toBytes:({c0:t,c1:e})=>st(Xe.toBytes(t),Xe.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:s},n)=>({c0:Xe.cmov(t,r,n),c1:Xe.cmov(e,s,n)}),reim:({c0:t,c1:e})=>({re:t,im:e}),mulByNonresidue:({c0:t,c1:e})=>({c0:Xe.sub(t,e),c1:Xe.add(t,e)}),multiplyByB:({c0:t,c1:e})=>{let r=Xe.mul(t,Le),s=Xe.mul(e,Le);return{c0:Xe.sub(r,s),c1:Xe.add(r,s)}},fromBigTuple:t=>{if(2!==t.length)throw new Error("Invalid tuple");const e=t.map((t=>Xe.create(t)));return{c0:e[0],c1:e[1]}},frobeniusMap:({c0:t,c1:e},r)=>({c0:t,c1:Xe.mul(e,ze[r%2])})},ze=[BigInt("0x1"),BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa")].map((t=>Xe.create(t))),Ye=BigInt("0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),Je=[[_e,Ne],[Ye,-Ye],[Ne,_e],[Ye,Ye],[-_e,Ne],[-Ye,Ye],[Ne,-_e],[-Ye,-Ye]].map((t=>$e.fromBigTuple(t))),Qe=({c0:t,c1:e,c2:r},{c0:s,c1:n,c2:o})=>({c0:$e.add(t,s),c1:$e.add(e,n),c2:$e.add(r,o)}),tr=({c0:t,c1:e,c2:r},{c0:s,c1:n,c2:o})=>({c0:$e.sub(t,s),c1:$e.sub(e,n),c2:$e.sub(r,o)}),er=({c0:t,c1:e,c2:r},s)=>{if("bigint"==typeof s)return{c0:$e.mul(t,s),c1:$e.mul(e,s),c2:$e.mul(r,s)};const{c0:n,c1:o,c2:a}=s,i=$e.mul(t,n),u=$e.mul(e,o),c=$e.mul(r,a);return{c0:$e.add(i,$e.mulByNonresidue($e.sub($e.mul($e.add(e,r),$e.add(o,a)),$e.add(u,c)))),c1:$e.add($e.sub($e.mul($e.add(t,e),$e.add(n,o)),$e.add(i,u)),$e.mulByNonresidue(c)),c2:$e.sub($e.add(u,$e.mul($e.add(t,r),$e.add(n,a))),$e.add(i,c))}},rr=({c0:t,c1:e,c2:r})=>{let s=$e.sqr(t),n=$e.mul($e.mul(t,e),Ue),o=$e.mul($e.mul(e,r),Ue),a=$e.sqr(r);return{c0:$e.add($e.mulByNonresidue(o),s),c1:$e.add($e.mulByNonresidue(a),n),c2:$e.sub($e.sub($e.add($e.add(n,$e.sqr($e.add($e.sub(t,e),r))),o),s),a)}},sr={ORDER:$e.ORDER,BITS:3*$e.BITS,BYTES:3*$e.BYTES,MASK:it(3*$e.BITS),ZERO:{c0:$e.ZERO,c1:$e.ZERO,c2:$e.ZERO},ONE:{c0:$e.ONE,c1:$e.ZERO,c2:$e.ZERO},create:t=>t,isValid:({c0:t,c1:e,c2:r})=>$e.isValid(t)&&$e.isValid(e)&&$e.isValid(r),is0:({c0:t,c1:e,c2:r})=>$e.is0(t)&&$e.is0(e)&&$e.is0(r),neg:({c0:t,c1:e,c2:r})=>({c0:$e.neg(t),c1:$e.neg(e),c2:$e.neg(r)}),eql:({c0:t,c1:e,c2:r},{c0:s,c1:n,c2:o})=>$e.eql(t,s)&&$e.eql(e,n)&&$e.eql(r,o),sqrt:()=>{throw new Error("Not implemented")},div:(t,e)=>sr.mul(t,"bigint"==typeof e?Xe.inv(Xe.create(e)):sr.inv(e)),pow:(t,e)=>Et(sr,t,e),invertBatch:t=>kt(sr,t),add:Qe,sub:tr,mul:er,sqr:rr,addN:Qe,subN:tr,mulN:er,sqrN:rr,inv:({c0:t,c1:e,c2:r})=>{let s=$e.sub($e.sqr(t),$e.mulByNonresidue($e.mul(r,e))),n=$e.sub($e.mulByNonresidue($e.sqr(r)),$e.mul(t,e)),o=$e.sub($e.sqr(e),$e.mul(t,r)),a=$e.inv($e.add($e.mulByNonresidue($e.add($e.mul(r,n),$e.mul(e,o))),$e.mul(t,s)));return{c0:$e.mul(a,s),c1:$e.mul(a,n),c2:$e.mul(a,o)}},fromBytes:t=>{if(t.length!==sr.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:$e.fromBytes(t.subarray(0,$e.BYTES)),c1:$e.fromBytes(t.subarray($e.BYTES,2*$e.BYTES)),c2:$e.fromBytes(t.subarray(2*$e.BYTES))}},toBytes:({c0:t,c1:e,c2:r})=>st($e.toBytes(t),$e.toBytes(e),$e.toBytes(r)),cmov:({c0:t,c1:e,c2:r},{c0:s,c1:n,c2:o},a)=>({c0:$e.cmov(t,s,a),c1:$e.cmov(e,n,a),c2:$e.cmov(r,o,a)}),fromBigSix:t=>{if(!Array.isArray(t)||6!==t.length)throw new Error("Invalid Fp6 usage");return{c0:$e.fromBigTuple(t.slice(0,2)),c1:$e.fromBigTuple(t.slice(2,4)),c2:$e.fromBigTuple(t.slice(4,6))}},frobeniusMap:({c0:t,c1:e,c2:r},s)=>({c0:$e.frobeniusMap(t,s),c1:$e.mul($e.frobeniusMap(e,s),nr[s%6]),c2:$e.mul($e.frobeniusMap(r,s),or[s%6])}),mulByNonresidue:({c0:t,c1:e,c2:r})=>({c0:$e.mulByNonresidue(r),c1:t,c2:e}),multiplyBy1:({c0:t,c1:e,c2:r},s)=>({c0:$e.mulByNonresidue($e.mul(r,s)),c1:$e.mul(t,s),c2:$e.mul(e,s)}),multiplyBy01({c0:t,c1:e,c2:r},s,n){let o=$e.mul(t,s),a=$e.mul(e,n);return{c0:$e.add($e.mulByNonresidue($e.sub($e.mul($e.add(e,r),n),a)),o),c1:$e.sub($e.sub($e.mul($e.add(s,n),$e.add(t,e)),o),a),c2:$e.add($e.sub($e.mul($e.add(t,r),s),o),a)}},multiplyByFp2:({c0:t,c1:e,c2:r},s)=>({c0:$e.mul(t,s),c1:$e.mul(e,s),c2:$e.mul(r,s)})},nr=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe")]].map((t=>$e.fromBigTuple(t))),or=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")]].map((t=>$e.fromBigTuple(t))),ar=BigInt("0xd201000000010000"),ir=ot(ar),ur=({c0:t,c1:e},{c0:r,c1:s})=>({c0:sr.add(t,r),c1:sr.add(e,s)}),cr=({c0:t,c1:e},{c0:r,c1:s})=>({c0:sr.sub(t,r),c1:sr.sub(e,s)}),dr=({c0:t,c1:e},r)=>{if("bigint"==typeof r)return{c0:sr.mul(t,r),c1:sr.mul(e,r)};let{c0:s,c1:n}=r,o=sr.mul(t,s),a=sr.mul(e,n);return{c0:sr.add(o,sr.mulByNonresidue(a)),c1:sr.sub(sr.mul(sr.add(t,e),sr.add(s,n)),sr.add(o,a))}},pr=({c0:t,c1:e})=>{let r=sr.mul(t,e);return{c0:sr.sub(sr.sub(sr.mul(sr.add(sr.mulByNonresidue(e),t),sr.add(t,e)),r),sr.mulByNonresidue(r)),c1:sr.add(r,r)}};function fr(t,e){const r=$e.sqr(t),s=$e.sqr(e);return{first:$e.add($e.mulByNonresidue(s),r),second:$e.sub($e.sub($e.sqr($e.add(t,e)),r),s)}}const lr={ORDER:$e.ORDER,BITS:2*$e.BITS,BYTES:2*$e.BYTES,MASK:it(2*$e.BITS),ZERO:{c0:sr.ZERO,c1:sr.ZERO},ONE:{c0:sr.ONE,c1:sr.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>sr.isValid(t)&&sr.isValid(e),is0:({c0:t,c1:e})=>sr.is0(t)&&sr.is0(e),neg:({c0:t,c1:e})=>({c0:sr.neg(t),c1:sr.neg(e)}),eql:({c0:t,c1:e},{c0:r,c1:s})=>sr.eql(t,r)&&sr.eql(e,s),sqrt:()=>{throw new Error("Not implemented")},inv:({c0:t,c1:e})=>{let r=sr.inv(sr.sub(sr.sqr(t),sr.mulByNonresidue(sr.sqr(e))));return{c0:sr.mul(t,r),c1:sr.neg(sr.mul(e,r))}},div:(t,e)=>lr.mul(t,"bigint"==typeof e?Xe.inv(Xe.create(e)):lr.inv(e)),pow:(t,e)=>Et(lr,t,e),invertBatch:t=>kt(lr,t),add:ur,sub:cr,mul:dr,sqr:pr,addN:ur,subN:cr,mulN:dr,sqrN:pr,fromBytes:t=>{if(t.length!==lr.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:sr.fromBytes(t.subarray(0,sr.BYTES)),c1:sr.fromBytes(t.subarray(sr.BYTES))}},toBytes:({c0:t,c1:e})=>st(sr.toBytes(t),sr.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:s},n)=>({c0:sr.cmov(t,r,n),c1:sr.cmov(e,s,n)}),fromBigTwelve:t=>({c0:sr.fromBigSix(t.slice(0,6)),c1:sr.fromBigSix(t.slice(6,12))}),frobeniusMap(t,e){const r=sr.frobeniusMap(t.c0,e),{c0:s,c1:n,c2:o}=sr.frobeniusMap(t.c1,e),a=hr[e%12];return{c0:r,c1:sr.create({c0:$e.mul(s,a),c1:$e.mul(n,a),c2:$e.mul(o,a)})}},multiplyBy014:({c0:t,c1:e},r,s,n)=>{let o=sr.multiplyBy01(t,r,s),a=sr.multiplyBy1(e,n);return{c0:sr.add(sr.mulByNonresidue(a),o),c1:sr.sub(sr.sub(sr.multiplyBy01(sr.add(e,t),r,$e.add(s,n)),o),a)}},multiplyByFp2:({c0:t,c1:e},r)=>({c0:sr.multiplyByFp2(t,r),c1:sr.multiplyByFp2(e,r)}),conjugate:({c0:t,c1:e})=>({c0:t,c1:sr.neg(e)}),_cyclotomicSquare:({c0:t,c1:e})=>{const{c0:r,c1:s,c2:n}=t,{c0:o,c1:a,c2:i}=e,{first:u,second:c}=fr(r,a),{first:d,second:p}=fr(o,n),{first:f,second:l}=fr(s,i);let h=$e.mulByNonresidue(l);return{c0:sr.create({c0:$e.add($e.mul($e.sub(u,r),Ue),u),c1:$e.add($e.mul($e.sub(d,s),Ue),d),c2:$e.add($e.mul($e.sub(f,n),Ue),f)}),c1:sr.create({c0:$e.add($e.mul($e.add(h,o),Ue),h),c1:$e.add($e.mul($e.add(c,a),Ue),c),c2:$e.add($e.mul($e.add(p,i),Ue),p)})}},_cyclotomicExp(t,e){let r=lr.ONE;for(let s=ir-1;s>=0;s--)r=lr._cyclotomicSquare(r),at(e,s)&&(r=lr.mul(r,t));return r},finalExponentiate:t=>{const e=ar,r=lr.div(lr.frobeniusMap(t,6),t),s=lr.mul(lr.frobeniusMap(r,2),r),n=lr.conjugate(lr._cyclotomicExp(s,e)),o=lr.mul(lr.conjugate(lr._cyclotomicSquare(s)),n),a=lr.conjugate(lr._cyclotomicExp(o,e)),i=lr.conjugate(lr._cyclotomicExp(a,e)),u=lr.mul(lr.conjugate(lr._cyclotomicExp(i,e)),lr._cyclotomicSquare(n)),c=lr.conjugate(lr._cyclotomicExp(u,e)),d=lr.frobeniusMap(lr.mul(n,i),2),p=lr.frobeniusMap(lr.mul(a,s),3),f=lr.frobeniusMap(lr.mul(u,lr.conjugate(s)),1),l=lr.mul(lr.mul(c,lr.conjugate(o)),s);return lr.mul(lr.mul(lr.mul(d,p),f),l)}},hr=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8"),BigInt("0x00fc3e2b36c4e03288e9e9022