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