!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("crypto")):"function"==typeof define&&define.amd?define(["crypto"],t):"object"==typeof exports?exports.jsckey=t(require("crypto")):e.jsckey=t(e.crypto)}(this,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/home/circleci/repo/packages/js-crypto-key-utils/dist",r(r.s=51)}([function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var i=n(r(37));t.encoder=i;var o=n(r(63));t.formatter=o,t.default={encoder:i,formatter:o}},function(e,t,r){"use strict";function n(e,t){return Object.keys(t).filter(function(r){return t[r].oid.toString()===e.toString()})}r.d(t,"b",function(){return n}),r.d(t,"c",function(){return i}),t.a={namedCurves:{"P-256":{indutnyName:"p256",payloadSize:32,oid:[1,2,840,10045,3,1,7]},"P-384":{indutnyName:"p384",payloadSize:48,oid:[1,3,132,0,34]},"P-521":{indutnyName:"p521",payloadSize:66,oid:[1,3,132,0,35]},"P-256K":{indutnyName:"secp256k1",payloadSize:32,oid:[1,3,132,0,10]}},publicKeyAlgorithms:{EC:{oid:[1,2,840,10045,2,1]},RSA:{oid:[1,2,840,113549,1,1,1]}},passwordBasedEncryptionSchemes:{"pbeWithMD5AndDES-CBC":{oid:[1,2,840,113549,1,5,3],hash:"MD5",encrypt:"DES-CBC"},"pbeWithSHA1AndDES-CBC":{oid:[1,2,840,113549,1,5,10],hash:"SHA-1",encrypt:"DES-CBC"},pbes2:{oid:[1,2,840,113549,1,5,13]}},keyDerivationFunctions:{pbkdf2:{oid:[1,2,840,113549,1,5,12],defaultSaltLen:8}},pbkdf2Prfs:{hmacWithSHA1:{oid:[1,2,840,113549,2,7],hash:"SHA-1"},hmacWithSHA256:{oid:[1,2,840,113549,2,9],hash:"SHA-256"},hmacWithSHA384:{oid:[1,2,840,113549,2,10],hash:"SHA-384"},hmacWithSHA512:{oid:[1,2,840,113549,2,11],hash:"SHA-512"}},encryptionSchemes:{"des-ede3-cbc":{oid:[1,2,840,113549,3,7],keyLength:24,ivLength:8},"aes128-cbc":{oid:[2,16,840,1,101,3,4,1,2],keyLength:16,ivLength:16},"aes192-cbc":{oid:[2,16,840,1,101,3,4,1,22],keyLength:24,ivLength:16},"aes256-cbc":{oid:[2,16,840,1,101,3,4,1,42],keyLength:32,ivLength:16}},hashes:{"SHA-256":{hashSize:32},"SHA-384":{hashSize:48},"SHA-512":{hashSize:64},"SHA-1":{hashSize:20},MD5:{hashSize:16}}};var i=function(e,t){var r=n(e,t);if(0===r.length)throw new Error("UnsupportedAlgorithm");return r[0]}},function(e,t,r){e.exports=r(52)},function(e,t,r){"use strict";const n=t;n.bignum=r(11),n.define=r(54).define,n.base=r(60),n.constants=r(61),n.decoders=r(35),n.encoders=r(32)},function(e,t,r){"use strict";(function(e){r.d(t,"d",function(){return f}),r.d(t,"e",function(){return s}),r.d(t,"c",function(){return u}),r.d(t,"b",function(){return d}),r.d(t,"f",function(){return h}),r.d(t,"a",function(){return p});var n=r(0),i=r.n(n),o=r(1),a=r(6),f=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pem";try{t=c(e,r)}catch(e){return!1}return"encryptedPrivate"===t},s=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pem";try{t=c(e,r)}catch(e){return!1}return"public"===t},c=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pem",n="pem"===r?i.a.formatter.pemToBin(t,"private"):t,o=a.b.decode(e.from(n),"der");if("encryptedPrivateKeyInfo"===o.type)return"encryptedPrivate";if("oneAsymmetricKey"===o.type)return"private";if("subjectPublicKeyInfo"===o.type)return"public";throw new Error("NotSpkiNorPkcs8Key")},u=function(e,t){var r;if(e instanceof Uint8Array)r="binary";else{if("string"!=typeof e)throw new Error("InvalidObjectType");r="string"}var n="string"===r?i.a.encoder.hexStringToArrayBuffer(e):e,a=o.a.namedCurves[t].payloadSize;if(n.length<=a)return"private";if(n.length===2*a+1&&4===n[0]||n.length===a+1&&(2===n[0]||3===n[0]))return"public";throw new Error("UnsupportedKeyStructure")},d=function(e){if("EC"===e.kty){if(e.x&&e.y&&e.d)return"private";if(e.x&&e.y)return"public";throw new Error("InvalidECKey")}if("RSA"===e.kty){if(e.n&&e.e&&e.d&&e.p&&e.q&&e.dp&&e.dq&&e.qi)return"private";if(e.n&&e.e)return"public";throw new Error("InvalidRSAKey")}throw new Error("UnsupportedJWKType")},h=function(e){if(!(e instanceof Uint8Array))throw new Error("NonUint8Array");for(var t=0,r=0;rt)throw new Error("InvalidLength");var r=new Uint8Array(t);return r.set(e,t-e.length),r}}).call(this,r(7).Buffer)},function(e,t){function r(e,t,r,n,i,o,a){try{var f=e[o](a),s=f.value}catch(e){return void r(e)}f.done?t(s):Promise.resolve(s).then(n,i)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise(function(i,o){var a=e.apply(t,n);function f(e){r(a,i,o,f,s,"next",e)}function s(e){r(a,i,o,f,s,"throw",e)}f(void 0)})}}},function(e,t,r){"use strict";(function(e){r.d(t,"b",function(){return o}),r.d(t,"h",function(){return a}),r.d(t,"c",function(){return f}),r.d(t,"a",function(){return s}),r.d(t,"d",function(){return c}),r.d(t,"f",function(){return u}),r.d(t,"g",function(){return d}),r.d(t,"e",function(){return h});var n=r(3),i=r.n(n),o=i.a.define("KeyStructure",function(){this.choice({subjectPublicKeyInfo:this.use(a),oneAsymmetricKey:this.use(f),encryptedPrivateKeyInfo:this.use(s)})}),a=i.a.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(p),this.key("subjectPublicKey").bitstr())}),f=i.a.define("OneAsymmetricKey",function(){this.seq().obj(this.key("version").use(l),this.key("privateKeyAlgorithm").use(p),this.key("privateKey").octstr(),this.key("attributes").implicit(0).optional().any(),this.key("publicKey").implicit(1).optional().bitstr())}),s=i.a.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("encryptionAlgorithm").use(p),this.key("encryptedData").octstr())}),c=i.a.define("PBEParameter",function(){this.seq().obj(this.key("salt").octstr(8),this.key("iterationCount").int())}),u=i.a.define("PBES2Params",function(){this.seq().obj(this.key("keyDerivationFunc").use(p),this.key("encryptionScheme").use(p))}),d=i.a.define("PBKDF2Params",function(){this.seq().obj(this.key("salt").choice({specified:this.octstr(),otherSource:this.use(p)}),this.key("iterationCount").int(),this.key("keyLength").int().optional(),this.key("prf").use(p).def({algorithm:[1,2,840,113549,2,7],parameters:e.from([5,0])}))}),h={"des-ede3-cbc":i.a.define("DesEde3CbcParams",function(){this.octstr()}),"aes128-cbc":i.a.define("Aes128CbcParams",function(){this.octstr()}),"aes192-cbc":i.a.define("Aes192CbcParams",function(){this.octstr()}),"aes256-cbc":i.a.define("Aes256CbcParams",function(){this.octstr()})},p=i.a.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())}),l=i.a.define("Version",function(){this.int()})}).call(this,r(7).Buffer)},function(e,t,r){"use strict";(function(e){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ var n=r(55),i=r(56),o=r(57);function a(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(e,t){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function l(e,t){if(s.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return D(e).length;default:if(n)return q(e).length;t=(""+t).toLowerCase(),n=!0}}function b(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return j(this,t,r);case"latin1":case"binary":return P(this,t,r);case"base64":return x(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,i);if("number"==typeof t)return t&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,i){var o,a=1,f=e.length,s=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,f/=2,s/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var u=-1;for(o=r;of&&(r=f-s),o=r;o>=0;o--){for(var d=!0,h=0;hi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function x(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function k(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+d<=r)switch(d){case 1:c<128&&(u=c);break;case 2:128==(192&(o=e[i+1]))&&(s=(31&c)<<6|63&o)>127&&(u=s);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(s=(15&c)<<12|(63&o)<<6|63&a)>2047&&(s<55296||s>57343)&&(u=s);break;case 4:o=e[i+1],a=e[i+2],f=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&f)&&(s=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&f)>65535&&s<1114112&&(u=s)}null===u?(u=65533,d=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=d}return function(e){var t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},s.prototype.compare=function(e,t,r,n,i){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),f=Math.min(o,a),c=this.slice(n,i),u=e.slice(t,r),d=0;di)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return S(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var E=4096;function j(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function C(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function U(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function R(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function z(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(e,t,r,n,o){return o||z(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function L(e,t,r,n,o){return o||z(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},s.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||O(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||O(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||C(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,1,255,0),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):R(this,e,t,!0),t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);C(this,e,t,r,i-1,-i)}var o=0,a=1,f=0;for(this[t]=255&e;++o>0)-f&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);C(this,e,t,r,i-1,-i)}var o=r-1,a=1,f=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===f&&0!==this[t+o+1]&&(f=1),this[t+o]=(e/a>>0)-f&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,1,127,-128),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):R(this,e,t,!0),t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||C(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},s.prototype.writeFloatLE=function(e,t,r){return T(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return T(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function D(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(34))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=r,r.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},function(e,t,r){"use strict";var n=t,i=r(11),o=r(9),a=r(38);n.assert=o,n.toArray=a.toArray,n.zero2=a.zero2,n.toHex=a.toHex,n.encode=a.encode,n.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var f=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,s=1;s0||t.cmpn(-i)>0;){var o,a,f,s=e.andln(3)+n&3,c=t.andln(3)+i&3;3===s&&(s=-1),3===c&&(c=-1),o=0==(1&s)?0:3!=(f=e.andln(7)+n&7)&&5!==f||2!==c?s:-s,r[0].push(o),a=0==(1&c)?0:3!=(f=t.andln(7)+i&7)&&5!==f||2!==s?c:-c,r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},function(e,t,r){(function(e){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{a=r(53).Buffer}catch(e){}function f(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function s(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?f-49+10:f>=17?f-17+10:f}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-f&67108863,(f+=24)>=26&&(f-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-f&67108863,(f+=24)>=26&&(f-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=f(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=f(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,f=Math.min(o,o-a)+r,c=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,f=67108863&a,s=a/67108864|0;r.words[0]=f;for(var c=1;c>>26,d=67108863&s,h=Math.min(c,t.length-1),p=Math.max(0,c-e.length+1);p<=h;p++){var l=c-p|0;u+=(a=(i=0|e.words[l])*(o=0|t.words[p])+d)/67108864|0,d=67108863&a}r.words[c]=0|d,s=0|u}return 0!==s?r.words[c]=0|s:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-s.length]+s+r:s+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var h=u[e],p=d[e];r="";var l=this.clone();for(l.negative=0;!l.isZero();){var b=l.modn(p).toString(e);r=(l=l.idivn(p)).isZero()?b+r:c[h-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==a),this.toArrayLike(a,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,f,s="le"===t,c=new e(o),u=this.clone();if(s){for(f=0;!u.isZero();f++)a=u.andln(255),u.iushrn(8),c[f]=a;for(;f=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,p=0|a[1],l=8191&p,b=p>>>13,y=0|a[2],m=8191&y,v=y>>>13,g=0|a[3],w=8191&g,_=g>>>13,S=0|a[4],A=8191&S,M=S>>>13,x=0|a[5],k=8191&x,E=x>>>13,j=0|a[6],P=8191&j,I=j>>>13,B=0|a[7],O=8191&B,C=B>>>13,U=0|a[8],R=8191&U,z=U>>>13,T=0|a[9],L=8191&T,N=T>>>13,K=0|f[0],q=8191&K,D=K>>>13,F=0|f[1],H=8191&F,W=F>>>13,Y=0|f[2],J=8191&Y,V=Y>>>13,Z=0|f[3],G=8191&Z,X=Z>>>13,$=0|f[4],Q=8191&$,ee=$>>>13,te=0|f[5],re=8191&te,ne=te>>>13,ie=0|f[6],oe=8191&ie,ae=ie>>>13,fe=0|f[7],se=8191&fe,ce=fe>>>13,ue=0|f[8],de=8191&ue,he=ue>>>13,pe=0|f[9],le=8191&pe,be=pe>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(c+(n=Math.imul(d,q))|0)+((8191&(i=(i=Math.imul(d,D))+Math.imul(h,q)|0))<<13)|0;c=((o=Math.imul(h,D))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(l,q),i=(i=Math.imul(l,D))+Math.imul(b,q)|0,o=Math.imul(b,D);var me=(c+(n=n+Math.imul(d,H)|0)|0)+((8191&(i=(i=i+Math.imul(d,W)|0)+Math.imul(h,H)|0))<<13)|0;c=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,q),i=(i=Math.imul(m,D))+Math.imul(v,q)|0,o=Math.imul(v,D),n=n+Math.imul(l,H)|0,i=(i=i+Math.imul(l,W)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,W)|0;var ve=(c+(n=n+Math.imul(d,J)|0)|0)+((8191&(i=(i=i+Math.imul(d,V)|0)+Math.imul(h,J)|0))<<13)|0;c=((o=o+Math.imul(h,V)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,D))+Math.imul(_,q)|0,o=Math.imul(_,D),n=n+Math.imul(m,H)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(v,H)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(l,J)|0,i=(i=i+Math.imul(l,V)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,V)|0;var ge=(c+(n=n+Math.imul(d,G)|0)|0)+((8191&(i=(i=i+Math.imul(d,X)|0)+Math.imul(h,G)|0))<<13)|0;c=((o=o+Math.imul(h,X)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(A,q),i=(i=Math.imul(A,D))+Math.imul(M,q)|0,o=Math.imul(M,D),n=n+Math.imul(w,H)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,J)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(l,G)|0,i=(i=i+Math.imul(l,X)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,X)|0;var we=(c+(n=n+Math.imul(d,Q)|0)|0)+((8191&(i=(i=i+Math.imul(d,ee)|0)+Math.imul(h,Q)|0))<<13)|0;c=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(k,q),i=(i=Math.imul(k,D))+Math.imul(E,q)|0,o=Math.imul(E,D),n=n+Math.imul(A,H)|0,i=(i=i+Math.imul(A,W)|0)+Math.imul(M,H)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,G)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(l,Q)|0,i=(i=i+Math.imul(l,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(c+(n=n+Math.imul(d,re)|0)|0)+((8191&(i=(i=i+Math.imul(d,ne)|0)+Math.imul(h,re)|0))<<13)|0;c=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(P,q),i=(i=Math.imul(P,D))+Math.imul(I,q)|0,o=Math.imul(I,D),n=n+Math.imul(k,H)|0,i=(i=i+Math.imul(k,W)|0)+Math.imul(E,H)|0,o=o+Math.imul(E,W)|0,n=n+Math.imul(A,J)|0,i=(i=i+Math.imul(A,V)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(l,re)|0,i=(i=i+Math.imul(l,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Se=(c+(n=n+Math.imul(d,oe)|0)|0)+((8191&(i=(i=i+Math.imul(d,ae)|0)+Math.imul(h,oe)|0))<<13)|0;c=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,D))+Math.imul(C,q)|0,o=Math.imul(C,D),n=n+Math.imul(P,H)|0,i=(i=i+Math.imul(P,W)|0)+Math.imul(I,H)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(A,G)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(l,oe)|0,i=(i=i+Math.imul(l,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0;var Ae=(c+(n=n+Math.imul(d,se)|0)|0)+((8191&(i=(i=i+Math.imul(d,ce)|0)+Math.imul(h,se)|0))<<13)|0;c=((o=o+Math.imul(h,ce)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(R,q),i=(i=Math.imul(R,D))+Math.imul(z,q)|0,o=Math.imul(z,D),n=n+Math.imul(O,H)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(C,H)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(P,J)|0,i=(i=i+Math.imul(P,V)|0)+Math.imul(I,J)|0,o=o+Math.imul(I,V)|0,n=n+Math.imul(k,G)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(E,G)|0,o=o+Math.imul(E,X)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(l,se)|0,i=(i=i+Math.imul(l,ce)|0)+Math.imul(b,se)|0,o=o+Math.imul(b,ce)|0;var Me=(c+(n=n+Math.imul(d,de)|0)|0)+((8191&(i=(i=i+Math.imul(d,he)|0)+Math.imul(h,de)|0))<<13)|0;c=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,D))+Math.imul(N,q)|0,o=Math.imul(N,D),n=n+Math.imul(R,H)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(z,H)|0,o=o+Math.imul(z,W)|0,n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,V)|0)+Math.imul(C,J)|0,o=o+Math.imul(C,V)|0,n=n+Math.imul(P,G)|0,i=(i=i+Math.imul(P,X)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,X)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,ee)|0,n=n+Math.imul(A,re)|0,i=(i=i+Math.imul(A,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,se)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(v,se)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(l,de)|0,i=(i=i+Math.imul(l,he)|0)+Math.imul(b,de)|0,o=o+Math.imul(b,he)|0;var xe=(c+(n=n+Math.imul(d,le)|0)|0)+((8191&(i=(i=i+Math.imul(d,be)|0)+Math.imul(h,le)|0))<<13)|0;c=((o=o+Math.imul(h,be)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(L,H),i=(i=Math.imul(L,W))+Math.imul(N,H)|0,o=Math.imul(N,W),n=n+Math.imul(R,J)|0,i=(i=i+Math.imul(R,V)|0)+Math.imul(z,J)|0,o=o+Math.imul(z,V)|0,n=n+Math.imul(O,G)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(P,Q)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(E,re)|0,o=o+Math.imul(E,ne)|0,n=n+Math.imul(A,oe)|0,i=(i=i+Math.imul(A,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(w,se)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,se)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(m,de)|0,i=(i=i+Math.imul(m,he)|0)+Math.imul(v,de)|0,o=o+Math.imul(v,he)|0;var ke=(c+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,be)|0)+Math.imul(b,le)|0))<<13)|0;c=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(L,J),i=(i=Math.imul(L,V))+Math.imul(N,J)|0,o=Math.imul(N,V),n=n+Math.imul(R,G)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(z,G)|0,o=o+Math.imul(z,X)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,ae)|0)+Math.imul(E,oe)|0,o=o+Math.imul(E,ae)|0,n=n+Math.imul(A,se)|0,i=(i=i+Math.imul(A,ce)|0)+Math.imul(M,se)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(w,de)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,de)|0,o=o+Math.imul(_,he)|0;var Ee=(c+(n=n+Math.imul(m,le)|0)|0)+((8191&(i=(i=i+Math.imul(m,be)|0)+Math.imul(v,le)|0))<<13)|0;c=((o=o+Math.imul(v,be)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(L,G),i=(i=Math.imul(L,X))+Math.imul(N,G)|0,o=Math.imul(N,X),n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(z,Q)|0,o=o+Math.imul(z,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,ae)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,ae)|0,n=n+Math.imul(k,se)|0,i=(i=i+Math.imul(k,ce)|0)+Math.imul(E,se)|0,o=o+Math.imul(E,ce)|0,n=n+Math.imul(A,de)|0,i=(i=i+Math.imul(A,he)|0)+Math.imul(M,de)|0,o=o+Math.imul(M,he)|0;var je=(c+(n=n+Math.imul(w,le)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,le)|0))<<13)|0;c=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(L,Q),i=(i=Math.imul(L,ee))+Math.imul(N,Q)|0,o=Math.imul(N,ee),n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(z,re)|0,o=o+Math.imul(z,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(P,se)|0,i=(i=i+Math.imul(P,ce)|0)+Math.imul(I,se)|0,o=o+Math.imul(I,ce)|0,n=n+Math.imul(k,de)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(E,de)|0,o=o+Math.imul(E,he)|0;var Pe=(c+(n=n+Math.imul(A,le)|0)|0)+((8191&(i=(i=i+Math.imul(A,be)|0)+Math.imul(M,le)|0))<<13)|0;c=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(L,re),i=(i=Math.imul(L,ne))+Math.imul(N,re)|0,o=Math.imul(N,ne),n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(z,oe)|0,o=o+Math.imul(z,ae)|0,n=n+Math.imul(O,se)|0,i=(i=i+Math.imul(O,ce)|0)+Math.imul(C,se)|0,o=o+Math.imul(C,ce)|0,n=n+Math.imul(P,de)|0,i=(i=i+Math.imul(P,he)|0)+Math.imul(I,de)|0,o=o+Math.imul(I,he)|0;var Ie=(c+(n=n+Math.imul(k,le)|0)|0)+((8191&(i=(i=i+Math.imul(k,be)|0)+Math.imul(E,le)|0))<<13)|0;c=((o=o+Math.imul(E,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(L,oe),i=(i=Math.imul(L,ae))+Math.imul(N,oe)|0,o=Math.imul(N,ae),n=n+Math.imul(R,se)|0,i=(i=i+Math.imul(R,ce)|0)+Math.imul(z,se)|0,o=o+Math.imul(z,ce)|0,n=n+Math.imul(O,de)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(C,de)|0,o=o+Math.imul(C,he)|0;var Be=(c+(n=n+Math.imul(P,le)|0)|0)+((8191&(i=(i=i+Math.imul(P,be)|0)+Math.imul(I,le)|0))<<13)|0;c=((o=o+Math.imul(I,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(L,se),i=(i=Math.imul(L,ce))+Math.imul(N,se)|0,o=Math.imul(N,ce),n=n+Math.imul(R,de)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(z,de)|0,o=o+Math.imul(z,he)|0;var Oe=(c+(n=n+Math.imul(O,le)|0)|0)+((8191&(i=(i=i+Math.imul(O,be)|0)+Math.imul(C,le)|0))<<13)|0;c=((o=o+Math.imul(C,be)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(L,de),i=(i=Math.imul(L,he))+Math.imul(N,de)|0,o=Math.imul(N,he);var Ce=(c+(n=n+Math.imul(R,le)|0)|0)+((8191&(i=(i=i+Math.imul(R,be)|0)+Math.imul(z,le)|0))<<13)|0;c=((o=o+Math.imul(z,be)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Ue=(c+(n=Math.imul(L,le))|0)+((8191&(i=(i=Math.imul(L,be))+Math.imul(N,le)|0))<<13)|0;return c=((o=Math.imul(N,be))+(i>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,s[0]=ye,s[1]=me,s[2]=ve,s[3]=ge,s[4]=we,s[5]=_e,s[6]=Se,s[7]=Ae,s[8]=Me,s[9]=xe,s[10]=ke,s[11]=Ee,s[12]=je,s[13]=Pe,s[14]=Ie,s[15]=Be,s[16]=Oe,s[17]=Ce,s[18]=Ue,0!==c&&(s[19]=c,r.length++),r};function l(e,t,r){return(new b).mulp(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(p=h),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=f,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):l(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),f=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==u||c>=i);c--){var d=0|this.words[c];this.words[c]=u<<26-o|d>>>o,u=d&f}return s&&0!==u&&(s.words[s.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(s/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===f)return this.strip();for(n(-1===f),f=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var f,s=n.length-i.length;if("mod"!==t){(f=new o(null)).length=s+1,f.words=new Array(f.length);for(var c=0;c=0;d--){var h=67108864*(0|n.words[i.length+d])+(0|n.words[i.length+d-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(i,h,d);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,d),n.isZero()||(n.negative^=1);f&&(f.words[d]=h)}return f&&f.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:f||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(f=this.neg().divmod(e,t),"mod"!==t&&(i=f.div.neg()),"div"!==t&&(a=f.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(f=this.divmod(e.neg(),t),"mod"!==t&&(i=f.div.neg()),{div:i,mod:f.mod}):0!=(this.negative&e.negative)?(f=this.neg().divmod(e.neg(),t),"div"!==t&&(a=f.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:f.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,f},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),f=new o(0),s=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var u=r.clone(),d=t.clone();!t.isZero();){for(var h=0,p=1;0==(t.words[0]&p)&&h<26;++h,p<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(u),a.isub(d)),i.iushrn(1),a.iushrn(1);for(var l=0,b=1;0==(r.words[0]&b)&&l<26;++l,b<<=1);if(l>0)for(r.iushrn(l);l-- >0;)(f.isOdd()||s.isOdd())&&(f.iadd(u),s.isub(d)),f.iushrn(1),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(f),a.isub(s)):(r.isub(t),f.isub(i),s.isub(a))}return{a:f,b:s,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),f=new o(0),s=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,u=1;0==(t.words[0]&u)&&c<26;++c,u<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(s),a.iushrn(1);for(var d=0,h=1;0==(r.words[0]&h)&&d<26;++d,h<<=1);if(d>0)for(r.iushrn(d);d-- >0;)f.isOdd()&&f.iadd(s),f.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(f)):(r.isub(t),f.isub(a))}return(i=0===t.cmpn(1)?a:f).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,f&=67108863,this.words[a]=f}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new S(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function A(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},i(v,m),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return y[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var f=new o(1).toRed(this),s=f.redNeg(),c=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new o(2*u*u).toRed(this);0!==this.pow(u,c).cmp(s);)u.redIAdd(s);for(var d=this.pow(u,i),h=this.pow(e,i.addn(1).iushrn(1)),p=this.pow(e,i),l=a;0!==p.cmp(f);){for(var b=p,y=0;0!==b.cmp(f);y++)b=b.redSqr();n(y=0;n--){for(var c=t.words[n],u=s-1;u>=0;u--){var d=c>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==d||0!==a?(a<<=1,a|=d,(4===++f||0===n&&0===u)&&(i=this.mul(i,r[a]),f=0,a=0)):f=0}s=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new A(e)},i(A,S),A.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},A.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},A.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(31)(e))},function(e,t,r){"use strict";t.utils=r(82),t.Cipher=r(83),t.DES=r(84),t.CBC=r(85),t.EDE=r(86)},function(e,t,r){"use strict";var n=r(9),i=r(8);function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function f(e){return 1===e.length?"0"+e:e}function s(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>6|192,r[n++]=63&a|128):o(e,i)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++i)),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128)}else for(i=0;i>>0}return a},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,a,f){var s=0,c=t;return s+=(c=c+n>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(e,t,r,n,i,o,a,f){return t+n+o+f>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,a,f,s,c){var u=0,d=t;return u+=(d=d+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,a,f,s,c){return t+n+o+f+c>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},function(e,t){e.exports=function(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";const n=r(8),i=r(25).Reporter,o=r(7).Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function f(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return f.isEncoderBuffer(e)||(e=new f(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(a,i),t.DecoderBuffer=a,a.isDecoderBuffer=function(e){if(e instanceof a)return!0;return"object"==typeof e&&o.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){const t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},t.EncoderBuffer=f,f.isEncoderBuffer=function(e){if(e instanceof f)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},f.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},function(e,t,r){"use strict";var n=r(13),i=r(9);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=s,s.prototype.point=function(){throw new Error("Not implemented")},s.prototype.validate=function(){throw new Error("Not implemented")},s.prototype._fixedNafMul=function(e,t){f(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=s;t--)c=(c<<1)+n[t];a.push(c)}for(var u=this.jpoint(null,null,null),d=this.jpoint(null,null,null),h=i;h>0;h--){for(s=0;s=0;c--){for(t=0;c>=0&&0===a[c];c--)t++;if(c>=0&&t++,s=s.dblp(t),c<0)break;var u=a[c];f(0!==u),s="affine"===e.type?u>0?s.mixedAdd(i[u-1>>1]):s.mixedAdd(i[-u-1>>1].neg()):u>0?s.add(i[u-1>>1]):s.add(i[-u-1>>1].neg())}return"affine"===e.type?s.toP():s},s.prototype._wnafMulAdd=function(e,t,r,n,i){for(var f=this._wnafT1,s=this._wnafT2,c=this._wnafT3,u=0,d=0;d=1;d-=2){var p=d-1,l=d;if(1===f[p]&&1===f[l]){var b=[t[p],null,null,t[l]];0===t[p].y.cmp(t[l].y)?(b[1]=t[p].add(t[l]),b[2]=t[p].toJ().mixedAdd(t[l].neg())):0===t[p].y.cmp(t[l].y.redNeg())?(b[1]=t[p].toJ().mixedAdd(t[l]),b[2]=t[p].add(t[l].neg())):(b[1]=t[p].toJ().mixedAdd(t[l]),b[2]=t[p].toJ().mixedAdd(t[l].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[p],r[l]);u=Math.max(m[0].length,u),c[p]=new Array(u),c[l]=new Array(u);for(var v=0;v=0;d--){for(var A=0;d>=0;){var M=!0;for(v=0;v=0&&A++,_=_.dblp(A),d<0)break;for(v=0;v0?x=s[v][k-1>>1]:k<0&&(x=s[v][-k-1>>1].neg()),_="affine"===x.type?_.mixedAdd(x):_.add(x))}}for(d=0;d=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i-1},ke.prototype.set=function(e,t){var r=this.__data__,n=Be(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ee.prototype.clear=function(){this.__data__={hash:new xe,map:new(pe||ke),string:new xe}},Ee.prototype.delete=function(e){return ze(this,e).delete(e)},Ee.prototype.get=function(e){return ze(this,e).get(e)},Ee.prototype.has=function(e){return ze(this,e).has(e)},Ee.prototype.set=function(e,t){return ze(this,e).set(e,t),this},je.prototype.clear=function(){this.__data__=new ke},je.prototype.delete=function(e){return this.__data__.delete(e)},je.prototype.get=function(e){return this.__data__.get(e)},je.prototype.has=function(e){return this.__data__.has(e)},je.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ke){var i=r.__data__;if(!pe||i.length-1&&e%1==0&&e-1&&e%1==0&&e<=o}(e.length)&&!Je(e)}var Ye=ue||function(){return!1};function Je(e){var t=Ve(e)?ee.call(e):"";return t==c||t==u}function Ve(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ze(e){return We(e)?Pe(e):function(e){if(!qe(e))return de(e);var t=[];for(var r in Object(e))Q.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}r.exports=function(e){return Oe(e,!0,!0)}}).call(this,r(34),r(31)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,r){"use strict";const n=t;n.der=r(33),n.pem=r(58)},function(e,t,r){"use strict";const n=r(8),i=r(7).Buffer,o=r(24),a=r(26);function f(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new s,this.tree._init(e.body)}function s(e){o.call(this,"der",e)}function c(e){return e<10?"0"+e:e}e.exports=f,f.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},n(s,o),s.prototype._encodeComposite=function(e,t,r,n){const o=function(e,t,r,n){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(a.tagByName.hasOwnProperty(e))i=a.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return n.error("Unknown tag: "+e);i=e}if(i>=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=a.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128){const e=new i(2);return e[0]=o,e[1]=n.length,this._createEncoderBuffer([e,n])}let f=1;for(let e=n.length;e>=256;e>>=8)f++;const s=new i(2+f);s[0]=o,s[1]=128|f;for(let e=1+f,t=n.length;t>0;e--,t>>=8)s[e]=255&t;return this._createEncoderBuffer([s,n])},s.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=new i(2*e.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let n=0;for(let t=0;t=128;r>>=7)n++}const o=new i(n);let a=o.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(o[a--]=127&r;(r>>=7)>0;)o[a--]=128|127&r}return this._createEncoderBuffer(o)},s.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[c(n.getUTCFullYear()),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[c(n.getUTCFullYear()%100),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},s.prototype._encodeNull=function(){return this._createEncoderBuffer("")},s.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=new i(t)}if(i.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=new i(t);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let r=1;for(let t=e;t>=256;t>>=8)r++;const n=new Array(r);for(let t=n.length-1;t>=0;t--)n[t]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(new i(n))},s.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},s.prototype._skipDefault=function(e,t,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:f.tag[r]}}function d(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(let t=0;t126||e[r]<32&&13!==e[r]&&10!==e[r]){t=!1;break}var n=null;if(t){n="";for(r=0;r>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},function(e,t,r){var n;function i(e){this.rand=e}if(e.exports=function(e){return n||(n=new i(null)),n.generate(e)},e.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},function(e,t,r){"use strict";var n=r(13),i=r(16),o=r(42),a=r(9),f=n.sum32,s=n.sum32_4,c=n.sum32_5,u=o.ch32,d=o.maj32,h=o.s0_256,p=o.s1_256,l=o.g0_256,b=o.g1_256,y=i.BlockHash,m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function v(){if(!(this instanceof v))return new v;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m,this.W=new Array(64)}n.inherits(v,y),e.exports=v,v.blockSize=512,v.outSize=256,v.hmacStrength=192,v.padLength=64,v.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n=0;--o){var a=this.tryEntries[o],f=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:j(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),l}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},function(e,t){},function(e,t,r){"use strict";const n=r(32),i=r(35),o=r(8);function a(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}t.define=function(e,t){return new a(e,t)},a.prototype._createNamed=function(e){const t=this.name;function r(e){this._initNamed(e,t)}return o(r,e),r.prototype._initNamed=function(t,r){e.call(this,t,r)},new r(this)},a.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(i[e])),this.decoders[e]},a.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},a.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n[e])),this.encoders[e]},a.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},function(e,t,r){"use strict";t.toByteArray=function(e){for(var t,r=c(e),n=r[0],a=r[1],f=new o(function(e,t,r){return 3*(t+r)/4-r}(0,n,a)),s=0,u=a>0?n-4:n,d=0;d>16&255,f[s++]=t>>8&255,f[s++]=255&t;2===a&&(t=i[e.charCodeAt(d)]<<2|i[e.charCodeAt(d+1)]>>4,f[s++]=255&t);1===a&&(t=i[e.charCodeAt(d)]<<10|i[e.charCodeAt(d+1)]<<4|i[e.charCodeAt(d+2)]>>2,f[s++]=t>>8&255,f[s++]=255&t);return f},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],a=0,f=r-i;af?f:a+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,s=a.length;f0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,o,a=[],f=t;f>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,r,n,i){var o,a,f=8*i-n-1,s=(1<>1,u=-7,d=r?i-1:0,h=r?-1:1,p=e[t+d];for(d+=h,o=p&(1<<-u)-1,p>>=-u,u+=f;u>0;o=256*o+e[t+d],d+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=n;u>0;a=256*a+e[t+d],d+=h,u-=8);if(0===o)o=1-c;else{if(o===s)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var a,f,s,c=8*o-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,l=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(s=Math.pow(2,-a))<1&&(a--,s*=2),(t+=a+d>=1?h/s:h*Math.pow(2,1-d))*s>=2&&(a++,s/=2),a+d>=u?(f=0,a=u):a+d>=1?(f=(t*s-1)*Math.pow(2,i),a+=d):(f=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[r+p]=255&f,p+=l,f/=256,i-=8);for(a=a<0;e[r+p]=255&a,p+=l,a/=256,c-=8);e[r+p-l]|=128*b}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"use strict";const n=r(8),i=r(33);function o(e){i.call(this,e),this.enc="pem"}n(o,i),e.exports=o,o.prototype.encode=function(e,t){const r=i.prototype.encode.call(this,e).toString("base64"),n=["-----BEGIN "+t.label+"-----"];for(let e=0;e=0?e.from(t):e.from(t.toString(),"binary")).toString("base64")},n=function(t){if(void 0===e)throw new Error("UnsupportedEnvironment");return e.from(t,"base64").toString("binary")}}).call(this,r(7).Buffer)},function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var i=n(r(37)),o={public:"PUBLIC KEY",private:"PRIVATE KEY",encryptedPrivate:"ENCRYPTED PRIVATE KEY",certificate:"CERTIFICATE",certRequest:"CERTIFICATE REQUEST"};t.pemToBin=function(e){var t=f(e);return i.decodeBase64(t)},t.binToPem=function(e,t){var r=i.encodeBase64(e);return a(r,t)};var a=function(e,t){if(Object.keys(o).indexOf(t)<0)throw new Error("Unsupported type");for(var r=o[t],n="-----BEGIN "+r+"-----\n";e.length>0;)n+=e.substring(0,64)+"\n",e=e.substring(64);return n=n+"-----END "+r+"-----"},f=function(e){var t=RegExp("^-----[s]*BEGIN[^-]*-----$","gm"),r=RegExp("^-----[s]*END[^-]*-----$","gm");try{var n=e.split(t)[1].split(r)[0];return n=n.replace(/\r?\n/g,"")}catch(e){throw new Error("Invalid format as PEM")}}},function(e){e.exports=JSON.parse('{"name":"elliptic","version":"6.5.0","description":"EC cryptography","main":"lib/elliptic.js","files":["lib"],"scripts":{"jscs":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","jshint":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","lint":"npm run jscs && npm run jshint","unit":"istanbul test _mocha --reporter=spec test/index.js","test":"npm run lint && npm run unit","version":"grunt dist && git add dist/"},"repository":{"type":"git","url":"git@github.com:indutny/elliptic"},"keywords":["EC","Elliptic","curve","Cryptography"],"author":"Fedor Indutny ","license":"MIT","bugs":{"url":"https://github.com/indutny/elliptic/issues"},"homepage":"https://github.com/indutny/elliptic","devDependencies":{"brfs":"^1.4.3","coveralls":"^2.11.3","grunt":"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2","istanbul":"^0.4.2","jscs":"^2.9.0","jshint":"^2.6.0","mocha":"^2.1.0"},"dependencies":{"bn.js":"^4.4.0","brorand":"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0","inherits":"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"}}')},function(e,t,r){"use strict";var n=r(10),i=r(11),o=r(8),a=r(19),f=n.assert;function s(e){a.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function c(e,t,r,n){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function u(e,t,r,n){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(s,a),e.exports=s,s.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?r=o[0]:(r=o[1],f(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new i(e.a,16),b:new i(e.b,16)}}):this._getEndoBasis(r)}}},s.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},s.prototype._getEndoBasis=function(e){for(var t,r,n,o,a,f,s,c,u,d=this.n.ushrn(Math.floor(this.n.bitLength()/2)),h=e,p=this.n.clone(),l=new i(1),b=new i(0),y=new i(0),m=new i(1),v=0;0!==h.cmpn(0);){var g=p.div(h);c=p.sub(g.mul(h)),u=y.sub(g.mul(l));var w=m.sub(g.mul(b));if(!n&&c.cmp(d)<0)t=s.neg(),r=l,n=c.neg(),o=u;else if(n&&2==++v)break;s=c,p=h,h=c,y=l,l=u,m=b,b=w}a=c.neg(),f=u;var _=n.sqr().add(o.sqr());return a.sqr().add(f.sqr()).cmp(_)>=0&&(a=t,f=r),n.negative&&(n=n.neg(),o=o.neg()),a.negative&&(a=a.neg(),f=f.neg()),[{a:n,b:o},{a:a,b:f}]},s.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),f=o.mul(n.a),s=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(f),k2:s.add(c).neg()}},s.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(t&&!o||!t&&o)&&(n=n.redNeg()),this.point(e,n)},s.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},s.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},c.prototype.isInfinity=function(){return this.inf},c.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},c.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},c.prototype.getX=function(){return this.x.fromRed()},c.prototype.getY=function(){return this.y.fromRed()},c.prototype.mul=function(e){return e=new i(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},c.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},c.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},c.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},c.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(u,a.BasePoint),s.prototype.jpoint=function(e,t,r){return new u(this,e,t,r)},u.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},u.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},u.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),f=n.redSub(i),s=o.redSub(a);if(0===f.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=f.redSqr(),u=c.redMul(f),d=n.redMul(c),h=s.redSqr().redIAdd(u).redISub(d).redISub(d),p=s.redMul(d.redISub(h)).redISub(o.redMul(u)),l=this.z.redMul(e.z).redMul(f);return this.curve.jpoint(h,p,l)},u.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),f=i.redSub(o);if(0===a.cmpn(0))return 0!==f.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var s=a.redSqr(),c=s.redMul(a),u=r.redMul(s),d=f.redSqr().redIAdd(c).redISub(u).redISub(u),h=f.redMul(u.redISub(d)).redISub(i.redMul(c)),p=this.z.redMul(a);return this.curve.jpoint(d,h,p)},u.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(11),i=r(8),o=r(19),a=r(10);function f(e){o.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function s(e,t,r){o.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(f,o),e.exports=f,f.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},i(s,o.BasePoint),f.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},f.prototype.point=function(e,t){return new s(this,e,t)},f.prototype.pointFromJSON=function(e){return s.fromJSON(this,e)},s.prototype.precompute=function(){},s.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},s.fromJSON=function(e,t){return new s(e,t[0],t[1]||e.one)},s.prototype.inspect=function(){return this.isInfinity()?"":""},s.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},s.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},s.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),f=t.z.redMul(o.redAdd(a).redSqr()),s=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(f,s)},s.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},s.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},s.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},s.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,r){"use strict";var n=r(10),i=r(11),o=r(8),a=r(19),f=n.assert;function s(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new i(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),f(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function c(e,t,r,n,o){a.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(t,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=o&&new i(o,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(s,a),e.exports=s,s.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},s.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},s.prototype.jpoint=function(e,t,r,n){return this.point(e,t,r,n)},s.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=n.redMul(o.redInvm()),f=a.redSqrt();if(0!==f.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var s=f.fromRed().isOdd();return(t&&!s||!t&&s)&&(f=f.redNeg()),this.point(e,f)},s.prototype.pointFromY=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=n.redMul(o.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=a.redSqrt();if(0!==f.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)},s.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),n=t.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===n.cmp(i)},o(c,a.BasePoint),s.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},s.prototype.point=function(e,t,r,n){return new c(this,e,t,r,n)},c.fromJSON=function(e,t){return new c(e,t[0],t[1],t[2])},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},c.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),f=n.redSub(t),s=i.redMul(a),c=o.redMul(f),u=i.redMul(f),d=a.redMul(o);return this.curve.point(s,c,d,u)},c.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(c.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var f=this.z.redSqr(),s=a.redSub(f).redISub(f);e=n.redSub(i).redISub(o).redMul(s),t=a.redMul(c.redSub(o)),r=a.redMul(s)}}else{var c=i.redAdd(o);f=this.curve._mulC(this.z).redSqr(),s=c.redSub(f).redSub(f);e=this.curve._mulC(n.redISub(c)).redMul(s),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(s)}return this.curve.point(e,t,r)},c.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),f=i.redAdd(n),s=r.redAdd(t),c=o.redMul(a),u=f.redMul(s),d=o.redMul(s),h=a.redMul(f);return this.curve.point(c,u,h,d)},c.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),f=this.curve.d.redMul(o).redMul(a),s=i.redSub(f),c=i.redAdd(f),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),d=n.redMul(s).redMul(u);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=s.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(s).redMul(c)),this.curve.point(d,t,r)},c.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},c.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},c.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},c.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function(){return this.normalize(),this.y.fromRed()},c.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},c.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},function(e,t,r){"use strict";t.sha1=r(69),t.sha224=r(70),t.sha256=r(43),t.sha384=r(71),t.sha512=r(44)},function(e,t,r){"use strict";var n=r(13),i=r(16),o=r(42),a=n.rotl32,f=n.sum32,s=n.sum32_5,c=o.ft_1,u=i.BlockHash,d=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(h,u),e.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t0))return a.iaddn(1),this.keyFromPrivate(a)}},d.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},d.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),f=t.getPrivate().toArray("be",a),s=e.toArray("be",a),c=new i({hash:this.hash,entropy:f,nonce:s,pers:o.pers,persEnc:o.persEnc||"utf8"}),d=this.n.sub(new n(1)),h=0;;h++){var p=o.k?o.k(h):new n(c.generate(this.n.byteLength()));if(!((p=this._truncateToN(p,!0)).cmpn(1)<=0||p.cmp(d)>=0)){var l=this.g.mul(p);if(!l.isInfinity()){var b=l.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=p.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(l.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new u({r:y,s:m,recoveryParam:v})}}}}}},d.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var f,s=a.invm(this.n),c=s.mul(e).umod(this.n),d=s.mul(o).umod(this.n);return this.curve._maxwellTrick?!(f=this.g.jmulAdd(c,r.getPublic(),d)).isInfinity()&&f.eqXToP(o):!(f=this.g.mulAdd(c,r.getPublic(),d)).isInfinity()&&0===f.getX().umod(this.n).cmp(o)},d.prototype.recoverPubKey=function(e,t,r,i){s((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,a=new n(e),f=t.r,c=t.s,d=1&r,h=r>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");f=h?this.curve.pointFromX(f.add(this.curve.n),d):this.curve.pointFromX(f,d);var p=t.r.invm(o),l=o.sub(a).mul(p).umod(o),b=c.mul(p).umod(o);return this.g.mulAdd(l,f,b)},d.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,r){"use strict";var n=r(20),i=r(38),o=r(9);function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}e.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length"}},function(e,t,r){"use strict";var n=r(11),i=r(10),o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function f(){this.place=0}function s(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new f;if(48!==e[r.place++])return!1;if(s(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=s(e,r),a=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var c=s(e,r);if(e.length!==c+r.place)return!1;var u=e.slice(r.place,c+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===u[0]&&128&u[1]&&(u=u.slice(1)),this.r=new n(a),this.s=new n(u),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=c(t),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];u(n,t.length),(n=n.concat(t)).push(2),u(n,r.length);var o=n.concat(r),a=[48];return u(a,o.length),a=a.concat(o),i.encode(a,e)}},function(e,t,r){"use strict";var n=r(20),i=r(27),o=r(10),a=o.assert,f=o.parseBytes,s=r(80),c=r(81);function u(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof u))return new u(e);e=i[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}e.exports=u,u.prototype.sign=function(e,t){e=f(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),s=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:s,Rencoded:o})},u.prototype.verify=function(e,t,r){e=f(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},u.prototype.hashInt=function(){for(var e=this.hash(),t=0;t>>0},t.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},t.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var f=0;f<=24;f+=8)i<<=1,i|=t>>>f+a&1;for(f=0;f<=24;f+=8)i<<=1,i|=e>>>f+a&1}for(a=6;a>=0;a-=2){for(f=1;f<=25;f+=8)o<<=1,o|=t>>>f+a&1;for(f=1;f<=25;f+=8)o<<=1,o|=e>>>f+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},t.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var f=24;f>=0;f-=8)i<<=1,i|=t>>>f+a&1,i<<=1,i|=e>>>f+a&1;for(a=4;a<8;a++)for(f=24;f>=0;f-=8)o<<=1,o|=t>>>f+a&1,o<<=1,o|=e>>>f+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},t.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var f=0;f<=24;f+=8)i<<=1,i|=t>>f+a&1;for(f=0;f<=24;f+=8)i<<=1,i|=e>>f+a&1}for(f=0;f<=24;f+=8)i<<=1,i|=t>>f+a&1;for(a=1;a<=3;a++){for(f=0;f<=24;f+=8)o<<=1,o|=t>>f+a&1;for(f=0;f<=24;f+=8)o<<=1,o|=e>>f+a&1}for(f=0;f<=24;f+=8)o<<=1,o|=e>>f+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},t.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];t.pc2=function(e,t,r,i){for(var o=0,a=0,f=n.length>>>1,s=0;s>>n[s]&1;for(s=f;s>>n[s]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},t.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];t.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];t.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},t.padSplit=function(e,t,r){for(var n=e.toString(2);n.length0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=a.r28shl(r,f),i=a.r28shl(i,f),a.pc2(r,i,e.keys,o)}},c.prototype._update=function(e,t,r,n){var i=this._desState,o=a.readUInt32BE(e,t),f=a.readUInt32BE(e,t+4);a.ip(o,f,i.tmp,0),o=i.tmp[0],f=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,f,i.tmp,0):this._decrypt(i,o,f,i.tmp,0),o=i.tmp[0],f=i.tmp[1],a.writeUInt32BE(r,o,n),a.writeUInt32BE(r,f,n+4)},c.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=h}a.rip(f,o,n,i)},c.prototype._decrypt=function(e,t,r,n,i){for(var o=r,f=t,s=e.keys.length-2;s>=0;s-=2){var c=e.keys[s],u=e.keys[s+1];a.expand(o,e.tmp,0),c^=e.tmp[0],u^=e.tmp[1];var d=a.substitute(c,u),h=o;o=(f^a.permute(d))>>>0,f=h}a.rip(o,f,n,i)}},function(e,t,r){"use strict";var n=r(9),i=r(8),o={};function a(e){n.equal(e.length,8,"Invalid IV length"),this.iv=new Array(8);for(var t=0;t(Math.pow(2,32)-1)*h)){e.next=5;break}throw new Error("DerivedKeyTooLong");case 5:for(l=Math.ceil(f/h),b=f-(l-1)*h,y=function(){var e=(0,o.default)(i.default.mark(function e(o){var a,f,c,h;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return(a=new Uint8Array(r.length+4)).set(r),a.set(d(o+1,4),r.length),e.next=5,s.default.compute(t,a,u);case 5:f=e.sent,c=new Uint8Array(f),h=1;case 8:if(!(h>8*(t-n-1);return r},h=function(){var e=(0,o.default)(i.default.mark(function e(t,r,n,o,s){var u,d;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(p(t,r,n,o,s),"string"==typeof t&&(t=a.default.encoder.stringToArrayBuffer(t)),!(o>c.default.hashes[s].hashSize)){e.next=4;break}throw new Error("DerivedKeyTooLong");case 4:(u=new Uint8Array(t.length+r.length)).set(t),u.set(r,t.length),d=0;case 8:if(!(d1&&void 0!==h[1]?h[1]:"SHA-256",!(Object.keys(s.default.hashes).indexOf(r)<0)){e.next=3;break}throw new Error("UnsupportedHashAlgorithm");case 3:if(t instanceof Uint8Array){e.next=5;break}throw new Error("UnsupportedMessageType");case 5:if(n=f.getWebCrypto(),i=f.getNodeCrypto(),a=f.getMsCrypto(),d=!0,void 0===n||"function"!=typeof n.digest||void 0!==a){e.next=15;break}return e.next=12,n.digest(r,t).catch(function(e){u=e.message,d=!1});case 12:c=e.sent,e.next=26;break;case 15:if(void 0===i){e.next=19;break}try{c=l(r,t,i)}catch(e){u=e.message,d=!1}e.next=26;break;case 19:if(void 0===a||"function"!=typeof a.digest){e.next=25;break}return e.next=22,p(r,t,a).catch(function(e){u=e.message,d=!1});case 22:c=e.sent,e.next=26;break;case 25:d=!1;case 26:if(d){e.next=35;break}e.prev=27,c=b(r,t),e.next=35;break;case 31:throw e.prev=31,e.t0=e.catch(27),u="".concat(u," => ").concat(e.t0.message),new Error("UnsupportedEnvironment: ".concat(u));case 35:return e.abrupt("return",new Uint8Array(c));case 36:case"end":return e.stop()}},e,null,[[27,31]])}));return function(t){return e.apply(this,arguments)}}();t.compute=h;var p=function(e,t,r){return new Promise(function(n,i){var o=r.digest(e,t);o.oncomplete=function(e){n(e.target.result)},o.onerror=function(e){i(e)}})},l=function(e,t,r){var n=s.default.hashes[e].nodeName,i=r.createHash(n);return i.update(t),i.digest()},b=function(e,t){var n;if("MD5"===e)n=(0,c.default)(Array.from(t),{asBytes:!0});else if(["SHA3-512","SHA3-384","SHA3-256","SHA3-224"].indexOf(e)>=0){var i=new u.SHA3(8*s.default.hashes[e].hashSize),o=r(7).Buffer;i.update(o.from(t)),n=i.digest("binary")}else n=d.default[s.default.hashes[e].nodeName]().update(t).digest();return new Uint8Array(n)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default={hashes:{"SHA3-512":{nodeName:"sha3-512",hashSize:64},"SHA3-384":{nodeName:"sha3-384",hashSize:48},"SHA3-256":{nodeName:"sha3-256",hashSize:32},"SHA3-224":{nodeName:"sha3-224",hashSize:28},"SHA-256":{nodeName:"sha256",hashSize:32},"SHA-384":{nodeName:"sha384",hashSize:48},"SHA-512":{nodeName:"sha512",hashSize:64},"SHA-1":{nodeName:"sha1",hashSize:20},MD5:{nodeName:"md5",hashSize:16}}}},function(e,t,r){var n,i,o,a,f;n=r(91),i=r(45).utf8,o=r(92),a=r(45).bin,(f=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?a.stringToBytes(e):i.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||(e=e.toString());for(var r=n.bytesToWords(e),s=8*e.length,c=1732584193,u=-271733879,d=-1732584194,h=271733878,p=0;p>>24)|4278255360&(r[p]<<24|r[p]>>>8);r[s>>>5]|=128<>>9<<4)]=s;var l=f._ff,b=f._gg,y=f._hh,m=f._ii;for(p=0;p>>0,u=u+g>>>0,d=d+w>>>0,h=h+_>>>0}return n.endian([c,u,d,h])})._ff=function(e,t,r,n,i,o,a){var f=e+(t&r|~t&n)+(i>>>0)+a;return(f<>>32-o)+t},f._gg=function(e,t,r,n,i,o,a){var f=e+(t&n|r&~n)+(i>>>0)+a;return(f<>>32-o)+t},f._hh=function(e,t,r,n,i,o,a){var f=e+(t^r^n)+(i>>>0)+a;return(f<>>32-o)+t},f._ii=function(e,t,r,n,i,o,a){var f=e+(r^(t|~n))+(i>>>0)+a;return(f<>>32-o)+t},f._blocksize=16,f._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var r=n.wordsToBytes(f(e,t));return t&&t.asBytes?r:t&&t.asString?a.bytesToString(r):n.bytesToHex(r)}},function(e,t){var r,n;r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],r=0,n=0;r>>5]|=e[r]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},bytesToHex:function(e){for(var t=[],r=0;r>>4).toString(16)),t.push((15&e[r]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],r=0;r>>6*(3-o)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,i=0;n>>6-2*i);return t}},e.exports=n},function(e,t){function r(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)} /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh * @license MIT */ e.exports=function(e){return null!=e&&(r(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&r(e.slice(0,0))}(e)||!!e._isBuffer)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SHA3=void 0;var n,i=r(7),o=(n=r(94))&&n.__esModule?n:{default:n};var a=function(e){var t=e.padding;return function e(){var r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:512;if(!this||this.constructor!==e)return new e(n);var a=new o.default({capacity:n,padding:t});return this.update=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";if(i.Buffer.isBuffer(e))return a.absorb(e),r;if("string"==typeof e)return r.update(i.Buffer.from(e,t));throw new TypeError("Not a string or buffer")},this.digest=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"binary",t=a.squeeze();return e&&"binary"!==e?t.toString(e):t},this.reset=function(){return a.reset(),r},this}},f=a({padding:1}),s=a({padding:6});t.SHA3=s;var c=f;s.SHA3Hash=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,i=r(7),o=(n=r(95))&&n.__esModule?n:{default:n};var a=[224,256,384,512],f=function(e,t){for(var r=0;r=u&&(f(p,h),s(h),d=0);return t},this.squeeze=function(){var e={queue:i.Buffer.allocUnsafe(u),state:new Uint32Array(50)};p.copy(e.queue);for(var t=0;t>>8,r[n+2]=e[o+1]>>>16,r[n+3]=e[o+1]>>>24,r[n+4]=e[o],r[n+5]=e[o]>>>8,r[n+6]=e[o]>>>16,r[n+7]=e[o]>>>24}return r}(e.state,c)},this.reset=function(){return p.fill(0),h.fill(0),d=0,t},this};t.default=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=f(r(96)),i=f(r(97)),o=f(r(99)),a=f(r(102));function f(e){return e&&e.__esModule?e:{default:e}}var s=function(){var e=new Uint32Array(10),t=new Uint32Array(10),r=new Uint32Array(2);return function(f){for(var s=0;s<24;s++)(0,a.default)({A:f,C:e,D:t,W:r}),(0,o.default)({A:f,C:e,W:r}),(0,n.default)({A:f,C:e}),(0,i.default)({A:f,roundIndex:s});e.fill(0),t.fill(0),r.fill(0)}};t.default=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,i=(n=r(28))&&n.__esModule?n:{default:n};var o=function(e){for(var t=e.A,r=e.C,n=0;n<25;n+=5){for(var o=0;o<5;o++)(0,i.default)(t,n+o)(r,o);for(var a=0;a<5;a++){var f=2*(n+a),s=(a+1)%5*2,c=(a+2)%5*2;t[f]^=~r[s]&r[c],t[f+1]^=~r[s+1]&r[c+1]}}};t.default=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,i=(n=r(98))&&n.__esModule?n:{default:n};var o=function(e){var t=e.A,r=2*e.roundIndex;t[0]^=i.default[r],t[1]^=i.default[r+1]};t.default=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=new Uint32Array([0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424]);t.default=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=a(r(100)),i=a(r(101)),o=a(r(28));function a(e){return e&&e.__esModule?e:{default:e}}var f=function(e){var t=e.A,r=e.C,a=e.W;(0,o.default)(t,1)(a,0);for(var f=0,s=0,c=0,u=32,d=0;d<24;d++){var h=n.default[d],p=i.default[d];(0,o.default)(t,h)(r,0),f=a[0],s=a[1],u=32-p,a[c=p<32?0:1]=f<>>u,a[(c+1)%2]=s<>>u,(0,o.default)(a,0)(t,h),(0,o.default)(r,0)(a,0)}};t.default=f},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=[10,7,11,17,18,3,5,16,8,21,24,4,15,23,19,13,12,2,20,14,22,9,6,1];t.default=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=[1,3,6,10,15,21,28,36,45,55,2,14,27,41,56,8,25,43,62,18,39,61,20,44];t.default=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,i=(n=r(28))&&n.__esModule?n:{default:n};var o=function(e){for(var t=e.A,r=e.C,n=e.D,o=e.W,a=0,f=0,s=0;s<5;s++){var c=2*s,u=2*(s+5),d=2*(s+10),h=2*(s+15),p=2*(s+20);r[c]=t[c]^t[u]^t[d]^t[h]^t[p],r[c+1]=t[c+1]^t[u+1]^t[d+1]^t[h+1]^t[p+1]}for(var l=0;l<5;l++){(0,i.default)(r,(l+1)%5)(o,0),a=o[0],f=o[1],o[0]=a<<1|f>>>31,o[1]=f<<1|a>>>31,n[2*l]=r[(l+4)%5*2]^o[0],n[2*l+1]=r[(l+4)%5*2+1]^o[1];for(var b=0;b<25;b+=5)t[2*(b+l)]^=n[2*l],t[2*(b+l)+1]^=n[2*l+1]}};t.default=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"compute",{enumerable:!0,get:function(){return n.compute}}),Object.defineProperty(t,"verify",{enumerable:!0,get:function(){return n.verify}}),t.default=void 0;var n=r(104),i={compute:n.compute,verify:n.verify};t.default=i},function(e,t,r){"use strict";var n=r(21),i=r(14);Object.defineProperty(t,"__esModule",{value:!0}),t.verify=t.compute=void 0;var o=i(r(2)),a=i(r(5)),f=i(r(105)),s=n(r(22)),c=i(r(23)),u=function(){var e=(0,a.default)(o.default.mark(function e(t,r){var n,i,a,c,u,h,p,l,b,y,m,v=arguments;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=v.length>2&&void 0!==v[2]?v[2]:"SHA-256",i=s.getWebCryptoAll(),a=s.getNodeCrypto(),c=!0,void 0===i||"function"!=typeof i.importKey||"function"!=typeof i.sign){e.next=38;break}if(void 0!==window.msCrypto){e.next=21;break}return e.prev=6,e.next=9,i.importKey("raw",t,{name:"HMAC",hash:{name:n}},!1,["sign","verify"]);case 9:return u=e.sent,e.next=12,i.sign({name:"HMAC",hash:{name:n}},u,r);case 12:return h=e.sent,e.abrupt("return",new Uint8Array(h));case 16:e.prev=16,e.t0=e.catch(6),c=!1;case 19:e.next=36;break;case 21:return e.prev=21,p=function(e,t,r,n,o){return new Promise(function(a,f){var s=i.importKey(e,t,r,n,o);s.oncomplete=function(e){a(e.target.result)},s.onerror=function(){f("KeyImportingFailed")}})},l=function(e,t,r){return new Promise(function(n,o){var a=i.sign({name:"HMAC",hash:{name:e}},t,r);a.oncomplete=function(e){n(new Uint8Array(e.target.result))},a.onerror=function(){o("ComputingHMACFailed")}})},e.next=26,p("raw",t,{name:"HMAC",hash:{name:n}},!1,["sign","verify"]);case 26:return b=e.sent,e.next=29,l(n,b,r);case 29:return y=e.sent,e.abrupt("return",new Uint8Array(y));case 33:e.prev=33,e.t1=e.catch(21),c=!1;case 36:e.next=50;break;case 38:if(void 0===a){e.next=49;break}return e.prev=39,m=a.createHmac(f.default.hashes[n].nodeName,t),e.abrupt("return",new Uint8Array(m.update(r).digest()));case 44:e.prev=44,e.t2=e.catch(39),c=!1;case 47:e.next=50;break;case 49:c=!1;case 50:if(c){e.next=60;break}return e.prev=51,e.next=54,d(t,r,n);case 54:return e.abrupt("return",e.sent);case 57:throw e.prev=57,e.t3=e.catch(51),new Error("UnsupportedEnvironments");case 60:case"end":return e.stop()}},e,null,[[6,16],[21,33],[39,44],[51,57]])}));return function(t,r){return e.apply(this,arguments)}}();t.compute=u;var d=function(){var e=(0,a.default)(o.default.mark(function e(t,r,n){var i,a,s,u,d,h,p,l;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=f.default.hashes[n].blockSize,a=f.default.hashes[n].hashSize,!(t.length>i)){e.next=6;break}return e.next=5,c.default.compute(t,n);case 5:t=e.sent;case 6:return(s=new Uint8Array(i)).set(t),u=s.map(function(e){return 255&(54^e)}),d=s.map(function(e){return 255&(92^e)}),(h=new Uint8Array(i+r.length)).set(u),h.set(r,i),e.next=15,c.default.compute(h,n);case 15:return p=e.sent,(l=new Uint8Array(i+a)).set(d),l.set(p,i),e.abrupt("return",c.default.compute(l,n));case 20:case"end":return e.stop()}},e)}));return function(t,r,n){return e.apply(this,arguments)}}(),h=function(){var e=(0,a.default)(o.default.mark(function e(t,r,n){var i,a,f=arguments;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=f.length>3&&void 0!==f[3]?f[3]:"SHA-256",n instanceof Uint8Array){e.next=3;break}throw new Error("InvalidInputMac");case 3:return e.next=5,u(t,r,i);case 5:return a=e.sent,e.abrupt("return",n.toString()===a.toString());case 7:case"end":return e.stop()}},e)}));return function(t,r,n){return e.apply(this,arguments)}}();t.verify=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default={hashes:{"SHA3-512":{nodeName:"sha3-512",hashSize:64,blockSize:72},"SHA3-384":{nodeName:"sha3-384",hashSize:48,blockSize:104},"SHA3-256":{nodeName:"sha3-256",hashSize:32,blockSize:136},"SHA3-224":{nodeName:"sha3-224",hashSize:28,blockSize:144},"SHA-256":{nodeName:"sha256",hashSize:32,blockSize:64},"SHA-384":{nodeName:"sha384",hashSize:48,blockSize:128},"SHA-512":{nodeName:"sha512",hashSize:64,blockSize:128},"SHA-1":{nodeName:"sha1",hashSize:20,blockSize:64},MD5:{nodeName:"md5",hashSize:16,blockSize:64}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default={hashes:{"SHA3-512":{hashSize:64},"SHA3-384":{hashSize:48},"SHA3-256":{hashSize:32},"SHA3-224":{hashSize:28},"SHA-256":{hashSize:32},"SHA-384":{hashSize:48},"SHA-512":{hashSize:64},"SHA-1":{hashSize:20},MD5:{hashSize:16}}}},function(e,t,r){"use strict";var n=r(21),i=r(14);Object.defineProperty(t,"__esModule",{value:!0}),t.unwrapKey=t.wrapKey=t.decrypt=t.encrypt=void 0;var o=i(r(2)),a=i(r(5)),f=n(r(22)),s=n(r(108)),c=n(r(109)),u=i(r(46)),d=function(e){var t=e.name,r=e.iv,n=e.tagLength;if(Object.keys(u.default.ciphers).indexOf(t)<0)throw new Error("UnsupportedAlgorithm");if(u.default.ciphers[t].ivLength){if(!(r instanceof Uint8Array))throw new Error("InvalidArguments");if(r.byteLength<2||r.byteLength>16)throw new Error("InvalidIVLength");if(u.default.ciphers[t].staticIvLength&&u.default.ciphers[t].ivLength!==r.byteLength)throw new Error("InvalidIVLength")}if(u.default.ciphers[t].tagLength&&n){if(!Number.isInteger(n))throw new Error("InvalidArguments");if(n<4||n>16)throw new Error("InvalidTagLength")}},h=function(){var e=(0,a.default)(o.default.mark(function e(t,r,n){var i,a,h,p,l,b,y,m;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.name,a=void 0===i?"AES-GCM":i,h=n.iv,p=n.additionalData,l=void 0===p?new Uint8Array([]):p,b=n.tagLength,t instanceof Uint8Array&&r instanceof Uint8Array){e.next=3;break}throw new Error("InvalidArguments");case 3:return d({name:a,iv:h,tagLength:b}),u.default.ciphers[a].tagLength&&!b&&(b=u.default.ciphers[a].tagLength),e.next=7,f.getWebCryptoAll();case 7:return y=e.sent,e.next=10,f.getNodeCrypto();case 10:if(m=e.sent,void 0===y||"function"!=typeof y.importKey||"function"!=typeof y.encrypt){e.next=15;break}return e.abrupt("return",c.encrypt(t,r,{name:a,iv:h,additionalData:l,tagLength:b},y));case 15:if(void 0===m){e.next=19;break}return e.abrupt("return",s.encrypt(t,r,{name:a,iv:h,additionalData:l,tagLength:b},m));case 19:throw new Error("UnsupportedEnvironment");case 20:case"end":return e.stop()}},e)}));return function(t,r,n){return e.apply(this,arguments)}}();t.encrypt=h;var p=function(){var e=(0,a.default)(o.default.mark(function e(t,r,n){var i,a,h,p,l,b,y,m;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.name,a=void 0===i?"AES-GCM":i,h=n.iv,p=n.additionalData,l=void 0===p?new Uint8Array([]):p,b=n.tagLength,t instanceof Uint8Array&&r instanceof Uint8Array){e.next=3;break}throw new Error("InvalidArguments");case 3:return d({name:a,iv:h,tagLength:b}),u.default.ciphers[a].tagLength&&!b&&(b=u.default.ciphers[a].tagLength),e.next=7,f.getWebCryptoAll();case 7:return y=e.sent,e.next=10,f.getNodeCrypto();case 10:if(m=e.sent,void 0===y||"function"!=typeof y.importKey||"function"!=typeof y.encrypt){e.next=15;break}return e.abrupt("return",c.decrypt(t,r,{name:a,iv:h,additionalData:l,tagLength:b},y));case 15:if(void 0===m){e.next=19;break}return e.abrupt("return",s.decrypt(t,r,{name:a,iv:h,additionalData:l,tagLength:b},m));case 19:throw new Error("UnsupportedEnvironment");case 20:case"end":return e.stop()}},e)}));return function(t,r,n){return e.apply(this,arguments)}}();t.decrypt=p;var l=function(){var e=(0,a.default)(o.default.mark(function e(t,r,n){var i,a,d,h,p;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.name,a=void 0===i?"AES-KW":i,t instanceof Uint8Array){e.next=3;break}throw new Error("NonUint8ArrayData");case 3:if(r instanceof Uint8Array){e.next=5;break}throw new Error("NonUint8ArrayKey");case 5:if(!(t.length%8>0)){e.next=7;break}throw new Error("WrappedKeyMustBeMultipleOf8");case 7:return e.next=9,f.getWebCryptoAll();case 9:return d=e.sent,e.next=12,f.getNodeCrypto();case 12:if(h=e.sent,p=u.default.wrapKeys["AES-KW"].defaultIV,void 0===d||"function"!=typeof d.importKey||"function"!=typeof d.wrapKey){e.next=18;break}return e.abrupt("return",c.wrapKey(t,r,{name:a,iv:p},d));case 18:if(void 0===h){e.next=22;break}return e.abrupt("return",s.wrapKey(t,r,{name:a,iv:p},h));case 22:throw new Error("UnsupportedEnvironment");case 23:case"end":return e.stop()}},e)}));return function(t,r,n){return e.apply(this,arguments)}}();t.wrapKey=l;var b=function(){var e=(0,a.default)(o.default.mark(function e(t,r,n){var i,a,d,h,p;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.name,a=void 0===i?"AES-KW":i,t instanceof Uint8Array){e.next=3;break}throw new Error("NonUint8ArrayData");case 3:if(r instanceof Uint8Array){e.next=5;break}throw new Error("NonUint8ArrayKey");case 5:return e.next=7,f.getWebCryptoAll();case 7:return d=e.sent,e.next=10,f.getNodeCrypto();case 10:if(h=e.sent,p=u.default.wrapKeys["AES-KW"].defaultIV,void 0===d||"function"!=typeof d.importKey||"function"!=typeof d.wrapKey){e.next=16;break}return e.abrupt("return",c.unwrapKey(t,r,{name:a,iv:p},d));case 16:if(void 0===h){e.next=20;break}return e.abrupt("return",s.unwrapKey(t,r,{name:a,iv:p},h));case 20:throw new Error("UnsupportedEnvironment");case 21:case"end":return e.stop()}},e)}));return function(t,r,n){return e.apply(this,arguments)}}();t.unwrapKey=b},function(e,t,r){"use strict";var n=r(14);Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=t.unwrapKey=t.wrapKey=void 0;var i=n(r(46));t.wrapKey=function(e,t,r,n){var i=r.name,a=void 0===i?"AES-KW":i,f=r.iv;return o(e,t,{name:a,iv:f},n,!0)};t.unwrapKey=function(e,t,r,n){var i=r.name,o=void 0===i?"AES-KW":i,f=r.iv;return a(e,t,{name:o,iv:f},n,!0)};var o=function(e,t,r,n){var o,a,s,c,u=r.name,d=r.iv,h=r.additionalData,p=r.tagLength,l=arguments.length>4&&void 0!==arguments[4]&&arguments[4],b=f(u,t.byteLength,l?i.default.wrapKeys:i.default.ciphers);switch(u){case"AES-GCM":(o=n.createCipheriv(b,t,d,{authTagLength:p})).setAAD(h);break;case"AES-CTR":if(0===d.length||d.length>16)throw new Error("InvalidIVLength");var y=new Uint8Array(16);y.set(d),y[15]+=1,o=n.createCipheriv(b,t,y);break;default:o=n.createCipheriv(b,t,d)}try{a=new Uint8Array(o.update(e)),s=new Uint8Array(o.final()),c=new Uint8Array([]),"AES-GCM"===u&&(c=new Uint8Array(o.getAuthTag()))}catch(e){throw new Error("NodeCrypto_EncryptionFailure")}var m=new Uint8Array(a.length+s.length+c.length);return m.set(a),m.set(s,a.length),m.set(c,a.length+s.length),m};t.encrypt=o;var a=function(e,t,r,n){var o,a,s,c,u=r.name,d=r.iv,h=r.additionalData,p=r.tagLength,l=arguments.length>4&&void 0!==arguments[4]&&arguments[4],b=f(u,t.byteLength,l?i.default.wrapKeys:i.default.ciphers);switch(u){case"AES-GCM":(o=n.createDecipheriv(b,t,d,{authTagLength:p})).setAAD(h),a=e.slice(0,e.length-p);var y=e.slice(e.length-p);o.setAuthTag(y);break;case"AES-CTR":if(0===d.length||d.length>16)throw new Error("InvalidIVLength");var m=new Uint8Array(16);m.set(d),m[15]+=1,o=n.createDecipheriv(b,t,m),a=e;break;default:o=n.createDecipheriv(b,t,d),a=e}try{s=o.update(a),c=o.final()}catch(e){throw new Error("NodeCrypto_DecryptionFailure")}var v=new Uint8Array(c.length+s.length);return v.set(s),v.set(c,s.length),v};t.decrypt=a;var f=function(e,t,r){var n=r[e].nodePrefix;return(n="".concat(n).concat((8*t).toString()))+r[e].nodeSuffix}},function(e,t,r){"use strict";var n=r(14);Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=t.unwrapKey=t.wrapKey=void 0;var i=n(r(2)),o=n(r(5)),a=function(){var e=(0,o.default)(i.default.mark(function e(t,r,n,o){var a,f,s,c,u,d;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.name,f=void 0===a?"AES-KW":a,s=n.iv,void 0!==window.msCrypto){e.next=20;break}return e.prev=2,e.next=5,o.importKey("raw",r,{name:f},!1,["wrapKey","unwrapKey"]);case 5:return c=e.sent,e.next=8,o.importKey("raw",t,{name:f},!0,["wrapKey","unwrapKey"]);case 8:return u=e.sent,e.next=11,o.wrapKey("raw",u,c,{name:f,iv:s});case 11:return d=e.sent,e.abrupt("return",new Uint8Array(d));case 15:throw e.prev=15,e.t0=e.catch(2),new Error("WebCrypto_FailedToWrapKey - ".concat(e.t0.message));case 18:e.next=21;break;case 20:throw new Error("ThrowAwayIeAsap");case 21:case"end":return e.stop()}},e,null,[[2,15]])}));return function(t,r,n,i){return e.apply(this,arguments)}}();t.wrapKey=a;var f=function(){var e=(0,o.default)(i.default.mark(function e(t,r,n,o){var a,f,s,c,u;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.name,f=void 0===a?"AES-KW":a,s=n.iv,void 0!==window.msCrypto){e.next=21;break}return e.prev=2,e.next=5,o.importKey("raw",r,{name:f},!1,["wrapKey","unwrapKey"]);case 5:return c=e.sent,e.next=8,o.unwrapKey("raw",t,c,{name:f,iv:s},{name:"AES-GCM"},!0,["encrypt","decrypt"]);case 8:return u=e.sent,e.t0=Uint8Array,e.next=12,o.exportKey("raw",u);case 12:return e.t1=e.sent,e.abrupt("return",new e.t0(e.t1));case 16:throw e.prev=16,e.t2=e.catch(2),new Error("WebCrypto_FailedToUnwrapKey - ".concat(e.t2.message));case 19:e.next=22;break;case 21:throw new Error("ThrowAwayMsIeAsap");case 22:case"end":return e.stop()}},e,null,[[2,16]])}));return function(t,r,n,i){return e.apply(this,arguments)}}();t.unwrapKey=f;var s=function(){var e=(0,o.default)(i.default.mark(function e(t,r,n,o){var a,f,s,c,p,l,b,y,m,v,g;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.name,f=void 0===a?"AES-GCM":a,s=n.iv,c=n.additionalData,p=n.tagLength,l=u({name:f,iv:s,additionalData:c,tagLength:p}),void 0!==window.msCrypto){e.next=18;break}return e.prev=3,e.next=6,o.importKey("raw",r,l,!1,["encrypt","decrypt"]);case 6:return b=e.sent,e.next=9,o.encrypt(l,b,t);case 9:return y=e.sent,e.abrupt("return",new Uint8Array(y));case 13:throw e.prev=13,e.t0=e.catch(3),new Error("WebCrypto_EncryptionFailure: ".concat(e.t0.message));case 16:e.next=38;break;case 18:return e.prev=18,e.next=21,d("raw",r,l,!1,["encrypt","decrypt"],o);case 21:return m=e.sent,e.next=24,h(l,m,t,o);case 24:if(v=e.sent,"AES-GCM"!==f){e.next=32;break}return(g=new Uint8Array(v.ciphertext.byteLength+v.tag.byteLength)).set(new Uint8Array(v.ciphertext)),g.set(new Uint8Array(v.tag),v.ciphertext.byteLength),e.abrupt("return",g);case 32:return e.abrupt("return",new Uint8Array(v));case 33:e.next=38;break;case 35:throw e.prev=35,e.t1=e.catch(18),new Error("ThrowAwayMsIeAsap: ".concat(e.t1.message));case 38:case"end":return e.stop()}},e,null,[[3,13],[18,35]])}));return function(t,r,n,i){return e.apply(this,arguments)}}();t.encrypt=s;var c=function(){var e=(0,o.default)(i.default.mark(function e(t,r,n,o){var a,f,s,c,h,l,b,y,m,v,g;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n.name,f=n.iv,s=n.additionalData,c=n.tagLength,h=u({name:a,iv:f,additionalData:s,tagLength:c}),window.msCrypto){e.next=18;break}return e.prev=3,e.next=6,o.importKey("raw",r,h,!1,["encrypt","decrypt"]);case 6:return l=e.sent,e.next=9,o.decrypt(h,l,t);case 9:return b=e.sent,e.abrupt("return",new Uint8Array(b));case 13:throw e.prev=13,e.t0=e.catch(3),new Error("WebCrypto_DecryptionFailure: ".concat(e.t0.message));case 16:e.next=39;break;case 18:return e.prev=18,e.next=21,d("raw",r,h,!1,["encrypt","decrypt"],o);case 21:if(y=e.sent,"AES-GCM"!==a){e.next=30;break}return v=t.slice(0,t.length-c),g=t.slice(t.length-c,t.length),e.next=27,p(Object.assign(h,{tag:g}),y,v,o);case 27:m=e.sent,e.next=33;break;case 30:return e.next=32,p(h,y,t,o);case 32:m=e.sent;case 33:return e.abrupt("return",new Uint8Array(m));case 36:throw e.prev=36,e.t1=e.catch(18),new Error("ThrowAwayMsIeAsap: ".concat(e.t1.message));case 39:case"end":return e.stop()}},e,null,[[3,13],[18,36]])}));return function(t,r,n,i){return e.apply(this,arguments)}}();t.decrypt=c;var u=function(e){var t=e.name,r=e.iv,n=e.additionalData,i=e.tagLength,o={};switch(t){case"AES-GCM":Object.assign(o,{name:t,iv:r,tagLength:8*i}),Object.assign(o,n.length>0?{additionalData:n}:{});break;case"AES-CBC":o.name=t,o.iv=r;break;case"AES-CTR":if(0===r.length||r.length>16)throw new Error("InvalidIVLength");o.name=t,o.counter=new Uint8Array(16),o.counter.set(r),o.counter[15]+=1,o.length=128}return o},d=function(e,t,r,n,i,o){return new Promise(function(a,f){var s=o.importKey(e,t,r,n,i);s.oncomplete=function(e){a(e.target.result)},s.onerror=function(){f("KeyImportingFailed")}})},h=function(e,t,r,n){return new Promise(function(i,o){var a=n.encrypt(e,t,r);a.oncomplete=function(e){i(e.target.result)},a.onerror=function(){o("EncryptionFailure")}})},p=function(e,t,r,n){return new Promise(function(i,o){var a=n.decrypt(e,t,r);a.oncomplete=function(e){i(e.target.result)},a.onerror=function(){o("DecryptionFailure")}})}},function(e,t,r){"use strict";var n=r(21);Object.defineProperty(t,"__esModule",{value:!0}),t.getRandomBytes=t.getRandomSampledString=t.getRandomAsciiString=t.getRandomString=void 0;var i=n(r(22));t.getRandomString=function(e){for(var t=o(e),r=o(e),n="",i=0;i2&&void 0!==arguments[2]&&arguments[2];if(Object.keys(b.a.namedCurves).indexOf(e.crv)<0)throw new Error("UnsupportedCurve");var n=S(e,{outputFormat:"binary",outputPublic:!0,compact:r}),i=b.a.publicKeyAlgorithms.EC.oid,o={unused:0,data:Array.from(n)},a=k.encode({type:"namedCurve",value:b.a.namedCurves[e.crv].oid},"der"),f={algorithm:i,parameters:a},s={};if("public"===t)s.subjectPublicKey=o,s.algorithm=f;else if("private"===t){var c=S(e,{outputFormat:"binary",outputPublic:!1,compact:r});s.version=0,s.privateKeyAlgorithm=f,s.privateKey=E.encode({version:1,privateKey:Array.from(c),parameters:a,publicKey:o},"der")}return s},x=function(e,t){if("public"===t){e.algorithm.parameters=k.decode(e.algorithm.parameters,"der");var r=new Uint8Array(e.subjectPublicKey.data),n=Object(b.b)(e.algorithm.parameters.value,b.a.namedCurves);if(n.length<1)throw new Error("UnsupportedCurve");return A(r,n[0],{outputPublic:!0})}if("private"===t){e.privateKeyAlgorithm.parameters=k.decode(e.privateKeyAlgorithm.parameters,"der");try{e.privateKey=E.decode(e.privateKey,"der")}catch(t){e.privateKey=j.decode(e.privateKey,"der")}var i=new Uint8Array(e.privateKey.privateKey),o=Object(b.b)(e.privateKeyAlgorithm.parameters.value,b.a.namedCurves);if(o.length<1)throw new Error("UnsupportedCurve");return A(i,o[0],{outputPublic:!1})}},k=l.a.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),E=l.a.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().any(),this.key("publicKey").explicit(1).optional().bitstr())}),j=l.a.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("publicKey").explicit(1).optional().bitstr())}),P=r(7),I=r.n(P),B=I.a.Buffer,O=function(e,t){var r={algorithm:b.a.publicKeyAlgorithms.RSA.oid,parameters:B.from([5,0])},n=m.a.encoder.decodeBase64Url(e.n),i=n.length,o=i%128==0?i:i+(128-i%128),a=new l.a.bignum(Object(w.a)(n,o)),f=new l.a.bignum(m.a.encoder.decodeBase64Url(e.e)),s={};return"public"===t?(s.subjectPublicKey={unused:0,data:U.encode({modulus:a,publicExponent:f},"der")},s.algorithm=r):"private"===t&&(s.version=0,s.privateKeyAlgorithm=r,s.privateKey=R.encode({version:0,modulus:a,publicExponent:f,privateExponent:new l.a.bignum(Object(w.a)(m.a.encoder.decodeBase64Url(e.d),o)),prime1:new l.a.bignum(Object(w.a)(m.a.encoder.decodeBase64Url(e.p),o)),prime2:new l.a.bignum(Object(w.a)(m.a.encoder.decodeBase64Url(e.q),o)),exponent1:new l.a.bignum(Object(w.a)(m.a.encoder.decodeBase64Url(e.dp),o)),exponent2:new l.a.bignum(Object(w.a)(m.a.encoder.decodeBase64Url(e.dq),o)),coefficient:new l.a.bignum(Object(w.a)(m.a.encoder.decodeBase64Url(e.qi),o))},"der")),s},C=function(e,t){if("public"===t){e.subjectPublicKey.data=U.decode(e.subjectPublicKey.data,"der");var r=e.subjectPublicKey.data.modulus,n=e.subjectPublicKey.data.publicExponent,i=r.byteLength(),o=i%128==0?i:i+(128-i%128);return r=new Uint8Array(r.toArray("be",o)),n=new Uint8Array(n.toArray("be",n.byteLength())),{kty:"RSA",n:m.a.encoder.encodeBase64Url(Object(w.f)(r)),e:m.a.encoder.encodeBase64Url(Object(w.f)(n))}}if("private"===t){e.privateKey=R.decode(e.privateKey,"der");var a={};a.modulus=e.privateKey.modulus;var f=a.modulus.byteLength(),s=f%128==0?f:f+(128-f%128);a.modulus=new Uint8Array(a.modulus.toArray("be",s)),a.publicExponent=new Uint8Array(e.privateKey.publicExponent.toArray("be",e.privateKey.publicExponent.byteLength())),a.privateExponent=new Uint8Array(e.privateKey.privateExponent.toArray("be",s));return["prime1","prime2","exponent1","exponent2","coefficient"].forEach(function(t){a[t]=new Uint8Array(e.privateKey[t].toArray("be",s>>1))}),{kty:"RSA",n:m.a.encoder.encodeBase64Url(Object(w.f)(a.modulus)),e:m.a.encoder.encodeBase64Url(Object(w.f)(a.publicExponent)),d:m.a.encoder.encodeBase64Url(Object(w.f)(a.privateExponent)),p:m.a.encoder.encodeBase64Url(Object(w.f)(a.prime1)),q:m.a.encoder.encodeBase64Url(Object(w.f)(a.prime2)),dp:m.a.encoder.encodeBase64Url(Object(w.f)(a.exponent1)),dq:m.a.encoder.encodeBase64Url(Object(w.f)(a.exponent2)),qi:m.a.encoder.encodeBase64Url(Object(w.f)(a.coefficient))}}},U=l.a.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())}),R=l.a.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int(),this.key("otherPrimeInfos").optional().use(z))}),z=l.a.define("OtherPrimeInfos",function(){this.seqof(T)}),T=l.a.define("OtherPrimeInfo",function(){this.seq().obj(this.key("prime").int(),this.key("exponent").int(),this.key("coefficient").int())}),L=r(6),N=r(12),K=r.n(N),q=r(17),D=r.n(q),F=r(29),H=r.n(F),W=r(18),Y=r.n(W),J=I.a.Buffer,V=l.a.bignum,Z=function(){var e=a()(i.a.mark(function e(t){var r,n,o,a,f=arguments;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===(r=f.length>1&&void 0!==f[1]?f[1]:{passphrase:""}).algorithm&&(r.algorithm="pbes2"),void 0===r.iterationCount&&(r.iterationCount=2048),"pbes2"!==r.algorithm){e.next=15;break}return void 0===r.cipher&&(r.cipher="aes256-cbc"),void 0===r.prf&&(r.prf="hmacWithSHA256"),n="pbkdf2",e.next=9,Q(t,r.passphrase,n,r.prf,r.iterationCount,r.cipher);case 9:return o=e.sent,e.next=12,X(o);case 12:return e.abrupt("return",e.sent);case 15:return e.next=17,te(t,r.passphrase,r.algorithm,r.iterationCount);case 17:return(a=e.sent).encryptionAlgorithm.algorithm=b.a.passwordBasedEncryptionSchemes[a.encryptionAlgorithm.algorithm].oid,a.encryptionAlgorithm.parameters=L.d.encode(a.encryptionAlgorithm.parameters,"der"),e.abrupt("return",L.a.encode(a,"der"));case 21:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),G=function(){var e=a()(i.a.mark(function e(t,r){var n;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if((n={}).encryptionAlgorithm={algorithm:Object(b.c)(t.encryptionAlgorithm.algorithm,b.a.passwordBasedEncryptionSchemes)},"pbes2"===n.encryptionAlgorithm.algorithm?n.encryptionAlgorithm.parameters=$(t.encryptionAlgorithm.parameters):n.encryptionAlgorithm.parameters=L.d.decode(t.encryptionAlgorithm.parameters,"der"),n.encryptedData=t.encryptedData,"pbes2"!==n.encryptionAlgorithm.algorithm){e.next=10;break}return e.next=7,ee(n,r);case 7:return e.abrupt("return",e.sent);case 10:return e.next=12,re(n,r);case 12:return e.abrupt("return",e.sent);case 13:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}(),X=function(e){var t={encryptionAlgorithm:{}};t.encryptionAlgorithm.algorithm=b.a.passwordBasedEncryptionSchemes[e.encryptionAlgorithm.algorithm].oid;var r=e.encryptionAlgorithm.parameters.keyDerivationFunc;if("pbkdf2"!==r.algorithm)throw new Error("UnsupportedKDF");r.parameters.prf.algorithm=b.a.pbkdf2Prfs[r.parameters.prf.algorithm].oid,r.parameters=L.g.encode(r.parameters,"der"),r.algorithm=b.a.keyDerivationFunctions[r.algorithm].oid;var n=e.encryptionAlgorithm.parameters.encryptionScheme;if(!(Object.keys(L.e).indexOf(n.algorithm)>=0))throw new Error("UnsupportedCipher");return n.parameters=L.e[n.algorithm].encode(n.parameters,"der"),n.algorithm=b.a.encryptionSchemes[n.algorithm].oid,t.encryptionAlgorithm.parameters=L.f.encode({keyDerivationFunc:r,encryptionScheme:n},"der"),t.encryptedData=e.encryptedData,L.a.encode(t,"der")},$=function(e){var t,r,n,i=L.f.decode(e,"der"),o=Object(b.c)(i.keyDerivationFunc.algorithm,b.a.keyDerivationFunctions);if("pbkdf2"!==o)throw new Error("UnsupportedKDF");var a=L.g.decode(i.keyDerivationFunc.parameters,"der");n={algorithm:Object(b.c)(a.prf.algorithm,b.a.pbkdf2Prfs),parameters:a.prf.parameters},t=a.iterationCount,r={type:a.salt.type,value:a.salt.value};var f=Object(b.c)(i.encryptionScheme.algorithm,b.a.encryptionSchemes);if(!(Object.keys(L.e).indexOf(f)>=0))throw new Error("UnsupportedCipher");return{keyDerivationFunc:{algorithm:o,parameters:{salt:r,iterationCount:t,prf:n}},encryptionScheme:{algorithm:f,parameters:L.e[f].decode(i.encryptionScheme.parameters,"der")}}},Q=function(){var e=a()(i.a.mark(function e(t,r,n,o,a,f){var s,c,u,d,h,p,l,y;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return s=m.a.encoder.stringToArrayBuffer(r),e.next=3,Y.a.getRandomBytes(b.a.keyDerivationFunctions[n].defaultSaltLen);case 3:if(c=e.sent,u=b.a.encryptionSchemes[f].keyLength,"pbkdf2"!==n){e.next=11;break}return e.next=8,D.a.pbkdf2(s,c,a,u,b.a.pbkdf2Prfs[o].hash);case 8:d=e.sent,e.next=12;break;case 11:throw new Error("UnsupportedKDF");case 12:if("des-ede3-cbc"!==f){e.next=23;break}return e.t0=J,e.next=16,Y.a.getRandomBytes(b.a.encryptionSchemes[f].ivLength);case 16:e.t1=e.sent,h=e.t0.from.call(e.t0,e.t1),l=K.a.CBC.instantiate(K.a.EDE),y=l.create({type:"encrypt",key:J.from(d),iv:h}),p=J.from(y.update(t).concat(y.final())),e.next=36;break;case 23:if("aes128-cbc"!==f&&"aes192-cbc"!==f&&"aes256-cbc"!==f){e.next=35;break}return e.next=26,Y.a.getRandomBytes(b.a.encryptionSchemes[f].ivLength);case 26:return h=e.sent,e.t2=J,e.next=30,H.a.encrypt(new Uint8Array(t),d,{name:"AES-CBC",iv:h});case 30:e.t3=e.sent,p=e.t2.from.call(e.t2,e.t3),h=J.from(h),e.next=36;break;case 35:throw new Error("UnsupportedCipher");case 36:return e.abrupt("return",{encryptedData:p,encryptionAlgorithm:{algorithm:"pbes2",parameters:{keyDerivationFunc:{algorithm:n,parameters:{salt:{type:"specified",value:J.from(c)},iterationCount:new V(a),prf:{algorithm:o,parameters:J.from([5,0])}}},encryptionScheme:{algorithm:f,parameters:h}}}});case 37:case"end":return e.stop()}},e)}));return function(t,r,n,i,o,a){return e.apply(this,arguments)}}(),ee=function(){var e=a()(i.a.mark(function e(t,r){var n,o,a,f,s,c,u,d,h,p,l,y,v;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.encryptionAlgorithm.parameters.keyDerivationFunc,o=t.encryptionAlgorithm.parameters.encryptionScheme,a=b.a.encryptionSchemes[o.algorithm].keyLength,"pbkdf2"!==n.algorithm){e.next=15;break}if(s=m.a.encoder.stringToArrayBuffer(r),"specified"===n.parameters.salt.type){e.next=7;break}throw new Error("UnsupportedSaltSource");case 7:return c=new Uint8Array(n.parameters.salt.value),u=n.parameters.iterationCount.toNumber(),d=n.parameters.prf.algorithm,e.next=12,D.a.pbkdf2(s,c,u,a,b.a.pbkdf2Prfs[d].hash);case 12:f=e.sent,e.next=16;break;case 15:throw new Error("UnsupportedKDF");case 16:if("des-ede3-cbc"!==o.algorithm){e.next=23;break}p=o.parameters,l=K.a.CBC.instantiate(K.a.EDE),y=l.create({type:"decrypt",key:f,iv:p}),h=J.from(y.update(t.encryptedData).concat(y.final())),e.next=33;break;case 23:if("aes128-cbc"!==o.algorithm&&"aes192-cbc"!==o.algorithm&&"aes256-cbc"!==o.algorithm){e.next=32;break}return v=new Uint8Array(o.parameters),e.t0=J,e.next=28,H.a.decrypt(new Uint8Array(t.encryptedData),f,{name:"AES-CBC",iv:v});case 28:e.t1=e.sent,h=e.t0.from.call(e.t0,e.t1),e.next=33;break;case 32:throw new Error("UnsupportedEncryptionAlgorithm");case 33:return e.abrupt("return",L.c.decode(h,"der"));case 34:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}(),te=function(){var e=a()(i.a.mark(function e(t,r,n,o){var a,f,s,c,u,d,h,p,l;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a=m.a.encoder.stringToArrayBuffer(r),e.next=3,Y.a.getRandomBytes(8);case 3:return f=e.sent,s=b.a.passwordBasedEncryptionSchemes[n].hash,e.next=7,D.a.pbkdf1(a,f,o,16,s);case 7:if(c=e.sent,u=c.slice(0,8),d=c.slice(8,16),"DES-CBC"!==b.a.passwordBasedEncryptionSchemes[n].encrypt){e.next=17;break}p=K.a.CBC.instantiate(K.a.DES),l=p.create({type:"encrypt",key:u,iv:d}),h=J.from(l.update(t).concat(l.final())),e.next=18;break;case 17:throw new Error("UnsupportedEncryptionAlgorithm");case 18:return e.abrupt("return",{encryptionAlgorithm:{algorithm:n,parameters:{salt:J.from(f),iterationCount:new V(o)}},encryptedData:h});case 19:case"end":return e.stop()}},e)}));return function(t,r,n,i){return e.apply(this,arguments)}}(),re=function(){var e=a()(i.a.mark(function e(t,r){var n,o,a,f,s,c,u,d,h,p;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=m.a.encoder.stringToArrayBuffer(r),o=new Uint8Array(t.encryptionAlgorithm.parameters.salt),a=b.a.passwordBasedEncryptionSchemes[t.encryptionAlgorithm.algorithm].hash,f=t.encryptionAlgorithm.parameters.iterationCount.toNumber(),e.next=6,D.a.pbkdf1(n,o,f,16,a);case 6:if(s=e.sent,c=s.slice(0,8),u=s.slice(8,16),"DES-CBC"!==b.a.passwordBasedEncryptionSchemes[t.encryptionAlgorithm.algorithm].encrypt){e.next=16;break}h=K.a.CBC.instantiate(K.a.DES),p=h.create({type:"decrypt",key:c,iv:u}),d=J.from(p.update(t.encryptedData).concat(p.final())),e.next=17;break;case 16:throw new Error("UnsupportedEncryptionAlgorithm");case 17:return e.abrupt("return",L.c.decode(d,"der"));case 18:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}(),ne=I.a.Buffer,ie=function(){var e=a()(i.a.mark(function e(t,r,n){var o,a,f,s,c,u,d,h;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n.outputPublic,a=n.compact,f=void 0!==a&&a,s=n.encOptions,c=Object(w.b)(t),u="boolean"==typeof o&&o?"public":c,"EC"===t.kty?d=M(t,u,f):"RSA"===t.kty&&(d=O(t,u)),"public"!==u){e.next=8;break}h=L.h.encode(d,"der"),e.next=14;break;case 8:if(h=L.c.encode(d,"der"),!(void 0!==s.passphrase&&s.passphrase.length>0)){e.next=14;break}return e.next=12,Z(h,s);case 12:h=e.sent,u="encryptedPrivate";case 14:return h=new Uint8Array(h),e.abrupt("return","pem"===r?m.a.formatter.binToPem(h,u):h);case 16:case"end":return e.stop()}},e)}));return function(t,r,n){return e.apply(this,arguments)}}(),oe=function(){var e=a()(i.a.mark(function e(t,r,n){var o,a,f,s,c,u;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:o=n.outputPublic,a=n.passphrase,f="pem"===r?m.a.formatter.pemToBin(t):t,e.prev=2,s=L.b.decode(ne.from(f),"der"),e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(2),new Error("FailedToDecodeKey");case 9:if("subjectPublicKeyInfo"!==s.type){e.next=14;break}c="public",s=s.value,e.next=26;break;case 14:if(c="boolean"==typeof o&&o?"public":"private","encryptedPrivateKeyInfo"!==s.type){e.next=21;break}return e.next=18,G(s.value,a);case 18:s=e.sent,e.next=26;break;case 21:if("oneAsymmetricKey"!==s.type){e.next=25;break}s=s.value,e.next=26;break;case 25:throw new Error("UnsupportedKeyStructure");case 26:if(!((u=Object(b.b)("public"===c?s.algorithm.algorithm:s.privateKeyAlgorithm.algorithm,b.a.publicKeyAlgorithms)).length<1)){e.next=29;break}throw new Error("UnsupportedKey");case 29:if("EC"!==u[0]){e.next=33;break}return e.abrupt("return",x(s,c));case 33:if("RSA"!==u[0]){e.next=37;break}return e.abrupt("return",C(s,c));case 37:throw new Error("InvalidKeyType");case 38:case"end":return e.stop()}},e,null,[[2,6]])}));return function(t,r,n){return e.apply(this,arguments)}}(),ae=function(){var e=a()(i.a.mark(function e(){var t,r,n,o=arguments;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:"pem",r=o.length>1?o[1]:void 0,n=o.length>2&&void 0!==o[2]?o[2]:{},!(["pem","der","oct"].indexOf(t)<0)){e.next=5;break}throw new Error("InvalidOutputForm");case 5:if("object"===h()(r)){e.next=7;break}throw new Error("InvalidJWKAsObject");case 7:if("EC"===r.kty||"RSA"===r.kty){e.next=9;break}throw new Error("UnsupportedKeyType");case 9:if(void 0===n.outputPublic||"boolean"==typeof n.outputPublic){e.next=11;break}throw new Error("outputPublicMustBeBoolean");case 11:if("EC"===r.key&&"boolean"!=typeof n.compact&&(n.compact=!1),"oct"===t&&"string"!==n.output&&(n.output="binary"),void 0===n.encryptParams&&(n.encryptParams={}),"der"!==t&&"pem"!==t||void 0!==n.encryptParams.passphrase||(n.encryptParams.passphrase=""),"der"!==t&&"pem"!==t){e.next=21;break}return e.next=18,ie(r,t,{outputPublic:n.outputPublic,compact:n.compact,encOptions:n.encryptParams});case 18:return e.abrupt("return",e.sent);case 21:if("oct"!==t||"EC"!==r.kty){e.next=25;break}return e.abrupt("return",S(r,{outputPublic:n.outputPublic,outputFormat:n.output,compact:n.compact}));case 25:throw new Error("UnsupportedConversion");case 26:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),fe=function(){var e=a()(i.a.mark(function e(t,r){var n,o=arguments;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:{},!(["pem","der","oct"].indexOf(t)<0)){e.next=3;break}throw new Error("InvalidInputForm");case 3:if("oct"!==t||n.namedCurve){e.next=5;break}throw new Error("InappropriateOptions");case 5:if(void 0===n.outputPublic||"boolean"==typeof n.outputPublic){e.next=7;break}throw new Error("outputPublicMustBeBoolean");case 7:if("der"!==t&&"pem"!==t||void 0!==n.passphrase||(n.passphrase=""),"der"!==t&&"pem"!==t){e.next=14;break}return e.next=11,oe(r,t,{outputPublic:n.outputPublic,passphrase:n.passphrase});case 11:return e.abrupt("return",e.sent);case 14:if("oct"!==t){e.next=18;break}return e.abrupt("return",A(r,n.namedCurve,{outputPublic:n.outputPublic}));case 18:throw new Error("UnsupportedConversion");case 19:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}(),se=r(23),ce=r.n(se),ue=I.a.Buffer,de=function(){var e=a()(i.a.mark(function e(t){var r,n,o,a,f,s=arguments;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=s.length>1&&void 0!==s[1]?s[1]:"SHA-256",n=s.length>2&&void 0!==s[2]?s[2]:"binary",!(["hex","binary"].indexOf(n)<0)){e.next=4;break}throw new Error("UnsupportedOutputFormat");case 4:if("EC"!==t.kty){e.next=8;break}o=JSON.stringify({crv:t.crv,kty:t.kty,x:t.x,y:t.y}),e.next=13;break;case 8:if("RSA"!==t.kty){e.next=12;break}o=JSON.stringify({e:t.e,kty:t.kty,n:t.n}),e.next=13;break;case 12:throw new Error("UnsupportedKeyType");case 13:return a=new Uint8Array(ue.from(o,"utf8")),e.next=16,ce.a.compute(a,r);case 16:if(f=e.sent,"hex"!==n){e.next=21;break}return e.abrupt("return",m.a.encoder.arrayBufferToHexString(f));case 21:if("base64"!==n){e.next=25;break}return e.abrupt("return",m.a.encoder.encodeBase64(f));case 25:if("binary"!==n){e.next=27;break}return e.abrupt("return",f);case 27:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),he=r(30),pe=r.n(he),le=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};s()(this,e);var i=pe()(r),o=pe()(n);if(this._jwk={},this._der=null,this._oct={},this._current={jwk:!1,der:!1,oct:!1},"jwk"===t)this._setJwk(i);else if("der"===t||"pem"===t){if("der"===t&&!(i instanceof Uint8Array))throw new Error("DerKeyMustBeUint8Array");if("pem"===t&&"string"!=typeof i)throw new Error("PemKeyMustBeString");this._setAsn1(i,t)}else{if("oct"!==t)throw new Error("UnsupportedType");if("string"!=typeof o.namedCurve)throw new Error("namedCurveMustBeSpecified");if(!(i instanceof Uint8Array))throw new Error("OctetKeyMustBeUint8Array");this._setSec1(i,o.namedCurve)}}var t,r,n,o;return u()(e,[{key:"_setJwk",value:function(e){this._type=Object(w.b)(e),this._jwk=e,this._isEncrypted&&(this._der=null),this._isEncrypted=!1,this._setCurrentStatus()}},{key:"_setAsn1",value:function(e,t){this._type=Object(w.e)(e,t)?"public":"private",this._isEncrypted=Object(w.d)(e,t),this._der="pem"===t?m.a.formatter.pemToBin(e):e,this._isEncrypted&&(this._jwk={},this._oct={}),this._setCurrentStatus()}},{key:"_setSec1",value:function(e,t){this._type=Object(w.c)(e,t),this._oct={namedCurve:t,key:e},this._isEncrypted&&(this._der=null),this._isEncrypted=!1,this._setCurrentStatus()}},{key:"_setCurrentStatus",value:function(){this._current.jwk="string"==typeof this._jwk.kty&&("RSA"===this._jwk.kty||"EC"===this._jwk.kty),this._current.der=void 0!==this._der&&this._der instanceof Uint8Array&&this._der.length>0,this._current.oct=void 0!==this._oct.key&&this._oct.key instanceof Uint8Array&&this._oct.key.length>0&&"string"==typeof this._oct.namedCurve}},{key:"export",value:(o=a()(i.a.mark(function e(){var t,r,n,o=arguments;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:"jwk",r=o.length>1&&void 0!==o[1]?o[1]:{},!(["pem","der","jwk","oct"].indexOf(t)<0)){e.next=4;break}throw new Error("UnsupportedFormat");case 4:if(!this._isEncrypted||"private"!==this._type){e.next=10;break}if("der"!==t&&"pem"!==t||0!==Object.keys(r).length||!this._current.der){e.next=9;break}return e.abrupt("return","pem"===t?m.a.formatter.binToPem(this._der,"encryptedPrivate"):this._der);case 9:throw new Error("DecryptionRequired");case 10:if(!this._current.jwk){e.next=14;break}n=this._jwk,e.next=27;break;case 14:if(!this._current.oct){e.next=20;break}return e.next=17,fe("oct",this._oct.key,{namedCurve:this._oct.namedCurve});case 17:n=e.sent,e.next=27;break;case 20:if(!this._current.der){e.next=26;break}return e.next=23,fe("der",this._der);case 23:n=e.sent,e.next=27;break;case 26:throw new Error("InvalidStatus");case 27:if(this._setJwk(n),"der"!==t&&"pem"!==t){e.next=35;break}return void 0===r.encryptParams&&(r.encryptParams={}),e.next=32,ae(t,n,{outputPublic:r.outputPublic,compact:r.compact,encryptParams:r.encryptParams});case 32:return e.abrupt("return",e.sent);case 35:if("oct"!==t){e.next=41;break}return e.next=38,ae(t,n,{outputPublic:r.outputPublic,output:r.output,compact:r.compact});case 38:return e.abrupt("return",e.sent);case 41:return e.abrupt("return",n);case 42:case"end":return e.stop()}},e,this)})),function(){return o.apply(this,arguments)})},{key:"encrypt",value:(n=a()(i.a.mark(function e(t){var r;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isEncrypted){e.next=2;break}throw new Error("AlreadyEncrypted");case 2:return r={encryptParams:{passphrase:t}},e.t0=this,e.next=6,this.export("der",r);case 6:return e.t1=e.sent,e.t0._setAsn1.call(e.t0,e.t1,"der"),e.abrupt("return",!0);case 9:case"end":return e.stop()}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"decrypt",value:(r=a()(i.a.mark(function e(t){var r;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._isEncrypted){e.next=2;break}throw new Error("NotEncrypted");case 2:if(!this._current.der||"string"!=typeof t){e.next=8;break}return e.next=5,fe("der",this._der,{passphrase:t});case 5:r=e.sent,e.next=9;break;case 8:throw new Error("FailedToDecrypt");case 9:return this._setJwk(r),e.abrupt("return",!0);case 11:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"getJwkThumbprint",value:(t=a()(i.a.mark(function e(){var t,r,n=arguments;return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:"SHA-256",r=n.length>1&&void 0!==n[1]?n[1]:"binary",!this._isEncrypted){e.next=4;break}throw new Error("DecryptionRequired");case 4:return e.t0=de,e.next=7,this.export("jwk");case 7:return e.t1=e.sent,e.t2=t,e.t3=r,e.next=12,(0,e.t0)(e.t1,e.t2,e.t3);case 12:return e.abrupt("return",e.sent);case 13:case"end":return e.stop()}},e,this)})),function(){return t.apply(this,arguments)})},{key:"keyType",get:function(){var e=this;if(this._isEncrypted)throw new Error("DecryptionRequired");return new Promise(function(){var t=a()(i.a.mark(function t(r,n){var o;return i.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.export("jwk").catch(function(e){n(e)});case 2:o=t.sent,r(o.kty);case 4:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}())}},{key:"jwkThumbprint",get:function(){return this.getJwkThumbprint()}},{key:"isEncrypted",get:function(){return this._isEncrypted}},{key:"isPrivate",get:function(){return"private"===this._type}},{key:"der",get:function(){return this.export("der")}},{key:"pem",get:function(){return this.export("pem")}},{key:"jwk",get:function(){return this.export("jwk")}},{key:"oct",get:function(){return this.export("oct",{output:"string"})}}]),e}();r.d(t,"Key",function(){return le});t.default={Key:le}}])});