UNPKG

curve-p256

Version:

The secp256r1 (p-256) elliptic curve for ECDH & ECDSA

2 lines (1 loc) 35.8 kB
(function(N,K){typeof exports=="object"&&typeof module<"u"?K(exports):typeof define=="function"&&define.amd?define(["exports"],K):(N=typeof globalThis<"u"?globalThis:N||self,K(N.CurveP256={}))})(this,(function(N){"use strict";let K;if(typeof globalThis<"u"&&(K=globalThis),typeof self<"u")K=self;else if(typeof window<"u")K=window;else if(typeof global<"u")K=global;else try{K=Function("return this")()}catch{}function be(){return K}function vt(t){if(!ArrayBuffer.isView(t))throw new TypeError("Failed to execute 'getRandomValues' on 'Crypto': parameter 1 is not of type 'ArrayBufferView'.");if(t.byteLength>65536){const e="Failed to execute 'getRandomValues' on 'Crypto': The ArrayBufferView's byte length ("+t.byteLength+") exceeds the number of bytes of entropy available via this API (65536).";throw"DOMException"in globalThis?new globalThis.DOMException(e):new Error(e)}const n=Math.pow(256,t.BYTES_PER_ELEMENT);for(let e=0;e<t.byteLength;++e)t[e]=Math.floor(n*Math.random());return t}function Ut(t,n){if(typeof t!="number")throw new TypeError(`[ERR_INVALID_ARG_TYPE]: The "size" argument must be of type number. Received type ${typeof t} (${t})`);if(t<0||t>2147483647)throw new RangeError(`[ERR_OUT_OF_RANGE]: The value of "size" is out of range. It must be >= 0 && <= 2147483647. Received ${t}`);if(n&&typeof n!="function")throw new TypeError(`[ERR_INVALID_ARG_TYPE]: The "callback" argument must be of type function. Received type ${typeof n} (${n})`);if(!n){const e=new Uint8Array(t);return vt(e)}return new Promise(e=>{const r=new Uint8Array(t),o=null;try{n(null,vt(r))}catch{n(o,r)}e(r)})}function kt(){return Ut(16).reduce((e,r,o)=>{let i=e+r.toString(16).padStart(2,"0");return(o===3||o===5||o===7||o===9)&&(i+="-"),i},"")}const Q=be();(function(){"crypto"in Q?("getRandomValues"in Q.crypto||(Q.crypto.getRandomValues=vt),"randomBytes"in Q.crypto||(Q.crypto.randomBytes=Ut),"randomUUID"in Q.crypto||(Q.crypto.randomUUID=kt)):Q.crypto={getRandomValues:vt,randomBytes:Ut,randomUUID:kt}})();const Ot=Q.crypto;function Dt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function pe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function jt(t,...n){if(!pe(t))throw new Error("Expected Uint8Array");if(n.length>0&&!n.includes(t.length))throw new Error(`Expected Uint8Array of length ${n}, not of length=${t.length}`)}function Ee(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Dt(t.outputLen),Dt(t.blockLen)}function At(t,n=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(n&&t.finished)throw new Error("Hash#digest() has already been called")}function Be(t,n){jt(t);const e=n.outputLen;if(t.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Mt(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}const Rt=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),X=(t,n)=>t<<32-n|t>>>n;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function ve(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Lt(t){if(typeof t=="string"&&(t=ve(t)),!Mt(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function Ae(...t){let n=0;for(let r=0;r<t.length;r++){const o=t[r];if(!Mt(o))throw new Error("Uint8Array expected");n+=o.length}const e=new Uint8Array(n);for(let r=0,o=0;r<t.length;r++){const i=t[r];e.set(i,o),o+=i.length}return e}class zt{clone(){return this._cloneInto()}}function Se(t){const n=r=>t().update(Lt(r)).digest(),e=t();return n.outputLen=e.outputLen,n.blockLen=e.blockLen,n.create=()=>t(),n}function xe(t=32){if(Ot&&typeof Ot.getRandomValues=="function")return Ot.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class Yt extends zt{constructor(n,e){super(),this.finished=!1,this.destroyed=!1,Ee(n);const r=Lt(e);if(this.iHash=n.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?n.create().update(r).digest():r);for(let f=0;f<i.length;f++)i[f]^=54;this.iHash.update(i),this.oHash=n.create();for(let f=0;f<i.length;f++)i[f]^=106;this.oHash.update(i),i.fill(0)}update(n){return At(this),this.iHash.update(n),this}digestInto(n){At(this),jt(n,this.outputLen),this.finished=!0,this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),this.destroy()}digest(){const n=new Uint8Array(this.oHash.outputLen);return this.digestInto(n),n}_cloneInto(n){n||(n=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:o,destroyed:i,blockLen:f,outputLen:s}=this;return n=n,n.finished=o,n.destroyed=i,n.blockLen=f,n.outputLen=s,n.oHash=e._cloneInto(n.oHash),n.iHash=r._cloneInto(n.iHash),n}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Gt=(t,n,e)=>new Yt(t,n).update(e).digest();Gt.create=(t,n)=>new Yt(t,n);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Wt=BigInt(0),St=BigInt(1),_e=BigInt(2);function j(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}const Ie=Array.from({length:256},(t,n)=>n.toString(16).padStart(2,"0"));function ct(t){if(!j(t))throw new Error("Uint8Array expected");let n="";for(let e=0;e<t.length;e++)n+=Ie[t[e]];return n}function Nt(t){const n=t.toString(16);return n.length&1?`0${n}`:n}function xt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}const J={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Kt(t){if(t>=J._0&&t<=J._9)return t-J._0;if(t>=J._A&&t<=J._F)return t-(J._A-10);if(t>=J._a&&t<=J._f)return t-(J._a-10)}function ft(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const n=t.length,e=n/2;if(n%2)throw new Error("padded hex string expected, got unpadded hex of length "+n);const r=new Uint8Array(e);for(let o=0,i=0;o<e;o++,i+=2){const f=Kt(t.charCodeAt(i)),s=Kt(t.charCodeAt(i+1));if(f===void 0||s===void 0){const c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}r[o]=f*16+s}return r}function F(t){return xt(ct(t))}function _t(t){if(!j(t))throw new Error("Uint8Array expected");return xt(ct(Uint8Array.from(t).reverse()))}function ut(t,n){return ft(t.toString(16).padStart(n*2,"0"))}function It(t,n){return ut(t,n).reverse()}function Xt(t){return ft(Nt(t))}function M(t,n,e){let r;if(typeof n=="string")try{r=ft(n)}catch(i){throw new Error(`${t} must be valid hex string, got "${n}". Cause: ${i}`)}else if(j(n))r=Uint8Array.from(n);else throw new Error(`${t} must be hex string or Uint8Array`);const o=r.length;if(typeof e=="number"&&o!==e)throw new Error(`${t} expected ${e} bytes, got ${o}`);return r}function z(...t){let n=0;for(let o=0;o<t.length;o++){const i=t[o];if(!j(i))throw new Error("Uint8Array expected");n+=i.length}let e=new Uint8Array(n),r=0;for(let o=0;o<t.length;o++){const i=t[o];e.set(i,r),r+=i.length}return e}function Qt(t,n){if(t.length!==n.length)return!1;let e=0;for(let r=0;r<t.length;r++)e|=t[r]^n[r];return e===0}function bt(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Te(t){let n;for(n=0;t>Wt;t>>=St,n+=1);return n}function Ue(t,n){return t>>BigInt(n)&St}const Oe=(t,n,e)=>t|(e?St:Wt)<<BigInt(n),qt=t=>(_e<<BigInt(t-1))-St,$t=t=>new Uint8Array(t),Jt=t=>Uint8Array.from(t);function Ft(t,n,e){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof n!="number"||n<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let r=$t(t),o=$t(t),i=0;const f=()=>{r.fill(1),o.fill(0),i=0},s=(...d)=>e(o,r,...d),c=(d=$t())=>{o=s(Jt([0]),d),r=s(),d.length!==0&&(o=s(Jt([1]),d),r=s())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const I=[];for(;d<n;){r=s();const S=r.slice();I.push(S),d+=r.length}return z(...I)};return(d,I)=>{f(),c(d);let S;for(;!(S=I(u()));)c();return f(),S}}const Re={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||j(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,n)=>n.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function ht(t,n,e={}){const r=(o,i,f)=>{const s=Re[i];if(typeof s!="function")throw new Error(`Invalid validator "${i}", expected function`);const c=t[o];if(!(f&&c===void 0)&&!s(c,t))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(const[o,i]of Object.entries(n))r(o,i,!1);for(const[o,i]of Object.entries(e))r(o,i,!0);return t}const Le=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Ue,bitLen:Te,bitMask:qt,bitSet:Oe,bytesToHex:ct,bytesToNumberBE:F,bytesToNumberLE:_t,concatBytes:z,createHmacDrbg:Ft,ensureBytes:M,equalBytes:Qt,hexToBytes:ft,hexToNumber:xt,isBytes:j,numberToBytesBE:ut,numberToBytesLE:It,numberToHexUnpadded:Nt,numberToVarBytesBE:Xt,utf8ToBytes:bt,validateObject:ht},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const H=BigInt(0),$=BigInt(1),at=BigInt(2),Ne=BigInt(3),Vt=BigInt(4),te=BigInt(5),ee=BigInt(8);BigInt(9),BigInt(16);function C(t,n){const e=t%n;return e>=H?e:n+e}function qe(t,n,e){if(e<=H||n<H)throw new Error("Expected power/modulo > 0");if(e===$)return H;let r=$;for(;n>H;)n&$&&(r=r*t%e),t=t*t%e,n>>=$;return r}function Ht(t,n){if(t===H||n<=H)throw new Error(`invert: expected positive integers, got n=${t} mod=${n}`);let e=C(t,n),r=n,o=H,i=$;for(;e!==H;){const s=r/e,c=r%e,u=o-i*s;r=e,e=c,o=i,i=u}if(r!==$)throw new Error("invert: does not exist");return C(o,n)}function $e(t){const n=(t-$)/at;let e,r,o;for(e=t-$,r=0;e%at===H;e/=at,r++);for(o=at;o<t&&qe(o,n,t)!==t-$;o++);if(r===1){const f=(t+$)/Vt;return function(c,u){const y=c.pow(u,f);if(!c.eql(c.sqr(y),u))throw new Error("Cannot find square root");return y}}const i=(e+$)/at;return function(s,c){if(s.pow(c,n)===s.neg(s.ONE))throw new Error("Cannot find square root");let u=r,y=s.pow(s.mul(s.ONE,o),e),d=s.pow(c,i),I=s.pow(c,e);for(;!s.eql(I,s.ONE);){if(s.eql(I,s.ZERO))return s.ZERO;let S=1;for(let B=s.sqr(I);S<u&&!s.eql(B,s.ONE);S++)B=s.sqr(B);const b=s.pow(y,$<<BigInt(u-S-1));y=s.sqr(b),d=s.mul(d,b),I=s.mul(I,y),u=S}return d}}function Ve(t){if(t%Vt===Ne){const n=(t+$)/Vt;return function(r,o){const i=r.pow(o,n);if(!r.eql(r.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%ee===te){const n=(t-te)/ee;return function(r,o){const i=r.mul(o,at),f=r.pow(i,n),s=r.mul(o,f),c=r.mul(r.mul(s,at),f),u=r.mul(s,r.sub(c,r.ONE));if(!r.eql(r.sqr(u),o))throw new Error("Cannot find square root");return u}}return $e(t)}const He=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ne(t){const n={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=He.reduce((r,o)=>(r[o]="function",r),n);return ht(t,e)}function Ce(t,n,e){if(e<H)throw new Error("Expected power > 0");if(e===H)return t.ONE;if(e===$)return n;let r=t.ONE,o=n;for(;e>H;)e&$&&(r=t.mul(r,o)),o=t.sqr(o),e>>=$;return r}function Ze(t,n){const e=new Array(n.length),r=n.reduce((i,f,s)=>t.is0(f)?i:(e[s]=i,t.mul(i,f)),t.ONE),o=t.inv(r);return n.reduceRight((i,f,s)=>t.is0(f)?i:(e[s]=t.mul(i,e[s]),t.mul(i,f)),o),e}function re(t,n){const e=n!==void 0?n:t.toString(2).length,r=Math.ceil(e/8);return{nBitLength:e,nByteLength:r}}function Pe(t,n,e=!1,r={}){if(t<=H)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:i}=re(t,n);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const f=Ve(t),s=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:qt(o),ZERO:H,ONE:$,create:c=>C(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return H<=c&&c<t},is0:c=>c===H,isOdd:c=>(c&$)===$,neg:c=>C(-c,t),eql:(c,u)=>c===u,sqr:c=>C(c*c,t),add:(c,u)=>C(c+u,t),sub:(c,u)=>C(c-u,t),mul:(c,u)=>C(c*u,t),pow:(c,u)=>Ce(s,c,u),div:(c,u)=>C(c*Ht(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Ht(c,t),sqrt:r.sqrt||(c=>f(s,c)),invertBatch:c=>Ze(s,c),cmov:(c,u,y)=>y?u:c,toBytes:c=>e?It(c,i):ut(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return e?_t(c):F(c)}});return Object.freeze(s)}function oe(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const n=t.toString(2).length;return Math.ceil(n/8)}function ie(t){const n=oe(t);return n+Math.ceil(n/2)}function ke(t,n,e=!1){const r=t.length,o=oe(n),i=ie(n);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const f=e?F(t):_t(t),s=C(f,n-$)+$;return e?It(s,o):ut(s,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const De=BigInt(0),Ct=BigInt(1);function je(t,n){const e=(o,i)=>{const f=i.negate();return o?f:i},r=o=>{const i=Math.ceil(n/o)+1,f=2**(o-1);return{windows:i,windowSize:f}};return{constTimeNegate:e,unsafeLadder(o,i){let f=t.ZERO,s=o;for(;i>De;)i&Ct&&(f=f.add(s)),s=s.double(),i>>=Ct;return f},precomputeWindow(o,i){const{windows:f,windowSize:s}=r(i),c=[];let u=o,y=u;for(let d=0;d<f;d++){y=u,c.push(y);for(let I=1;I<s;I++)y=y.add(u),c.push(y);u=y.double()}return c},wNAF(o,i,f){const{windows:s,windowSize:c}=r(o);let u=t.ZERO,y=t.BASE;const d=BigInt(2**o-1),I=2**o,S=BigInt(o);for(let b=0;b<s;b++){const B=b*c;let a=Number(f&d);f>>=S,a>c&&(a-=I,f+=Ct);const l=B,h=B+Math.abs(a)-1,m=b%2!==0,p=a<0;a===0?y=y.add(e(m,i[l])):u=u.add(e(p,i[h]))}return{p:u,f:y}},wNAFCached(o,i,f,s){const c=o._WINDOW_SIZE||1;let u=i.get(o);return u||(u=this.precomputeWindow(o,c),c!==1&&i.set(o,s(u))),this.wNAF(c,u,f)}}}function se(t){return ne(t.Fp),ht(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...re(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Me(t){const n=se(t);ht(n,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:e,Fp:r,a:o}=n;if(e){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...n})}const{bytesToNumberBE:ze,hexToBytes:Ye}=Le,lt={Err:class extends Error{constructor(n=""){super(n)}},_parseInt(t){const{Err:n}=lt;if(t.length<2||t[0]!==2)throw new n("Invalid signature integer tag");const e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new n("Invalid signature integer: wrong length");if(r[0]&128)throw new n("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new n("Invalid signature integer: unnecessary leading zero");return{d:ze(r),l:t.subarray(e+2)}},toSig(t){const{Err:n}=lt,e=typeof t=="string"?Ye(t):t;if(!j(e))throw new Error("ui8a expected");let r=e.length;if(r<2||e[0]!=48)throw new n("Invalid signature tag");if(e[1]!==r-2)throw new n("Invalid signature: incorrect length");const{d:o,l:i}=lt._parseInt(e.subarray(2)),{d:f,l:s}=lt._parseInt(i);if(s.length)throw new n("Invalid signature: left bytes after parsing");return{r:o,s:f}},hexFromSig(t){const n=u=>Number.parseInt(u[0],16)&8?"00"+u:u,e=u=>{const y=u.toString(16);return y.length&1?`0${y}`:y},r=n(e(t.s)),o=n(e(t.r)),i=r.length/2,f=o.length/2,s=e(i),c=e(f);return`30${e(f+i+4)}02${c}${o}02${s}${r}`}},Y=BigInt(0),q=BigInt(1),tt=BigInt(2),Tt=BigInt(3),ce=BigInt(4);function Ge(t){const n=Me(t),{Fp:e}=n,r=n.toBytes||((B,a,l)=>{const h=a.toAffine();return z(Uint8Array.from([4]),e.toBytes(h.x),e.toBytes(h.y))}),o=n.fromBytes||(B=>{const a=B.subarray(1),l=e.fromBytes(a.subarray(0,e.BYTES)),h=e.fromBytes(a.subarray(e.BYTES,2*e.BYTES));return{x:l,y:h}});function i(B){const{a,b:l}=n,h=e.sqr(B),m=e.mul(h,B);return e.add(e.add(m,e.mul(B,a)),l)}if(!e.eql(e.sqr(n.Gy),i(n.Gx)))throw new Error("bad generator point: equation left != right");function f(B){return typeof B=="bigint"&&Y<B&&B<n.n}function s(B){if(!f(B))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(B){const{allowedPrivateKeyLengths:a,nByteLength:l,wrapPrivateKey:h,n:m}=n;if(a&&typeof B!="bigint"){if(j(B)&&(B=ct(B)),typeof B!="string"||!a.includes(B.length))throw new Error("Invalid key");B=B.padStart(l*2,"0")}let p;try{p=typeof B=="bigint"?B:F(M("private key",B,l))}catch{throw new Error(`private key must be ${l} bytes, hex or bigint, not ${typeof B}`)}return h&&(p=C(p,m)),s(p),p}const u=new Map;function y(B){if(!(B instanceof d))throw new Error("ProjectivePoint expected")}const b=class b{constructor(a,l,h){if(this.px=a,this.py=l,this.pz=h,a==null||!e.isValid(a))throw new Error("x required");if(l==null||!e.isValid(l))throw new Error("y required");if(h==null||!e.isValid(h))throw new Error("z required")}static fromAffine(a){const{x:l,y:h}=a||{};if(!a||!e.isValid(l)||!e.isValid(h))throw new Error("invalid affine point");if(a instanceof b)throw new Error("projective point not allowed");const m=p=>e.eql(p,e.ZERO);return m(l)&&m(h)?b.ZERO:new b(l,h,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(a){const l=e.invertBatch(a.map(h=>h.pz));return a.map((h,m)=>h.toAffine(l[m])).map(b.fromAffine)}static fromHex(a){const l=b.fromAffine(o(M("pointHex",a)));return l.assertValidity(),l}static fromPrivateKey(a){return b.BASE.multiply(c(a))}_setWindowSize(a){this._WINDOW_SIZE=a,u.delete(this)}assertValidity(){if(this.is0()){if(n.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:a,y:l}=this.toAffine();if(!e.isValid(a)||!e.isValid(l))throw new Error("bad point: x or y not FE");const h=e.sqr(l),m=i(a);if(!e.eql(h,m))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:a}=this.toAffine();if(e.isOdd)return!e.isOdd(a);throw new Error("Field doesn't support isOdd")}equals(a){y(a);const{px:l,py:h,pz:m}=this,{px:p,py:T,pz:_}=a,E=e.eql(e.mul(l,_),e.mul(p,m)),A=e.eql(e.mul(h,_),e.mul(T,m));return E&&A}negate(){return new b(this.px,e.neg(this.py),this.pz)}double(){const{a,b:l}=n,h=e.mul(l,Tt),{px:m,py:p,pz:T}=this;let _=e.ZERO,E=e.ZERO,A=e.ZERO,x=e.mul(m,m),G=e.mul(p,p),R=e.mul(T,T),U=e.mul(m,p);return U=e.add(U,U),A=e.mul(m,T),A=e.add(A,A),_=e.mul(a,A),E=e.mul(h,R),E=e.add(_,E),_=e.sub(G,E),E=e.add(G,E),E=e.mul(_,E),_=e.mul(U,_),A=e.mul(h,A),R=e.mul(a,R),U=e.sub(x,R),U=e.mul(a,U),U=e.add(U,A),A=e.add(x,x),x=e.add(A,x),x=e.add(x,R),x=e.mul(x,U),E=e.add(E,x),R=e.mul(p,T),R=e.add(R,R),x=e.mul(R,U),_=e.sub(_,x),A=e.mul(R,G),A=e.add(A,A),A=e.add(A,A),new b(_,E,A)}add(a){y(a);const{px:l,py:h,pz:m}=this,{px:p,py:T,pz:_}=a;let E=e.ZERO,A=e.ZERO,x=e.ZERO;const G=n.a,R=e.mul(n.b,Tt);let U=e.mul(l,p),Z=e.mul(h,T),P=e.mul(m,_),g=e.add(l,h),w=e.add(p,T);g=e.mul(g,w),w=e.add(U,Z),g=e.sub(g,w),w=e.add(l,m);let v=e.add(p,_);return w=e.mul(w,v),v=e.add(U,P),w=e.sub(w,v),v=e.add(h,m),E=e.add(T,_),v=e.mul(v,E),E=e.add(Z,P),v=e.sub(v,E),x=e.mul(G,w),E=e.mul(R,P),x=e.add(E,x),E=e.sub(Z,x),x=e.add(Z,x),A=e.mul(E,x),Z=e.add(U,U),Z=e.add(Z,U),P=e.mul(G,P),w=e.mul(R,w),Z=e.add(Z,P),P=e.sub(U,P),P=e.mul(G,P),w=e.add(w,P),U=e.mul(Z,w),A=e.add(A,U),U=e.mul(v,w),E=e.mul(g,E),E=e.sub(E,U),U=e.mul(g,Z),x=e.mul(v,x),x=e.add(x,U),new b(E,A,x)}subtract(a){return this.add(a.negate())}is0(){return this.equals(b.ZERO)}wNAF(a){return S.wNAFCached(this,u,a,l=>{const h=e.invertBatch(l.map(m=>m.pz));return l.map((m,p)=>m.toAffine(h[p])).map(b.fromAffine)})}multiplyUnsafe(a){const l=b.ZERO;if(a===Y)return l;if(s(a),a===q)return this;const{endo:h}=n;if(!h)return S.unsafeLadder(this,a);let{k1neg:m,k1:p,k2neg:T,k2:_}=h.splitScalar(a),E=l,A=l,x=this;for(;p>Y||_>Y;)p&q&&(E=E.add(x)),_&q&&(A=A.add(x)),x=x.double(),p>>=q,_>>=q;return m&&(E=E.negate()),T&&(A=A.negate()),A=new b(e.mul(A.px,h.beta),A.py,A.pz),E.add(A)}multiply(a){s(a);let l=a,h,m;const{endo:p}=n;if(p){const{k1neg:T,k1:_,k2neg:E,k2:A}=p.splitScalar(l);let{p:x,f:G}=this.wNAF(_),{p:R,f:U}=this.wNAF(A);x=S.constTimeNegate(T,x),R=S.constTimeNegate(E,R),R=new b(e.mul(R.px,p.beta),R.py,R.pz),h=x.add(R),m=G.add(U)}else{const{p:T,f:_}=this.wNAF(l);h=T,m=_}return b.normalizeZ([h,m])[0]}multiplyAndAddUnsafe(a,l,h){const m=b.BASE,p=(_,E)=>E===Y||E===q||!_.equals(m)?_.multiplyUnsafe(E):_.multiply(E),T=p(this,l).add(p(a,h));return T.is0()?void 0:T}toAffine(a){const{px:l,py:h,pz:m}=this,p=this.is0();a==null&&(a=p?e.ONE:e.inv(m));const T=e.mul(l,a),_=e.mul(h,a),E=e.mul(m,a);if(p)return{x:e.ZERO,y:e.ZERO};if(!e.eql(E,e.ONE))throw new Error("invZ was invalid");return{x:T,y:_}}isTorsionFree(){const{h:a,isTorsionFree:l}=n;if(a===q)return!0;if(l)return l(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:a,clearCofactor:l}=n;return a===q?this:l?l(b,this):this.multiplyUnsafe(n.h)}toRawBytes(a=!0){return this.assertValidity(),r(b,this,a)}toHex(a=!0){return ct(this.toRawBytes(a))}};b.BASE=new b(n.Gx,n.Gy,e.ONE),b.ZERO=new b(e.ZERO,e.ONE,e.ZERO);let d=b;const I=n.nBitLength,S=je(d,n.endo?Math.ceil(I/2):I);return{CURVE:n,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:f}}function We(t){const n=se(t);return ht(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}function Ke(t){const n=We(t),{Fp:e,n:r}=n,o=e.BYTES+1,i=2*e.BYTES+1;function f(g){return Y<g&&g<e.ORDER}function s(g){return C(g,r)}function c(g){return Ht(g,r)}const{ProjectivePoint:u,normPrivateKeyToScalar:y,weierstrassEquation:d,isWithinCurveOrder:I}=Ge({...n,toBytes(g,w,v){const L=w.toAffine(),O=e.toBytes(L.x),V=z;return v?V(Uint8Array.from([w.hasEvenY()?2:3]),O):V(Uint8Array.from([4]),O,e.toBytes(L.y))},fromBytes(g){const w=g.length,v=g[0],L=g.subarray(1);if(w===o&&(v===2||v===3)){const O=F(L);if(!f(O))throw new Error("Point is not on curve");const V=d(O);let k=e.sqrt(V);const D=(k&q)===q;return(v&1)===1!==D&&(k=e.neg(k)),{x:O,y:k}}else if(w===i&&v===4){const O=e.fromBytes(L.subarray(0,e.BYTES)),V=e.fromBytes(L.subarray(e.BYTES,2*e.BYTES));return{x:O,y:V}}else throw new Error(`Point of length ${w} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),S=g=>ct(ut(g,n.nByteLength));function b(g){const w=r>>q;return g>w}function B(g){return b(g)?s(-g):g}const a=(g,w,v)=>F(g.slice(w,v));class l{constructor(w,v,L){this.r=w,this.s=v,this.recovery=L,this.assertValidity()}static fromCompact(w){const v=n.nByteLength;return w=M("compactSignature",w,v*2),new l(a(w,0,v),a(w,v,2*v))}static fromDER(w){const{r:v,s:L}=lt.toSig(M("DER",w));return new l(v,L)}assertValidity(){if(!I(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!I(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(w){return new l(this.r,this.s,w)}recoverPublicKey(w){const{r:v,s:L,recovery:O}=this,V=E(M("msgHash",w));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const k=O===2||O===3?v+n.n:v;if(k>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");const D=(O&1)===0?"02":"03",ot=u.fromHex(D+S(k)),it=c(k),wt=s(-V*it),Bt=s(L*it),st=u.BASE.multiplyAndAddUnsafe(ot,wt,Bt);if(!st)throw new Error("point at infinify");return st.assertValidity(),st}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new l(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return ft(this.toDERHex())}toDERHex(){return lt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ft(this.toCompactHex())}toCompactHex(){return S(this.r)+S(this.s)}}const h={isValidPrivateKey(g){try{return y(g),!0}catch{return!1}},normPrivateKeyToScalar:y,randomPrivateKey:()=>{const g=ie(n.n);return ke(n.randomBytes(g),n.n)},precompute(g=8,w=u.BASE){return w._setWindowSize(g),w.multiply(BigInt(3)),w}};function m(g,w=!0){return u.fromPrivateKey(g).toRawBytes(w)}function p(g){const w=j(g),v=typeof g=="string",L=(w||v)&&g.length;return w?L===o||L===i:v?L===2*o||L===2*i:g instanceof u}function T(g,w,v=!0){if(p(g))throw new Error("first arg must be private key");if(!p(w))throw new Error("second arg must be public key");return u.fromHex(w).multiply(y(g)).toRawBytes(v)}const _=n.bits2int||function(g){const w=F(g),v=g.length*8-n.nBitLength;return v>0?w>>BigInt(v):w},E=n.bits2int_modN||function(g){return s(_(g))},A=qt(n.nBitLength);function x(g){if(typeof g!="bigint")throw new Error("bigint expected");if(!(Y<=g&&g<A))throw new Error(`bigint expected < 2^${n.nBitLength}`);return ut(g,n.nByteLength)}function G(g,w,v=R){if(["recovered","canonical"].some(dt=>dt in v))throw new Error("sign() legacy options not supported");const{hash:L,randomBytes:O}=n;let{lowS:V,prehash:k,extraEntropy:D}=v;V==null&&(V=!0),g=M("msgHash",g),k&&(g=M("prehashed msgHash",L(g)));const ot=E(g),it=y(w),wt=[x(it),x(ot)];if(D!=null){const dt=D===!0?O(e.BYTES):D;wt.push(M("extraEntropy",dt))}const Bt=z(...wt),st=ot;function Pt(dt){const gt=_(dt);if(!I(gt))return;const ge=c(gt),yt=u.BASE.multiply(gt).toAffine(),W=s(yt.x);if(W===Y)return;const mt=s(ge*s(st+W*it));if(mt===Y)return;let ye=(yt.x===W?0:2)|Number(yt.y&q),me=mt;return V&&b(mt)&&(me=B(mt),ye^=1),new l(W,me,ye)}return{seed:Bt,k2sig:Pt}}const R={lowS:n.lowS,prehash:!1},U={lowS:n.lowS,prehash:!1};function Z(g,w,v=R){const{seed:L,k2sig:O}=G(g,w,v),V=n;return Ft(V.hash.outputLen,V.nByteLength,V.hmac)(L,O)}u.BASE._setWindowSize(8);function P(g,w,v,L=U){var yt;const O=g;if(w=M("msgHash",w),v=M("publicKey",v),"strict"in L)throw new Error("options.strict was renamed to lowS");const{lowS:V,prehash:k}=L;let D,ot;try{if(typeof O=="string"||j(O))try{D=l.fromDER(O)}catch(W){if(!(W instanceof lt.Err))throw W;D=l.fromCompact(O)}else if(typeof O=="object"&&typeof O.r=="bigint"&&typeof O.s=="bigint"){const{r:W,s:mt}=O;D=new l(W,mt)}else throw new Error("PARSE");ot=u.fromHex(v)}catch(W){if(W.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(V&&D.hasHighS())return!1;k&&(w=n.hash(w));const{r:it,s:wt}=D,Bt=E(w),st=c(wt),Pt=s(Bt*st),dt=s(it*st),gt=(yt=u.BASE.multiplyAndAddUnsafe(ot,Pt,dt))==null?void 0:yt.toAffine();return gt?s(gt.x)===it:!1}return{CURVE:n,getPublicKey:m,getSharedSecret:T,sign:Z,verify:P,ProjectivePoint:u,Signature:l,utils:h}}function Xe(t,n){const e=t.ORDER;let r=Y;for(let b=e-q;b%tt===Y;b/=tt)r+=q;const o=r,i=tt<<o-q-q,f=i*tt,s=(e-q)/f,c=(s-q)/tt,u=f-q,y=i,d=t.pow(n,s),I=t.pow(n,(s+q)/tt);let S=(b,B)=>{let a=d,l=t.pow(B,u),h=t.sqr(l);h=t.mul(h,B);let m=t.mul(b,h);m=t.pow(m,c),m=t.mul(m,l),l=t.mul(m,B),h=t.mul(m,b);let p=t.mul(h,l);m=t.pow(p,y);let T=t.eql(m,t.ONE);l=t.mul(h,I),m=t.mul(p,a),h=t.cmov(l,h,T),p=t.cmov(m,p,T);for(let _=o;_>q;_--){let E=_-tt;E=tt<<E-q;let A=t.pow(p,E);const x=t.eql(A,t.ONE);l=t.mul(h,a),a=t.mul(a,a),A=t.mul(p,a),h=t.cmov(l,h,x),p=t.cmov(A,p,x)}return{isValid:T,value:h}};if(t.ORDER%ce===Tt){const b=(t.ORDER-Tt)/ce,B=t.sqrt(t.neg(n));S=(a,l)=>{let h=t.sqr(l);const m=t.mul(a,l);h=t.mul(h,m);let p=t.pow(h,b);p=t.mul(p,m);const T=t.mul(p,B),_=t.mul(t.sqr(p),l),E=t.eql(_,a);let A=t.cmov(T,p,E);return{isValid:E,value:A}}}return S}function Qe(t,n){if(ne(t),!t.isValid(n.A)||!t.isValid(n.B)||!t.isValid(n.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const e=Xe(t,n.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let o,i,f,s,c,u,y,d;o=t.sqr(r),o=t.mul(o,n.Z),i=t.sqr(o),i=t.add(i,o),f=t.add(i,t.ONE),f=t.mul(f,n.B),s=t.cmov(n.Z,t.neg(i),!t.eql(i,t.ZERO)),s=t.mul(s,n.A),i=t.sqr(f),u=t.sqr(s),c=t.mul(u,n.A),i=t.add(i,c),i=t.mul(i,f),u=t.mul(u,s),c=t.mul(u,n.B),i=t.add(i,c),y=t.mul(o,f);const{isValid:I,value:S}=e(i,u);d=t.mul(o,r),d=t.mul(d,S),y=t.cmov(y,f,I),d=t.cmov(d,S,I);const b=t.isOdd(r)===t.isOdd(d);return d=t.cmov(t.neg(d),d,b),y=t.div(y,s),{x:y,y:d}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Je(t){return{hash:t,hmac:(n,...e)=>Gt(t,n,Ae(...e)),randomBytes:xe}}function Fe(t,n){const e=r=>Ke({...t,...Je(r)});return Object.freeze({...e(n),create:e})}function tn(t,n,e,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(n,e,r);const o=BigInt(32),i=BigInt(4294967295),f=Number(e>>o&i),s=Number(e&i),c=r?4:0,u=r?0:4;t.setUint32(n+c,f,r),t.setUint32(n+u,s,r)}class en extends zt{constructor(n,e,r,o){super(),this.blockLen=n,this.outputLen=e,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(n),this.view=Rt(this.buffer)}update(n){At(this);const{view:e,buffer:r,blockLen:o}=this;n=Lt(n);const i=n.length;for(let f=0;f<i;){const s=Math.min(o-this.pos,i-f);if(s===o){const c=Rt(n);for(;o<=i-f;f+=o)this.process(c,f);continue}r.set(n.subarray(f,f+s),this.pos),this.pos+=s,f+=s,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=n.length,this.roundClean(),this}digestInto(n){At(this),Be(n,this),this.finished=!0;const{buffer:e,view:r,blockLen:o,isLE:i}=this;let{pos:f}=this;e[f++]=128,this.buffer.subarray(f).fill(0),this.padOffset>o-f&&(this.process(r,0),f=0);for(let d=f;d<o;d++)e[d]=0;tn(r,o-8,BigInt(this.length*8),i),this.process(r,0);const s=Rt(n),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,y=this.get();if(u>y.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)s.setUint32(4*d,y[d],i)}digest(){const{buffer:n,outputLen:e}=this;this.digestInto(n);const r=n.slice(0,e);return this.destroy(),r}_cloneInto(n){n||(n=new this.constructor),n.set(...this.get());const{blockLen:e,buffer:r,length:o,finished:i,destroyed:f,pos:s}=this;return n.length=o,n.pos=s,n.finished=i,n.destroyed=f,o%e&&n.buffer.set(r),n}}const nn=(t,n,e)=>t&n^~t&e,rn=(t,n,e)=>t&n^t&e^n&e,on=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),et=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),nt=new Uint32Array(64);class sn extends en{constructor(){super(64,32,8,!1),this.A=et[0]|0,this.B=et[1]|0,this.C=et[2]|0,this.D=et[3]|0,this.E=et[4]|0,this.F=et[5]|0,this.G=et[6]|0,this.H=et[7]|0}get(){const{A:n,B:e,C:r,D:o,E:i,F:f,G:s,H:c}=this;return[n,e,r,o,i,f,s,c]}set(n,e,r,o,i,f,s,c){this.A=n|0,this.B=e|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=f|0,this.G=s|0,this.H=c|0}process(n,e){for(let d=0;d<16;d++,e+=4)nt[d]=n.getUint32(e,!1);for(let d=16;d<64;d++){const I=nt[d-15],S=nt[d-2],b=X(I,7)^X(I,18)^I>>>3,B=X(S,17)^X(S,19)^S>>>10;nt[d]=B+nt[d-7]+b+nt[d-16]|0}let{A:r,B:o,C:i,D:f,E:s,F:c,G:u,H:y}=this;for(let d=0;d<64;d++){const I=X(s,6)^X(s,11)^X(s,25),S=y+I+nn(s,c,u)+on[d]+nt[d]|0,B=(X(r,2)^X(r,13)^X(r,22))+rn(r,o,i)|0;y=u,u=c,c=s,s=f+S|0,f=i,i=o,o=r,r=S+B|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,f=f+this.D|0,s=s+this.E|0,c=c+this.F|0,u=u+this.G|0,y=y+this.H|0,this.set(r,o,i,f,s,c,u,y)}roundClean(){nt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const fe=Se(()=>new sn);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function cn(t){if(j(t))return t;if(typeof t=="string")return bt(t);throw new Error("DST must be Uint8Array or string")}const fn=F;function rt(t,n){if(t<0||t>=1<<8*n)throw new Error(`bad I2OSP call: value=${t} length=${n}`);const e=Array.from({length:n}).fill(0);for(let r=n-1;r>=0;r--)e[r]=t&255,t>>>=8;return new Uint8Array(e)}function un(t,n){const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t[r]^n[r];return e}function pt(t){if(!j(t))throw new Error("Uint8Array expected")}function Zt(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function an(t,n,e,r){pt(t),pt(n),Zt(e),n.length>255&&(n=r(z(bt("H2C-OVERSIZE-DST-"),n)));const{outputLen:o,blockLen:i}=r,f=Math.ceil(e/o);if(f>255)throw new Error("Invalid xmd length");const s=z(n,rt(n.length,1)),c=rt(0,i),u=rt(e,2),y=new Array(f),d=r(z(c,t,u,rt(0,1),s));y[0]=r(z(d,rt(1,1),s));for(let S=1;S<=f;S++){const b=[un(d,y[S-1]),rt(S+1,1),s];y[S]=r(z(...b))}return z(...y).slice(0,e)}function ln(t,n,e,r,o){if(pt(t),pt(n),Zt(e),n.length>255){const i=Math.ceil(2*r/8);n=o.create({dkLen:i}).update(bt("H2C-OVERSIZE-DST-")).update(n).digest()}if(e>65535||n.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:e}).update(t).update(rt(e,2)).update(n).update(rt(n.length,1)).digest()}function ue(t,n,e){ht(e,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:o,m:i,hash:f,expand:s,DST:c}=e;pt(t),Zt(n);const u=cn(c),y=r.toString(2).length,d=Math.ceil((y+o)/8),I=n*i*d;let S;if(s==="xmd")S=an(t,u,I,f);else if(s==="xof")S=ln(t,u,I,o,f);else if(s==="_internal_pass")S=t;else throw new Error('expand must be "xmd" or "xof"');const b=new Array(n);for(let B=0;B<n;B++){const a=new Array(i);for(let l=0;l<i;l++){const h=d*(l+B*i),m=S.subarray(h,h+d);a[l]=C(fn(m),r)}b[B]=a}return b}function dn(t,n,e){if(typeof n!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(r,o){const i=ue(r,2,{...e,DST:e.DST,...o}),f=t.fromAffine(n(i[0])),s=t.fromAffine(n(i[1])),c=f.add(s).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,o){const i=ue(r,1,{...e,DST:e.encodeDST,...o}),f=t.fromAffine(n(i[0])).clearCofactor();return f.assertValidity(),f}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Et=Pe(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),ae=Et.create(BigInt("-3")),le=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),de=Fe({a:ae,b:le,Fp:Et,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},fe),he=de,hn=Qe(Et,{A:ae,B:le,Z:Et.create(BigInt("-10"))}),we=dn(he.ProjectivePoint,t=>hn(t[0]),{DST:"P256_XMD:SHA-256_SSWU_RO_",encodeDST:"P256_XMD:SHA-256_SSWU_NU_",p:Et.ORDER,m:1,k:128,expand:"xmd",hash:fe}),wn=we.hashToCurve,gn=we.encodeToCurve;N.bytesToHex=ct,N.bytesToNumberBE=F,N.bytesToNumberLE=_t,N.concatBytes=z,N.encodeToCurve=gn,N.ensureBytes=M,N.equalBytes=Qt,N.hashToCurve=wn,N.hexToBytes=ft,N.hexToNumber=xt,N.numberToBytesBE=ut,N.numberToBytesLE=It,N.numberToHexUnpadded=Nt,N.numberToVarBytesBE=Xt,N.p256=de,N.secp256r1=he,N.utf8ToBytes=bt,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}));