2 lines
40 KiB
JavaScript
2 lines
40 KiB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.gmhelper=e():t.gmhelper=e()}("undefined"!=typeof self?self:this,(function(){return t={10:(t,e,r)=>{const i=r(694),{G:o,curve:n,n:s}=i.generateEcparam(),h=r(664).sm3,u=r(742);function a(t){for(var e="",r=0;r<t.length;r++){var i=t.charCodeAt(r).toString(16);i.length<2&&(i="0"+i),e+=i}return e}function f(t,e,r="1234567812345678"){r=i.utf8ToHex(r);const n=i.leftPad(o.curve.a.toBigInteger().toRadix(16),64),s=i.leftPad(o.curve.b.toBigInteger().toRadix(16),64),u=i.leftPad(o.getX().toBigInteger().toRadix(16),64),f=i.leftPad(o.getY().toBigInteger().toRadix(16),64);let l,c;if(128===e.length)l=e.substr(0,64),c=e.substr(64,64);else{const t=o.curve.decodePointHex(e);l=i.leftPad(t.getX().toBigInteger().toRadix(16),64),c=i.leftPad(t.getY().toBigInteger().toRadix(16),64)}const p=i.hexToArray(r+n+s+u+f+l+c),g=4*r.length;p.unshift(255&g),p.unshift(g>>8&255);const d=h(p);return{z:d,hex:h(i.hexToArray(d+a(t)))}}function l(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 e="",r=0;r<t.length;r++){var i=t[r];e+=1===(i=i.toString(16)).length?"0"+i:i}return e}(u.toByteArray(t))).substr(t.indexOf("03420004")+8)}t.exports={base64PkToHexPk:l,getHash:f,getHashAsBase64:function(t,e){var r=f(t,l(e));return{z:r.z,hashHex:r.hex,hashBase64:u.fromByteArray(i.hexToArray(r.hex))}}}},742:(t,e)=>{"use strict";e.byteLength=function(t){var e=u(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){var e,r,n=u(t),s=n[0],h=n[1],a=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,h)),f=0,l=h>0?s-4:s;for(r=0;r<l;r+=4)e=i[t.charCodeAt(r)]<<18|i[t.charCodeAt(r+1)]<<12|i[t.charCodeAt(r+2)]<<6|i[t.charCodeAt(r+3)],a[f++]=e>>16&255,a[f++]=e>>8&255,a[f++]=255&e;return 2===h&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,a[f++]=255&e),1===h&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,a[f++]=e>>8&255,a[f++]=255&e),a},e.fromByteArray=function(t){for(var e,i=t.length,o=i%3,n=[],s=16383,h=0,u=i-o;h<u;h+=s)n.push(a(t,h,h+s>u?u:h+s));return 1===o?(e=t[i-1],n.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[i-2]<<8)+t[i-1],n.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),n.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,h=n.length;s<h;++s)r[s]=n[s],i[n.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function a(t,e,i){for(var o,n,s=[],h=e;h<i;h+=3)o=(t[h]<<16&16711680)+(t[h+1]<<8&65280)+(255&t[h+2]),s.push(r[(n=o)>>18&63]+r[n>>12&63]+r[n>>6&63]+r[63&n]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},77:function(t,e){(function(){var e;function r(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function i(){return new r(null)}var o="undefined"!=typeof navigator;o&&"Microsoft Internet Explorer"==navigator.appName?(r.prototype.am=function(t,e,r,i,o,n){for(var s=32767&e,h=e>>15;--n>=0;){var u=32767&this[t],a=this[t++]>>15,f=h*u+a*s;o=((u=s*u+((32767&f)<<15)+r[i]+(1073741823&o))>>>30)+(f>>>15)+h*a+(o>>>30),r[i++]=1073741823&u}return o},e=30):o&&"Netscape"!=navigator.appName?(r.prototype.am=function(t,e,r,i,o,n){for(;--n>=0;){var s=e*this[t++]+r[i]+o;o=Math.floor(s/67108864),r[i++]=67108863&s}return o},e=26):(r.prototype.am=function(t,e,r,i,o,n){for(var s=16383&e,h=e>>14;--n>=0;){var u=16383&this[t],a=this[t++]>>14,f=h*u+a*s;o=((u=s*u+((16383&f)<<14)+r[i]+o)>>28)+(f>>14)+h*a,r[i++]=268435455&u}return o},e=28),r.prototype.DB=e,r.prototype.DM=(1<<e)-1,r.prototype.DV=1<<e,r.prototype.FV=Math.pow(2,52),r.prototype.F1=52-e,r.prototype.F2=2*e-52;var n,s,h=new Array;for(n="0".charCodeAt(0),s=0;s<=9;++s)h[n++]=s;for(n="a".charCodeAt(0),s=10;s<36;++s)h[n++]=s;for(n="A".charCodeAt(0),s=10;s<36;++s)h[n++]=s;function u(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function a(t,e){var r=h[t.charCodeAt(e)];return null==r?-1:r}function f(t){var e=i();return e.fromInt(t),e}function l(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function c(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,e){return t&e}function d(t,e){return t|e}function m(t,e){return t^e}function y(t,e){return t&~e}function v(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function T(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function F(){}function b(t){return t}function B(t){this.r2=i(),this.q3=i(),r.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}c.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},c.prototype.revert=function(t){return t},c.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},c.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},c.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=i();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(r.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=i();return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},r.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},r.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},r.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var o=t.length,n=!1,s=0;--o>=0;){var h=8==i?255&t[o]:a(t,o);h<0?"-"==t.charAt(o)&&(n=!0):(n=!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(),n&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},r.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},r.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},r.prototype.lShiftTo=function(t,e){var r,i=t%this.DB,o=this.DB-i,n=(1<<o)-1,s=Math.floor(t/this.DB),h=this.s<<i&this.DM;for(r=this.t-1;r>=0;--r)e[r+s+1]=this[r]>>o|h,h=(this[r]&n)<<i;for(r=s-1;r>=0;--r)e[r]=0;e[s]=h,e.t=this.t+s+1,e.s=this.s,e.clamp()},r.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,o=this.DB-i,n=(1<<i)-1;e[0]=this[r]>>i;for(var s=r+1;s<this.t;++s)e[s-r-1]|=(this[s]&n)<<o,e[s-r]=this[s]>>i;i>0&&(e[this.t-r-1]|=(this.s&n)<<o),e.t=this.t-r,e.clamp()}},r.prototype.subTo=function(t,e){for(var r=0,i=0,o=Math.min(t.t,this.t);r<o;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()},r.prototype.multiplyTo=function(t,e){var i=this.abs(),o=t.abs(),n=i.t;for(e.t=n+o.t;--n>=0;)e[n]=0;for(n=0;n<o.t;++n)e[n+i.t]=i.am(0,o[n],e,n,0,i.t);e.s=0,e.clamp(),this.s!=t.s&&r.ZERO.subTo(e,e)},r.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},r.prototype.divRemTo=function(t,e,o){var n=t.abs();if(!(n.t<=0)){var s=this.abs();if(s.t<n.t)return null!=e&&e.fromInt(0),void(null!=o&&this.copyTo(o));null==o&&(o=i());var h=i(),u=this.s,a=t.s,f=this.DB-l(n[n.t-1]);f>0?(n.lShiftTo(f,h),s.lShiftTo(f,o)):(n.copyTo(h),s.copyTo(o));var c=h.t,p=h[c-1];if(0!=p){var g=p*(1<<this.F1)+(c>1?h[c-2]>>this.F2:0),d=this.FV/g,m=(1<<this.F1)/g,y=1<<this.F2,v=o.t,T=v-c,F=null==e?i():e;for(h.dlShiftTo(T,F),o.compareTo(F)>=0&&(o[o.t++]=1,o.subTo(F,o)),r.ONE.dlShiftTo(c,F),F.subTo(h,h);h.t<c;)h[h.t++]=0;for(;--T>=0;){var b=o[--v]==p?this.DM:Math.floor(o[v]*d+(o[v-1]+y)*m);if((o[v]+=h.am(0,b,o,T,0,c))<b)for(h.dlShiftTo(T,F),o.subTo(F,o);o[v]<--b;)o.subTo(F,o)}null!=e&&(o.drShiftTo(c,e),u!=a&&r.ZERO.subTo(e,e)),o.t=c,o.clamp(),f>0&&o.rShiftTo(f,o),u<0&&r.ZERO.subTo(o,o)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},r.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},r.prototype.exp=function(t,e){if(t>4294967295||t<1)return r.ONE;var o=i(),n=i(),s=e.convert(this),h=l(t)-1;for(s.copyTo(o);--h>=0;)if(e.sqrTo(o,n),(t&1<<h)>0)e.mulTo(n,s,o);else{var u=o;o=n,n=u}return e.revert(o)},r.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<<e)-1,o=!1,n="",s=this.t,h=this.DB-s*this.DB%e;if(s-- >0)for(h<this.DB&&(r=this[s]>>h)>0&&(o=!0,n=u(r));s>=0;)h<e?(r=(this[s]&(1<<h)-1)<<e-h,r|=this[--s]>>(h+=this.DB-e)):(r=this[s]>>(h-=e)&i,h<=0&&(h+=this.DB,--s)),r>0&&(o=!0),o&&(n+=u(r));return o?n:"0"},r.prototype.negate=function(){var t=i();return r.ZERO.subTo(this,t),t},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(t){var e=i();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(r.ZERO)>0&&t.subTo(e,e),e},r.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new c(e):new p(e),this.exp(t,r)},r.ZERO=f(0),r.ONE=f(1),F.prototype.convert=b,F.prototype.revert=b,F.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},F.prototype.sqrTo=function(t,e){t.squareTo(e)},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 e=i();return t.copyTo(e),this.reduce(e),e},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,e,r){t.multiplyTo(e,r),this.reduce(r)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var w,x,I,D=[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],A=(1<<26)/D[D.length-1];function E(){var t;t=(new Date).getTime(),x[I++]^=255&t,x[I++]^=t>>8&255,x[I++]^=t>>16&255,x[I++]^=t>>24&255,I>=M&&(I-=M)}if(r.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},r.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),o=f(r),n=i(),s=i(),h="";for(this.divRemTo(o,n,s);n.signum()>0;)h=(r+s.intValue()).toString(t).substr(1)+h,n.divRemTo(o,n,s);return s.intValue().toString(t)+h},r.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),o=Math.pow(e,i),n=!1,s=0,h=0,u=0;u<t.length;++u){var f=a(t,u);f<0?"-"==t.charAt(u)&&0==this.signum()&&(n=!0):(h=e*h+f,++s>=i&&(this.dMultiply(o),this.dAddOffset(h,0),s=0,h=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(h,0)),n&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(r.ONE.shiftLeft(t-1),d,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(r.ONE.shiftLeft(t-1),this);else{var o=new Array,n=7&t;o.length=1+(t>>3),e.nextBytes(o),n>0?o[0]&=(1<<n)-1:o[0]=0,this.fromString(o,256)}},r.prototype.bitwiseTo=function(t,e,r){var i,o,n=Math.min(t.t,this.t);for(i=0;i<n;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(o=t.s&this.DM,i=n;i<this.t;++i)r[i]=e(this[i],o);r.t=this.t}else{for(o=this.s&this.DM,i=n;i<t.t;++i)r[i]=e(o,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},r.prototype.changeBit=function(t,e){var i=r.ONE.shiftLeft(t);return this.bitwiseTo(i,e,i),i},r.prototype.addTo=function(t,e){for(var r=0,i=0,o=Math.min(t.t,this.t);r<o;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()},r.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},r.prototype.multiplyLowerTo=function(t,e,r){var i,o=Math.min(this.t+t.t,e);for(r.s=0,r.t=o;o>0;)r[--o]=0;for(i=r.t-this.t;o<i;++o)r[o+this.t]=this.am(0,t[o],r,o,0,this.t);for(i=Math.min(t.t,e);o<i;++o)this.am(0,t[o],r,o,0,e-o);r.clamp()},r.prototype.multiplyUpperTo=function(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)},r.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r},r.prototype.millerRabin=function(t){var e=this.subtract(r.ONE),o=e.getLowestSetBit();if(o<=0)return!1;var n=e.shiftRight(o);(t=t+1>>1)>D.length&&(t=D.length);for(var s=i(),h=0;h<t;++h){s.fromInt(D[Math.floor(Math.random()*D.length)]);var u=s.modPow(n,this);if(0!=u.compareTo(r.ONE)&&0!=u.compareTo(e)){for(var a=1;a++<o&&0!=u.compareTo(e);)if(0==(u=u.modPowInt(2,this)).compareTo(r.ONE))return!1;if(0!=u.compareTo(e))return!1}}return!0},r.prototype.clone=function(){var t=i();return this.copyTo(t),t},r.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]},r.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,i=this.DB-t*this.DB%8,o=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[o++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==o&&(128&this.s)!=(128&r)&&++o,(o>0||r!=this.s)&&(e[o++]=r);return e},r.prototype.equals=function(t){return 0==this.compareTo(t)},r.prototype.min=function(t){return this.compareTo(t)<0?this:t},r.prototype.max=function(t){return this.compareTo(t)>0?this:t},r.prototype.and=function(t){var e=i();return this.bitwiseTo(t,g,e),e},r.prototype.or=function(t){var e=i();return this.bitwiseTo(t,d,e),e},r.prototype.xor=function(t){var e=i();return this.bitwiseTo(t,m,e),e},r.prototype.andNot=function(t){var e=i();return this.bitwiseTo(t,y,e),e},r.prototype.not=function(){for(var t=i(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},r.prototype.shiftLeft=function(t){var e=i();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},r.prototype.shiftRight=function(t){var e=i();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},r.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},r.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=T(this[r]^e);return t},r.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},r.prototype.setBit=function(t){return this.changeBit(t,d)},r.prototype.clearBit=function(t){return this.changeBit(t,y)},r.prototype.flipBit=function(t){return this.changeBit(t,m)},r.prototype.add=function(t){var e=i();return this.addTo(t,e),e},r.prototype.subtract=function(t){var e=i();return this.subTo(t,e),e},r.prototype.multiply=function(t){var e=i();return this.multiplyTo(t,e),e},r.prototype.divide=function(t){var e=i();return this.divRemTo(t,e,null),e},r.prototype.remainder=function(t){var e=i();return this.divRemTo(t,null,e),e},r.prototype.divideAndRemainder=function(t){var e=i(),r=i();return this.divRemTo(t,e,r),new Array(e,r)},r.prototype.modPow=function(t,e){var r,o,n=t.bitLength(),s=f(1);if(n<=0)return s;r=n<18?1:n<48?3:n<144?4:n<768?5:6,o=n<8?new c(e):e.isEven()?new B(e):new p(e);var h=new Array,u=3,a=r-1,g=(1<<r)-1;if(h[1]=o.convert(this),r>1){var d=i();for(o.sqrTo(h[1],d);u<=g;)h[u]=i(),o.mulTo(d,h[u-2],h[u]),u+=2}var m,y,v=t.t-1,T=!0,F=i();for(n=l(t[v])-1;v>=0;){for(n>=a?m=t[v]>>n-a&g:(m=(t[v]&(1<<n+1)-1)<<a-n,v>0&&(m|=t[v-1]>>this.DB+n-a)),u=r;0==(1&m);)m>>=1,--u;if((n-=u)<0&&(n+=this.DB,--v),T)h[m].copyTo(s),T=!1;else{for(;u>1;)o.sqrTo(s,F),o.sqrTo(F,s),u-=2;u>0?o.sqrTo(s,F):(y=s,s=F,F=y),o.mulTo(F,h[m],s)}for(;v>=0&&0==(t[v]&1<<n);)o.sqrTo(s,F),y=s,s=F,F=y,--n<0&&(n=this.DB-1,--v)}return o.revert(s)},r.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return r.ZERO;for(var i=t.clone(),o=this.clone(),n=f(1),s=f(0),h=f(0),u=f(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(t,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;o.isEven();)o.rShiftTo(1,o),e?(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(o)>=0?(i.subTo(o,i),e&&n.subTo(h,n),s.subTo(u,s)):(o.subTo(i,o),e&&h.subTo(n,h),u.subTo(s,u))}return 0!=o.compareTo(r.ONE)?r.ZERO:u.compareTo(t)>=0?u.subtract(t):u.signum()<0?(u.addTo(t,u),u.signum()<0?u.add(t):u):u},r.prototype.pow=function(t){return this.exp(t,new F)},r.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var o=e.getLowestSetBit(),n=r.getLowestSetBit();if(n<0)return e;for(o<n&&(n=o),n>0&&(e.rShiftTo(n,e),r.rShiftTo(n,r));e.signum()>0;)(o=e.getLowestSetBit())>0&&e.rShiftTo(o,e),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return n>0&&r.lShiftTo(n,r),r},r.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=D[D.length-1]){for(e=0;e<D.length;++e)if(r[0]==D[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<D.length;){for(var i=D[e],o=e+1;o<D.length&&i<A;)i*=D[o++];for(i=r.modInt(i);e<o;)if(i%D[e++]==0)return!1}return r.millerRabin(t)},r.prototype.square=function(){var t=i();return this.squareTo(t),t},r.prototype.Barrett=B,null==x){var S;if(x=new Array,I=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var q=new Uint8Array(32);for(window.crypto.getRandomValues(q),S=0;S<32;++S)x[I++]=q[S]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var P=window.crypto.random(32);for(S=0;S<P.length;++S)x[I++]=255&P.charCodeAt(S)}for(;I<M;)S=Math.floor(65536*Math.random()),x[I++]=S>>>8,x[I++]=255&S;I=0,E()}function R(){if(null==w){for(E(),(w=new O).init(x),I=0;I<x.length;++I)x[I]=0;I=0}return w.next()}function C(){}function O(){this.i=0,this.j=0,this.S=new Array}C.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=R()},O.prototype.init=function(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0},O.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 M=256;t.exports={default:r,BigInteger:r,SecureRandom:C}}).call(this)},664:(t,e,r)=>{t.exports={sm2:r(251),sm3:r(748),sm4:r(810)}},563:(t,e,r)=>{const{BigInteger:i}=r(77);class o{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 e=t.toString(16);return e.length%2==1&&(e="0"+e),t<128?e:(128+e.length/2).toString(16)+e}getValue(){return""}}class n extends o{constructor(t){super(),this.t="02",t&&(this.v=function(t){let e=t.toString(16);if("-"!==e[0])e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{e=e.substr(1);let r=e.length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);let o="";for(let t=0;t<r;t++)o+="f";o=new i(o,16),e=o.xor(t).add(i.ONE),e=e.toString(16).replace(/^-/,"")}return e}(t))}getValue(){return this.v}}class s extends o{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,e){return+t[e+2]<8?1:128&+t.substr(e+2,2)}function u(t,e){const r=h(t,e),o=t.substr(e+2,2*r);return o?(+o[0]<8?new i(o,16):new i(o.substr(2),16)).intValue():-1}function a(t,e){return e+2*(h(t,e)+1)}t.exports={encodeDer(t,e){const r=new n(t),i=new n(e);return new s([r,i]).getEncodedHex()},decodeDer(t){const e=a(t,0),r=a(t,e),o=u(t,e),n=t.substr(r,2*o),s=r+n.length,h=a(t,s),f=u(t,s),l=t.substr(h,2*f);return{r:new i(n,16),s:new i(l,16)}}}},13:(t,e,r)=>{const{BigInteger:i}=r(77),o=new i("2"),n=new i("3");class s{constructor(t,e){this.x=e,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,e,r,o){this.curve=t,this.x=e,this.y=r,this.z=null==o?i.ONE:o,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 e=this.x.toBigInteger(),r=this.y.toBigInteger(),o=this.z,n=t.x.toBigInteger(),s=t.y.toBigInteger(),u=t.z,a=this.curve.q,f=e.multiply(u).mod(a),l=n.multiply(o).mod(a),c=f.subtract(l),p=r.multiply(u).mod(a),g=s.multiply(o).mod(a),d=p.subtract(g);if(i.ZERO.equals(c))return i.ZERO.equals(d)?this.twice():this.curve.infinity;const m=f.add(l),y=o.multiply(u).mod(a),v=c.square().mod(a),T=c.multiply(v).mod(a),F=y.multiply(d.square()).subtract(m.multiply(v)).mod(a),b=c.multiply(F).mod(a),B=d.multiply(v.multiply(f).subtract(F)).subtract(p.multiply(T)).mod(a),w=T.multiply(y).mod(a);return new h(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(B),w)}twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;const t=this.x.toBigInteger(),e=this.y.toBigInteger(),r=this.z,i=this.curve.q,o=this.curve.a.toBigInteger(),s=t.square().multiply(n).add(o.multiply(r.square())).mod(i),u=e.shiftLeft(1).multiply(r).mod(i),a=e.square().mod(i),f=a.multiply(t).multiply(r).mod(i),l=u.square().mod(i),c=s.square().subtract(f.shiftLeft(3)).mod(i),p=u.multiply(c).mod(i),g=s.multiply(f.shiftLeft(2).subtract(c)).subtract(l.shiftLeft(1).multiply(a)).mod(i),d=u.multiply(l).mod(i);return new h(this.curve,this.curve.fromBigInteger(p),this.curve.fromBigInteger(g),d)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const e=t.multiply(n),r=this.negate();let i=this;for(let o=e.bitLength()-2;o>0;o--){i=i.twice();const n=e.testBit(o);n!==t.testBit(o)&&(i=i.add(n?this:r))}return i}}t.exports={ECPointFp:h,ECCurveFp:class{constructor(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),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 e=this.fromBigInteger(new i(t.substr(2),16));let r=this.fromBigInteger(e.multiply(e.square()).add(e.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new i("4")).add(i.ONE),this.q));return r.toBigInteger().mod(o).equals(new i(t.substr(0,2),16).subtract(o))||(r=r.negate()),new h(this,e,r);case 4:case 6:case 7:const n=(t.length-2)/2,s=t.substr(2,n),u=t.substr(n+2,n);return new h(this,this.fromBigInteger(new i(s,16)),this.fromBigInteger(new i(u,16)));default:return null}}}}},251:(t,e,r)=>{const{BigInteger:i}=r(77),{encodeDer:o,decodeDer:n}=r(563),s=r(694),h=r(570).sm3,{G:u,curve:a,n:f}=s.generateEcparam();function l(t,e,r="1234567812345678"){r=s.utf8ToHex(r);const i=s.leftPad(u.curve.a.toBigInteger().toRadix(16),64),o=s.leftPad(u.curve.b.toBigInteger().toRadix(16),64),n=s.leftPad(u.getX().toBigInteger().toRadix(16),64),a=s.leftPad(u.getY().toBigInteger().toRadix(16),64);let f,l;if(128===e.length)f=e.substr(0,64),l=e.substr(64,64);else{const t=u.curve.decodePointHex(e);f=s.leftPad(t.getX().toBigInteger().toRadix(16),64),l=s.leftPad(t.getY().toBigInteger().toRadix(16),64)}const c=s.hexToArray(r+i+o+n+a+f+l),p=4*r.length;c.unshift(255&p),c.unshift(p>>8&255);const g=h(c);return s.arrayToHex(h(g.concat(s.hexToArray(t))))}function c(){const t=s.generateKeyPairHex(),e=a.decodePointHex(t.publicKey);return t.k=new i(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}t.exports={generateKeyPairHex:s.generateKeyPairHex,compressPublicKeyHex:s.compressPublicKeyHex,comparePublicKeyHex:s.comparePublicKeyHex,doEncrypt:function(t,e,r=1){t="string"==typeof t?s.hexToArray(s.utf8ToHex(t)):Array.prototype.slice.call(t),e=s.getGlobalCurve().decodePointHex(e);const o=s.generateKeyPairHex(),n=new i(o.privateKey,16);let u=o.publicKey;u.length>128&&(u=u.substr(u.length-128));const a=e.multiply(n),f=s.hexToArray(s.leftPad(a.getX().toBigInteger().toRadix(16),64)),l=s.hexToArray(s.leftPad(a.getY().toBigInteger().toRadix(16),64)),c=s.arrayToHex(h([].concat(f,t,l)));let p=1,g=0,d=[];const m=[].concat(f,l),y=()=>{d=h([...m,p>>24&255,p>>16&255,p>>8&255,255&p]),p++,g=0};y();for(let e=0,r=t.length;e<r;e++)g===d.length&&y(),t[e]^=255&d[g++];const v=s.arrayToHex(t);return 0===r?u+v+c:u+c+v},doDecrypt:function(t,e,r=1,{output:o="string"}={}){e=new i(e,16);let n=t.substr(128,64),u=t.substr(192);0===r&&(n=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(e),l=s.hexToArray(s.leftPad(f.getX().toBigInteger().toRadix(16),64)),c=s.hexToArray(s.leftPad(f.getY().toBigInteger().toRadix(16),64));let p=1,g=0,d=[];const m=[].concat(l,c),y=()=>{d=h([...m,p>>24&255,p>>16&255,p>>8&255,255&p]),p++,g=0};y();for(let t=0,e=a.length;t<e;t++)g===d.length&&y(),a[t]^=255&d[g++];return s.arrayToHex(h([].concat(l,a,c)))===n.toLowerCase()?"array"===o?a:s.arrayToUtf8(a):"array"===o?[]:""},doSignature:function(t,e,{pointPool:r,der:n,hash:h,publicKey:a,userId:p}={}){let g="string"==typeof t?s.utf8ToHex(t):s.arrayToHex(t);h&&(a=a||function(t){const e=u.multiply(new i(t,16));return"04"+s.leftPad(e.getX().toBigInteger().toString(16),64)+s.leftPad(e.getY().toBigInteger().toString(16),64)}(e),g=l(g,a,p));const d=new i(e,16),m=new i(g,16);let y=null,v=null,T=null;do{do{let t;t=r&&r.length?r.pop():c(),y=t.k,v=m.add(t.x1).mod(f)}while(v.equals(i.ZERO)||v.add(y).equals(f));T=d.add(i.ONE).modInverse(f).multiply(y.subtract(v.multiply(d))).mod(f)}while(T.equals(i.ZERO));return n?o(v,T):s.leftPad(v.toString(16),64)+s.leftPad(T.toString(16),64)},doVerifySignature:function(t,e,r,{der:o,hash:h,userId:c}={}){let p,g,d="string"==typeof t?s.utf8ToHex(t):s.arrayToHex(t);if(h&&(d=l(d,r,c)),o){const t=n(e);p=t.r,g=t.s}else p=new i(e.substring(0,64),16),g=new i(e.substring(64),16);const m=a.decodePointHex(r),y=new i(d,16),v=p.add(g).mod(f);if(v.equals(i.ZERO))return!1;const T=u.multiply(g).add(m.multiply(v)),F=y.add(T.getX().toBigInteger()).mod(f);return p.equals(F)},getPoint:c,verifyPublicKey:s.verifyPublicKey}},570:t=>{const e=new Uint32Array(68),r=new Uint32Array(64);function i(t,e){const r=31&e;return t<<r|t>>>32-r}function o(t,e){const r=[];for(let i=t.length-1;i>=0;i--)r[i]=255&(t[i]^e[i]);return r}function n(t){return t^i(t,9)^i(t,17)}function s(t){let o=8*t.length,s=o%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,e=h.length;t<e;t++)h[t]=0;for(let t=0,e=u.length;t<e;t++)u[t]=0;o=o.toString(2);for(let t=7;t>=0;t--)if(o.length>8){const e=o.length-8;u[t]=parseInt(o.substr(e),2),o=o.substr(0,e)}else o.length>0&&(u[t]=parseInt(o,2),o="");const a=new Uint8Array([...t,128,...h,...u]),f=new DataView(a.buffer,0),l=a.length/64,c=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<l;t++){e.fill(0),r.fill(0);const o=16*t;for(let t=0;t<16;t++)e[t]=f.getUint32(4*(o+t),!1);for(let t=16;t<68;t++)e[t]=(p=e[t-16]^e[t-9]^i(e[t-3],15))^i(p,15)^i(p,23)^i(e[t-13],7)^e[t-6];for(let t=0;t<64;t++)r[t]=e[t]^e[t+4];const s=2043430169,h=2055708042;let u,a,l,g,d,m=c[0],y=c[1],v=c[2],T=c[3],F=c[4],b=c[5],B=c[6],w=c[7];for(let t=0;t<64;t++)d=t>=0&&t<=15?s:h,u=i(i(m,12)+F+i(d,t),7),a=u^i(m,12),l=(t>=0&&t<=15?m^y^v:m&y|m&v|y&v)+T+a+r[t],g=(t>=0&&t<=15?F^b^B:F&b|~F&B)+w+u+e[t],T=v,v=i(y,9),y=m,m=l,w=B,B=i(b,19),b=F,F=n(g);c[0]^=m,c[1]^=y,c[2]^=v,c[3]^=T,c[4]^=F,c[5]^=b,c[6]^=B,c[7]^=w}var p;const g=[];for(let t=0,e=c.length;t<e;t++){const e=c[t];g.push((4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e)}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,e){for(e.length>64&&(e=s(e));e.length<64;)e.push(0);const r=o(e,h),i=o(e,u),n=s([...r,...t]);return s([...i,...n])}}},694:(t,e,r)=>{const{BigInteger:i,SecureRandom:o}=r(77),{ECCurveFp:n}=r(13),s=new o,{curve:h,G:u,n:a}=f();function f(){const t=new i("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),e=new i("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),r=new i("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),o=new n(t,e,r),s=o.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:o,G:s,n:new i("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function l(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t}t.exports={getGlobalCurve:function(){return h},generateEcparam:f,generateKeyPairHex:function(t,e,r){const o=(t?new i(t,e,r):new i(a.bitLength(),s)).mod(a.subtract(i.ONE)).add(i.ONE),n=l(o.toString(16),64),h=u.multiply(o);return{privateKey:n,publicKey:"04"+l(h.getX().toBigInteger().toString(16),64)+l(h.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");const e=(t.length-2)/2,r=t.substr(2,e);let o="03";return new i(t.substr(e+2,e),16).mod(new i("2")).equals(i.ZERO)&&(o="02"),o+r},utf8ToHex:function(t){const e=(t=unescape(encodeURIComponent(t))).length,r=[];for(let i=0;i<e;i++)r[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;const i=[];for(let t=0;t<e;t++){const e=r[t>>>2]>>>24-t%4*8&255;i.push((e>>>4).toString(16)),i.push((15&e).toString(16))}return i.join("")},leftPad:l,arrayToHex:function(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")},arrayToUtf8:function(t){const e=[];let r=0;for(let i=0;i<2*t.length;i+=2)e[i>>>3]|=parseInt(t[r],10)<<24-i%8*4,r++;try{const r=[];for(let i=0;i<t.length;i++){const t=e[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(t))}return decodeURIComponent(escape(r.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){const e=[];let r=t.length;r%2!=0&&(t=l(t,r+1)),r=t.length;for(let i=0;i<r;i+=2)e.push(parseInt(t.substr(i,2),16));return e},verifyPublicKey:function(t){const e=h.decodePointHex(t);if(!e)return!1;const r=e.getX();return e.getY().square().equals(r.multiply(r.square()).add(r.multiply(h.a)).add(h.b))},comparePublicKeyHex:function(t,e){const r=h.decodePointHex(t);if(!r)return!1;const i=h.decodePointHex(e);return!!i&&r.equals(i)}}},748:(t,e,r)=>{const{sm3:i,hmac:o}=r(570);function n(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")}t.exports=function(t,e){if(t="string"==typeof t?function(t){const e=[];for(let r=0,i=t.length;r<i;r++){const i=t.codePointAt(r);if(i<=127)e.push(i);else if(i<=2047)e.push(192|i>>>6),e.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)e.push(224|i>>>12),e.push(128|i>>>6&63),e.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw e.push(i),new Error("input is not supported");r++,e.push(240|i>>>18&28),e.push(128|i>>>12&63),e.push(128|i>>>6&63),e.push(128|63&i)}}return e}(t):Array.prototype.slice.call(t),e){if("hmac"!==(e.mode||"hmac"))throw new Error("invalid mode");let r=e.key;if(!r)throw new Error("invalid key");return r="string"==typeof r?function(t){const e=[];let r=t.length;var i,o;r%2!=0&&(o=r+1,t=(i=t).length>=o?i:new Array(o-i.length+1).join("0")+i),r=t.length;for(let i=0;i<r;i+=2)e.push(parseInt(t.substr(i,2),16));return e}(r):Array.prototype.slice.call(r),n(o(t,r))}return n(i(t))}},810:t=>{const e=16,r=[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 o(t){const e=[];for(let r=0,i=t.length;r<i;r+=2)e.push(parseInt(t.substr(r,2),16));return e}function n(t,e){return t<<e|t>>>32-e}function s(t){return(255&r[t>>>24&255])<<24|(255&r[t>>>16&255])<<16|(255&r[t>>>8&255])<<8|255&r[255&t]}function h(t){return t^n(t,2)^n(t,10)^n(t,18)^n(t,24)}function u(t){return t^n(t,13)^n(t,23)}function a(t,e,r){const i=new Array(4),o=new Array(4);for(let e=0;e<4;e++)o[0]=255&t[4*e],o[1]=255&t[4*e+1],o[2]=255&t[4*e+2],o[3]=255&t[4*e+3],i[e]=o[0]<<24|o[1]<<16|o[2]<<8|o[3];for(let t,e=0;e<32;e+=4)t=i[1]^i[2]^i[3]^r[e+0],i[0]^=h(s(t)),t=i[2]^i[3]^i[0]^r[e+1],i[1]^=h(s(t)),t=i[3]^i[0]^i[1]^r[e+2],i[2]^=h(s(t)),t=i[0]^i[1]^i[2]^r[e+3],i[3]^=h(s(t));for(let t=0;t<16;t+=4)e[t]=i[3-t/4]>>>24&255,e[t+1]=i[3-t/4]>>>16&255,e[t+2]=i[3-t/4]>>>8&255,e[t+3]=255&i[3-t/4]}function f(t,r,n,{padding:h="pkcs#7",mode:f,iv:l=[],output:c="string"}={}){if("cbc"===f&&("string"==typeof l&&(l=o(l)),16!==l.length))throw new Error("iv is invalid");if("string"==typeof r&&(r=o(r)),16!==r.length)throw new Error("key is invalid");if(t="string"==typeof t?0!==n?function(t){const e=[];for(let r=0,i=t.length;r<i;r++){const i=t.codePointAt(r);if(i<=127)e.push(i);else if(i<=2047)e.push(192|i>>>6),e.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)e.push(224|i>>>12),e.push(128|i>>>6&63),e.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw e.push(i),new Error("input is not supported");r++,e.push(240|i>>>18&28),e.push(128|i>>>12&63),e.push(128|i>>>6&63),e.push(128|63&i)}}return e}(t):o(t):[...t],("pkcs#5"===h||"pkcs#7"===h)&&0!==n){const r=e-t.length%e;for(let e=0;e<r;e++)t.push(r)}const p=new Array(32);!function(t,e,r){const o=new Array(4),n=new Array(4);for(let e=0;e<4;e++)n[0]=255&t[0+4*e],n[1]=255&t[1+4*e],n[2]=255&t[2+4*e],n[3]=255&t[3+4*e],o[e]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];o[0]^=2746333894,o[1]^=1453994832,o[2]^=1736282519,o[3]^=2993693404;for(let t,r=0;r<32;r+=4)t=o[1]^o[2]^o[3]^i[r+0],e[r+0]=o[0]^=u(s(t)),t=o[2]^o[3]^o[0]^i[r+1],e[r+1]=o[1]^=u(s(t)),t=o[3]^o[0]^o[1]^i[r+2],e[r+2]=o[2]^=u(s(t)),t=o[0]^o[1]^o[2]^i[r+3],e[r+3]=o[3]^=u(s(t));if(0===r)for(let t,r=0;r<16;r++)t=e[r],e[r]=e[31-r],e[31-r]=t}(r,p,n);const g=[];let d=l,m=t.length,y=0;for(;m>=e;){const r=t.slice(y,y+16),i=new Array(16);if("cbc"===f)for(let t=0;t<e;t++)0!==n&&(r[t]^=d[t]);a(r,i,p);for(let t=0;t<e;t++)"cbc"===f&&0===n&&(i[t]^=d[t]),g[y+t]=i[t];"cbc"===f&&(d=0!==n?i:r),m-=e,y+=e}if(("pkcs#5"===h||"pkcs#7"===h)&&0===n){const t=g.length,e=g[t-1];for(let r=1;r<=e;r++)if(g[t-r]!==e)throw new Error("padding is invalid");g.splice(t-e,e)}return"array"!==c?0!==n?g.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join(""):function(t){const e=[];for(let r=0,i=t.length;r<i;r++)t[r]>=240&&t[r]<=247?(e.push(String.fromCodePoint(((7&t[r])<<18)+((63&t[r+1])<<12)+((63&t[r+2])<<6)+(63&t[r+3]))),r+=3):t[r]>=224&&t[r]<=239?(e.push(String.fromCodePoint(((15&t[r])<<12)+((63&t[r+1])<<6)+(63&t[r+2]))),r+=2):t[r]>=192&&t[r]<=223?(e.push(String.fromCodePoint(((31&t[r])<<6)+(63&t[r+1]))),r++):e.push(String.fromCodePoint(t[r]));return e.join("")}(g):g}t.exports={encrypt:(t,e,r)=>f(t,e,1,r),decrypt:(t,e,r)=>f(t,e,0,r)}}},e={},function r(i){var o=e[i];if(void 0!==o)return o.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,r),n.exports}(10);var t,e}));
|
|
//# sourceMappingURL=gmhelper.js.map
|