fullstack.web/swa/u/gmhelper.js

2 lines
45 KiB
JavaScript

!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.gmhelper=r():t.gmhelper=r()}("undefined"!=typeof self?self:this,(function(){return t={10:(t,r,e)=>{const i=e(694),{G:n,curve:o,n:s}=i.generateEcparam(),h=e(664).sm3,u=e(742),a=e(751);function f(t){for(var r="",e=0;e<t.length;e++){var i=t.charCodeAt(e).toString(16);i.length<2&&(i="0"+i),r+=i}return r}function c(t,r,e){if(32!==t.length||32!==r.length||32!==e.length)throw"输入格式错误";for(var i=l(t),n=l(r),o=l(e),s=[],h=0;h<16;h++)s[h]=i[h]^n[h]^o[h];return function(t){for(var r=[],e=0;e<t.length;e++)r.push((t[e]>>>4).toString(16)),r.push((15&t[e]).toString(16));return r.join("")}(s)}function l(t){for(var r=[],e=0;e<t.length;e+=2)r.push(parseInt(t.substr(e,2),16));return r}function p(t,r,e){var i=c(t,r,e),n=a.SM4CryptECB("00000000000000000000000000000000",1,i);return{checkValue:n.slice(0,8),ret:n,keyPlaintext:i}}function g(t){return a.SM4CryptECB("00000000000000000000000000000000",1,t)}function f(t){for(var r="",e=0;e<t.length;e++){var i=t.charCodeAt(e).toString(16);i.length<2&&(i="0"+i),r+=i}return r}function y(t,r,e="1234567812345678"){e=i.utf8ToHex(e);const o=i.leftPad(n.curve.a.toBigInteger().toRadix(16),64),s=i.leftPad(n.curve.b.toBigInteger().toRadix(16),64),u=i.leftPad(n.getX().toBigInteger().toRadix(16),64),a=i.leftPad(n.getY().toBigInteger().toRadix(16),64);let c,l;if(128===r.length)c=r.substr(0,64),l=r.substr(64,64);else{const t=n.curve.decodePointHex(r);c=i.leftPad(t.getX().toBigInteger().toRadix(16),64),l=i.leftPad(t.getY().toBigInteger().toRadix(16),64)}const p=i.hexToArray(e+o+s+u+a+c+l),g=4*e.length;p.unshift(255&g),p.unshift(g>>8&255);const y=h(p);return{z:y,hex:h(i.hexToArray(y+f(t)))}}function d(t){return t=(t=t.substr("-----BEGIN ECDSA PUBLIC KEY-----".length)).substr(0,t.length-"-----END ECDSA PUBLIC KEY-----".length),(t=function(t){for(var r="",e=0;e<t.length;e++){var i=t[e];r+=1===(i=i.toString(16)).length?"0"+i:i}return r}(u.toByteArray(t))).substr(t.indexOf("03420004")+8)}t.exports={xor:c,kcv:g,decryptKey:function(t,r){return a.SM4CryptECB(t,0,r)},checkValue:p,checkValueKey:function(t,r,e,i){const n=c(t,r,e);var o=a.SM4CryptECB("00000000000000000000000000000000",1,n);const s=o.slice(0,8);return{keyCiphertext:a.SM4CryptECB(n,1,i),checkValue:s,ret:o}},decryptionKey:function(t,r){return{keyPlaintext:a.SM4CryptECB(t,0,r),checkData:g(t).slice(0,8)}},decentralizedMainKey:function(t){var r;r=t,t=Array.prototype.map.call(new Uint8Array(r),(t=>("00"+t.toString(16)).slice(-2))).join(""),console.log("mk="+t);let e="11111111111111111111111111111111",i="22222222222222222222222222222222",n="33333333333333333333333333333333",o=p(e,i,n),s=function(t,r){var e=a.SM4CryptECB("00000000000000000000000000000000",1,t);const i=e.slice(0,8);return{keyCiphertext:a.SM4CryptECB(t,1,r),checkValue:i,ret:e}}(t,o.keyPlaintext);return{p1:e,p2:i,p3:n,p:o,m:s}},base64PkToHexPk:d,getHash:y,getHashAsBase64:function(t,r){var e=y(t,d(r));return{z:e.z,hashHex:e.hex,hashBase64:u.fromByteArray(i.hexToArray(e.hex))}}}},742:(t,r)=>{"use strict";r.byteLength=function(t){var r=u(t),e=r[0],i=r[1];return 3*(e+i)/4-i},r.toByteArray=function(t){var r,e,o=u(t),s=o[0],h=o[1],a=new n(function(t,r,e){return 3*(r+e)/4-e}(0,s,h)),f=0,c=h>0?s-4:s;for(e=0;e<c;e+=4)r=i[t.charCodeAt(e)]<<18|i[t.charCodeAt(e+1)]<<12|i[t.charCodeAt(e+2)]<<6|i[t.charCodeAt(e+3)],a[f++]=r>>16&255,a[f++]=r>>8&255,a[f++]=255&r;return 2===h&&(r=i[t.charCodeAt(e)]<<2|i[t.charCodeAt(e+1)]>>4,a[f++]=255&r),1===h&&(r=i[t.charCodeAt(e)]<<10|i[t.charCodeAt(e+1)]<<4|i[t.charCodeAt(e+2)]>>2,a[f++]=r>>8&255,a[f++]=255&r),a},r.fromByteArray=function(t){for(var r,i=t.length,n=i%3,o=[],s=16383,h=0,u=i-n;h<u;h+=s)o.push(a(t,h,h+s>u?u:h+s));return 1===n?(r=t[i-1],o.push(e[r>>2]+e[r<<4&63]+"==")):2===n&&(r=(t[i-2]<<8)+t[i-1],o.push(e[r>>10]+e[r>>4&63]+e[r<<2&63]+"=")),o.join("")};for(var e=[],i=[],n="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,h=o.length;s<h;++s)e[s]=o[s],i[o.charCodeAt(s)]=s;function u(t){var r=t.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=t.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function a(t,r,i){for(var n,o,s=[],h=r;h<i;h+=3)n=(t[h]<<16&16711680)+(t[h+1]<<8&65280)+(255&t[h+2]),s.push(e[(o=n)>>18&63]+e[o>>12&63]+e[o>>6&63]+e[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},77:function(t,r){(function(){var r;function e(t,r,e){null!=t&&("number"==typeof t?this.fromNumber(t,r,e):null==r&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,r))}function i(){return new e(null)}var n="undefined"!=typeof navigator;n&&"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=function(t,r,e,i,n,o){for(var s=32767&r,h=r>>15;--o>=0;){var u=32767&this[t],a=this[t++]>>15,f=h*u+a*s;n=((u=s*u+((32767&f)<<15)+e[i]+(1073741823&n))>>>30)+(f>>>15)+h*a+(n>>>30),e[i++]=1073741823&u}return n},r=30):n&&"Netscape"!=navigator.appName?(e.prototype.am=function(t,r,e,i,n,o){for(;--o>=0;){var s=r*this[t++]+e[i]+n;n=Math.floor(s/67108864),e[i++]=67108863&s}return n},r=26):(e.prototype.am=function(t,r,e,i,n,o){for(var s=16383&r,h=r>>14;--o>=0;){var u=16383&this[t],a=this[t++]>>14,f=h*u+a*s;n=((u=s*u+((16383&f)<<14)+e[i]+n)>>28)+(f>>14)+h*a,e[i++]=268435455&u}return n},r=28),e.prototype.DB=r,e.prototype.DM=(1<<r)-1,e.prototype.DV=1<<r,e.prototype.FV=Math.pow(2,52),e.prototype.F1=52-r,e.prototype.F2=2*r-52;var o,s,h=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)h[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)h[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)h[o++]=s;function u(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function a(t,r){var e=h[t.charCodeAt(r)];return null==e?-1:e}function f(t){var r=i();return r.fromInt(t),r}function c(t){var r,e=1;return 0!=(r=t>>>16)&&(t=r,e+=16),0!=(r=t>>8)&&(t=r,e+=8),0!=(r=t>>4)&&(t=r,e+=4),0!=(r=t>>2)&&(t=r,e+=2),0!=(r=t>>1)&&(t=r,e+=1),e}function l(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function g(t,r){return t&r}function y(t,r){return t|r}function d(t,r){return t^r}function m(t,r){return t&~r}function v(t){if(0==t)return-1;var r=0;return 0==(65535&t)&&(t>>=16,r+=16),0==(255&t)&&(t>>=8,r+=8),0==(15&t)&&(t>>=4,r+=4),0==(3&t)&&(t>>=2,r+=2),0==(1&t)&&++r,r}function T(t){for(var r=0;0!=t;)t&=t-1,++r;return r}function F(){}function w(t){return t}function B(t){this.r2=i(),this.q3=i(),e.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}l.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},l.prototype.revert=function(t){return t},l.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},l.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},l.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)},p.prototype.convert=function(t){var r=i();return t.abs().dlShiftTo(this.m.t,r),r.divRemTo(this.m,null,r),t.s<0&&r.compareTo(e.ZERO)>0&&this.m.subTo(r,r),r},p.prototype.revert=function(t){var r=i();return t.copyTo(r),this.reduce(r),r},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var r=0;r<this.m.t;++r){var e=32767&t[r],i=e*this.mpl+((e*this.mph+(t[r]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[e=r+this.m.t]+=this.m.am(0,i,t,r,0,this.m.t);t[e]>=t.DV;)t[e]-=t.DV,t[++e]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},p.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)},e.prototype.copyTo=function(t){for(var r=this.t-1;r>=0;--r)t[r]=this[r];t.t=this.t,t.s=this.s},e.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},e.prototype.fromString=function(t,r){var i;if(16==r)i=4;else if(8==r)i=3;else if(256==r)i=8;else if(2==r)i=1;else if(32==r)i=5;else{if(4!=r)return void this.fromRadix(t,r);i=2}this.t=0,this.s=0;for(var n=t.length,o=!1,s=0;--n>=0;){var h=8==i?255&t[n]:a(t,n);h<0?"-"==t.charAt(n)&&(o=!0):(o=!1,0==s?this[this.t++]=h:s+i>this.DB?(this[this.t-1]|=(h&(1<<this.DB-s)-1)<<s,this[this.t++]=h>>this.DB-s):this[this.t-1]|=h<<s,(s+=i)>=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),o&&e.ZERO.subTo(this,this)},e.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},e.prototype.dlShiftTo=function(t,r){var e;for(e=this.t-1;e>=0;--e)r[e+t]=this[e];for(e=t-1;e>=0;--e)r[e]=0;r.t=this.t+t,r.s=this.s},e.prototype.drShiftTo=function(t,r){for(var e=t;e<this.t;++e)r[e-t]=this[e];r.t=Math.max(this.t-t,0),r.s=this.s},e.prototype.lShiftTo=function(t,r){var e,i=t%this.DB,n=this.DB-i,o=(1<<n)-1,s=Math.floor(t/this.DB),h=this.s<<i&this.DM;for(e=this.t-1;e>=0;--e)r[e+s+1]=this[e]>>n|h,h=(this[e]&o)<<i;for(e=s-1;e>=0;--e)r[e]=0;r[s]=h,r.t=this.t+s+1,r.s=this.s,r.clamp()},e.prototype.rShiftTo=function(t,r){r.s=this.s;var e=Math.floor(t/this.DB);if(e>=this.t)r.t=0;else{var i=t%this.DB,n=this.DB-i,o=(1<<i)-1;r[0]=this[e]>>i;for(var s=e+1;s<this.t;++s)r[s-e-1]|=(this[s]&o)<<n,r[s-e]=this[s]>>i;i>0&&(r[this.t-e-1]|=(this.s&o)<<n),r.t=this.t-e,r.clamp()}},e.prototype.subTo=function(t,r){for(var e=0,i=0,n=Math.min(t.t,this.t);e<n;)i+=this[e]-t[e],r[e++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;e<this.t;)i+=this[e],r[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<t.t;)i-=t[e],r[e++]=i&this.DM,i>>=this.DB;i-=t.s}r.s=i<0?-1:0,i<-1?r[e++]=this.DV+i:i>0&&(r[e++]=i),r.t=e,r.clamp()},e.prototype.multiplyTo=function(t,r){var i=this.abs(),n=t.abs(),o=i.t;for(r.t=o+n.t;--o>=0;)r[o]=0;for(o=0;o<n.t;++o)r[o+i.t]=i.am(0,n[o],r,o,0,i.t);r.s=0,r.clamp(),this.s!=t.s&&e.ZERO.subTo(r,r)},e.prototype.squareTo=function(t){for(var r=this.abs(),e=t.t=2*r.t;--e>=0;)t[e]=0;for(e=0;e<r.t-1;++e){var i=r.am(e,r[e],t,2*e,0,1);(t[e+r.t]+=r.am(e+1,2*r[e],t,2*e+1,i,r.t-e-1))>=r.DV&&(t[e+r.t]-=r.DV,t[e+r.t+1]=1)}t.t>0&&(t[t.t-1]+=r.am(e,r[e],t,2*e,0,1)),t.s=0,t.clamp()},e.prototype.divRemTo=function(t,r,n){var o=t.abs();if(!(o.t<=0)){var s=this.abs();if(s.t<o.t)return null!=r&&r.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=i());var h=i(),u=this.s,a=t.s,f=this.DB-c(o[o.t-1]);f>0?(o.lShiftTo(f,h),s.lShiftTo(f,n)):(o.copyTo(h),s.copyTo(n));var l=h.t,p=h[l-1];if(0!=p){var g=p*(1<<this.F1)+(l>1?h[l-2]>>this.F2:0),y=this.FV/g,d=(1<<this.F1)/g,m=1<<this.F2,v=n.t,T=v-l,F=null==r?i():r;for(h.dlShiftTo(T,F),n.compareTo(F)>=0&&(n[n.t++]=1,n.subTo(F,n)),e.ONE.dlShiftTo(l,F),F.subTo(h,h);h.t<l;)h[h.t++]=0;for(;--T>=0;){var w=n[--v]==p?this.DM:Math.floor(n[v]*y+(n[v-1]+m)*d);if((n[v]+=h.am(0,w,n,T,0,l))<w)for(h.dlShiftTo(T,F),n.subTo(F,n);n[v]<--w;)n.subTo(F,n)}null!=r&&(n.drShiftTo(l,r),u!=a&&e.ZERO.subTo(r,r)),n.t=l,n.clamp(),f>0&&n.rShiftTo(f,n),u<0&&e.ZERO.subTo(n,n)}}},e.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var r=3&t;return(r=(r=(r=(r=r*(2-(15&t)*r)&15)*(2-(255&t)*r)&255)*(2-((65535&t)*r&65535))&65535)*(2-t*r%this.DV)%this.DV)>0?this.DV-r:-r},e.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},e.prototype.exp=function(t,r){if(t>4294967295||t<1)return e.ONE;var n=i(),o=i(),s=r.convert(this),h=c(t)-1;for(s.copyTo(n);--h>=0;)if(r.sqrTo(n,o),(t&1<<h)>0)r.mulTo(o,s,n);else{var u=n;n=o,o=u}return r.revert(n)},e.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var r;if(16==t)r=4;else if(8==t)r=3;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return this.toRadix(t);r=2}var e,i=(1<<r)-1,n=!1,o="",s=this.t,h=this.DB-s*this.DB%r;if(s-- >0)for(h<this.DB&&(e=this[s]>>h)>0&&(n=!0,o=u(e));s>=0;)h<r?(e=(this[s]&(1<<h)-1)<<r-h,e|=this[--s]>>(h+=this.DB-r)):(e=this[s]>>(h-=r)&i,h<=0&&(h+=this.DB,--s)),e>0&&(n=!0),n&&(o+=u(e));return n?o:"0"},e.prototype.negate=function(){var t=i();return e.ZERO.subTo(this,t),t},e.prototype.abs=function(){return this.s<0?this.negate():this},e.prototype.compareTo=function(t){var r=this.s-t.s;if(0!=r)return r;var e=this.t;if(0!=(r=e-t.t))return this.s<0?-r:r;for(;--e>=0;)if(0!=(r=this[e]-t[e]))return r;return 0},e.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+c(this[this.t-1]^this.s&this.DM)},e.prototype.mod=function(t){var r=i();return this.abs().divRemTo(t,null,r),this.s<0&&r.compareTo(e.ZERO)>0&&t.subTo(r,r),r},e.prototype.modPowInt=function(t,r){var e;return e=t<256||r.isEven()?new l(r):new p(r),this.exp(t,e)},e.ZERO=f(0),e.ONE=f(1),F.prototype.convert=w,F.prototype.revert=w,F.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e)},F.prototype.sqrTo=function(t,r){t.squareTo(r)},B.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var r=i();return t.copyTo(r),this.reduce(r),r},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},B.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},B.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)};var b,x,S,A=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],I=(1<<26)/A[A.length-1];function E(){var t;t=(new Date).getTime(),x[S++]^=255&t,x[S++]^=t>>8&255,x[S++]^=t>>16&255,x[S++]^=t>>24&255,S>=O&&(S-=O)}if(e.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},e.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var r=this.chunkSize(t),e=Math.pow(t,r),n=f(e),o=i(),s=i(),h="";for(this.divRemTo(n,o,s);o.signum()>0;)h=(e+s.intValue()).toString(t).substr(1)+h,o.divRemTo(n,o,s);return s.intValue().toString(t)+h},e.prototype.fromRadix=function(t,r){this.fromInt(0),null==r&&(r=10);for(var i=this.chunkSize(r),n=Math.pow(r,i),o=!1,s=0,h=0,u=0;u<t.length;++u){var f=a(t,u);f<0?"-"==t.charAt(u)&&0==this.signum()&&(o=!0):(h=r*h+f,++s>=i&&(this.dMultiply(n),this.dAddOffset(h,0),s=0,h=0))}s>0&&(this.dMultiply(Math.pow(r,s)),this.dAddOffset(h,0)),o&&e.ZERO.subTo(this,this)},e.prototype.fromNumber=function(t,r,i){if("number"==typeof r)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(e.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(r);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(e.ONE.shiftLeft(t-1),this);else{var n=new Array,o=7&t;n.length=1+(t>>3),r.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}},e.prototype.bitwiseTo=function(t,r,e){var i,n,o=Math.min(t.t,this.t);for(i=0;i<o;++i)e[i]=r(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=o;i<this.t;++i)e[i]=r(this[i],n);e.t=this.t}else{for(n=this.s&this.DM,i=o;i<t.t;++i)e[i]=r(n,t[i]);e.t=t.t}e.s=r(this.s,t.s),e.clamp()},e.prototype.changeBit=function(t,r){var i=e.ONE.shiftLeft(t);return this.bitwiseTo(i,r,i),i},e.prototype.addTo=function(t,r){for(var e=0,i=0,n=Math.min(t.t,this.t);e<n;)i+=this[e]+t[e],r[e++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;e<this.t;)i+=this[e],r[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<t.t;)i+=t[e],r[e++]=i&this.DM,i>>=this.DB;i+=t.s}r.s=i<0?-1:0,i>0?r[e++]=i:i<-1&&(r[e++]=this.DV+i),r.t=e,r.clamp()},e.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},e.prototype.dAddOffset=function(t,r){if(0!=t){for(;this.t<=r;)this[this.t++]=0;for(this[r]+=t;this[r]>=this.DV;)this[r]-=this.DV,++r>=this.t&&(this[this.t++]=0),++this[r]}},e.prototype.multiplyLowerTo=function(t,r,e){var i,n=Math.min(this.t+t.t,r);for(e.s=0,e.t=n;n>0;)e[--n]=0;for(i=e.t-this.t;n<i;++n)e[n+this.t]=this.am(0,t[n],e,n,0,this.t);for(i=Math.min(t.t,r);n<i;++n)this.am(0,t[n],e,n,0,r-n);e.clamp()},e.prototype.multiplyUpperTo=function(t,r,e){--r;var i=e.t=this.t+t.t-r;for(e.s=0;--i>=0;)e[i]=0;for(i=Math.max(r-this.t,0);i<t.t;++i)e[this.t+i-r]=this.am(r-i,t[i],e,0,0,this.t+i-r);e.clamp(),e.drShiftTo(1,e)},e.prototype.modInt=function(t){if(t<=0)return 0;var r=this.DV%t,e=this.s<0?t-1:0;if(this.t>0)if(0==r)e=this[0]%t;else for(var i=this.t-1;i>=0;--i)e=(r*e+this[i])%t;return e},e.prototype.millerRabin=function(t){var r=this.subtract(e.ONE),n=r.getLowestSetBit();if(n<=0)return!1;var o=r.shiftRight(n);(t=t+1>>1)>A.length&&(t=A.length);for(var s=i(),h=0;h<t;++h){s.fromInt(A[Math.floor(Math.random()*A.length)]);var u=s.modPow(o,this);if(0!=u.compareTo(e.ONE)&&0!=u.compareTo(r)){for(var a=1;a++<n&&0!=u.compareTo(r);)if(0==(u=u.modPowInt(2,this)).compareTo(e.ONE))return!1;if(0!=u.compareTo(r))return!1}}return!0},e.prototype.clone=function(){var t=i();return this.copyTo(t),t},e.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},e.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},e.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},e.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},e.prototype.toByteArray=function(){var t=this.t,r=new Array;r[0]=this.s;var e,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i<this.DB&&(e=this[t]>>i)!=(this.s&this.DM)>>i&&(r[n++]=e|this.s<<this.DB-i);t>=0;)i<8?(e=(this[t]&(1<<i)-1)<<8-i,e|=this[--t]>>(i+=this.DB-8)):(e=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),0!=(128&e)&&(e|=-256),0==n&&(128&this.s)!=(128&e)&&++n,(n>0||e!=this.s)&&(r[n++]=e);return r},e.prototype.equals=function(t){return 0==this.compareTo(t)},e.prototype.min=function(t){return this.compareTo(t)<0?this:t},e.prototype.max=function(t){return this.compareTo(t)>0?this:t},e.prototype.and=function(t){var r=i();return this.bitwiseTo(t,g,r),r},e.prototype.or=function(t){var r=i();return this.bitwiseTo(t,y,r),r},e.prototype.xor=function(t){var r=i();return this.bitwiseTo(t,d,r),r},e.prototype.andNot=function(t){var r=i();return this.bitwiseTo(t,m,r),r},e.prototype.not=function(){for(var t=i(),r=0;r<this.t;++r)t[r]=this.DM&~this[r];return t.t=this.t,t.s=~this.s,t},e.prototype.shiftLeft=function(t){var r=i();return t<0?this.rShiftTo(-t,r):this.lShiftTo(t,r),r},e.prototype.shiftRight=function(t){var r=i();return t<0?this.lShiftTo(-t,r):this.rShiftTo(t,r),r},e.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+v(this[t]);return this.s<0?this.t*this.DB:-1},e.prototype.bitCount=function(){for(var t=0,r=this.s&this.DM,e=0;e<this.t;++e)t+=T(this[e]^r);return t},e.prototype.testBit=function(t){var r=Math.floor(t/this.DB);return r>=this.t?0!=this.s:0!=(this[r]&1<<t%this.DB)},e.prototype.setBit=function(t){return this.changeBit(t,y)},e.prototype.clearBit=function(t){return this.changeBit(t,m)},e.prototype.flipBit=function(t){return this.changeBit(t,d)},e.prototype.add=function(t){var r=i();return this.addTo(t,r),r},e.prototype.subtract=function(t){var r=i();return this.subTo(t,r),r},e.prototype.multiply=function(t){var r=i();return this.multiplyTo(t,r),r},e.prototype.divide=function(t){var r=i();return this.divRemTo(t,r,null),r},e.prototype.remainder=function(t){var r=i();return this.divRemTo(t,null,r),r},e.prototype.divideAndRemainder=function(t){var r=i(),e=i();return this.divRemTo(t,r,e),new Array(r,e)},e.prototype.modPow=function(t,r){var e,n,o=t.bitLength(),s=f(1);if(o<=0)return s;e=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new l(r):r.isEven()?new B(r):new p(r);var h=new Array,u=3,a=e-1,g=(1<<e)-1;if(h[1]=n.convert(this),e>1){var y=i();for(n.sqrTo(h[1],y);u<=g;)h[u]=i(),n.mulTo(y,h[u-2],h[u]),u+=2}var d,m,v=t.t-1,T=!0,F=i();for(o=c(t[v])-1;v>=0;){for(o>=a?d=t[v]>>o-a&g:(d=(t[v]&(1<<o+1)-1)<<a-o,v>0&&(d|=t[v-1]>>this.DB+o-a)),u=e;0==(1&d);)d>>=1,--u;if((o-=u)<0&&(o+=this.DB,--v),T)h[d].copyTo(s),T=!1;else{for(;u>1;)n.sqrTo(s,F),n.sqrTo(F,s),u-=2;u>0?n.sqrTo(s,F):(m=s,s=F,F=m),n.mulTo(F,h[d],s)}for(;v>=0&&0==(t[v]&1<<o);)n.sqrTo(s,F),m=s,s=F,F=m,--o<0&&(o=this.DB-1,--v)}return n.revert(s)},e.prototype.modInverse=function(t){var r=t.isEven();if(this.isEven()&&r||0==t.signum())return e.ZERO;for(var i=t.clone(),n=this.clone(),o=f(1),s=f(0),h=f(0),u=f(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),r?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(t,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),r?(h.isEven()&&u.isEven()||(h.addTo(this,h),u.subTo(t,u)),h.rShiftTo(1,h)):u.isEven()||u.subTo(t,u),u.rShiftTo(1,u);i.compareTo(n)>=0?(i.subTo(n,i),r&&o.subTo(h,o),s.subTo(u,s)):(n.subTo(i,n),r&&h.subTo(o,h),u.subTo(s,u))}return 0!=n.compareTo(e.ONE)?e.ZERO:u.compareTo(t)>=0?u.subtract(t):u.signum()<0?(u.addTo(t,u),u.signum()<0?u.add(t):u):u},e.prototype.pow=function(t){return this.exp(t,new F)},e.prototype.gcd=function(t){var r=this.s<0?this.negate():this.clone(),e=t.s<0?t.negate():t.clone();if(r.compareTo(e)<0){var i=r;r=e,e=i}var n=r.getLowestSetBit(),o=e.getLowestSetBit();if(o<0)return r;for(n<o&&(o=n),o>0&&(r.rShiftTo(o,r),e.rShiftTo(o,e));r.signum()>0;)(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),r.compareTo(e)>=0?(r.subTo(e,r),r.rShiftTo(1,r)):(e.subTo(r,e),e.rShiftTo(1,e));return o>0&&e.lShiftTo(o,e),e},e.prototype.isProbablePrime=function(t){var r,e=this.abs();if(1==e.t&&e[0]<=A[A.length-1]){for(r=0;r<A.length;++r)if(e[0]==A[r])return!0;return!1}if(e.isEven())return!1;for(r=1;r<A.length;){for(var i=A[r],n=r+1;n<A.length&&i<I;)i*=A[n++];for(i=e.modInt(i);r<n;)if(i%A[r++]==0)return!1}return e.millerRabin(t)},e.prototype.square=function(){var t=i();return this.squareTo(t),t},e.prototype.Barrett=B,null==x){var D;if(x=new Array,S=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var q=new Uint8Array(32);for(window.crypto.getRandomValues(q),D=0;D<32;++D)x[S++]=q[D]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var C=window.crypto.random(32);for(D=0;D<C.length;++D)x[S++]=255&C.charCodeAt(D)}for(;S<O;)D=Math.floor(65536*Math.random()),x[S++]=D>>>8,x[S++]=255&D;S=0,E()}function P(){if(null==b){for(E(),(b=new M).init(x),S=0;S<x.length;++S)x[S]=0;S=0}return b.next()}function R(){}function M(){this.i=0,this.j=0,this.S=new Array}R.prototype.nextBytes=function(t){var r;for(r=0;r<t.length;++r)t[r]=P()},M.prototype.init=function(t){var r,e,i;for(r=0;r<256;++r)this.S[r]=r;for(e=0,r=0;r<256;++r)e=e+this.S[r]+t[r%t.length]&255,i=this.S[r],this.S[r]=this.S[e],this.S[e]=i;this.i=0,this.j=0},M.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var O=256;t.exports={default:e,BigInteger:e,SecureRandom:R}}).call(this)},664:(t,r,e)=>{t.exports={sm2:e(251),sm3:e(748),sm4:e(810)}},563:(t,r,e)=>{const{BigInteger:i}=e(77);class n{constructor(){this.tlv=null,this.t="00",this.l="00",this.v=""}getEncodedHex(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv}getLength(){const t=this.v.length/2;let r=t.toString(16);return r.length%2==1&&(r="0"+r),t<128?r:(128+r.length/2).toString(16)+r}getValue(){return""}}class o extends n{constructor(t){super(),this.t="02",t&&(this.v=function(t){let r=t.toString(16);if("-"!==r[0])r.length%2==1?r="0"+r:r.match(/^[0-7]/)||(r="00"+r);else{r=r.substr(1);let e=r.length;e%2==1?e+=1:r.match(/^[0-7]/)||(e+=2);let n="";for(let t=0;t<e;t++)n+="f";n=new i(n,16),r=n.xor(t).add(i.ONE),r=r.toString(16).replace(/^-/,"")}return r}(t))}getValue(){return this.v}}class s extends n{constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map((t=>t.getEncodedHex())).join(""),this.v}}function h(t,r){return+t[r+2]<8?1:128&+t.substr(r+2,2)}function u(t,r){const e=h(t,r),n=t.substr(r+2,2*e);return n?(+n[0]<8?new i(n,16):new i(n.substr(2),16)).intValue():-1}function a(t,r){return r+2*(h(t,r)+1)}t.exports={encodeDer(t,r){const e=new o(t),i=new o(r);return new s([e,i]).getEncodedHex()},decodeDer(t){const r=a(t,0),e=a(t,r),n=u(t,r),o=t.substr(e,2*n),s=e+o.length,h=a(t,s),f=u(t,s),c=t.substr(h,2*f);return{r:new i(o,16),s:new i(c,16)}}}},13:(t,r,e)=>{const{BigInteger:i}=e(77),n=new i("2"),o=new i("3");class s{constructor(t,r){this.x=r,this.q=t}equals(t){return t===this||this.q.equals(t.q)&&this.x.equals(t.x)}toBigInteger(){return this.x}negate(){return new s(this.q,this.x.negate().mod(this.q))}add(t){return new s(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new s(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new s(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new s(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new s(this.q,this.x.square().mod(this.q))}}class h{constructor(t,r,e,n){this.curve=t,this.x=r,this.y=e,this.z=null==n?i.ONE:n,this.zinv=null}getX(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}getY(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}equals(t){return t===this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(i.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(i.ZERO))}isInfinity(){return null===this.x&&null===this.y||this.z.equals(i.ZERO)&&!this.y.toBigInteger().equals(i.ZERO)}negate(){return new h(this.curve,this.x,this.y.negate(),this.z)}add(t){if(this.isInfinity())return t;if(t.isInfinity())return this;const r=this.x.toBigInteger(),e=this.y.toBigInteger(),n=this.z,o=t.x.toBigInteger(),s=t.y.toBigInteger(),u=t.z,a=this.curve.q,f=r.multiply(u).mod(a),c=o.multiply(n).mod(a),l=f.subtract(c),p=e.multiply(u).mod(a),g=s.multiply(n).mod(a),y=p.subtract(g);if(i.ZERO.equals(l))return i.ZERO.equals(y)?this.twice():this.curve.infinity;const d=f.add(c),m=n.multiply(u).mod(a),v=l.square().mod(a),T=l.multiply(v).mod(a),F=m.multiply(y.square()).subtract(d.multiply(v)).mod(a),w=l.multiply(F).mod(a),B=y.multiply(v.multiply(f).subtract(F)).subtract(p.multiply(T)).mod(a),b=T.multiply(m).mod(a);return new h(this.curve,this.curve.fromBigInteger(w),this.curve.fromBigInteger(B),b)}twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;const t=this.x.toBigInteger(),r=this.y.toBigInteger(),e=this.z,i=this.curve.q,n=this.curve.a.toBigInteger(),s=t.square().multiply(o).add(n.multiply(e.square())).mod(i),u=r.shiftLeft(1).multiply(e).mod(i),a=r.square().mod(i),f=a.multiply(t).multiply(e).mod(i),c=u.square().mod(i),l=s.square().subtract(f.shiftLeft(3)).mod(i),p=u.multiply(l).mod(i),g=s.multiply(f.shiftLeft(2).subtract(l)).subtract(c.shiftLeft(1).multiply(a)).mod(i),y=u.multiply(c).mod(i);return new h(this.curve,this.curve.fromBigInteger(p),this.curve.fromBigInteger(g),y)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const r=t.multiply(o),e=this.negate();let i=this;for(let n=r.bitLength()-2;n>0;n--){i=i.twice();const o=r.testBit(n);o!==t.testBit(n)&&(i=i.add(o?this:e))}return i}}t.exports={ECPointFp:h,ECCurveFp:class{constructor(t,r,e){this.q=t,this.a=this.fromBigInteger(r),this.b=this.fromBigInteger(e),this.infinity=new h(this,null,null)}equals(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)}fromBigInteger(t){return new s(this.q,t)}decodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:const r=this.fromBigInteger(new i(t.substr(2),16));let e=this.fromBigInteger(r.multiply(r.square()).add(r.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new i("4")).add(i.ONE),this.q));return e.toBigInteger().mod(n).equals(new i(t.substr(0,2),16).subtract(n))||(e=e.negate()),new h(this,r,e);case 4:case 6:case 7:const o=(t.length-2)/2,s=t.substr(2,o),u=t.substr(o+2,o);return new h(this,this.fromBigInteger(new i(s,16)),this.fromBigInteger(new i(u,16)));default:return null}}}}},251:(t,r,e)=>{const{BigInteger:i}=e(77),{encodeDer:n,decodeDer:o}=e(563),s=e(694),h=e(570).sm3,{G:u,curve:a,n:f}=s.generateEcparam();function c(t,r,e="1234567812345678"){e=s.utf8ToHex(e);const i=s.leftPad(u.curve.a.toBigInteger().toRadix(16),64),n=s.leftPad(u.curve.b.toBigInteger().toRadix(16),64),o=s.leftPad(u.getX().toBigInteger().toRadix(16),64),a=s.leftPad(u.getY().toBigInteger().toRadix(16),64);let f,c;if(128===r.length)f=r.substr(0,64),c=r.substr(64,64);else{const t=u.curve.decodePointHex(r);f=s.leftPad(t.getX().toBigInteger().toRadix(16),64),c=s.leftPad(t.getY().toBigInteger().toRadix(16),64)}const l=s.hexToArray(e+i+n+o+a+f+c),p=4*e.length;l.unshift(255&p),l.unshift(p>>8&255);const g=h(l);return s.arrayToHex(h(g.concat(s.hexToArray(t))))}function l(){const t=s.generateKeyPairHex(),r=a.decodePointHex(t.publicKey);return t.k=new i(t.privateKey,16),t.x1=r.getX().toBigInteger(),t}t.exports={generateKeyPairHex:s.generateKeyPairHex,compressPublicKeyHex:s.compressPublicKeyHex,comparePublicKeyHex:s.comparePublicKeyHex,doEncrypt:function(t,r,e=1){t="string"==typeof t?s.hexToArray(s.utf8ToHex(t)):Array.prototype.slice.call(t),r=s.getGlobalCurve().decodePointHex(r);const n=s.generateKeyPairHex(),o=new i(n.privateKey,16);let u=n.publicKey;u.length>128&&(u=u.substr(u.length-128));const a=r.multiply(o),f=s.hexToArray(s.leftPad(a.getX().toBigInteger().toRadix(16),64)),c=s.hexToArray(s.leftPad(a.getY().toBigInteger().toRadix(16),64)),l=s.arrayToHex(h([].concat(f,t,c)));let p=1,g=0,y=[];const d=[].concat(f,c),m=()=>{y=h([...d,p>>24&255,p>>16&255,p>>8&255,255&p]),p++,g=0};m();for(let r=0,e=t.length;r<e;r++)g===y.length&&m(),t[r]^=255&y[g++];const v=s.arrayToHex(t);return 0===e?u+v+l:u+l+v},doDecrypt:function(t,r,e=1,{output:n="string"}={}){r=new i(r,16);let o=t.substr(128,64),u=t.substr(192);0===e&&(o=t.substr(t.length-64),u=t.substr(128,t.length-128-64));const a=s.hexToArray(u),f=s.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(r),c=s.hexToArray(s.leftPad(f.getX().toBigInteger().toRadix(16),64)),l=s.hexToArray(s.leftPad(f.getY().toBigInteger().toRadix(16),64));let p=1,g=0,y=[];const d=[].concat(c,l),m=()=>{y=h([...d,p>>24&255,p>>16&255,p>>8&255,255&p]),p++,g=0};m();for(let t=0,r=a.length;t<r;t++)g===y.length&&m(),a[t]^=255&y[g++];return s.arrayToHex(h([].concat(c,a,l)))===o.toLowerCase()?"array"===n?a:s.arrayToUtf8(a):"array"===n?[]:""},doSignature:function(t,r,{pointPool:e,der:o,hash:h,publicKey:a,userId:p}={}){let g="string"==typeof t?s.utf8ToHex(t):s.arrayToHex(t);h&&(a=a||function(t){const r=u.multiply(new i(t,16));return"04"+s.leftPad(r.getX().toBigInteger().toString(16),64)+s.leftPad(r.getY().toBigInteger().toString(16),64)}(r),g=c(g,a,p));const y=new i(r,16),d=new i(g,16);let m=null,v=null,T=null;do{do{let t;t=e&&e.length?e.pop():l(),m=t.k,v=d.add(t.x1).mod(f)}while(v.equals(i.ZERO)||v.add(m).equals(f));T=y.add(i.ONE).modInverse(f).multiply(m.subtract(v.multiply(y))).mod(f)}while(T.equals(i.ZERO));return o?n(v,T):s.leftPad(v.toString(16),64)+s.leftPad(T.toString(16),64)},doVerifySignature:function(t,r,e,{der:n,hash:h,userId:l}={}){let p,g,y="string"==typeof t?s.utf8ToHex(t):s.arrayToHex(t);if(h&&(y=c(y,e,l)),n){const t=o(r);p=t.r,g=t.s}else p=new i(r.substring(0,64),16),g=new i(r.substring(64),16);const d=a.decodePointHex(e),m=new i(y,16),v=p.add(g).mod(f);if(v.equals(i.ZERO))return!1;const T=u.multiply(g).add(d.multiply(v)),F=m.add(T.getX().toBigInteger()).mod(f);return p.equals(F)},getPoint:l,verifyPublicKey:s.verifyPublicKey}},570:t=>{const r=new Uint32Array(68),e=new Uint32Array(64);function i(t,r){const e=31&r;return t<<e|t>>>32-e}function n(t,r){const e=[];for(let i=t.length-1;i>=0;i--)e[i]=255&(t[i]^r[i]);return e}function o(t){return t^i(t,9)^i(t,17)}function s(t){let n=8*t.length,s=n%512;s=s>=448?512-s%448-1:448-s-1;const h=new Array((s-7)/8),u=new Array(8);for(let t=0,r=h.length;t<r;t++)h[t]=0;for(let t=0,r=u.length;t<r;t++)u[t]=0;n=n.toString(2);for(let t=7;t>=0;t--)if(n.length>8){const r=n.length-8;u[t]=parseInt(n.substr(r),2),n=n.substr(0,r)}else n.length>0&&(u[t]=parseInt(n,2),n="");const a=new Uint8Array([...t,128,...h,...u]),f=new DataView(a.buffer,0),c=a.length/64,l=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<c;t++){r.fill(0),e.fill(0);const n=16*t;for(let t=0;t<16;t++)r[t]=f.getUint32(4*(n+t),!1);for(let t=16;t<68;t++)r[t]=(p=r[t-16]^r[t-9]^i(r[t-3],15))^i(p,15)^i(p,23)^i(r[t-13],7)^r[t-6];for(let t=0;t<64;t++)e[t]=r[t]^r[t+4];const s=2043430169,h=2055708042;let u,a,c,g,y,d=l[0],m=l[1],v=l[2],T=l[3],F=l[4],w=l[5],B=l[6],b=l[7];for(let t=0;t<64;t++)y=t>=0&&t<=15?s:h,u=i(i(d,12)+F+i(y,t),7),a=u^i(d,12),c=(t>=0&&t<=15?d^m^v:d&m|d&v|m&v)+T+a+e[t],g=(t>=0&&t<=15?F^w^B:F&w|~F&B)+b+u+r[t],T=v,v=i(m,9),m=d,d=c,b=B,B=i(w,19),w=F,F=o(g);l[0]^=d,l[1]^=m,l[2]^=v,l[3]^=T,l[4]^=F,l[5]^=w,l[6]^=B,l[7]^=b}var p;const g=[];for(let t=0,r=l.length;t<r;t++){const r=l[t];g.push((4278190080&r)>>>24,(16711680&r)>>>16,(65280&r)>>>8,255&r)}return g}const h=new Uint8Array(64),u=new Uint8Array(64);for(let t=0;t<64;t++)h[t]=54,u[t]=92;t.exports={sm3:s,hmac:function(t,r){for(r.length>64&&(r=s(r));r.length<64;)r.push(0);const e=n(r,h),i=n(r,u),o=s([...e,...t]);return s([...i,...o])}}},694:(t,r,e)=>{const{BigInteger:i,SecureRandom:n}=e(77),{ECCurveFp:o}=e(13),s=new n,{curve:h,G:u,n:a}=f();function f(){const t=new i("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),r=new i("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),e=new i("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),n=new o(t,r,e),s=n.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:n,G:s,n:new i("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function c(t,r){return t.length>=r?t:new Array(r-t.length+1).join("0")+t}t.exports={getGlobalCurve:function(){return h},generateEcparam:f,generateKeyPairHex:function(t,r,e){const n=(t?new i(t,r,e):new i(a.bitLength(),s)).mod(a.subtract(i.ONE)).add(i.ONE),o=c(n.toString(16),64),h=u.multiply(n);return{privateKey:o,publicKey:"04"+c(h.getX().toBigInteger().toString(16),64)+c(h.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");const r=(t.length-2)/2,e=t.substr(2,r);let n="03";return new i(t.substr(r+2,r),16).mod(new i("2")).equals(i.ZERO)&&(n="02"),n+e},utf8ToHex:function(t){const r=(t=unescape(encodeURIComponent(t))).length,e=[];for(let i=0;i<r;i++)e[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;const i=[];for(let t=0;t<r;t++){const r=e[t>>>2]>>>24-t%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},leftPad:c,arrayToHex:function(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")},arrayToUtf8:function(t){const r=[];let e=0;for(let i=0;i<2*t.length;i+=2)r[i>>>3]|=parseInt(t[e],10)<<24-i%8*4,e++;try{const e=[];for(let i=0;i<t.length;i++){const t=r[i>>>2]>>>24-i%4*8&255;e.push(String.fromCharCode(t))}return decodeURIComponent(escape(e.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){const r=[];let e=t.length;e%2!=0&&(t=c(t,e+1)),e=t.length;for(let i=0;i<e;i+=2)r.push(parseInt(t.substr(i,2),16));return r},verifyPublicKey:function(t){const r=h.decodePointHex(t);if(!r)return!1;const e=r.getX();return r.getY().square().equals(e.multiply(e.square()).add(e.multiply(h.a)).add(h.b))},comparePublicKeyHex:function(t,r){const e=h.decodePointHex(t);if(!e)return!1;const i=h.decodePointHex(r);return!!i&&e.equals(i)}}},748:(t,r,e)=>{const{sm3:i,hmac:n}=e(570);function o(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")}t.exports=function(t,r){if(t="string"==typeof t?function(t){const r=[];for(let e=0,i=t.length;e<i;e++){const i=t.codePointAt(e);if(i<=127)r.push(i);else if(i<=2047)r.push(192|i>>>6),r.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)r.push(224|i>>>12),r.push(128|i>>>6&63),r.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw r.push(i),new Error("input is not supported");e++,r.push(240|i>>>18&28),r.push(128|i>>>12&63),r.push(128|i>>>6&63),r.push(128|63&i)}}return r}(t):Array.prototype.slice.call(t),r){if("hmac"!==(r.mode||"hmac"))throw new Error("invalid mode");let e=r.key;if(!e)throw new Error("invalid key");return e="string"==typeof e?function(t){const r=[];let e=t.length;var i,n;e%2!=0&&(n=e+1,t=(i=t).length>=n?i:new Array(n-i.length+1).join("0")+i),e=t.length;for(let i=0;i<e;i+=2)r.push(parseInt(t.substr(i,2),16));return r}(e):Array.prototype.slice.call(e),o(n(t,e))}return o(i(t))}},810:t=>{const r=16,e=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],i=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function n(t){const r=[];for(let e=0,i=t.length;e<i;e+=2)r.push(parseInt(t.substr(e,2),16));return r}function o(t,r){return t<<r|t>>>32-r}function s(t){return(255&e[t>>>24&255])<<24|(255&e[t>>>16&255])<<16|(255&e[t>>>8&255])<<8|255&e[255&t]}function h(t){return t^o(t,2)^o(t,10)^o(t,18)^o(t,24)}function u(t){return t^o(t,13)^o(t,23)}function a(t,r,e){const i=new Array(4),n=new Array(4);for(let r=0;r<4;r++)n[0]=255&t[4*r],n[1]=255&t[4*r+1],n[2]=255&t[4*r+2],n[3]=255&t[4*r+3],i[r]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];for(let t,r=0;r<32;r+=4)t=i[1]^i[2]^i[3]^e[r+0],i[0]^=h(s(t)),t=i[2]^i[3]^i[0]^e[r+1],i[1]^=h(s(t)),t=i[3]^i[0]^i[1]^e[r+2],i[2]^=h(s(t)),t=i[0]^i[1]^i[2]^e[r+3],i[3]^=h(s(t));for(let t=0;t<16;t+=4)r[t]=i[3-t/4]>>>24&255,r[t+1]=i[3-t/4]>>>16&255,r[t+2]=i[3-t/4]>>>8&255,r[t+3]=255&i[3-t/4]}function f(t,e,o,{padding:h="pkcs#7",mode:f,iv:c=[],output:l="string"}={}){if("cbc"===f&&("string"==typeof c&&(c=n(c)),16!==c.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=n(e)),16!==e.length)throw new Error("key is invalid");if(t="string"==typeof t?0!==o?function(t){const r=[];for(let e=0,i=t.length;e<i;e++){const i=t.codePointAt(e);if(i<=127)r.push(i);else if(i<=2047)r.push(192|i>>>6),r.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)r.push(224|i>>>12),r.push(128|i>>>6&63),r.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw r.push(i),new Error("input is not supported");e++,r.push(240|i>>>18&28),r.push(128|i>>>12&63),r.push(128|i>>>6&63),r.push(128|63&i)}}return r}(t):n(t):[...t],("pkcs#5"===h||"pkcs#7"===h)&&0!==o){const e=r-t.length%r;for(let r=0;r<e;r++)t.push(e)}const p=new Array(32);!function(t,r,e){const n=new Array(4),o=new Array(4);for(let r=0;r<4;r++)o[0]=255&t[0+4*r],o[1]=255&t[1+4*r],o[2]=255&t[2+4*r],o[3]=255&t[3+4*r],n[r]=o[0]<<24|o[1]<<16|o[2]<<8|o[3];n[0]^=2746333894,n[1]^=1453994832,n[2]^=1736282519,n[3]^=2993693404;for(let t,e=0;e<32;e+=4)t=n[1]^n[2]^n[3]^i[e+0],r[e+0]=n[0]^=u(s(t)),t=n[2]^n[3]^n[0]^i[e+1],r[e+1]=n[1]^=u(s(t)),t=n[3]^n[0]^n[1]^i[e+2],r[e+2]=n[2]^=u(s(t)),t=n[0]^n[1]^n[2]^i[e+3],r[e+3]=n[3]^=u(s(t));if(0===e)for(let t,e=0;e<16;e++)t=r[e],r[e]=r[31-e],r[31-e]=t}(e,p,o);const g=[];let y=c,d=t.length,m=0;for(;d>=r;){const e=t.slice(m,m+16),i=new Array(16);if("cbc"===f)for(let t=0;t<r;t++)0!==o&&(e[t]^=y[t]);a(e,i,p);for(let t=0;t<r;t++)"cbc"===f&&0===o&&(i[t]^=y[t]),g[m+t]=i[t];"cbc"===f&&(y=0!==o?i:e),d-=r,m+=r}if(("pkcs#5"===h||"pkcs#7"===h)&&0===o){const t=g.length,r=g[t-1];for(let e=1;e<=r;e++)if(g[t-e]!==r)throw new Error("padding is invalid");g.splice(t-r,r)}return"array"!==l?0!==o?g.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join(""):function(t){const r=[];for(let e=0,i=t.length;e<i;e++)t[e]>=240&&t[e]<=247?(r.push(String.fromCodePoint(((7&t[e])<<18)+((63&t[e+1])<<12)+((63&t[e+2])<<6)+(63&t[e+3]))),e+=3):t[e]>=224&&t[e]<=239?(r.push(String.fromCodePoint(((15&t[e])<<12)+((63&t[e+1])<<6)+(63&t[e+2]))),e+=2):t[e]>=192&&t[e]<=223?(r.push(String.fromCodePoint(((31&t[e])<<6)+(63&t[e+1]))),e++):r.push(String.fromCodePoint(t[e]));return r.join("")}(g):g}t.exports={encrypt:(t,r,e)=>f(t,r,1,e),decrypt:(t,r,e)=>f(t,r,0,e)}},751:t=>{var r={};!function(){function t(){this.mode=0,this.sk=[]}function e(t,r,e){return r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}function i(t,r,e){r[e]=t>>>24,r[e+1]=t>>>16,r[e+2]=t>>>8,r[e+3]=t}function n(t,r){return(4294967295&t)<<r|t>>>32-r}var o=[[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5],[43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153],[156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98],[228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166],[71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168],[104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53],[30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135],[212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158],[234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161],[224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227],[29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111],[213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81],[141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216],[10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176],[137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132],[24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72]],s=[2746333894,1453994832,1736282519,2993693404],h=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function u(t){return o[t>>>4][t%16]}function a(t,r){var o,a,f,c,l=new Array(4),p=new Array(36),g=0;for(l[0]=e(l[0],r,0),l[1]=e(l[1],r,4),l[2]=e(l[2],r,8),l[3]=e(l[3],r,12),p[0]=l[0]^s[0],p[1]=l[1]^s[1],p[2]=l[2]^s[2],p[3]=l[3]^s[3];g<32;g++)p[g+4]=p[g]^(o=p[g+1]^p[g+2]^p[g+3]^h[g],void 0,void 0,c=void 0,0,f=new Uint8Array(4),c=new Array(4),i(o,f,0),c[0]=u(f[0]),c[1]=u(f[1]),c[2]=u(f[2]),c[3]=u(f[3]),(a=e(0,c,0))^n(a,13)^n(a,23)),t[g]=p[g+4]}function f(t,r,o){var s,h,a,f,c,l,p,g,y,d=0,m=new Array(36);for(m[0]=e(m[0],r,0),m[1]=e(m[1],r,4),m[2]=e(m[2],r,8),m[3]=e(m[3],r,12);d<32;)m[d+4]=(s=m[d],h=m[d+1],a=m[d+2],f=m[d+3],c=t[d],l=void 0,p=void 0,g=void 0,y=void 0,s^(l=h^a^f^c,g=new Uint8Array(4),y=new Array(4),i(l,g,0),y[0]=u(g[0]),y[1]=u(g[1]),y[2]=u(g[2]),y[3]=u(g[3]),(p=e(0,y,0))^n(p,2)^n(p,10)^n(p,18)^n(p,24))),d++;i(m[35],o,0),i(m[34],o,4),i(m[33],o,8),i(m[32],o,12)}function c(t,r){for(var e=r-t.length;e-- >0;)t="0"+t;return t}function l(t,r){for(var e=p(t),i=p(r),n="",o=0;o<16;o++)n+=c((e[o]^i[o]).toString(16).toUpperCase(),2);return n}function p(t){for(var r=t.length/2,e="",i=new Array(r),n=0;n<r;n++)e=t.slice(2*n,2*(n+1)),i[n]=parseInt(e,16)||0;return i}r.SM4CryptECB=function(r,e,i){if(32!==i.length)return console.log("传入密钥["+i+"]长度不为32位"),"";var n=r.length,o=n%32;if(0!==o)for(n+=o=32-o;o--;)r+="0";var s=new t,h=p(i);1===e?function(t,r){t.mode=1,a(t.sk,r)}(s,h):function(t,r){var e,i;for(t.mode=1,a(t.sk,r),e=0;e<16;e++)i=t.sk[31-e],t.sk[31-e]=t.sk[e],t.sk[e]=i}(s,h);var u=p(r),l=new Array(n/2);!function(t,r,e,i,n){for(var o=0;e>0;){var s=i.slice(o,o+16),h=new Uint8Array(16);f(t.sk,s,h);for(var u=0;u<16;u++)n[o+u]=h[u];o+=16,e-=16}}(s,0,n/2,u,l);for(var g="",y=0;y<n/2;y++)g+=c(l[y].toString(16),2).toUpperCase();return g},r.SM4MACGenerated=function(t,e){if(32!==e.length)return console.log("传入密钥["+e+"]长度不为32位"),"";var i=t.length,n=Math.floor(i/32);if(i%32!=0){for(var o=32*(n+=1)-i;o--;)t+="0";i=32*n}for(var s="",h="",u=0;u<n;u++)h=t.slice(32*u,32*(u+1)),u>0&&(h=l(h,s)),s=r.SM4CryptECB(h,1,e);return s}}();try{t.exports=r}catch(t){}}},r={},function e(i){var n=r[i];if(void 0!==n)return n.exports;var o=r[i]={exports:{}};return t[i].call(o.exports,o,o.exports,e),o.exports}(10);var t,r}));
//# sourceMappingURL=gmhelper.js.map