shogun-button-react 6.2.3 → 6.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +752 -752
- package/dist/118.index.js +1 -1
- package/dist/122.index.js +1 -1
- package/dist/122.index.js.LICENSE.txt +1 -1
- package/dist/18.index.js +1 -1
- package/dist/195.index.js +1 -1
- package/dist/452.index.js +2 -0
- package/dist/452.index.js.LICENSE.txt +1 -0
- package/dist/47.index.js +1 -1
- package/dist/47.index.js.LICENSE.txt +1 -1
- package/dist/508.index.js +1 -1
- package/dist/604.index.js +1 -1
- package/dist/619.index.js +1 -1
- package/dist/649.index.js +1 -1
- package/dist/649.index.js.LICENSE.txt +1 -1
- package/dist/695.index.js +1 -1
- package/dist/732.index.js +1 -1
- package/dist/794.index.js +1 -1
- package/dist/794.index.js.LICENSE.txt +1 -1
- package/dist/841.index.js +2 -0
- package/dist/841.index.js.LICENSE.txt +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +0 -2
- package/package.json +2 -2
package/dist/118.index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 118.index.js.LICENSE.txt */
|
|
2
|
-
export const __webpack_esm_id__=118;export const __webpack_esm_ids__=[118];export const __webpack_esm_modules__={13118:(t,e,n)=>{n.d(e,{ml_dsa87:()=>mt});const r=BigInt(2**32-1),o=BigInt(32);function s(t,e=!1){return e?{h:Number(t&r),l:Number(t>>o&r)}:{h:0|Number(t>>o&r),l:0|Number(t&r)}}function i(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function c(t,e=""){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e&&`"${e}" `}expected integer >= 0, got ${t}`)}function u(t,e,n=""){const r=i(t),o=t?.length,s=void 0!==e;if(!r||s&&o!==e)throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${e}`:"")+", got "+(r?`length=${o}`:"type="+typeof t));return t}function l(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")}function f(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function d(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const a=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=d(t[e]);return t};function h(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];u(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const o=t[e];n.set(o,r),r+=o.length}return n}const g=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])}),p=BigInt(0),y=BigInt(1),w=BigInt(2),b=BigInt(7),L=BigInt(256),A=BigInt(113),m=[],E=[],k=[];for(let t=0,e=y,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],m.push(2*(5*r+n)),E.push((t+1)*(t+2)/2%64);let o=p;for(let t=0;t<7;t++)e=(e<<y^(e>>b)*A)%L,e&w&&(o^=y<<(y<<BigInt(t))-y);k.push(o)}const x=function(t,e=!1){const n=t.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){const{h:n,l:c}=s(t[i],e);[r[i],o[i]]=[n,c]}return[r,o]}(k,!0),I=x[0],U=x[1],_=(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),T=(t,e,n)=>n>32?((t,e,n)=>t<<n-32|e>>>64-n)(t,e,n):((t,e,n)=>e<<n|t>>>32-n)(t,e,n);class v{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,e,n,r=!1,o=24){if(this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=o,c(n,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}clone(){return this._cloneInto()}keccak(){a(this.state32),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,o=(e+2)%10,s=n[o],i=n[o+1],c=_(s,i,1)^n[r],u=T(s,i,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=c,t[e+n+1]^=u}let e=t[2],o=t[3];for(let n=0;n<24;n++){const r=E[n],s=_(e,o,r),i=T(e,o,r),c=m[n];e=t[c],o=t[c+1],t[c]=s,t[c+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]^=I[r],t[1]^=U[r]}f(n)}(this.state32,this.rounds),a(this.state32),this.posOut=0,this.pos=0}update(t){l(this),u(t);const{blockLen:e,state:n}=this,r=t.length;for(let o=0;o<r;){const s=Math.min(e-this.pos,r-o);for(let e=0;e<s;e++)n[this.pos++]^=t[o++];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){l(this,!1),u(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,o=t.length;r<o;){this.posOut>=n&&this.keccak();const s=Math.min(n-this.posOut,o-r);t.set(e.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return c(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(function(t,e){u(t,void 0,"digestInto() output");const n=e.outputLen;if(t.length<n)throw new Error('"digestInto() output" expected to be of length >='+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,f(this.state)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:o,enableXOF:s}=this;return t||=new v(e,n,r,s,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=n,t.outputLen=r,t.enableXOF=s,t.destroyed=this.destroyed,t}}const O=(t,e,n,r={})=>function(t,e={}){const n=(e,n)=>t(n).update(e).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=e=>t(e),Object.assign(n,e),Object.freeze(n)}((r={})=>new v(e,t,void 0===r.dkLen?n:r.dkLen,!0),r),M=O(31,168,16,g(11)),B=O(31,136,32,g(12));function F(t){if(!Number.isSafeInteger(t)||t<0||t>4294967295)throw new Error("wrong u32 integer:"+t);return t}function N(t){return F(t),!(t&t-1)&&0!==t}function K(t,e){F(t);let n=0;for(let r=0;r<e;r++,t>>>=1)n=n<<1|1&t;return n}function $(t){return F(t),31-Math.clz32(t)}function P(t){const e=t.length;if(e<2||!N(e))throw new Error("n must be a power of 2 and greater than 1. Got "+e);const n=$(e);for(let r=0;r<e;r++){const e=K(r,n);if(r<e){const n=t[r];t[r]=t[e],t[e]=n}}return t}const R=(t,e)=>{const{N:n,roots:r,dit:o,invertButterflies:s=!1,skipStages:i=0,brp:c=!0}=e,u=$(n);if(!N(n))throw new Error("FFT: Polynomial size should be power of two");const l=o!==s;return e=>{if(e.length!==n)throw new Error("FFT: wrong Polynomial length");o&&c&&P(e);for(let c=0,f=1;c<u-i;c++){const d=o?c+1+i:u-c,a=1<<d,h=a>>1,g=n>>d;for(let i=0;i<n;i+=a)for(let c=0,u=f++;c<h;c++){const f=i+c,d=i+c+h,a=r[s?o?n-u:u:c*g],p=e[d],y=e[f];if(l){const n=t.mul(p,a);e[f]=t.add(y,n),e[d]=t.sub(y,n)}else s?(e[f]=t.add(p,y),e[d]=t.mul(t.sub(p,y),a)):(e[f]=t.add(y,p),e[d]=t.mul(t.sub(y,p),a))}}return!o&&c&&P(e),e}},S=function(t=32){const e="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof e?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))};function X(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}function G(t){if("object"!=typeof t||null===t||i(t))throw new Error("expected opts to be an object")}function Y(t){G(t),void 0!==t.context&&u(t.context,void 0,"opts.context")}function C(t){Y(t),!1!==t.extraEntropy&&void 0!==t.extraEntropy&&u(t.extraEntropy,void 0,"opts.extraEntropy")}function j(t,...e){const n=t=>"number"==typeof t?t:t.bytesLen,r=e.reduce((t,e)=>t+n(e),0);return{bytesLen:r,encode:o=>{const s=new Uint8Array(r);for(let r=0,i=0;r<e.length;r++){const c=e[r],l=n(c),f="number"==typeof c?o[r]:c.encode(o[r]);u(f,l,t),s.set(f,i),"number"!=typeof c&&f.fill(0),i+=l}return s},decode:o=>{u(o,r,t);const s=[];for(const t of e){const e=n(t),r=o.subarray(0,e);s.push("number"==typeof t?r:t.decode(r)),o=o.subarray(e)}return s}}}function H(t,e){const n=e*t.bytesLen;return{bytesLen:n,encode:r=>{if(r.length!==e)throw new Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${e}`);const o=new Uint8Array(n);for(let e=0,n=0;e<r.length;e++){const s=t.encode(r[e]);o.set(s,n),s.fill(0),n+=s.length}return o},decode:e=>{u(e,n);const r=[];for(let n=0;n<e.length;n+=t.bytesLen)r.push(t.decode(e.subarray(n,n+t.bytesLen)));return r}}}function V(...t){for(const e of t)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function z(t){return(1<<t)-1}const D=Uint8Array.of();function W(t,e=D){if(u(t),u(e),e.length>255)throw new Error("context should be less than 255 bytes");return h(new Uint8Array([0,e.length]),e,t)}const Q=Uint8Array.from([6,9,96,134,72,1,101,3,4,2]);function q(t,e,n=D){if(u(e),u(n),n.length>255)throw new Error("context should be less than 255 bytes");const r=t(e);return h(new Uint8Array([1,n.length]),n,t.oid,r)}const Z=t=>(e,n)=>{n||(n=t.blockLen);const r=new Uint8Array(e.length+2);r.set(e);const o=e.length,s=new Uint8Array(n);let i=t.create({}),c=0,u=0;return{stats:()=>({calls:c,xofs:u}),get:(e,n)=>(r[o+0]=e,r[o+1]=n,i.destroy(),i=t.create({}).update(r),c++,()=>(u++,i.xofInto(s))),clean:()=>{i.destroy(),V(s,r)}}},J=Z(M),tt=Z(B);function et(t){G(t),void 0!==t.externalMu&&function(t,e=""){if("boolean"!=typeof t)throw new Error((e&&`"${e}" `)+"expected boolean, got type="+typeof t)}(t.externalMu,"opts.externalMu")}const nt=256,rt=8380417,ot=0|Math.floor(95232),st=0|Math.floor(261888),it={K:8,L:7,D:13,GAMMA1:2**19,GAMMA2:st,TAU:60,ETA:2,OMEGA:75},ct=t=>new Int32Array(t),{mod:ut,smod:lt,NTT:ft,bitsCoder:dt}=(t=>{const{newPoly:e,N:n,Q:r,F:o,ROOT_OF_UNITY:s,brvBits:i,isKyber:c}=t,u=(t,e=r)=>{const n=t%e|0;return 0|(n>=0?n:e+n)},l=function(){const t=e(n);for(let e=0;e<n;e++){const n=K(e,i),o=BigInt(s)**BigInt(n)%BigInt(r);t[e]=0|Number(o)}return t}(),f={add:(t,e)=>0|u((0|t)+(0|e)),sub:(t,e)=>0|u((0|t)-(0|e)),mul:(t,e)=>0|u((0|t)*(0|e)),inv:t=>{throw new Error("not implemented")}},d={N:n,roots:l,invertButterflies:!0,skipStages:c?1:0,brp:!1},a=R(f,{dit:!1,...d}),h=R(f,{dit:!0,...d}),g={encode:t=>a(t),decode:t=>{h(t);for(let e=0;e<t.length;e++)t[e]=u(o*t[e]);return t}};return{mod:u,smod:(t,e=r)=>{const n=0|u(t,e);return 0|(n>e>>1?n-e:n)},nttZetas:l,NTT:g,bitsCoder:(t,r)=>{const o=z(t),s=t*(n/8);return{bytesLen:s,encode:e=>{const n=new Uint8Array(s);for(let s=0,i=0,c=0,u=0;s<e.length;s++)for(i|=(r.encode(e[s])&o)<<c,c+=t;c>=8;c-=8,i>>=8)n[u++]=i&z(c);return n},decode:s=>{const i=e(n);for(let e=0,n=0,c=0,u=0;e<s.length;e++)for(n|=s[e]<<c,c+=8;c>=t;c-=t,n>>=t)i[u++]=r.decode(n&o);return i}}}}})({N:nt,Q:rt,F:8347681,ROOT_OF_UNITY:1753,newPoly:ct,isKyber:!1,brvBits:8}),at=t=>t,ht=(t,e=at,n=at)=>dt(t,{encode:t=>e(n(t)),decode:t=>n(e(t))}),gt=(t,e)=>{for(let n=0;n<t.length;n++)t[n]=ut(t[n]+e[n]);return t},pt=(t,e)=>{for(let n=0;n<t.length;n++)t[n]=ut(t[n]-e[n]);return t},yt=t=>{for(let e=0;e<nt;e++)t[e]<<=13;return t},wt=(t,e)=>{for(let n=0;n<nt;n++)if(Math.abs(lt(t[n]))>=e)return!0;return!1},bt=(t,e)=>{const n=ct(nt);for(let r=0;r<t.length;r++)n[r]=ut(t[r]*e[r]);return n};function Lt(t){const e=ct(nt);for(let n=0;n<nt;){const r=t();if(r.length%3)throw new Error("RejNTTPoly: unaligned block");for(let t=0;n<nt&&t<=r.length-3;t+=3){const o=8388607&(r[t+0]|r[t+1]<<8|r[t+2]<<16);o<rt&&(e[n++]=o)}}return e}function At(t){const{K:e,L:n,GAMMA1:r,GAMMA2:o,TAU:s,ETA:i,OMEGA:c}=t,{CRH_BYTES:l,TR_BYTES:f,C_TILDE_BYTES:d,XOF128:a,XOF256:h,securityLevel:g}=t;if(![2,4].includes(i))throw new Error("Wrong ETA");if(![1<<17,1<<19].includes(r))throw new Error("Wrong GAMMA1");if(![ot,st].includes(o))throw new Error("Wrong GAMMA2");const p=s*i,y=t=>{const e=ut(t),n=0|lt(e,2*o);return e-n===rt-1?{r1:0,r0:n-1|0}:{r1:0|Math.floor((e-n)/(2*o)),r0:n}},w=t=>y(t).r1,b=t=>y(t).r0,L=(t,e)=>t<=o||t>rt-o||t===rt-o&&0===e?0:1,A=(t,e)=>{const n=Math.floor((rt-1)/(2*o)),{r1:r,r0:s}=y(e);return 1===t?s>0?0|ut(r+1,n):0|ut(r-1,n):0|r},m=t=>{const e=ut(t),n=0|lt(e,8192);return{r1:0|Math.floor((e-n)/8192),r0:n}},E={bytesLen:c+e,encode:t=>{if(!1===t)throw new Error("hint.encode: hint is false");const n=new Uint8Array(c+e);for(let r=0,o=0;r<e;r++){for(let e=0;e<nt;e++)0!==t[r][e]&&(n[o++]=e);n[c+r]=o}return n},decode:t=>{const n=[];let r=0;for(let o=0;o<e;o++){const e=ct(nt);if(t[c+o]<r||t[c+o]>c)return!1;for(let n=r;n<t[c+o];n++){if(n>r&&t[n]<=t[n-1])return!1;e[t[n]]=1}r=t[c+o],n.push(e)}for(let e=r;e<c;e++)if(0!==t[e])return!1;return n}},k=ht(2===i?3:4,t=>i-t,t=>{if(!(-i<=t&&t<=i))throw new Error(`malformed key s1/s3 ${t} outside of ETA range [${-i}, ${i}]`);return t}),x=ht(13,t=>4096-t),I=ht(10),U=ht(r===1<<17?18:20,t=>lt(r-t)),_=H(ht(o===ot?6:4),e),T=j("publicKey",32,H(I,e)),v=j("secretKey",32,32,f,H(k,n),H(k,e),H(x,e)),O=j("signature",d,H(U,n),E),M=2===i?t=>t<15&&2-t%5:t=>t<9&&4-t;function F(t){const e=ct(nt);for(let n=0;n<nt;){const r=t();for(let t=0;n<nt&&t<r.length;t+=1){const o=M(15&r[t]),s=M(r[t]>>4&15);!1!==o&&(e[n++]=o),n<nt&&!1!==s&&(e[n++]=s)}}return e}const N=t=>{const e=ct(nt),n=B.create({}).update(t),r=new Uint8Array(B.blockLen);n.xofInto(r);const o=r.slice(0,8);for(let t=nt-s,i=8,c=0,u=0;t<nt;t++){let s=t+1;for(;s>t;)s=r[i++],i<B.blockLen||(n.xofInto(r),i=0);e[t]=e[s],e[s]=1-((o[c]>>u++&1)<<1),u>=8&&(c++,u=0)}return e},K=t=>{const e=ct(nt),n=ct(nt);for(let r=0;r<t.length;r++){const{r0:o,r1:s}=m(t[r]);e[r]=o,n[r]=s}return{r0:e,r1:n}},$=(t,e)=>{for(let n=0;n<nt;n++)t[n]=A(e[n],t[n]);return t},P=(t,e)=>{const n=ct(nt);let r=0;for(let o=0;o<nt;o++){const s=L(t[o],e[o]);n[o]=s,r+=s}return{v:n,cnt:r}},R=j("seed",32,64,32),G={info:{type:"internal-ml-dsa"},lengths:{secretKey:v.bytesLen,publicKey:T.bytesLen,seed:32,signature:O.bytesLen,signRand:32},keygen:t=>{const r=new Uint8Array(34),o=void 0===t;o&&(t=S(32)),u(t,32,"seed"),r.set(t),o&&V(t),r[32]=e,r[33]=n;const[s,i,c]=R.decode(B(r,{dkLen:R.bytesLen})),l=h(i),d=[];for(let t=0;t<n;t++)d.push(F(l.get(255&t,t>>8&255)));const g=[];for(let t=n;t<n+e;t++)g.push(F(l.get(255&t,t>>8&255)));const p=d.map(t=>ft.encode(t.slice())),y=[],w=[],b=a(s),L=ct(nt);for(let t=0;t<e;t++){V(L);for(let e=0;e<n;e++){const n=Lt(b.get(e,t));gt(L,bt(n,p[e]))}ft.decode(L);const{r0:e,r1:r}=K(gt(L,g[t]));y.push(e),w.push(r)}const A=T.encode([s,w]),m=B(A,{dkLen:f}),E=v.encode([s,c,m,d,g,y]);return b.clean(),l.clean(),V(s,i,c,d,g,p,L,y,w,m,r),{publicKey:A,secretKey:E}},getPublicKey:t=>{const[r,o,s,i,c,u]=v.decode(t),l=a(r),f=i.map(t=>ft.encode(t.slice())),d=[],h=ct(nt);for(let t=0;t<e;t++){h.fill(0);for(let e=0;e<n;e++){const n=Lt(l.get(e,t));gt(h,bt(n,f[e]))}ft.decode(h),gt(h,c[t]);const{r1:e}=K(h);d.push(e)}return l.clean(),V(h,f,u,i,c),T.encode([r,d])},sign:(t,s,i={})=>{C(i),et(i);let{extraEntropy:f,externalMu:g=!1}=i;const[y,L,A,m,E,k]=v.decode(s),x=[],I=a(y);for(let t=0;t<e;t++){const e=[];for(let r=0;r<n;r++)e.push(Lt(I.get(r,t)));x.push(e)}I.clean();for(let t=0;t<n;t++)ft.encode(m[t]);for(let t=0;t<e;t++)ft.encode(E[t]),ft.encode(k[t]);const T=g?t:B.create({dkLen:l}).update(A).update(t).digest(),M=!1===f?new Uint8Array(32):void 0===f?S(32):f;u(M,32,"extraEntropy");const F=B.create({dkLen:l}).update(L).update(M).update(T).digest();u(F,l);const K=h(F,U.bytesLen);t:for(let t=0;;){const s=[];for(let e=0;e<n;e++,t++)s.push(U.decode(K.get(255&t,t>>8)()));const i=s.map(t=>ft.encode(t.slice())),u=[];for(let t=0;t<e;t++){const e=ct(nt);for(let r=0;r<n;r++)gt(e,bt(x[t][r],i[r]));ft.decode(e),u.push(e)}const l=u.map(t=>t.map(w)),f=B.create({dkLen:d}).update(T).update(_.encode(l)).digest(),a=ft.encode(N(f)),h=m.map(t=>bt(t,a));for(let t=0;t<n;t++)if(gt(ft.decode(h[t]),s[t]),wt(h[t],r-p))continue t;let g=0;const y=[];for(let t=0;t<e;t++){const e=ft.decode(bt(E[t],a)),n=pt(u[t],e).map(b);if(wt(n,o-p))continue t;const r=ft.decode(bt(k[t],a));if(wt(r,o))continue t;gt(n,r);const s=P(n,l[t]);y.push(s.v),g+=s.cnt}if(g>c)continue;K.clean();const L=O.encode([f,h,y]);return V(f,h,y,a,l,u,i,s,F,T,m,E,k,...x),L}throw new Error("Unreachable code path reached, report this error")},verify:(t,o,s,i={})=>{et(i);const{externalMu:u=!1}=i,[h,g]=T.decode(s),y=B(s,{dkLen:f});if(t.length!==O.bytesLen)return!1;const[w,b,L]=O.decode(t);if(!1===L)return!1;for(let t=0;t<n;t++)if(wt(b[t],r-p))return!1;const A=u?o:B.create({dkLen:l}).update(y).update(o).digest(),m=ft.encode(N(w)),E=b.map(t=>t.slice());for(let t=0;t<n;t++)ft.encode(E[t]);const k=[],x=a(h);for(let t=0;t<e;t++){const e=bt(ft.encode(yt(g[t])),m),r=ct(nt);for(let e=0;e<n;e++){const n=Lt(x.get(e,t));gt(r,bt(n,E[e]))}const o=ft.decode(pt(r,e));k.push($(o,L[t]))}x.clean();const I=B.create({dkLen:d}).update(A).update(_.encode(k)).digest();for(const t of L)if(!(t.reduce((t,e)=>t+e,0)<=c))return!1;for(const t of b)if(wt(t,r-p))return!1;return X(w,I)}};return{info:{type:"ml-dsa"},internal:G,securityLevel:g,keygen:G.keygen,lengths:G.lengths,getPublicKey:G.getPublicKey,sign:(t,e,n={})=>{C(n);const r=W(t,n.context),o=G.sign(r,e,n);return V(r),o},verify:(t,e,n,r={})=>(Y(r),G.verify(t,W(e,r.context),n)),prehash:t=>(function(t,e=0){if(!t.oid||!X(t.oid.subarray(0,10),Q))throw new Error("hash.oid is invalid: expected NIST hash");const n=8*t.outputLen/2;if(e>n)throw new Error("Pre-hash security strength too low: "+n+", required: "+e)}(t,g),{info:{type:"hashml-dsa"},securityLevel:g,lengths:G.lengths,keygen:G.keygen,getPublicKey:G.getPublicKey,sign:(e,n,r={})=>{C(r);const o=q(t,e,r.context),s=G.sign(o,n,r);return V(o),s},verify:(e,n,r,o={})=>(Y(o),G.verify(e,q(t,n,o.context),r))})}}const mt=At({...it,CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:64,XOF128:J,XOF256:tt,securityLevel:256})}};
|
|
2
|
+
export const __webpack_esm_id__=118;export const __webpack_esm_ids__=[118];export const __webpack_esm_modules__={3118:(t,e,n)=>{n.d(e,{ml_dsa87:()=>mt});const r=BigInt(2**32-1),o=BigInt(32);function s(t,e=!1){return e?{h:Number(t&r),l:Number(t>>o&r)}:{h:0|Number(t>>o&r),l:0|Number(t&r)}}function i(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function c(t,e=""){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e&&`"${e}" `}expected integer >= 0, got ${t}`)}function u(t,e,n=""){const r=i(t),o=t?.length,s=void 0!==e;if(!r||s&&o!==e)throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${e}`:"")+", got "+(r?`length=${o}`:"type="+typeof t));return t}function l(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")}function f(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function d(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const a=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=d(t[e]);return t};function h(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];u(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const o=t[e];n.set(o,r),r+=o.length}return n}const g=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])}),p=BigInt(0),y=BigInt(1),w=BigInt(2),b=BigInt(7),L=BigInt(256),A=BigInt(113),m=[],E=[],k=[];for(let t=0,e=y,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],m.push(2*(5*r+n)),E.push((t+1)*(t+2)/2%64);let o=p;for(let t=0;t<7;t++)e=(e<<y^(e>>b)*A)%L,e&w&&(o^=y<<(y<<BigInt(t))-y);k.push(o)}const x=function(t,e=!1){const n=t.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){const{h:n,l:c}=s(t[i],e);[r[i],o[i]]=[n,c]}return[r,o]}(k,!0),I=x[0],U=x[1],_=(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),T=(t,e,n)=>n>32?((t,e,n)=>t<<n-32|e>>>64-n)(t,e,n):((t,e,n)=>e<<n|t>>>32-n)(t,e,n);class v{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(t,e,n,r=!1,o=24){if(this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=o,c(n,"outputLen"),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}clone(){return this._cloneInto()}keccak(){a(this.state32),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,o=(e+2)%10,s=n[o],i=n[o+1],c=_(s,i,1)^n[r],u=T(s,i,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=c,t[e+n+1]^=u}let e=t[2],o=t[3];for(let n=0;n<24;n++){const r=E[n],s=_(e,o,r),i=T(e,o,r),c=m[n];e=t[c],o=t[c+1],t[c]=s,t[c+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]^=I[r],t[1]^=U[r]}f(n)}(this.state32,this.rounds),a(this.state32),this.posOut=0,this.pos=0}update(t){l(this),u(t);const{blockLen:e,state:n}=this,r=t.length;for(let o=0;o<r;){const s=Math.min(e-this.pos,r-o);for(let e=0;e<s;e++)n[this.pos++]^=t[o++];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){l(this,!1),u(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,o=t.length;r<o;){this.posOut>=n&&this.keccak();const s=Math.min(n-this.posOut,o-r);t.set(e.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return c(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(function(t,e){u(t,void 0,"digestInto() output");const n=e.outputLen;if(t.length<n)throw new Error('"digestInto() output" expected to be of length >='+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,f(this.state)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:o,enableXOF:s}=this;return t||=new v(e,n,r,s,o),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=n,t.outputLen=r,t.enableXOF=s,t.destroyed=this.destroyed,t}}const O=(t,e,n,r={})=>function(t,e={}){const n=(e,n)=>t(n).update(e).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=e=>t(e),Object.assign(n,e),Object.freeze(n)}((r={})=>new v(e,t,void 0===r.dkLen?n:r.dkLen,!0),r),M=O(31,168,16,g(11)),B=O(31,136,32,g(12));function F(t){if(!Number.isSafeInteger(t)||t<0||t>4294967295)throw new Error("wrong u32 integer:"+t);return t}function N(t){return F(t),!(t&t-1)&&0!==t}function K(t,e){F(t);let n=0;for(let r=0;r<e;r++,t>>>=1)n=n<<1|1&t;return n}function $(t){return F(t),31-Math.clz32(t)}function P(t){const e=t.length;if(e<2||!N(e))throw new Error("n must be a power of 2 and greater than 1. Got "+e);const n=$(e);for(let r=0;r<e;r++){const e=K(r,n);if(r<e){const n=t[r];t[r]=t[e],t[e]=n}}return t}const R=(t,e)=>{const{N:n,roots:r,dit:o,invertButterflies:s=!1,skipStages:i=0,brp:c=!0}=e,u=$(n);if(!N(n))throw new Error("FFT: Polynomial size should be power of two");const l=o!==s;return e=>{if(e.length!==n)throw new Error("FFT: wrong Polynomial length");o&&c&&P(e);for(let c=0,f=1;c<u-i;c++){const d=o?c+1+i:u-c,a=1<<d,h=a>>1,g=n>>d;for(let i=0;i<n;i+=a)for(let c=0,u=f++;c<h;c++){const f=i+c,d=i+c+h,a=r[s?o?n-u:u:c*g],p=e[d],y=e[f];if(l){const n=t.mul(p,a);e[f]=t.add(y,n),e[d]=t.sub(y,n)}else s?(e[f]=t.add(p,y),e[d]=t.mul(t.sub(p,y),a)):(e[f]=t.add(y,p),e[d]=t.mul(t.sub(y,p),a))}}return!o&&c&&P(e),e}},S=function(t=32){const e="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof e?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))};function X(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}function G(t){if("object"!=typeof t||null===t||i(t))throw new Error("expected opts to be an object")}function Y(t){G(t),void 0!==t.context&&u(t.context,void 0,"opts.context")}function C(t){Y(t),!1!==t.extraEntropy&&void 0!==t.extraEntropy&&u(t.extraEntropy,void 0,"opts.extraEntropy")}function j(t,...e){const n=t=>"number"==typeof t?t:t.bytesLen,r=e.reduce((t,e)=>t+n(e),0);return{bytesLen:r,encode:o=>{const s=new Uint8Array(r);for(let r=0,i=0;r<e.length;r++){const c=e[r],l=n(c),f="number"==typeof c?o[r]:c.encode(o[r]);u(f,l,t),s.set(f,i),"number"!=typeof c&&f.fill(0),i+=l}return s},decode:o=>{u(o,r,t);const s=[];for(const t of e){const e=n(t),r=o.subarray(0,e);s.push("number"==typeof t?r:t.decode(r)),o=o.subarray(e)}return s}}}function H(t,e){const n=e*t.bytesLen;return{bytesLen:n,encode:r=>{if(r.length!==e)throw new Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${e}`);const o=new Uint8Array(n);for(let e=0,n=0;e<r.length;e++){const s=t.encode(r[e]);o.set(s,n),s.fill(0),n+=s.length}return o},decode:e=>{u(e,n);const r=[];for(let n=0;n<e.length;n+=t.bytesLen)r.push(t.decode(e.subarray(n,n+t.bytesLen)));return r}}}function V(...t){for(const e of t)if(Array.isArray(e))for(const t of e)t.fill(0);else e.fill(0)}function z(t){return(1<<t)-1}const D=Uint8Array.of();function W(t,e=D){if(u(t),u(e),e.length>255)throw new Error("context should be less than 255 bytes");return h(new Uint8Array([0,e.length]),e,t)}const Q=Uint8Array.from([6,9,96,134,72,1,101,3,4,2]);function q(t,e,n=D){if(u(e),u(n),n.length>255)throw new Error("context should be less than 255 bytes");const r=t(e);return h(new Uint8Array([1,n.length]),n,t.oid,r)}const Z=t=>(e,n)=>{n||(n=t.blockLen);const r=new Uint8Array(e.length+2);r.set(e);const o=e.length,s=new Uint8Array(n);let i=t.create({}),c=0,u=0;return{stats:()=>({calls:c,xofs:u}),get:(e,n)=>(r[o+0]=e,r[o+1]=n,i.destroy(),i=t.create({}).update(r),c++,()=>(u++,i.xofInto(s))),clean:()=>{i.destroy(),V(s,r)}}},J=Z(M),tt=Z(B);function et(t){G(t),void 0!==t.externalMu&&function(t,e=""){if("boolean"!=typeof t)throw new Error((e&&`"${e}" `)+"expected boolean, got type="+typeof t)}(t.externalMu,"opts.externalMu")}const nt=256,rt=8380417,ot=0|Math.floor(95232),st=0|Math.floor(261888),it={K:8,L:7,D:13,GAMMA1:2**19,GAMMA2:st,TAU:60,ETA:2,OMEGA:75},ct=t=>new Int32Array(t),{mod:ut,smod:lt,NTT:ft,bitsCoder:dt}=(t=>{const{newPoly:e,N:n,Q:r,F:o,ROOT_OF_UNITY:s,brvBits:i,isKyber:c}=t,u=(t,e=r)=>{const n=t%e|0;return 0|(n>=0?n:e+n)},l=function(){const t=e(n);for(let e=0;e<n;e++){const n=K(e,i),o=BigInt(s)**BigInt(n)%BigInt(r);t[e]=0|Number(o)}return t}(),f={add:(t,e)=>0|u((0|t)+(0|e)),sub:(t,e)=>0|u((0|t)-(0|e)),mul:(t,e)=>0|u((0|t)*(0|e)),inv:t=>{throw new Error("not implemented")}},d={N:n,roots:l,invertButterflies:!0,skipStages:c?1:0,brp:!1},a=R(f,{dit:!1,...d}),h=R(f,{dit:!0,...d}),g={encode:t=>a(t),decode:t=>{h(t);for(let e=0;e<t.length;e++)t[e]=u(o*t[e]);return t}};return{mod:u,smod:(t,e=r)=>{const n=0|u(t,e);return 0|(n>e>>1?n-e:n)},nttZetas:l,NTT:g,bitsCoder:(t,r)=>{const o=z(t),s=t*(n/8);return{bytesLen:s,encode:e=>{const n=new Uint8Array(s);for(let s=0,i=0,c=0,u=0;s<e.length;s++)for(i|=(r.encode(e[s])&o)<<c,c+=t;c>=8;c-=8,i>>=8)n[u++]=i&z(c);return n},decode:s=>{const i=e(n);for(let e=0,n=0,c=0,u=0;e<s.length;e++)for(n|=s[e]<<c,c+=8;c>=t;c-=t,n>>=t)i[u++]=r.decode(n&o);return i}}}}})({N:nt,Q:rt,F:8347681,ROOT_OF_UNITY:1753,newPoly:ct,isKyber:!1,brvBits:8}),at=t=>t,ht=(t,e=at,n=at)=>dt(t,{encode:t=>e(n(t)),decode:t=>n(e(t))}),gt=(t,e)=>{for(let n=0;n<t.length;n++)t[n]=ut(t[n]+e[n]);return t},pt=(t,e)=>{for(let n=0;n<t.length;n++)t[n]=ut(t[n]-e[n]);return t},yt=t=>{for(let e=0;e<nt;e++)t[e]<<=13;return t},wt=(t,e)=>{for(let n=0;n<nt;n++)if(Math.abs(lt(t[n]))>=e)return!0;return!1},bt=(t,e)=>{const n=ct(nt);for(let r=0;r<t.length;r++)n[r]=ut(t[r]*e[r]);return n};function Lt(t){const e=ct(nt);for(let n=0;n<nt;){const r=t();if(r.length%3)throw new Error("RejNTTPoly: unaligned block");for(let t=0;n<nt&&t<=r.length-3;t+=3){const o=8388607&(r[t+0]|r[t+1]<<8|r[t+2]<<16);o<rt&&(e[n++]=o)}}return e}function At(t){const{K:e,L:n,GAMMA1:r,GAMMA2:o,TAU:s,ETA:i,OMEGA:c}=t,{CRH_BYTES:l,TR_BYTES:f,C_TILDE_BYTES:d,XOF128:a,XOF256:h,securityLevel:g}=t;if(![2,4].includes(i))throw new Error("Wrong ETA");if(![1<<17,1<<19].includes(r))throw new Error("Wrong GAMMA1");if(![ot,st].includes(o))throw new Error("Wrong GAMMA2");const p=s*i,y=t=>{const e=ut(t),n=0|lt(e,2*o);return e-n===rt-1?{r1:0,r0:n-1|0}:{r1:0|Math.floor((e-n)/(2*o)),r0:n}},w=t=>y(t).r1,b=t=>y(t).r0,L=(t,e)=>t<=o||t>rt-o||t===rt-o&&0===e?0:1,A=(t,e)=>{const n=Math.floor((rt-1)/(2*o)),{r1:r,r0:s}=y(e);return 1===t?s>0?0|ut(r+1,n):0|ut(r-1,n):0|r},m=t=>{const e=ut(t),n=0|lt(e,8192);return{r1:0|Math.floor((e-n)/8192),r0:n}},E={bytesLen:c+e,encode:t=>{if(!1===t)throw new Error("hint.encode: hint is false");const n=new Uint8Array(c+e);for(let r=0,o=0;r<e;r++){for(let e=0;e<nt;e++)0!==t[r][e]&&(n[o++]=e);n[c+r]=o}return n},decode:t=>{const n=[];let r=0;for(let o=0;o<e;o++){const e=ct(nt);if(t[c+o]<r||t[c+o]>c)return!1;for(let n=r;n<t[c+o];n++){if(n>r&&t[n]<=t[n-1])return!1;e[t[n]]=1}r=t[c+o],n.push(e)}for(let e=r;e<c;e++)if(0!==t[e])return!1;return n}},k=ht(2===i?3:4,t=>i-t,t=>{if(!(-i<=t&&t<=i))throw new Error(`malformed key s1/s3 ${t} outside of ETA range [${-i}, ${i}]`);return t}),x=ht(13,t=>4096-t),I=ht(10),U=ht(r===1<<17?18:20,t=>lt(r-t)),_=H(ht(o===ot?6:4),e),T=j("publicKey",32,H(I,e)),v=j("secretKey",32,32,f,H(k,n),H(k,e),H(x,e)),O=j("signature",d,H(U,n),E),M=2===i?t=>t<15&&2-t%5:t=>t<9&&4-t;function F(t){const e=ct(nt);for(let n=0;n<nt;){const r=t();for(let t=0;n<nt&&t<r.length;t+=1){const o=M(15&r[t]),s=M(r[t]>>4&15);!1!==o&&(e[n++]=o),n<nt&&!1!==s&&(e[n++]=s)}}return e}const N=t=>{const e=ct(nt),n=B.create({}).update(t),r=new Uint8Array(B.blockLen);n.xofInto(r);const o=r.slice(0,8);for(let t=nt-s,i=8,c=0,u=0;t<nt;t++){let s=t+1;for(;s>t;)s=r[i++],i<B.blockLen||(n.xofInto(r),i=0);e[t]=e[s],e[s]=1-((o[c]>>u++&1)<<1),u>=8&&(c++,u=0)}return e},K=t=>{const e=ct(nt),n=ct(nt);for(let r=0;r<t.length;r++){const{r0:o,r1:s}=m(t[r]);e[r]=o,n[r]=s}return{r0:e,r1:n}},$=(t,e)=>{for(let n=0;n<nt;n++)t[n]=A(e[n],t[n]);return t},P=(t,e)=>{const n=ct(nt);let r=0;for(let o=0;o<nt;o++){const s=L(t[o],e[o]);n[o]=s,r+=s}return{v:n,cnt:r}},R=j("seed",32,64,32),G={info:{type:"internal-ml-dsa"},lengths:{secretKey:v.bytesLen,publicKey:T.bytesLen,seed:32,signature:O.bytesLen,signRand:32},keygen:t=>{const r=new Uint8Array(34),o=void 0===t;o&&(t=S(32)),u(t,32,"seed"),r.set(t),o&&V(t),r[32]=e,r[33]=n;const[s,i,c]=R.decode(B(r,{dkLen:R.bytesLen})),l=h(i),d=[];for(let t=0;t<n;t++)d.push(F(l.get(255&t,t>>8&255)));const g=[];for(let t=n;t<n+e;t++)g.push(F(l.get(255&t,t>>8&255)));const p=d.map(t=>ft.encode(t.slice())),y=[],w=[],b=a(s),L=ct(nt);for(let t=0;t<e;t++){V(L);for(let e=0;e<n;e++){const n=Lt(b.get(e,t));gt(L,bt(n,p[e]))}ft.decode(L);const{r0:e,r1:r}=K(gt(L,g[t]));y.push(e),w.push(r)}const A=T.encode([s,w]),m=B(A,{dkLen:f}),E=v.encode([s,c,m,d,g,y]);return b.clean(),l.clean(),V(s,i,c,d,g,p,L,y,w,m,r),{publicKey:A,secretKey:E}},getPublicKey:t=>{const[r,o,s,i,c,u]=v.decode(t),l=a(r),f=i.map(t=>ft.encode(t.slice())),d=[],h=ct(nt);for(let t=0;t<e;t++){h.fill(0);for(let e=0;e<n;e++){const n=Lt(l.get(e,t));gt(h,bt(n,f[e]))}ft.decode(h),gt(h,c[t]);const{r1:e}=K(h);d.push(e)}return l.clean(),V(h,f,u,i,c),T.encode([r,d])},sign:(t,s,i={})=>{C(i),et(i);let{extraEntropy:f,externalMu:g=!1}=i;const[y,L,A,m,E,k]=v.decode(s),x=[],I=a(y);for(let t=0;t<e;t++){const e=[];for(let r=0;r<n;r++)e.push(Lt(I.get(r,t)));x.push(e)}I.clean();for(let t=0;t<n;t++)ft.encode(m[t]);for(let t=0;t<e;t++)ft.encode(E[t]),ft.encode(k[t]);const T=g?t:B.create({dkLen:l}).update(A).update(t).digest(),M=!1===f?new Uint8Array(32):void 0===f?S(32):f;u(M,32,"extraEntropy");const F=B.create({dkLen:l}).update(L).update(M).update(T).digest();u(F,l);const K=h(F,U.bytesLen);t:for(let t=0;;){const s=[];for(let e=0;e<n;e++,t++)s.push(U.decode(K.get(255&t,t>>8)()));const i=s.map(t=>ft.encode(t.slice())),u=[];for(let t=0;t<e;t++){const e=ct(nt);for(let r=0;r<n;r++)gt(e,bt(x[t][r],i[r]));ft.decode(e),u.push(e)}const l=u.map(t=>t.map(w)),f=B.create({dkLen:d}).update(T).update(_.encode(l)).digest(),a=ft.encode(N(f)),h=m.map(t=>bt(t,a));for(let t=0;t<n;t++)if(gt(ft.decode(h[t]),s[t]),wt(h[t],r-p))continue t;let g=0;const y=[];for(let t=0;t<e;t++){const e=ft.decode(bt(E[t],a)),n=pt(u[t],e).map(b);if(wt(n,o-p))continue t;const r=ft.decode(bt(k[t],a));if(wt(r,o))continue t;gt(n,r);const s=P(n,l[t]);y.push(s.v),g+=s.cnt}if(g>c)continue;K.clean();const L=O.encode([f,h,y]);return V(f,h,y,a,l,u,i,s,F,T,m,E,k,...x),L}throw new Error("Unreachable code path reached, report this error")},verify:(t,o,s,i={})=>{et(i);const{externalMu:u=!1}=i,[h,g]=T.decode(s),y=B(s,{dkLen:f});if(t.length!==O.bytesLen)return!1;const[w,b,L]=O.decode(t);if(!1===L)return!1;for(let t=0;t<n;t++)if(wt(b[t],r-p))return!1;const A=u?o:B.create({dkLen:l}).update(y).update(o).digest(),m=ft.encode(N(w)),E=b.map(t=>t.slice());for(let t=0;t<n;t++)ft.encode(E[t]);const k=[],x=a(h);for(let t=0;t<e;t++){const e=bt(ft.encode(yt(g[t])),m),r=ct(nt);for(let e=0;e<n;e++){const n=Lt(x.get(e,t));gt(r,bt(n,E[e]))}const o=ft.decode(pt(r,e));k.push($(o,L[t]))}x.clean();const I=B.create({dkLen:d}).update(A).update(_.encode(k)).digest();for(const t of L)if(!(t.reduce((t,e)=>t+e,0)<=c))return!1;for(const t of b)if(wt(t,r-p))return!1;return X(w,I)}};return{info:{type:"ml-dsa"},internal:G,securityLevel:g,keygen:G.keygen,lengths:G.lengths,getPublicKey:G.getPublicKey,sign:(t,e,n={})=>{C(n);const r=W(t,n.context),o=G.sign(r,e,n);return V(r),o},verify:(t,e,n,r={})=>(Y(r),G.verify(t,W(e,r.context),n)),prehash:t=>(function(t,e=0){if(!t.oid||!X(t.oid.subarray(0,10),Q))throw new Error("hash.oid is invalid: expected NIST hash");const n=8*t.outputLen/2;if(e>n)throw new Error("Pre-hash security strength too low: "+n+", required: "+e)}(t,g),{info:{type:"hashml-dsa"},securityLevel:g,lengths:G.lengths,keygen:G.keygen,getPublicKey:G.getPublicKey,sign:(e,n,r={})=>{C(r);const o=q(t,e,r.context),s=G.sign(o,n,r);return V(o),s},verify:(e,n,r,o={})=>(Y(o),G.verify(e,q(t,n,o.context),r))})}}const mt=At({...it,CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:64,XOF128:J,XOF256:tt,securityLevel:256})}};
|
package/dist/122.index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! For license information please see 122.index.js.LICENSE.txt */
|
|
1
|
+
/*! For license information please see 122.index.js.LICENSE.txt */
|
|
2
2
|
export const __webpack_esm_id__=122;export const __webpack_esm_ids__=[122];export const __webpack_esm_modules__={86122:(f,t,e)=>{e.d(t,{ed25519:()=>m});var n=e(8442),i=e(32531),r=e(50649),s=e(26618),o=(e(7766),e(15916)),c=e(78906);const a=BigInt(0),d=BigInt(1),u=BigInt(2),B=(BigInt(3),BigInt(5)),g=BigInt(8),l=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),_=(()=>({p:l,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:g,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function I(f){return f[0]&=248,f[31]&=127,f[31]|=64,f}const p=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function w(f,t){const e=l,n=(0,o.zi)(t*t*t,e),i=function(f){const t=BigInt(10),e=BigInt(20),n=BigInt(40),i=BigInt(80),r=l,s=f*f%r*f%r,c=(0,o.zH)(s,u,r)*s%r,a=(0,o.zH)(c,d,r)*f%r,g=(0,o.zH)(a,B,r)*a%r,_=(0,o.zH)(g,t,r)*g%r,I=(0,o.zH)(_,e,r)*_%r,p=(0,o.zH)(I,n,r)*I%r,w=(0,o.zH)(p,i,r)*p%r,z=(0,o.zH)(w,i,r)*p%r,x=(0,o.zH)(z,t,r)*g%r;return{pow_p_5_8:(0,o.zH)(x,u,r)*f%r,b2:s}}(f*(0,o.zi)(n*n*t,e)).pow_p_5_8;let r=(0,o.zi)(f*n*i,e);const s=(0,o.zi)(t*r*r,e),c=r,a=(0,o.zi)(r*p,e),g=s===f,_=s===(0,o.zi)(-f,e),I=s===(0,o.zi)(-f*p,e);return g&&(r=c),(_||I)&&(r=a),(0,o.dQ)(r,e)&&(r=(0,o.zi)(-r,e)),{isValid:g||_,value:r}}const z=(()=>(0,o.D0)(_.p,{isLE:!0}))(),x=(()=>(0,o.D0)(_.n,{isLE:!0}))(),h=(()=>({..._,Fp:z,hash:n.Zf,adjustScalarBytes:I,uvRatio:w}))(),m=(()=>(0,s.n6)(h))(),H=p,b=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),E=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),v=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),y=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),P=f=>w(d,f),Q=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),F=f=>m.Point.Fp.create((0,c.lX)(f)&Q);function O(f){const{d:t}=_,e=l,n=f=>z.create(f),i=n(H*f*f),r=n((i+d)*v);let s=BigInt(-1);const c=n((s-t*i)*n(i+t));let{isValid:a,value:u}=w(r,c),B=n(u*f);(0,o.dQ)(B,e)||(B=n(-B)),a||(u=B),a||(s=i);const g=n(s*(i-d)*y-c),I=u*u,p=n((u+u)*c),x=n(g*b),h=n(d-I),E=n(d+I);return new m.Point(n(p*E),n(h*x),n(x*E),n(p*h))}class R extends s.i5{constructor(f){super(f)}static fromAffine(f){return new R(m.Point.fromAffine(f))}assertSame(f){if(!(f instanceof R))throw new Error("RistrettoPoint expected")}init(f){return new R(f)}static hashToCurve(f){return function(f){(0,i.DO)(f,64);const t=O(F(f.subarray(0,32))),e=O(F(f.subarray(32,64)));return new R(t.add(e))}((0,c.qj)("ristrettoHash",f,64))}static fromBytes(f){(0,i.DO)(f,32);const{a:t,d:e}=_,n=l,r=f=>z.create(f),s=F(f);if(!(0,c.ex)(z.toBytes(s),f)||(0,o.dQ)(s,n))throw new Error("invalid ristretto255 encoding 1");const u=r(s*s),B=r(d+t*u),g=r(d-t*u),I=r(B*B),p=r(g*g),w=r(t*e*I-p),{isValid:x,value:h}=P(r(w*p)),H=r(h*g),b=r(h*H*w);let E=r((s+s)*H);(0,o.dQ)(E,n)&&(E=r(-E));const v=r(B*b),y=r(E*v);if(!x||(0,o.dQ)(y,n)||v===a)throw new Error("invalid ristretto255 encoding 2");return new R(new m.Point(E,v,d,y))}static fromHex(f){return R.fromBytes((0,c.qj)("ristrettoHex",f,32))}static msm(f,t){return(0,r.Xf)(R,m.Point.Fn,f,t)}toBytes(){let{X:f,Y:t,Z:e,T:n}=this.ep;const i=l,r=f=>z.create(f),s=r(r(e+t)*r(e-t)),c=r(f*t),a=r(c*c),{value:d}=P(r(s*a)),u=r(d*s),B=r(d*c),g=r(u*B*n);let _;if((0,o.dQ)(n*g,i)){let e=r(t*H),n=r(f*H);f=e,t=n,_=r(u*E)}else _=B;(0,o.dQ)(f*g,i)&&(t=r(-t));let I=r((e-t)*_);return(0,o.dQ)(I,i)&&(I=r(-I)),z.toBytes(I)}equals(f){this.assertSame(f);const{X:t,Y:e}=this.ep,{X:n,Y:i}=f.ep,r=f=>z.create(f),s=r(t*i)===r(e*n),o=r(e*i)===r(t*n);return s||o}is0(){return this.equals(R.ZERO)}}R.BASE=(()=>new R(m.Point.BASE))(),R.ZERO=(()=>new R(m.Point.ZERO))(),R.Fp=(()=>z)(),R.Fn=(()=>x)()}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
package/dist/18.index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const __webpack_esm_id__=18;export const __webpack_esm_ids__=[18];export const __webpack_esm_modules__={8018:(e,r,i)=>{i.d(r,{MlKem1024:()=>o,MlKem512:()=>l,MlKem768:()=>b});var t=i(
|
|
1
|
+
export const __webpack_esm_id__=18;export const __webpack_esm_ids__=[18];export const __webpack_esm_modules__={8018:(e,r,i)=>{i.d(r,{MlKem1024:()=>o,MlKem512:()=>l,MlKem768:()=>b});var t=i(8619),a=i(4220);class n{constructor(){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_prim",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}async serializePublicKey(e){try{return await this._serializePublicKey(e)}catch(e){throw new a.LV(e)}}async deserializePublicKey(e){try{return await this._deserializePublicKey(e)}catch(e){throw new a.Ug(e)}}async serializePrivateKey(e){try{return await this._serializePrivateKey(e)}catch(e){throw new a.LV(e)}}async deserializePrivateKey(e){try{return await this._deserializePrivateKey(e)}catch(e){throw new a.Ug(e)}}async generateKeyPair(){await this._setup();const e=new Uint8Array(32),r=new Uint8Array(32);try{this._api.getRandomValues(e),this._api.getRandomValues(r)}catch(e){throw new a.EM(e)}try{const i=(0,a.xW)(e,r),[t,n]=await this._prim.deriveKeyPair(i);return{privateKey:await this.deserializePrivateKey(i.buffer),publicKey:await this.deserializePublicKey(t.buffer)}}catch(e){throw new a.$7(e)}}async deriveKeyPair(e){try{const[r,i]=await this._prim.deriveKeyPair(new Uint8Array(e));return{privateKey:await this.deserializePrivateKey(e),publicKey:await this.deserializePublicKey(r.buffer)}}catch(e){throw new a.$7(e)}}async importKey(e,r,i=!0){await this._setup();try{let t;if("jwk"===e){if(r instanceof ArrayBuffer||r instanceof Uint8Array)throw new Error("Invalid jwk key format");t=await this._importJWK(r,i)}else if(r instanceof ArrayBuffer)t=new Uint8Array(r);else{if(!(r instanceof Uint8Array))throw new Error("Invalid key format");t=r}if(i&&t.byteLength!==this.publicKeySize)throw new Error("Invalid length of the key");if(!i&&t.byteLength!==this.privateKeySize)throw new Error("Invalid length of the key");return new a.Bk(this.name,t,i?"public":"private",i?[]:a.xE)}catch(e){throw new a.Ug(e)}}async encap(e){let r;if(void 0!==e.ekm)if(e.ekm instanceof ArrayBuffer)r=new Uint8Array(e.ekm);else{if(!(e.ekm instanceof Uint8Array))throw new a.NS("ekm must be 32 bytes in length");r=e.ekm}const i=new Uint8Array(await this.serializePublicKey(e.recipientPublicKey));if(i.byteLength!==this.publicKeySize)throw new a.NS("Invalid length of recipientKey");try{const[e,t]=await this._prim.encap(i,r);return{sharedSecret:t.buffer,enc:e.buffer}}catch(e){throw new a.Wg(e)}}async decap(e){const r=(0,a.Di)(e.recipientKey)?e.recipientKey.privateKey:e.recipientKey;if(e.enc.byteLength!==this.encSize)throw new a.NS("Invalid length of enc");const i=new Uint8Array(e.enc),t=new Uint8Array(await this.serializePrivateKey(r));if(t.byteLength!==this.privateKeySize)throw new a.NS("Invalid length of recipientKey");try{const[e,r]=await this._prim.deriveKeyPair(t);return(await this._prim.decap(i,r)).buffer}catch(e){throw new a.uu(e)}}async _setup(){void 0===this._api&&(this._api=await(0,a.QZ)())}_serializePublicKey(e){return new Promise((r,i)=>{"public"!==e.type&&i(new Error("Not public key")),e.algorithm.name!==this.name&&i(new Error(`Invalid algorithm name: ${e.algorithm.name}`)),e.key.byteLength!==this.publicKeySize&&i(new Error(`Invalid key length: ${e.key.byteLength}`)),r(e.key.buffer)})}_deserializePublicKey(e){return new Promise((r,i)=>{e.byteLength!==this.publicKeySize&&i(new Error(`Invalid key length: ${e.byteLength}`)),r(new a.Bk(this.name,new Uint8Array(e),"public"))})}_serializePrivateKey(e){return new Promise((r,i)=>{"private"!==e.type&&i(new Error("Not private key")),e.algorithm.name!==this.name&&i(new Error(`Invalid algorithm name: ${e.algorithm.name}`)),e.key.byteLength!==this.privateKeySize&&i(new Error(`Invalid key length: ${e.key.byteLength}`)),r(e.key.buffer)})}_deserializePrivateKey(e){return new Promise((r,i)=>{e.byteLength!==this.privateKeySize&&i(new Error(`Invalid key length: ${e.byteLength}`)),r(new a.Bk(this.name,new Uint8Array(e),"private",["deriveBits"]))})}_importJWK(e,r){return new Promise((i,t)=>{void 0!==e.kty&&"AKP"===e.kty||t(new Error(`Invalid kty: ${e.kty}`)),void 0!==e.alg&&e.alg===this.name||t(new Error(`Invalid alg: ${e.alg}`)),r||(void 0===e.priv&&t(new Error("Invalid key: `priv` not found")),void 0===e.key_ops||1===e.key_ops.length&&"deriveBits"===e.key_ops[0]||t(new Error("Invalid key: `key_ops` should be ['deriveBits']")),i((0,a.rf)(e.priv))),void 0!==e.priv&&t(new Error("Invalid key: `priv` should not be set")),void 0===e.pub&&t(new Error("Invalid key: `pub` not found")),void 0!==e.key_ops&&e.key_ops.length>0&&t(new Error("Invalid key: `key_ops` should not be set")),i((0,a.rf)(e.pub))})}}class l extends n{constructor(){super(),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:a.h.MlKem512}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ML-KEM-512"}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:768}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:800}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:64}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_prim",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._prim=new t.Zc}}class b extends n{constructor(){super(),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:a.h.MlKem768}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ML-KEM-768"}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:1088}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:1184}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:64}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_prim",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._prim=new t.wo}}class o extends n{constructor(){super(),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:a.h.MlKem1024}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ML-KEM-1024"}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:1568}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:1568}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:64}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_prim",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._prim=new t.AL}}}};
|
package/dist/195.index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 195.index.js.LICENSE.txt */
|
|
2
|
-
export const __webpack_esm_id__=195;export const __webpack_esm_ids__=[195];export const __webpack_esm_modules__={7766:(t,e,r)=>{r.d(e,{Tq:()=>u,qX:()=>d,zc:()=>c});var n=r(32531);function i(t,e){if(o(t),o(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=255&t,t>>>=8;return new Uint8Array(r)}function s(t,e){const r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function o(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function a(t){if(!(0,n.aY)(t)&&"string"!=typeof t)throw new Error("DST must be Uint8Array or string");return"string"==typeof t?(0,n.AI)(t):t}function u(t,e,r,u){(0,n.DO)(t),o(r),(e=a(e)).length>255&&(e=u((0,n.Id)((0,n.AI)("H2C-OVERSIZE-DST-"),e)));const{outputLen:c,blockLen:d}=u,h=Math.ceil(r/c);if(r>65535||h>255)throw new Error("expand_message_xmd: invalid lenInBytes");const l=(0,n.Id)(e,i(e.length,1)),f=i(0,d),p=i(r,2),y=new Array(h),m=u((0,n.Id)(f,t,p,i(0,1),l));y[0]=u((0,n.Id)(m,i(1,1),l));for(let t=1;t<=h;t++){const e=[s(m,y[t-1]),i(t+1,1),l];y[t]=u((0,n.Id)(...e))}return(0,n.Id)(...y).slice(0,r)}function c(t,e,r,s,u){if((0,n.DO)(t),o(r),(e=a(e)).length>255){const t=Math.ceil(2*s/8);e=u.create({dkLen:t}).update((0,n.AI)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return u.create({dkLen:r}).update(t).update(i(r,2)).update(e).update(i(e.length,1)).digest()}const d=(0,n.AI)("HashToScalar-")},26618:(t,e,r)=>{r.d(e,{TO:()=>h,i5:()=>l,n6:()=>f});var n=r(78906),i=r(32531),s=r(50649),o=r(15916);const a=BigInt(0),u=BigInt(1),c=BigInt(2),d=BigInt(8);function h(t,e={}){const r=(0,s.UT)("edwards",t,e,e.FpFnLE),{Fp:o,Fn:h}=r;let l=r.CURVE;const{h:f}=l;(0,n.DS)(e,{},{uvRatio:"function"});const p=c<<BigInt(8*h.BYTES)-u,y=t=>o.create(t),m=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:o.sqrt(o.div(t,e))}}catch(t){return{isValid:!1,value:a}}});if(!function(t,e,r,n){const i=t.sqr(r),s=t.sqr(n),o=t.add(t.mul(e.a,i),s),a=t.add(t.ONE,t.mul(e.d,t.mul(i,s)));return t.eql(o,a)}(o,l,l.Gx,l.Gy))throw new Error("bad curve params: generator point");function g(t,e,r=!1){const i=r?u:a;return(0,n.aK)("coordinate "+t,e,i,p),e}function w(t){if(!(t instanceof E))throw new Error("ExtendedPoint expected")}const B=(0,n.x)((t,e)=>{const{X:r,Y:n,Z:i}=t,s=t.is0();null==e&&(e=s?d:o.inv(i));const c=y(r*e),h=y(n*e),l=o.mul(i,e);if(s)return{x:a,y:u};if(l!==u)throw new Error("invZ was invalid");return{x:c,y:h}}),x=(0,n.x)(t=>{const{a:e,d:r}=l;if(t.is0())throw new Error("bad point: ZERO");const{X:n,Y:i,Z:s,T:o}=t,a=y(n*n),u=y(i*i),c=y(s*s),d=y(c*c),h=y(a*e);if(y(c*y(h+u))!==y(d+y(r*y(a*u))))throw new Error("bad point: equation left != right (1)");if(y(n*i)!==y(s*o))throw new Error("bad point: equation left != right (2)");return!0});class E{constructor(t,e,r,n){this.X=g("x",t),this.Y=g("y",e),this.Z=g("z",r,!0),this.T=g("t",n),Object.freeze(this)}static CURVE(){return l}static fromAffine(t){if(t instanceof E)throw new Error("extended point not allowed");const{x:e,y:r}=t||{};return g("x",e),g("y",r),new E(e,r,u,y(e*r))}static fromBytes(t,e=!1){const r=o.BYTES,{a:i,d:s}=l;t=(0,n.nC)((0,n.eV)(t,r,"point")),(0,n.d6)(e,"zip215");const c=(0,n.nC)(t),d=t[r-1];c[r-1]=-129&d;const h=(0,n.lX)(c),f=e?p:o.ORDER;(0,n.aK)("point.y",h,a,f);const g=y(h*h),w=y(g-u),B=y(s*g-i);let{isValid:x,value:S}=m(w,B);if(!x)throw new Error("bad point: invalid y coordinate");const b=(S&u)===u,v=!!(128&d);if(!e&&S===a&&v)throw new Error("bad point: x=0 and x_0=1");return v!==b&&(S=y(-S)),E.fromAffine({x:S,y:h})}static fromHex(t,e=!1){return E.fromBytes((0,n.qj)("point",t),e)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return S.createCache(this,t),e||this.multiply(c),this}assertValidity(){x(this)}equals(t){w(t);const{X:e,Y:r,Z:n}=this,{X:i,Y:s,Z:o}=t,a=y(e*o),u=y(i*n),c=y(r*o),d=y(s*n);return a===u&&c===d}is0(){return this.equals(E.ZERO)}negate(){return new E(y(-this.X),this.Y,this.Z,y(-this.T))}double(){const{a:t}=l,{X:e,Y:r,Z:n}=this,i=y(e*e),s=y(r*r),o=y(c*y(n*n)),a=y(t*i),u=e+r,d=y(y(u*u)-i-s),h=a+s,f=h-o,p=a-s,m=y(d*f),g=y(h*p),w=y(d*p),B=y(f*h);return new E(m,g,B,w)}add(t){w(t);const{a:e,d:r}=l,{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:u,Z:c,T:d}=t,h=y(n*a),f=y(i*u),p=y(o*r*d),m=y(s*c),g=y((n+i)*(a+u)-h-f),B=m-p,x=m+p,S=y(f-e*h),b=y(g*B),v=y(x*S),A=y(g*S),T=y(B*x);return new E(b,v,T,A)}subtract(t){return this.add(t.negate())}multiply(t){if(!h.isValidNot0(t))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:e,f:r}=S.cached(this,t,t=>(0,s.Ak)(E,t));return(0,s.Ak)(E,[e,r])[0]}multiplyUnsafe(t,e=E.ZERO){if(!h.isValid(t))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return t===a?E.ZERO:this.is0()||t===u?this:S.unsafe(this,t,t=>(0,s.Ak)(E,t),e)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return S.unsafe(this,l.n).is0()}toAffine(t){return B(this,t)}clearCofactor(){return f===u?this:this.multiplyUnsafe(f)}toBytes(){const{x:t,y:e}=this.toAffine(),r=o.toBytes(e);return r[r.length-1]|=t&u?128:0,r}toHex(){return(0,i.My)(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(t){return(0,s.Ak)(E,t)}static msm(t,e){return(0,s.Xf)(E,h,t,e)}_setWindowSize(t){this.precompute(t)}toRawBytes(){return this.toBytes()}}E.BASE=new E(l.Gx,l.Gy,u,y(l.Gx*l.Gy)),E.ZERO=new E(a,u,u,a),E.Fp=o,E.Fn=h;const S=new s.hT(E,h.BITS);return E.BASE.precompute(8),E}class l{constructor(t){this.ep=t}static fromBytes(t){(0,n.SJ)()}static fromHex(t){(0,n.SJ)()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return(0,i.My)(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,e){return this.init(this.ep.precompute(t,e))}toRawBytes(){return this.toBytes()}}function f(t){const{CURVE:e,curveOpts:r,hash:s,eddsaOpts:a}=function(t){const e={a:t.a,d:t.d,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r={Fp:t.Fp,Fn:(0,o.D0)(e.n,t.nBitLength,!0),uvRatio:t.uvRatio},n={randomBytes:t.randomBytes,adjustScalarBytes:t.adjustScalarBytes,domain:t.domain,prehash:t.prehash,mapToCurve:t.mapToCurve};return{CURVE:e,curveOpts:r,hash:t.hash,eddsaOpts:n}}(t);return function(t,e){const r=e.Point;return Object.assign({},e,{ExtendedPoint:r,CURVE:t,nBitLength:r.Fn.BITS,nByteLength:r.Fn.BYTES})}(t,function(t,e,r={}){if("function"!=typeof e)throw new Error('"hash" function param is required');(0,n.DS)(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:s}=r,{BASE:o,Fp:a,Fn:c}=t,d=r.randomBytes||i.po,h=r.adjustScalarBytes||(t=>t),l=r.domain||((t,e,r)=>{if((0,n.d6)(r,"phflag"),e.length||r)throw new Error("Contexts/pre-hash are not supported");return t});function f(t){return c.create((0,n.lX)(t))}function p(t){const{head:r,prefix:i,scalar:s}=function(t){const r=B.secretKey;t=(0,n.qj)("private key",t,r);const i=(0,n.qj)("hashed private key",e(t),2*r),s=h(i.slice(0,r));return{head:s,prefix:i.slice(r,2*r),scalar:f(s)}}(t),a=o.multiply(s),u=a.toBytes();return{head:r,prefix:i,scalar:s,point:a,pointBytes:u}}function y(t){return p(t).pointBytes}function m(t=Uint8Array.of(),...r){const o=(0,i.Id)(...r);return f(e(l(o,(0,n.qj)("context",t),!!s)))}const g={zip215:!0},w=a.BYTES,B={secretKey:w,publicKey:w,signature:2*w,seed:w};function x(t=d(B.seed)){return(0,n.eV)(t,B.seed,"seed")}const E={getExtendedPublicKey:p,randomSecretKey:x,isValidSecretKey:function(t){return(0,i.aY)(t)&&t.length===c.BYTES},isValidPublicKey:function(e,r){try{return!!t.fromBytes(e,r)}catch(t){return!1}},toMontgomery(e){const{y:r}=t.fromBytes(e),n=B.publicKey,i=32===n;if(!i&&57!==n)throw new Error("only defined for 25519 and 448");const s=i?a.div(u+r,u-r):a.div(r-u,r+u);return a.toBytes(s)},toMontgomerySecret(t){const r=B.secretKey;(0,n.eV)(t,r);const i=e(t.subarray(0,r));return h(i).subarray(0,r)},randomPrivateKey:x,precompute:(e=8,r=t.BASE)=>r.precompute(e,!1)};return Object.freeze({keygen:function(t){const e=E.randomSecretKey(t);return{secretKey:e,publicKey:y(e)}},getPublicKey:y,sign:function(t,e,r={}){t=(0,n.qj)("message",t),s&&(t=s(t));const{prefix:a,scalar:u,pointBytes:d}=p(e),h=m(r.context,a,t),l=o.multiply(h).toBytes(),f=m(r.context,l,d,t),y=c.create(h+f*u);if(!c.isValid(y))throw new Error("sign failed: invalid s");const g=(0,i.Id)(l,c.toBytes(y));return(0,n.eV)(g,B.signature,"result")},verify:function(e,r,i,a=g){const{context:u,zip215:c}=a,d=B.signature;e=(0,n.qj)("signature",e,d),r=(0,n.qj)("message",r),i=(0,n.qj)("publicKey",i,B.publicKey),void 0!==c&&(0,n.d6)(c,"zip215"),s&&(r=s(r));const h=d/2,l=e.subarray(0,h),f=(0,n.lX)(e.subarray(h,d));let p,y,w;try{p=t.fromBytes(i,c),y=t.fromBytes(l,c),w=o.multiplyUnsafe(f)}catch(t){return!1}if(!c&&p.isSmallOrder())return!1;const x=m(u,y.toBytes(),p.toBytes(),r);return y.add(p.multiplyUnsafe(x)).subtract(w).clearCofactor().is0()},utils:E,Point:t,lengths:B})}(h(e,r),s,a))}}};
|
|
2
|
+
export const __webpack_esm_id__=195;export const __webpack_esm_ids__=[195];export const __webpack_esm_modules__={5385:(t,e,r)=>{r.d(e,{Tq:()=>f,qX:()=>p,qj:()=>y,zc:()=>d});var n=r(8906),i=r(2531),s=r(5916);const o=n.Ph;function a(t,e){if(c(t),c(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=255&t,t>>>=8;return new Uint8Array(r)}function u(t,e){const r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function c(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function h(t){if(!(0,i.aY)(t)&&"string"!=typeof t)throw new Error("DST must be Uint8Array or string");return"string"==typeof t?(0,i.AI)(t):t}function f(t,e,r,n){(0,i.DO)(t),c(r),(e=h(e)).length>255&&(e=n((0,i.Id)((0,i.AI)("H2C-OVERSIZE-DST-"),e)));const{outputLen:s,blockLen:o}=n,f=Math.ceil(r/s);if(r>65535||f>255)throw new Error("expand_message_xmd: invalid lenInBytes");const d=(0,i.Id)(e,a(e.length,1)),l=a(0,o),p=a(r,2),y=new Array(f),m=n((0,i.Id)(l,t,p,a(0,1),d));y[0]=n((0,i.Id)(m,a(1,1),d));for(let t=1;t<=f;t++){const e=[u(m,y[t-1]),a(t+1,1),d];y[t]=n((0,i.Id)(...e))}return(0,i.Id)(...y).slice(0,r)}function d(t,e,r,n,s){if((0,i.DO)(t),c(r),(e=h(e)).length>255){const t=Math.ceil(2*n/8);e=s.create({dkLen:t}).update((0,i.AI)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:r}).update(t).update(a(r,2)).update(e).update(a(e.length,1)).digest()}function l(t,e,r){(0,n.DS)(r,{p:"bigint",m:"number",k:"number",hash:"function"});const{p:a,k:u,m:h,hash:l,expand:p,DST:y}=r;if(!(0,n.jN)(r.hash))throw new Error("expected valid hash");(0,i.DO)(t),c(e);const m=a.toString(2).length,w=Math.ceil((m+u)/8),g=e*h*w;let x;if("xmd"===p)x=f(t,y,g,l);else if("xof"===p)x=d(t,y,g,u,l);else{if("_internal_pass"!==p)throw new Error('expand must be "xmd" or "xof"');x=t}const E=new Array(e);for(let t=0;t<e;t++){const e=new Array(h);for(let r=0;r<h;r++){const n=w*(r+t*h),i=x.subarray(n,n+w);e[r]=(0,s.zi)(o(i),a)}E[t]=e}return E}const p=(0,i.AI)("HashToScalar-");function y(t,e,r){if("function"!=typeof e)throw new Error("mapToCurve() must be defined");function n(r){return t.fromAffine(e(r))}function i(e){const r=e.clearCofactor();return r.equals(t.ZERO)?t.ZERO:(r.assertValidity(),r)}return{defaults:r,hashToCurve(t,e){const s=l(t,2,Object.assign({},r,e)),o=n(s[0]),a=n(s[1]);return i(o.add(a))},encodeToCurve(t,e){const s=r.encodeDST?{DST:r.encodeDST}:{};return i(n(l(t,1,Object.assign({},r,s,e))[0]))},mapToCurve(t){if(!Array.isArray(t))throw new Error("expected array of bigints");for(const e of t)if("bigint"!=typeof e)throw new Error("expected array of bigints");return i(n(t))},hashToScalar(e,n){const i=t.Fn.ORDER;return l(e,1,Object.assign({},r,{p:i,m:1,DST:p},n))[0][0]}}}},6618:(t,e,r)=>{r.d(e,{TO:()=>f,i5:()=>d,n6:()=>l});var n=r(8906),i=r(2531),s=r(649),o=r(5916);const a=BigInt(0),u=BigInt(1),c=BigInt(2),h=BigInt(8);function f(t,e={}){const r=(0,s.UT)("edwards",t,e,e.FpFnLE),{Fp:o,Fn:f}=r;let d=r.CURVE;const{h:l}=d;(0,n.DS)(e,{},{uvRatio:"function"});const p=c<<BigInt(8*f.BYTES)-u,y=t=>o.create(t),m=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:o.sqrt(o.div(t,e))}}catch(t){return{isValid:!1,value:a}}});if(!function(t,e,r,n){const i=t.sqr(r),s=t.sqr(n),o=t.add(t.mul(e.a,i),s),a=t.add(t.ONE,t.mul(e.d,t.mul(i,s)));return t.eql(o,a)}(o,d,d.Gx,d.Gy))throw new Error("bad curve params: generator point");function w(t,e,r=!1){const i=r?u:a;return(0,n.aK)("coordinate "+t,e,i,p),e}function g(t){if(!(t instanceof B))throw new Error("ExtendedPoint expected")}const x=(0,n.x)((t,e)=>{const{X:r,Y:n,Z:i}=t,s=t.is0();null==e&&(e=s?h:o.inv(i));const c=y(r*e),f=y(n*e),d=o.mul(i,e);if(s)return{x:a,y:u};if(d!==u)throw new Error("invZ was invalid");return{x:c,y:f}}),E=(0,n.x)(t=>{const{a:e,d:r}=d;if(t.is0())throw new Error("bad point: ZERO");const{X:n,Y:i,Z:s,T:o}=t,a=y(n*n),u=y(i*i),c=y(s*s),h=y(c*c),f=y(a*e);if(y(c*y(f+u))!==y(h+y(r*y(a*u))))throw new Error("bad point: equation left != right (1)");if(y(n*i)!==y(s*o))throw new Error("bad point: equation left != right (2)");return!0});class B{constructor(t,e,r,n){this.X=w("x",t),this.Y=w("y",e),this.Z=w("z",r,!0),this.T=w("t",n),Object.freeze(this)}static CURVE(){return d}static fromAffine(t){if(t instanceof B)throw new Error("extended point not allowed");const{x:e,y:r}=t||{};return w("x",e),w("y",r),new B(e,r,u,y(e*r))}static fromBytes(t,e=!1){const r=o.BYTES,{a:i,d:s}=d;t=(0,n.nC)((0,n.eV)(t,r,"point")),(0,n.d6)(e,"zip215");const c=(0,n.nC)(t),h=t[r-1];c[r-1]=-129&h;const f=(0,n.lX)(c),l=e?p:o.ORDER;(0,n.aK)("point.y",f,a,l);const w=y(f*f),g=y(w-u),x=y(s*w-i);let{isValid:E,value:b}=m(g,x);if(!E)throw new Error("bad point: invalid y coordinate");const S=(b&u)===u,v=!!(128&h);if(!e&&b===a&&v)throw new Error("bad point: x=0 and x_0=1");return v!==S&&(b=y(-b)),B.fromAffine({x:b,y:f})}static fromHex(t,e=!1){return B.fromBytes((0,n.qj)("point",t),e)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return b.createCache(this,t),e||this.multiply(c),this}assertValidity(){E(this)}equals(t){g(t);const{X:e,Y:r,Z:n}=this,{X:i,Y:s,Z:o}=t,a=y(e*o),u=y(i*n),c=y(r*o),h=y(s*n);return a===u&&c===h}is0(){return this.equals(B.ZERO)}negate(){return new B(y(-this.X),this.Y,this.Z,y(-this.T))}double(){const{a:t}=d,{X:e,Y:r,Z:n}=this,i=y(e*e),s=y(r*r),o=y(c*y(n*n)),a=y(t*i),u=e+r,h=y(y(u*u)-i-s),f=a+s,l=f-o,p=a-s,m=y(h*l),w=y(f*p),g=y(h*p),x=y(l*f);return new B(m,w,x,g)}add(t){g(t);const{a:e,d:r}=d,{X:n,Y:i,Z:s,T:o}=this,{X:a,Y:u,Z:c,T:h}=t,f=y(n*a),l=y(i*u),p=y(o*r*h),m=y(s*c),w=y((n+i)*(a+u)-f-l),x=m-p,E=m+p,b=y(l-e*f),S=y(w*x),v=y(E*b),T=y(w*b),A=y(x*E);return new B(S,v,A,T)}subtract(t){return this.add(t.negate())}multiply(t){if(!f.isValidNot0(t))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:e,f:r}=b.cached(this,t,t=>(0,s.Ak)(B,t));return(0,s.Ak)(B,[e,r])[0]}multiplyUnsafe(t,e=B.ZERO){if(!f.isValid(t))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return t===a?B.ZERO:this.is0()||t===u?this:b.unsafe(this,t,t=>(0,s.Ak)(B,t),e)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return b.unsafe(this,d.n).is0()}toAffine(t){return x(this,t)}clearCofactor(){return l===u?this:this.multiplyUnsafe(l)}toBytes(){const{x:t,y:e}=this.toAffine(),r=o.toBytes(e);return r[r.length-1]|=t&u?128:0,r}toHex(){return(0,i.My)(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(t){return(0,s.Ak)(B,t)}static msm(t,e){return(0,s.Xf)(B,f,t,e)}_setWindowSize(t){this.precompute(t)}toRawBytes(){return this.toBytes()}}B.BASE=new B(d.Gx,d.Gy,u,y(d.Gx*d.Gy)),B.ZERO=new B(a,u,u,a),B.Fp=o,B.Fn=f;const b=new s.hT(B,f.BITS);return B.BASE.precompute(8),B}class d{constructor(t){this.ep=t}static fromBytes(t){(0,n.SJ)()}static fromHex(t){(0,n.SJ)()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return(0,i.My)(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,e){return this.init(this.ep.precompute(t,e))}toRawBytes(){return this.toBytes()}}function l(t){const{CURVE:e,curveOpts:r,hash:s,eddsaOpts:a}=function(t){const e={a:t.a,d:t.d,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r={Fp:t.Fp,Fn:(0,o.D0)(e.n,t.nBitLength,!0),uvRatio:t.uvRatio},n={randomBytes:t.randomBytes,adjustScalarBytes:t.adjustScalarBytes,domain:t.domain,prehash:t.prehash,mapToCurve:t.mapToCurve};return{CURVE:e,curveOpts:r,hash:t.hash,eddsaOpts:n}}(t);return function(t,e){const r=e.Point;return Object.assign({},e,{ExtendedPoint:r,CURVE:t,nBitLength:r.Fn.BITS,nByteLength:r.Fn.BYTES})}(t,function(t,e,r={}){if("function"!=typeof e)throw new Error('"hash" function param is required');(0,n.DS)(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:s}=r,{BASE:o,Fp:a,Fn:c}=t,h=r.randomBytes||i.po,f=r.adjustScalarBytes||(t=>t),d=r.domain||((t,e,r)=>{if((0,n.d6)(r,"phflag"),e.length||r)throw new Error("Contexts/pre-hash are not supported");return t});function l(t){return c.create((0,n.lX)(t))}function p(t){const{head:r,prefix:i,scalar:s}=function(t){const r=x.secretKey;t=(0,n.qj)("private key",t,r);const i=(0,n.qj)("hashed private key",e(t),2*r),s=f(i.slice(0,r));return{head:s,prefix:i.slice(r,2*r),scalar:l(s)}}(t),a=o.multiply(s),u=a.toBytes();return{head:r,prefix:i,scalar:s,point:a,pointBytes:u}}function y(t){return p(t).pointBytes}function m(t=Uint8Array.of(),...r){const o=(0,i.Id)(...r);return l(e(d(o,(0,n.qj)("context",t),!!s)))}const w={zip215:!0},g=a.BYTES,x={secretKey:g,publicKey:g,signature:2*g,seed:g};function E(t=h(x.seed)){return(0,n.eV)(t,x.seed,"seed")}const B={getExtendedPublicKey:p,randomSecretKey:E,isValidSecretKey:function(t){return(0,i.aY)(t)&&t.length===c.BYTES},isValidPublicKey:function(e,r){try{return!!t.fromBytes(e,r)}catch(t){return!1}},toMontgomery(e){const{y:r}=t.fromBytes(e),n=x.publicKey,i=32===n;if(!i&&57!==n)throw new Error("only defined for 25519 and 448");const s=i?a.div(u+r,u-r):a.div(r-u,r+u);return a.toBytes(s)},toMontgomerySecret(t){const r=x.secretKey;(0,n.eV)(t,r);const i=e(t.subarray(0,r));return f(i).subarray(0,r)},randomPrivateKey:E,precompute:(e=8,r=t.BASE)=>r.precompute(e,!1)};return Object.freeze({keygen:function(t){const e=B.randomSecretKey(t);return{secretKey:e,publicKey:y(e)}},getPublicKey:y,sign:function(t,e,r={}){t=(0,n.qj)("message",t),s&&(t=s(t));const{prefix:a,scalar:u,pointBytes:h}=p(e),f=m(r.context,a,t),d=o.multiply(f).toBytes(),l=m(r.context,d,h,t),y=c.create(f+l*u);if(!c.isValid(y))throw new Error("sign failed: invalid s");const w=(0,i.Id)(d,c.toBytes(y));return(0,n.eV)(w,x.signature,"result")},verify:function(e,r,i,a=w){const{context:u,zip215:c}=a,h=x.signature;e=(0,n.qj)("signature",e,h),r=(0,n.qj)("message",r),i=(0,n.qj)("publicKey",i,x.publicKey),void 0!==c&&(0,n.d6)(c,"zip215"),s&&(r=s(r));const f=h/2,d=e.subarray(0,f),l=(0,n.lX)(e.subarray(f,h));let p,y,g;try{p=t.fromBytes(i,c),y=t.fromBytes(d,c),g=o.multiplyUnsafe(l)}catch(t){return!1}if(!c&&p.isSmallOrder())return!1;const E=m(u,y.toBytes(),p.toBytes(),r);return y.add(p.multiplyUnsafe(E)).subtract(g).clearCofactor().is0()},utils:B,Point:t,lengths:x})}(f(e,r),s,a))}}};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 452.index.js.LICENSE.txt */
|
|
2
|
+
export const __webpack_esm_id__=452;export const __webpack_esm_ids__=[452];export const __webpack_esm_modules__={3452:(f,e,t)=>{t.d(e,{ed448:()=>O});var n=t(7238),c=t(2531),a=t(649),i=t(6618),r=(t(5385),t(5916)),s=t(8906);const o={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3"),h:BigInt(4),a:BigInt(1),d:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffff6756"),Gx:BigInt("0x4f1970c66bed0ded221d15a622bf36da9e146570470f1767ea6de324a3d3a46412ae1af72ab66511433b80e18b00938e2626a82bc70cc05e"),Gy:BigInt("0x693f46716eb6bc248876203756c9c7624bea73736ca3984087789c1e05a0c2d73ad3ff1ce67c39c4fdbd132c4ed7c8ad9808795bf230fa14")},d=Object.assign({},o,{d:BigInt("0xd78b4bdc7f0daf19f24f38c29373a2ccad46157242a50f37809b1da3412a12e79ccc9c81264cfe9ad080997058fb61c4243cc32dbaa156b9"),Gx:BigInt("0x79a70b2b70400553ae7c9df416c792c61128751ac92969240c25a07d728bdc93e21f7787ed6972249de732f38496cd11698713093e9c04fc"),Gy:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000000000000000000000000000000000000000000001")}),B=(0,c.qj)(()=>n.mh.create({dkLen:114})),u=BigInt(1),g=BigInt(2),b=BigInt(3),I=BigInt(4),l=BigInt(11),h=BigInt(22),m=BigInt(44),w=BigInt(88),p=BigInt(223);function x(f){return f[0]&=252,f[55]|=128,f[56]=0,f}function _(f,e){const t=o.p,n=(0,r.zi)(f*f*e,t),c=(0,r.zi)(n*f,t),a=function(f){const e=o.p,t=f*f*f%e,n=t*t*f%e,c=(0,r.zH)(n,b,e)*n%e,a=(0,r.zH)(c,b,e)*n%e,i=(0,r.zH)(a,g,e)*t%e,s=(0,r.zH)(i,l,e)*i%e,d=(0,r.zH)(s,h,e)*s%e,B=(0,r.zH)(d,m,e)*d%e,I=(0,r.zH)(B,w,e)*B%e,x=(0,r.zH)(I,m,e)*d%e,_=(0,r.zH)(x,g,e)*t%e,z=(0,r.zH)(_,u,e)*f%e;return(0,r.zH)(z,p,e)*_%e}((0,r.zi)(c*n*e,t)),i=(0,r.zi)(c*a,t),s=(0,r.zi)(i*i,t);return{isValid:(0,r.zi)(s*e,t)===f,value:i}}const z=(()=>(0,r.D0)(o.p,{BITS:456,isLE:!0}))(),E=(()=>(0,r.D0)(o.n,{BITS:456,isLE:!0}))(),y=(()=>(0,r.D0)(o.p,{BITS:448,isLE:!0}))(),H=(()=>(0,r.D0)(o.n,{BITS:448,isLE:!0}))();function S(f,e,t){if(e.length>255)throw new Error("context must be smaller than 255, got: "+e.length);return(0,c.Id)((0,s.Mh)("SigEd448"),new Uint8Array([t?1:0,e.length]),e,f)}const D=(()=>({...o,Fp:z,Fn:E,nBitLength:E.BITS,hash:B,adjustScalarBytes:x,domain:S,uvRatio:_}))(),O=(0,i.n6)(D);(0,i.TO)(d);const R=BigInt("39082"),v=BigInt("78163"),T=BigInt("98944233647732219769177004876929019128417576295529901074099889598043702116001257856802131563896515373927712232092845883226922417596214"),L=BigInt("315019913931389607337177038330951043522456072897266928557328499619017160722351061360252776265186336876723201881398623946864393857820716"),P=f=>_(u,f);function j(f){const{d:e}=o,t=z.ORDER,n=f=>z.create(f),c=n(-f*f),a=n(e*(c-u)),i=n((a+u)*(a-c)),{isValid:s,value:d}=_(v,n((c+u)*i));let B=d;s||(B=n(f*d));let b=u;s||(b=n(-u));const I=n(B*(c+u));let l=I;(0,r.dQ)(I,t)&&(l=n(-I));const h=I*I,m=n(l*g),w=n(h+u),p=n(h-u),x=n(B*I*(c-u)*v+b);return new O.Point(n(m*x),n(p*w),n(w*x),n(m*p))}class q extends i.i5{constructor(f){super(f)}static fromAffine(f){return new q(O.Point.fromAffine(f))}assertSame(f){if(!(f instanceof q))throw new Error("DecafPoint expected")}init(f){return new q(f)}static hashToCurve(f){return function(f){(0,c.DO)(f,112);const e=!0,t=j(y.create(y.fromBytes(f.subarray(0,56),e))),n=j(y.create(y.fromBytes(f.subarray(56,112),e)));return new q(t.add(n))}((0,s.qj)("decafHash",f,112))}static fromBytes(f){(0,c.DO)(f,56);const{d:e}=o,t=z.ORDER,n=f=>y.create(f),a=y.fromBytes(f);if(!(0,s.ex)(H.toBytes(a),f)||(0,r.dQ)(a,t))throw new Error("invalid decaf448 encoding 1");const i=n(a*a),d=n(u+i),B=n(d*d),g=n(B-I*e*i),{isValid:b,value:l}=P(n(g*B));let h=n((a+a)*l*d*T);(0,r.dQ)(h,t)&&(h=n(-h));const m=n(h*l*g*L),w=n((u-i)*l*d),p=n(m*w);if(!b)throw new Error("invalid decaf448 encoding 2");return new q(new O.Point(m,w,u,p))}static fromHex(f){return q.fromBytes((0,s.qj)("decafHex",f,56))}static msm(f,e){return(0,a.Xf)(q,E,f,e)}toBytes(){const{X:f,Z:e,T:t}=this.ep,n=z.ORDER,c=f=>z.create(f),a=c(c(f+t)*c(f-t)),i=c(f*f),{value:s}=P(c(a*R*i));let o=c(s*a*T);(0,r.dQ)(o,n)&&(o=c(-o));const d=c(L*o*e-t);let B=c(R*s*f*d);return(0,r.dQ)(B,n)&&(B=c(-B)),H.toBytes(B)}equals(f){this.assertSame(f);const{X:e,Y:t}=this.ep,{X:n,Y:c}=f.ep;return z.create(e*c)===z.create(t*n)}is0(){return this.equals(q.ZERO)}}q.BASE=(()=>new q(O.Point.BASE).multiplyUnsafe(g))(),q.ZERO=(()=>new q(O.Point.ZERO))(),q.Fp=(()=>y)(),q.Fn=(()=>H)()}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
package/dist/47.index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! For license information please see 47.index.js.LICENSE.txt */
|
|
1
|
+
/*! For license information please see 47.index.js.LICENSE.txt */
|
|
2
2
|
export const __webpack_esm_id__=47;export const __webpack_esm_ids__=[47];export const __webpack_esm_modules__={91047:(e,t,f)=>{f.d(t,{p256:()=>P,p384:()=>k,p521:()=>q});var r=f(8442),n=f(21454),o=f(32531),i=f(78906),s=f(50649),a=f(15916);const c=(e,t)=>(e+(e>=0?t:-t)/m)/t;function d(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function u(e,t){const f={};for(let r of Object.keys(t))f[r]=void 0===e[r]?t[r]:e[r];return(0,i.d6)(f.lowS,"lowS"),(0,i.d6)(f.prehash,"prehash"),void 0!==f.format&&d(f.format),f}class l extends Error{constructor(e=""){super(e)}}const h={Err:l,_tlv:{encode:(e,t)=>{const{Err:f}=h;if(e<0||e>256)throw new f("tlv.encode: wrong tag");if(1&t.length)throw new f("tlv.encode: unpadded data");const r=t.length/2,n=(0,i.zW)(r);if(n.length/2&128)throw new f("tlv.encode: long form length too big");const o=r>127?(0,i.zW)(n.length/2|128):"";return(0,i.zW)(e)+o+n+t},decode(e,t){const{Err:f}=h;let r=0;if(e<0||e>256)throw new f("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new f("tlv.decode: wrong tlv");const n=t[r++];let o=0;if(128&n){const e=127&n;if(!e)throw new f("tlv.decode(long): indefinite length not supported");if(e>4)throw new f("tlv.decode(long): byte length is too big");const i=t.subarray(r,r+e);if(i.length!==e)throw new f("tlv.decode: length bytes not complete");if(0===i[0])throw new f("tlv.decode(long): zero leftmost byte");for(const e of i)o=o<<8|e;if(r+=e,o<128)throw new f("tlv.decode(long): not minimal encoding")}else o=n;const i=t.subarray(r,r+o);if(i.length!==o)throw new f("tlv.decode: wrong value length");return{v:i,l:t.subarray(r+o)}}},_int:{encode(e){const{Err:t}=h;if(e<y)throw new t("integer: negative integers are not allowed");let f=(0,i.zW)(e);if(8&Number.parseInt(f[0],16)&&(f="00"+f),1&f.length)throw new t("unexpected DER parsing assertion: unpadded hex");return f},decode(e){const{Err:t}=h;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return(0,i.Ph)(e)}},toSig(e){const{Err:t,_int:f,_tlv:r}=h,n=(0,i.qj)("signature",e),{v:o,l:s}=r.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,o),{v:d,l:u}=r.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:f.decode(a),s:f.decode(d)}},hexFromSig(e){const{_tlv:t,_int:f}=h,r=t.encode(2,f.encode(e.r))+t.encode(2,f.encode(e.s));return t.encode(48,r)}},y=BigInt(0),b=BigInt(1),m=BigInt(2),p=BigInt(3),g=BigInt(4);function w(e,t){const{BYTES:f}=e;let r;if("bigint"==typeof t)r=t;else{let n=(0,i.qj)("private key",t);try{r=e.fromBytes(n)}catch(e){throw new Error(`invalid private key: expected ui8a of size ${f}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function E(e){return Uint8Array.of(e?2:3)}function B(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function v(e){const{CURVE:t,curveOpts:f,hash:r,ecdsaOpts:l}=function(e){const{CURVE:t,curveOpts:f}=function(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},f=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:f,Fn:(0,a.D0)(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:f,hash:e.hash,ecdsaOpts:r}}(e);return function(e,t){const f=t.Point;return Object.assign({},t,{ProjectivePoint:f,CURVE:Object.assign({},e,(0,a.LH)(f.Fn.ORDER,f.Fn.BITS))})}(e,function(e,t,f={}){(0,o.sd)(t),(0,i.DS)(f,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=f.randomBytes||o.po,s=f.hmac||((e,...f)=>(0,n.w)(t,e,(0,o.Id)(...f))),{Fp:c,Fn:l}=e,{ORDER:p,BITS:g}=l,{keygen:v,getPublicKey:x,getSharedSecret:S,utils:O,lengths:R}=function(e,t={}){const{Fn:f}=e,r=t.randomBytes||o.po,n=Object.assign(B(e.Fp,f),{seed:(0,a.Tp)(f.ORDER)});function s(e){try{return!!w(f,e)}catch(e){return!1}}function c(e=r(n.seed)){return(0,a.qy)((0,i.eV)(e,n.seed,"seed"),f.ORDER)}function d(t,r=!0){return e.BASE.multiply(w(f,t)).toBytes(r)}function u(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:o,publicKeyUncompressed:s}=n;if(f.allowedLengths||r===o)return;const a=(0,i.qj)("key",t).length;return a===o||a===s}const l={isValidSecretKey:s,isValidPublicKey:function(t,f){const{publicKey:r,publicKeyUncompressed:o}=n;try{const n=t.length;return!(!0===f&&n!==r||!1===f&&n!==o||!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:c,isValidPrivateKey:s,randomPrivateKey:c,normPrivateKeyToScalar:e=>w(f,e),precompute:(t=8,f=e.BASE)=>f.precompute(t,!1)};return Object.freeze({getPublicKey:d,getSharedSecret:function(t,r,n=!0){if(!0===u(t))throw new Error("first arg must be private key");if(!1===u(r))throw new Error("second arg must be public key");const o=w(f,t);return e.fromHex(r).multiply(o).toBytes(n)},keygen:function(e){const t=c(e);return{secretKey:t,publicKey:d(t)}},Point:e,utils:l,lengths:n})}(e,f),I={prehash:!1,lowS:"boolean"==typeof f.lowS&&f.lowS,format:void 0,extraEntropy:!1},K="compact";function V(e){return e>p>>b}function P(e,t){if(!l.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class k{constructor(e,t,f){this.r=P("r",e),this.s=P("s",t),null!=f&&(this.recovery=f),Object.freeze(this)}static fromBytes(e,t=K){let f;if(function(e,t){d(t);const f=R.signature,r="compact"===t?f:"recovered"===t?f+1:void 0;(0,i.eV)(e,r,`${t} signature`)}(e,t),"der"===t){const{r:t,s:f}=h.toSig((0,i.eV)(e));return new k(t,f)}"recovered"===t&&(f=e[0],t="compact",e=e.subarray(1));const r=l.BYTES,n=e.subarray(0,r),o=e.subarray(r,2*r);return new k(l.fromBytes(n),l.fromBytes(o),f)}static fromHex(e,t){return this.fromBytes((0,o.aT)(e),t)}addRecoveryBit(e){return new k(this.r,this.s,e)}recoverPublicKey(t){const f=c.ORDER,{r,s:n,recovery:s}=this;if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");if(p*m<f&&s>1)throw new Error("recovery id is ambiguous for h>1 curve");const a=2===s||3===s?r+p:r;if(!c.isValid(a))throw new Error("recovery id 2 or 3 invalid");const d=c.toBytes(a),u=e.fromBytes((0,o.Id)(E(!(1&s)),d)),h=l.inv(a),y=A((0,i.qj)("msgHash",t)),b=l.create(-y*h),g=l.create(n*h),w=e.BASE.multiplyUnsafe(b).add(u.multiplyUnsafe(g));if(w.is0())throw new Error("point at infinify");return w.assertValidity(),w}hasHighS(){return V(this.s)}toBytes(e=K){if(d(e),"der"===e)return(0,o.aT)(h.hexFromSig(this));const t=l.toBytes(this.r),f=l.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return(0,o.Id)(Uint8Array.of(this.recovery),t,f)}return(0,o.Id)(t,f)}toHex(e){return(0,o.My)(this.toBytes(e))}assertValidity(){}static fromCompact(e){return k.fromBytes((0,i.qj)("sig",e),"compact")}static fromDER(e){return k.fromBytes((0,i.qj)("sig",e),"der")}normalizeS(){return this.hasHighS()?new k(this.r,l.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return(0,o.My)(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return(0,o.My)(this.toBytes("compact"))}}const q=f.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=(0,i.Ph)(e),f=8*e.length-g;return f>0?t>>BigInt(f):t},A=f.bits2int_modN||function(e){return l.create(q(e))},F=(0,i.OG)(g);function Z(e){return(0,i.aK)("num < 2^"+g,e,y,F),l.toBytes(e)}function _(e,f){return(0,i.eV)(e,void 0,"message"),f?(0,i.eV)(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:v,getPublicKey:x,getSharedSecret:S,utils:O,lengths:R,Point:e,sign:function(f,n,a={}){f=(0,i.qj)("message",f);const{seed:c,k2sig:d}=function(t,f,n){if(["recovered","canonical"].some(e=>e in n))throw new Error("sign() legacy options not supported");const{lowS:s,prehash:a,extraEntropy:c}=u(n,I);t=_(t,a);const d=A(t),h=w(l,f),m=[Z(h),Z(d)];if(null!=c&&!1!==c){const e=!0===c?r(R.secretKey):c;m.push((0,i.qj)("extraEntropy",e))}const p=(0,o.Id)(...m),g=d;return{seed:p,k2sig:function(t){const f=q(t);if(!l.isValidNot0(f))return;const r=l.inv(f),n=e.BASE.multiply(f).toAffine(),o=l.create(n.x);if(o===y)return;const i=l.create(r*l.create(g+o*h));if(i===y)return;let a=(n.x===o?0:2)|Number(n.y&b),c=i;return s&&V(i)&&(c=l.neg(i),a^=1),new k(o,c,a)}}}(f,n,a);return(0,i.fg)(t.outputLen,l.BYTES,s)(c,d)},verify:function(t,f,r,n={}){const{lowS:s,prehash:a,format:c}=u(n,I);if(r=(0,i.qj)("publicKey",r),f=_((0,i.qj)("message",f),a),"strict"in n)throw new Error("options.strict was renamed to lowS");const d=void 0===c?function(e){let t;const f="string"==typeof e||(0,o.aY)(e),r=!f&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!f&&!r)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(r)t=new k(e.r,e.s);else if(f){try{t=k.fromBytes((0,i.qj)("sig",e),"der")}catch(e){if(!(e instanceof h.Err))throw e}if(!t)try{t=k.fromBytes((0,i.qj)("sig",e),"compact")}catch(e){return!1}}return t||!1}(t):k.fromBytes((0,i.qj)("sig",t),c);if(!1===d)return!1;try{const t=e.fromBytes(r);if(s&&d.hasHighS())return!1;const{r:n,s:o}=d,i=A(f),a=l.inv(o),c=l.create(i*a),u=l.create(n*a),h=e.BASE.multiplyUnsafe(c).add(t.multiplyUnsafe(u));return!h.is0()&&l.create(h.x)===n}catch(e){return!1}},recoverPublicKey:function(e,t,f={}){const{prehash:r}=u(f,I);return t=_(t,r),k.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:k,hash:t})}(function(e,t={}){const f=(0,s.UT)("weierstrass",e,t),{Fp:r,Fn:n}=f;let a=f.CURVE;const{h:d,n:u}=a;(0,i.DS)(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:l}=t;if(l&&(!r.is0(a.a)||"bigint"!=typeof l.beta||!Array.isArray(l.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const h=B(r,n);function m(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const v=t.toBytes||function(e,t,f){const{x:n,y:s}=t.toAffine(),a=r.toBytes(n);if((0,i.d6)(f,"isCompressed"),f){m();const e=!r.isOdd(s);return(0,o.Id)(E(e),a)}return(0,o.Id)(Uint8Array.of(4),a,r.toBytes(s))},x=t.fromBytes||function(e){(0,i.eV)(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:f}=h,n=e.length,o=e[0],s=e.subarray(1);if(n!==t||2!==o&&3!==o){if(n===f&&4===o){const e=r.BYTES,t=r.fromBytes(s.subarray(0,e)),f=r.fromBytes(s.subarray(e,2*e));if(!O(t,f))throw new Error("bad point: is not on curve");return{x:t,y:f}}throw new Error(`bad point: got length ${n}, expected compressed=${t} or uncompressed=${f}`)}{const e=r.fromBytes(s);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=S(e);let f;try{f=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}return m(),!(1&~o)!==r.isOdd(f)&&(f=r.neg(f)),{x:e,y:f}}};function S(e){const t=r.sqr(e),f=r.mul(t,e);return r.add(r.add(f,r.mul(e,a.a)),a.b)}function O(e,t){const f=r.sqr(t),n=S(e);return r.eql(f,n)}if(!O(a.Gx,a.Gy))throw new Error("bad curve params: generator point");const R=r.mul(r.pow(a.a,p),g),I=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(R,I)))throw new Error("bad curve params: a or b");function K(e,t,f=!1){if(!r.isValid(t)||f&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function V(e){if(!(e instanceof F))throw new Error("ProjectivePoint expected")}function P(e){if(!l||!l.basises)throw new Error("no endo");return function(e,t,f){const[[r,n],[o,s]]=t,a=c(s*e,f),d=c(-n*e,f);let u=e-a*r-d*o,l=-a*n-d*s;const h=u<y,m=l<y;h&&(u=-u),m&&(l=-l);const p=(0,i.OG)(Math.ceil((0,i.dJ)(f)/2))+b;if(u<y||u>=p||l<y||l>=p)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:u,k2neg:m,k2:l}}(e,l.basises,n.ORDER)}const k=(0,i.x)((e,t)=>{const{X:f,Y:n,Z:o}=e;if(r.eql(o,r.ONE))return{x:f,y:n};const i=e.is0();null==t&&(t=i?r.ONE:r.inv(o));const s=r.mul(f,t),a=r.mul(n,t),c=r.mul(o,t);if(i)return{x:r.ZERO,y:r.ZERO};if(!r.eql(c,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}),q=(0,i.x)(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:f,y:n}=e.toAffine();if(!r.isValid(f)||!r.isValid(n))throw new Error("bad point: x or y not field elements");if(!O(f,n))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function A(e,t,f,n,o){return f=new F(r.mul(f.X,e),f.Y,f.Z),t=(0,s.u0)(n,t),f=(0,s.u0)(o,f),t.add(f)}class F{constructor(e,t,f){this.X=K("x",e),this.Y=K("y",t,!0),this.Z=K("z",f),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){const{x:t,y:f}=e||{};if(!e||!r.isValid(t)||!r.isValid(f))throw new Error("invalid affine point");if(e instanceof F)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(f)?F.ZERO:new F(t,f,r.ONE)}static fromBytes(e){const t=F.fromAffine(x((0,i.eV)(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return F.fromBytes((0,i.qj)("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return _.createCache(this,e),t||this.multiply(p),this}assertValidity(){q(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){V(e);const{X:t,Y:f,Z:n}=this,{X:o,Y:i,Z:s}=e,a=r.eql(r.mul(t,s),r.mul(o,n)),c=r.eql(r.mul(f,s),r.mul(i,n));return a&&c}negate(){return new F(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=a,f=r.mul(t,p),{X:n,Y:o,Z:i}=this;let s=r.ZERO,c=r.ZERO,d=r.ZERO,u=r.mul(n,n),l=r.mul(o,o),h=r.mul(i,i),y=r.mul(n,o);return y=r.add(y,y),d=r.mul(n,i),d=r.add(d,d),s=r.mul(e,d),c=r.mul(f,h),c=r.add(s,c),s=r.sub(l,c),c=r.add(l,c),c=r.mul(s,c),s=r.mul(y,s),d=r.mul(f,d),h=r.mul(e,h),y=r.sub(u,h),y=r.mul(e,y),y=r.add(y,d),d=r.add(u,u),u=r.add(d,u),u=r.add(u,h),u=r.mul(u,y),c=r.add(c,u),h=r.mul(o,i),h=r.add(h,h),u=r.mul(h,y),s=r.sub(s,u),d=r.mul(h,l),d=r.add(d,d),d=r.add(d,d),new F(s,c,d)}add(e){V(e);const{X:t,Y:f,Z:n}=this,{X:o,Y:i,Z:s}=e;let c=r.ZERO,d=r.ZERO,u=r.ZERO;const l=a.a,h=r.mul(a.b,p);let y=r.mul(t,o),b=r.mul(f,i),m=r.mul(n,s),g=r.add(t,f),w=r.add(o,i);g=r.mul(g,w),w=r.add(y,b),g=r.sub(g,w),w=r.add(t,n);let E=r.add(o,s);return w=r.mul(w,E),E=r.add(y,m),w=r.sub(w,E),E=r.add(f,n),c=r.add(i,s),E=r.mul(E,c),c=r.add(b,m),E=r.sub(E,c),u=r.mul(l,w),c=r.mul(h,m),u=r.add(c,u),c=r.sub(b,u),u=r.add(b,u),d=r.mul(c,u),b=r.add(y,y),b=r.add(b,y),m=r.mul(l,m),w=r.mul(h,w),b=r.add(b,m),m=r.sub(y,m),m=r.mul(l,m),w=r.add(w,m),y=r.mul(b,w),d=r.add(d,y),y=r.mul(E,w),c=r.mul(g,c),c=r.sub(c,y),y=r.mul(g,b),u=r.mul(E,u),u=r.add(u,y),new F(c,d,u)}subtract(e){return this.add(e.negate())}is0(){return this.equals(F.ZERO)}multiply(e){const{endo:f}=t;if(!n.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,o;const i=e=>_.cached(this,e,e=>(0,s.Ak)(F,e));if(f){const{k1neg:t,k1:n,k2neg:s,k2:a}=P(e),{p:c,f:d}=i(n),{p:u,f:l}=i(a);o=d.add(l),r=A(f.beta,c,u,t,s)}else{const{p:t,f}=i(e);r=t,o=f}return(0,s.Ak)(F,[r,o])[0]}multiplyUnsafe(e){const{endo:f}=t,r=this;if(!n.isValid(e))throw new Error("invalid scalar: out of range");if(e===y||r.is0())return F.ZERO;if(e===b)return r;if(_.hasCache(this))return this.multiply(e);if(f){const{k1neg:t,k1:n,k2neg:o,k2:i}=P(e),{p1:a,p2:c}=(0,s.fH)(F,r,n,i);return A(f.beta,a,c,t,o)}return _.unsafe(r,e)}multiplyAndAddUnsafe(e,t,f){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(f));return r.is0()?void 0:r}toAffine(e){return k(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return d===b||(e?e(F,this):_.unsafe(this,u).is0())}clearCofactor(){const{clearCofactor:e}=t;return d===b?this:e?e(F,this):this.multiplyUnsafe(d)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}toBytes(e=!0){return(0,i.d6)(e,"isCompressed"),this.assertValidity(),v(F,this,e)}toHex(e=!0){return(0,o.My)(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return(0,s.Ak)(F,e)}static msm(e,t){return(0,s.Xf)(F,n,e,t)}static fromPrivateKey(e){return F.BASE.multiply(w(n,e))}}F.BASE=new F(a.Gx,a.Gy,r.ONE),F.ZERO=new F(r.ZERO,r.ONE,r.ZERO),F.Fp=r,F.Fn=n;const Z=n.BITS,_=new s.hT(F,t.endo?Math.ceil(Z/2):Z);return F.BASE.precompute(8),F}(t,f),r,l))}function x(e,t){const f=t=>v({...e,hash:t});return{...f(t),create:f}}const S={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},O={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},R={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},I=(0,a.D0)(S.p),K=(0,a.D0)(O.p),V=(0,a.D0)(R.p),P=x({...S,Fp:I,lowS:!1},r.sc),k=x({...O,Fp:K,lowS:!1},r.qt),q=x({...R,Fp:V,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},r.Zf)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
package/dist/508.index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 508.index.js.LICENSE.txt */
|
|
2
|
-
export const __webpack_esm_id__=508;export const __webpack_esm_ids__=[508];export const __webpack_esm_modules__={93508:(e,t,r)=>{r.d(t,{XWing:()=>g});var i=r(38619),a=r(24220);const n=BigInt(1),s=BigInt(2),y=BigInt(3),h=BigInt(5),o=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function c(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const w=(()=>{const e=o;return(0,a.EC)({P:e,type:"x25519",powPminus2:t=>{const{pow_p_5_8:r,b2:i}=function(e){const t=BigInt(10),r=BigInt(20),i=BigInt(40),y=BigInt(80),c=o,w=e*e%c*e%c,l=(0,a.zH)(w,s,c)*w%c,u=(0,a.zH)(l,n,c)*e%c,f=(0,a.zH)(u,h,c)*u%c,b=(0,a.zH)(f,t,c)*f%c,d=(0,a.zH)(b,r,c)*b%c,p=(0,a.zH)(d,i,c)*d%c,v=(0,a.zH)(p,y,c)*p%c,g=(0,a.zH)(v,y,c)*p%c,_=(0,a.zH)(g,t,c)*f%c;return{pow_p_5_8:(0,a.zH)(_,s,c)*e%c,b2:w}}(t);return(0,a.zi)((0,a.zH)(r,y,e)*i,e)},adjustScalarBytes:c})})();class l extends a.o0{async extract(e,t){if(await this._setup(),0===e.byteLength&&(e=new ArrayBuffer(this.hashSize)),e.byteLength!==this.hashSize)return(0,a.w8)(a.sc,new Uint8Array(e),new Uint8Array(t)).buffer;const r=await this._api.importKey("raw",e,this.algHash,!1,["sign"]);return await this._api.sign("HMAC",r,t)}}const u="X25519";class f{constructor(e){Object.defineProperty(this,"_hkdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nPk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nSk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._hkdf=e,this._nPk=32,this._nSk=32}async serializePublicKey(e){try{return await this._serializePublicKey(e)}catch(e){throw new a.LV(e)}}async deserializePublicKey(e){try{return await this._importRawKey(e,!0)}catch(e){throw new a.Ug(e)}}async serializePrivateKey(e){try{return await this._serializePrivateKey(e)}catch(e){throw new a.LV(e)}}async deserializePrivateKey(e){try{return await this._importRawKey(e,!1)}catch(e){throw new a.Ug(e)}}async importKey(e,t,r){try{if("raw"===e)return await this._importRawKey(t,r);if(t instanceof ArrayBuffer)throw new Error("Invalid jwk key format");return await this._importJWK(t,r)}catch(e){throw new a.Ug(e)}}async generateKeyPair(){try{const e=await w.utils.randomSecretKey(),t=new a.Bk(u,e,"private",a.xE);return{publicKey:await this.derivePublicKey(t),privateKey:t}}catch(e){throw new a.EM(e)}}async deriveKeyPair(e){try{const t=await this._hkdf.labeledExtract(a.wg.buffer,a.CY,new Uint8Array(e)),r=await this._hkdf.labeledExpand(t,a.Hz,a.wg,this._nSk),i=new a.Bk(u,new Uint8Array(r),"private",a.xE);return{privateKey:i,publicKey:await this.derivePublicKey(i)}}catch(e){throw new a.$7(e)}}async derivePublicKey(e){try{return await this._derivePublicKey(e)}catch(e){throw new a.Ug(e)}}async dh(e,t){try{return await this._dh(e,t)}catch(e){throw new a.LV(e)}}async derive(e,t){try{return await this._derive(e,t)}catch(e){throw new a.LV(e)}}_serializePublicKey(e){return new Promise(t=>{t(e.key.buffer)})}_serializePrivateKey(e){return new Promise(t=>{t(e.key.buffer)})}_importRawKey(e,t){return new Promise((r,i)=>{t&&e.byteLength!==this._nPk&&i(new Error("Invalid length of the key")),t||e.byteLength===this._nSk||i(new Error("Invalid length of the key")),r(new a.Bk(u,new Uint8Array(e),t?"public":"private",t?[]:a.xE))})}_importJWK(e,t){return new Promise((r,i)=>{void 0!==e.kty&&"OKP"===e.kty||i(new Error(`Invalid kty: ${e.kty}`)),void 0!==e.crv&&"X25519"===e.crv||i(new Error(`Invalid crv: ${e.crv}`)),t?(void 0!==e.d&&i(new Error("Invalid key: `d` should not be set")),void 0===e.x&&i(new Error("Invalid key: `x` not found")),r(new a.Bk(u,(0,a.rf)(e.x),"public"))):("string"!=typeof e.d&&i(new Error("Invalid key: `d` not found")),r(new a.Bk(u,(0,a.rf)(e.d),"private",a.xE)))})}_derivePublicKey(e){return new Promise((t,r)=>{try{const r=w.getPublicKey(e.key);t(new a.Bk(u,r,"public"))}catch(e){r(e)}})}_dh(e,t){return new Promise((r,i)=>{try{r(w.getSharedSecret(e.key,t.key).buffer)}catch(e){i(e)}})}_derive(e,t){return new Promise((r,i)=>{try{r(w.getSharedSecret(e,t))}catch(e){i(e)}})}}a.gX;const b="X-Wing",d=new Uint8Array([9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),p=new Uint8Array([92,46,47,47,94,92]);function v(e,t,r,a){const n=new Uint8Array(e.length+t.length+r.length+a.length+p.length);return n.set(e,0),n.set(t,e.length),n.set(r,e.length+t.length),n.set(a,e.length+t.length+r.length),n.set(p,e.length+t.length+r.length+a.length),i.C2.create().update(n).digest()}class g{constructor(){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:a.h.XWing}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:b}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:1120}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:1216}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_m",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_x25519",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._m=new i.wo,this._x25519=new f(new l)}async serializePublicKey(e){await this._setup();try{return await this._serializePublicKey(e)}catch(e){throw new a.LV(e)}}async deserializePublicKey(e){await this._setup();try{return await this._deserializePublicKey(e)}catch(e){throw new a.Ug(e)}}async serializePrivateKey(e){await this._setup();try{return await this._serializePrivateKey(e)}catch(e){throw new a.LV(e)}}async deserializePrivateKey(e){await this._setup();try{return await this._deserializePrivateKey(e)}catch(e){throw new a.Ug(e)}}async generateKeyPair(){await this._setup();const e=new Uint8Array(32);try{this._api.getRandomValues(e)}catch(e){throw new a.EM(e)}try{const[t,r]=await this._generateKeyPairDerand(e);return{privateKey:await this.deserializePrivateKey(e.buffer),publicKey:await this.deserializePublicKey(r.buffer)}}catch(e){throw new a.$7(e)}}async generateKeyPairDerand(e){if(32!==e.byteLength)throw new a.NS("Invalid length of sk");try{const[t,r]=await this._generateKeyPairDerand(e);return{privateKey:await this.deserializePrivateKey(e.buffer),publicKey:await this.deserializePublicKey(r.buffer)}}catch(e){throw new a.$7(e)}}async deriveKeyPair(e){await this._setup();try{const t=i.mh.create({dkLen:32}).update(new Uint8Array(e)).digest(),[r,a]=await this._generateKeyPairDerand(t);return{privateKey:await this.deserializePrivateKey(t.buffer),publicKey:await this.deserializePublicKey(a.buffer)}}catch(e){throw new a.$7(e)}}async importKey(e,t,r=!0){await this._setup();try{let i;if("jwk"===e){if(t instanceof ArrayBuffer||t instanceof Uint8Array)throw new Error("Invalid jwk key format");i=await this._importJWK(t,r)}else if(t instanceof ArrayBuffer)i=new Uint8Array(t);else{if(!(t instanceof Uint8Array))throw new Error("Invalid key format");i=t}if(r&&i.byteLength!==this.publicKeySize)throw new Error("Invalid length of the key");if(!r&&i.byteLength!==this.privateKeySize)throw new Error("Invalid length of the key");return new a.Bk(b,i,r?"public":"private",r?[]:a.xE)}catch(e){throw new a.Ug(e)}}async encap(e){let t,r,i;if(void 0!==e.ekm&&!(0,a.Di)(e.ekm)){if(64!==e.ekm.byteLength)throw new a.NS("ekm must be 64 bytes in length");t=e.ekm}if(void 0!==t){const e=new Uint8Array(t);r=e.subarray(0,32),i=e.subarray(32,64)}else{i=new Uint8Array(32);try{this._api.getRandomValues(i)}catch(e){throw new a.EM(e)}}const n=new Uint8Array(await this.serializePublicKey(e.recipientPublicKey));if(1216!==n.byteLength)throw new a.NS("Invalid length of recipientPublicKey");await this._setup();try{const e=n.subarray(0,1184),t=n.subarray(1184,1216),s=await this._x25519.derive(i,d),y=await this._x25519.derive(i,t),[h,o]=await this._m.encap(e,r);return{sharedSecret:v(o,y,s,t).buffer,enc:(0,a.xW)(h,s).buffer}}catch(e){throw new a.Wg(e)}}async decap(e){const t=(0,a.Di)(e.recipientKey)?e.recipientKey.privateKey:e.recipientKey;if(1120!==e.enc.byteLength)throw new a.NS("Invalid length of enc");const r=new Uint8Array(await this.serializePrivateKey(t));if(32!==r.byteLength)throw new a.NS("Invalid length of recipientKey");await this._setup();try{const[t,i,a,n]=await this._expandDecapsulationKey(r),s=new Uint8Array(e.enc),y=s.subarray(0,1088),h=s.subarray(1088);return v(await this._m.decap(y,t),await this._x25519.derive(i,h),h,n).buffer}catch(e){throw new a.uu(e)}}async _setup(){void 0===this._api&&(this._api=await(0,a.QZ)())}async _generateKeyPairDerand(e){const[t,r,i,n]=await this._expandDecapsulationKey(e);return[e,(0,a.xW)(i,n)]}async _expandDecapsulationKey(e){const t=i.mh.create({dkLen:96}).update(e).digest(),[r,a]=await this._m.deriveKeyPair(t.subarray(0,64)),n=t.subarray(64,96);return[a,n,r,await this._x25519.derive(n,d)]}_serializePublicKey(e){return new Promise((t,r)=>{"public"!==e.type&&r(new Error("Not public key")),e.algorithm.name!==this.name&&r(new Error(`Invalid algorithm name: ${e.algorithm.name}`)),e.key.byteLength!==this.publicKeySize&&r(new Error(`Invalid key length: ${e.key.byteLength}`)),t(e.key.buffer)})}_deserializePublicKey(e){return new Promise((t,r)=>{e.byteLength!==this.publicKeySize&&r(new Error(`Invalid key length: ${e.byteLength}`)),t(new a.Bk(this.name,new Uint8Array(e),"public"))})}_serializePrivateKey(e){return new Promise((t,r)=>{"private"!==e.type&&r(new Error("Not private key")),e.algorithm.name!==this.name&&r(new Error(`Invalid algorithm name: ${e.algorithm.name}`)),e.key.byteLength!==this.privateKeySize&&r(new Error(`Invalid key length: ${e.key.byteLength}`)),t(e.key.buffer)})}_deserializePrivateKey(e){return new Promise((t,r)=>{e.byteLength!==this.privateKeySize&&r(new Error(`Invalid key length: ${e.byteLength}`)),t(new a.Bk(this.name,new Uint8Array(e),"private",["deriveBits"]))})}_importJWK(e,t){return new Promise((r,i)=>{void 0!==e.kty&&"AKP"===e.kty||i(new Error(`Invalid kty: ${e.kty}`)),void 0!==e.alg&&e.alg===b||i(new Error(`Invalid alg: ${e.alg}`)),t||(void 0===e.priv&&i(new Error("Invalid key: `priv` not found")),void 0===e.key_ops||1===e.key_ops.length&&"deriveBits"===e.key_ops[0]||i(new Error("Invalid key: `key_ops` should be ['deriveBits']")),r((0,a.rf)(e.priv))),void 0!==e.priv&&i(new Error("Invalid key: `priv` should not be set")),void 0===e.pub&&i(new Error("Invalid key: `pub` not found")),void 0!==e.key_ops&&e.key_ops.length>0&&i(new Error("Invalid key: `key_ops` should not be set")),r((0,a.rf)(e.pub))})}}}};
|
|
2
|
+
export const __webpack_esm_id__=508;export const __webpack_esm_ids__=[508];export const __webpack_esm_modules__={3508:(e,t,r)=>{r.d(t,{XWing:()=>g});var i=r(8619),a=r(4220);const n=BigInt(1),s=BigInt(2),y=BigInt(3),h=BigInt(5),o=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function c(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const w=(()=>{const e=o;return(0,a.EC)({P:e,type:"x25519",powPminus2:t=>{const{pow_p_5_8:r,b2:i}=function(e){const t=BigInt(10),r=BigInt(20),i=BigInt(40),y=BigInt(80),c=o,w=e*e%c*e%c,l=(0,a.zH)(w,s,c)*w%c,u=(0,a.zH)(l,n,c)*e%c,f=(0,a.zH)(u,h,c)*u%c,b=(0,a.zH)(f,t,c)*f%c,d=(0,a.zH)(b,r,c)*b%c,p=(0,a.zH)(d,i,c)*d%c,v=(0,a.zH)(p,y,c)*p%c,g=(0,a.zH)(v,y,c)*p%c,_=(0,a.zH)(g,t,c)*f%c;return{pow_p_5_8:(0,a.zH)(_,s,c)*e%c,b2:w}}(t);return(0,a.zi)((0,a.zH)(r,y,e)*i,e)},adjustScalarBytes:c})})();class l extends a.o0{async extract(e,t){if(await this._setup(),0===e.byteLength&&(e=new ArrayBuffer(this.hashSize)),e.byteLength!==this.hashSize)return(0,a.w8)(a.sc,new Uint8Array(e),new Uint8Array(t)).buffer;const r=await this._api.importKey("raw",e,this.algHash,!1,["sign"]);return await this._api.sign("HMAC",r,t)}}const u="X25519";class f{constructor(e){Object.defineProperty(this,"_hkdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nPk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nSk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._hkdf=e,this._nPk=32,this._nSk=32}async serializePublicKey(e){try{return await this._serializePublicKey(e)}catch(e){throw new a.LV(e)}}async deserializePublicKey(e){try{return await this._importRawKey(e,!0)}catch(e){throw new a.Ug(e)}}async serializePrivateKey(e){try{return await this._serializePrivateKey(e)}catch(e){throw new a.LV(e)}}async deserializePrivateKey(e){try{return await this._importRawKey(e,!1)}catch(e){throw new a.Ug(e)}}async importKey(e,t,r){try{if("raw"===e)return await this._importRawKey(t,r);if(t instanceof ArrayBuffer)throw new Error("Invalid jwk key format");return await this._importJWK(t,r)}catch(e){throw new a.Ug(e)}}async generateKeyPair(){try{const e=await w.utils.randomSecretKey(),t=new a.Bk(u,e,"private",a.xE);return{publicKey:await this.derivePublicKey(t),privateKey:t}}catch(e){throw new a.EM(e)}}async deriveKeyPair(e){try{const t=await this._hkdf.labeledExtract(a.wg.buffer,a.CY,new Uint8Array(e)),r=await this._hkdf.labeledExpand(t,a.Hz,a.wg,this._nSk),i=new a.Bk(u,new Uint8Array(r),"private",a.xE);return{privateKey:i,publicKey:await this.derivePublicKey(i)}}catch(e){throw new a.$7(e)}}async derivePublicKey(e){try{return await this._derivePublicKey(e)}catch(e){throw new a.Ug(e)}}async dh(e,t){try{return await this._dh(e,t)}catch(e){throw new a.LV(e)}}async derive(e,t){try{return await this._derive(e,t)}catch(e){throw new a.LV(e)}}_serializePublicKey(e){return new Promise(t=>{t(e.key.buffer)})}_serializePrivateKey(e){return new Promise(t=>{t(e.key.buffer)})}_importRawKey(e,t){return new Promise((r,i)=>{t&&e.byteLength!==this._nPk&&i(new Error("Invalid length of the key")),t||e.byteLength===this._nSk||i(new Error("Invalid length of the key")),r(new a.Bk(u,new Uint8Array(e),t?"public":"private",t?[]:a.xE))})}_importJWK(e,t){return new Promise((r,i)=>{void 0!==e.kty&&"OKP"===e.kty||i(new Error(`Invalid kty: ${e.kty}`)),void 0!==e.crv&&"X25519"===e.crv||i(new Error(`Invalid crv: ${e.crv}`)),t?(void 0!==e.d&&i(new Error("Invalid key: `d` should not be set")),void 0===e.x&&i(new Error("Invalid key: `x` not found")),r(new a.Bk(u,(0,a.rf)(e.x),"public"))):("string"!=typeof e.d&&i(new Error("Invalid key: `d` not found")),r(new a.Bk(u,(0,a.rf)(e.d),"private",a.xE)))})}_derivePublicKey(e){return new Promise((t,r)=>{try{const r=w.getPublicKey(e.key);t(new a.Bk(u,r,"public"))}catch(e){r(e)}})}_dh(e,t){return new Promise((r,i)=>{try{r(w.getSharedSecret(e.key,t.key).buffer)}catch(e){i(e)}})}_derive(e,t){return new Promise((r,i)=>{try{r(w.getSharedSecret(e,t))}catch(e){i(e)}})}}a.gX;const b="X-Wing",d=new Uint8Array([9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),p=new Uint8Array([92,46,47,47,94,92]);function v(e,t,r,a){const n=new Uint8Array(e.length+t.length+r.length+a.length+p.length);return n.set(e,0),n.set(t,e.length),n.set(r,e.length+t.length),n.set(a,e.length+t.length+r.length),n.set(p,e.length+t.length+r.length+a.length),i.C2.create().update(n).digest()}class g{constructor(){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:a.h.XWing}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:b}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:1120}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:1216}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"auth",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_m",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_x25519",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._m=new i.wo,this._x25519=new f(new l)}async serializePublicKey(e){await this._setup();try{return await this._serializePublicKey(e)}catch(e){throw new a.LV(e)}}async deserializePublicKey(e){await this._setup();try{return await this._deserializePublicKey(e)}catch(e){throw new a.Ug(e)}}async serializePrivateKey(e){await this._setup();try{return await this._serializePrivateKey(e)}catch(e){throw new a.LV(e)}}async deserializePrivateKey(e){await this._setup();try{return await this._deserializePrivateKey(e)}catch(e){throw new a.Ug(e)}}async generateKeyPair(){await this._setup();const e=new Uint8Array(32);try{this._api.getRandomValues(e)}catch(e){throw new a.EM(e)}try{const[t,r]=await this._generateKeyPairDerand(e);return{privateKey:await this.deserializePrivateKey(e.buffer),publicKey:await this.deserializePublicKey(r.buffer)}}catch(e){throw new a.$7(e)}}async generateKeyPairDerand(e){if(32!==e.byteLength)throw new a.NS("Invalid length of sk");try{const[t,r]=await this._generateKeyPairDerand(e);return{privateKey:await this.deserializePrivateKey(e.buffer),publicKey:await this.deserializePublicKey(r.buffer)}}catch(e){throw new a.$7(e)}}async deriveKeyPair(e){await this._setup();try{const t=i.mh.create({dkLen:32}).update(new Uint8Array(e)).digest(),[r,a]=await this._generateKeyPairDerand(t);return{privateKey:await this.deserializePrivateKey(t.buffer),publicKey:await this.deserializePublicKey(a.buffer)}}catch(e){throw new a.$7(e)}}async importKey(e,t,r=!0){await this._setup();try{let i;if("jwk"===e){if(t instanceof ArrayBuffer||t instanceof Uint8Array)throw new Error("Invalid jwk key format");i=await this._importJWK(t,r)}else if(t instanceof ArrayBuffer)i=new Uint8Array(t);else{if(!(t instanceof Uint8Array))throw new Error("Invalid key format");i=t}if(r&&i.byteLength!==this.publicKeySize)throw new Error("Invalid length of the key");if(!r&&i.byteLength!==this.privateKeySize)throw new Error("Invalid length of the key");return new a.Bk(b,i,r?"public":"private",r?[]:a.xE)}catch(e){throw new a.Ug(e)}}async encap(e){let t,r,i;if(void 0!==e.ekm&&!(0,a.Di)(e.ekm)){if(64!==e.ekm.byteLength)throw new a.NS("ekm must be 64 bytes in length");t=e.ekm}if(void 0!==t){const e=new Uint8Array(t);r=e.subarray(0,32),i=e.subarray(32,64)}else{i=new Uint8Array(32);try{this._api.getRandomValues(i)}catch(e){throw new a.EM(e)}}const n=new Uint8Array(await this.serializePublicKey(e.recipientPublicKey));if(1216!==n.byteLength)throw new a.NS("Invalid length of recipientPublicKey");await this._setup();try{const e=n.subarray(0,1184),t=n.subarray(1184,1216),s=await this._x25519.derive(i,d),y=await this._x25519.derive(i,t),[h,o]=await this._m.encap(e,r);return{sharedSecret:v(o,y,s,t).buffer,enc:(0,a.xW)(h,s).buffer}}catch(e){throw new a.Wg(e)}}async decap(e){const t=(0,a.Di)(e.recipientKey)?e.recipientKey.privateKey:e.recipientKey;if(1120!==e.enc.byteLength)throw new a.NS("Invalid length of enc");const r=new Uint8Array(await this.serializePrivateKey(t));if(32!==r.byteLength)throw new a.NS("Invalid length of recipientKey");await this._setup();try{const[t,i,a,n]=await this._expandDecapsulationKey(r),s=new Uint8Array(e.enc),y=s.subarray(0,1088),h=s.subarray(1088);return v(await this._m.decap(y,t),await this._x25519.derive(i,h),h,n).buffer}catch(e){throw new a.uu(e)}}async _setup(){void 0===this._api&&(this._api=await(0,a.QZ)())}async _generateKeyPairDerand(e){const[t,r,i,n]=await this._expandDecapsulationKey(e);return[e,(0,a.xW)(i,n)]}async _expandDecapsulationKey(e){const t=i.mh.create({dkLen:96}).update(e).digest(),[r,a]=await this._m.deriveKeyPair(t.subarray(0,64)),n=t.subarray(64,96);return[a,n,r,await this._x25519.derive(n,d)]}_serializePublicKey(e){return new Promise((t,r)=>{"public"!==e.type&&r(new Error("Not public key")),e.algorithm.name!==this.name&&r(new Error(`Invalid algorithm name: ${e.algorithm.name}`)),e.key.byteLength!==this.publicKeySize&&r(new Error(`Invalid key length: ${e.key.byteLength}`)),t(e.key.buffer)})}_deserializePublicKey(e){return new Promise((t,r)=>{e.byteLength!==this.publicKeySize&&r(new Error(`Invalid key length: ${e.byteLength}`)),t(new a.Bk(this.name,new Uint8Array(e),"public"))})}_serializePrivateKey(e){return new Promise((t,r)=>{"private"!==e.type&&r(new Error("Not private key")),e.algorithm.name!==this.name&&r(new Error(`Invalid algorithm name: ${e.algorithm.name}`)),e.key.byteLength!==this.privateKeySize&&r(new Error(`Invalid key length: ${e.key.byteLength}`)),t(e.key.buffer)})}_deserializePrivateKey(e){return new Promise((t,r)=>{e.byteLength!==this.privateKeySize&&r(new Error(`Invalid key length: ${e.byteLength}`)),t(new a.Bk(this.name,new Uint8Array(e),"private",["deriveBits"]))})}_importJWK(e,t){return new Promise((r,i)=>{void 0!==e.kty&&"AKP"===e.kty||i(new Error(`Invalid kty: ${e.kty}`)),void 0!==e.alg&&e.alg===b||i(new Error(`Invalid alg: ${e.alg}`)),t||(void 0===e.priv&&i(new Error("Invalid key: `priv` not found")),void 0===e.key_ops||1===e.key_ops.length&&"deriveBits"===e.key_ops[0]||i(new Error("Invalid key: `key_ops` should be ['deriveBits']")),r((0,a.rf)(e.priv))),void 0!==e.priv&&i(new Error("Invalid key: `priv` should not be set")),void 0===e.pub&&i(new Error("Invalid key: `pub` not found")),void 0!==e.key_ops&&e.key_ops.length>0&&i(new Error("Invalid key: `key_ops` should not be set")),r((0,a.rf)(e.pub))})}}}};
|