!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>>4).toString(16)),r.push((15&t[e]).toString(16));return r.join("")}(s)}function l(t){for(var r=[],e=0;e>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("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>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;hu?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;s0)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>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<>>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<>=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>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):this[this.t-1]|=h<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<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=0;--e)r[e+s+1]=this[e]>>n|h,h=(this[e]&o)<=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;for(var s=e+1;s>i;i>0&&(r[this.t-e-1]|=(this.s&o)<>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;e>=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=0;)t[e]=0;for(e=0;e=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.t0?(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<1?h[l-2]>>this.F2:0),y=this.FV/g,d=(1<=0&&(n[n.t++]=1,n.subTo(F,n)),e.ONE.dlShiftTo(l,F),F.subTo(h,h);h.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))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<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<0)for(h>h)>0&&(n=!0,o=u(e));s>=0;)h>(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=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<>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;e>=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=0;)e[i]=0;for(i=Math.max(r-this.t,0);i0)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>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>i)!=(this.s&this.DM)>>i&&(r[n++]=e|this.s<=0;)i<8?(e=(this[t]&(1<>(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?0!=this.s:0!=(this[r]&1<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<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<=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(n0&&(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>>8,x[S++]=255&D;S=0,E()}function P(){if(null==b){for(E(),(b=new M).init(x),S=0;S{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;tt.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{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{const r=new Uint32Array(68),e=new Uint32Array(64);function i(t,r){const e=31&r;return 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=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=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>>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>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;const i=[];for(let t=0;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>>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{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>>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{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>>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>>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=r;){const e=t.slice(m,m+16),i=new Array(16);if("cbc"===f)for(let t=0;t1===(t=t.toString(16)).length?"0"+t:t)).join(""):function(t){const r=[];for(let e=0,i=t.length;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)<>>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;n0;){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;y0&&(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