diff --git a/README.md b/README.md index fc2ee97..4c07a42 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,8 @@ To configure the library: ```js const mcl = new MIRACLTrust({ - projectId: "", // required + projectUrl: "", // required + projectId: "", // required seed: "hexEncodedRandomNumberGeneratorSeed", // required userStorage: localStorage, // required deviceName: "Name of Device", diff --git a/cjs/client.cjs b/cjs/client.cjs index eaf481e..96739c4 100644 --- a/cjs/client.cjs +++ b/cjs/client.cjs @@ -23901,7 +23901,7 @@ HTTP.prototype.request = function (options, callback) { /** * @class * @param {Object} options - * @param {string} options.server - Server address, defaults to https://api.mpin.io + * @param {string} options.projectUrl - MIRACL Trust Project URL that is used for communication with the MIRACL Trust API * @param {string} options.projectId - MIRACL Trust Project ID * @param {string} options.seed - Hex encoded random number generator seed * @param {string} options.deviceName - Name of the current device @@ -23931,11 +23931,11 @@ function Client(options) { throw new Error("Invalid user storage"); } - if (!options.server) { - options.server = "https://api.mpin.io"; + if (!options.projectUrl) { + options.projectUrl = "https://api.mpin.io"; } else { // remove trailing slash from url, if there is one - options.server = options.server.replace(/\/$/, ""); + options.projectUrl = options.projectUrl.replace(/\/$/, ""); } // Ensure that default PIN lenght is between 4 and 6 @@ -23952,7 +23952,7 @@ function Client(options) { } // Set the client name using the current lib version and provided application info - options.clientName = "MIRACL Client.js/8.7.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); + options.clientName = "MIRACL Client.js/8.8.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); self.options = options; @@ -23987,7 +23987,7 @@ Client.prototype.fetchAccessId = function (userId, callback) { reqData; reqData = { - url: self.options.server + "/rps/v2/session", + url: self.options.projectUrl + "/rps/v2/session", type: "POST", data: { projectId: self.options.projectId, @@ -24016,7 +24016,7 @@ Client.prototype.fetchStatus = function (callback) { reqData; reqData = { - url: self.options.server + "/rps/v2/access", + url: self.options.projectUrl + "/rps/v2/access", type: "POST", data: { webOTT: self.session.webOTT @@ -24047,7 +24047,7 @@ Client.prototype.sendPushNotificationForAuth = function (userId, callback) { } reqData = { - url: self.options.server + "/pushauth?" + self._urlEncode(self.options.oidc), + url: self.options.projectUrl + "/pushauth?" + self._urlEncode(self.options.oidc), type: "POST", data: { prerollId: userId @@ -24083,7 +24083,7 @@ Client.prototype.sendVerificationEmail = function (userId, callback) { return callback(new Error("Empty user ID"), null); } - reqData.url = self.options.server + "/verification/email"; + reqData.url = self.options.projectUrl + "/verification/email"; reqData.type = "POST"; reqData.data = { userId: userId, @@ -24132,7 +24132,7 @@ Client.prototype.getActivationToken = function (verificationURI, callback) { return callback(new Error("Empty verification code"), null); } - reqData.url = self.options.server + "/verification/confirmation"; + reqData.url = self.options.projectUrl + "/verification/confirmation"; reqData.type = "POST"; reqData.data = { userId: params["user_id"], @@ -24222,7 +24222,7 @@ Client.prototype._createMPinID = function (userId, activationToken, keypair, cal var self = this, regData = {}; - regData.url = self.options.server + "/registration"; + regData.url = self.options.projectUrl + "/registration"; regData.type = "POST"; regData.data = { userId: userId, @@ -24371,7 +24371,7 @@ Client.prototype.generateQuickCode = function (userId, userPin, callback) { } self.http.request({ - url: self.options.server + "/verification/quickcode", + url: self.options.projectUrl + "/verification/quickcode", type: "POST", data: { projectId: self.options.projectId, @@ -24485,7 +24485,7 @@ Client.prototype._getPass1 = function (identityData, userPin, scope, X, SEC, cal U: res.U }; - self.http.request({ url: self.options.server + "/rps/v2/pass1", type: "POST", data: requestData }, callback); + self.http.request({ url: self.options.projectUrl + "/rps/v2/pass1", type: "POST", data: requestData }, callback); }; /** @@ -24520,7 +24520,7 @@ Client.prototype._getPass2 = function (identityData, scope, yHex, X, SEC, callba V: vHex }; - self.http.request({ url: self.options.server + "/rps/v2/pass2", type: "POST", data: requestData}, callback); + self.http.request({ url: self.options.projectUrl + "/rps/v2/pass2", type: "POST", data: requestData}, callback); }; Client.prototype._finishAuthentication = function (userId, userPin, scope, authOTT, callback) { @@ -24532,7 +24532,7 @@ Client.prototype._finishAuthentication = function (userId, userPin, scope, authO "wam": "dvs" }; - self.http.request({ url: self.options.server + "/rps/v2/authenticate", type: "POST", data: requestData }, function (err, result) { + self.http.request({ url: self.options.projectUrl + "/rps/v2/authenticate", type: "POST", data: requestData }, function (err, result) { if (err) { return callback(err, result); } diff --git a/cjs/promise.cjs b/cjs/promise.cjs index 59b82eb..7c2006c 100644 --- a/cjs/promise.cjs +++ b/cjs/promise.cjs @@ -23901,7 +23901,7 @@ HTTP.prototype.request = function (options, callback) { /** * @class * @param {Object} options - * @param {string} options.server - Server address, defaults to https://api.mpin.io + * @param {string} options.projectUrl - MIRACL Trust Project URL that is used for communication with the MIRACL Trust API * @param {string} options.projectId - MIRACL Trust Project ID * @param {string} options.seed - Hex encoded random number generator seed * @param {string} options.deviceName - Name of the current device @@ -23931,11 +23931,11 @@ function Client(options) { throw new Error("Invalid user storage"); } - if (!options.server) { - options.server = "https://api.mpin.io"; + if (!options.projectUrl) { + options.projectUrl = "https://api.mpin.io"; } else { // remove trailing slash from url, if there is one - options.server = options.server.replace(/\/$/, ""); + options.projectUrl = options.projectUrl.replace(/\/$/, ""); } // Ensure that default PIN lenght is between 4 and 6 @@ -23952,7 +23952,7 @@ function Client(options) { } // Set the client name using the current lib version and provided application info - options.clientName = "MIRACL Client.js/8.7.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); + options.clientName = "MIRACL Client.js/8.8.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); self.options = options; @@ -23987,7 +23987,7 @@ Client.prototype.fetchAccessId = function (userId, callback) { reqData; reqData = { - url: self.options.server + "/rps/v2/session", + url: self.options.projectUrl + "/rps/v2/session", type: "POST", data: { projectId: self.options.projectId, @@ -24016,7 +24016,7 @@ Client.prototype.fetchStatus = function (callback) { reqData; reqData = { - url: self.options.server + "/rps/v2/access", + url: self.options.projectUrl + "/rps/v2/access", type: "POST", data: { webOTT: self.session.webOTT @@ -24047,7 +24047,7 @@ Client.prototype.sendPushNotificationForAuth = function (userId, callback) { } reqData = { - url: self.options.server + "/pushauth?" + self._urlEncode(self.options.oidc), + url: self.options.projectUrl + "/pushauth?" + self._urlEncode(self.options.oidc), type: "POST", data: { prerollId: userId @@ -24083,7 +24083,7 @@ Client.prototype.sendVerificationEmail = function (userId, callback) { return callback(new Error("Empty user ID"), null); } - reqData.url = self.options.server + "/verification/email"; + reqData.url = self.options.projectUrl + "/verification/email"; reqData.type = "POST"; reqData.data = { userId: userId, @@ -24132,7 +24132,7 @@ Client.prototype.getActivationToken = function (verificationURI, callback) { return callback(new Error("Empty verification code"), null); } - reqData.url = self.options.server + "/verification/confirmation"; + reqData.url = self.options.projectUrl + "/verification/confirmation"; reqData.type = "POST"; reqData.data = { userId: params["user_id"], @@ -24222,7 +24222,7 @@ Client.prototype._createMPinID = function (userId, activationToken, keypair, cal var self = this, regData = {}; - regData.url = self.options.server + "/registration"; + regData.url = self.options.projectUrl + "/registration"; regData.type = "POST"; regData.data = { userId: userId, @@ -24371,7 +24371,7 @@ Client.prototype.generateQuickCode = function (userId, userPin, callback) { } self.http.request({ - url: self.options.server + "/verification/quickcode", + url: self.options.projectUrl + "/verification/quickcode", type: "POST", data: { projectId: self.options.projectId, @@ -24485,7 +24485,7 @@ Client.prototype._getPass1 = function (identityData, userPin, scope, X, SEC, cal U: res.U }; - self.http.request({ url: self.options.server + "/rps/v2/pass1", type: "POST", data: requestData }, callback); + self.http.request({ url: self.options.projectUrl + "/rps/v2/pass1", type: "POST", data: requestData }, callback); }; /** @@ -24520,7 +24520,7 @@ Client.prototype._getPass2 = function (identityData, scope, yHex, X, SEC, callba V: vHex }; - self.http.request({ url: self.options.server + "/rps/v2/pass2", type: "POST", data: requestData}, callback); + self.http.request({ url: self.options.projectUrl + "/rps/v2/pass2", type: "POST", data: requestData}, callback); }; Client.prototype._finishAuthentication = function (userId, userPin, scope, authOTT, callback) { @@ -24532,7 +24532,7 @@ Client.prototype._finishAuthentication = function (userId, userPin, scope, authO "wam": "dvs" }; - self.http.request({ url: self.options.server + "/rps/v2/authenticate", type: "POST", data: requestData }, function (err, result) { + self.http.request({ url: self.options.projectUrl + "/rps/v2/authenticate", type: "POST", data: requestData }, function (err, result) { if (err) { return callback(err, result); } diff --git a/dist/client.js b/dist/client.js index cd2c381..5d3a662 100644 --- a/dist/client.js +++ b/dist/client.js @@ -23902,7 +23902,7 @@ HTTP.prototype.request = function (options, callback) { /** * @class * @param {Object} options - * @param {string} options.server - Server address, defaults to https://api.mpin.io + * @param {string} options.projectUrl - MIRACL Trust Project URL that is used for communication with the MIRACL Trust API * @param {string} options.projectId - MIRACL Trust Project ID * @param {string} options.seed - Hex encoded random number generator seed * @param {string} options.deviceName - Name of the current device @@ -23932,11 +23932,11 @@ function Client(options) { throw new Error("Invalid user storage"); } - if (!options.server) { - options.server = "https://api.mpin.io"; + if (!options.projectUrl) { + options.projectUrl = "https://api.mpin.io"; } else { // remove trailing slash from url, if there is one - options.server = options.server.replace(/\/$/, ""); + options.projectUrl = options.projectUrl.replace(/\/$/, ""); } // Ensure that default PIN lenght is between 4 and 6 @@ -23953,7 +23953,7 @@ function Client(options) { } // Set the client name using the current lib version and provided application info - options.clientName = "MIRACL Client.js/8.7.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); + options.clientName = "MIRACL Client.js/8.8.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); self.options = options; @@ -23988,7 +23988,7 @@ Client.prototype.fetchAccessId = function (userId, callback) { reqData; reqData = { - url: self.options.server + "/rps/v2/session", + url: self.options.projectUrl + "/rps/v2/session", type: "POST", data: { projectId: self.options.projectId, @@ -24017,7 +24017,7 @@ Client.prototype.fetchStatus = function (callback) { reqData; reqData = { - url: self.options.server + "/rps/v2/access", + url: self.options.projectUrl + "/rps/v2/access", type: "POST", data: { webOTT: self.session.webOTT @@ -24048,7 +24048,7 @@ Client.prototype.sendPushNotificationForAuth = function (userId, callback) { } reqData = { - url: self.options.server + "/pushauth?" + self._urlEncode(self.options.oidc), + url: self.options.projectUrl + "/pushauth?" + self._urlEncode(self.options.oidc), type: "POST", data: { prerollId: userId @@ -24084,7 +24084,7 @@ Client.prototype.sendVerificationEmail = function (userId, callback) { return callback(new Error("Empty user ID"), null); } - reqData.url = self.options.server + "/verification/email"; + reqData.url = self.options.projectUrl + "/verification/email"; reqData.type = "POST"; reqData.data = { userId: userId, @@ -24133,7 +24133,7 @@ Client.prototype.getActivationToken = function (verificationURI, callback) { return callback(new Error("Empty verification code"), null); } - reqData.url = self.options.server + "/verification/confirmation"; + reqData.url = self.options.projectUrl + "/verification/confirmation"; reqData.type = "POST"; reqData.data = { userId: params["user_id"], @@ -24223,7 +24223,7 @@ Client.prototype._createMPinID = function (userId, activationToken, keypair, cal var self = this, regData = {}; - regData.url = self.options.server + "/registration"; + regData.url = self.options.projectUrl + "/registration"; regData.type = "POST"; regData.data = { userId: userId, @@ -24372,7 +24372,7 @@ Client.prototype.generateQuickCode = function (userId, userPin, callback) { } self.http.request({ - url: self.options.server + "/verification/quickcode", + url: self.options.projectUrl + "/verification/quickcode", type: "POST", data: { projectId: self.options.projectId, @@ -24486,7 +24486,7 @@ Client.prototype._getPass1 = function (identityData, userPin, scope, X, SEC, cal U: res.U }; - self.http.request({ url: self.options.server + "/rps/v2/pass1", type: "POST", data: requestData }, callback); + self.http.request({ url: self.options.projectUrl + "/rps/v2/pass1", type: "POST", data: requestData }, callback); }; /** @@ -24521,7 +24521,7 @@ Client.prototype._getPass2 = function (identityData, scope, yHex, X, SEC, callba V: vHex }; - self.http.request({ url: self.options.server + "/rps/v2/pass2", type: "POST", data: requestData}, callback); + self.http.request({ url: self.options.projectUrl + "/rps/v2/pass2", type: "POST", data: requestData}, callback); }; Client.prototype._finishAuthentication = function (userId, userPin, scope, authOTT, callback) { @@ -24533,7 +24533,7 @@ Client.prototype._finishAuthentication = function (userId, userPin, scope, authO "wam": "dvs" }; - self.http.request({ url: self.options.server + "/rps/v2/authenticate", type: "POST", data: requestData }, function (err, result) { + self.http.request({ url: self.options.projectUrl + "/rps/v2/authenticate", type: "POST", data: requestData }, function (err, result) { if (err) { return callback(err, result); } diff --git a/dist/client.min.js b/dist/client.min.js index 5516c52..54a6ad5 100644 --- a/dist/client.min.js +++ b/dist/client.min.js @@ -1 +1 @@ -var MIRACLTrust=function(){"use strict";function t(t){var n=function(i,e){i instanceof n?(this.a=new t.FP(i.a),this.b=new t.FP(i.b)):(this.a=new t.FP(i),this.b=new t.FP(e))};return n.prototype={reduce:function(){this.a.reduce(),this.b.reduce()},norm:function(){this.a.norm(),this.b.norm()},iszilch:function(){return this.reduce(),this.a.iszilch()&&this.b.iszilch()},isunity:function(){var n=new t.FP(1);return this.a.equals(n)&&this.b.iszilch()},cmove:function(t,n){this.a.cmove(t.a,n),this.b.cmove(t.b,n)},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)},getA:function(){return this.a.redc()},getB:function(){return this.b.redc()},set:function(t,n){this.a.copy(t),this.b.copy(n)},seta:function(t){this.a.copy(t),this.b.zero()},bset:function(t,n){this.a.bcopy(t),this.b.bcopy(n)},bseta:function(t){this.a.bcopy(t),this.b.zero()},copy:function(t){this.a.copy(t.a),this.b.copy(t.b)},zero:function(){this.a.zero(),this.b.zero()},one:function(){this.a.one(),this.b.zero()},neg:function(){var n=new t.FP(this.a),i=new t.FP(0);n.add(this.b),n.neg(),i.copy(n),i.add(this.b),this.b.copy(n),this.b.add(this.a),this.a.copy(i)},conj:function(){this.b.neg(),this.b.norm()},add:function(t){this.a.add(t.a),this.b.add(t.b)},sub:function(t){var i=new n(t);i.neg(),this.add(i)},rsub:function(t){this.neg(),this.add(t)},pmul:function(t){this.a.mul(t),this.b.mul(t)},imul:function(t){this.a.imul(t),this.b.imul(t)},sqr:function(){var n=new t.FP(this.a),i=new t.FP(this.a),e=new t.FP(this.b);n.add(this.b),i.add(this.a),i.norm(),this.b.mul(i),e.neg(),this.a.add(e),this.a.norm(),n.norm(),this.a.mul(n)},mul:function(n){var i,e,o,r,s,h,c=new t.BIG(0),u=new t.DBIG(0);c.rcopy(t.ROM_FIELD.Modulus),u.ucopy(c),(this.a.XES+this.b.XES)*(n.a.XES+n.b.XES)>t.FP.FEXCESS&&(this.a.XES>1&&this.a.reduce(),this.b.XES>1&&this.b.reduce()),i=t.BIG.mul(this.a.f,n.a.f),e=t.BIG.mul(this.b.f,n.b.f),o=new t.BIG(this.a.f),r=new t.BIG(n.a.f),o.add(this.b.f),o.norm(),r.add(n.b.f),r.norm(),s=t.BIG.mul(o,r),(h=new t.DBIG(0)).copy(i),h.add(e),e.rsub(u),i.add(e),i.norm(),s.sub(h),s.norm(),this.a.f.copy(t.FP.mod(i)),this.a.XES=3,this.b.f.copy(t.FP.mod(s)),this.b.XES=2},sqrt:function(){var n,i;return!!this.iszilch()||(n=new t.FP(this.b),i=new t.FP(this.a),n.sqr(),i.sqr(),n.add(i),1!=n.jacobi()?(this.zero(),!1):(n=n.sqrt(),i.copy(this.a),i.add(n),i.norm(),i.div2(),1!=i.jacobi()&&(i.copy(this.a),i.sub(n),i.norm(),i.div2(),1!=i.jacobi())?(this.zero(),!1):(i=i.sqrt(),this.a.copy(i),i.add(i),i.inverse(),this.b.mul(i),!0)))},toString:function(){return"["+this.a.toString()+","+this.b.toString()+"]"},inverse:function(){var n,i;this.norm(),n=new t.FP(this.a),i=new t.FP(this.b),n.sqr(),i.sqr(),n.add(i),n.inverse(),this.a.mul(n),n.neg(),n.norm(),this.b.mul(n)},div2:function(){this.a.div2(),this.b.div2()},times_i:function(){var n=new t.FP(this.a);this.a.copy(this.b),this.a.neg(),this.b.copy(n)},mul_ip:function(){var i=new n(this),e=new t.FP(this.a);this.a.copy(this.b),this.a.neg(),this.b.copy(e),this.add(i)},div_ip2:function(){var t=new n(0);this.norm(),t.a.copy(this.a),t.a.add(this.b),t.b.copy(this.b),t.b.sub(this.a),this.copy(t),this.norm()},div_ip:function(){var t=new n(0);this.norm(),t.a.copy(this.a),t.a.add(this.b),t.b.copy(this.b),t.b.sub(this.a),this.copy(t),this.norm(),this.div2()},pow:function(t){this.norm();var i,e=new n(1),o=new n(this);for(t.norm();i=t.parity(),t.fshr(1),1==i&&e.mul(o),!t.iszilch();)o.sqr();return e.reduce(),e}},n}function n(t){var n=function(i,e){i instanceof n?(this.a=new t.FP2(i.a),this.b=new t.FP2(i.b)):(this.a=new t.FP2(i),this.b=new t.FP2(e))};return n.prototype={reduce:function(){this.a.reduce(),this.b.reduce()},norm:function(){this.a.norm(),this.b.norm()},iszilch:function(){return this.reduce(),this.a.iszilch()&&this.b.iszilch()},isunity:function(){var n=new t.FP2(1);return this.a.equals(n)&&this.b.iszilch()},cmove:function(t,n){this.a.cmove(t.a,n),this.b.cmove(t.b,n)},isreal:function(){return this.b.iszilch()},real:function(){return this.a},geta:function(){return this.a},getb:function(){return this.b},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b)},zero:function(){this.a.zero(),this.b.zero()},one:function(){this.a.one(),this.b.zero()},set:function(t,n){this.a.copy(t),this.b.copy(n)},seta:function(t){this.a.copy(t),this.b.zero()},neg:function(){this.norm();var n=new t.FP2(this.a),i=new t.FP2(0);n.add(this.b),n.neg(),i.copy(n),i.add(this.b),this.b.copy(n),this.b.add(this.a),this.a.copy(i),this.norm()},conj:function(){this.b.neg(),this.norm()},nconj:function(){this.a.neg(),this.norm()},add:function(t){this.a.add(t.a),this.b.add(t.b)},sub:function(t){var i=new n(t);i.neg(),this.add(i)},rsub:function(t){this.neg(),this.add(t)},pmul:function(t){this.a.mul(t),this.b.mul(t)},imul:function(t){this.a.imul(t),this.b.imul(t)},sqr:function(){var n=new t.FP2(this.a),i=new t.FP2(this.b),e=new t.FP2(this.a);e.mul(this.b),n.add(this.b),n.norm(),i.mul_ip(),i.add(this.a),i.norm(),this.a.copy(n),this.a.mul(i),i.copy(e),i.mul_ip(),i.add(e),i.norm(),i.neg(),this.a.add(i),this.b.copy(e),this.b.add(e),this.norm()},mul:function(n){var i=new t.FP2(this.a),e=new t.FP2(this.b),o=new t.FP2(0),r=new t.FP2(this.b);i.mul(n.a),e.mul(n.b),o.copy(n.b),o.add(n.a),r.add(this.a),o.norm(),r.norm(),r.mul(o),o.copy(i),o.neg(),r.add(o),o.copy(e),o.neg(),this.b.copy(r),this.b.add(o),e.mul_ip(),this.a.copy(e),this.a.add(i),this.norm()},toString:function(){return"["+this.a.toString()+","+this.b.toString()+"]"},inverse:function(){this.norm();var n=new t.FP2(this.a),i=new t.FP2(this.b);n.sqr(),i.sqr(),i.mul_ip(),i.norm(),n.sub(i),n.inverse(),this.a.mul(n),n.neg(),n.norm(),this.b.mul(n)},times_i:function(){var n=new t.FP2(this.b),i=new t.FP2(this.b);n.times_i(),i.add(n),this.b.copy(this.a),this.a.copy(i),this.norm()},frob:function(t){this.a.conj(),this.b.conj(),this.b.mul(t)},pow:function(i){this.norm(),i.norm();for(var e,o=new n(this),r=new t.BIG(i),s=new n(1);e=r.parity(),r.fshr(1),1===e&&s.mul(o),!r.iszilch();)o.sqr();return s.reduce(),s},xtr_A:function(t,i,e){var o=new n(t),r=new n(t);o.sub(i),o.norm(),o.pmul(this.a),r.add(i),r.norm(),r.pmul(this.b),r.times_i(),this.copy(o),this.add(r),this.add(e),this.reduce()},xtr_D:function(){var t=new n(this);this.sqr(),t.conj(),t.add(t),this.sub(t),this.reduce()},xtr_pow:function(i){var e,o,r,s=new n(3),h=new n(this),c=new n(h),u=new n(0),a=new n(0);for(c.xtr_D(),i.norm(),e=i.parity(),(o=new t.BIG(i)).fshr(1),0===e&&(o.dec(1),o.norm()),r=o.nbits()-1;r>=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),m=new n(0),p=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),p++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(m)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(m)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(m)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(m)):(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),m=new n(0),p=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),p++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(m)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(m)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(m)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(m)):(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h>>8&255])^t.ROTL16(t.ftable[h[2]>>>16&255])^t.ROTL24(t.ftable[h[3]>>>24&255]),c[1]=this.fkey[r+1]^t.ftable[255&h[1]]^t.ROTL8(t.ftable[h[2]>>>8&255])^t.ROTL16(t.ftable[h[3]>>>16&255])^t.ROTL24(t.ftable[h[0]>>>24&255]),c[2]=this.fkey[r+2]^t.ftable[255&h[2]]^t.ROTL8(t.ftable[h[3]>>>8&255])^t.ROTL16(t.ftable[h[0]>>>16&255])^t.ROTL24(t.ftable[h[1]>>>24&255]),c[3]=this.fkey[r+3]^t.ftable[255&h[3]]^t.ROTL8(t.ftable[h[0]>>>8&255])^t.ROTL16(t.ftable[h[1]>>>16&255])^t.ROTL24(t.ftable[h[2]>>>24&255]),r+=4,o=0;o<4;o++)i=h[o],h[o]=c[o],c[o]=i;for(c[0]=this.fkey[r]^255&t.fbsub[255&h[0]]^t.ROTL8(255&t.fbsub[h[1]>>>8&255])^t.ROTL16(255&t.fbsub[h[2]>>>16&255])^t.ROTL24(255&t.fbsub[h[3]>>>24&255]),c[1]=this.fkey[r+1]^255&t.fbsub[255&h[1]]^t.ROTL8(255&t.fbsub[h[2]>>>8&255])^t.ROTL16(255&t.fbsub[h[3]>>>16&255])^t.ROTL24(255&t.fbsub[h[0]>>>24&255]),c[2]=this.fkey[r+2]^255&t.fbsub[255&h[2]]^t.ROTL8(255&t.fbsub[h[3]>>>8&255])^t.ROTL16(255&t.fbsub[h[0]>>>16&255])^t.ROTL24(255&t.fbsub[h[1]>>>24&255]),c[3]=this.fkey[r+3]^255&t.fbsub[255&h[3]]^t.ROTL8(255&t.fbsub[h[0]>>>8&255])^t.ROTL16(255&t.fbsub[h[1]>>>16&255])^t.ROTL24(255&t.fbsub[h[2]>>>24&255]),e=o=0;e<4;e++,o+=4)for(s=t.unpack(c[e]),r=0;r<4;r++)n[o+r]=s[r]},ecb_decrypt:function(n){var i,e,o,r,s=[],h=[],c=[];for(e=o=0;e<4;e++,o+=4){for(r=0;r<4;r++)s[r]=n[o+r];h[e]=t.pack(s),h[e]^=this.rkey[e]}for(r=4,e=1;e>>8&255])^t.ROTL16(t.rtable[h[2]>>>16&255])^t.ROTL24(t.rtable[h[1]>>>24&255]),c[1]=this.rkey[r+1]^t.rtable[255&h[1]]^t.ROTL8(t.rtable[h[0]>>>8&255])^t.ROTL16(t.rtable[h[3]>>>16&255])^t.ROTL24(t.rtable[h[2]>>>24&255]),c[2]=this.rkey[r+2]^t.rtable[255&h[2]]^t.ROTL8(t.rtable[h[1]>>>8&255])^t.ROTL16(t.rtable[h[0]>>>16&255])^t.ROTL24(t.rtable[h[3]>>>24&255]),c[3]=this.rkey[r+3]^t.rtable[255&h[3]]^t.ROTL8(t.rtable[h[2]>>>8&255])^t.ROTL16(t.rtable[h[1]>>>16&255])^t.ROTL24(t.rtable[h[0]>>>24&255]),r+=4,o=0;o<4;o++)i=h[o],h[o]=c[o],c[o]=i;for(c[0]=this.rkey[r]^255&t.rbsub[255&h[0]]^t.ROTL8(255&t.rbsub[h[3]>>>8&255])^t.ROTL16(255&t.rbsub[h[2]>>>16&255])^t.ROTL24(255&t.rbsub[h[1]>>>24&255]),c[1]=this.rkey[r+1]^255&t.rbsub[255&h[1]]^t.ROTL8(255&t.rbsub[h[0]>>>8&255])^t.ROTL16(255&t.rbsub[h[3]>>>16&255])^t.ROTL24(255&t.rbsub[h[2]>>>24&255]),c[2]=this.rkey[r+2]^255&t.rbsub[255&h[2]]^t.ROTL8(255&t.rbsub[h[1]>>>8&255])^t.ROTL16(255&t.rbsub[h[0]>>>16&255])^t.ROTL24(255&t.rbsub[h[3]>>>24&255]),c[3]=this.rkey[r+3]^255&t.rbsub[255&h[3]]^t.ROTL8(255&t.rbsub[h[2]>>>8&255])^t.ROTL16(255&t.rbsub[h[1]>>>16&255])^t.ROTL24(255&t.rbsub[h[0]>>>24&255]),e=o=0;e<4;e++,o+=4)for(s=t.unpack(c[e]),r=0;r<4;r++)n[o+r]=s[r]},encrypt:function(n){var i,e,o,r=[];switch(e=0,this.mode){case t.ECB:return this.ecb_encrypt(n),0;case t.CBC:for(o=0;o<16;o++)n[o]^=this.f[o];for(this.ecb_encrypt(n),o=0;o<16;o++)this.f[o]=n[o];return 0;case t.CFB1:case t.CFB2:case t.CFB4:for(i=this.mode-t.CFB1+1,o=0;o>>24},t.ROTL16=function(t){return t<<16|t>>>16},t.ROTL24=function(t){return t<<24|t>>>8},t.pack=function(t){return(255&t[3])<<24|(255&t[2])<<16|(255&t[1])<<8|255&t[0]},t.unpack=function(t){var n=[];return n[0]=255&t,n[1]=t>>>8&255,n[2]=t>>>16&255,n[3]=t>>>24&255,n},t.bmul=function(n,i){var e=255&i,o=255&t.ltab[255&n],r=255&t.ltab[e];return 0!==n&&0!==i?t.ptab[(o+r)%255]:0},t.SubByte=function(n){var i=t.unpack(n);return i[0]=t.fbsub[255&i[0]],i[1]=t.fbsub[255&i[1]],i[2]=t.fbsub[255&i[2]],i[3]=t.fbsub[255&i[3]],t.pack(i)},t.product=function(n,i){var e=t.unpack(n),o=t.unpack(i);return 255&(t.bmul(e[0],o[0])^t.bmul(e[1],o[1])^t.bmul(e[2],o[2])^t.bmul(e[3],o[3]))},t.InvMixCol=function(n){var i,e=[];return i=t.pack(t.InCo),e[3]=t.product(i,n),i=t.ROTL24(i),e[2]=t.product(i,n),i=t.ROTL24(i),e[1]=t.product(i,n),i=t.ROTL24(i),e[0]=t.product(i,n),t.pack(e)},t.InCo=[11,13,9,14],t.rco=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47],t.ptab=[1,3,5,15,17,51,85,255,26,46,114,150,161,248,19,53,95,225,56,72,216,115,149,164,247,2,6,10,30,34,102,170,229,52,92,228,55,89,235,38,106,190,217,112,144,171,230,49,83,245,4,12,20,60,68,204,79,209,104,184,211,110,178,205,76,212,103,169,224,59,77,215,98,166,241,8,24,40,120,136,131,158,185,208,107,189,220,127,129,152,179,206,73,219,118,154,181,196,87,249,16,48,80,240,11,29,39,105,187,214,97,163,254,25,43,125,135,146,173,236,47,113,147,174,233,32,96,160,251,22,58,78,210,109,183,194,93,231,50,86,250,21,63,65,195,94,226,61,71,201,64,192,91,237,44,116,156,191,218,117,159,186,213,100,172,239,42,126,130,157,188,223,122,142,137,128,155,182,193,88,232,35,101,175,234,37,111,177,200,67,197,84,252,31,33,99,165,244,7,9,27,45,119,153,176,203,70,202,69,207,74,222,121,139,134,145,168,227,62,66,198,81,243,14,18,54,90,238,41,123,141,140,143,138,133,148,167,242,13,23,57,75,221,124,132,151,162,253,28,36,108,180,199,82,246,1],t.ltab=[0,255,25,1,50,2,26,198,75,199,27,104,51,238,223,3,100,4,224,14,52,141,129,239,76,113,8,200,248,105,28,193,125,194,29,181,249,185,39,106,77,228,166,114,154,201,9,120,101,47,138,5,33,15,225,36,18,240,130,69,53,147,218,142,150,143,219,189,54,208,206,148,19,92,210,241,64,70,131,56,102,221,253,48,191,6,139,98,179,37,226,152,34,136,145,16,126,110,72,195,163,182,30,66,58,107,40,84,250,133,61,186,43,121,10,21,155,159,94,202,78,212,172,229,243,115,167,87,175,88,168,80,244,234,214,116,79,174,233,213,231,230,173,232,44,215,117,122,235,22,11,245,89,203,95,176,156,169,81,160,127,12,246,111,23,196,73,236,216,67,31,45,164,118,123,183,204,187,62,90,251,96,177,134,59,82,161,108,170,85,41,157,151,178,135,144,97,190,220,252,188,149,207,205,55,63,91,209,83,57,132,60,65,162,109,71,20,42,158,93,86,242,211,171,68,17,146,217,35,32,46,137,180,124,184,38,119,153,227,165,103,74,237,222,197,49,254,24,13,99,140,128,192,247,112,7],t.fbsub=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],t.rbsub=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],t.ftable=[2774754246,2222750968,2574743534,2373680118,234025727,3177933782,2976870366,1422247313,1345335392,50397442,2842126286,2099981142,436141799,1658312629,3870010189,2591454956,1170918031,2642575903,1086966153,2273148410,368769775,3948501426,3376891790,200339707,3970805057,1742001331,4255294047,3937382213,3214711843,4154762323,2524082916,1539358875,3266819957,486407649,2928907069,1780885068,1513502316,1094664062,49805301,1338821763,1546925160,4104496465,887481809,150073849,2473685474,1943591083,1395732834,1058346282,201589768,1388824469,1696801606,1589887901,672667696,2711000631,251987210,3046808111,151455502,907153956,2608889883,1038279391,652995533,1764173646,3451040383,2675275242,453576978,2659418909,1949051992,773462580,756751158,2993581788,3998898868,4221608027,4132590244,1295727478,1641469623,3467883389,2066295122,1055122397,1898917726,2542044179,4115878822,1758581177,0,753790401,1612718144,536673507,3367088505,3982187446,3194645204,1187761037,3653156455,1262041458,3729410708,3561770136,3898103984,1255133061,1808847035,720367557,3853167183,385612781,3309519750,3612167578,1429418854,2491778321,3477423498,284817897,100794884,2172616702,4031795360,1144798328,3131023141,3819481163,4082192802,4272137053,3225436288,2324664069,2912064063,3164445985,1211644016,83228145,3753688163,3249976951,1977277103,1663115586,806359072,452984805,250868733,1842533055,1288555905,336333848,890442534,804056259,3781124030,2727843637,3427026056,957814574,1472513171,4071073621,2189328124,1195195770,2892260552,3881655738,723065138,2507371494,2690670784,2558624025,3511635870,2145180835,1713513028,2116692564,2878378043,2206763019,3393603212,703524551,3552098411,1007948840,2044649127,3797835452,487262998,1994120109,1004593371,1446130276,1312438900,503974420,3679013266,168166924,1814307912,3831258296,1573044895,1859376061,4021070915,2791465668,2828112185,2761266481,937747667,2339994098,854058965,1137232011,1496790894,3077402074,2358086913,1691735473,3528347292,3769215305,3027004632,4199962284,133494003,636152527,2942657994,2390391540,3920539207,403179536,3585784431,2289596656,1864705354,1915629148,605822008,4054230615,3350508659,1371981463,602466507,2094914977,2624877800,555687742,3712699286,3703422305,2257292045,2240449039,2423288032,1111375484,3300242801,2858837708,3628615824,84083462,32962295,302911004,2741068226,1597322602,4183250862,3501832553,2441512471,1489093017,656219450,3114180135,954327513,335083755,3013122091,856756514,3144247762,1893325225,2307821063,2811532339,3063651117,572399164,2458355477,552200649,1238290055,4283782570,2015897680,2061492133,2408352771,4171342169,2156497161,386731290,3669999461,837215959,3326231172,3093850320,3275833730,2962856233,1999449434,286199582,3417354363,4233385128,3602627437,974525996],t.rtable=[1353184337,1399144830,3282310938,2522752826,3412831035,4047871263,2874735276,2466505547,1442459680,4134368941,2440481928,625738485,4242007375,3620416197,2151953702,2409849525,1230680542,1729870373,2551114309,3787521629,41234371,317738113,2744600205,3338261355,3881799427,2510066197,3950669247,3663286933,763608788,3542185048,694804553,1154009486,1787413109,2021232372,1799248025,3715217703,3058688446,397248752,1722556617,3023752829,407560035,2184256229,1613975959,1165972322,3765920945,2226023355,480281086,2485848313,1483229296,436028815,2272059028,3086515026,601060267,3791801202,1468997603,715871590,120122290,63092015,2591802758,2768779219,4068943920,2997206819,3127509762,1552029421,723308426,2461301159,4042393587,2715969870,3455375973,3586000134,526529745,2331944644,2639474228,2689987490,853641733,1978398372,971801355,2867814464,111112542,1360031421,4186579262,1023860118,2919579357,1186850381,3045938321,90031217,1876166148,4279586912,620468249,2548678102,3426959497,2006899047,3175278768,2290845959,945494503,3689859193,1191869601,3910091388,3374220536,0,2206629897,1223502642,2893025566,1316117100,4227796733,1446544655,517320253,658058550,1691946762,564550760,3511966619,976107044,2976320012,266819475,3533106868,2660342555,1338359936,2720062561,1766553434,370807324,179999714,3844776128,1138762300,488053522,185403662,2915535858,3114841645,3366526484,2233069911,1275557295,3151862254,4250959779,2670068215,3170202204,3309004356,880737115,1982415755,3703972811,1761406390,1676797112,3403428311,277177154,1076008723,538035844,2099530373,4164795346,288553390,1839278535,1261411869,4080055004,3964831245,3504587127,1813426987,2579067049,4199060497,577038663,3297574056,440397984,3626794326,4019204898,3343796615,3251714265,4272081548,906744984,3481400742,685669029,646887386,2764025151,3835509292,227702864,2613862250,1648787028,3256061430,3904428176,1593260334,4121936770,3196083615,2090061929,2838353263,3004310991,999926984,2809993232,1852021992,2075868123,158869197,4095236462,28809964,2828685187,1701746150,2129067946,147831841,3873969647,3650873274,3459673930,3557400554,3598495785,2947720241,824393514,815048134,3227951669,935087732,2798289660,2966458592,366520115,1251476721,4158319681,240176511,804688151,2379631990,1303441219,1414376140,3741619940,3820343710,461924940,3089050817,2136040774,82468509,1563790337,1937016826,776014843,1511876531,1389550482,861278441,323475053,2355222426,2047648055,2383738969,2302415851,3995576782,902390199,3991215329,1018251130,1507840668,1064563285,2043548696,3208103795,3939366739,1537932639,342834655,2262516856,2180231114,1053059257,741614648,1598071746,1925389590,203809468,2336832552,1100287487,1895934009,3736275976,2632234200,2428589668,1636092795,1890988757,1952214088,1113045200],t}(),h.GCM=function(t){var n=function(){this.table=new Array(128);for(var n=0;n<128;n++)this.table[n]=new Array(4);this.stateX=[],this.Y_0=[],this.counter=0,this.lenA=[],this.lenC=[],this.status=0,this.a=new t.AES};return n.ACCEPTING_HEADER=0,n.ACCEPTING_CIPHER=1,n.NOT_ACCEPTING_MORE=2,n.FINISHED=3,n.ENCRYPTING=0,n.DECRYPTING=1,n.prototype={precompute:function(t){var i,e,o,r=[];for(i=e=0;i<4;i++,e+=4)r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],this.table[0][i]=n.pack(r);for(i=1;i<128;i++){for(o=0,e=0;e<4;e++)this.table[i][e]=o|this.table[i-1][e]>>>1,o=this.table[i-1][e]<<31;0!==o&&(this.table[i][0]^=3774873600)}},gf2mul:function(){var t,i,e,o,r,s=[],h=[];for(s[0]=s[1]=s[2]=s[3]=0,i=8,e=0,t=0;t<128;t++){for(r=1+~(r=this.stateX[e]>>>--i&1),o=0;o<4;o++)s[o]^=this.table[t][o]&r;if(0===i&&(i=8,16==++e))break}for(t=i=0;t<4;t++,i+=4)h=n.unpack(s[t]),this.stateX[i]=h[0],this.stateX[i+1]=h[1],this.stateX[i+2]=h[2],this.stateX[i+3]=h[3]},wrap:function(){var t,i,e=[],o=[],r=[];for(e[0]=this.lenA[0]<<3|(3758096384&this.lenA[1])>>>29,e[1]=this.lenA[1]<<3,e[2]=this.lenC[0]<<3|(3758096384&this.lenC[1])>>>29,e[3]=this.lenC[1]<<3,t=i=0;t<4;t++,i+=4)r=n.unpack(e[t]),o[i]=r[0],o[i+1]=r[1],o[i+2]=r[2],o[i+3]=r[3];for(t=0;t<16;t++)this.stateX[t]^=o[t];this.gf2mul()},init:function(i,e,o,r){var s,h=[],c=[];for(s=0;s<16;s++)h[s]=0,this.stateX[s]=0;if(this.a.init(t.AES.ECB,i,e,r),this.a.ecb_encrypt(h),this.precompute(h),this.lenA[0]=this.lenC[0]=this.lenA[1]=this.lenC[1]=0,12==o){for(s=0;s<12;s++)this.a.f[s]=r[s];for(c=n.unpack(1),this.a.f[12]=c[0],this.a.f[13]=c[1],this.a.f[14]=c[2],this.a.f[15]=c[3],s=0;s<16;s++)this.Y_0[s]=this.a.f[s]}else{for(this.status=n.ACCEPTING_CIPHER,this.ghash(r,o),this.wrap(),s=0;s<16;s++)this.a.f[s]=this.stateX[s],this.Y_0[s]=this.a.f[s],this.stateX[s]=0;this.lenA[0]=this.lenC[0]=this.lenA[1]=this.lenC[1]=0}this.status=n.ACCEPTING_HEADER},add_header:function(t,i){var e,o=0;if(this.status!=n.ACCEPTING_HEADER)return!1;for(;o>>8&255,n[1]=t>>>16&255,n[0]=t>>>24&255,n},n.hex2bytes=function(t){var n,i=t.length,e=[];for(n=0;n>>0)+(t.bot>>>0),i=n>>>0,e=(this.top>>>0)+(t.top>>>0);return this.bot=i,this.top=i!=n?e+1>>>0:e,this},copy:function(){return new t(this.top,this.bot)},shlb:function(){var t=this.bot>>>24;return this.top=t+(this.top<<8),this.bot<<=8,this}},t}(),h.HASH256=function(){var t=function(){this.length=[],this.h=[],this.w=[],this.init()};return t.prototype={transform:function(){var n,i,e,o,r,s,h,c,u,a,f;for(f=16;f<64;f++)this.w[f]=t.theta1(this.w[f-2])+this.w[f-7]+t.theta0(this.w[f-15])+this.w[f-16]|0;for(n=this.h[0],i=this.h[1],e=this.h[2],o=this.h[3],r=this.h[4],s=this.h[5],h=this.h[6],c=this.h[7],f=0;f<64;f++)u=c+t.Sig1(r)+t.Ch(r,s,h)+t.HK[f]+this.w[f]|0,a=t.Sig0(n)+t.Maj(n,i,e)|0,c=h,h=s,s=r,r=o+u|0,o=e,e=i,i=n,n=u+a|0;this.h[0]+=n,this.h[1]+=i,this.h[2]+=e,this.h[3]+=o,this.h[4]+=r,this.h[5]+=s,this.h[6]+=h,this.h[7]+=c},init:function(){var n;for(n=0;n<64;n++)this.w[n]=0;this.length[0]=this.length[1]=0,this.h[0]=t.H[0],this.h[1]=t.H[1],this.h[2]=t.H[2],this.h[3]=t.H[3],this.h[4]=t.H[4],this.h[5]=t.H[5],this.h[6]=t.H[6],this.h[7]=t.H[7]},process:function(t){var n;n=(this.length[0]>>>5)%16,this.w[n]<<=8,this.w[n]|=255&t,this.length[0]+=8,4294967295&this.length[0]||(this.length[1]++,this.length[0]=0),this.length[0]%512==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var n,i,e,o=[];for(n=this.length[0],i=this.length[1],this.process(128);this.length[0]%512!=448;)this.process(0);for(this.w[14]=i,this.w[15]=n,this.transform(),e=0;e>>2]>>8*(3-e%4)&255;return this.init(),o}},t.S=function(t,n){return n>>>t|n<<32-t},t.R=function(t,n){return n>>>t},t.Ch=function(t,n,i){return t&n^~t&i},t.Maj=function(t,n,i){return t&n^t&i^n&i},t.Sig0=function(n){return t.S(2,n)^t.S(13,n)^t.S(22,n)},t.Sig1=function(n){return t.S(6,n)^t.S(11,n)^t.S(25,n)},t.theta0=function(n){return t.S(7,n)^t.S(18,n)^t.R(3,n)},t.theta1=function(n){return t.S(17,n)^t.S(19,n)^t.R(10,n)},t.len=32,t.H=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],t.HK=[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],t}(),h.HASH384=function(t){var n=function(){this.length=[],this.h=[],this.w=[],this.init()};return n.prototype={transform:function(){var t,i,e,o,r,s,h,c,u,a,f;for(f=16;f<80;f++)this.w[f]=n.theta1(this.w[f-2]).add(this.w[f-7]).add(n.theta0(this.w[f-15])).add(this.w[f-16]);for(t=this.h[0].copy(),i=this.h[1].copy(),e=this.h[2].copy(),o=this.h[3].copy(),r=this.h[4].copy(),s=this.h[5].copy(),h=this.h[6].copy(),c=this.h[7].copy(),f=0;f<80;f++)(u=c.copy()).add(n.Sig1(r)).add(n.Ch(r,s,h)).add(n.HK[f]).add(this.w[f]),(a=n.Sig0(t)).add(n.Maj(t,i,e)),c=h,h=s,s=r,(r=o.copy()).add(u),o=e,e=i,i=t,(t=u.copy()).add(a);this.h[0].add(t),this.h[1].add(i),this.h[2].add(e),this.h[3].add(o),this.h[4].add(r),this.h[5].add(s),this.h[6].add(h),this.h[7].add(c)},init:function(){var i;for(i=0;i<80;i++)this.w[i]=new t.UInt64(0,0);this.length[0]=new t.UInt64(0,0),this.length[1]=new t.UInt64(0,0),this.h[0]=n.H[0].copy(),this.h[1]=n.H[1].copy(),this.h[2]=n.H[2].copy(),this.h[3]=n.H[3].copy(),this.h[4]=n.H[4].copy(),this.h[5]=n.H[5].copy(),this.h[6]=n.H[6].copy(),this.h[7]=n.H[7].copy()},process:function(n){var i,e;i=(this.length[0].bot>>>6)%16,this.w[i].shlb(),this.w[i].bot|=255&n,e=new t.UInt64(0,8),this.length[0].add(e),0===this.length[0].top&&0==this.length[0].bot&&(e=new t.UInt64(0,1),this.length[1].add(e)),this.length[0].bot%1024==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var t,i,e,o=[];for(t=this.length[0].copy(),i=this.length[1].copy(),this.process(128);this.length[0].bot%1024!=896;)this.process(0);for(this.w[14]=i,this.w[15]=t,this.transform(),e=0;e>>3]).bot;return this.init(),o}},n.S=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n|i.bot<<32-n,i.bot>>>n|i.top<<32-n):new t.UInt64(i.bot>>>n-32|i.top<<64-n,i.top>>>n-32|i.bot<<64-n)},n.R=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n,i.bot>>>n|i.top<<32-n):new t.UInt64(0,i.top>>>n-32)},n.Ch=function(n,i,e){return new t.UInt64(n.top&i.top^~n.top&e.top,n.bot&i.bot^~n.bot&e.bot)},n.Maj=function(n,i,e){return new t.UInt64(n.top&i.top^n.top&e.top^i.top&e.top,n.bot&i.bot^n.bot&e.bot^i.bot&e.bot)},n.Sig0=function(i){var e=n.S(28,i),o=n.S(34,i),r=n.S(39,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.Sig1=function(i){var e=n.S(14,i),o=n.S(18,i),r=n.S(41,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta0=function(i){var e=n.S(1,i),o=n.S(8,i),r=n.R(7,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta1=function(i){var e=n.S(19,i),o=n.S(61,i),r=n.R(6,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.len=48,n.H=[new t.UInt64(3418070365,3238371032),new t.UInt64(1654270250,914150663),new t.UInt64(2438529370,812702999),new t.UInt64(355462360,4144912697),new t.UInt64(1731405415,4290775857),new t.UInt64(2394180231,1750603025),new t.UInt64(3675008525,1694076839),new t.UInt64(1203062813,3204075428)],n.HK=[new t.UInt64(1116352408,3609767458),new t.UInt64(1899447441,602891725),new t.UInt64(3049323471,3964484399),new t.UInt64(3921009573,2173295548),new t.UInt64(961987163,4081628472),new t.UInt64(1508970993,3053834265),new t.UInt64(2453635748,2937671579),new t.UInt64(2870763221,3664609560),new t.UInt64(3624381080,2734883394),new t.UInt64(310598401,1164996542),new t.UInt64(607225278,1323610764),new t.UInt64(1426881987,3590304994),new t.UInt64(1925078388,4068182383),new t.UInt64(2162078206,991336113),new t.UInt64(2614888103,633803317),new t.UInt64(3248222580,3479774868),new t.UInt64(3835390401,2666613458),new t.UInt64(4022224774,944711139),new t.UInt64(264347078,2341262773),new t.UInt64(604807628,2007800933),new t.UInt64(770255983,1495990901),new t.UInt64(1249150122,1856431235),new t.UInt64(1555081692,3175218132),new t.UInt64(1996064986,2198950837),new t.UInt64(2554220882,3999719339),new t.UInt64(2821834349,766784016),new t.UInt64(2952996808,2566594879),new t.UInt64(3210313671,3203337956),new t.UInt64(3336571891,1034457026),new t.UInt64(3584528711,2466948901),new t.UInt64(113926993,3758326383),new t.UInt64(338241895,168717936),new t.UInt64(666307205,1188179964),new t.UInt64(773529912,1546045734),new t.UInt64(1294757372,1522805485),new t.UInt64(1396182291,2643833823),new t.UInt64(1695183700,2343527390),new t.UInt64(1986661051,1014477480),new t.UInt64(2177026350,1206759142),new t.UInt64(2456956037,344077627),new t.UInt64(2730485921,1290863460),new t.UInt64(2820302411,3158454273),new t.UInt64(3259730800,3505952657),new t.UInt64(3345764771,106217008),new t.UInt64(3516065817,3606008344),new t.UInt64(3600352804,1432725776),new t.UInt64(4094571909,1467031594),new t.UInt64(275423344,851169720),new t.UInt64(430227734,3100823752),new t.UInt64(506948616,1363258195),new t.UInt64(659060556,3750685593),new t.UInt64(883997877,3785050280),new t.UInt64(958139571,3318307427),new t.UInt64(1322822218,3812723403),new t.UInt64(1537002063,2003034995),new t.UInt64(1747873779,3602036899),new t.UInt64(1955562222,1575990012),new t.UInt64(2024104815,1125592928),new t.UInt64(2227730452,2716904306),new t.UInt64(2361852424,442776044),new t.UInt64(2428436474,593698344),new t.UInt64(2756734187,3733110249),new t.UInt64(3204031479,2999351573),new t.UInt64(3329325298,3815920427),new t.UInt64(3391569614,3928383900),new t.UInt64(3515267271,566280711),new t.UInt64(3940187606,3454069534),new t.UInt64(4118630271,4000239992),new t.UInt64(116418474,1914138554),new t.UInt64(174292421,2731055270),new t.UInt64(289380356,3203993006),new t.UInt64(460393269,320620315),new t.UInt64(685471733,587496836),new t.UInt64(852142971,1086792851),new t.UInt64(1017036298,365543100),new t.UInt64(1126000580,2618297676),new t.UInt64(1288033470,3409855158),new t.UInt64(1501505948,4234509866),new t.UInt64(1607167915,987167468),new t.UInt64(1816402316,1246189591)],n}(h),h.HASH512=function(t){var n=function(){this.length=[],this.h=[],this.w=[],this.init()};return n.prototype={transform:function(){var t,i,e,o,r,s,h,c,u,a,f;for(f=16;f<80;f++)this.w[f]=n.theta1(this.w[f-2]).add(this.w[f-7]).add(n.theta0(this.w[f-15])).add(this.w[f-16]);for(t=this.h[0].copy(),i=this.h[1].copy(),e=this.h[2].copy(),o=this.h[3].copy(),r=this.h[4].copy(),s=this.h[5].copy(),h=this.h[6].copy(),c=this.h[7].copy(),f=0;f<80;f++)(u=c.copy()).add(n.Sig1(r)).add(n.Ch(r,s,h)).add(n.HK[f]).add(this.w[f]),(a=n.Sig0(t)).add(n.Maj(t,i,e)),c=h,h=s,s=r,(r=o.copy()).add(u),o=e,e=i,i=t,(t=u.copy()).add(a);this.h[0].add(t),this.h[1].add(i),this.h[2].add(e),this.h[3].add(o),this.h[4].add(r),this.h[5].add(s),this.h[6].add(h),this.h[7].add(c)},init:function(){var i;for(i=0;i<80;i++)this.w[i]=new t.UInt64(0,0);this.length[0]=new t.UInt64(0,0),this.length[1]=new t.UInt64(0,0),this.h[0]=n.H[0].copy(),this.h[1]=n.H[1].copy(),this.h[2]=n.H[2].copy(),this.h[3]=n.H[3].copy(),this.h[4]=n.H[4].copy(),this.h[5]=n.H[5].copy(),this.h[6]=n.H[6].copy(),this.h[7]=n.H[7].copy()},process:function(n){var i,e;i=(this.length[0].bot>>>6)%16,this.w[i].shlb(),this.w[i].bot|=255&n,e=new t.UInt64(0,8),this.length[0].add(e),0===this.length[0].top&&0==this.length[0].bot&&(e=new t.UInt64(0,1),this.length[1].add(e)),this.length[0].bot%1024==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var t,i,e,o=[];for(t=this.length[0].copy(),i=this.length[1].copy(),this.process(128);this.length[0].bot%1024!=896;)this.process(0);for(this.w[14]=i,this.w[15]=t,this.transform(),e=0;e>>3]).bot;return this.init(),o}},n.S=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n|i.bot<<32-n,i.bot>>>n|i.top<<32-n):new t.UInt64(i.bot>>>n-32|i.top<<64-n,i.top>>>n-32|i.bot<<64-n)},n.R=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n,i.bot>>>n|i.top<<32-n):new t.UInt64(0,i.top>>>n-32)},n.Ch=function(n,i,e){return new t.UInt64(n.top&i.top^~n.top&e.top,n.bot&i.bot^~n.bot&e.bot)},n.Maj=function(n,i,e){return new t.UInt64(n.top&i.top^n.top&e.top^i.top&e.top,n.bot&i.bot^n.bot&e.bot^i.bot&e.bot)},n.Sig0=function(i){var e=n.S(28,i),o=n.S(34,i),r=n.S(39,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.Sig1=function(i){var e=n.S(14,i),o=n.S(18,i),r=n.S(41,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta0=function(i){var e=n.S(1,i),o=n.S(8,i),r=n.R(7,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta1=function(i){var e=n.S(19,i),o=n.S(61,i),r=n.R(6,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.len=64,n.H=[new t.UInt64(1779033703,4089235720),new t.UInt64(3144134277,2227873595),new t.UInt64(1013904242,4271175723),new t.UInt64(2773480762,1595750129),new t.UInt64(1359893119,2917565137),new t.UInt64(2600822924,725511199),new t.UInt64(528734635,4215389547),new t.UInt64(1541459225,327033209)],n.HK=[new t.UInt64(1116352408,3609767458),new t.UInt64(1899447441,602891725),new t.UInt64(3049323471,3964484399),new t.UInt64(3921009573,2173295548),new t.UInt64(961987163,4081628472),new t.UInt64(1508970993,3053834265),new t.UInt64(2453635748,2937671579),new t.UInt64(2870763221,3664609560),new t.UInt64(3624381080,2734883394),new t.UInt64(310598401,1164996542),new t.UInt64(607225278,1323610764),new t.UInt64(1426881987,3590304994),new t.UInt64(1925078388,4068182383),new t.UInt64(2162078206,991336113),new t.UInt64(2614888103,633803317),new t.UInt64(3248222580,3479774868),new t.UInt64(3835390401,2666613458),new t.UInt64(4022224774,944711139),new t.UInt64(264347078,2341262773),new t.UInt64(604807628,2007800933),new t.UInt64(770255983,1495990901),new t.UInt64(1249150122,1856431235),new t.UInt64(1555081692,3175218132),new t.UInt64(1996064986,2198950837),new t.UInt64(2554220882,3999719339),new t.UInt64(2821834349,766784016),new t.UInt64(2952996808,2566594879),new t.UInt64(3210313671,3203337956),new t.UInt64(3336571891,1034457026),new t.UInt64(3584528711,2466948901),new t.UInt64(113926993,3758326383),new t.UInt64(338241895,168717936),new t.UInt64(666307205,1188179964),new t.UInt64(773529912,1546045734),new t.UInt64(1294757372,1522805485),new t.UInt64(1396182291,2643833823),new t.UInt64(1695183700,2343527390),new t.UInt64(1986661051,1014477480),new t.UInt64(2177026350,1206759142),new t.UInt64(2456956037,344077627),new t.UInt64(2730485921,1290863460),new t.UInt64(2820302411,3158454273),new t.UInt64(3259730800,3505952657),new t.UInt64(3345764771,106217008),new t.UInt64(3516065817,3606008344),new t.UInt64(3600352804,1432725776),new t.UInt64(4094571909,1467031594),new t.UInt64(275423344,851169720),new t.UInt64(430227734,3100823752),new t.UInt64(506948616,1363258195),new t.UInt64(659060556,3750685593),new t.UInt64(883997877,3785050280),new t.UInt64(958139571,3318307427),new t.UInt64(1322822218,3812723403),new t.UInt64(1537002063,2003034995),new t.UInt64(1747873779,3602036899),new t.UInt64(1955562222,1575990012),new t.UInt64(2024104815,1125592928),new t.UInt64(2227730452,2716904306),new t.UInt64(2361852424,442776044),new t.UInt64(2428436474,593698344),new t.UInt64(2756734187,3733110249),new t.UInt64(3204031479,2999351573),new t.UInt64(3329325298,3815920427),new t.UInt64(3391569614,3928383900),new t.UInt64(3515267271,566280711),new t.UInt64(3940187606,3454069534),new t.UInt64(4118630271,4000239992),new t.UInt64(116418474,1914138554),new t.UInt64(174292421,2731055270),new t.UInt64(289380356,3203993006),new t.UInt64(460393269,320620315),new t.UInt64(685471733,587496836),new t.UInt64(852142971,1086792851),new t.UInt64(1017036298,365543100),new t.UInt64(1126000580,2618297676),new t.UInt64(1288033470,3409855158),new t.UInt64(1501505948,4234509866),new t.UInt64(1607167915,987167468),new t.UInt64(1816402316,1246189591)],n}(h),h.SHA3=function(t){var n=function(t){this.length=0,this.rate=0,this.len=0,this.S=[],this.init(t)};return n.prototype={transform:function(){var i,e,o,r=[],s=[],h=[];for(o=0;o>=3)%5,o=Math.floor(h/5),c=new t.UInt64(0,i),r=0;r=i||c%this.rate==0){e=!0;break}h=n.rotl(h,56)}if(e)break}if(e)break}if(c>=i)break;e=!1,this.transform()}},hash:function(t){if(1==this.rate-this.length%this.rate)this.process(134);else{for(this.process(6);this.length%this.rate!=this.rate-1;)this.process(0);this.process(128)}this.squeeze(t,this.len)},shake:function(t,n){if(1==this.rate-this.length%this.rate)this.process(159);else{for(this.process(31);this.length%this.rate!=this.rate-1;)this.process(0);this.process(128)}this.squeeze(t,n)}},n.rotl=function(n,i){return 0==i?n:i<32?new t.UInt64(n.top<>>32-i,n.bot<>>32-i):new t.UInt64(n.bot<>>64-i,n.top<>>64-i)},n.xor=function(n,i){return new t.UInt64(n.top^i.top,n.bot^i.bot)},n.and=function(n,i){return new t.UInt64(n.top&i.top,n.bot&i.bot)},n.not=function(n){return new t.UInt64(~n.top,~n.bot)},n.ROUNDS=24,n.HASH224=28,n.HASH256=32,n.HASH384=48,n.HASH512=64,n.SHAKE128=16,n.SHAKE256=32,n.RC=[new t.UInt64(0,1),new t.UInt64(0,32898),new t.UInt64(2147483648,32906),new t.UInt64(2147483648,2147516416),new t.UInt64(0,32907),new t.UInt64(0,2147483649),new t.UInt64(2147483648,2147516545),new t.UInt64(2147483648,32777),new t.UInt64(0,138),new t.UInt64(0,136),new t.UInt64(0,2147516425),new t.UInt64(0,2147483658),new t.UInt64(0,2147516555),new t.UInt64(2147483648,139),new t.UInt64(2147483648,32905),new t.UInt64(2147483648,32771),new t.UInt64(2147483648,32770),new t.UInt64(2147483648,128),new t.UInt64(0,32778),new t.UInt64(2147483648,2147483658),new t.UInt64(2147483648,2147516545),new t.UInt64(2147483648,32896),new t.UInt64(0,2147483649),new t.UInt64(2147483648,2147516424)],n}(h),h.RAND=function(t){var n=function(){this.ira=[],this.rndptr=0,this.borrow=0,this.pool_ptr=0,this.pool=[],this.clean()};return n.prototype={NK:21,NJ:6,NV:8,clean:function(){var t;for(t=0;t<32;t++)this.pool[t]=0;for(t=0;t>>0)-this.ira[t]-this.borrow|0,(i>>>=0)e&&(this.borrow=1),this.ira[t]=0|i;return this.ira[0]},sirand:function(t){var n,i,e,o=1;for(this.borrow=0,this.rndptr=0,t>>>=0,this.ira[0]^=t,n=1;n0){for(o=0;o=32&&this.fill_pool(),255&t}},n.pack=function(t){return(255&t[3])<<24|(255&t[2])<<16|(255&t[1])<<8|255&t[0]},n}(h),h.NHS=function(t){var n={round:function(t,n){return Math.floor((t+(n>>1))/n)},nabs:function(t){var n=t>>31;return t+n^n},redc:function(t){return(((67108863&t)*n.ND&67108863)*n.PRIME+t)*n.MODINV},nres:function(t){return n.redc(t*n.R2MODP)},modmul:function(t,i){return n.redc(t*i)},ntt:function(t){var i,e,o,r,s,h,c,u=n.DEGREE/2,a=n.PRIME;for(o=0;o1;){for(r=0,e=0;e>n.WL-1&a},Encode:function(t,i){var e,o,r,s,h,c;for(c=n.PRIME/2,e=o=0;e<256;)for(h=t[o++],s=0;s<8;s++)r=1&h,i[e]=r*c,i[e+256]=r*c,i[e+512]=r*c,i[e+768]=r*c,h>>=1,e++},Decode:function(t,i){var e,o,r,s,h=n.PRIME/2;for(e=0;e<32;e++)i[e]=0;for(e=o=0;e<256;){for(r=0;r<8;r++)s=(s=n.nabs(t[e]-h)+n.nabs(t[e+256]-h)+n.nabs(t[e+512]-h)+n.nabs(t[e+768]-h)-n.PRIME)>>31&1,i[o]=((255&i[o])>>1)+(s<<7),e++;o++}},Parse:function(i,e){var o,r,s,h=new t.SHA3(t.SHA3.SHAKE128),c=[];for(o=0;o<32;o++)h.process(i[o]);for(h.shake(c,4*n.DEGREE),o=r=0;o>8|s<<6),i[o++]=s>>2&255,i[o++]=255&(s>>10|h<<4),i[o++]=h>>4&255,i[o++]=255&(h>>12|c<<2),i[o++]=c>>6},unpack:function(t,i){var e,o,r,s,h,c,u,a,f;for(e=o=0;e>6|h<<2|(15&c)<<10,i[e++]=c>>4|u<<4|(3&a)<<12,i[e++]=a>>2|f<<6},Compress:function(t,i){var e,o,r,s=0;for(e=o=0;e>>8&255,i[o+2]=s>>>16&255,o+=3,s=0}},Decompress:function(t,i){var e,o,r,s,h=0;for(e=o=0;e>>21,h<<=3,i[e]=n.round(s*n.PRIME,8),e++},Error:function(t,i){var e,o,r,s,h;for(s=0;s>=1,o>>=1;i[s]=r+n.PRIME}},redc_it:function(t){var i;for(i=0;i>n.WL-1&n.PRIME)},poly_hard_reduce:function(t){var i,e;for(i=0;i>n.WL-1&n.PRIME)},bytestostring:function(t){var n,i,e="",o=t.length;for(i=0;i>>4&15).toString(16),e+=(15&n).toString(16);return e},SERVER_1:function(t,i,e){var o,r=new Uint8Array(32),s=new Uint8Array(1792),h=new Int32Array(n.DEGREE),c=new Int32Array(n.DEGREE),u=new Int32Array(n.DEGREE);for(o=0;o<32;o++)r[o]=t.getByte();for(n.Parse(r,u),n.Error(t,c),n.Error(t,h),n.ntt(h),n.ntt(c),n.poly_mul(u,u,h),n.poly_add(u,u,c),n.poly_hard_reduce(u),n.redc_it(u),n.pack(u,s),o=0;o<32;o++)i[o]=r[o];for(o=0;o<1792;o++)i[o+32]=s[o];for(n.poly_hard_reduce(h),n.pack(h,s),o=0;o<1792;o++)e[o]=s[o]},CLIENT:function(i,e,o,r){var s,h=new t.SHA3(t.SHA3.HASH256),c=new Uint8Array(32),u=new Uint8Array(1792),a=new Uint8Array(32),f=new Uint8Array(384),E=new Int32Array(n.DEGREE),B=new Int32Array(n.DEGREE),y=new Int32Array(n.DEGREE),I=new Int32Array(n.DEGREE),m=new Int32Array(n.DEGREE);for(n.Error(i,E),n.Error(i,B),n.ntt(E),n.ntt(B),s=0;s<32;s++)c[s]=e[s];for(s=0;s<1792;s++)u[s]=e[s+32];for(n.Parse(c,y),n.poly_mul(y,y,E),n.poly_add(y,y,B),n.poly_hard_reduce(y),s=0;s<32;s++)a[s]=i.getByte();for(s=0;s<32;s++)h.process(a[s]);for(h.hash(a),n.Encode(a,I),n.unpack(u,m),n.nres_it(m),n.poly_mul(m,m,E),n.intt(m),n.Error(i,B),n.poly_add(m,m,B),n.poly_add(m,m,I),n.Compress(m,f),h.init(t.SHA3.HASH256),s=0;s<32;s++)h.process(a[s]);for(h.hash(a),s=0;s<32;s++)r[s]=a[s];for(n.redc_it(y),n.pack(y,u),s=0;s<1792;s++)o[s]=u[s];for(s=0;s<384;s++)o[s+1792]=f[s]},SERVER_2:function(i,e,o){var r,s=new t.SHA3(t.SHA3.HASH256),h=new Int32Array(n.DEGREE),c=new Int32Array(n.DEGREE),u=new Int32Array(n.DEGREE),a=new Uint8Array(1792),f=new Uint8Array(32),E=new Uint8Array(384);for(r=0;r<1792;r++)a[r]=e[r];for(n.unpack(a,u),n.nres_it(u),r=0;r<384;r++)E[r]=e[r+1792];for(n.Decompress(E,h),r=0;r<1792;r++)a[r]=i[r];for(n.unpack(a,c),n.poly_mul(u,u,c),n.intt(u),n.poly_sub(u,h,u),n.poly_soft_reduce(u),n.Decode(u,f),r=0;r<32;r++)s.process(f[r]);for(s.hash(f),r=0;r<32;r++)o[r]=f[r]},PRIME:12289,LGN:10,ND:50343935,ONE:10924,R2MODP:7586};return n.MODINV=Math.pow(2,-26),n.DEGREE=1024,n.WL=26,n.inv=4091,n.invpr=4401,n.roots=[10924,3439,7271,11355,11709,9879,10742,2259,7036,2539,8427,9802,10192,4635,1420,1239,6050,10731,7026,5040,6577,5505,10953,9704,9373,11614,867,8052,8079,8356,11442,11524,5127,11769,941,9207,6770,2705,895,3507,8981,1510,2703,8477,3501,7979,11817,9904,8201,12253,10369,921,1414,10113,10933,2417,9035,7667,7466,5597,6765,10100,2047,7870,560,7412,6155,2904,6540,11072,4731,7581,4991,4e3,324,75,12204,2825,7295,437,3820,3160,4680,9276,4234,5304,233,11774,251,9730,10988,7095,4248,9176,1923,6931,8295,8406,5916,4,1634,4247,9401,7069,10180,10094,1727,1879,11798,1138,7441,5705,10500,3796,1733,5294,12024,10976,11900,10037,4486,1266,6075,10623,7623,6885,10819,11266,3798,11120,7291,6353,8366,1709,9220,4410,8350,795,5533,1167,3593,7090,5367,901,452,7387,8918,8664,12,6830,11982,11649,3414,1473,4826,2255,5637,7108,6327,6585,8638,4958,10454,10385,8712,6113,10609,2342,8475,255,1311,2693,225,11317,9605,289,3623,11876,10744,11590,3250,10538,829,2809,2950,11834,8504,6520,8996,3903,11536,7677,5059,1740,6777,4641,9487,2765,4095,1972,1616,6291,3717,8029,4828,11586,3470,4672,4226,4847,4534,4008,2831,3500,6428,4674,490,341,9994,2541,11867,9688,8748,2025,8115,4268,10521,9604,3043,9466,9197,1560,11648,1786,5134,1416,853,4180,9924,7759,5761,8047,7251,4068,2763,5760,12264,108,5722,4283,11321,6148,4502,2180,9762,1577,6849,8754,12187,3390,8447,4800,10220,90,672,1521,7386,1027,7848,5913,8135,11555,1514,9681,182,1180,2759,11676,8270,8514,4584,3792,5616,1300,2623,3907,7653,11671,5443,11387,9242,8739,12216,9655,6988,12086,9954,256,9557,9836,11792,10012,1450,6025,8601,10525,4232,8262,7841,3977,7290,7832,311,7013,9453,3895,11971,3340,1991,4671,2862,6807,6659,7117,946,1812,10617,2799,11068,11665,3587,3675,8124,3246,1074,9124,2845,7372,8118,12120,10842,1827,11417,11632,10,9788,9985,3563,11528,7220,8204,7816,918,6357,7237,196,6332,11479,5956,2289,7260,3046,10889,6048,519,6606,8228,9187,10651,1669,11183,1337,11593,9397,5517,253,10901,589,2739,4389,4857,5562,1704,11318,1767,4164,878,4072,4397,10007,9376,7177,3613,2088,759,8027,4011,3318,4914,7282,9859,5582,6867,6710,588,2867,9535,5507,7529,10732,2983,12183,5855,4200,2798,3151,5436,9451,8397,5016,9062,4601,3703,4157,9738,206,2794,9067,11025,1528,3663,1872,5481,4341,10318,2616,11782,224,3754,2462,9371,2283,11159,12255,10689,6912,12259,7503,2111,11526,270,6207,10170,306,4031,10605,5450,1034,10087,173,3081,2420,10273,7726,10450,4012,964,12057,3540,11743,7747,7824,11721,4420,10435,1619,3900,7730,10826,913,4387,219,11680,3614,1639,9141,8249,2706,5458,1491,5786,7939,4930,8196,7005,11521,11931,1055,11207,2708,208,11882,11064,5292,10020,954,1724,6316,11685,8508,11356,3539,2734,11784,1741,5751,8229,7708,1460,3524,96,5484,9833,7169,9899,7867,9940,8673,5483,1383,26,10702,9172,1668,2937,6483,4166,7564,6069,7208,7397,9336,6360,6934,11311,8649,6587,3004,10523,6646,6265,12260,1422,10570,6632,10183,12218,6697,8985,7883,8251,12037,11138,6447,9898,9346,2797,4630,1800,4513,3106,2312,10488,9255,2040,5934,3920,2728,6218,8039,8913,3770,8539,3911,10359,3422,2268,525,11694,7486,1909,3059,2162,9831,8182,3487,5060,261,1631,8684,1757,6665,3182,509,5158,2787,1172,11650,8909,9686,4545,28,11438,5151,4362,327,9815,9213,12089,864,8852,7966,2931,3068,12055,1994,12131,191,10434,3098,9566,8814,6824,8862,5658,627,4205,11328,1999,5128,2008,4106,1881,7604,9406,11963,3095,6292,9294,5565,1864,8169,573,474,702,6307,3164,2553,981,11492,84,10943,10140,7809,11609,10311,9204,3496,2592,600,7422,9228,11310,10128,11733,11250,11828,5924,529,4105,10169,1785,9177,6562,1575,5485,5790,2023,783,9398,1474,7396,10461,32,5803,7374,8361,9104,10372,8773,1527,2743,7018,4583,10835,12180,10572,7909,4964,7066,4087,1515,11312,7170,1441,7047,9218,7368,12001,8126,5004,9351,7160,3478,7528,12211,8129,8140,3430,2387,8513,5498,9335,6371,12080,1886,7649,5298,12202,5783,9012,4817,2934,10920,7802,213,11360,9912,5971,4682,8023,5157,3460,7173,1601,3898,7052,3453,12114,756,3187,5403,5513,6169,6936,2971,6889,11039,11076,12122,11575,11441,9973,9022,10095,630,4704,10647,2546,7189,5780,4524,7789,7151,10598,6322,1274,8260,7024,7998,8734,10442,7510,1966,2445,9100,6072,2771,4415,7963,1234,5975,3249,12017,11778,6140,12049,10868,8233,1792,5454,7407,8810,8639,10150,5308,11051,12230,5046,8678,5731,3261,1874,5668,2177,12224,4726,2687,10063,11091,1648,8119,7745,10782,9746,663,6622,395,585,7304,3742,7921,531,1147,7712,10433,7518,2423,7626,2448,7670,11106,2160,500,6185,7690,70,7071,8450,363,6962,1384,8272,5556,6426,7632,1503,1372,7457,6619,4825,3734,1664,9033,2489,5469,3633,9375,8440,2864,823,11683,4547,9359,7417,4334,1752,1771,2573,4123,6884,6145,9421,2067,11928,5492,80,4570,6146,3926,6201,8604,4187,1083,713,2327,5313,7033,3499,10937,9820,1818,7568,2207,11202,10103,4116,7780,5300,1682,3547,1390,8592,11547,4118,4822,7297,9768,1185,4712,9623,10534,1989,7629,1343,4521,6721,1442,7269,2024,3441,10696,1063,815,1500,5809,10781,6023,8740,1568,1700,4945,4152,3692,4379,12051,1089,11517,12079,3365,2488,6948,1890,6582,9745,2142,3639,501,1283,7238,9164,1211,9278,4651,10466,4926,11705,3506,6748,10665,202,8467,5073,5612,8313,6362,11600,11333,2722,4954,2048,6391,6131,1533,8026,720,11473,2542,8587,6653,1339,10437,3635,6417,9932,8216,12168,6913,9783,7385,4715,6667,1456,9440,3714,177,8695,6678,12068,7345,8061,10400,5758,195],n.iroots=[10924,8850,934,5018,10030,1547,2410,580,11050,10869,7654,2097,2487,3862,9750,5253,765,847,3933,4210,4237,11422,675,2916,2585,1336,6784,5712,7249,5263,1558,6239,4419,10242,2189,5524,6692,4823,4622,3254,9872,1356,2176,10875,11368,1920,36,4088,2385,472,4310,8788,3812,9586,10779,3308,8782,11394,9584,5519,3082,11348,520,7162,1023,1470,5404,4666,1666,6214,11023,7803,2252,389,1313,265,6995,10556,8493,1789,6584,4848,11151,491,10410,10562,2195,2109,5220,2888,8042,10655,12285,6373,3883,3994,5358,10366,3113,8041,5194,1301,2559,12038,515,12056,6985,8055,3013,7609,9129,8469,11852,4994,9464,85,12214,11965,8289,7298,4708,7558,1217,5749,9385,6134,4877,11729,10712,2527,10109,7787,6141,968,8006,6567,12181,25,6529,9526,8221,5038,4242,6528,4530,2365,8109,11436,10873,7155,10503,641,10729,3092,2823,9246,2685,1768,8021,4174,10264,3541,2601,422,9748,2295,11948,11799,7615,5861,8789,9458,8281,7755,7442,8063,7617,8819,703,7461,4260,8572,5998,10673,10317,8194,9524,2802,7648,5512,10549,7230,4612,753,8386,3293,5769,3785,455,9339,9480,11460,1751,9039,699,1545,413,8666,12e3,2684,972,12064,9596,10978,12034,3814,9947,1680,6176,3577,1904,1835,7331,3651,5704,5962,5181,6652,10034,7463,10816,8875,640,307,5459,12277,3625,3371,4902,11837,11388,6922,5199,8696,11122,6756,11494,3939,7879,3069,10580,3923,5936,4998,1169,8491,8750,933,3781,604,5973,10565,11335,2269,6997,1225,407,12081,9581,1082,11234,358,768,5284,4093,7359,4350,6503,10798,6831,9583,4040,3148,10650,8675,609,12070,7902,11376,1463,4559,8389,10670,1854,7869,568,4465,4542,546,8749,232,11325,8277,1839,4563,2016,9869,9208,12116,2202,11255,6839,1684,8258,11983,2119,6082,12019,763,10178,4786,30,5377,1600,34,1130,10006,2918,9827,8535,12065,507,9673,1971,7948,6808,10417,8626,10761,1264,3222,9495,12083,2551,8132,8586,7688,3227,7273,3892,2838,6853,9138,9491,8089,6434,106,9306,1557,4760,6782,2754,9422,11701,5579,5422,6707,2430,5007,7375,8971,8278,4262,11530,10201,8676,5112,2913,2282,7892,8217,11411,8125,10522,971,10585,6727,7432,7900,9550,11700,1388,12036,6772,2892,696,10952,1106,10620,1638,3102,4061,5683,11770,6241,1400,9243,5029,1e4,6333,810,5957,12093,5052,5932,11371,4473,4085,5069,761,8726,2304,2501,12279,657,872,10462,1447,169,4171,4917,9444,3165,11215,9043,4165,8614,8702,624,1221,9490,1672,10477,11343,5172,5630,5482,9427,7618,10298,8949,318,8394,2836,5276,11978,4457,4999,8312,4448,4027,8057,1764,3688,6264,10839,2277,497,2453,2732,12033,2335,203,5301,2634,73,3550,3047,902,6846,618,4636,8382,9666,10989,6673,8497,7705,3775,4019,613,9530,11109,12107,2608,10775,734,4154,6376,4441,11262,4903,10768,11617,12199,2069,7489,3842,8899,102,3535,5440,12094,6531,1889,4228,4944,221,5611,3594,12112,8575,2849,10833,5622,7574,4904,2506,5376,121,4073,2357,5872,8654,1852,10950,5636,3702,9747,816,11569,4263,10756,6158,5898,10241,7335,9567,956,689,5927,3976,6677,7216,3822,12087,1624,5541,8783,584,7363,1823,7638,3011,11078,3125,5051,11006,11788,8650,10147,2544,5707,10399,5341,9801,8924,210,772,11200,238,7910,8597,8137,7344,10589,10721,3549,6266,1508,6480,10789,11474,11226,1593,8848,10265,5020,10847,5568,7768,10946,4660,10300,1755,2666,7577,11104,2521,4992,7467,8171,742,3697,10899,8742,10607,6989,4509,8173,2186,1087,10082,4721,10471,2469,1352,8790,5256,6976,9962,11576,11206,8102,3685,6088,8363,6143,7719,12209,6797,361,10222,2868,6144,5405,8166,9716,10518,10537,7955,4872,2930,7742,606,11466,9425,3849,2914,8656,6820,9800,3256,10625,8555,7464,5670,4832,10917,10786,4657,5863,6733,4017,10905,5327,11926,3839,5218,12219,4599,6104,11789,10129,1183,4619,9841,4663,9866,4771,1856,4577,11142,11758,4368,8547,4985,11704,11894,5667,11626,2543,1507,4544,4170,10641,1198,2226,9602,7563,65,10112,6621,10415,9028,6558,3611,7243,59,1238,6981,2139,3650,3479,4882,6835,10497,4056,1421,240,6149,511,272,9040,6314,11055,4326,7874,9518,6217,3189,9844,10323,4779,1847,3555,4291,5265,4029,11015,5967,1691,5138,4500,7765,6509,5100,9743,1642,7585,11659,2194,3267,2316,848,714,167,1213,1250,5400,9318,5353,6120,6776,6886,9102,11533,175,8836,5237,8391,10688,5116,8829,7132,4266,7607,6318,2377,929,12076,4487,1369,9355,7472,3277,6506,87,6991,4640,10403,209,5918,2954,6791,3776,9902,8859,4149,4160,78,4761,8811,5129,2938,7285,4163,288,4921,3071,5242,10848,5119,977,10774,8202,5223,7325,4380,1717,109,1454,7706,5271,9546,10762,3516,1917,3185,3928,4915,6486,12257,1828,4893,10815,2891,11506,10266,6499,6804,10714,5727,3112,10504,2120,8184,11760,6365,461,1039,556,2161,979,3061,4867,11689,9697,8793,3085,1978,680,4480,2149,1346,12205,797,11308,9736,9125,5982,11587,11815,11716,4120,10425,6724,2995,5997,9194,326,2883,4685,10408,8183,10281,7161,10290,961,8084,11662,6631,3427,5465,3475,2723,9191,1855,12098,158,10295,234,9221,9358,4323,3437,11425,200,3076,2474,11962,7927,7138,851,12261,7744,2603,3380,639,11117,9502,7131,11780,9107,5624,10532,3605,10658,12028,7229,8802,4107,2458,10127,9230,10380,4803,595,11764,10021,8867,1930,8378,3750,8519,3376,4250,6071,9561,8369,6355,10249,3034,1801,9977,9183,7776,10489,7659,9492,2943,2391,5842,1151,252,4038,4406,3304,5592,71,2106,5657,1719,10867,29,6024,5643,1766,9285,5702,3640,978,5355,5929,2953,4892,5081,6220,4725,8123,5806,9352,10621,3117,1587,12263,10906,6806,3616,2349,4422,2390,5120,2456,6805,12193,8765,10829,4581,4060,6538,10548,505,9555],n}(h),void 0!==r)return h.config=s[r],h.BIG=function(t){var n=function(t){switch(this.w=new Array(n.NLEN),typeof t){case"object":this.copy(t);break;case"number":this.zero(),this.w[0]=t;break;default:this.zero()}};return n.CHUNK=32,n.MODBYTES=t.config["@NB"],n.BASEBITS=t.config["@BASE"],n.NLEN=1+Math.floor((8*n.MODBYTES-1)/n.BASEBITS),n.DNLEN=2*n.NLEN,n.BMASK=(1<>n.BASEBITS;return this.w[n.NLEN-1]=this.w[n.NLEN-1]+e,this.w[n.NLEN-1]>>8*n.MODBYTES%n.BASEBITS},fshr:function(t){var i,e;for(i=this.w[0]&(1<>t|this.w[e+1]<>t,i},shr:function(t){var i,e=t%n.BASEBITS,o=Math.floor(t/n.BASEBITS);for(i=0;i>e|this.w[o+i+1]<>e,i=n.NLEN-o;i>n.BASEBITS-t,i=n.NLEN-2;i>0;i--)this.w[i]=this.w[i]<>n.BASEBITS-t;return this.w[0]=this.w[0]<>8*n.MODBYTES%n.BASEBITS},shl:function(t){var i,e=t%n.BASEBITS,o=Math.floor(t/n.BASEBITS);for(this.w[n.NLEN-1]=this.w[n.NLEN-1-o]<o+2&&(this.w[n.NLEN-1]|=this.w[n.NLEN-o-2]>>n.BASEBITS-e),i=n.NLEN-2;i>o;i--)this.w[i]=this.w[i-o]<>n.BASEBITS-e;for(this.w[o]=this.w[0]<=0&&0===this.w[e];)e--;if(e<0)return 0;for(t=n.BASEBITS*e,i=this.w[e];0!==i;)i=Math.floor(i/2),t++;return t},toString:function(){var t,i,e="",o=this.nbits();for(o%4==0?o=Math.floor(o/4):(o=Math.floor(o/4),o++),o<2*n.MODBYTES&&(o=2*n.MODBYTES),i=o-1;i>=0;i--)(t=new n(0)).copy(this),t.shr(4*i),e+=(15&t.w[0]).toString(16);return e},add:function(t){var i;for(i=0;i=0;e--)t[e+i]=255&o.w[0],o.fshr(8);return this},toBytes:function(t){this.tobytearray(t,0)},muladd:function(t,i,e,o){var r=t*i+e+this.w[o];return this.w[o]=r&n.BMASK,(r-this.w[o])*n.MODINV},pmul:function(t){var i,e,o=0;for(e=0;e=0;e--)t=o*i+this.w[e],this.w[e]=Math.floor(t/3),o=t%3;return o},mod2m:function(t){var i,e,o;for(e=Math.floor(t/n.BASEBITS),o=(1<=0);for(;i>0;)t.fshr(1),e.copy(this),e.sub(t),e.norm(),this.cmove(e,1-(e.w[n.NLEN-1]>>n.CHUNK-1&1)),i--}},div:function(t){var i=0,e=0,o=new n(1),r=new n(0),s=new n(0);for(this.norm(),r.copy(this),this.zero();n.comp(r,t)>=0;)o.fshl(1),t.fshl(1),i++;for(;i>0;)t.fshr(1),o.fshr(1),s.copy(r),s.sub(t),s.norm(),e=1-(s.w[n.NLEN-1]>>n.CHUNK-1&1),r.cmove(s,e),s.copy(this),s.add(o),s.norm(),this.cmove(s,e),i--},parity:function(){return this.w[0]%2},bit:function(t){return(this.w[Math.floor(t/n.BASEBITS)]&1<0?1:0},lastbits:function(t){var n=(1<>n.BASEBITS&&(i=!1);return i},jacobi:function(t){var i,e,o=0,r=new n(0),s=new n(0),h=new n(0),c=new n(0),u=new n(1);if(0===t.parity()||0===n.comp(this,c)||n.comp(t,u)<=0)return 0;for(this.norm(),s.copy(this),h.copy(t),s.mod(t);n.comp(h,u)>0;){if(0===n.comp(s,c))return 0;for(i=h.lastbits(3),e=0;0===s.parity();)e++,s.shr(1);e%2==1&&(o+=(i*i-1)/8),o+=(i-1)*(s.lastbits(2)-1)/4,r.copy(h),r.mod(s),h.copy(s),s.copy(r),o%=2}return 0===o?1:-1},invmodp:function(t){var i=new n(0),e=new n(0),o=new n(1),r=new n(0),s=new n(0),h=new n(1);for(this.mod(t),i.copy(this),e.copy(t);0!==n.comp(i,h)&&0!==n.comp(e,h);){for(;0===i.parity();)i.fshr(1),0!==o.parity()&&(o.add(t),o.norm()),o.fshr(1);for(;0===e.parity();)e.fshr(1),0!==r.parity()&&(r.add(t),r.norm()),r.fshr(1);n.comp(i,e)>=0?(i.sub(e),i.norm(),n.comp(o,r)>=0?o.sub(r):(s.copy(t),s.sub(r),o.add(s)),o.norm()):(e.sub(i),e.norm(),n.comp(r,o)>=0?r.sub(o):(s.copy(t),s.sub(o),r.add(s)),r.norm())}0===n.comp(i,h)?this.copy(o):this.copy(r)},powmod:function(t,i){var e,o=new n(1),r=new n(0),s=new n(0);for(this.norm(),t.norm(),r.copy(t),s.copy(this);e=r.parity(),r.fshr(1),1==e&&(o=n.modmul(o,s,i)),!r.iszilch();)s=n.modsqr(s,i);return o}},n.frombytearray=function(t,i){var e,o=new n(0);for(e=0;e=0;e--)if(t.w[e]!=i.w[e])return t.w[e]>i.w[e]?1:-1;return 0},n.random=function(t){var i,e,o=new n(0),r=0,s=0;for(i=0;i<8*n.MODBYTES;i++)0===r?s=t.getByte():s>>=1,e=1&s,o.shl(1),o.w[0]+=e,r++,r&=7;return o},n.randomnum=function(n,i){var e,o,r=new t.DBIG(0),s=0,h=0;for(e=0;e<2*n.nbits();e++)0===s?h=i.getByte():h>>=1,o=1&h,r.shl(1),r.w[0]+=o,s++,s&=7;return r.mod(n)},n.mul=function(i,e){var o,r,s,h,c,u,a=new t.DBIG(0),f=[];for(h=0;h=1+Math.floor(c/2);h--)s+=(i.w[h]-i.w[c-h])*(e.w[c-h]-e.w[h]);a.w[c]=s}for(c=n.NLEN;c<2*n.NLEN-1;c++){for(s=r-=f[c-n.NLEN],h=n.NLEN-1;h>=1+Math.floor(c/2);h--)s+=(i.w[h]-i.w[c-h])*(e.w[c-h]-e.w[h]);a.w[c]=s}for(u=0,h=0;h>1;s++)o+=i.w[r-s]*i.w[s];for(o+=o,c.w[r]=o,r++,o=i.w[r]*i.w[0],s=1;s>1;s++)o+=i.w[r-s]*i.w[s];o+=o,o+=i.w[r>>1]*i.w[r>>1],c.w[r]=o,r++}for(r=n.NLEN-1+n.NLEN%2;r>1;s++)o+=i.w[r-s]*i.w[s];for(o+=o,c.w[r]=o,r++,o=i.w[n.NLEN-1]*i.w[r-n.NLEN+1],s=r-n.NLEN+2;s>1;s++)o+=i.w[r-s]*i.w[s];o+=o,o+=i.w[r>>1]*i.w[r>>1],c.w[r]=o,r++}for(o=i.w[n.NLEN-2]*i.w[n.NLEN-1],o+=o,c.w[n.DNLEN-3]=o,o=i.w[n.NLEN-1]*i.w[n.NLEN-1],c.w[n.DNLEN-2]=o,h=0,s=0;sMath.floor(c/2);h--)s+=(a[c-h]-a[h])*(t.w[h]-t.w[c-h]);a[c]=(s&n.BMASK)*i&n.BMASK,r=(s+=a[c]*t.w[0])*n.MODINV+e.w[c+1],f[c]=a[c]*t.w[c],o+=f[c]}for(c=n.NLEN;c<2*n.NLEN-1;c++){for(s=r+o,h=n.NLEN-1;h>=1+Math.floor(c/2);h--)s+=(a[c-h]-a[h])*(t.w[h]-t.w[c-h]);u.w[c-n.NLEN]=s&n.BMASK,r=(s-u.w[c-n.NLEN])*n.MODINV+e.w[c+1],o-=f[c-n.NLEN+1]}return u.w[n.NLEN-1]=r&n.BMASK,u},n.modmul=function(t,i,e){return t.mod(e),i.mod(e),n.mul(t,i).mod(e)},n.modsqr=function(t,i){return t.mod(i),n.sqr(t).mod(i)},n.modneg=function(t,n){return t.mod(n),n.minus(t)},n.invmod256=function(t){var n,i;return i=0,i+=t>>1&1,i=2-(i&=1),i=(n=1+(i<<=1))*(3&t),i>>=2,i+=n*(t>>2&3)&3,i*=n,i=4-(i&=3),i=(n+=i<<=2)*(15&t),i>>=4,i+=n*(t>>4&15)&15,i*=n,n+((i=16-(i&=15))<<4)},n}(h),h.DBIG=function(t){var n=function(t){this.w=[],this.zero(),this.w[0]=t};return n.prototype={zero:function(){for(var n=0;n>t.BIG.BASEBITS;return this.w[t.BIG.DNLEN-1]=this.w[t.BIG.DNLEN-1]+e,this},muladd:function(n,i,e,o){var r=n*i+e+this.w[o];return this.w[o]=r&t.BIG.BMASK,(r-this.w[o])*t.BIG.MODINV},shr:function(n){var i,e=n%t.BIG.BASEBITS,o=Math.floor(n/t.BIG.BASEBITS);for(i=0;i>e|this.w[o+i+1]<>e,i=t.BIG.DNLEN-o;i>t.BIG.BASEBITS-e,i=t.BIG.DNLEN-2;i>o;i--)this.w[i]=this.w[i-o]<>t.BIG.BASEBITS-e;for(this.w[o]=this.w[0]<=0&&0===this.w[e];)e--;if(e<0)return 0;for(n=t.BIG.BASEBITS*e,i=this.w[e];0!==i;)i=Math.floor(i/2),n++;return n},toString:function(){var t,i,e="",o=this.nbits();for(o%4==0?o=Math.floor(o/4):(o=Math.floor(o/4),o++),i=o-1;i>=0;i--)(t=new n(0)).copy(this),t.shr(4*i),e+=(15&t.w[0]).toString(16);return e},mod:function(i){var e=0,o=new n(0),r=new n(0),s=new t.BIG(0);if(this.norm(),o.hcopy(i),s.hcopy(this),n.comp(this,o)<0)return s;do{o.shl(1),e++}while(n.comp(this,o)>=0);for(;e>0;)o.shr(1),r.copy(this),r.sub(o),r.norm(),this.cmove(r,1-(r.w[t.BIG.DNLEN-1]>>t.BIG.CHUNK-1&1)),e--;return s.hcopy(this),s},div:function(i){var e=0,o=0,r=new n(0),s=new n(0),h=new t.BIG(0),c=new t.BIG(0),u=new t.BIG(1);for(r.hcopy(i),this.norm();n.comp(this,r)>=0;)u.fshl(1),r.shl(1),o++;for(;o>0;)r.shr(1),u.shr(1),s.copy(this),s.sub(r),s.norm(),e=1-(s.w[t.BIG.DNLEN-1]>>t.BIG.CHUNK-1&1),this.cmove(s,e),h.copy(c),h.add(u),h.norm(),c.cmove(h,e),o--;return c},split:function(n){var i,e,o=new t.BIG(0),r=n%t.BIG.BASEBITS,s=this.w[t.BIG.DNLEN-1]<=t.BIG.NLEN-1;e--)i=this.w[e]>>r|s,s=this.w[e]<=0;e--)if(n.w[e]!=i.w[e])return n.w[e]>i.w[e]?1:-1;return 0},n}(h),void 0!==h.config.TFF?(h.FF=function(t){var n=function(n){this.v=new Array(n),this.length=n;for(var i=0;i>n.P_TBITS)},zero:function(){for(var t=0;t>t.BIG.BASEBITS)},copy:function(t){for(var n=0;n0;t--)i=this.v[t].fshr(1),this.v[t-1].ortop(i<=0;t--)n+=this.v[t].toString();return n},toBytes:function(n){var i;for(i=0;i=0);for(;i>0;)t.shr(),n.comp(this,t)>=0&&(this.sub(t),this.norm()),i--}},reduce:function(t,i){var e=t.length,o=new n(2*e),r=new n(e),s=new n(e);return r.sducopy(this),s.karmul_lower(0,this,0,i,0,o,0,e),this.karmul_upper(t,s,o,e),s.sducopy(this),r.add(t),r.sub(s),r.norm(),r},dmod:function(i){var e,o=i.length,r=new n(2*o),s=new n(2*o),h=new n(o);for(s.copy(this),s.norm(),r.dsucopy(i),e=t.BIG.BIGBITS*o;n.comp(s,r)>=0;)s.sub(r),s.norm();for(;e>0;)r.shr(),n.comp(s,r)>=0&&(s.sub(r),s.norm()),e--;return h.copy(s),h.mod(i),h},invmodp:function(t){var i=t.length,e=new n(i),o=new n(i),r=new n(i),s=new n(i),h=new n(i),c=new n(i);for(c.one(),e.copy(this),o.copy(t),r.copy(c),s.zero();0!==n.comp(e,c)&&0!==n.comp(o,c);){for(;0===e.parity();)e.shr(),0!==r.parity()&&(r.add(t),r.norm()),r.shr();for(;0===o.parity();)o.shr(),0!==s.parity()&&(s.add(t),s.norm()),s.shr();n.comp(e,o)>=0?(e.sub(o),e.norm(),n.comp(r,s)>=0?r.sub(s):(h.copy(t),h.sub(s),r.add(h)),r.norm()):(o.sub(e),o.norm(),n.comp(s,r)>=0?s.sub(r):(h.copy(t),h.sub(r),s.add(h)),s.norm())}0===n.comp(e,c)?this.copy(r):this.copy(s)},nres:function(i){var e,o=i.length;1===o?((e=new t.DBIG(0)).hcopy(this.v[0]),e.shl(t.BIG.NLEN*t.BIG.BASEBITS),this.v[0].copy(e.mod(i.v[0]))):((e=new n(2*o)).dsucopy(this),this.copy(e.dmod(i)))},redc:function(i,e){var o,r=i.length;1===r?((o=new t.DBIG(0)).hcopy(this.v[0]),this.v[0].copy(t.BIG.monty(i.v[0],(1<=Math.floor((n.P_FEXCESS-1)/(h+1))&&this.mod(e),1===c?(r=t.BIG.mul(this.v[0],i.v[0]),this.v[0].copy(t.BIG.monty(e.v[0],(1<=Math.floor((n.P_FEXCESS-1)/(r+1))&&this.mod(i),1===i.length?(o=t.BIG.sqr(this.v[0]),this.v[0].copy(t.BIG.monty(i.v[0],(1<=0;o--)r=i.v[Math.floor(o/t.BIG.BIGBITS)].bit(o%t.BIG.BIGBITS),this.copy(h),this.modmul(c,e,u),n.cswap(h,c,r),h.modsqr(e,u),c.copy(this),n.cswap(h,c,r);this.copy(h),this.redc(e,u)},skspow:function(i,e){var o,r,s=e.length,h=new n(s),c=new n(s),u=e.invmod2m();for(this.mod(e),h.one(),c.copy(this),h.nres(e),c.nres(e),o=8*t.BIG.MODBYTES-1;o>=0;o--)r=i.bit(o),this.copy(h),this.modmul(c,e,u),n.cswap(h,c,r),h.modsqr(e,u),c.copy(this),n.cswap(h,c,r);this.copy(h),this.redc(e,u)},power:function(t,i){var e=i.length,o=!0,r=new n(e),s=i.invmod2m();if(r.copy(this),r.nres(i),2==t)this.copy(r),this.modsqr(i,s);else for(;t%2==1&&(o?this.copy(r):this.modmul(r,i,s),o=!1),0!=(t>>=1);)r.modsqr(i,s);this.redc(i,s)},pow:function(i,e){var o,r=e.length,s=new n(r),h=e.invmod2m();for(s.copy(this),this.one(),this.nres(e),s.nres(e),o=8*t.BIG.MODBYTES*r-1;o>=0;o--)this.modsqr(e,h),1===i.v[Math.floor(o/t.BIG.BIGBITS)].bit(o%t.BIG.BIGBITS)&&this.modmul(s,e,h);this.redc(e,h)},pow2:function(i,e,o,r){var s,h,c,u=r.length,a=new n(u),f=new n(u),E=new n(u),B=r.invmod2m();for(a.copy(this),f.copy(e),a.nres(r),f.nres(r),E.copy(a),E.modmul(f,r,B),this.one(),this.nres(r),s=8*t.BIG.MODBYTES-1;s>=0;s--)h=i.bit(s),c=o.bit(s),this.modsqr(r,B),1==h?1==c?this.modmul(E,r,B):this.modmul(a,r,B):1==c&&this.modmul(f,r,B);this.redc(r,B)},cfactor:function(t){var i,e=this.length,o=new n(e),r=new n(e);r.set(t),o.copy(this),o.norm();do{for(o.sub(r),o.norm();!o.iszilch()&&0===o.parity();)o.shr()}while(n.comp(o,r)>0);return i=o.v[0].get(0),n.igcd(t,i)>1}},n.comp=function(n,i){var e,o;for(e=n.length-1;e>=0;e--)if(0!==(o=t.BIG.comp(n.v[e],i.v[e])))return o;return 0},n.fromBytes=function(n,i){var e;for(e=0;e>>4&15).toString(16),e+=(15&n).toString(16);return e},bytestostring:function(t){var n,i="";for(n=0;n=0&&o.process_num(e),r=o.hash()):n==this.SHA384?(o=new t.HASH384,null!=i&&o.process_array(i),e>=0&&o.process_num(e),r=o.hash()):n==this.SHA512&&(o=new t.HASH512,null!=i&&o.process_array(i),e>=0&&o.process_num(e),r=o.hash()),r},KEY_PAIR:function(n,i,e,o){for(var r=o.n.length>>1,s=new t.FF(r),h=new t.FF(r),c=new t.FF(r);;){for(e.p.random(n);3!=e.p.lastbits(2);)e.p.inc(1);for(;!t.FF.prime(e.p,n);)e.p.inc(4);if(h.copy(e.p),h.dec(1),!h.cfactor(i))break}for(;;){for(e.q.random(n);3!=e.q.lastbits(2);)e.q.inc(1);for(;!t.FF.prime(e.q,n);)e.q.inc(4);if(c.copy(e.q),c.dec(1),!c.cfactor(i))break}o.n=t.FF.mul(e.p,e.q),o.e=i,s.copy(h),s.shr(),e.dp.set(i),e.dp.invmodp(s),0===e.dp.parity()&&e.dp.add(s),e.dp.norm(),s.copy(c),s.shr(),e.dq.set(i),e.dq.invmodp(s),0===e.dq.parity()&&e.dq.add(s),e.dq.norm(),e.c.copy(e.p),e.c.invmodp(e.q)},MGF1:function(t,n,i,e){var o,r,s,h=t,c=[],u=0;for(s=0;si)for(s=0;sa-r-s-1)return null;for(u=this.hashit(t,o,-1),c=0;c=1;c--)y[c]=y[c-1];for(c=0;c>=0;c--)y[c]=0;return y},OAEP_DECODE:function(t,i,e){var o,r,s,h,c,u,a,f,E,B,y=n.RFS-1,I=[],m=[],p=[];if(y<(s=r=t)+r+1)return null;for(a=0;a=u;a--)e[a]=e[a-u];for(a=u-1;a>=0;a--)e[a]=0}for(E=this.hashit(t,i,-1),a=0;a=y-s-r)return null;if(0!==p[f])break}if(c=p[f],!o||0!==h||1!=c){for(a=0;a0&&r.add(n.q),r.sub(o),r.norm(),r=(s=t.FF.mul(n.c,r)).dmod(n.q),s=t.FF.mul(r,n.p),c.add(s),c.norm(),c.toBytes(e)}};return n}(h),h.rsa_public_key=function(t){return function(n){this.e=0,this.n=new t.FF(n)}}(h),void(h.rsa_private_key=function(t){return function(n){this.p=new t.FF(n),this.q=new t.FF(n),this.dp=new t.FF(n),this.dq=new t.FF(n),this.c=new t.FF(n)}}(h))):void 0!==h.config.CURVE?(h.ROM_CURVE=e[h.config.CURVE],h.ROM_FIELD=o[h.config.FIELD],h.FP=function(t){var n=function(i){i instanceof n?(this.f=new t.BIG(i.f),this.XES=i.XES):(this.f=new t.BIG(i),this.nres())};return n.NOT_SPECIAL=0,n.PSEUDO_MERSENNE=1,n.GENERALISED_MERSENNE=2,n.MONTGOMERY_FRIENDLY=3,n.MODBITS=t.config["@NBT"],n.MOD8=t.config["@M8"],n.MODTYPE=t.config["@MT"],n.FEXCESS=1<n.FEXCESS&&this.reduce(),e=t.BIG.mul(this.f,i.f),this.f.copy(n.mod(e)),this.XES=2,this},imul:function(t){var i,e,o=!1;return t<0&&(t=-t,o=!0),n.MODTYPE==n.PSEUDO_MERSENNE||n.MODTYPE==n.GENERALISED_MERSENNE?(i=this.f.pxmul(t),this.f.copy(n.mod(i)),this.XES=2):this.XES*t<=n.FEXCESS?(this.f.pmul(t),this.XES*=t):(e=new n(t),this.mul(e)),o&&(this.neg(),this.norm()),this},sqr:function(){var i,e;return this.XES*this.XES>n.FEXCESS&&this.reduce(),i=t.BIG.sqr(this.f),e=n.mod(i),this.f.copy(e),this.XES=2,this},add:function(t){return this.f.add(t.f),this.XES+=t.XES,this.XES>n.FEXCESS&&this.reduce(),this},neg:function(){var i,e=new t.BIG(0);return e.rcopy(t.ROM_FIELD.Modulus),i=n.logb2(this.XES-1),e.fshl(i),this.XES=1<n.FEXCESS&&this.reduce(),this},sub:function(t){var i=new n(0);return i.copy(t),i.neg(),this.add(i),this},rsub:function(t){var i=new n(0);i.copy(this),i.neg(),this.copy(t),this.add(i)},div2:function(){var n;return 0===this.f.parity()||((n=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),this.f.add(n),this.f.norm()),this.f.fshr(1),this},inverse:function(){var n=new t.BIG(0);return n.rcopy(t.ROM_FIELD.Modulus),n.dec(2),n.norm(),this.copy(this.pow(n)),this},equals:function(n){return n.reduce(),this.reduce(),0===t.BIG.comp(n.f,this.f)},pow:function(i){var e,o,r,s,h=[],c=[],u=new t.BIG(i);for(u.norm(),o=1+Math.floor((u.nbits()+3)/4),e=0;e=0;e--)s.sqr(),s.sqr(),s.sqr(),s.sqr(),s.mul(c[h[e]]);return s.reduce(),s},jacobi:function(){var n=new t.BIG(0),i=this.redc();return n.rcopy(t.ROM_FIELD.Modulus),i.jacobi(n)},sqrt:function(){var i,e,o,r=new t.BIG(0);return this.reduce(),r.rcopy(t.ROM_FIELD.Modulus),5==n.MOD8?(r.dec(5),r.norm(),r.shr(3),(i=new n(0)).copy(this),i.f.shl(1),e=i.pow(r),i.mul(e),i.mul(e),i.f.dec(1),(o=new n(0)).copy(this),o.mul(e),o.mul(i),o.reduce(),o):(r.inc(1),r.norm(),r.shr(2),this.pow(r))}},n.logb2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},n.mod=function(i){var e,o,r,s,h,c,u,a,f,E=new t.BIG(0);if(n.MODTYPE==n.PSEUDO_MERSENNE)return o=i.split(n.MODBITS),E.hcopy(i),r=1!=t.ROM_FIELD.MConst?o.pmul(t.ROM_FIELD.MConst):0,o.add(E),o.norm(),s=o.w[t.BIG.NLEN-1],o.w[t.BIG.NLEN-1]&=n.TMASK,o.inc(t.ROM_FIELD.MConst*((s>>n.TBITS)+(r<>n.TBITS,E.w[t.BIG.NLEN-1]&=n.TMASK,E.w[0]+=u,E.w[Math.floor(224/t.BIG.BASEBITS)]+=u<<224%t.BIG.BASEBITS,E.norm()),n.MODTYPE==n.NOT_SPECIAL&&((a=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),E.copy(t.BIG.monty(a,t.ROM_FIELD.MConst,i))),E},n}(h),h.ECP=function(t){var n=function(){this.x=new t.FP(0),this.y=new t.FP(1),n.CURVETYPE!=n.EDWARDS?this.z=new t.FP(0):this.z=new t.FP(1)};return n.WEIERSTRASS=0,n.EDWARDS=1,n.MONTGOMERY=2,n.NOT=0,n.BN=1,n.BLS=2,n.D_TYPE=0,n.M_TYPE=1,n.POSITIVEX=0,n.NEGATIVEX=1,n.CURVETYPE=t.config["@CT"],n.CURVE_PAIRING_TYPE=t.config["@PF"],n.SEXTIC_TWIST=t.config["@ST"],n.SIGN_OF_X=t.config["@SX"],n.HASH_TYPE=t.config["@HT"],n.AESKEY=t.config["@AK"],n.prototype={is_infinity:function(){return this.x.reduce(),this.z.reduce(),n.CURVETYPE==n.EDWARDS?(this.y.reduce(),this.x.iszilch()&&this.y.equals(this.z)):n.CURVETYPE==n.WEIERSTRASS?(this.y.reduce(),this.x.iszilch()&&this.z.iszilch()):n.CURVETYPE!=n.MONTGOMERY||this.z.iszilch()},cswap:function(t,i){this.x.cswap(t.x,i),n.CURVETYPE!=n.MONTGOMERY&&this.y.cswap(t.y,i),this.z.cswap(t.z,i)},cmove:function(t,i){this.x.cmove(t.x,i),n.CURVETYPE!=n.MONTGOMERY&&this.y.cmove(t.y,i),this.z.cmove(t.z,i)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(i){var e,o;return e=new t.FP(0),o=new t.FP(0),e.copy(this.x),e.mul(i.z),e.reduce(),o.copy(i.x),o.mul(this.z),o.reduce(),!(!e.equals(o)||n.CURVETYPE!=n.MONTGOMERY&&(e.copy(this.y),e.mul(i.z),e.reduce(),o.copy(i.y),o.mul(this.z),o.reduce(),!e.equals(o)))},copy:function(t){this.x.copy(t.x),n.CURVETYPE!=n.MONTGOMERY&&this.y.copy(t.y),this.z.copy(t.z)},neg:function(){n.CURVETYPE==n.WEIERSTRASS?(this.y.neg(),this.y.norm()):n.CURVETYPE==n.EDWARDS&&(this.x.neg(),this.x.norm())},inf:function(){this.x.zero(),n.CURVETYPE!=n.MONTGOMERY&&this.y.one(),n.CURVETYPE!=n.EDWARDS?this.z.zero():this.z.one()},setxy:function(i,e){var o,r;this.x=new t.FP(0),this.x.bcopy(i),this.y=new t.FP(0),this.y.bcopy(e),this.z=new t.FP(1),o=n.RHS(this.x),n.CURVETYPE==n.MONTGOMERY?1!=o.jacobi()&&this.inf():((r=new t.FP(0)).copy(this.y),r.sqr(),r.equals(o)||this.inf())},setxi:function(i,e){var o,r;this.x=new t.FP(0),this.x.bcopy(i),o=n.RHS(this.x),this.z=new t.FP(1),1==o.jacobi()?((r=o.sqrt()).redc().parity()!=e&&r.neg(),this.y=r):this.inf()},setx:function(i){var e;this.x=new t.FP(0),this.x.bcopy(i),e=n.RHS(this.x),this.z=new t.FP(1),1==e.jacobi()?n.CURVETYPE!=n.MONTGOMERY&&(this.y=e.sqrt()):this.inf()},affine:function(){var i;this.is_infinity()||(i=new t.FP(1),this.z.equals(i)||(this.z.inverse(),n.CURVETYPE!=n.EDWARDS&&n.CURVETYPE!=n.WEIERSTRASS||(this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z=i),n.CURVETYPE==n.MONTGOMERY&&(this.x.mul(this.z),this.x.reduce(),this.z=i)))},getX:function(){return this.affine(),this.x.redc()},getY:function(){return this.affine(),this.y.redc()},getS:function(){return this.affine(),this.getY().parity()},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(i){var e,o=[];for(n.CURVETYPE!=n.MONTGOMERY?i[0]=4:i[0]=2,this.affine(),this.x.redc().toBytes(o),e=0;e>2),p.add(y),p.norm(),this.z.copy(p),this.z.mul(a))},add:function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,m,p,d;n.CURVETYPE==n.WEIERSTRASS&&(0==t.ROM_CURVE.CURVE_A?(e=3*t.ROM_CURVE.CURVE_B_I,(o=new t.FP(0)).copy(this.x),o.mul(i.x),(r=new t.FP(0)).copy(this.y),r.mul(i.y),(s=new t.FP(0)).copy(this.z),s.mul(i.z),(h=new t.FP(0)).copy(this.x),h.add(this.y),h.norm(),(c=new t.FP(0)).copy(i.x),c.add(i.y),c.norm(),h.mul(c),c.copy(o),c.add(r),h.sub(c),h.norm(),c.copy(this.y),c.add(this.z),c.norm(),(u=new t.FP(0)).copy(i.y),u.add(i.z),u.norm(),c.mul(u),u.copy(r),u.add(s),c.sub(u),c.norm(),u.copy(this.x),u.add(this.z),u.norm(),(a=new t.FP(0)).copy(i.x),a.add(i.z),a.norm(),u.mul(a),a.copy(o),a.add(s),a.rsub(u),a.norm(),u.copy(o),u.add(o),o.add(u),o.norm(),s.imul(e),(f=new t.FP(0)).copy(r),f.add(s),f.norm(),r.sub(s),r.norm(),a.imul(e),u.copy(a),u.mul(c),s.copy(h),s.mul(r),u.rsub(s),a.mul(o),r.mul(f),a.add(r),o.mul(h),f.mul(c),f.add(o),this.x.copy(u),this.x.norm(),this.y.copy(a),this.y.norm(),this.z.copy(f),this.z.norm()):((o=new t.FP(0)).copy(this.x),(r=new t.FP(0)).copy(this.y),(s=new t.FP(0)).copy(this.z),(h=new t.FP(0)).copy(this.x),(c=new t.FP(0)).copy(i.x),f=new t.FP(0),(a=new t.FP(0)).copy(i.x),(u=new t.FP(0)).copy(i.y),e=new t.FP(0),0==t.ROM_CURVE.CURVE_B_I&&e.rcopy(t.ROM_CURVE.CURVE_B),o.mul(i.x),r.mul(i.y),s.mul(i.z),h.add(this.y),h.norm(),c.add(i.y),c.norm(),h.mul(c),c.copy(o),c.add(r),h.sub(c),h.norm(),c.copy(this.y),c.add(this.z),c.norm(),u.add(i.z),u.norm(),c.mul(u),u.copy(r),u.add(s),c.sub(u),c.norm(),u.copy(this.x),u.add(this.z),u.norm(),a.add(i.z),a.norm(),u.mul(a),a.copy(o),a.add(s),a.rsub(u),a.norm(),f.copy(s),0==t.ROM_CURVE.CURVE_B_I?f.mul(e):f.imul(t.ROM_CURVE.CURVE_B_I),u.copy(a),u.sub(f),u.norm(),f.copy(u),f.add(u),u.add(f),f.copy(r),f.sub(u),f.norm(),u.add(r),u.norm(),0==t.ROM_CURVE.CURVE_B_I?a.mul(e):a.imul(t.ROM_CURVE.CURVE_B_I),r.copy(s),r.add(s),s.add(r),a.sub(s),a.sub(o),a.norm(),r.copy(a),r.add(a),a.add(r),a.norm(),r.copy(o),r.add(o),o.add(r),o.sub(s),o.norm(),r.copy(c),r.mul(a),s.copy(o),s.mul(a),a.copy(u),a.mul(f),a.add(s),u.mul(h),u.sub(r),f.mul(c),r.copy(h),r.mul(o),f.add(r),this.x.copy(u),this.x.norm(),this.y.copy(a),this.y.norm(),this.z.copy(f),this.z.norm())),n.CURVETYPE==n.EDWARDS&&((E=new t.FP(0)).copy(this.z),B=new t.FP(0),(y=new t.FP(0)).copy(this.x),(I=new t.FP(0)).copy(this.y),m=new t.FP(0),p=new t.FP(0),d=new t.FP(0),E.mul(i.z),B.copy(E),B.sqr(),y.mul(i.x),I.mul(i.y),m.copy(y),m.mul(I),0==t.ROM_CURVE.CURVE_B_I?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),m.mul(e)):m.imul(t.ROM_CURVE.CURVE_B_I),p.copy(B),p.sub(m),d.copy(B),d.add(m),1==t.ROM_CURVE.CURVE_A&&(m.copy(I),m.sub(y)),y.add(I),B.copy(this.x),B.add(this.y),I.copy(i.x),I.add(i.y),B.norm(),I.norm(),B.mul(I),B.sub(y),B.norm(),p.norm(),B.mul(p),this.x.copy(E),this.x.mul(B),d.norm(),1==t.ROM_CURVE.CURVE_A&&(m.norm(),y.copy(m),y.mul(d)),-1==t.ROM_CURVE.CURVE_A&&(y.norm(),y.mul(d)),this.y.copy(E),this.y.mul(y),this.z.copy(p),this.z.mul(d))},dadd:function(n,i){var e,o,r,s,h,c;(e=new t.FP(0)).copy(this.x),(o=new t.FP(0)).copy(this.x),(r=new t.FP(0)).copy(n.x),(s=new t.FP(0)).copy(n.x),h=new t.FP(0),c=new t.FP(0),e.add(this.z),o.sub(this.z),r.add(n.z),s.sub(n.z),s.norm(),e.norm(),h.copy(s),h.mul(e),r.norm(),o.norm(),c.copy(r),c.mul(o),e.copy(h),e.add(c),e.norm(),e.sqr(),o.copy(h),o.sub(c),o.norm(),o.sqr(),this.x.copy(e),this.z.copy(i.x),this.z.mul(o)},sub:function(t){t.neg(),this.add(t),t.neg()},pinmul:function(i,e){var o,r,s,h,c;if(n.CURVETYPE==n.MONTGOMERY)return this.mul(new t.BIG(i));for(s=new n,h=new n,(c=new n).copy(this),o=e-1;o>=0;o--)r=i>>o&1,s.copy(c),s.add(h),h.cswap(c,r),c.copy(s),h.dbl(),h.cswap(c,r);return s.copy(h),s.affine(),s},cfp:function(){var n=t.ROM_CURVE.CURVE_Cof_I,i=new t.BIG(0);if(1!=n){if(4==n)return this.dbl(),this.dbl(),void this.affine();if(8==n)return this.dbl(),this.dbl(),this.dbl(),void this.affine();i.rcopy(t.ROM_CURVE.CURVE_Cof),this.copy(this.mul(i))}},mul:function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,m,p;if(i.iszilch()||this.is_infinity())return new n;if(e=new n,n.CURVETYPE==n.MONTGOMERY){for(o=new n,(r=new n).copy(this),(s=new n).copy(this),s.dbl(),o.copy(this),o.affine(),B=(I=i.nbits())-2;B>=0;B--)y=i.bit(B),e.copy(s),e.dadd(r,o),r.cswap(s,y),s.copy(e),r.dbl(),r.cswap(s,y);e.copy(r)}else{for(h=new t.BIG,c=new t.BIG,u=new n,a=new n,f=[],E=[],this.affine(),u.copy(this),u.dbl(),f[0]=new n,f[0].copy(this),B=1;B<8;B++)f[B]=new n,f[B].copy(f[B-1]),f[B].add(u);for(c.copy(i),m=c.parity(),c.inc(1),c.norm(),p=c.parity(),h.copy(c),h.inc(1),h.norm(),c.cmove(h,m),u.cmove(this,p),a.copy(u),I=1+Math.floor((c.nbits()+3)/4),B=0;B=0;B--)u.select(f,E[B]),e.dbl(),e.dbl(),e.dbl(),e.dbl(),e.add(u);e.sub(a)}return e.affine(),e},mul2:function(i,e,o){var r,s,h,c,u,a,f=new t.BIG,E=new t.BIG,B=new t.BIG,y=new n,I=new n,m=new n,p=[],d=[];for(this.affine(),e.affine(),f.copy(i),E.copy(o),p[1]=new n,p[1].copy(this),p[1].sub(e),p[2]=new n,p[2].copy(this),p[2].add(e),y.copy(e),y.dbl(),p[0]=new n,p[0].copy(p[1]),p[0].sub(y),p[3]=new n,p[3].copy(p[2]),p[3].add(y),I.copy(this),I.dbl(),p[5]=new n,p[5].copy(p[1]),p[5].add(I),p[6]=new n,p[6].copy(p[2]),p[6].add(I),p[4]=new n,p[4].copy(p[5]),p[4].sub(y),p[7]=new n,p[7].copy(p[6]),p[7].add(y),s=f.parity(),f.inc(1),f.norm(),h=f.parity(),B.copy(f),B.inc(1),B.norm(),f.cmove(B,s),I.cmove(this,h),m.copy(I),s=E.parity(),E.inc(1),E.norm(),h=E.parity(),B.copy(E),B.inc(1),B.norm(),E.cmove(B,s),y.cmove(e,h),m.add(y),B.copy(f),B.add(E),B.norm(),c=1+Math.floor((B.nbits()+1)/2),r=0;r=0;r--)I.select(p,d[r]),y.dbl(),y.dbl(),y.add(I);return y.sub(m),y.affine(),y}},n.generator=function(){var i=new n,e=new t.BIG(0),o=new t.BIG(0);return e.rcopy(t.ROM_CURVE.CURVE_Gx),t.ECP.CURVETYPE!=t.ECP.MONTGOMERY?(o.rcopy(t.ROM_CURVE.CURVE_Gy),i.setxy(e,o)):i.setx(e),i},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.fromBytes=function(i){var e,o,r,s=[],h=new n,c=new t.BIG(0);for(c.rcopy(t.ROM_FIELD.Modulus),r=0;r=0)return h;if(4==i[0]){for(r=0;r=0||h.setxy(e,o),h}return h.setx(e),h},n.RHS=function(i){var e,o,r,s,h=new t.FP(0);return i.norm(),h.copy(i),h.sqr(),n.CURVETYPE==n.WEIERSTRASS?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),h.mul(i),-3==t.ROM_CURVE.CURVE_A&&((o=new t.FP(0)).copy(i),o.imul(3),o.neg(),o.norm(),h.add(o)),h.add(e)):n.CURVETYPE==n.EDWARDS?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),r=new t.FP(1),e.mul(h),e.sub(r),e.norm(),-1==t.ROM_CURVE.CURVE_A&&h.neg(),h.sub(r),h.norm(),e.inverse(),h.mul(e)):n.CURVETYPE==n.MONTGOMERY&&((s=new t.FP(0)).copy(h),s.mul(i),h.imul(t.ROM_CURVE.CURVE_A),h.add(s),h.add(i)),h.reduce(),h},n.mapit=function(i){var e=new t.BIG(0),o=t.BIG.fromBytes(i),r=new n;for(e.rcopy(t.ROM_FIELD.Modulus),o.mod(e);;){for(;n.CURVETYPE!=n.MONTGOMERY?r.setxi(o,0):r.setx(o),o.inc(1),o.norm(),r.is_infinity(););if(r.cfp(),!r.is_infinity())break}return r},n}(h),h.ECDH=function(t){return{INVALID_PUBLIC_KEY:-2,ERROR:-3,INVALID:-4,EFS:t.BIG.MODBYTES,EGS:t.BIG.MODBYTES,SHA256:32,SHA384:48,SHA512:64,inttobytes:function(t,n){var i,e=[];for(i=0;i0&&i>0;)e[--i]=255&t,t=Math.floor(t/256);return e},bytestostring:function(t){var n,i,e="",o=t.length;for(i=0;i0&&h.process_num(e),null!=o&&h.process_array(o),0==(s=h.hash()).length)return null;if(0==r)return s;if(c=[],n>=r)for(u=0;ui)for(r=0;re)for(s=0;s32&&(c=128),o=new Array(c),s<4)return 0;for(r=0;rc)for(h=this.hashit(t,i,0,null,0),r=0;r=i.length){r=!0;break}o=i[E++]}if(u.decrypt(a),r)break;for(c=0;c<16;c++)f[B++]=a[c]}if(u.end(),s=!1,h=a[15],(15!=c||h<1||h>16)&&(s=!0),h>=2&&h<=16)for(c=16-h;c<16;c++)a[c]!=h&&(s=!0);if(!s)for(c=0;c<16-h;c++)f[B++]=a[c];if(e=[],s)return e;for(c=0;c=0||a.iszilch()||t.BIG.comp(a,h)>=0)&&(I=this.INVALID),0===I&&(a.invmodp(h),c=t.BIG.modmul(c,a,h),f=t.BIG.modmul(u,a,h),(B=t.ECP.fromBytes(i)).is_infinity()?I=this.ERROR:((y=new t.ECP).copy(B),(y=y.mul2(f,E,c)).is_infinity()?I=this.INVALID:((a=y.getX()).mod(h),0!==t.BIG.comp(a,u)&&(I=this.INVALID)))),I},ECIES_ENCRYPT:function(n,i,e,o,r,s,h,c){var u,a,f,E,B=[],y=[],I=[],m=[],p=[],d=[];if(0!==this.KEY_PAIR_GENERATE(o,p,h))return d;if(0!==this.ECPSVDP_DH(p,r,B))return d;for(E=0;E<2*this.EFS+1;E++)y[E]=h[E];for(E=0;E>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP4(this.a),i=new t.FP4(this.c),e=new t.FP4(this.b),o=new t.FP4(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP4(this.a),i=new t.FP4(this.b),e=new t.FP4(this.c),o=new t.FP4(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP4(this.a),e=new t.FP4(0),o=new t.FP4(this.b),r=new t.FP4(0),s=new t.FP4(this.a),h=new t.FP4(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP4(this.a),r=new t.FP4(this.b),s=new t.FP4(this.b),h=new t.FP4(0),c=new t.FP4(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP4(this.a),o=new t.FP4(0),r=new t.FP4(0),s=new t.FP4(0),h=new t.FP4(this.a),c=new t.FP4(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP4(this.a),i=new t.FP4(this.b),e=new t.FP4(this.a),o=new t.FP4(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n){var i=new t.FP2(n),e=new t.FP2(n);i.sqr(),e.mul(i),this.a.frob(e),this.b.frob(e),this.c.frob(e),this.b.pmul(n),this.c.pmul(i)},trace:function(){var n=new t.FP4(0);return n.copy(this.a),n.imul(3),n.reduce(),n},toString:function(){return"["+this.a.toString()+","+this.b.toString()+","+this.c.toString()+"]"},toBytes:function(n){var i,e=[];for(this.a.geta().getA().toBytes(e),i=0;i=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),m=E.trace(),B=B.xtr_pow2(y,I,m,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f=[];for(e=0;e>31&1},n.pow4=function(i,e){var o,r,s,h,c,u,a=[],f=new n(0),E=new n(0),B=[],y=new t.BIG(0),I=[],m=[];for(o=0;o<4;o++)B[o]=new t.BIG(e[o]),B[o].norm();for(a[0]=new n(i[0]),a[1]=new n(a[0]),a[1].mul(i[1]),a[2]=new n(a[0]),a[2].mul(i[2]),a[3]=new n(a[1]),a[3].mul(i[2]),a[4]=new n(i[0]),a[4].mul(i[3]),a[5]=new n(a[1]),a[5].mul(i[3]),a[6]=new n(a[2]),a[6].mul(i[3]),a[7]=new n(a[3]),a[7].mul(i[3]),u=1-B[0].parity(),B[0].inc(u),B[0].norm(),y.zero(),o=0;o<4;o++)y.or(B[o]);for(m[(h=1+y.nbits())-1]=1,o=0;o>1),B[r].norm(),I[o]+=c*s,s*=2;for(E.select(a,2*I[h-1]+1),o=h-2;o>=0;o--)E.usqr(),f.select(a,2*I[o]+m[o]),E.mul(f);return f.copy(i[0]),f.conj(),f.mul(E),E.cmove(f,u),E.reduce(),E},n}(h),h.ECP2=function(t){var n=function(){this.x=new t.FP2(0),this.y=new t.FP2(1),this.z=new t.FP2(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e,o,r=new n;o=((o=(i^(e=i>>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.neg(),this.cmove(r,1&e)},equals:function(n){var i,e;return(i=new t.FP2(0)).copy(this.x),(e=new t.FP2(0)).copy(n.x),i.copy(this.x),i.mul(n.z),i.reduce(),e.copy(n.x),e.mul(this.z),e.reduce(),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),i.reduce(),e.copy(n.y),e.mul(this.z),e.reduce(),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP2(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o=new n,r=new t.BIG(0),s=new t.BIG(0);return r.rcopy(t.ROM_CURVE.CURVE_Pxa),s.rcopy(t.ROM_CURVE.CURVE_Pxb),(i=new t.FP2(0)).bset(r,s),r.rcopy(t.ROM_CURVE.CURVE_Pya),s.rcopy(t.ROM_CURVE.CURVE_Pyb),(e=new t.FP2(0)).bset(r,s),o.setxy(i,e),o},n.fromBytes=function(i){var e,o,r,s,h,c,u=[];for(r=0;r>1),y[r].norm(),I[o]+=c*s,s*=2;for(f.select(E,2*I[h-1]+1),o=h-2;o>=0;o--)f.dbl(),a.select(E,2*I[o]+m[o]),f.add(a);return a.copy(f),a.sub(i[0]),f.cmove(a,u),f.affine(),f},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E=new t.BIG(0),B=new t.BIG(0);for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);u=new t.FP2(r,o),(s=new n).setx(u),s.is_infinity();)o.inc(1),o.norm();return E.rcopy(t.ROM_FIELD.Fra),B.rcopy(t.ROM_FIELD.Frb),u=new t.FP2(E,B),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(u.inverse(),u.norm()),(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&((h=new n).copy(s),h=h.mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&h.neg(),(c=new n).copy(h),c.dbl(),c.add(h),c.frob(u),s.frob(u),s.frob(u),s.frob(u),s.add(h),s.add(c),h.frob(u),h.frob(u),s.add(h)),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BLS&&(f=(a=s.mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&a.neg(),f.sub(a),f.sub(s),a.sub(s),a.frob(u),s.dbl(),s.frob(u),s.frob(u),s.add(f),s.add(a)),s.affine(),s},n}(h),h.PAIR=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,m=new t.FP12(1),p=new t.FP4(0);return n==i?(r=new t.FP2(n.getx()),s=new t.FP2(n.gety()),h=new t.FP2(n.getz()),(c=new t.FP2(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.pmul(o),r.imul(6),r.pmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_ip2(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.mul_ip(),h.add(h),c.mul_ip(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP4(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP4(r),p=new t.FP4(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP4(0),(p=new t.FP4(r)).times_i()),n.dbl()):(a=new t.FP2(n.getx()),f=new t.FP2(n.gety()),E=new t.FP2(n.getz()),B=new t.FP2(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.pmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.mul_ip(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.pmul(e),f.neg(),f.norm(),y=new t.FP4(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP4(f),p=new t.FP4(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP4(0),(p=new t.FP4(f)).times_i()),n.add(i)),m.set(y,I,p),m},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m,p;for((h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),c=new t.BIG(h),a=new t.ECP2,t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?((o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(s.inverse(),s.norm()),c.pmul(6),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX?c.inc(2):c.dec(2)):c.copy(h),c.norm(),(u=new t.BIG(c)).pmul(3),u.norm(),E=new t.FP(e.getx()),B=new t.FP(e.gety()),y=new t.ECP2,I=new t.FP12(1),y.copy(i),p=u.nbits()-2;p>=1;p--)I.sqr(),f=n.line(y,y,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),1==(m=u.bit(p)-c.bit(p))&&(f=n.line(y,i,E,B),I.smul(f,t.ECP.SEXTIC_TWIST)),-1==m&&(i.neg(),f=n.line(y,i,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&I.conj(),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&(t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&y.neg(),a.copy(i),a.frob(s),f=n.line(y,a,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),a.frob(s),a.neg(),f=n.line(y,a,E,B),I.smul(f,t.ECP.SEXTIC_TWIST)),I},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,m,p,d,l,w,_,S;for((u=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),a=new t.BIG(u),E=new t.ECP2,t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?((s=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),c=new t.FP2(s,h),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(c.inverse(),c.norm()),a.pmul(6),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX?a.inc(2):a.dec(2)):a.copy(u),a.norm(),(f=new t.BIG(a)).pmul(3),f.norm(),y=new t.FP(e.getx()),I=new t.FP(e.gety()),m=new t.FP(r.getx()),p=new t.FP(r.gety()),d=new t.ECP2,l=new t.ECP2,w=new t.FP12(1),d.copy(i),l.copy(o),S=f.nbits()-2;S>=1;S--)w.sqr(),B=n.line(d,d,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),B=n.line(l,l,m,p),w.smul(B,t.ECP.SEXTIC_TWIST),1==(_=f.bit(S)-a.bit(S))&&(B=n.line(d,i,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),B=n.line(l,o,m,p),w.smul(B,t.ECP.SEXTIC_TWIST)),-1==_&&(i.neg(),B=n.line(d,i,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),B=n.line(l,o,m,p),w.smul(B,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&w.conj(),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&(t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(d.neg(),l.neg()),E.copy(i),E.frob(c),B=n.line(d,E,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),E.frob(c),E.neg(),B=n.line(d,E,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),E.copy(o),E.frob(c),B=n.line(l,E,m,p),w.smul(B,t.ECP.SEXTIC_TWIST),E.frob(c),E.neg(),B=n.line(l,E,m,p),w.smul(B,t.ECP.SEXTIC_TWIST)),w},fexp:function(n){var i,e,o,r,s,h,c,u,a,f,E,B,y,I,m,p;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP12(n),(h=new t.FP12(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o),s.frob(o),s.mul(h),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?(h.copy(s),h.frob(o),(c=new t.FP12(h)).frob(o),h.mul(s),c.mul(h),c.frob(o),(u=new t.FP12(s)).conj(),E=s.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&E.conj(),(f=new t.FP12(E)).frob(o),a=E.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&a.conj(),(B=new t.FP12(a)).conj(),h=a.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&h.conj(),a.frob(o),s.copy(a),s.conj(),E.mul(s),a.frob(o),s.copy(h),s.frob(o),h.mul(s),h.usqr(),h.mul(E),h.mul(B),s.copy(f),s.mul(B),s.mul(h),h.mul(a),s.usqr(),s.mul(h),s.usqr(),h.copy(s),h.mul(u),s.mul(c),h.usqr(),s.mul(h),s.reduce()):((y=new t.FP12(s)).usqr(),I=y.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&I.conj(),r.fshr(1),m=I.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),r.fshl(1),(p=new t.FP12(s)).conj(),I.mul(p),I.conj(),I.mul(m),m=I.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),p=m.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&p.conj(),I.conj(),p.mul(I),I.conj(),I.frob(o),I.frob(o),I.frob(o),m.frob(o),m.frob(o),I.mul(m),m=p.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),m.mul(y),m.mul(s),I.mul(m),m.copy(p),m.frob(o),I.mul(m),s.copy(I),s.reduce()),s},glv:function(n){var i,e,o,r,s,h,c,u,a=[];if(t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN){for(i=new t.BIG(0),o=[],(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),c=0;c<2;c++)i.rcopy(t.ROM_CURVE.CURVE_W[c]),r=t.BIG.mul(i,n),o[c]=new t.BIG(r.div(e)),a[c]=new t.BIG(0);for(a[0].copy(n),c=0;c<2;c++)for(u=0;u<2;u++)i.rcopy(t.ROM_CURVE.CURVE_SB[u][c]),i.copy(t.BIG.modmul(o[u],i,e)),a[c].add(e),a[c].sub(i),a[c].mod(e)}else(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=t.BIG.smul(s,s),a[0]=new t.BIG(n),a[0].mod(h),a[1]=new t.BIG(n),a[1].div(h),a[1].rsub(e);return a},gs:function(n){var i,e,o,r,s,h,c,u,a=[];if(t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN){for(o=new t.BIG(0),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),s=[],i=0;i<4;i++)o.rcopy(t.ROM_CURVE.CURVE_WB[i]),h=t.BIG.mul(o,n),s[i]=new t.BIG(h.div(r)),a[i]=new t.BIG(0);for(a[0].copy(n),i=0;i<4;i++)for(e=0;e<4;e++)o.rcopy(t.ROM_CURVE.CURVE_BB[e][i]),o.copy(t.BIG.modmul(s[e],o,r)),a[i].add(r),a[i].sub(o),a[i].mod(r)}else{for((c=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),u=new t.BIG(n),i=0;i<3;i++)a[i]=new t.BIG(u),a[i].mod(c),u.div(c);a[3]=new t.BIG(u),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(a[1].copy(t.BIG.modneg(a[1],r)),a[3].copy(t.BIG.modneg(a[3],r)))}return a},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,m=0,p=[];if(0==n?y=c:(y=u,c=null),0!=(m=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return m;if(p=y.slice(),void 0!==B||null!=B)for(I=0;I>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP8(this.a),i=new t.FP8(this.c),e=new t.FP8(this.b),o=new t.FP8(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP8(this.a),i=new t.FP8(this.b),e=new t.FP8(this.c),o=new t.FP8(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP8(this.a),e=new t.FP8(0),o=new t.FP8(this.b),r=new t.FP8(0),s=new t.FP8(this.a),h=new t.FP8(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP8(this.a),r=new t.FP8(this.b),s=new t.FP8(this.b),h=new t.FP8(0),c=new t.FP8(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP8(this.a),o=new t.FP8(0),r=new t.FP8(0),s=new t.FP8(0),h=new t.FP8(this.a),c=new t.FP8(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP8(this.a),i=new t.FP8(this.b),e=new t.FP8(this.a),o=new t.FP8(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n,i){var e,o=new t.FP2(n),r=new t.FP2(n);for(o.sqr(),r.mul(o),r.mul_ip(),r.norm(),e=0;e=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s,1),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),m=E.trace(),B=B.xtr_pow2(y,I,m,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B=[];for(e=0;e>31&1},n.pow8=function(i,e){var o,r,s,h,c,u,a,f,E=[],B=[],y=new n(0),I=new n(0),m=[],p=new t.BIG(0),d=new t.BIG(0),l=new t.BIG(0),w=[],_=[],S=[],P=[];for(o=0;o<8;o++)m[o]=new t.BIG(e[o]),m[o].norm();for(E[0]=new n(i[0]),E[1]=new n(E[0]),E[1].mul(i[1]),E[2]=new n(E[0]),E[2].mul(i[2]),E[3]=new n(E[1]),E[3].mul(i[2]),E[4]=new n(i[0]),E[4].mul(i[3]),E[5]=new n(E[1]),E[5].mul(i[3]),E[6]=new n(E[2]),E[6].mul(i[3]),E[7]=new n(E[3]),E[7].mul(i[3]),d.rcopy(t.ROM_FIELD.Fra),l.rcopy(t.ROM_FIELD.Frb),f=new t.FP2(d,l),o=0;o<8;o++)B[o]=new n(E[o]),B[o].frob(f,4);for(u=1-m[0].parity(),m[0].inc(u),m[0].norm(),a=1-m[4].parity(),m[4].inc(a),m[4].norm(),p.zero(),o=0;o<8;o++)p.or(m[o]);for(_[(h=1+p.nbits())-1]=1,P[h-1]=1,o=0;o>1),m[r].norm(),w[o]+=c*s,s*=2;for(S[o]=0,s=1,r=5;r<8;r++)c=P[o]*m[r].parity(),m[r].fshr(1),m[r].dec(c>>1),m[r].norm(),S[o]+=c*s,s*=2}for(I.select(E,2*w[h-1]+1),y.select(B,2*S[h-1]+1),I.mul(y),o=h-2;o>=0;o--)I.usqr(),y.select(E,2*w[o]+_[o]),I.mul(y),y.select(B,2*S[o]+P[o]),I.mul(y);return y.copy(i[0]),y.conj(),y.mul(I),I.cmove(y,u),y.copy(i[4]),y.conj(),y.mul(I),I.cmove(y,a),I.reduce(),I},n}(h),h.ECP4=function(t){var n=function(){this.x=new t.FP4(0),this.y=new t.FP4(1),this.z=new t.FP4(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(n){var i,e;return i=new t.FP4(this.x),e=new t.FP4(n.x),i.mul(n.z),e.mul(this.z),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),e.copy(n.y),e.mul(this.z),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP4(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.geta().getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o,r,s,h,c=new n,u=new t.BIG(0),a=new t.BIG(0);return u.rcopy(t.ROM_CURVE.CURVE_Pxaa),a.rcopy(t.ROM_CURVE.CURVE_Pxab),i=new t.FP2(u,a),u.rcopy(t.ROM_CURVE.CURVE_Pxba),a.rcopy(t.ROM_CURVE.CURVE_Pxbb),e=new t.FP2(u,a),o=new t.FP4(i,e),u.rcopy(t.ROM_CURVE.CURVE_Pyaa),a.rcopy(t.ROM_CURVE.CURVE_Pyab),r=new t.FP2(u,a),u.rcopy(t.ROM_CURVE.CURVE_Pyba),a.rcopy(t.ROM_CURVE.CURVE_Pybb),s=new t.FP2(u,a),h=new t.FP4(r,s),c.setxy(o,h),c},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f=[];for(h=0;h>1),m[r].norm(),p[o]+=c*s,s*=2;for(l[o]=0,s=1,r=5;r<8;r++)c=w[o]*m[r].parity(),m[r].fshr(1),m[r].dec(c>>1),m[r].norm(),l[o]+=c*s,s*=2}for(E.select(B,2*p[h-1]+1),f.select(y,2*l[h-1]+1),E.add(f),o=h-2;o>=0;o--)E.dbl(),f.select(B,2*p[o]+d[o]),E.add(f),f.select(y,2*l[o]+w[o]),E.add(f);return f.copy(E),f.sub(i[0]),E.cmove(f,u),f.copy(E),f.sub(i[4]),E.cmove(f,a),E.affine(),E},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E,B=n.frob_constants();for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);c=new t.FP2(r,o),h=new t.FP4(c),(s=new n).setx(h),s.is_infinity();)o.inc(1),o.norm();return(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),E=(f=(a=(u=s.mul(o)).mul(o)).mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(u.neg(),f.neg()),E.sub(f),E.sub(s),f.sub(a),f.frob(B,1),a.sub(u),a.frob(B,2),u.sub(s),u.frob(B,3),s.dbl(),s.frob(B,4),s.add(E),s.add(f),s.add(a),s.add(u),s.affine(),s},n.frob_constants=function(){var n,i,e,o,r=new t.BIG(0),s=new t.BIG(0),h=[];return r.rcopy(t.ROM_FIELD.Fra),s.rcopy(t.ROM_FIELD.Frb),n=new t.FP2(r,s),(i=new t.FP2(n)).sqr(),(o=new t.FP2(i)).mul_ip(),o.norm(),(e=new t.FP2(o)).sqr(),o.mul(e),e.copy(n),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(e.mul_ip(),e.inverse(),i.copy(e),i.sqr()),i.mul_ip(),i.norm(),e.mul(i),h[0]=new t.FP2(i),h[1]=new t.FP2(e),h[2]=new t.FP2(o),h},n}(h),h.PAIR192=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,m,p=new t.FP24(1);return n==i?(r=new t.FP4(n.getx()),s=new t.FP4(n.gety()),h=new t.FP4(n.getz()),(c=new t.FP4(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.qmul(o),r.imul(6),r.qmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_2i(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.times_i(),h.add(h),c.times_i(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP8(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP8(r),m=new t.FP8(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP8(0),(m=new t.FP8(r)).times_i()),n.dbl()):(a=new t.FP4(n.getx()),f=new t.FP4(n.gety()),E=new t.FP4(n.getz()),B=new t.FP4(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.qmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.times_i(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.qmul(e),f.neg(),f.norm(),y=new t.FP8(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP8(f),m=new t.FP8(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP8(0),(m=new t.FP8(f)).times_i()),n.add(i)),p.set(y,I,m),p},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B;for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),r=new t.BIG(o),(s=new t.BIG(r)).pmul(3),s.norm(),c=new t.FP(e.getx()),u=new t.FP(e.gety()),a=new t.ECP4,f=new t.FP24(1),a.copy(i),B=s.nbits()-2;B>=1;B--)f.sqr(),h=n.line(a,a,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),1==(E=s.bit(B)-r.bit(B))&&(h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST)),-1==E&&(i.neg(),h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&f.conj(),f},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,m,p,d;for((s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=new t.BIG(s),(c=new t.BIG(h)).pmul(3),c.norm(),a=new t.FP(e.getx()),f=new t.FP(e.gety()),E=new t.FP(r.getx()),B=new t.FP(r.gety()),y=new t.ECP4,I=new t.ECP4,m=new t.FP24(1),y.copy(i),I.copy(o),d=c.nbits()-2;d>=1;d--)m.sqr(),u=n.line(y,y,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,I,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),1==(p=c.bit(d)-h.bit(d))&&(u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST)),-1==p&&(i.neg(),u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),m},fexp:function(n){var i,e,o,r,s,h,c,u,a,f,E,B,y,I;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP24(n),(h=new t.FP24(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o,4),s.mul(h),(I=new t.FP24(s)).usqr(),u=I.pow(r),r.fshr(1),a=u.pow(r),r.fshl(1),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&u.conj(),(f=new t.FP24(u)).conj(),a.mul(f),a.mul(s),B=(E=(f=a.pow(r)).pow(r)).pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(f.conj(),B.conj()),f.frob(o,6),E.frob(o,5),f.mul(E),y=B.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&y.conj(),B.frob(o,4),f.mul(B),(c=new t.FP24(a)).conj(),y.mul(c),B.copy(y),B.frob(o,3),f.mul(B),B=y.pow(r),y=B.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&B.conj(),c.copy(B),c.frob(o,2),f.mul(c),c.copy(y),c.frob(o,1),f.mul(c),B=y.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&B.conj(),a.frob(o,7),B.mul(I),f.mul(a),f.mul(B),s.mul(f),s.reduce(),s},glv:function(n){var i,e,o,r=[];return(i=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),o=t.BIG.smul(e,e),e=t.BIG.smul(o,o),r[0]=new t.BIG(n),r[0].mod(e),r[1]=new t.BIG(n),r[1].div(e),r[1].rsub(i),r},gs:function(n){var i,e,o,r,s=[];for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),r=new t.BIG(n),i=0;i<7;i++)s[i]=new t.BIG(r),s[i].mod(o),r.div(o);return s[7]=new t.BIG(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(s[1].copy(t.BIG.modneg(s[1],e)),s[3].copy(t.BIG.modneg(s[3],e)),s[5].copy(t.BIG.modneg(s[5],e)),s[7].copy(t.BIG.modneg(s[7],e))),s},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,m=0,p=[];if(0==n?y=c:(y=u,c=null),0!=(m=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return m;if(p=y.slice(),void 0!==B||null!=B)for(I=0;I=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),m=new n(0),p=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),p++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(m)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(m)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(m)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(m)):(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP16(this.a),i=new t.FP16(this.c),e=new t.FP16(this.b),o=new t.FP16(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP16(this.a),i=new t.FP16(this.b),e=new t.FP16(this.c),o=new t.FP16(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP16(this.a),e=new t.FP16(0),o=new t.FP16(this.b),r=new t.FP16(0),s=new t.FP16(this.a),h=new t.FP16(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP16(this.a),r=new t.FP16(this.b),s=new t.FP16(this.b),h=new t.FP16(0),c=new t.FP16(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP16(this.a),o=new t.FP16(0),r=new t.FP16(0),s=new t.FP16(0),h=new t.FP16(this.a),c=new t.FP16(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP16(this.a),i=new t.FP16(this.b),e=new t.FP16(this.a),o=new t.FP16(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n,i){var e,o=new t.FP2(n),r=new t.FP2(n);for(o.sqr(),r.mul(o),r.mul_ip(),r.norm(),r.mul_ip(),r.norm(),e=0;e=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s,1),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),m=E.trace(),B=B.xtr_pow2(y,I,m,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I=[];for(e=0;e>31&1},n.pow16=function(i,e){var o,r,s,h,c,u,a,f,E,B,y=[],I=[],m=[],p=[],d=new n(0),l=new n(0),w=[],_=new t.BIG(0),S=new t.BIG(0),P=new t.BIG(0),T=[],C=[],b=[],G=[],R=[],g=[],M=[],O=[];for(o=0;o<16;o++)w[o]=new t.BIG(e[o]),w[o].norm();for(y[0]=new n(i[0]),y[1]=new n(y[0]),y[1].mul(i[1]),y[2]=new n(y[0]),y[2].mul(i[2]),y[3]=new n(y[1]),y[3].mul(i[2]),y[4]=new n(i[0]),y[4].mul(i[3]),y[5]=new n(y[1]),y[5].mul(i[3]),y[6]=new n(y[2]),y[6].mul(i[3]),y[7]=new n(y[3]),y[7].mul(i[3]),S.rcopy(t.ROM_FIELD.Fra),P.rcopy(t.ROM_FIELD.Frb),B=new t.FP2(S,P),o=0;o<8;o++)I[o]=new n(y[o]),I[o].frob(B,4),m[o]=new n(I[o]),m[o].frob(B,4),p[o]=new n(m[o]),p[o].frob(B,4);for(u=1-w[0].parity(),w[0].inc(u),w[0].norm(),a=1-w[4].parity(),w[4].inc(a),w[4].norm(),f=1-w[8].parity(),w[8].inc(f),w[8].norm(),E=1-w[12].parity(),w[12].inc(E),w[12].norm(),_.zero(),o=0;o<16;o++)_.or(w[o]);for(C[(h=1+_.nbits())-1]=1,G[h-1]=1,g[h-1]=1,O[h-1]=1,o=0;o>1),w[r].norm(),T[o]+=c*s,s*=2;for(b[o]=0,s=1,r=5;r<8;r++)c=G[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),b[o]+=c*s,s*=2;for(R[o]=0,s=1,r=9;r<12;r++)c=g[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),R[o]+=c*s,s*=2;for(M[o]=0,s=1,r=13;r<16;r++)c=O[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),M[o]+=c*s,s*=2}for(l.select(y,2*T[h-1]+1),d.select(I,2*b[h-1]+1),l.mul(d),d.select(m,2*R[h-1]+1),l.mul(d),d.select(p,2*M[h-1]+1),l.mul(d),o=h-2;o>=0;o--)l.usqr(),d.select(y,2*T[o]+C[o]),l.mul(d),d.select(I,2*b[o]+G[o]),l.mul(d),d.select(m,2*R[o]+g[o]),l.mul(d),d.select(p,2*M[o]+O[o]),l.mul(d);return d.copy(i[0]),d.conj(),d.mul(l),l.cmove(d,u),d.copy(i[4]),d.conj(),d.mul(l),l.cmove(d,a),d.copy(i[8]),d.conj(),d.mul(l),l.cmove(d,f),d.copy(i[12]),d.conj(),d.mul(l),l.cmove(d,E),l.reduce(),l},n}(h),h.ECP8=function(t){var n=function(){this.x=new t.FP8(0),this.y=new t.FP8(1),this.z=new t.FP8(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(n){var i,e;return i=new t.FP8(this.x),e=new t.FP8(n.x),i.mul(n.z),e.mul(this.z),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),e.copy(n.y),e.mul(this.z),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP8(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.geta().geta().getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o,r,s,h,c,u,a,f,E,B,y,I,m=new n,p=new t.BIG(0),d=new t.BIG(0);return p.rcopy(t.ROM_CURVE.CURVE_Pxaaa),d.rcopy(t.ROM_CURVE.CURVE_Pxaab),i=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pxaba),d.rcopy(t.ROM_CURVE.CURVE_Pxabb),e=new t.FP2(p,d),o=new t.FP4(i,e),p.rcopy(t.ROM_CURVE.CURVE_Pxbaa),d.rcopy(t.ROM_CURVE.CURVE_Pxbab),r=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pxbba),d.rcopy(t.ROM_CURVE.CURVE_Pxbbb),s=new t.FP2(p,d),h=new t.FP4(r,s),c=new t.FP8(o,h),p.rcopy(t.ROM_CURVE.CURVE_Pyaaa),d.rcopy(t.ROM_CURVE.CURVE_Pyaab),u=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pyaba),d.rcopy(t.ROM_CURVE.CURVE_Pyabb),a=new t.FP2(p,d),f=new t.FP4(u,a),p.rcopy(t.ROM_CURVE.CURVE_Pybaa),d.rcopy(t.ROM_CURVE.CURVE_Pybab),E=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pybba),d.rcopy(t.ROM_CURVE.CURVE_Pybbb),B=new t.FP2(p,d),y=new t.FP4(E,B),I=new t.FP8(f,y),m.setxy(c,I),m},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B=[];for(u=0;u>1),w[r].norm(),_[o]+=c*s,s*=2;for(P[o]=0,s=1,r=5;r<8;r++)c=T[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),P[o]+=c*s,s*=2;for(C[o]=0,s=1,r=9;r<12;r++)c=b[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),C[o]+=c*s,s*=2;for(G[o]=0,s=1,r=13;r<16;r++)c=R[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),G[o]+=c*s,s*=2}for(y.select(I,2*_[h-1]+1),B.select(m,2*P[h-1]+1),y.add(B),B.select(p,2*C[h-1]+1),y.add(B),B.select(d,2*G[h-1]+1),y.add(B),o=h-2;o>=0;o--)y.dbl(),B.select(I,2*_[o]+S[o]),y.add(B),B.select(m,2*P[o]+T[o]),y.add(B),B.select(p,2*C[o]+b[o]),y.add(B),B.select(d,2*G[o]+R[o]),y.add(B);return B.copy(y),B.sub(i[0]),y.cmove(B,u),B.copy(y),B.sub(i[4]),y.cmove(B,a),B.copy(y),B.sub(i[8]),y.cmove(B,f),B.copy(y),B.sub(i[12]),y.cmove(B,E),y.affine(),y},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,m,p,d=n.frob_constants();for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);c=new t.FP2(r,o),u=new t.FP4(c),h=new t.FP8(u),(s=new n).setx(h),s.is_infinity();)o.inc(1),o.norm();return(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),p=(m=(I=(y=(B=(E=(f=(a=s.mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(a.neg(),E.neg(),y.neg(),m.neg()),p.sub(m),p.sub(s),m.sub(I),m.frob(d,1),I.sub(y),I.frob(d,2),y.sub(B),y.frob(d,3),B.sub(E),B.frob(d,4),E.sub(f),E.frob(d,5),f.sub(a),f.frob(d,6),a.sub(s),a.frob(d,7),s.dbl(),s.frob(d,8),s.add(p),s.add(m),s.add(I),s.add(y),s.add(B),s.add(E),s.add(f),s.add(a),s.affine(),s},n.frob_constants=function(){var n,i,e,o,r=new t.BIG(0),s=new t.BIG(0),h=[];return r.rcopy(t.ROM_FIELD.Fra),s.rcopy(t.ROM_FIELD.Frb),n=new t.FP2(r,s),(i=new t.FP2(n)).sqr(),(o=new t.FP2(i)).mul_ip(),o.norm(),(e=new t.FP2(o)).sqr(),o.mul(e),o.mul_ip(),o.norm(),e.copy(n),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(e.mul_ip(),e.inverse(),i.copy(e),i.sqr()),i.mul_ip(),i.norm(),e.mul(i),h[0]=new t.FP2(i),h[1]=new t.FP2(e),h[2]=new t.FP2(o),h},n}(h),h.PAIR256=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,m,p=new t.FP48(1);return n==i?(r=new t.FP8(n.getx()),s=new t.FP8(n.gety()),h=new t.FP8(n.getz()),(c=new t.FP8(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.tmul(o),r.imul(6),r.tmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_2i(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.times_i(),h.add(h),c.times_i(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP16(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP16(r),m=new t.FP16(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP16(0),(m=new t.FP16(r)).times_i()),n.dbl()):(a=new t.FP8(n.getx()),f=new t.FP8(n.gety()),E=new t.FP8(n.getz()),B=new t.FP8(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.tmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.times_i(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.tmul(e),f.neg(),f.norm(),y=new t.FP16(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP16(f),m=new t.FP16(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP16(0),(m=new t.FP16(f)).times_i()),n.add(i)),p.set(y,I,m),p},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B;for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),r=new t.BIG(o),(s=new t.BIG(r)).pmul(3),s.norm(),c=new t.FP(e.getx()),u=new t.FP(e.gety()),a=new t.ECP8,f=new t.FP48(1),a.copy(i),B=s.nbits()-2;B>=1;B--)f.sqr(),h=n.line(a,a,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),1==(E=s.bit(B)-r.bit(B))&&(h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST)),-1==E&&(i.neg(),h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&f.conj(),f},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,m,p,d;for((s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=new t.BIG(s),(c=new t.BIG(h)).pmul(3),c.norm(),a=new t.FP(e.getx()),f=new t.FP(e.gety()),E=new t.FP(r.getx()),B=new t.FP(r.gety()),y=new t.ECP8,I=new t.ECP8,m=new t.FP48(1),y.copy(i),I.copy(o),d=c.nbits()-2;d>=1;d--)m.sqr(),u=n.line(y,y,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,I,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),1==(p=c.bit(d)-h.bit(d))&&(u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST)),-1==p&&(i.neg(),u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),m},fexp:function(n){var i,e,o,r,s,h,c,u,a,f;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP48(n),(h=new t.FP48(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o,8),s.mul(h),(f=new t.FP48(s)).usqr(),c=f.pow(r),r.fshr(1),u=c.pow(r),r.fshl(1),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),(a=new t.FP48(c)).conj(),u.mul(a),u.mul(s),s.mul(f),c=u.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,14),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,13),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,12),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,11),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,10),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,9),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,8),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(u),a.conj(),c.mul(a),a.copy(c),a.frob(o,7),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,6),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,5),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,4),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,3),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,2),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,1),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),s.mul(c),u.frob(o,15),s.mul(u),s.reduce(),s},glv:function(n){var i,e,o,r=[];return(i=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),o=t.BIG.smul(e,e),e=t.BIG.smul(o,o),o=t.BIG.smul(e,e),r[0]=new t.BIG(n),r[0].mod(o),r[1]=new t.BIG(n),r[1].div(o),r[1].rsub(i),r},gs:function(n){var i,e,o,r,s=[];for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),r=new t.BIG(n),i=0;i<15;i++)s[i]=new t.BIG(r),s[i].mod(o),r.div(o);return s[15]=new t.BIG(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(s[1].copy(t.BIG.modneg(s[1],e)),s[3].copy(t.BIG.modneg(s[3],e)),s[5].copy(t.BIG.modneg(s[5],e)),s[7].copy(t.BIG.modneg(s[7],e)),s[9].copy(t.BIG.modneg(s[9],e)),s[11].copy(t.BIG.modneg(s[11],e)),s[13].copy(t.BIG.modneg(s[13],e)),s[15].copy(t.BIG.modneg(s[15],e))),s},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,m=0,p=[];if(0==n?y=c:(y=u,c=null),0!=(m=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return m;if(p=y.slice(),void 0!==B||null!=B)for(I=0;I6||t.defaultPinLength<4)&&(t.defaultPinLength=4),t.requestTimeout&&!isNaN(t.requestTimeout)||(t.requestTimeout=4e3),t.oidc||(t.oidc={}),t.clientName="MIRACL Client.js/8.7.0"+(t.applicationInfo?" "+t.applicationInfo:""),n.options=t,n.http=new u(t.requestTimeout,t.clientName,t.projectId,t.cors),n.crypto=new h(t.seed),n.users=new c(t.userStorage,t.projectId,"mfa")}return h.prototype._crypto=function(t){return t||(t="BN254CX"),s[t]||(s[t]=new r(t),s[t].MPIN.MAXPIN=1e6,s[t].MPIN.PBLEN=20,s[t].MPIN.TRAP=2e3),s[t]},h.prototype.generateKeypair=function(t){var n,i=this,e=[],o=[];if(0!=(n=i._crypto(t).MPIN.GET_DVS_KEYPAIR(i.rng,e,o)))throw new Error("Could not generate key pair: "+n);return{publicKey:i._bytesToHex(o),privateKey:i._bytesToHex(e)}},h.prototype.addShares=function(t,n,i,e){var o,r,s,h,c=this,u=[];if(o=c._hexToBytes(t),r=c._hexToBytes(n),s=c._hexToBytes(i),0!==(h=c._crypto(e).MPIN.RECOMBINE_G1(r,s,u)))throw new Error("Could not combine the client secret shares: "+h);if(0!=(h=c._crypto(e).MPIN.GET_G1_MULTIPLE(null,0,o,u,u)))throw new Error("Could not combine private key with client secret: "+h);return c._bytesToHex(u)},h.prototype.extractPin=function(t,n,i,e,o){var r,s,h,c=this;if(r=c._hexToBytes(e),s=c._hexToBytes(c._mpinIdWithPublicKey(t,n)),0!==(h=c._crypto(o).MPIN.EXTRACT_PIN(c._crypto(o).MPIN.SHA256,s,i,r)))throw new Error("Could not extract PIN from client secret: "+h);return c._bytesToHex(r)},h.prototype.calculatePass1=function(t,n,i,e,o,r,s){var h,c,u=this,a=[],f=[];if(h=u._mpinIdWithPublicKey(n,i),0!==(c=u._crypto(t).MPIN.CLIENT_1(u._crypto(t).MPIN.SHA256,0,u._hexToBytes(h),u.rng,r,o,u._hexToBytes(e),s,a,f,u._hexToBytes(0))))throw new Error("Could not calculate pass 1 request data: "+c);return{UT:u._bytesToHex(f),U:u._bytesToHex(a)}},h.prototype.calculatePass2=function(t,n,i,e){var o,r=this;if(0!==(o=r._crypto(t).MPIN.CLIENT_2(n,r._hexToBytes(i),e)))throw new Error("Could not calculate pass 2 request data: "+o);return r._bytesToHex(e)},h.prototype.sign=function(t,n,i,e,o,r,s){var h,c,u=this,a=[],f=[];if(h=u._mpinIdWithPublicKey(n,i),0!=(c=u._crypto(t).MPIN.CLIENT(u._crypto(t).MPIN.SHA256,0,u._hexToBytes(h),u.rng,[],o,u._hexToBytes(e),a,f,null,null,s,[],u._hexToBytes(r))))throw new Error("Could not sign message: "+c);return{U:u._bytesToHex(f),V:u._bytesToHex(a)}},h.prototype._mpinIdWithPublicKey=function(t,n){var i,e=this,o=e._hexToBytes(t),r=e._hexToBytes(n);if(o){if(!r)return t;for(i=0;i>>4&15).toString(16),e+=(15&n).toString(16);return e},c.prototype.data=[],c.prototype.states={start:"STARTED",register:"REGISTERED",revoked:"REVOKED"},c.prototype.loadData=function(){var t=this;t.data=JSON.parse(t.storage.getItem(t.storageKey))||[],t.store(),t.data.sort((function(t,n){return t.lastUsed&&(!n.lastUsed||t.lastUsed>n.lastUsed)?1:n.lastUsed&&(!t.lastUsed||t.lastUsedt.FP.FEXCESS&&(this.a.XES>1&&this.a.reduce(),this.b.XES>1&&this.b.reduce()),i=t.BIG.mul(this.a.f,n.a.f),e=t.BIG.mul(this.b.f,n.b.f),o=new t.BIG(this.a.f),r=new t.BIG(n.a.f),o.add(this.b.f),o.norm(),r.add(n.b.f),r.norm(),s=t.BIG.mul(o,r),(h=new t.DBIG(0)).copy(i),h.add(e),e.rsub(u),i.add(e),i.norm(),s.sub(h),s.norm(),this.a.f.copy(t.FP.mod(i)),this.a.XES=3,this.b.f.copy(t.FP.mod(s)),this.b.XES=2},sqrt:function(){var n,i;return!!this.iszilch()||(n=new t.FP(this.b),i=new t.FP(this.a),n.sqr(),i.sqr(),n.add(i),1!=n.jacobi()?(this.zero(),!1):(n=n.sqrt(),i.copy(this.a),i.add(n),i.norm(),i.div2(),1!=i.jacobi()&&(i.copy(this.a),i.sub(n),i.norm(),i.div2(),1!=i.jacobi())?(this.zero(),!1):(i=i.sqrt(),this.a.copy(i),i.add(i),i.inverse(),this.b.mul(i),!0)))},toString:function(){return"["+this.a.toString()+","+this.b.toString()+"]"},inverse:function(){var n,i;this.norm(),n=new t.FP(this.a),i=new t.FP(this.b),n.sqr(),i.sqr(),n.add(i),n.inverse(),this.a.mul(n),n.neg(),n.norm(),this.b.mul(n)},div2:function(){this.a.div2(),this.b.div2()},times_i:function(){var n=new t.FP(this.a);this.a.copy(this.b),this.a.neg(),this.b.copy(n)},mul_ip:function(){var i=new n(this),e=new t.FP(this.a);this.a.copy(this.b),this.a.neg(),this.b.copy(e),this.add(i)},div_ip2:function(){var t=new n(0);this.norm(),t.a.copy(this.a),t.a.add(this.b),t.b.copy(this.b),t.b.sub(this.a),this.copy(t),this.norm()},div_ip:function(){var t=new n(0);this.norm(),t.a.copy(this.a),t.a.add(this.b),t.b.copy(this.b),t.b.sub(this.a),this.copy(t),this.norm(),this.div2()},pow:function(t){this.norm();var i,e=new n(1),o=new n(this);for(t.norm();i=t.parity(),t.fshr(1),1==i&&e.mul(o),!t.iszilch();)o.sqr();return e.reduce(),e}},n}function n(t){var n=function(i,e){i instanceof n?(this.a=new t.FP2(i.a),this.b=new t.FP2(i.b)):(this.a=new t.FP2(i),this.b=new t.FP2(e))};return n.prototype={reduce:function(){this.a.reduce(),this.b.reduce()},norm:function(){this.a.norm(),this.b.norm()},iszilch:function(){return this.reduce(),this.a.iszilch()&&this.b.iszilch()},isunity:function(){var n=new t.FP2(1);return this.a.equals(n)&&this.b.iszilch()},cmove:function(t,n){this.a.cmove(t.a,n),this.b.cmove(t.b,n)},isreal:function(){return this.b.iszilch()},real:function(){return this.a},geta:function(){return this.a},getb:function(){return this.b},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b)},zero:function(){this.a.zero(),this.b.zero()},one:function(){this.a.one(),this.b.zero()},set:function(t,n){this.a.copy(t),this.b.copy(n)},seta:function(t){this.a.copy(t),this.b.zero()},neg:function(){this.norm();var n=new t.FP2(this.a),i=new t.FP2(0);n.add(this.b),n.neg(),i.copy(n),i.add(this.b),this.b.copy(n),this.b.add(this.a),this.a.copy(i),this.norm()},conj:function(){this.b.neg(),this.norm()},nconj:function(){this.a.neg(),this.norm()},add:function(t){this.a.add(t.a),this.b.add(t.b)},sub:function(t){var i=new n(t);i.neg(),this.add(i)},rsub:function(t){this.neg(),this.add(t)},pmul:function(t){this.a.mul(t),this.b.mul(t)},imul:function(t){this.a.imul(t),this.b.imul(t)},sqr:function(){var n=new t.FP2(this.a),i=new t.FP2(this.b),e=new t.FP2(this.a);e.mul(this.b),n.add(this.b),n.norm(),i.mul_ip(),i.add(this.a),i.norm(),this.a.copy(n),this.a.mul(i),i.copy(e),i.mul_ip(),i.add(e),i.norm(),i.neg(),this.a.add(i),this.b.copy(e),this.b.add(e),this.norm()},mul:function(n){var i=new t.FP2(this.a),e=new t.FP2(this.b),o=new t.FP2(0),r=new t.FP2(this.b);i.mul(n.a),e.mul(n.b),o.copy(n.b),o.add(n.a),r.add(this.a),o.norm(),r.norm(),r.mul(o),o.copy(i),o.neg(),r.add(o),o.copy(e),o.neg(),this.b.copy(r),this.b.add(o),e.mul_ip(),this.a.copy(e),this.a.add(i),this.norm()},toString:function(){return"["+this.a.toString()+","+this.b.toString()+"]"},inverse:function(){this.norm();var n=new t.FP2(this.a),i=new t.FP2(this.b);n.sqr(),i.sqr(),i.mul_ip(),i.norm(),n.sub(i),n.inverse(),this.a.mul(n),n.neg(),n.norm(),this.b.mul(n)},times_i:function(){var n=new t.FP2(this.b),i=new t.FP2(this.b);n.times_i(),i.add(n),this.b.copy(this.a),this.a.copy(i),this.norm()},frob:function(t){this.a.conj(),this.b.conj(),this.b.mul(t)},pow:function(i){this.norm(),i.norm();for(var e,o=new n(this),r=new t.BIG(i),s=new n(1);e=r.parity(),r.fshr(1),1===e&&s.mul(o),!r.iszilch();)o.sqr();return s.reduce(),s},xtr_A:function(t,i,e){var o=new n(t),r=new n(t);o.sub(i),o.norm(),o.pmul(this.a),r.add(i),r.norm(),r.pmul(this.b),r.times_i(),this.copy(o),this.add(r),this.add(e),this.reduce()},xtr_D:function(){var t=new n(this);this.sqr(),t.conj(),t.add(t),this.sub(t),this.reduce()},xtr_pow:function(i){var e,o,r,s=new n(3),h=new n(this),c=new n(h),u=new n(0),a=new n(0);for(c.xtr_D(),i.norm(),e=i.parity(),(o=new t.BIG(i)).fshr(1),0===e&&(o.dec(1),o.norm()),r=o.nbits()-1;r>=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),m=new n(0),p=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),p++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(m)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(m)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(m)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(m)):(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),m=new n(0),p=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),p++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(m)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(m)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(m)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(m)):(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h>>8&255])^t.ROTL16(t.ftable[h[2]>>>16&255])^t.ROTL24(t.ftable[h[3]>>>24&255]),c[1]=this.fkey[r+1]^t.ftable[255&h[1]]^t.ROTL8(t.ftable[h[2]>>>8&255])^t.ROTL16(t.ftable[h[3]>>>16&255])^t.ROTL24(t.ftable[h[0]>>>24&255]),c[2]=this.fkey[r+2]^t.ftable[255&h[2]]^t.ROTL8(t.ftable[h[3]>>>8&255])^t.ROTL16(t.ftable[h[0]>>>16&255])^t.ROTL24(t.ftable[h[1]>>>24&255]),c[3]=this.fkey[r+3]^t.ftable[255&h[3]]^t.ROTL8(t.ftable[h[0]>>>8&255])^t.ROTL16(t.ftable[h[1]>>>16&255])^t.ROTL24(t.ftable[h[2]>>>24&255]),r+=4,o=0;o<4;o++)i=h[o],h[o]=c[o],c[o]=i;for(c[0]=this.fkey[r]^255&t.fbsub[255&h[0]]^t.ROTL8(255&t.fbsub[h[1]>>>8&255])^t.ROTL16(255&t.fbsub[h[2]>>>16&255])^t.ROTL24(255&t.fbsub[h[3]>>>24&255]),c[1]=this.fkey[r+1]^255&t.fbsub[255&h[1]]^t.ROTL8(255&t.fbsub[h[2]>>>8&255])^t.ROTL16(255&t.fbsub[h[3]>>>16&255])^t.ROTL24(255&t.fbsub[h[0]>>>24&255]),c[2]=this.fkey[r+2]^255&t.fbsub[255&h[2]]^t.ROTL8(255&t.fbsub[h[3]>>>8&255])^t.ROTL16(255&t.fbsub[h[0]>>>16&255])^t.ROTL24(255&t.fbsub[h[1]>>>24&255]),c[3]=this.fkey[r+3]^255&t.fbsub[255&h[3]]^t.ROTL8(255&t.fbsub[h[0]>>>8&255])^t.ROTL16(255&t.fbsub[h[1]>>>16&255])^t.ROTL24(255&t.fbsub[h[2]>>>24&255]),e=o=0;e<4;e++,o+=4)for(s=t.unpack(c[e]),r=0;r<4;r++)n[o+r]=s[r]},ecb_decrypt:function(n){var i,e,o,r,s=[],h=[],c=[];for(e=o=0;e<4;e++,o+=4){for(r=0;r<4;r++)s[r]=n[o+r];h[e]=t.pack(s),h[e]^=this.rkey[e]}for(r=4,e=1;e>>8&255])^t.ROTL16(t.rtable[h[2]>>>16&255])^t.ROTL24(t.rtable[h[1]>>>24&255]),c[1]=this.rkey[r+1]^t.rtable[255&h[1]]^t.ROTL8(t.rtable[h[0]>>>8&255])^t.ROTL16(t.rtable[h[3]>>>16&255])^t.ROTL24(t.rtable[h[2]>>>24&255]),c[2]=this.rkey[r+2]^t.rtable[255&h[2]]^t.ROTL8(t.rtable[h[1]>>>8&255])^t.ROTL16(t.rtable[h[0]>>>16&255])^t.ROTL24(t.rtable[h[3]>>>24&255]),c[3]=this.rkey[r+3]^t.rtable[255&h[3]]^t.ROTL8(t.rtable[h[2]>>>8&255])^t.ROTL16(t.rtable[h[1]>>>16&255])^t.ROTL24(t.rtable[h[0]>>>24&255]),r+=4,o=0;o<4;o++)i=h[o],h[o]=c[o],c[o]=i;for(c[0]=this.rkey[r]^255&t.rbsub[255&h[0]]^t.ROTL8(255&t.rbsub[h[3]>>>8&255])^t.ROTL16(255&t.rbsub[h[2]>>>16&255])^t.ROTL24(255&t.rbsub[h[1]>>>24&255]),c[1]=this.rkey[r+1]^255&t.rbsub[255&h[1]]^t.ROTL8(255&t.rbsub[h[0]>>>8&255])^t.ROTL16(255&t.rbsub[h[3]>>>16&255])^t.ROTL24(255&t.rbsub[h[2]>>>24&255]),c[2]=this.rkey[r+2]^255&t.rbsub[255&h[2]]^t.ROTL8(255&t.rbsub[h[1]>>>8&255])^t.ROTL16(255&t.rbsub[h[0]>>>16&255])^t.ROTL24(255&t.rbsub[h[3]>>>24&255]),c[3]=this.rkey[r+3]^255&t.rbsub[255&h[3]]^t.ROTL8(255&t.rbsub[h[2]>>>8&255])^t.ROTL16(255&t.rbsub[h[1]>>>16&255])^t.ROTL24(255&t.rbsub[h[0]>>>24&255]),e=o=0;e<4;e++,o+=4)for(s=t.unpack(c[e]),r=0;r<4;r++)n[o+r]=s[r]},encrypt:function(n){var i,e,o,r=[];switch(e=0,this.mode){case t.ECB:return this.ecb_encrypt(n),0;case t.CBC:for(o=0;o<16;o++)n[o]^=this.f[o];for(this.ecb_encrypt(n),o=0;o<16;o++)this.f[o]=n[o];return 0;case t.CFB1:case t.CFB2:case t.CFB4:for(i=this.mode-t.CFB1+1,o=0;o>>24},t.ROTL16=function(t){return t<<16|t>>>16},t.ROTL24=function(t){return t<<24|t>>>8},t.pack=function(t){return(255&t[3])<<24|(255&t[2])<<16|(255&t[1])<<8|255&t[0]},t.unpack=function(t){var n=[];return n[0]=255&t,n[1]=t>>>8&255,n[2]=t>>>16&255,n[3]=t>>>24&255,n},t.bmul=function(n,i){var e=255&i,o=255&t.ltab[255&n],r=255&t.ltab[e];return 0!==n&&0!==i?t.ptab[(o+r)%255]:0},t.SubByte=function(n){var i=t.unpack(n);return i[0]=t.fbsub[255&i[0]],i[1]=t.fbsub[255&i[1]],i[2]=t.fbsub[255&i[2]],i[3]=t.fbsub[255&i[3]],t.pack(i)},t.product=function(n,i){var e=t.unpack(n),o=t.unpack(i);return 255&(t.bmul(e[0],o[0])^t.bmul(e[1],o[1])^t.bmul(e[2],o[2])^t.bmul(e[3],o[3]))},t.InvMixCol=function(n){var i,e=[];return i=t.pack(t.InCo),e[3]=t.product(i,n),i=t.ROTL24(i),e[2]=t.product(i,n),i=t.ROTL24(i),e[1]=t.product(i,n),i=t.ROTL24(i),e[0]=t.product(i,n),t.pack(e)},t.InCo=[11,13,9,14],t.rco=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47],t.ptab=[1,3,5,15,17,51,85,255,26,46,114,150,161,248,19,53,95,225,56,72,216,115,149,164,247,2,6,10,30,34,102,170,229,52,92,228,55,89,235,38,106,190,217,112,144,171,230,49,83,245,4,12,20,60,68,204,79,209,104,184,211,110,178,205,76,212,103,169,224,59,77,215,98,166,241,8,24,40,120,136,131,158,185,208,107,189,220,127,129,152,179,206,73,219,118,154,181,196,87,249,16,48,80,240,11,29,39,105,187,214,97,163,254,25,43,125,135,146,173,236,47,113,147,174,233,32,96,160,251,22,58,78,210,109,183,194,93,231,50,86,250,21,63,65,195,94,226,61,71,201,64,192,91,237,44,116,156,191,218,117,159,186,213,100,172,239,42,126,130,157,188,223,122,142,137,128,155,182,193,88,232,35,101,175,234,37,111,177,200,67,197,84,252,31,33,99,165,244,7,9,27,45,119,153,176,203,70,202,69,207,74,222,121,139,134,145,168,227,62,66,198,81,243,14,18,54,90,238,41,123,141,140,143,138,133,148,167,242,13,23,57,75,221,124,132,151,162,253,28,36,108,180,199,82,246,1],t.ltab=[0,255,25,1,50,2,26,198,75,199,27,104,51,238,223,3,100,4,224,14,52,141,129,239,76,113,8,200,248,105,28,193,125,194,29,181,249,185,39,106,77,228,166,114,154,201,9,120,101,47,138,5,33,15,225,36,18,240,130,69,53,147,218,142,150,143,219,189,54,208,206,148,19,92,210,241,64,70,131,56,102,221,253,48,191,6,139,98,179,37,226,152,34,136,145,16,126,110,72,195,163,182,30,66,58,107,40,84,250,133,61,186,43,121,10,21,155,159,94,202,78,212,172,229,243,115,167,87,175,88,168,80,244,234,214,116,79,174,233,213,231,230,173,232,44,215,117,122,235,22,11,245,89,203,95,176,156,169,81,160,127,12,246,111,23,196,73,236,216,67,31,45,164,118,123,183,204,187,62,90,251,96,177,134,59,82,161,108,170,85,41,157,151,178,135,144,97,190,220,252,188,149,207,205,55,63,91,209,83,57,132,60,65,162,109,71,20,42,158,93,86,242,211,171,68,17,146,217,35,32,46,137,180,124,184,38,119,153,227,165,103,74,237,222,197,49,254,24,13,99,140,128,192,247,112,7],t.fbsub=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],t.rbsub=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],t.ftable=[2774754246,2222750968,2574743534,2373680118,234025727,3177933782,2976870366,1422247313,1345335392,50397442,2842126286,2099981142,436141799,1658312629,3870010189,2591454956,1170918031,2642575903,1086966153,2273148410,368769775,3948501426,3376891790,200339707,3970805057,1742001331,4255294047,3937382213,3214711843,4154762323,2524082916,1539358875,3266819957,486407649,2928907069,1780885068,1513502316,1094664062,49805301,1338821763,1546925160,4104496465,887481809,150073849,2473685474,1943591083,1395732834,1058346282,201589768,1388824469,1696801606,1589887901,672667696,2711000631,251987210,3046808111,151455502,907153956,2608889883,1038279391,652995533,1764173646,3451040383,2675275242,453576978,2659418909,1949051992,773462580,756751158,2993581788,3998898868,4221608027,4132590244,1295727478,1641469623,3467883389,2066295122,1055122397,1898917726,2542044179,4115878822,1758581177,0,753790401,1612718144,536673507,3367088505,3982187446,3194645204,1187761037,3653156455,1262041458,3729410708,3561770136,3898103984,1255133061,1808847035,720367557,3853167183,385612781,3309519750,3612167578,1429418854,2491778321,3477423498,284817897,100794884,2172616702,4031795360,1144798328,3131023141,3819481163,4082192802,4272137053,3225436288,2324664069,2912064063,3164445985,1211644016,83228145,3753688163,3249976951,1977277103,1663115586,806359072,452984805,250868733,1842533055,1288555905,336333848,890442534,804056259,3781124030,2727843637,3427026056,957814574,1472513171,4071073621,2189328124,1195195770,2892260552,3881655738,723065138,2507371494,2690670784,2558624025,3511635870,2145180835,1713513028,2116692564,2878378043,2206763019,3393603212,703524551,3552098411,1007948840,2044649127,3797835452,487262998,1994120109,1004593371,1446130276,1312438900,503974420,3679013266,168166924,1814307912,3831258296,1573044895,1859376061,4021070915,2791465668,2828112185,2761266481,937747667,2339994098,854058965,1137232011,1496790894,3077402074,2358086913,1691735473,3528347292,3769215305,3027004632,4199962284,133494003,636152527,2942657994,2390391540,3920539207,403179536,3585784431,2289596656,1864705354,1915629148,605822008,4054230615,3350508659,1371981463,602466507,2094914977,2624877800,555687742,3712699286,3703422305,2257292045,2240449039,2423288032,1111375484,3300242801,2858837708,3628615824,84083462,32962295,302911004,2741068226,1597322602,4183250862,3501832553,2441512471,1489093017,656219450,3114180135,954327513,335083755,3013122091,856756514,3144247762,1893325225,2307821063,2811532339,3063651117,572399164,2458355477,552200649,1238290055,4283782570,2015897680,2061492133,2408352771,4171342169,2156497161,386731290,3669999461,837215959,3326231172,3093850320,3275833730,2962856233,1999449434,286199582,3417354363,4233385128,3602627437,974525996],t.rtable=[1353184337,1399144830,3282310938,2522752826,3412831035,4047871263,2874735276,2466505547,1442459680,4134368941,2440481928,625738485,4242007375,3620416197,2151953702,2409849525,1230680542,1729870373,2551114309,3787521629,41234371,317738113,2744600205,3338261355,3881799427,2510066197,3950669247,3663286933,763608788,3542185048,694804553,1154009486,1787413109,2021232372,1799248025,3715217703,3058688446,397248752,1722556617,3023752829,407560035,2184256229,1613975959,1165972322,3765920945,2226023355,480281086,2485848313,1483229296,436028815,2272059028,3086515026,601060267,3791801202,1468997603,715871590,120122290,63092015,2591802758,2768779219,4068943920,2997206819,3127509762,1552029421,723308426,2461301159,4042393587,2715969870,3455375973,3586000134,526529745,2331944644,2639474228,2689987490,853641733,1978398372,971801355,2867814464,111112542,1360031421,4186579262,1023860118,2919579357,1186850381,3045938321,90031217,1876166148,4279586912,620468249,2548678102,3426959497,2006899047,3175278768,2290845959,945494503,3689859193,1191869601,3910091388,3374220536,0,2206629897,1223502642,2893025566,1316117100,4227796733,1446544655,517320253,658058550,1691946762,564550760,3511966619,976107044,2976320012,266819475,3533106868,2660342555,1338359936,2720062561,1766553434,370807324,179999714,3844776128,1138762300,488053522,185403662,2915535858,3114841645,3366526484,2233069911,1275557295,3151862254,4250959779,2670068215,3170202204,3309004356,880737115,1982415755,3703972811,1761406390,1676797112,3403428311,277177154,1076008723,538035844,2099530373,4164795346,288553390,1839278535,1261411869,4080055004,3964831245,3504587127,1813426987,2579067049,4199060497,577038663,3297574056,440397984,3626794326,4019204898,3343796615,3251714265,4272081548,906744984,3481400742,685669029,646887386,2764025151,3835509292,227702864,2613862250,1648787028,3256061430,3904428176,1593260334,4121936770,3196083615,2090061929,2838353263,3004310991,999926984,2809993232,1852021992,2075868123,158869197,4095236462,28809964,2828685187,1701746150,2129067946,147831841,3873969647,3650873274,3459673930,3557400554,3598495785,2947720241,824393514,815048134,3227951669,935087732,2798289660,2966458592,366520115,1251476721,4158319681,240176511,804688151,2379631990,1303441219,1414376140,3741619940,3820343710,461924940,3089050817,2136040774,82468509,1563790337,1937016826,776014843,1511876531,1389550482,861278441,323475053,2355222426,2047648055,2383738969,2302415851,3995576782,902390199,3991215329,1018251130,1507840668,1064563285,2043548696,3208103795,3939366739,1537932639,342834655,2262516856,2180231114,1053059257,741614648,1598071746,1925389590,203809468,2336832552,1100287487,1895934009,3736275976,2632234200,2428589668,1636092795,1890988757,1952214088,1113045200],t}(),h.GCM=function(t){var n=function(){this.table=new Array(128);for(var n=0;n<128;n++)this.table[n]=new Array(4);this.stateX=[],this.Y_0=[],this.counter=0,this.lenA=[],this.lenC=[],this.status=0,this.a=new t.AES};return n.ACCEPTING_HEADER=0,n.ACCEPTING_CIPHER=1,n.NOT_ACCEPTING_MORE=2,n.FINISHED=3,n.ENCRYPTING=0,n.DECRYPTING=1,n.prototype={precompute:function(t){var i,e,o,r=[];for(i=e=0;i<4;i++,e+=4)r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],this.table[0][i]=n.pack(r);for(i=1;i<128;i++){for(o=0,e=0;e<4;e++)this.table[i][e]=o|this.table[i-1][e]>>>1,o=this.table[i-1][e]<<31;0!==o&&(this.table[i][0]^=3774873600)}},gf2mul:function(){var t,i,e,o,r,s=[],h=[];for(s[0]=s[1]=s[2]=s[3]=0,i=8,e=0,t=0;t<128;t++){for(r=1+~(r=this.stateX[e]>>>--i&1),o=0;o<4;o++)s[o]^=this.table[t][o]&r;if(0===i&&(i=8,16==++e))break}for(t=i=0;t<4;t++,i+=4)h=n.unpack(s[t]),this.stateX[i]=h[0],this.stateX[i+1]=h[1],this.stateX[i+2]=h[2],this.stateX[i+3]=h[3]},wrap:function(){var t,i,e=[],o=[],r=[];for(e[0]=this.lenA[0]<<3|(3758096384&this.lenA[1])>>>29,e[1]=this.lenA[1]<<3,e[2]=this.lenC[0]<<3|(3758096384&this.lenC[1])>>>29,e[3]=this.lenC[1]<<3,t=i=0;t<4;t++,i+=4)r=n.unpack(e[t]),o[i]=r[0],o[i+1]=r[1],o[i+2]=r[2],o[i+3]=r[3];for(t=0;t<16;t++)this.stateX[t]^=o[t];this.gf2mul()},init:function(i,e,o,r){var s,h=[],c=[];for(s=0;s<16;s++)h[s]=0,this.stateX[s]=0;if(this.a.init(t.AES.ECB,i,e,r),this.a.ecb_encrypt(h),this.precompute(h),this.lenA[0]=this.lenC[0]=this.lenA[1]=this.lenC[1]=0,12==o){for(s=0;s<12;s++)this.a.f[s]=r[s];for(c=n.unpack(1),this.a.f[12]=c[0],this.a.f[13]=c[1],this.a.f[14]=c[2],this.a.f[15]=c[3],s=0;s<16;s++)this.Y_0[s]=this.a.f[s]}else{for(this.status=n.ACCEPTING_CIPHER,this.ghash(r,o),this.wrap(),s=0;s<16;s++)this.a.f[s]=this.stateX[s],this.Y_0[s]=this.a.f[s],this.stateX[s]=0;this.lenA[0]=this.lenC[0]=this.lenA[1]=this.lenC[1]=0}this.status=n.ACCEPTING_HEADER},add_header:function(t,i){var e,o=0;if(this.status!=n.ACCEPTING_HEADER)return!1;for(;o>>8&255,n[1]=t>>>16&255,n[0]=t>>>24&255,n},n.hex2bytes=function(t){var n,i=t.length,e=[];for(n=0;n>>0)+(t.bot>>>0),i=n>>>0,e=(this.top>>>0)+(t.top>>>0);return this.bot=i,this.top=i!=n?e+1>>>0:e,this},copy:function(){return new t(this.top,this.bot)},shlb:function(){var t=this.bot>>>24;return this.top=t+(this.top<<8),this.bot<<=8,this}},t}(),h.HASH256=function(){var t=function(){this.length=[],this.h=[],this.w=[],this.init()};return t.prototype={transform:function(){var n,i,e,o,r,s,h,c,u,a,f;for(f=16;f<64;f++)this.w[f]=t.theta1(this.w[f-2])+this.w[f-7]+t.theta0(this.w[f-15])+this.w[f-16]|0;for(n=this.h[0],i=this.h[1],e=this.h[2],o=this.h[3],r=this.h[4],s=this.h[5],h=this.h[6],c=this.h[7],f=0;f<64;f++)u=c+t.Sig1(r)+t.Ch(r,s,h)+t.HK[f]+this.w[f]|0,a=t.Sig0(n)+t.Maj(n,i,e)|0,c=h,h=s,s=r,r=o+u|0,o=e,e=i,i=n,n=u+a|0;this.h[0]+=n,this.h[1]+=i,this.h[2]+=e,this.h[3]+=o,this.h[4]+=r,this.h[5]+=s,this.h[6]+=h,this.h[7]+=c},init:function(){var n;for(n=0;n<64;n++)this.w[n]=0;this.length[0]=this.length[1]=0,this.h[0]=t.H[0],this.h[1]=t.H[1],this.h[2]=t.H[2],this.h[3]=t.H[3],this.h[4]=t.H[4],this.h[5]=t.H[5],this.h[6]=t.H[6],this.h[7]=t.H[7]},process:function(t){var n;n=(this.length[0]>>>5)%16,this.w[n]<<=8,this.w[n]|=255&t,this.length[0]+=8,4294967295&this.length[0]||(this.length[1]++,this.length[0]=0),this.length[0]%512==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var n,i,e,o=[];for(n=this.length[0],i=this.length[1],this.process(128);this.length[0]%512!=448;)this.process(0);for(this.w[14]=i,this.w[15]=n,this.transform(),e=0;e>>2]>>8*(3-e%4)&255;return this.init(),o}},t.S=function(t,n){return n>>>t|n<<32-t},t.R=function(t,n){return n>>>t},t.Ch=function(t,n,i){return t&n^~t&i},t.Maj=function(t,n,i){return t&n^t&i^n&i},t.Sig0=function(n){return t.S(2,n)^t.S(13,n)^t.S(22,n)},t.Sig1=function(n){return t.S(6,n)^t.S(11,n)^t.S(25,n)},t.theta0=function(n){return t.S(7,n)^t.S(18,n)^t.R(3,n)},t.theta1=function(n){return t.S(17,n)^t.S(19,n)^t.R(10,n)},t.len=32,t.H=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],t.HK=[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],t}(),h.HASH384=function(t){var n=function(){this.length=[],this.h=[],this.w=[],this.init()};return n.prototype={transform:function(){var t,i,e,o,r,s,h,c,u,a,f;for(f=16;f<80;f++)this.w[f]=n.theta1(this.w[f-2]).add(this.w[f-7]).add(n.theta0(this.w[f-15])).add(this.w[f-16]);for(t=this.h[0].copy(),i=this.h[1].copy(),e=this.h[2].copy(),o=this.h[3].copy(),r=this.h[4].copy(),s=this.h[5].copy(),h=this.h[6].copy(),c=this.h[7].copy(),f=0;f<80;f++)(u=c.copy()).add(n.Sig1(r)).add(n.Ch(r,s,h)).add(n.HK[f]).add(this.w[f]),(a=n.Sig0(t)).add(n.Maj(t,i,e)),c=h,h=s,s=r,(r=o.copy()).add(u),o=e,e=i,i=t,(t=u.copy()).add(a);this.h[0].add(t),this.h[1].add(i),this.h[2].add(e),this.h[3].add(o),this.h[4].add(r),this.h[5].add(s),this.h[6].add(h),this.h[7].add(c)},init:function(){var i;for(i=0;i<80;i++)this.w[i]=new t.UInt64(0,0);this.length[0]=new t.UInt64(0,0),this.length[1]=new t.UInt64(0,0),this.h[0]=n.H[0].copy(),this.h[1]=n.H[1].copy(),this.h[2]=n.H[2].copy(),this.h[3]=n.H[3].copy(),this.h[4]=n.H[4].copy(),this.h[5]=n.H[5].copy(),this.h[6]=n.H[6].copy(),this.h[7]=n.H[7].copy()},process:function(n){var i,e;i=(this.length[0].bot>>>6)%16,this.w[i].shlb(),this.w[i].bot|=255&n,e=new t.UInt64(0,8),this.length[0].add(e),0===this.length[0].top&&0==this.length[0].bot&&(e=new t.UInt64(0,1),this.length[1].add(e)),this.length[0].bot%1024==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var t,i,e,o=[];for(t=this.length[0].copy(),i=this.length[1].copy(),this.process(128);this.length[0].bot%1024!=896;)this.process(0);for(this.w[14]=i,this.w[15]=t,this.transform(),e=0;e>>3]).bot;return this.init(),o}},n.S=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n|i.bot<<32-n,i.bot>>>n|i.top<<32-n):new t.UInt64(i.bot>>>n-32|i.top<<64-n,i.top>>>n-32|i.bot<<64-n)},n.R=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n,i.bot>>>n|i.top<<32-n):new t.UInt64(0,i.top>>>n-32)},n.Ch=function(n,i,e){return new t.UInt64(n.top&i.top^~n.top&e.top,n.bot&i.bot^~n.bot&e.bot)},n.Maj=function(n,i,e){return new t.UInt64(n.top&i.top^n.top&e.top^i.top&e.top,n.bot&i.bot^n.bot&e.bot^i.bot&e.bot)},n.Sig0=function(i){var e=n.S(28,i),o=n.S(34,i),r=n.S(39,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.Sig1=function(i){var e=n.S(14,i),o=n.S(18,i),r=n.S(41,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta0=function(i){var e=n.S(1,i),o=n.S(8,i),r=n.R(7,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta1=function(i){var e=n.S(19,i),o=n.S(61,i),r=n.R(6,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.len=48,n.H=[new t.UInt64(3418070365,3238371032),new t.UInt64(1654270250,914150663),new t.UInt64(2438529370,812702999),new t.UInt64(355462360,4144912697),new t.UInt64(1731405415,4290775857),new t.UInt64(2394180231,1750603025),new t.UInt64(3675008525,1694076839),new t.UInt64(1203062813,3204075428)],n.HK=[new t.UInt64(1116352408,3609767458),new t.UInt64(1899447441,602891725),new t.UInt64(3049323471,3964484399),new t.UInt64(3921009573,2173295548),new t.UInt64(961987163,4081628472),new t.UInt64(1508970993,3053834265),new t.UInt64(2453635748,2937671579),new t.UInt64(2870763221,3664609560),new t.UInt64(3624381080,2734883394),new t.UInt64(310598401,1164996542),new t.UInt64(607225278,1323610764),new t.UInt64(1426881987,3590304994),new t.UInt64(1925078388,4068182383),new t.UInt64(2162078206,991336113),new t.UInt64(2614888103,633803317),new t.UInt64(3248222580,3479774868),new t.UInt64(3835390401,2666613458),new t.UInt64(4022224774,944711139),new t.UInt64(264347078,2341262773),new t.UInt64(604807628,2007800933),new t.UInt64(770255983,1495990901),new t.UInt64(1249150122,1856431235),new t.UInt64(1555081692,3175218132),new t.UInt64(1996064986,2198950837),new t.UInt64(2554220882,3999719339),new t.UInt64(2821834349,766784016),new t.UInt64(2952996808,2566594879),new t.UInt64(3210313671,3203337956),new t.UInt64(3336571891,1034457026),new t.UInt64(3584528711,2466948901),new t.UInt64(113926993,3758326383),new t.UInt64(338241895,168717936),new t.UInt64(666307205,1188179964),new t.UInt64(773529912,1546045734),new t.UInt64(1294757372,1522805485),new t.UInt64(1396182291,2643833823),new t.UInt64(1695183700,2343527390),new t.UInt64(1986661051,1014477480),new t.UInt64(2177026350,1206759142),new t.UInt64(2456956037,344077627),new t.UInt64(2730485921,1290863460),new t.UInt64(2820302411,3158454273),new t.UInt64(3259730800,3505952657),new t.UInt64(3345764771,106217008),new t.UInt64(3516065817,3606008344),new t.UInt64(3600352804,1432725776),new t.UInt64(4094571909,1467031594),new t.UInt64(275423344,851169720),new t.UInt64(430227734,3100823752),new t.UInt64(506948616,1363258195),new t.UInt64(659060556,3750685593),new t.UInt64(883997877,3785050280),new t.UInt64(958139571,3318307427),new t.UInt64(1322822218,3812723403),new t.UInt64(1537002063,2003034995),new t.UInt64(1747873779,3602036899),new t.UInt64(1955562222,1575990012),new t.UInt64(2024104815,1125592928),new t.UInt64(2227730452,2716904306),new t.UInt64(2361852424,442776044),new t.UInt64(2428436474,593698344),new t.UInt64(2756734187,3733110249),new t.UInt64(3204031479,2999351573),new t.UInt64(3329325298,3815920427),new t.UInt64(3391569614,3928383900),new t.UInt64(3515267271,566280711),new t.UInt64(3940187606,3454069534),new t.UInt64(4118630271,4000239992),new t.UInt64(116418474,1914138554),new t.UInt64(174292421,2731055270),new t.UInt64(289380356,3203993006),new t.UInt64(460393269,320620315),new t.UInt64(685471733,587496836),new t.UInt64(852142971,1086792851),new t.UInt64(1017036298,365543100),new t.UInt64(1126000580,2618297676),new t.UInt64(1288033470,3409855158),new t.UInt64(1501505948,4234509866),new t.UInt64(1607167915,987167468),new t.UInt64(1816402316,1246189591)],n}(h),h.HASH512=function(t){var n=function(){this.length=[],this.h=[],this.w=[],this.init()};return n.prototype={transform:function(){var t,i,e,o,r,s,h,c,u,a,f;for(f=16;f<80;f++)this.w[f]=n.theta1(this.w[f-2]).add(this.w[f-7]).add(n.theta0(this.w[f-15])).add(this.w[f-16]);for(t=this.h[0].copy(),i=this.h[1].copy(),e=this.h[2].copy(),o=this.h[3].copy(),r=this.h[4].copy(),s=this.h[5].copy(),h=this.h[6].copy(),c=this.h[7].copy(),f=0;f<80;f++)(u=c.copy()).add(n.Sig1(r)).add(n.Ch(r,s,h)).add(n.HK[f]).add(this.w[f]),(a=n.Sig0(t)).add(n.Maj(t,i,e)),c=h,h=s,s=r,(r=o.copy()).add(u),o=e,e=i,i=t,(t=u.copy()).add(a);this.h[0].add(t),this.h[1].add(i),this.h[2].add(e),this.h[3].add(o),this.h[4].add(r),this.h[5].add(s),this.h[6].add(h),this.h[7].add(c)},init:function(){var i;for(i=0;i<80;i++)this.w[i]=new t.UInt64(0,0);this.length[0]=new t.UInt64(0,0),this.length[1]=new t.UInt64(0,0),this.h[0]=n.H[0].copy(),this.h[1]=n.H[1].copy(),this.h[2]=n.H[2].copy(),this.h[3]=n.H[3].copy(),this.h[4]=n.H[4].copy(),this.h[5]=n.H[5].copy(),this.h[6]=n.H[6].copy(),this.h[7]=n.H[7].copy()},process:function(n){var i,e;i=(this.length[0].bot>>>6)%16,this.w[i].shlb(),this.w[i].bot|=255&n,e=new t.UInt64(0,8),this.length[0].add(e),0===this.length[0].top&&0==this.length[0].bot&&(e=new t.UInt64(0,1),this.length[1].add(e)),this.length[0].bot%1024==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var t,i,e,o=[];for(t=this.length[0].copy(),i=this.length[1].copy(),this.process(128);this.length[0].bot%1024!=896;)this.process(0);for(this.w[14]=i,this.w[15]=t,this.transform(),e=0;e>>3]).bot;return this.init(),o}},n.S=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n|i.bot<<32-n,i.bot>>>n|i.top<<32-n):new t.UInt64(i.bot>>>n-32|i.top<<64-n,i.top>>>n-32|i.bot<<64-n)},n.R=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n,i.bot>>>n|i.top<<32-n):new t.UInt64(0,i.top>>>n-32)},n.Ch=function(n,i,e){return new t.UInt64(n.top&i.top^~n.top&e.top,n.bot&i.bot^~n.bot&e.bot)},n.Maj=function(n,i,e){return new t.UInt64(n.top&i.top^n.top&e.top^i.top&e.top,n.bot&i.bot^n.bot&e.bot^i.bot&e.bot)},n.Sig0=function(i){var e=n.S(28,i),o=n.S(34,i),r=n.S(39,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.Sig1=function(i){var e=n.S(14,i),o=n.S(18,i),r=n.S(41,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta0=function(i){var e=n.S(1,i),o=n.S(8,i),r=n.R(7,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta1=function(i){var e=n.S(19,i),o=n.S(61,i),r=n.R(6,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.len=64,n.H=[new t.UInt64(1779033703,4089235720),new t.UInt64(3144134277,2227873595),new t.UInt64(1013904242,4271175723),new t.UInt64(2773480762,1595750129),new t.UInt64(1359893119,2917565137),new t.UInt64(2600822924,725511199),new t.UInt64(528734635,4215389547),new t.UInt64(1541459225,327033209)],n.HK=[new t.UInt64(1116352408,3609767458),new t.UInt64(1899447441,602891725),new t.UInt64(3049323471,3964484399),new t.UInt64(3921009573,2173295548),new t.UInt64(961987163,4081628472),new t.UInt64(1508970993,3053834265),new t.UInt64(2453635748,2937671579),new t.UInt64(2870763221,3664609560),new t.UInt64(3624381080,2734883394),new t.UInt64(310598401,1164996542),new t.UInt64(607225278,1323610764),new t.UInt64(1426881987,3590304994),new t.UInt64(1925078388,4068182383),new t.UInt64(2162078206,991336113),new t.UInt64(2614888103,633803317),new t.UInt64(3248222580,3479774868),new t.UInt64(3835390401,2666613458),new t.UInt64(4022224774,944711139),new t.UInt64(264347078,2341262773),new t.UInt64(604807628,2007800933),new t.UInt64(770255983,1495990901),new t.UInt64(1249150122,1856431235),new t.UInt64(1555081692,3175218132),new t.UInt64(1996064986,2198950837),new t.UInt64(2554220882,3999719339),new t.UInt64(2821834349,766784016),new t.UInt64(2952996808,2566594879),new t.UInt64(3210313671,3203337956),new t.UInt64(3336571891,1034457026),new t.UInt64(3584528711,2466948901),new t.UInt64(113926993,3758326383),new t.UInt64(338241895,168717936),new t.UInt64(666307205,1188179964),new t.UInt64(773529912,1546045734),new t.UInt64(1294757372,1522805485),new t.UInt64(1396182291,2643833823),new t.UInt64(1695183700,2343527390),new t.UInt64(1986661051,1014477480),new t.UInt64(2177026350,1206759142),new t.UInt64(2456956037,344077627),new t.UInt64(2730485921,1290863460),new t.UInt64(2820302411,3158454273),new t.UInt64(3259730800,3505952657),new t.UInt64(3345764771,106217008),new t.UInt64(3516065817,3606008344),new t.UInt64(3600352804,1432725776),new t.UInt64(4094571909,1467031594),new t.UInt64(275423344,851169720),new t.UInt64(430227734,3100823752),new t.UInt64(506948616,1363258195),new t.UInt64(659060556,3750685593),new t.UInt64(883997877,3785050280),new t.UInt64(958139571,3318307427),new t.UInt64(1322822218,3812723403),new t.UInt64(1537002063,2003034995),new t.UInt64(1747873779,3602036899),new t.UInt64(1955562222,1575990012),new t.UInt64(2024104815,1125592928),new t.UInt64(2227730452,2716904306),new t.UInt64(2361852424,442776044),new t.UInt64(2428436474,593698344),new t.UInt64(2756734187,3733110249),new t.UInt64(3204031479,2999351573),new t.UInt64(3329325298,3815920427),new t.UInt64(3391569614,3928383900),new t.UInt64(3515267271,566280711),new t.UInt64(3940187606,3454069534),new t.UInt64(4118630271,4000239992),new t.UInt64(116418474,1914138554),new t.UInt64(174292421,2731055270),new t.UInt64(289380356,3203993006),new t.UInt64(460393269,320620315),new t.UInt64(685471733,587496836),new t.UInt64(852142971,1086792851),new t.UInt64(1017036298,365543100),new t.UInt64(1126000580,2618297676),new t.UInt64(1288033470,3409855158),new t.UInt64(1501505948,4234509866),new t.UInt64(1607167915,987167468),new t.UInt64(1816402316,1246189591)],n}(h),h.SHA3=function(t){var n=function(t){this.length=0,this.rate=0,this.len=0,this.S=[],this.init(t)};return n.prototype={transform:function(){var i,e,o,r=[],s=[],h=[];for(o=0;o>=3)%5,o=Math.floor(h/5),c=new t.UInt64(0,i),r=0;r=i||c%this.rate==0){e=!0;break}h=n.rotl(h,56)}if(e)break}if(e)break}if(c>=i)break;e=!1,this.transform()}},hash:function(t){if(1==this.rate-this.length%this.rate)this.process(134);else{for(this.process(6);this.length%this.rate!=this.rate-1;)this.process(0);this.process(128)}this.squeeze(t,this.len)},shake:function(t,n){if(1==this.rate-this.length%this.rate)this.process(159);else{for(this.process(31);this.length%this.rate!=this.rate-1;)this.process(0);this.process(128)}this.squeeze(t,n)}},n.rotl=function(n,i){return 0==i?n:i<32?new t.UInt64(n.top<>>32-i,n.bot<>>32-i):new t.UInt64(n.bot<>>64-i,n.top<>>64-i)},n.xor=function(n,i){return new t.UInt64(n.top^i.top,n.bot^i.bot)},n.and=function(n,i){return new t.UInt64(n.top&i.top,n.bot&i.bot)},n.not=function(n){return new t.UInt64(~n.top,~n.bot)},n.ROUNDS=24,n.HASH224=28,n.HASH256=32,n.HASH384=48,n.HASH512=64,n.SHAKE128=16,n.SHAKE256=32,n.RC=[new t.UInt64(0,1),new t.UInt64(0,32898),new t.UInt64(2147483648,32906),new t.UInt64(2147483648,2147516416),new t.UInt64(0,32907),new t.UInt64(0,2147483649),new t.UInt64(2147483648,2147516545),new t.UInt64(2147483648,32777),new t.UInt64(0,138),new t.UInt64(0,136),new t.UInt64(0,2147516425),new t.UInt64(0,2147483658),new t.UInt64(0,2147516555),new t.UInt64(2147483648,139),new t.UInt64(2147483648,32905),new t.UInt64(2147483648,32771),new t.UInt64(2147483648,32770),new t.UInt64(2147483648,128),new t.UInt64(0,32778),new t.UInt64(2147483648,2147483658),new t.UInt64(2147483648,2147516545),new t.UInt64(2147483648,32896),new t.UInt64(0,2147483649),new t.UInt64(2147483648,2147516424)],n}(h),h.RAND=function(t){var n=function(){this.ira=[],this.rndptr=0,this.borrow=0,this.pool_ptr=0,this.pool=[],this.clean()};return n.prototype={NK:21,NJ:6,NV:8,clean:function(){var t;for(t=0;t<32;t++)this.pool[t]=0;for(t=0;t>>0)-this.ira[t]-this.borrow|0,(i>>>=0)e&&(this.borrow=1),this.ira[t]=0|i;return this.ira[0]},sirand:function(t){var n,i,e,o=1;for(this.borrow=0,this.rndptr=0,t>>>=0,this.ira[0]^=t,n=1;n0){for(o=0;o=32&&this.fill_pool(),255&t}},n.pack=function(t){return(255&t[3])<<24|(255&t[2])<<16|(255&t[1])<<8|255&t[0]},n}(h),h.NHS=function(t){var n={round:function(t,n){return Math.floor((t+(n>>1))/n)},nabs:function(t){var n=t>>31;return t+n^n},redc:function(t){return(((67108863&t)*n.ND&67108863)*n.PRIME+t)*n.MODINV},nres:function(t){return n.redc(t*n.R2MODP)},modmul:function(t,i){return n.redc(t*i)},ntt:function(t){var i,e,o,r,s,h,c,u=n.DEGREE/2,a=n.PRIME;for(o=0;o1;){for(r=0,e=0;e>n.WL-1&a},Encode:function(t,i){var e,o,r,s,h,c;for(c=n.PRIME/2,e=o=0;e<256;)for(h=t[o++],s=0;s<8;s++)r=1&h,i[e]=r*c,i[e+256]=r*c,i[e+512]=r*c,i[e+768]=r*c,h>>=1,e++},Decode:function(t,i){var e,o,r,s,h=n.PRIME/2;for(e=0;e<32;e++)i[e]=0;for(e=o=0;e<256;){for(r=0;r<8;r++)s=(s=n.nabs(t[e]-h)+n.nabs(t[e+256]-h)+n.nabs(t[e+512]-h)+n.nabs(t[e+768]-h)-n.PRIME)>>31&1,i[o]=((255&i[o])>>1)+(s<<7),e++;o++}},Parse:function(i,e){var o,r,s,h=new t.SHA3(t.SHA3.SHAKE128),c=[];for(o=0;o<32;o++)h.process(i[o]);for(h.shake(c,4*n.DEGREE),o=r=0;o>8|s<<6),i[o++]=s>>2&255,i[o++]=255&(s>>10|h<<4),i[o++]=h>>4&255,i[o++]=255&(h>>12|c<<2),i[o++]=c>>6},unpack:function(t,i){var e,o,r,s,h,c,u,a,f;for(e=o=0;e>6|h<<2|(15&c)<<10,i[e++]=c>>4|u<<4|(3&a)<<12,i[e++]=a>>2|f<<6},Compress:function(t,i){var e,o,r,s=0;for(e=o=0;e>>8&255,i[o+2]=s>>>16&255,o+=3,s=0}},Decompress:function(t,i){var e,o,r,s,h=0;for(e=o=0;e>>21,h<<=3,i[e]=n.round(s*n.PRIME,8),e++},Error:function(t,i){var e,o,r,s,h;for(s=0;s>=1,o>>=1;i[s]=r+n.PRIME}},redc_it:function(t){var i;for(i=0;i>n.WL-1&n.PRIME)},poly_hard_reduce:function(t){var i,e;for(i=0;i>n.WL-1&n.PRIME)},bytestostring:function(t){var n,i,e="",o=t.length;for(i=0;i>>4&15).toString(16),e+=(15&n).toString(16);return e},SERVER_1:function(t,i,e){var o,r=new Uint8Array(32),s=new Uint8Array(1792),h=new Int32Array(n.DEGREE),c=new Int32Array(n.DEGREE),u=new Int32Array(n.DEGREE);for(o=0;o<32;o++)r[o]=t.getByte();for(n.Parse(r,u),n.Error(t,c),n.Error(t,h),n.ntt(h),n.ntt(c),n.poly_mul(u,u,h),n.poly_add(u,u,c),n.poly_hard_reduce(u),n.redc_it(u),n.pack(u,s),o=0;o<32;o++)i[o]=r[o];for(o=0;o<1792;o++)i[o+32]=s[o];for(n.poly_hard_reduce(h),n.pack(h,s),o=0;o<1792;o++)e[o]=s[o]},CLIENT:function(i,e,o,r){var s,h=new t.SHA3(t.SHA3.HASH256),c=new Uint8Array(32),u=new Uint8Array(1792),a=new Uint8Array(32),f=new Uint8Array(384),E=new Int32Array(n.DEGREE),B=new Int32Array(n.DEGREE),y=new Int32Array(n.DEGREE),I=new Int32Array(n.DEGREE),m=new Int32Array(n.DEGREE);for(n.Error(i,E),n.Error(i,B),n.ntt(E),n.ntt(B),s=0;s<32;s++)c[s]=e[s];for(s=0;s<1792;s++)u[s]=e[s+32];for(n.Parse(c,y),n.poly_mul(y,y,E),n.poly_add(y,y,B),n.poly_hard_reduce(y),s=0;s<32;s++)a[s]=i.getByte();for(s=0;s<32;s++)h.process(a[s]);for(h.hash(a),n.Encode(a,I),n.unpack(u,m),n.nres_it(m),n.poly_mul(m,m,E),n.intt(m),n.Error(i,B),n.poly_add(m,m,B),n.poly_add(m,m,I),n.Compress(m,f),h.init(t.SHA3.HASH256),s=0;s<32;s++)h.process(a[s]);for(h.hash(a),s=0;s<32;s++)r[s]=a[s];for(n.redc_it(y),n.pack(y,u),s=0;s<1792;s++)o[s]=u[s];for(s=0;s<384;s++)o[s+1792]=f[s]},SERVER_2:function(i,e,o){var r,s=new t.SHA3(t.SHA3.HASH256),h=new Int32Array(n.DEGREE),c=new Int32Array(n.DEGREE),u=new Int32Array(n.DEGREE),a=new Uint8Array(1792),f=new Uint8Array(32),E=new Uint8Array(384);for(r=0;r<1792;r++)a[r]=e[r];for(n.unpack(a,u),n.nres_it(u),r=0;r<384;r++)E[r]=e[r+1792];for(n.Decompress(E,h),r=0;r<1792;r++)a[r]=i[r];for(n.unpack(a,c),n.poly_mul(u,u,c),n.intt(u),n.poly_sub(u,h,u),n.poly_soft_reduce(u),n.Decode(u,f),r=0;r<32;r++)s.process(f[r]);for(s.hash(f),r=0;r<32;r++)o[r]=f[r]},PRIME:12289,LGN:10,ND:50343935,ONE:10924,R2MODP:7586};return n.MODINV=Math.pow(2,-26),n.DEGREE=1024,n.WL=26,n.inv=4091,n.invpr=4401,n.roots=[10924,3439,7271,11355,11709,9879,10742,2259,7036,2539,8427,9802,10192,4635,1420,1239,6050,10731,7026,5040,6577,5505,10953,9704,9373,11614,867,8052,8079,8356,11442,11524,5127,11769,941,9207,6770,2705,895,3507,8981,1510,2703,8477,3501,7979,11817,9904,8201,12253,10369,921,1414,10113,10933,2417,9035,7667,7466,5597,6765,10100,2047,7870,560,7412,6155,2904,6540,11072,4731,7581,4991,4e3,324,75,12204,2825,7295,437,3820,3160,4680,9276,4234,5304,233,11774,251,9730,10988,7095,4248,9176,1923,6931,8295,8406,5916,4,1634,4247,9401,7069,10180,10094,1727,1879,11798,1138,7441,5705,10500,3796,1733,5294,12024,10976,11900,10037,4486,1266,6075,10623,7623,6885,10819,11266,3798,11120,7291,6353,8366,1709,9220,4410,8350,795,5533,1167,3593,7090,5367,901,452,7387,8918,8664,12,6830,11982,11649,3414,1473,4826,2255,5637,7108,6327,6585,8638,4958,10454,10385,8712,6113,10609,2342,8475,255,1311,2693,225,11317,9605,289,3623,11876,10744,11590,3250,10538,829,2809,2950,11834,8504,6520,8996,3903,11536,7677,5059,1740,6777,4641,9487,2765,4095,1972,1616,6291,3717,8029,4828,11586,3470,4672,4226,4847,4534,4008,2831,3500,6428,4674,490,341,9994,2541,11867,9688,8748,2025,8115,4268,10521,9604,3043,9466,9197,1560,11648,1786,5134,1416,853,4180,9924,7759,5761,8047,7251,4068,2763,5760,12264,108,5722,4283,11321,6148,4502,2180,9762,1577,6849,8754,12187,3390,8447,4800,10220,90,672,1521,7386,1027,7848,5913,8135,11555,1514,9681,182,1180,2759,11676,8270,8514,4584,3792,5616,1300,2623,3907,7653,11671,5443,11387,9242,8739,12216,9655,6988,12086,9954,256,9557,9836,11792,10012,1450,6025,8601,10525,4232,8262,7841,3977,7290,7832,311,7013,9453,3895,11971,3340,1991,4671,2862,6807,6659,7117,946,1812,10617,2799,11068,11665,3587,3675,8124,3246,1074,9124,2845,7372,8118,12120,10842,1827,11417,11632,10,9788,9985,3563,11528,7220,8204,7816,918,6357,7237,196,6332,11479,5956,2289,7260,3046,10889,6048,519,6606,8228,9187,10651,1669,11183,1337,11593,9397,5517,253,10901,589,2739,4389,4857,5562,1704,11318,1767,4164,878,4072,4397,10007,9376,7177,3613,2088,759,8027,4011,3318,4914,7282,9859,5582,6867,6710,588,2867,9535,5507,7529,10732,2983,12183,5855,4200,2798,3151,5436,9451,8397,5016,9062,4601,3703,4157,9738,206,2794,9067,11025,1528,3663,1872,5481,4341,10318,2616,11782,224,3754,2462,9371,2283,11159,12255,10689,6912,12259,7503,2111,11526,270,6207,10170,306,4031,10605,5450,1034,10087,173,3081,2420,10273,7726,10450,4012,964,12057,3540,11743,7747,7824,11721,4420,10435,1619,3900,7730,10826,913,4387,219,11680,3614,1639,9141,8249,2706,5458,1491,5786,7939,4930,8196,7005,11521,11931,1055,11207,2708,208,11882,11064,5292,10020,954,1724,6316,11685,8508,11356,3539,2734,11784,1741,5751,8229,7708,1460,3524,96,5484,9833,7169,9899,7867,9940,8673,5483,1383,26,10702,9172,1668,2937,6483,4166,7564,6069,7208,7397,9336,6360,6934,11311,8649,6587,3004,10523,6646,6265,12260,1422,10570,6632,10183,12218,6697,8985,7883,8251,12037,11138,6447,9898,9346,2797,4630,1800,4513,3106,2312,10488,9255,2040,5934,3920,2728,6218,8039,8913,3770,8539,3911,10359,3422,2268,525,11694,7486,1909,3059,2162,9831,8182,3487,5060,261,1631,8684,1757,6665,3182,509,5158,2787,1172,11650,8909,9686,4545,28,11438,5151,4362,327,9815,9213,12089,864,8852,7966,2931,3068,12055,1994,12131,191,10434,3098,9566,8814,6824,8862,5658,627,4205,11328,1999,5128,2008,4106,1881,7604,9406,11963,3095,6292,9294,5565,1864,8169,573,474,702,6307,3164,2553,981,11492,84,10943,10140,7809,11609,10311,9204,3496,2592,600,7422,9228,11310,10128,11733,11250,11828,5924,529,4105,10169,1785,9177,6562,1575,5485,5790,2023,783,9398,1474,7396,10461,32,5803,7374,8361,9104,10372,8773,1527,2743,7018,4583,10835,12180,10572,7909,4964,7066,4087,1515,11312,7170,1441,7047,9218,7368,12001,8126,5004,9351,7160,3478,7528,12211,8129,8140,3430,2387,8513,5498,9335,6371,12080,1886,7649,5298,12202,5783,9012,4817,2934,10920,7802,213,11360,9912,5971,4682,8023,5157,3460,7173,1601,3898,7052,3453,12114,756,3187,5403,5513,6169,6936,2971,6889,11039,11076,12122,11575,11441,9973,9022,10095,630,4704,10647,2546,7189,5780,4524,7789,7151,10598,6322,1274,8260,7024,7998,8734,10442,7510,1966,2445,9100,6072,2771,4415,7963,1234,5975,3249,12017,11778,6140,12049,10868,8233,1792,5454,7407,8810,8639,10150,5308,11051,12230,5046,8678,5731,3261,1874,5668,2177,12224,4726,2687,10063,11091,1648,8119,7745,10782,9746,663,6622,395,585,7304,3742,7921,531,1147,7712,10433,7518,2423,7626,2448,7670,11106,2160,500,6185,7690,70,7071,8450,363,6962,1384,8272,5556,6426,7632,1503,1372,7457,6619,4825,3734,1664,9033,2489,5469,3633,9375,8440,2864,823,11683,4547,9359,7417,4334,1752,1771,2573,4123,6884,6145,9421,2067,11928,5492,80,4570,6146,3926,6201,8604,4187,1083,713,2327,5313,7033,3499,10937,9820,1818,7568,2207,11202,10103,4116,7780,5300,1682,3547,1390,8592,11547,4118,4822,7297,9768,1185,4712,9623,10534,1989,7629,1343,4521,6721,1442,7269,2024,3441,10696,1063,815,1500,5809,10781,6023,8740,1568,1700,4945,4152,3692,4379,12051,1089,11517,12079,3365,2488,6948,1890,6582,9745,2142,3639,501,1283,7238,9164,1211,9278,4651,10466,4926,11705,3506,6748,10665,202,8467,5073,5612,8313,6362,11600,11333,2722,4954,2048,6391,6131,1533,8026,720,11473,2542,8587,6653,1339,10437,3635,6417,9932,8216,12168,6913,9783,7385,4715,6667,1456,9440,3714,177,8695,6678,12068,7345,8061,10400,5758,195],n.iroots=[10924,8850,934,5018,10030,1547,2410,580,11050,10869,7654,2097,2487,3862,9750,5253,765,847,3933,4210,4237,11422,675,2916,2585,1336,6784,5712,7249,5263,1558,6239,4419,10242,2189,5524,6692,4823,4622,3254,9872,1356,2176,10875,11368,1920,36,4088,2385,472,4310,8788,3812,9586,10779,3308,8782,11394,9584,5519,3082,11348,520,7162,1023,1470,5404,4666,1666,6214,11023,7803,2252,389,1313,265,6995,10556,8493,1789,6584,4848,11151,491,10410,10562,2195,2109,5220,2888,8042,10655,12285,6373,3883,3994,5358,10366,3113,8041,5194,1301,2559,12038,515,12056,6985,8055,3013,7609,9129,8469,11852,4994,9464,85,12214,11965,8289,7298,4708,7558,1217,5749,9385,6134,4877,11729,10712,2527,10109,7787,6141,968,8006,6567,12181,25,6529,9526,8221,5038,4242,6528,4530,2365,8109,11436,10873,7155,10503,641,10729,3092,2823,9246,2685,1768,8021,4174,10264,3541,2601,422,9748,2295,11948,11799,7615,5861,8789,9458,8281,7755,7442,8063,7617,8819,703,7461,4260,8572,5998,10673,10317,8194,9524,2802,7648,5512,10549,7230,4612,753,8386,3293,5769,3785,455,9339,9480,11460,1751,9039,699,1545,413,8666,12e3,2684,972,12064,9596,10978,12034,3814,9947,1680,6176,3577,1904,1835,7331,3651,5704,5962,5181,6652,10034,7463,10816,8875,640,307,5459,12277,3625,3371,4902,11837,11388,6922,5199,8696,11122,6756,11494,3939,7879,3069,10580,3923,5936,4998,1169,8491,8750,933,3781,604,5973,10565,11335,2269,6997,1225,407,12081,9581,1082,11234,358,768,5284,4093,7359,4350,6503,10798,6831,9583,4040,3148,10650,8675,609,12070,7902,11376,1463,4559,8389,10670,1854,7869,568,4465,4542,546,8749,232,11325,8277,1839,4563,2016,9869,9208,12116,2202,11255,6839,1684,8258,11983,2119,6082,12019,763,10178,4786,30,5377,1600,34,1130,10006,2918,9827,8535,12065,507,9673,1971,7948,6808,10417,8626,10761,1264,3222,9495,12083,2551,8132,8586,7688,3227,7273,3892,2838,6853,9138,9491,8089,6434,106,9306,1557,4760,6782,2754,9422,11701,5579,5422,6707,2430,5007,7375,8971,8278,4262,11530,10201,8676,5112,2913,2282,7892,8217,11411,8125,10522,971,10585,6727,7432,7900,9550,11700,1388,12036,6772,2892,696,10952,1106,10620,1638,3102,4061,5683,11770,6241,1400,9243,5029,1e4,6333,810,5957,12093,5052,5932,11371,4473,4085,5069,761,8726,2304,2501,12279,657,872,10462,1447,169,4171,4917,9444,3165,11215,9043,4165,8614,8702,624,1221,9490,1672,10477,11343,5172,5630,5482,9427,7618,10298,8949,318,8394,2836,5276,11978,4457,4999,8312,4448,4027,8057,1764,3688,6264,10839,2277,497,2453,2732,12033,2335,203,5301,2634,73,3550,3047,902,6846,618,4636,8382,9666,10989,6673,8497,7705,3775,4019,613,9530,11109,12107,2608,10775,734,4154,6376,4441,11262,4903,10768,11617,12199,2069,7489,3842,8899,102,3535,5440,12094,6531,1889,4228,4944,221,5611,3594,12112,8575,2849,10833,5622,7574,4904,2506,5376,121,4073,2357,5872,8654,1852,10950,5636,3702,9747,816,11569,4263,10756,6158,5898,10241,7335,9567,956,689,5927,3976,6677,7216,3822,12087,1624,5541,8783,584,7363,1823,7638,3011,11078,3125,5051,11006,11788,8650,10147,2544,5707,10399,5341,9801,8924,210,772,11200,238,7910,8597,8137,7344,10589,10721,3549,6266,1508,6480,10789,11474,11226,1593,8848,10265,5020,10847,5568,7768,10946,4660,10300,1755,2666,7577,11104,2521,4992,7467,8171,742,3697,10899,8742,10607,6989,4509,8173,2186,1087,10082,4721,10471,2469,1352,8790,5256,6976,9962,11576,11206,8102,3685,6088,8363,6143,7719,12209,6797,361,10222,2868,6144,5405,8166,9716,10518,10537,7955,4872,2930,7742,606,11466,9425,3849,2914,8656,6820,9800,3256,10625,8555,7464,5670,4832,10917,10786,4657,5863,6733,4017,10905,5327,11926,3839,5218,12219,4599,6104,11789,10129,1183,4619,9841,4663,9866,4771,1856,4577,11142,11758,4368,8547,4985,11704,11894,5667,11626,2543,1507,4544,4170,10641,1198,2226,9602,7563,65,10112,6621,10415,9028,6558,3611,7243,59,1238,6981,2139,3650,3479,4882,6835,10497,4056,1421,240,6149,511,272,9040,6314,11055,4326,7874,9518,6217,3189,9844,10323,4779,1847,3555,4291,5265,4029,11015,5967,1691,5138,4500,7765,6509,5100,9743,1642,7585,11659,2194,3267,2316,848,714,167,1213,1250,5400,9318,5353,6120,6776,6886,9102,11533,175,8836,5237,8391,10688,5116,8829,7132,4266,7607,6318,2377,929,12076,4487,1369,9355,7472,3277,6506,87,6991,4640,10403,209,5918,2954,6791,3776,9902,8859,4149,4160,78,4761,8811,5129,2938,7285,4163,288,4921,3071,5242,10848,5119,977,10774,8202,5223,7325,4380,1717,109,1454,7706,5271,9546,10762,3516,1917,3185,3928,4915,6486,12257,1828,4893,10815,2891,11506,10266,6499,6804,10714,5727,3112,10504,2120,8184,11760,6365,461,1039,556,2161,979,3061,4867,11689,9697,8793,3085,1978,680,4480,2149,1346,12205,797,11308,9736,9125,5982,11587,11815,11716,4120,10425,6724,2995,5997,9194,326,2883,4685,10408,8183,10281,7161,10290,961,8084,11662,6631,3427,5465,3475,2723,9191,1855,12098,158,10295,234,9221,9358,4323,3437,11425,200,3076,2474,11962,7927,7138,851,12261,7744,2603,3380,639,11117,9502,7131,11780,9107,5624,10532,3605,10658,12028,7229,8802,4107,2458,10127,9230,10380,4803,595,11764,10021,8867,1930,8378,3750,8519,3376,4250,6071,9561,8369,6355,10249,3034,1801,9977,9183,7776,10489,7659,9492,2943,2391,5842,1151,252,4038,4406,3304,5592,71,2106,5657,1719,10867,29,6024,5643,1766,9285,5702,3640,978,5355,5929,2953,4892,5081,6220,4725,8123,5806,9352,10621,3117,1587,12263,10906,6806,3616,2349,4422,2390,5120,2456,6805,12193,8765,10829,4581,4060,6538,10548,505,9555],n}(h),void 0!==r)return h.config=s[r],h.BIG=function(t){var n=function(t){switch(this.w=new Array(n.NLEN),typeof t){case"object":this.copy(t);break;case"number":this.zero(),this.w[0]=t;break;default:this.zero()}};return n.CHUNK=32,n.MODBYTES=t.config["@NB"],n.BASEBITS=t.config["@BASE"],n.NLEN=1+Math.floor((8*n.MODBYTES-1)/n.BASEBITS),n.DNLEN=2*n.NLEN,n.BMASK=(1<>n.BASEBITS;return this.w[n.NLEN-1]=this.w[n.NLEN-1]+e,this.w[n.NLEN-1]>>8*n.MODBYTES%n.BASEBITS},fshr:function(t){var i,e;for(i=this.w[0]&(1<>t|this.w[e+1]<>t,i},shr:function(t){var i,e=t%n.BASEBITS,o=Math.floor(t/n.BASEBITS);for(i=0;i>e|this.w[o+i+1]<>e,i=n.NLEN-o;i>n.BASEBITS-t,i=n.NLEN-2;i>0;i--)this.w[i]=this.w[i]<>n.BASEBITS-t;return this.w[0]=this.w[0]<>8*n.MODBYTES%n.BASEBITS},shl:function(t){var i,e=t%n.BASEBITS,o=Math.floor(t/n.BASEBITS);for(this.w[n.NLEN-1]=this.w[n.NLEN-1-o]<o+2&&(this.w[n.NLEN-1]|=this.w[n.NLEN-o-2]>>n.BASEBITS-e),i=n.NLEN-2;i>o;i--)this.w[i]=this.w[i-o]<>n.BASEBITS-e;for(this.w[o]=this.w[0]<=0&&0===this.w[e];)e--;if(e<0)return 0;for(t=n.BASEBITS*e,i=this.w[e];0!==i;)i=Math.floor(i/2),t++;return t},toString:function(){var t,i,e="",o=this.nbits();for(o%4==0?o=Math.floor(o/4):(o=Math.floor(o/4),o++),o<2*n.MODBYTES&&(o=2*n.MODBYTES),i=o-1;i>=0;i--)(t=new n(0)).copy(this),t.shr(4*i),e+=(15&t.w[0]).toString(16);return e},add:function(t){var i;for(i=0;i=0;e--)t[e+i]=255&o.w[0],o.fshr(8);return this},toBytes:function(t){this.tobytearray(t,0)},muladd:function(t,i,e,o){var r=t*i+e+this.w[o];return this.w[o]=r&n.BMASK,(r-this.w[o])*n.MODINV},pmul:function(t){var i,e,o=0;for(e=0;e=0;e--)t=o*i+this.w[e],this.w[e]=Math.floor(t/3),o=t%3;return o},mod2m:function(t){var i,e,o;for(e=Math.floor(t/n.BASEBITS),o=(1<=0);for(;i>0;)t.fshr(1),e.copy(this),e.sub(t),e.norm(),this.cmove(e,1-(e.w[n.NLEN-1]>>n.CHUNK-1&1)),i--}},div:function(t){var i=0,e=0,o=new n(1),r=new n(0),s=new n(0);for(this.norm(),r.copy(this),this.zero();n.comp(r,t)>=0;)o.fshl(1),t.fshl(1),i++;for(;i>0;)t.fshr(1),o.fshr(1),s.copy(r),s.sub(t),s.norm(),e=1-(s.w[n.NLEN-1]>>n.CHUNK-1&1),r.cmove(s,e),s.copy(this),s.add(o),s.norm(),this.cmove(s,e),i--},parity:function(){return this.w[0]%2},bit:function(t){return(this.w[Math.floor(t/n.BASEBITS)]&1<0?1:0},lastbits:function(t){var n=(1<>n.BASEBITS&&(i=!1);return i},jacobi:function(t){var i,e,o=0,r=new n(0),s=new n(0),h=new n(0),c=new n(0),u=new n(1);if(0===t.parity()||0===n.comp(this,c)||n.comp(t,u)<=0)return 0;for(this.norm(),s.copy(this),h.copy(t),s.mod(t);n.comp(h,u)>0;){if(0===n.comp(s,c))return 0;for(i=h.lastbits(3),e=0;0===s.parity();)e++,s.shr(1);e%2==1&&(o+=(i*i-1)/8),o+=(i-1)*(s.lastbits(2)-1)/4,r.copy(h),r.mod(s),h.copy(s),s.copy(r),o%=2}return 0===o?1:-1},invmodp:function(t){var i=new n(0),e=new n(0),o=new n(1),r=new n(0),s=new n(0),h=new n(1);for(this.mod(t),i.copy(this),e.copy(t);0!==n.comp(i,h)&&0!==n.comp(e,h);){for(;0===i.parity();)i.fshr(1),0!==o.parity()&&(o.add(t),o.norm()),o.fshr(1);for(;0===e.parity();)e.fshr(1),0!==r.parity()&&(r.add(t),r.norm()),r.fshr(1);n.comp(i,e)>=0?(i.sub(e),i.norm(),n.comp(o,r)>=0?o.sub(r):(s.copy(t),s.sub(r),o.add(s)),o.norm()):(e.sub(i),e.norm(),n.comp(r,o)>=0?r.sub(o):(s.copy(t),s.sub(o),r.add(s)),r.norm())}0===n.comp(i,h)?this.copy(o):this.copy(r)},powmod:function(t,i){var e,o=new n(1),r=new n(0),s=new n(0);for(this.norm(),t.norm(),r.copy(t),s.copy(this);e=r.parity(),r.fshr(1),1==e&&(o=n.modmul(o,s,i)),!r.iszilch();)s=n.modsqr(s,i);return o}},n.frombytearray=function(t,i){var e,o=new n(0);for(e=0;e=0;e--)if(t.w[e]!=i.w[e])return t.w[e]>i.w[e]?1:-1;return 0},n.random=function(t){var i,e,o=new n(0),r=0,s=0;for(i=0;i<8*n.MODBYTES;i++)0===r?s=t.getByte():s>>=1,e=1&s,o.shl(1),o.w[0]+=e,r++,r&=7;return o},n.randomnum=function(n,i){var e,o,r=new t.DBIG(0),s=0,h=0;for(e=0;e<2*n.nbits();e++)0===s?h=i.getByte():h>>=1,o=1&h,r.shl(1),r.w[0]+=o,s++,s&=7;return r.mod(n)},n.mul=function(i,e){var o,r,s,h,c,u,a=new t.DBIG(0),f=[];for(h=0;h=1+Math.floor(c/2);h--)s+=(i.w[h]-i.w[c-h])*(e.w[c-h]-e.w[h]);a.w[c]=s}for(c=n.NLEN;c<2*n.NLEN-1;c++){for(s=r-=f[c-n.NLEN],h=n.NLEN-1;h>=1+Math.floor(c/2);h--)s+=(i.w[h]-i.w[c-h])*(e.w[c-h]-e.w[h]);a.w[c]=s}for(u=0,h=0;h>1;s++)o+=i.w[r-s]*i.w[s];for(o+=o,c.w[r]=o,r++,o=i.w[r]*i.w[0],s=1;s>1;s++)o+=i.w[r-s]*i.w[s];o+=o,o+=i.w[r>>1]*i.w[r>>1],c.w[r]=o,r++}for(r=n.NLEN-1+n.NLEN%2;r>1;s++)o+=i.w[r-s]*i.w[s];for(o+=o,c.w[r]=o,r++,o=i.w[n.NLEN-1]*i.w[r-n.NLEN+1],s=r-n.NLEN+2;s>1;s++)o+=i.w[r-s]*i.w[s];o+=o,o+=i.w[r>>1]*i.w[r>>1],c.w[r]=o,r++}for(o=i.w[n.NLEN-2]*i.w[n.NLEN-1],o+=o,c.w[n.DNLEN-3]=o,o=i.w[n.NLEN-1]*i.w[n.NLEN-1],c.w[n.DNLEN-2]=o,h=0,s=0;sMath.floor(c/2);h--)s+=(a[c-h]-a[h])*(t.w[h]-t.w[c-h]);a[c]=(s&n.BMASK)*i&n.BMASK,r=(s+=a[c]*t.w[0])*n.MODINV+e.w[c+1],f[c]=a[c]*t.w[c],o+=f[c]}for(c=n.NLEN;c<2*n.NLEN-1;c++){for(s=r+o,h=n.NLEN-1;h>=1+Math.floor(c/2);h--)s+=(a[c-h]-a[h])*(t.w[h]-t.w[c-h]);u.w[c-n.NLEN]=s&n.BMASK,r=(s-u.w[c-n.NLEN])*n.MODINV+e.w[c+1],o-=f[c-n.NLEN+1]}return u.w[n.NLEN-1]=r&n.BMASK,u},n.modmul=function(t,i,e){return t.mod(e),i.mod(e),n.mul(t,i).mod(e)},n.modsqr=function(t,i){return t.mod(i),n.sqr(t).mod(i)},n.modneg=function(t,n){return t.mod(n),n.minus(t)},n.invmod256=function(t){var n,i;return i=0,i+=t>>1&1,i=2-(i&=1),i=(n=1+(i<<=1))*(3&t),i>>=2,i+=n*(t>>2&3)&3,i*=n,i=4-(i&=3),i=(n+=i<<=2)*(15&t),i>>=4,i+=n*(t>>4&15)&15,i*=n,n+((i=16-(i&=15))<<4)},n}(h),h.DBIG=function(t){var n=function(t){this.w=[],this.zero(),this.w[0]=t};return n.prototype={zero:function(){for(var n=0;n>t.BIG.BASEBITS;return this.w[t.BIG.DNLEN-1]=this.w[t.BIG.DNLEN-1]+e,this},muladd:function(n,i,e,o){var r=n*i+e+this.w[o];return this.w[o]=r&t.BIG.BMASK,(r-this.w[o])*t.BIG.MODINV},shr:function(n){var i,e=n%t.BIG.BASEBITS,o=Math.floor(n/t.BIG.BASEBITS);for(i=0;i>e|this.w[o+i+1]<>e,i=t.BIG.DNLEN-o;i>t.BIG.BASEBITS-e,i=t.BIG.DNLEN-2;i>o;i--)this.w[i]=this.w[i-o]<>t.BIG.BASEBITS-e;for(this.w[o]=this.w[0]<=0&&0===this.w[e];)e--;if(e<0)return 0;for(n=t.BIG.BASEBITS*e,i=this.w[e];0!==i;)i=Math.floor(i/2),n++;return n},toString:function(){var t,i,e="",o=this.nbits();for(o%4==0?o=Math.floor(o/4):(o=Math.floor(o/4),o++),i=o-1;i>=0;i--)(t=new n(0)).copy(this),t.shr(4*i),e+=(15&t.w[0]).toString(16);return e},mod:function(i){var e=0,o=new n(0),r=new n(0),s=new t.BIG(0);if(this.norm(),o.hcopy(i),s.hcopy(this),n.comp(this,o)<0)return s;do{o.shl(1),e++}while(n.comp(this,o)>=0);for(;e>0;)o.shr(1),r.copy(this),r.sub(o),r.norm(),this.cmove(r,1-(r.w[t.BIG.DNLEN-1]>>t.BIG.CHUNK-1&1)),e--;return s.hcopy(this),s},div:function(i){var e=0,o=0,r=new n(0),s=new n(0),h=new t.BIG(0),c=new t.BIG(0),u=new t.BIG(1);for(r.hcopy(i),this.norm();n.comp(this,r)>=0;)u.fshl(1),r.shl(1),o++;for(;o>0;)r.shr(1),u.shr(1),s.copy(this),s.sub(r),s.norm(),e=1-(s.w[t.BIG.DNLEN-1]>>t.BIG.CHUNK-1&1),this.cmove(s,e),h.copy(c),h.add(u),h.norm(),c.cmove(h,e),o--;return c},split:function(n){var i,e,o=new t.BIG(0),r=n%t.BIG.BASEBITS,s=this.w[t.BIG.DNLEN-1]<=t.BIG.NLEN-1;e--)i=this.w[e]>>r|s,s=this.w[e]<=0;e--)if(n.w[e]!=i.w[e])return n.w[e]>i.w[e]?1:-1;return 0},n}(h),void 0!==h.config.TFF?(h.FF=function(t){var n=function(n){this.v=new Array(n),this.length=n;for(var i=0;i>n.P_TBITS)},zero:function(){for(var t=0;t>t.BIG.BASEBITS)},copy:function(t){for(var n=0;n0;t--)i=this.v[t].fshr(1),this.v[t-1].ortop(i<=0;t--)n+=this.v[t].toString();return n},toBytes:function(n){var i;for(i=0;i=0);for(;i>0;)t.shr(),n.comp(this,t)>=0&&(this.sub(t),this.norm()),i--}},reduce:function(t,i){var e=t.length,o=new n(2*e),r=new n(e),s=new n(e);return r.sducopy(this),s.karmul_lower(0,this,0,i,0,o,0,e),this.karmul_upper(t,s,o,e),s.sducopy(this),r.add(t),r.sub(s),r.norm(),r},dmod:function(i){var e,o=i.length,r=new n(2*o),s=new n(2*o),h=new n(o);for(s.copy(this),s.norm(),r.dsucopy(i),e=t.BIG.BIGBITS*o;n.comp(s,r)>=0;)s.sub(r),s.norm();for(;e>0;)r.shr(),n.comp(s,r)>=0&&(s.sub(r),s.norm()),e--;return h.copy(s),h.mod(i),h},invmodp:function(t){var i=t.length,e=new n(i),o=new n(i),r=new n(i),s=new n(i),h=new n(i),c=new n(i);for(c.one(),e.copy(this),o.copy(t),r.copy(c),s.zero();0!==n.comp(e,c)&&0!==n.comp(o,c);){for(;0===e.parity();)e.shr(),0!==r.parity()&&(r.add(t),r.norm()),r.shr();for(;0===o.parity();)o.shr(),0!==s.parity()&&(s.add(t),s.norm()),s.shr();n.comp(e,o)>=0?(e.sub(o),e.norm(),n.comp(r,s)>=0?r.sub(s):(h.copy(t),h.sub(s),r.add(h)),r.norm()):(o.sub(e),o.norm(),n.comp(s,r)>=0?s.sub(r):(h.copy(t),h.sub(r),s.add(h)),s.norm())}0===n.comp(e,c)?this.copy(r):this.copy(s)},nres:function(i){var e,o=i.length;1===o?((e=new t.DBIG(0)).hcopy(this.v[0]),e.shl(t.BIG.NLEN*t.BIG.BASEBITS),this.v[0].copy(e.mod(i.v[0]))):((e=new n(2*o)).dsucopy(this),this.copy(e.dmod(i)))},redc:function(i,e){var o,r=i.length;1===r?((o=new t.DBIG(0)).hcopy(this.v[0]),this.v[0].copy(t.BIG.monty(i.v[0],(1<=Math.floor((n.P_FEXCESS-1)/(h+1))&&this.mod(e),1===c?(r=t.BIG.mul(this.v[0],i.v[0]),this.v[0].copy(t.BIG.monty(e.v[0],(1<=Math.floor((n.P_FEXCESS-1)/(r+1))&&this.mod(i),1===i.length?(o=t.BIG.sqr(this.v[0]),this.v[0].copy(t.BIG.monty(i.v[0],(1<=0;o--)r=i.v[Math.floor(o/t.BIG.BIGBITS)].bit(o%t.BIG.BIGBITS),this.copy(h),this.modmul(c,e,u),n.cswap(h,c,r),h.modsqr(e,u),c.copy(this),n.cswap(h,c,r);this.copy(h),this.redc(e,u)},skspow:function(i,e){var o,r,s=e.length,h=new n(s),c=new n(s),u=e.invmod2m();for(this.mod(e),h.one(),c.copy(this),h.nres(e),c.nres(e),o=8*t.BIG.MODBYTES-1;o>=0;o--)r=i.bit(o),this.copy(h),this.modmul(c,e,u),n.cswap(h,c,r),h.modsqr(e,u),c.copy(this),n.cswap(h,c,r);this.copy(h),this.redc(e,u)},power:function(t,i){var e=i.length,o=!0,r=new n(e),s=i.invmod2m();if(r.copy(this),r.nres(i),2==t)this.copy(r),this.modsqr(i,s);else for(;t%2==1&&(o?this.copy(r):this.modmul(r,i,s),o=!1),0!=(t>>=1);)r.modsqr(i,s);this.redc(i,s)},pow:function(i,e){var o,r=e.length,s=new n(r),h=e.invmod2m();for(s.copy(this),this.one(),this.nres(e),s.nres(e),o=8*t.BIG.MODBYTES*r-1;o>=0;o--)this.modsqr(e,h),1===i.v[Math.floor(o/t.BIG.BIGBITS)].bit(o%t.BIG.BIGBITS)&&this.modmul(s,e,h);this.redc(e,h)},pow2:function(i,e,o,r){var s,h,c,u=r.length,a=new n(u),f=new n(u),E=new n(u),B=r.invmod2m();for(a.copy(this),f.copy(e),a.nres(r),f.nres(r),E.copy(a),E.modmul(f,r,B),this.one(),this.nres(r),s=8*t.BIG.MODBYTES-1;s>=0;s--)h=i.bit(s),c=o.bit(s),this.modsqr(r,B),1==h?1==c?this.modmul(E,r,B):this.modmul(a,r,B):1==c&&this.modmul(f,r,B);this.redc(r,B)},cfactor:function(t){var i,e=this.length,o=new n(e),r=new n(e);r.set(t),o.copy(this),o.norm();do{for(o.sub(r),o.norm();!o.iszilch()&&0===o.parity();)o.shr()}while(n.comp(o,r)>0);return i=o.v[0].get(0),n.igcd(t,i)>1}},n.comp=function(n,i){var e,o;for(e=n.length-1;e>=0;e--)if(0!==(o=t.BIG.comp(n.v[e],i.v[e])))return o;return 0},n.fromBytes=function(n,i){var e;for(e=0;e>>4&15).toString(16),e+=(15&n).toString(16);return e},bytestostring:function(t){var n,i="";for(n=0;n=0&&o.process_num(e),r=o.hash()):n==this.SHA384?(o=new t.HASH384,null!=i&&o.process_array(i),e>=0&&o.process_num(e),r=o.hash()):n==this.SHA512&&(o=new t.HASH512,null!=i&&o.process_array(i),e>=0&&o.process_num(e),r=o.hash()),r},KEY_PAIR:function(n,i,e,o){for(var r=o.n.length>>1,s=new t.FF(r),h=new t.FF(r),c=new t.FF(r);;){for(e.p.random(n);3!=e.p.lastbits(2);)e.p.inc(1);for(;!t.FF.prime(e.p,n);)e.p.inc(4);if(h.copy(e.p),h.dec(1),!h.cfactor(i))break}for(;;){for(e.q.random(n);3!=e.q.lastbits(2);)e.q.inc(1);for(;!t.FF.prime(e.q,n);)e.q.inc(4);if(c.copy(e.q),c.dec(1),!c.cfactor(i))break}o.n=t.FF.mul(e.p,e.q),o.e=i,s.copy(h),s.shr(),e.dp.set(i),e.dp.invmodp(s),0===e.dp.parity()&&e.dp.add(s),e.dp.norm(),s.copy(c),s.shr(),e.dq.set(i),e.dq.invmodp(s),0===e.dq.parity()&&e.dq.add(s),e.dq.norm(),e.c.copy(e.p),e.c.invmodp(e.q)},MGF1:function(t,n,i,e){var o,r,s,h=t,c=[],u=0;for(s=0;si)for(s=0;sa-r-s-1)return null;for(u=this.hashit(t,o,-1),c=0;c=1;c--)y[c]=y[c-1];for(c=0;c>=0;c--)y[c]=0;return y},OAEP_DECODE:function(t,i,e){var o,r,s,h,c,u,a,f,E,B,y=n.RFS-1,I=[],m=[],p=[];if(y<(s=r=t)+r+1)return null;for(a=0;a=u;a--)e[a]=e[a-u];for(a=u-1;a>=0;a--)e[a]=0}for(E=this.hashit(t,i,-1),a=0;a=y-s-r)return null;if(0!==p[f])break}if(c=p[f],!o||0!==h||1!=c){for(a=0;a0&&r.add(n.q),r.sub(o),r.norm(),r=(s=t.FF.mul(n.c,r)).dmod(n.q),s=t.FF.mul(r,n.p),c.add(s),c.norm(),c.toBytes(e)}};return n}(h),h.rsa_public_key=function(t){return function(n){this.e=0,this.n=new t.FF(n)}}(h),void(h.rsa_private_key=function(t){return function(n){this.p=new t.FF(n),this.q=new t.FF(n),this.dp=new t.FF(n),this.dq=new t.FF(n),this.c=new t.FF(n)}}(h))):void 0!==h.config.CURVE?(h.ROM_CURVE=e[h.config.CURVE],h.ROM_FIELD=o[h.config.FIELD],h.FP=function(t){var n=function(i){i instanceof n?(this.f=new t.BIG(i.f),this.XES=i.XES):(this.f=new t.BIG(i),this.nres())};return n.NOT_SPECIAL=0,n.PSEUDO_MERSENNE=1,n.GENERALISED_MERSENNE=2,n.MONTGOMERY_FRIENDLY=3,n.MODBITS=t.config["@NBT"],n.MOD8=t.config["@M8"],n.MODTYPE=t.config["@MT"],n.FEXCESS=1<n.FEXCESS&&this.reduce(),e=t.BIG.mul(this.f,i.f),this.f.copy(n.mod(e)),this.XES=2,this},imul:function(t){var i,e,o=!1;return t<0&&(t=-t,o=!0),n.MODTYPE==n.PSEUDO_MERSENNE||n.MODTYPE==n.GENERALISED_MERSENNE?(i=this.f.pxmul(t),this.f.copy(n.mod(i)),this.XES=2):this.XES*t<=n.FEXCESS?(this.f.pmul(t),this.XES*=t):(e=new n(t),this.mul(e)),o&&(this.neg(),this.norm()),this},sqr:function(){var i,e;return this.XES*this.XES>n.FEXCESS&&this.reduce(),i=t.BIG.sqr(this.f),e=n.mod(i),this.f.copy(e),this.XES=2,this},add:function(t){return this.f.add(t.f),this.XES+=t.XES,this.XES>n.FEXCESS&&this.reduce(),this},neg:function(){var i,e=new t.BIG(0);return e.rcopy(t.ROM_FIELD.Modulus),i=n.logb2(this.XES-1),e.fshl(i),this.XES=1<n.FEXCESS&&this.reduce(),this},sub:function(t){var i=new n(0);return i.copy(t),i.neg(),this.add(i),this},rsub:function(t){var i=new n(0);i.copy(this),i.neg(),this.copy(t),this.add(i)},div2:function(){var n;return 0===this.f.parity()||((n=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),this.f.add(n),this.f.norm()),this.f.fshr(1),this},inverse:function(){var n=new t.BIG(0);return n.rcopy(t.ROM_FIELD.Modulus),n.dec(2),n.norm(),this.copy(this.pow(n)),this},equals:function(n){return n.reduce(),this.reduce(),0===t.BIG.comp(n.f,this.f)},pow:function(i){var e,o,r,s,h=[],c=[],u=new t.BIG(i);for(u.norm(),o=1+Math.floor((u.nbits()+3)/4),e=0;e=0;e--)s.sqr(),s.sqr(),s.sqr(),s.sqr(),s.mul(c[h[e]]);return s.reduce(),s},jacobi:function(){var n=new t.BIG(0),i=this.redc();return n.rcopy(t.ROM_FIELD.Modulus),i.jacobi(n)},sqrt:function(){var i,e,o,r=new t.BIG(0);return this.reduce(),r.rcopy(t.ROM_FIELD.Modulus),5==n.MOD8?(r.dec(5),r.norm(),r.shr(3),(i=new n(0)).copy(this),i.f.shl(1),e=i.pow(r),i.mul(e),i.mul(e),i.f.dec(1),(o=new n(0)).copy(this),o.mul(e),o.mul(i),o.reduce(),o):(r.inc(1),r.norm(),r.shr(2),this.pow(r))}},n.logb2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},n.mod=function(i){var e,o,r,s,h,c,u,a,f,E=new t.BIG(0);if(n.MODTYPE==n.PSEUDO_MERSENNE)return o=i.split(n.MODBITS),E.hcopy(i),r=1!=t.ROM_FIELD.MConst?o.pmul(t.ROM_FIELD.MConst):0,o.add(E),o.norm(),s=o.w[t.BIG.NLEN-1],o.w[t.BIG.NLEN-1]&=n.TMASK,o.inc(t.ROM_FIELD.MConst*((s>>n.TBITS)+(r<>n.TBITS,E.w[t.BIG.NLEN-1]&=n.TMASK,E.w[0]+=u,E.w[Math.floor(224/t.BIG.BASEBITS)]+=u<<224%t.BIG.BASEBITS,E.norm()),n.MODTYPE==n.NOT_SPECIAL&&((a=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),E.copy(t.BIG.monty(a,t.ROM_FIELD.MConst,i))),E},n}(h),h.ECP=function(t){var n=function(){this.x=new t.FP(0),this.y=new t.FP(1),n.CURVETYPE!=n.EDWARDS?this.z=new t.FP(0):this.z=new t.FP(1)};return n.WEIERSTRASS=0,n.EDWARDS=1,n.MONTGOMERY=2,n.NOT=0,n.BN=1,n.BLS=2,n.D_TYPE=0,n.M_TYPE=1,n.POSITIVEX=0,n.NEGATIVEX=1,n.CURVETYPE=t.config["@CT"],n.CURVE_PAIRING_TYPE=t.config["@PF"],n.SEXTIC_TWIST=t.config["@ST"],n.SIGN_OF_X=t.config["@SX"],n.HASH_TYPE=t.config["@HT"],n.AESKEY=t.config["@AK"],n.prototype={is_infinity:function(){return this.x.reduce(),this.z.reduce(),n.CURVETYPE==n.EDWARDS?(this.y.reduce(),this.x.iszilch()&&this.y.equals(this.z)):n.CURVETYPE==n.WEIERSTRASS?(this.y.reduce(),this.x.iszilch()&&this.z.iszilch()):n.CURVETYPE!=n.MONTGOMERY||this.z.iszilch()},cswap:function(t,i){this.x.cswap(t.x,i),n.CURVETYPE!=n.MONTGOMERY&&this.y.cswap(t.y,i),this.z.cswap(t.z,i)},cmove:function(t,i){this.x.cmove(t.x,i),n.CURVETYPE!=n.MONTGOMERY&&this.y.cmove(t.y,i),this.z.cmove(t.z,i)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(i){var e,o;return e=new t.FP(0),o=new t.FP(0),e.copy(this.x),e.mul(i.z),e.reduce(),o.copy(i.x),o.mul(this.z),o.reduce(),!(!e.equals(o)||n.CURVETYPE!=n.MONTGOMERY&&(e.copy(this.y),e.mul(i.z),e.reduce(),o.copy(i.y),o.mul(this.z),o.reduce(),!e.equals(o)))},copy:function(t){this.x.copy(t.x),n.CURVETYPE!=n.MONTGOMERY&&this.y.copy(t.y),this.z.copy(t.z)},neg:function(){n.CURVETYPE==n.WEIERSTRASS?(this.y.neg(),this.y.norm()):n.CURVETYPE==n.EDWARDS&&(this.x.neg(),this.x.norm())},inf:function(){this.x.zero(),n.CURVETYPE!=n.MONTGOMERY&&this.y.one(),n.CURVETYPE!=n.EDWARDS?this.z.zero():this.z.one()},setxy:function(i,e){var o,r;this.x=new t.FP(0),this.x.bcopy(i),this.y=new t.FP(0),this.y.bcopy(e),this.z=new t.FP(1),o=n.RHS(this.x),n.CURVETYPE==n.MONTGOMERY?1!=o.jacobi()&&this.inf():((r=new t.FP(0)).copy(this.y),r.sqr(),r.equals(o)||this.inf())},setxi:function(i,e){var o,r;this.x=new t.FP(0),this.x.bcopy(i),o=n.RHS(this.x),this.z=new t.FP(1),1==o.jacobi()?((r=o.sqrt()).redc().parity()!=e&&r.neg(),this.y=r):this.inf()},setx:function(i){var e;this.x=new t.FP(0),this.x.bcopy(i),e=n.RHS(this.x),this.z=new t.FP(1),1==e.jacobi()?n.CURVETYPE!=n.MONTGOMERY&&(this.y=e.sqrt()):this.inf()},affine:function(){var i;this.is_infinity()||(i=new t.FP(1),this.z.equals(i)||(this.z.inverse(),n.CURVETYPE!=n.EDWARDS&&n.CURVETYPE!=n.WEIERSTRASS||(this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z=i),n.CURVETYPE==n.MONTGOMERY&&(this.x.mul(this.z),this.x.reduce(),this.z=i)))},getX:function(){return this.affine(),this.x.redc()},getY:function(){return this.affine(),this.y.redc()},getS:function(){return this.affine(),this.getY().parity()},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(i){var e,o=[];for(n.CURVETYPE!=n.MONTGOMERY?i[0]=4:i[0]=2,this.affine(),this.x.redc().toBytes(o),e=0;e>2),p.add(y),p.norm(),this.z.copy(p),this.z.mul(a))},add:function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,m,p,d;n.CURVETYPE==n.WEIERSTRASS&&(0==t.ROM_CURVE.CURVE_A?(e=3*t.ROM_CURVE.CURVE_B_I,(o=new t.FP(0)).copy(this.x),o.mul(i.x),(r=new t.FP(0)).copy(this.y),r.mul(i.y),(s=new t.FP(0)).copy(this.z),s.mul(i.z),(h=new t.FP(0)).copy(this.x),h.add(this.y),h.norm(),(c=new t.FP(0)).copy(i.x),c.add(i.y),c.norm(),h.mul(c),c.copy(o),c.add(r),h.sub(c),h.norm(),c.copy(this.y),c.add(this.z),c.norm(),(u=new t.FP(0)).copy(i.y),u.add(i.z),u.norm(),c.mul(u),u.copy(r),u.add(s),c.sub(u),c.norm(),u.copy(this.x),u.add(this.z),u.norm(),(a=new t.FP(0)).copy(i.x),a.add(i.z),a.norm(),u.mul(a),a.copy(o),a.add(s),a.rsub(u),a.norm(),u.copy(o),u.add(o),o.add(u),o.norm(),s.imul(e),(f=new t.FP(0)).copy(r),f.add(s),f.norm(),r.sub(s),r.norm(),a.imul(e),u.copy(a),u.mul(c),s.copy(h),s.mul(r),u.rsub(s),a.mul(o),r.mul(f),a.add(r),o.mul(h),f.mul(c),f.add(o),this.x.copy(u),this.x.norm(),this.y.copy(a),this.y.norm(),this.z.copy(f),this.z.norm()):((o=new t.FP(0)).copy(this.x),(r=new t.FP(0)).copy(this.y),(s=new t.FP(0)).copy(this.z),(h=new t.FP(0)).copy(this.x),(c=new t.FP(0)).copy(i.x),f=new t.FP(0),(a=new t.FP(0)).copy(i.x),(u=new t.FP(0)).copy(i.y),e=new t.FP(0),0==t.ROM_CURVE.CURVE_B_I&&e.rcopy(t.ROM_CURVE.CURVE_B),o.mul(i.x),r.mul(i.y),s.mul(i.z),h.add(this.y),h.norm(),c.add(i.y),c.norm(),h.mul(c),c.copy(o),c.add(r),h.sub(c),h.norm(),c.copy(this.y),c.add(this.z),c.norm(),u.add(i.z),u.norm(),c.mul(u),u.copy(r),u.add(s),c.sub(u),c.norm(),u.copy(this.x),u.add(this.z),u.norm(),a.add(i.z),a.norm(),u.mul(a),a.copy(o),a.add(s),a.rsub(u),a.norm(),f.copy(s),0==t.ROM_CURVE.CURVE_B_I?f.mul(e):f.imul(t.ROM_CURVE.CURVE_B_I),u.copy(a),u.sub(f),u.norm(),f.copy(u),f.add(u),u.add(f),f.copy(r),f.sub(u),f.norm(),u.add(r),u.norm(),0==t.ROM_CURVE.CURVE_B_I?a.mul(e):a.imul(t.ROM_CURVE.CURVE_B_I),r.copy(s),r.add(s),s.add(r),a.sub(s),a.sub(o),a.norm(),r.copy(a),r.add(a),a.add(r),a.norm(),r.copy(o),r.add(o),o.add(r),o.sub(s),o.norm(),r.copy(c),r.mul(a),s.copy(o),s.mul(a),a.copy(u),a.mul(f),a.add(s),u.mul(h),u.sub(r),f.mul(c),r.copy(h),r.mul(o),f.add(r),this.x.copy(u),this.x.norm(),this.y.copy(a),this.y.norm(),this.z.copy(f),this.z.norm())),n.CURVETYPE==n.EDWARDS&&((E=new t.FP(0)).copy(this.z),B=new t.FP(0),(y=new t.FP(0)).copy(this.x),(I=new t.FP(0)).copy(this.y),m=new t.FP(0),p=new t.FP(0),d=new t.FP(0),E.mul(i.z),B.copy(E),B.sqr(),y.mul(i.x),I.mul(i.y),m.copy(y),m.mul(I),0==t.ROM_CURVE.CURVE_B_I?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),m.mul(e)):m.imul(t.ROM_CURVE.CURVE_B_I),p.copy(B),p.sub(m),d.copy(B),d.add(m),1==t.ROM_CURVE.CURVE_A&&(m.copy(I),m.sub(y)),y.add(I),B.copy(this.x),B.add(this.y),I.copy(i.x),I.add(i.y),B.norm(),I.norm(),B.mul(I),B.sub(y),B.norm(),p.norm(),B.mul(p),this.x.copy(E),this.x.mul(B),d.norm(),1==t.ROM_CURVE.CURVE_A&&(m.norm(),y.copy(m),y.mul(d)),-1==t.ROM_CURVE.CURVE_A&&(y.norm(),y.mul(d)),this.y.copy(E),this.y.mul(y),this.z.copy(p),this.z.mul(d))},dadd:function(n,i){var e,o,r,s,h,c;(e=new t.FP(0)).copy(this.x),(o=new t.FP(0)).copy(this.x),(r=new t.FP(0)).copy(n.x),(s=new t.FP(0)).copy(n.x),h=new t.FP(0),c=new t.FP(0),e.add(this.z),o.sub(this.z),r.add(n.z),s.sub(n.z),s.norm(),e.norm(),h.copy(s),h.mul(e),r.norm(),o.norm(),c.copy(r),c.mul(o),e.copy(h),e.add(c),e.norm(),e.sqr(),o.copy(h),o.sub(c),o.norm(),o.sqr(),this.x.copy(e),this.z.copy(i.x),this.z.mul(o)},sub:function(t){t.neg(),this.add(t),t.neg()},pinmul:function(i,e){var o,r,s,h,c;if(n.CURVETYPE==n.MONTGOMERY)return this.mul(new t.BIG(i));for(s=new n,h=new n,(c=new n).copy(this),o=e-1;o>=0;o--)r=i>>o&1,s.copy(c),s.add(h),h.cswap(c,r),c.copy(s),h.dbl(),h.cswap(c,r);return s.copy(h),s.affine(),s},cfp:function(){var n=t.ROM_CURVE.CURVE_Cof_I,i=new t.BIG(0);if(1!=n){if(4==n)return this.dbl(),this.dbl(),void this.affine();if(8==n)return this.dbl(),this.dbl(),this.dbl(),void this.affine();i.rcopy(t.ROM_CURVE.CURVE_Cof),this.copy(this.mul(i))}},mul:function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,m,p;if(i.iszilch()||this.is_infinity())return new n;if(e=new n,n.CURVETYPE==n.MONTGOMERY){for(o=new n,(r=new n).copy(this),(s=new n).copy(this),s.dbl(),o.copy(this),o.affine(),B=(I=i.nbits())-2;B>=0;B--)y=i.bit(B),e.copy(s),e.dadd(r,o),r.cswap(s,y),s.copy(e),r.dbl(),r.cswap(s,y);e.copy(r)}else{for(h=new t.BIG,c=new t.BIG,u=new n,a=new n,f=[],E=[],this.affine(),u.copy(this),u.dbl(),f[0]=new n,f[0].copy(this),B=1;B<8;B++)f[B]=new n,f[B].copy(f[B-1]),f[B].add(u);for(c.copy(i),m=c.parity(),c.inc(1),c.norm(),p=c.parity(),h.copy(c),h.inc(1),h.norm(),c.cmove(h,m),u.cmove(this,p),a.copy(u),I=1+Math.floor((c.nbits()+3)/4),B=0;B=0;B--)u.select(f,E[B]),e.dbl(),e.dbl(),e.dbl(),e.dbl(),e.add(u);e.sub(a)}return e.affine(),e},mul2:function(i,e,o){var r,s,h,c,u,a,f=new t.BIG,E=new t.BIG,B=new t.BIG,y=new n,I=new n,m=new n,p=[],d=[];for(this.affine(),e.affine(),f.copy(i),E.copy(o),p[1]=new n,p[1].copy(this),p[1].sub(e),p[2]=new n,p[2].copy(this),p[2].add(e),y.copy(e),y.dbl(),p[0]=new n,p[0].copy(p[1]),p[0].sub(y),p[3]=new n,p[3].copy(p[2]),p[3].add(y),I.copy(this),I.dbl(),p[5]=new n,p[5].copy(p[1]),p[5].add(I),p[6]=new n,p[6].copy(p[2]),p[6].add(I),p[4]=new n,p[4].copy(p[5]),p[4].sub(y),p[7]=new n,p[7].copy(p[6]),p[7].add(y),s=f.parity(),f.inc(1),f.norm(),h=f.parity(),B.copy(f),B.inc(1),B.norm(),f.cmove(B,s),I.cmove(this,h),m.copy(I),s=E.parity(),E.inc(1),E.norm(),h=E.parity(),B.copy(E),B.inc(1),B.norm(),E.cmove(B,s),y.cmove(e,h),m.add(y),B.copy(f),B.add(E),B.norm(),c=1+Math.floor((B.nbits()+1)/2),r=0;r=0;r--)I.select(p,d[r]),y.dbl(),y.dbl(),y.add(I);return y.sub(m),y.affine(),y}},n.generator=function(){var i=new n,e=new t.BIG(0),o=new t.BIG(0);return e.rcopy(t.ROM_CURVE.CURVE_Gx),t.ECP.CURVETYPE!=t.ECP.MONTGOMERY?(o.rcopy(t.ROM_CURVE.CURVE_Gy),i.setxy(e,o)):i.setx(e),i},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.fromBytes=function(i){var e,o,r,s=[],h=new n,c=new t.BIG(0);for(c.rcopy(t.ROM_FIELD.Modulus),r=0;r=0)return h;if(4==i[0]){for(r=0;r=0||h.setxy(e,o),h}return h.setx(e),h},n.RHS=function(i){var e,o,r,s,h=new t.FP(0);return i.norm(),h.copy(i),h.sqr(),n.CURVETYPE==n.WEIERSTRASS?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),h.mul(i),-3==t.ROM_CURVE.CURVE_A&&((o=new t.FP(0)).copy(i),o.imul(3),o.neg(),o.norm(),h.add(o)),h.add(e)):n.CURVETYPE==n.EDWARDS?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),r=new t.FP(1),e.mul(h),e.sub(r),e.norm(),-1==t.ROM_CURVE.CURVE_A&&h.neg(),h.sub(r),h.norm(),e.inverse(),h.mul(e)):n.CURVETYPE==n.MONTGOMERY&&((s=new t.FP(0)).copy(h),s.mul(i),h.imul(t.ROM_CURVE.CURVE_A),h.add(s),h.add(i)),h.reduce(),h},n.mapit=function(i){var e=new t.BIG(0),o=t.BIG.fromBytes(i),r=new n;for(e.rcopy(t.ROM_FIELD.Modulus),o.mod(e);;){for(;n.CURVETYPE!=n.MONTGOMERY?r.setxi(o,0):r.setx(o),o.inc(1),o.norm(),r.is_infinity(););if(r.cfp(),!r.is_infinity())break}return r},n}(h),h.ECDH=function(t){return{INVALID_PUBLIC_KEY:-2,ERROR:-3,INVALID:-4,EFS:t.BIG.MODBYTES,EGS:t.BIG.MODBYTES,SHA256:32,SHA384:48,SHA512:64,inttobytes:function(t,n){var i,e=[];for(i=0;i0&&i>0;)e[--i]=255&t,t=Math.floor(t/256);return e},bytestostring:function(t){var n,i,e="",o=t.length;for(i=0;i0&&h.process_num(e),null!=o&&h.process_array(o),0==(s=h.hash()).length)return null;if(0==r)return s;if(c=[],n>=r)for(u=0;ui)for(r=0;re)for(s=0;s32&&(c=128),o=new Array(c),s<4)return 0;for(r=0;rc)for(h=this.hashit(t,i,0,null,0),r=0;r=i.length){r=!0;break}o=i[E++]}if(u.decrypt(a),r)break;for(c=0;c<16;c++)f[B++]=a[c]}if(u.end(),s=!1,h=a[15],(15!=c||h<1||h>16)&&(s=!0),h>=2&&h<=16)for(c=16-h;c<16;c++)a[c]!=h&&(s=!0);if(!s)for(c=0;c<16-h;c++)f[B++]=a[c];if(e=[],s)return e;for(c=0;c=0||a.iszilch()||t.BIG.comp(a,h)>=0)&&(I=this.INVALID),0===I&&(a.invmodp(h),c=t.BIG.modmul(c,a,h),f=t.BIG.modmul(u,a,h),(B=t.ECP.fromBytes(i)).is_infinity()?I=this.ERROR:((y=new t.ECP).copy(B),(y=y.mul2(f,E,c)).is_infinity()?I=this.INVALID:((a=y.getX()).mod(h),0!==t.BIG.comp(a,u)&&(I=this.INVALID)))),I},ECIES_ENCRYPT:function(n,i,e,o,r,s,h,c){var u,a,f,E,B=[],y=[],I=[],m=[],p=[],d=[];if(0!==this.KEY_PAIR_GENERATE(o,p,h))return d;if(0!==this.ECPSVDP_DH(p,r,B))return d;for(E=0;E<2*this.EFS+1;E++)y[E]=h[E];for(E=0;E>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP4(this.a),i=new t.FP4(this.c),e=new t.FP4(this.b),o=new t.FP4(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP4(this.a),i=new t.FP4(this.b),e=new t.FP4(this.c),o=new t.FP4(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP4(this.a),e=new t.FP4(0),o=new t.FP4(this.b),r=new t.FP4(0),s=new t.FP4(this.a),h=new t.FP4(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP4(this.a),r=new t.FP4(this.b),s=new t.FP4(this.b),h=new t.FP4(0),c=new t.FP4(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP4(this.a),o=new t.FP4(0),r=new t.FP4(0),s=new t.FP4(0),h=new t.FP4(this.a),c=new t.FP4(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP4(this.a),i=new t.FP4(this.b),e=new t.FP4(this.a),o=new t.FP4(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n){var i=new t.FP2(n),e=new t.FP2(n);i.sqr(),e.mul(i),this.a.frob(e),this.b.frob(e),this.c.frob(e),this.b.pmul(n),this.c.pmul(i)},trace:function(){var n=new t.FP4(0);return n.copy(this.a),n.imul(3),n.reduce(),n},toString:function(){return"["+this.a.toString()+","+this.b.toString()+","+this.c.toString()+"]"},toBytes:function(n){var i,e=[];for(this.a.geta().getA().toBytes(e),i=0;i=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),m=E.trace(),B=B.xtr_pow2(y,I,m,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f=[];for(e=0;e>31&1},n.pow4=function(i,e){var o,r,s,h,c,u,a=[],f=new n(0),E=new n(0),B=[],y=new t.BIG(0),I=[],m=[];for(o=0;o<4;o++)B[o]=new t.BIG(e[o]),B[o].norm();for(a[0]=new n(i[0]),a[1]=new n(a[0]),a[1].mul(i[1]),a[2]=new n(a[0]),a[2].mul(i[2]),a[3]=new n(a[1]),a[3].mul(i[2]),a[4]=new n(i[0]),a[4].mul(i[3]),a[5]=new n(a[1]),a[5].mul(i[3]),a[6]=new n(a[2]),a[6].mul(i[3]),a[7]=new n(a[3]),a[7].mul(i[3]),u=1-B[0].parity(),B[0].inc(u),B[0].norm(),y.zero(),o=0;o<4;o++)y.or(B[o]);for(m[(h=1+y.nbits())-1]=1,o=0;o>1),B[r].norm(),I[o]+=c*s,s*=2;for(E.select(a,2*I[h-1]+1),o=h-2;o>=0;o--)E.usqr(),f.select(a,2*I[o]+m[o]),E.mul(f);return f.copy(i[0]),f.conj(),f.mul(E),E.cmove(f,u),E.reduce(),E},n}(h),h.ECP2=function(t){var n=function(){this.x=new t.FP2(0),this.y=new t.FP2(1),this.z=new t.FP2(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e,o,r=new n;o=((o=(i^(e=i>>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.neg(),this.cmove(r,1&e)},equals:function(n){var i,e;return(i=new t.FP2(0)).copy(this.x),(e=new t.FP2(0)).copy(n.x),i.copy(this.x),i.mul(n.z),i.reduce(),e.copy(n.x),e.mul(this.z),e.reduce(),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),i.reduce(),e.copy(n.y),e.mul(this.z),e.reduce(),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP2(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o=new n,r=new t.BIG(0),s=new t.BIG(0);return r.rcopy(t.ROM_CURVE.CURVE_Pxa),s.rcopy(t.ROM_CURVE.CURVE_Pxb),(i=new t.FP2(0)).bset(r,s),r.rcopy(t.ROM_CURVE.CURVE_Pya),s.rcopy(t.ROM_CURVE.CURVE_Pyb),(e=new t.FP2(0)).bset(r,s),o.setxy(i,e),o},n.fromBytes=function(i){var e,o,r,s,h,c,u=[];for(r=0;r>1),y[r].norm(),I[o]+=c*s,s*=2;for(f.select(E,2*I[h-1]+1),o=h-2;o>=0;o--)f.dbl(),a.select(E,2*I[o]+m[o]),f.add(a);return a.copy(f),a.sub(i[0]),f.cmove(a,u),f.affine(),f},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E=new t.BIG(0),B=new t.BIG(0);for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);u=new t.FP2(r,o),(s=new n).setx(u),s.is_infinity();)o.inc(1),o.norm();return E.rcopy(t.ROM_FIELD.Fra),B.rcopy(t.ROM_FIELD.Frb),u=new t.FP2(E,B),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(u.inverse(),u.norm()),(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&((h=new n).copy(s),h=h.mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&h.neg(),(c=new n).copy(h),c.dbl(),c.add(h),c.frob(u),s.frob(u),s.frob(u),s.frob(u),s.add(h),s.add(c),h.frob(u),h.frob(u),s.add(h)),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BLS&&(f=(a=s.mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&a.neg(),f.sub(a),f.sub(s),a.sub(s),a.frob(u),s.dbl(),s.frob(u),s.frob(u),s.add(f),s.add(a)),s.affine(),s},n}(h),h.PAIR=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,m=new t.FP12(1),p=new t.FP4(0);return n==i?(r=new t.FP2(n.getx()),s=new t.FP2(n.gety()),h=new t.FP2(n.getz()),(c=new t.FP2(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.pmul(o),r.imul(6),r.pmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_ip2(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.mul_ip(),h.add(h),c.mul_ip(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP4(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP4(r),p=new t.FP4(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP4(0),(p=new t.FP4(r)).times_i()),n.dbl()):(a=new t.FP2(n.getx()),f=new t.FP2(n.gety()),E=new t.FP2(n.getz()),B=new t.FP2(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.pmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.mul_ip(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.pmul(e),f.neg(),f.norm(),y=new t.FP4(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP4(f),p=new t.FP4(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP4(0),(p=new t.FP4(f)).times_i()),n.add(i)),m.set(y,I,p),m},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m,p;for((h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),c=new t.BIG(h),a=new t.ECP2,t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?((o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(s.inverse(),s.norm()),c.pmul(6),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX?c.inc(2):c.dec(2)):c.copy(h),c.norm(),(u=new t.BIG(c)).pmul(3),u.norm(),E=new t.FP(e.getx()),B=new t.FP(e.gety()),y=new t.ECP2,I=new t.FP12(1),y.copy(i),p=u.nbits()-2;p>=1;p--)I.sqr(),f=n.line(y,y,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),1==(m=u.bit(p)-c.bit(p))&&(f=n.line(y,i,E,B),I.smul(f,t.ECP.SEXTIC_TWIST)),-1==m&&(i.neg(),f=n.line(y,i,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&I.conj(),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&(t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&y.neg(),a.copy(i),a.frob(s),f=n.line(y,a,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),a.frob(s),a.neg(),f=n.line(y,a,E,B),I.smul(f,t.ECP.SEXTIC_TWIST)),I},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,m,p,d,l,w,_,S;for((u=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),a=new t.BIG(u),E=new t.ECP2,t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?((s=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),c=new t.FP2(s,h),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(c.inverse(),c.norm()),a.pmul(6),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX?a.inc(2):a.dec(2)):a.copy(u),a.norm(),(f=new t.BIG(a)).pmul(3),f.norm(),y=new t.FP(e.getx()),I=new t.FP(e.gety()),m=new t.FP(r.getx()),p=new t.FP(r.gety()),d=new t.ECP2,l=new t.ECP2,w=new t.FP12(1),d.copy(i),l.copy(o),S=f.nbits()-2;S>=1;S--)w.sqr(),B=n.line(d,d,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),B=n.line(l,l,m,p),w.smul(B,t.ECP.SEXTIC_TWIST),1==(_=f.bit(S)-a.bit(S))&&(B=n.line(d,i,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),B=n.line(l,o,m,p),w.smul(B,t.ECP.SEXTIC_TWIST)),-1==_&&(i.neg(),B=n.line(d,i,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),B=n.line(l,o,m,p),w.smul(B,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&w.conj(),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&(t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(d.neg(),l.neg()),E.copy(i),E.frob(c),B=n.line(d,E,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),E.frob(c),E.neg(),B=n.line(d,E,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),E.copy(o),E.frob(c),B=n.line(l,E,m,p),w.smul(B,t.ECP.SEXTIC_TWIST),E.frob(c),E.neg(),B=n.line(l,E,m,p),w.smul(B,t.ECP.SEXTIC_TWIST)),w},fexp:function(n){var i,e,o,r,s,h,c,u,a,f,E,B,y,I,m,p;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP12(n),(h=new t.FP12(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o),s.frob(o),s.mul(h),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?(h.copy(s),h.frob(o),(c=new t.FP12(h)).frob(o),h.mul(s),c.mul(h),c.frob(o),(u=new t.FP12(s)).conj(),E=s.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&E.conj(),(f=new t.FP12(E)).frob(o),a=E.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&a.conj(),(B=new t.FP12(a)).conj(),h=a.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&h.conj(),a.frob(o),s.copy(a),s.conj(),E.mul(s),a.frob(o),s.copy(h),s.frob(o),h.mul(s),h.usqr(),h.mul(E),h.mul(B),s.copy(f),s.mul(B),s.mul(h),h.mul(a),s.usqr(),s.mul(h),s.usqr(),h.copy(s),h.mul(u),s.mul(c),h.usqr(),s.mul(h),s.reduce()):((y=new t.FP12(s)).usqr(),I=y.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&I.conj(),r.fshr(1),m=I.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),r.fshl(1),(p=new t.FP12(s)).conj(),I.mul(p),I.conj(),I.mul(m),m=I.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),p=m.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&p.conj(),I.conj(),p.mul(I),I.conj(),I.frob(o),I.frob(o),I.frob(o),m.frob(o),m.frob(o),I.mul(m),m=p.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),m.mul(y),m.mul(s),I.mul(m),m.copy(p),m.frob(o),I.mul(m),s.copy(I),s.reduce()),s},glv:function(n){var i,e,o,r,s,h,c,u,a=[];if(t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN){for(i=new t.BIG(0),o=[],(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),c=0;c<2;c++)i.rcopy(t.ROM_CURVE.CURVE_W[c]),r=t.BIG.mul(i,n),o[c]=new t.BIG(r.div(e)),a[c]=new t.BIG(0);for(a[0].copy(n),c=0;c<2;c++)for(u=0;u<2;u++)i.rcopy(t.ROM_CURVE.CURVE_SB[u][c]),i.copy(t.BIG.modmul(o[u],i,e)),a[c].add(e),a[c].sub(i),a[c].mod(e)}else(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=t.BIG.smul(s,s),a[0]=new t.BIG(n),a[0].mod(h),a[1]=new t.BIG(n),a[1].div(h),a[1].rsub(e);return a},gs:function(n){var i,e,o,r,s,h,c,u,a=[];if(t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN){for(o=new t.BIG(0),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),s=[],i=0;i<4;i++)o.rcopy(t.ROM_CURVE.CURVE_WB[i]),h=t.BIG.mul(o,n),s[i]=new t.BIG(h.div(r)),a[i]=new t.BIG(0);for(a[0].copy(n),i=0;i<4;i++)for(e=0;e<4;e++)o.rcopy(t.ROM_CURVE.CURVE_BB[e][i]),o.copy(t.BIG.modmul(s[e],o,r)),a[i].add(r),a[i].sub(o),a[i].mod(r)}else{for((c=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),u=new t.BIG(n),i=0;i<3;i++)a[i]=new t.BIG(u),a[i].mod(c),u.div(c);a[3]=new t.BIG(u),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(a[1].copy(t.BIG.modneg(a[1],r)),a[3].copy(t.BIG.modneg(a[3],r)))}return a},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,m=0,p=[];if(0==n?y=c:(y=u,c=null),0!=(m=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return m;if(p=y.slice(),void 0!==B||null!=B)for(I=0;I>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP8(this.a),i=new t.FP8(this.c),e=new t.FP8(this.b),o=new t.FP8(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP8(this.a),i=new t.FP8(this.b),e=new t.FP8(this.c),o=new t.FP8(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP8(this.a),e=new t.FP8(0),o=new t.FP8(this.b),r=new t.FP8(0),s=new t.FP8(this.a),h=new t.FP8(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP8(this.a),r=new t.FP8(this.b),s=new t.FP8(this.b),h=new t.FP8(0),c=new t.FP8(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP8(this.a),o=new t.FP8(0),r=new t.FP8(0),s=new t.FP8(0),h=new t.FP8(this.a),c=new t.FP8(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP8(this.a),i=new t.FP8(this.b),e=new t.FP8(this.a),o=new t.FP8(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n,i){var e,o=new t.FP2(n),r=new t.FP2(n);for(o.sqr(),r.mul(o),r.mul_ip(),r.norm(),e=0;e=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s,1),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),m=E.trace(),B=B.xtr_pow2(y,I,m,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B=[];for(e=0;e>31&1},n.pow8=function(i,e){var o,r,s,h,c,u,a,f,E=[],B=[],y=new n(0),I=new n(0),m=[],p=new t.BIG(0),d=new t.BIG(0),l=new t.BIG(0),w=[],_=[],S=[],P=[];for(o=0;o<8;o++)m[o]=new t.BIG(e[o]),m[o].norm();for(E[0]=new n(i[0]),E[1]=new n(E[0]),E[1].mul(i[1]),E[2]=new n(E[0]),E[2].mul(i[2]),E[3]=new n(E[1]),E[3].mul(i[2]),E[4]=new n(i[0]),E[4].mul(i[3]),E[5]=new n(E[1]),E[5].mul(i[3]),E[6]=new n(E[2]),E[6].mul(i[3]),E[7]=new n(E[3]),E[7].mul(i[3]),d.rcopy(t.ROM_FIELD.Fra),l.rcopy(t.ROM_FIELD.Frb),f=new t.FP2(d,l),o=0;o<8;o++)B[o]=new n(E[o]),B[o].frob(f,4);for(u=1-m[0].parity(),m[0].inc(u),m[0].norm(),a=1-m[4].parity(),m[4].inc(a),m[4].norm(),p.zero(),o=0;o<8;o++)p.or(m[o]);for(_[(h=1+p.nbits())-1]=1,P[h-1]=1,o=0;o>1),m[r].norm(),w[o]+=c*s,s*=2;for(S[o]=0,s=1,r=5;r<8;r++)c=P[o]*m[r].parity(),m[r].fshr(1),m[r].dec(c>>1),m[r].norm(),S[o]+=c*s,s*=2}for(I.select(E,2*w[h-1]+1),y.select(B,2*S[h-1]+1),I.mul(y),o=h-2;o>=0;o--)I.usqr(),y.select(E,2*w[o]+_[o]),I.mul(y),y.select(B,2*S[o]+P[o]),I.mul(y);return y.copy(i[0]),y.conj(),y.mul(I),I.cmove(y,u),y.copy(i[4]),y.conj(),y.mul(I),I.cmove(y,a),I.reduce(),I},n}(h),h.ECP4=function(t){var n=function(){this.x=new t.FP4(0),this.y=new t.FP4(1),this.z=new t.FP4(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(n){var i,e;return i=new t.FP4(this.x),e=new t.FP4(n.x),i.mul(n.z),e.mul(this.z),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),e.copy(n.y),e.mul(this.z),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP4(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.geta().getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o,r,s,h,c=new n,u=new t.BIG(0),a=new t.BIG(0);return u.rcopy(t.ROM_CURVE.CURVE_Pxaa),a.rcopy(t.ROM_CURVE.CURVE_Pxab),i=new t.FP2(u,a),u.rcopy(t.ROM_CURVE.CURVE_Pxba),a.rcopy(t.ROM_CURVE.CURVE_Pxbb),e=new t.FP2(u,a),o=new t.FP4(i,e),u.rcopy(t.ROM_CURVE.CURVE_Pyaa),a.rcopy(t.ROM_CURVE.CURVE_Pyab),r=new t.FP2(u,a),u.rcopy(t.ROM_CURVE.CURVE_Pyba),a.rcopy(t.ROM_CURVE.CURVE_Pybb),s=new t.FP2(u,a),h=new t.FP4(r,s),c.setxy(o,h),c},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f=[];for(h=0;h>1),m[r].norm(),p[o]+=c*s,s*=2;for(l[o]=0,s=1,r=5;r<8;r++)c=w[o]*m[r].parity(),m[r].fshr(1),m[r].dec(c>>1),m[r].norm(),l[o]+=c*s,s*=2}for(E.select(B,2*p[h-1]+1),f.select(y,2*l[h-1]+1),E.add(f),o=h-2;o>=0;o--)E.dbl(),f.select(B,2*p[o]+d[o]),E.add(f),f.select(y,2*l[o]+w[o]),E.add(f);return f.copy(E),f.sub(i[0]),E.cmove(f,u),f.copy(E),f.sub(i[4]),E.cmove(f,a),E.affine(),E},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E,B=n.frob_constants();for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);c=new t.FP2(r,o),h=new t.FP4(c),(s=new n).setx(h),s.is_infinity();)o.inc(1),o.norm();return(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),E=(f=(a=(u=s.mul(o)).mul(o)).mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(u.neg(),f.neg()),E.sub(f),E.sub(s),f.sub(a),f.frob(B,1),a.sub(u),a.frob(B,2),u.sub(s),u.frob(B,3),s.dbl(),s.frob(B,4),s.add(E),s.add(f),s.add(a),s.add(u),s.affine(),s},n.frob_constants=function(){var n,i,e,o,r=new t.BIG(0),s=new t.BIG(0),h=[];return r.rcopy(t.ROM_FIELD.Fra),s.rcopy(t.ROM_FIELD.Frb),n=new t.FP2(r,s),(i=new t.FP2(n)).sqr(),(o=new t.FP2(i)).mul_ip(),o.norm(),(e=new t.FP2(o)).sqr(),o.mul(e),e.copy(n),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(e.mul_ip(),e.inverse(),i.copy(e),i.sqr()),i.mul_ip(),i.norm(),e.mul(i),h[0]=new t.FP2(i),h[1]=new t.FP2(e),h[2]=new t.FP2(o),h},n}(h),h.PAIR192=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,m,p=new t.FP24(1);return n==i?(r=new t.FP4(n.getx()),s=new t.FP4(n.gety()),h=new t.FP4(n.getz()),(c=new t.FP4(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.qmul(o),r.imul(6),r.qmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_2i(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.times_i(),h.add(h),c.times_i(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP8(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP8(r),m=new t.FP8(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP8(0),(m=new t.FP8(r)).times_i()),n.dbl()):(a=new t.FP4(n.getx()),f=new t.FP4(n.gety()),E=new t.FP4(n.getz()),B=new t.FP4(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.qmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.times_i(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.qmul(e),f.neg(),f.norm(),y=new t.FP8(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP8(f),m=new t.FP8(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP8(0),(m=new t.FP8(f)).times_i()),n.add(i)),p.set(y,I,m),p},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B;for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),r=new t.BIG(o),(s=new t.BIG(r)).pmul(3),s.norm(),c=new t.FP(e.getx()),u=new t.FP(e.gety()),a=new t.ECP4,f=new t.FP24(1),a.copy(i),B=s.nbits()-2;B>=1;B--)f.sqr(),h=n.line(a,a,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),1==(E=s.bit(B)-r.bit(B))&&(h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST)),-1==E&&(i.neg(),h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&f.conj(),f},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,m,p,d;for((s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=new t.BIG(s),(c=new t.BIG(h)).pmul(3),c.norm(),a=new t.FP(e.getx()),f=new t.FP(e.gety()),E=new t.FP(r.getx()),B=new t.FP(r.gety()),y=new t.ECP4,I=new t.ECP4,m=new t.FP24(1),y.copy(i),I.copy(o),d=c.nbits()-2;d>=1;d--)m.sqr(),u=n.line(y,y,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,I,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),1==(p=c.bit(d)-h.bit(d))&&(u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST)),-1==p&&(i.neg(),u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),m},fexp:function(n){var i,e,o,r,s,h,c,u,a,f,E,B,y,I;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP24(n),(h=new t.FP24(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o,4),s.mul(h),(I=new t.FP24(s)).usqr(),u=I.pow(r),r.fshr(1),a=u.pow(r),r.fshl(1),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&u.conj(),(f=new t.FP24(u)).conj(),a.mul(f),a.mul(s),B=(E=(f=a.pow(r)).pow(r)).pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(f.conj(),B.conj()),f.frob(o,6),E.frob(o,5),f.mul(E),y=B.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&y.conj(),B.frob(o,4),f.mul(B),(c=new t.FP24(a)).conj(),y.mul(c),B.copy(y),B.frob(o,3),f.mul(B),B=y.pow(r),y=B.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&B.conj(),c.copy(B),c.frob(o,2),f.mul(c),c.copy(y),c.frob(o,1),f.mul(c),B=y.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&B.conj(),a.frob(o,7),B.mul(I),f.mul(a),f.mul(B),s.mul(f),s.reduce(),s},glv:function(n){var i,e,o,r=[];return(i=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),o=t.BIG.smul(e,e),e=t.BIG.smul(o,o),r[0]=new t.BIG(n),r[0].mod(e),r[1]=new t.BIG(n),r[1].div(e),r[1].rsub(i),r},gs:function(n){var i,e,o,r,s=[];for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),r=new t.BIG(n),i=0;i<7;i++)s[i]=new t.BIG(r),s[i].mod(o),r.div(o);return s[7]=new t.BIG(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(s[1].copy(t.BIG.modneg(s[1],e)),s[3].copy(t.BIG.modneg(s[3],e)),s[5].copy(t.BIG.modneg(s[5],e)),s[7].copy(t.BIG.modneg(s[7],e))),s},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,m=0,p=[];if(0==n?y=c:(y=u,c=null),0!=(m=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return m;if(p=y.slice(),void 0!==B||null!=B)for(I=0;I=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),m=new n(0),p=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),p++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(m)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(m)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(m)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(m)):(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP16(this.a),i=new t.FP16(this.c),e=new t.FP16(this.b),o=new t.FP16(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP16(this.a),i=new t.FP16(this.b),e=new t.FP16(this.c),o=new t.FP16(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP16(this.a),e=new t.FP16(0),o=new t.FP16(this.b),r=new t.FP16(0),s=new t.FP16(this.a),h=new t.FP16(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP16(this.a),r=new t.FP16(this.b),s=new t.FP16(this.b),h=new t.FP16(0),c=new t.FP16(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP16(this.a),o=new t.FP16(0),r=new t.FP16(0),s=new t.FP16(0),h=new t.FP16(this.a),c=new t.FP16(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP16(this.a),i=new t.FP16(this.b),e=new t.FP16(this.a),o=new t.FP16(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n,i){var e,o=new t.FP2(n),r=new t.FP2(n);for(o.sqr(),r.mul(o),r.mul_ip(),r.norm(),r.mul_ip(),r.norm(),e=0;e=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s,1),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),m=E.trace(),B=B.xtr_pow2(y,I,m,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I=[];for(e=0;e>31&1},n.pow16=function(i,e){var o,r,s,h,c,u,a,f,E,B,y=[],I=[],m=[],p=[],d=new n(0),l=new n(0),w=[],_=new t.BIG(0),S=new t.BIG(0),P=new t.BIG(0),T=[],C=[],b=[],G=[],R=[],g=[],M=[],O=[];for(o=0;o<16;o++)w[o]=new t.BIG(e[o]),w[o].norm();for(y[0]=new n(i[0]),y[1]=new n(y[0]),y[1].mul(i[1]),y[2]=new n(y[0]),y[2].mul(i[2]),y[3]=new n(y[1]),y[3].mul(i[2]),y[4]=new n(i[0]),y[4].mul(i[3]),y[5]=new n(y[1]),y[5].mul(i[3]),y[6]=new n(y[2]),y[6].mul(i[3]),y[7]=new n(y[3]),y[7].mul(i[3]),S.rcopy(t.ROM_FIELD.Fra),P.rcopy(t.ROM_FIELD.Frb),B=new t.FP2(S,P),o=0;o<8;o++)I[o]=new n(y[o]),I[o].frob(B,4),m[o]=new n(I[o]),m[o].frob(B,4),p[o]=new n(m[o]),p[o].frob(B,4);for(u=1-w[0].parity(),w[0].inc(u),w[0].norm(),a=1-w[4].parity(),w[4].inc(a),w[4].norm(),f=1-w[8].parity(),w[8].inc(f),w[8].norm(),E=1-w[12].parity(),w[12].inc(E),w[12].norm(),_.zero(),o=0;o<16;o++)_.or(w[o]);for(C[(h=1+_.nbits())-1]=1,G[h-1]=1,g[h-1]=1,O[h-1]=1,o=0;o>1),w[r].norm(),T[o]+=c*s,s*=2;for(b[o]=0,s=1,r=5;r<8;r++)c=G[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),b[o]+=c*s,s*=2;for(R[o]=0,s=1,r=9;r<12;r++)c=g[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),R[o]+=c*s,s*=2;for(M[o]=0,s=1,r=13;r<16;r++)c=O[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),M[o]+=c*s,s*=2}for(l.select(y,2*T[h-1]+1),d.select(I,2*b[h-1]+1),l.mul(d),d.select(m,2*R[h-1]+1),l.mul(d),d.select(p,2*M[h-1]+1),l.mul(d),o=h-2;o>=0;o--)l.usqr(),d.select(y,2*T[o]+C[o]),l.mul(d),d.select(I,2*b[o]+G[o]),l.mul(d),d.select(m,2*R[o]+g[o]),l.mul(d),d.select(p,2*M[o]+O[o]),l.mul(d);return d.copy(i[0]),d.conj(),d.mul(l),l.cmove(d,u),d.copy(i[4]),d.conj(),d.mul(l),l.cmove(d,a),d.copy(i[8]),d.conj(),d.mul(l),l.cmove(d,f),d.copy(i[12]),d.conj(),d.mul(l),l.cmove(d,E),l.reduce(),l},n}(h),h.ECP8=function(t){var n=function(){this.x=new t.FP8(0),this.y=new t.FP8(1),this.z=new t.FP8(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(n){var i,e;return i=new t.FP8(this.x),e=new t.FP8(n.x),i.mul(n.z),e.mul(this.z),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),e.copy(n.y),e.mul(this.z),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP8(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.geta().geta().getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o,r,s,h,c,u,a,f,E,B,y,I,m=new n,p=new t.BIG(0),d=new t.BIG(0);return p.rcopy(t.ROM_CURVE.CURVE_Pxaaa),d.rcopy(t.ROM_CURVE.CURVE_Pxaab),i=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pxaba),d.rcopy(t.ROM_CURVE.CURVE_Pxabb),e=new t.FP2(p,d),o=new t.FP4(i,e),p.rcopy(t.ROM_CURVE.CURVE_Pxbaa),d.rcopy(t.ROM_CURVE.CURVE_Pxbab),r=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pxbba),d.rcopy(t.ROM_CURVE.CURVE_Pxbbb),s=new t.FP2(p,d),h=new t.FP4(r,s),c=new t.FP8(o,h),p.rcopy(t.ROM_CURVE.CURVE_Pyaaa),d.rcopy(t.ROM_CURVE.CURVE_Pyaab),u=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pyaba),d.rcopy(t.ROM_CURVE.CURVE_Pyabb),a=new t.FP2(p,d),f=new t.FP4(u,a),p.rcopy(t.ROM_CURVE.CURVE_Pybaa),d.rcopy(t.ROM_CURVE.CURVE_Pybab),E=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pybba),d.rcopy(t.ROM_CURVE.CURVE_Pybbb),B=new t.FP2(p,d),y=new t.FP4(E,B),I=new t.FP8(f,y),m.setxy(c,I),m},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B=[];for(u=0;u>1),w[r].norm(),_[o]+=c*s,s*=2;for(P[o]=0,s=1,r=5;r<8;r++)c=T[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),P[o]+=c*s,s*=2;for(C[o]=0,s=1,r=9;r<12;r++)c=b[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),C[o]+=c*s,s*=2;for(G[o]=0,s=1,r=13;r<16;r++)c=R[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),G[o]+=c*s,s*=2}for(y.select(I,2*_[h-1]+1),B.select(m,2*P[h-1]+1),y.add(B),B.select(p,2*C[h-1]+1),y.add(B),B.select(d,2*G[h-1]+1),y.add(B),o=h-2;o>=0;o--)y.dbl(),B.select(I,2*_[o]+S[o]),y.add(B),B.select(m,2*P[o]+T[o]),y.add(B),B.select(p,2*C[o]+b[o]),y.add(B),B.select(d,2*G[o]+R[o]),y.add(B);return B.copy(y),B.sub(i[0]),y.cmove(B,u),B.copy(y),B.sub(i[4]),y.cmove(B,a),B.copy(y),B.sub(i[8]),y.cmove(B,f),B.copy(y),B.sub(i[12]),y.cmove(B,E),y.affine(),y},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,m,p,d=n.frob_constants();for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);c=new t.FP2(r,o),u=new t.FP4(c),h=new t.FP8(u),(s=new n).setx(h),s.is_infinity();)o.inc(1),o.norm();return(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),p=(m=(I=(y=(B=(E=(f=(a=s.mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(a.neg(),E.neg(),y.neg(),m.neg()),p.sub(m),p.sub(s),m.sub(I),m.frob(d,1),I.sub(y),I.frob(d,2),y.sub(B),y.frob(d,3),B.sub(E),B.frob(d,4),E.sub(f),E.frob(d,5),f.sub(a),f.frob(d,6),a.sub(s),a.frob(d,7),s.dbl(),s.frob(d,8),s.add(p),s.add(m),s.add(I),s.add(y),s.add(B),s.add(E),s.add(f),s.add(a),s.affine(),s},n.frob_constants=function(){var n,i,e,o,r=new t.BIG(0),s=new t.BIG(0),h=[];return r.rcopy(t.ROM_FIELD.Fra),s.rcopy(t.ROM_FIELD.Frb),n=new t.FP2(r,s),(i=new t.FP2(n)).sqr(),(o=new t.FP2(i)).mul_ip(),o.norm(),(e=new t.FP2(o)).sqr(),o.mul(e),o.mul_ip(),o.norm(),e.copy(n),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(e.mul_ip(),e.inverse(),i.copy(e),i.sqr()),i.mul_ip(),i.norm(),e.mul(i),h[0]=new t.FP2(i),h[1]=new t.FP2(e),h[2]=new t.FP2(o),h},n}(h),h.PAIR256=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,m,p=new t.FP48(1);return n==i?(r=new t.FP8(n.getx()),s=new t.FP8(n.gety()),h=new t.FP8(n.getz()),(c=new t.FP8(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.tmul(o),r.imul(6),r.tmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_2i(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.times_i(),h.add(h),c.times_i(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP16(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP16(r),m=new t.FP16(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP16(0),(m=new t.FP16(r)).times_i()),n.dbl()):(a=new t.FP8(n.getx()),f=new t.FP8(n.gety()),E=new t.FP8(n.getz()),B=new t.FP8(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.tmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.times_i(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.tmul(e),f.neg(),f.norm(),y=new t.FP16(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP16(f),m=new t.FP16(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP16(0),(m=new t.FP16(f)).times_i()),n.add(i)),p.set(y,I,m),p},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B;for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),r=new t.BIG(o),(s=new t.BIG(r)).pmul(3),s.norm(),c=new t.FP(e.getx()),u=new t.FP(e.gety()),a=new t.ECP8,f=new t.FP48(1),a.copy(i),B=s.nbits()-2;B>=1;B--)f.sqr(),h=n.line(a,a,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),1==(E=s.bit(B)-r.bit(B))&&(h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST)),-1==E&&(i.neg(),h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&f.conj(),f},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,m,p,d;for((s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=new t.BIG(s),(c=new t.BIG(h)).pmul(3),c.norm(),a=new t.FP(e.getx()),f=new t.FP(e.gety()),E=new t.FP(r.getx()),B=new t.FP(r.gety()),y=new t.ECP8,I=new t.ECP8,m=new t.FP48(1),y.copy(i),I.copy(o),d=c.nbits()-2;d>=1;d--)m.sqr(),u=n.line(y,y,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,I,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),1==(p=c.bit(d)-h.bit(d))&&(u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST)),-1==p&&(i.neg(),u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),m},fexp:function(n){var i,e,o,r,s,h,c,u,a,f;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP48(n),(h=new t.FP48(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o,8),s.mul(h),(f=new t.FP48(s)).usqr(),c=f.pow(r),r.fshr(1),u=c.pow(r),r.fshl(1),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),(a=new t.FP48(c)).conj(),u.mul(a),u.mul(s),s.mul(f),c=u.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,14),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,13),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,12),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,11),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,10),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,9),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,8),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(u),a.conj(),c.mul(a),a.copy(c),a.frob(o,7),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,6),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,5),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,4),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,3),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,2),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,1),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),s.mul(c),u.frob(o,15),s.mul(u),s.reduce(),s},glv:function(n){var i,e,o,r=[];return(i=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),o=t.BIG.smul(e,e),e=t.BIG.smul(o,o),o=t.BIG.smul(e,e),r[0]=new t.BIG(n),r[0].mod(o),r[1]=new t.BIG(n),r[1].div(o),r[1].rsub(i),r},gs:function(n){var i,e,o,r,s=[];for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),r=new t.BIG(n),i=0;i<15;i++)s[i]=new t.BIG(r),s[i].mod(o),r.div(o);return s[15]=new t.BIG(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(s[1].copy(t.BIG.modneg(s[1],e)),s[3].copy(t.BIG.modneg(s[3],e)),s[5].copy(t.BIG.modneg(s[5],e)),s[7].copy(t.BIG.modneg(s[7],e)),s[9].copy(t.BIG.modneg(s[9],e)),s[11].copy(t.BIG.modneg(s[11],e)),s[13].copy(t.BIG.modneg(s[13],e)),s[15].copy(t.BIG.modneg(s[15],e))),s},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,m=0,p=[];if(0==n?y=c:(y=u,c=null),0!=(m=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return m;if(p=y.slice(),void 0!==B||null!=B)for(I=0;I6||t.defaultPinLength<4)&&(t.defaultPinLength=4),t.requestTimeout&&!isNaN(t.requestTimeout)||(t.requestTimeout=4e3),t.oidc||(t.oidc={}),t.clientName="MIRACL Client.js/8.8.0"+(t.applicationInfo?" "+t.applicationInfo:""),n.options=t,n.http=new u(t.requestTimeout,t.clientName,t.projectId,t.cors),n.crypto=new h(t.seed),n.users=new c(t.userStorage,t.projectId,"mfa")}return h.prototype._crypto=function(t){return t||(t="BN254CX"),s[t]||(s[t]=new r(t),s[t].MPIN.MAXPIN=1e6,s[t].MPIN.PBLEN=20,s[t].MPIN.TRAP=2e3),s[t]},h.prototype.generateKeypair=function(t){var n,i=this,e=[],o=[];if(0!=(n=i._crypto(t).MPIN.GET_DVS_KEYPAIR(i.rng,e,o)))throw new Error("Could not generate key pair: "+n);return{publicKey:i._bytesToHex(o),privateKey:i._bytesToHex(e)}},h.prototype.addShares=function(t,n,i,e){var o,r,s,h,c=this,u=[];if(o=c._hexToBytes(t),r=c._hexToBytes(n),s=c._hexToBytes(i),0!==(h=c._crypto(e).MPIN.RECOMBINE_G1(r,s,u)))throw new Error("Could not combine the client secret shares: "+h);if(0!=(h=c._crypto(e).MPIN.GET_G1_MULTIPLE(null,0,o,u,u)))throw new Error("Could not combine private key with client secret: "+h);return c._bytesToHex(u)},h.prototype.extractPin=function(t,n,i,e,o){var r,s,h,c=this;if(r=c._hexToBytes(e),s=c._hexToBytes(c._mpinIdWithPublicKey(t,n)),0!==(h=c._crypto(o).MPIN.EXTRACT_PIN(c._crypto(o).MPIN.SHA256,s,i,r)))throw new Error("Could not extract PIN from client secret: "+h);return c._bytesToHex(r)},h.prototype.calculatePass1=function(t,n,i,e,o,r,s){var h,c,u=this,a=[],f=[];if(h=u._mpinIdWithPublicKey(n,i),0!==(c=u._crypto(t).MPIN.CLIENT_1(u._crypto(t).MPIN.SHA256,0,u._hexToBytes(h),u.rng,r,o,u._hexToBytes(e),s,a,f,u._hexToBytes(0))))throw new Error("Could not calculate pass 1 request data: "+c);return{UT:u._bytesToHex(f),U:u._bytesToHex(a)}},h.prototype.calculatePass2=function(t,n,i,e){var o,r=this;if(0!==(o=r._crypto(t).MPIN.CLIENT_2(n,r._hexToBytes(i),e)))throw new Error("Could not calculate pass 2 request data: "+o);return r._bytesToHex(e)},h.prototype.sign=function(t,n,i,e,o,r,s){var h,c,u=this,a=[],f=[];if(h=u._mpinIdWithPublicKey(n,i),0!=(c=u._crypto(t).MPIN.CLIENT(u._crypto(t).MPIN.SHA256,0,u._hexToBytes(h),u.rng,[],o,u._hexToBytes(e),a,f,null,null,s,[],u._hexToBytes(r))))throw new Error("Could not sign message: "+c);return{U:u._bytesToHex(f),V:u._bytesToHex(a)}},h.prototype._mpinIdWithPublicKey=function(t,n){var i,e=this,o=e._hexToBytes(t),r=e._hexToBytes(n);if(o){if(!r)return t;for(i=0;i>>4&15).toString(16),e+=(15&n).toString(16);return e},c.prototype.data=[],c.prototype.states={start:"STARTED",register:"REGISTERED",revoked:"REVOKED"},c.prototype.loadData=function(){var t=this;t.data=JSON.parse(t.storage.getItem(t.storageKey))||[],t.store(),t.data.sort((function(t,n){return t.lastUsed&&(!n.lastUsed||t.lastUsed>n.lastUsed)?1:n.lastUsed&&(!t.lastUsed||t.lastUsedt.FP.FEXCESS&&(this.a.XES>1&&this.a.reduce(),this.b.XES>1&&this.b.reduce()),i=t.BIG.mul(this.a.f,n.a.f),e=t.BIG.mul(this.b.f,n.b.f),o=new t.BIG(this.a.f),r=new t.BIG(n.a.f),o.add(this.b.f),o.norm(),r.add(n.b.f),r.norm(),s=t.BIG.mul(o,r),(h=new t.DBIG(0)).copy(i),h.add(e),e.rsub(u),i.add(e),i.norm(),s.sub(h),s.norm(),this.a.f.copy(t.FP.mod(i)),this.a.XES=3,this.b.f.copy(t.FP.mod(s)),this.b.XES=2},sqrt:function(){var n,i;return!!this.iszilch()||(n=new t.FP(this.b),i=new t.FP(this.a),n.sqr(),i.sqr(),n.add(i),1!=n.jacobi()?(this.zero(),!1):(n=n.sqrt(),i.copy(this.a),i.add(n),i.norm(),i.div2(),1!=i.jacobi()&&(i.copy(this.a),i.sub(n),i.norm(),i.div2(),1!=i.jacobi())?(this.zero(),!1):(i=i.sqrt(),this.a.copy(i),i.add(i),i.inverse(),this.b.mul(i),!0)))},toString:function(){return"["+this.a.toString()+","+this.b.toString()+"]"},inverse:function(){var n,i;this.norm(),n=new t.FP(this.a),i=new t.FP(this.b),n.sqr(),i.sqr(),n.add(i),n.inverse(),this.a.mul(n),n.neg(),n.norm(),this.b.mul(n)},div2:function(){this.a.div2(),this.b.div2()},times_i:function(){var n=new t.FP(this.a);this.a.copy(this.b),this.a.neg(),this.b.copy(n)},mul_ip:function(){var i=new n(this),e=new t.FP(this.a);this.a.copy(this.b),this.a.neg(),this.b.copy(e),this.add(i)},div_ip2:function(){var t=new n(0);this.norm(),t.a.copy(this.a),t.a.add(this.b),t.b.copy(this.b),t.b.sub(this.a),this.copy(t),this.norm()},div_ip:function(){var t=new n(0);this.norm(),t.a.copy(this.a),t.a.add(this.b),t.b.copy(this.b),t.b.sub(this.a),this.copy(t),this.norm(),this.div2()},pow:function(t){this.norm();var i,e=new n(1),o=new n(this);for(t.norm();i=t.parity(),t.fshr(1),1==i&&e.mul(o),!t.iszilch();)o.sqr();return e.reduce(),e}},n}function n(t){var n=function(i,e){i instanceof n?(this.a=new t.FP2(i.a),this.b=new t.FP2(i.b)):(this.a=new t.FP2(i),this.b=new t.FP2(e))};return n.prototype={reduce:function(){this.a.reduce(),this.b.reduce()},norm:function(){this.a.norm(),this.b.norm()},iszilch:function(){return this.reduce(),this.a.iszilch()&&this.b.iszilch()},isunity:function(){var n=new t.FP2(1);return this.a.equals(n)&&this.b.iszilch()},cmove:function(t,n){this.a.cmove(t.a,n),this.b.cmove(t.b,n)},isreal:function(){return this.b.iszilch()},real:function(){return this.a},geta:function(){return this.a},getb:function(){return this.b},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b)},zero:function(){this.a.zero(),this.b.zero()},one:function(){this.a.one(),this.b.zero()},set:function(t,n){this.a.copy(t),this.b.copy(n)},seta:function(t){this.a.copy(t),this.b.zero()},neg:function(){this.norm();var n=new t.FP2(this.a),i=new t.FP2(0);n.add(this.b),n.neg(),i.copy(n),i.add(this.b),this.b.copy(n),this.b.add(this.a),this.a.copy(i),this.norm()},conj:function(){this.b.neg(),this.norm()},nconj:function(){this.a.neg(),this.norm()},add:function(t){this.a.add(t.a),this.b.add(t.b)},sub:function(t){var i=new n(t);i.neg(),this.add(i)},rsub:function(t){this.neg(),this.add(t)},pmul:function(t){this.a.mul(t),this.b.mul(t)},imul:function(t){this.a.imul(t),this.b.imul(t)},sqr:function(){var n=new t.FP2(this.a),i=new t.FP2(this.b),e=new t.FP2(this.a);e.mul(this.b),n.add(this.b),n.norm(),i.mul_ip(),i.add(this.a),i.norm(),this.a.copy(n),this.a.mul(i),i.copy(e),i.mul_ip(),i.add(e),i.norm(),i.neg(),this.a.add(i),this.b.copy(e),this.b.add(e),this.norm()},mul:function(n){var i=new t.FP2(this.a),e=new t.FP2(this.b),o=new t.FP2(0),r=new t.FP2(this.b);i.mul(n.a),e.mul(n.b),o.copy(n.b),o.add(n.a),r.add(this.a),o.norm(),r.norm(),r.mul(o),o.copy(i),o.neg(),r.add(o),o.copy(e),o.neg(),this.b.copy(r),this.b.add(o),e.mul_ip(),this.a.copy(e),this.a.add(i),this.norm()},toString:function(){return"["+this.a.toString()+","+this.b.toString()+"]"},inverse:function(){this.norm();var n=new t.FP2(this.a),i=new t.FP2(this.b);n.sqr(),i.sqr(),i.mul_ip(),i.norm(),n.sub(i),n.inverse(),this.a.mul(n),n.neg(),n.norm(),this.b.mul(n)},times_i:function(){var n=new t.FP2(this.b),i=new t.FP2(this.b);n.times_i(),i.add(n),this.b.copy(this.a),this.a.copy(i),this.norm()},frob:function(t){this.a.conj(),this.b.conj(),this.b.mul(t)},pow:function(i){this.norm(),i.norm();for(var e,o=new n(this),r=new t.BIG(i),s=new n(1);e=r.parity(),r.fshr(1),1===e&&s.mul(o),!r.iszilch();)o.sqr();return s.reduce(),s},xtr_A:function(t,i,e){var o=new n(t),r=new n(t);o.sub(i),o.norm(),o.pmul(this.a),r.add(i),r.norm(),r.pmul(this.b),r.times_i(),this.copy(o),this.add(r),this.add(e),this.reduce()},xtr_D:function(){var t=new n(this);this.sqr(),t.conj(),t.add(t),this.sub(t),this.reduce()},xtr_pow:function(i){var e,o,r,s=new n(3),h=new n(this),c=new n(h),u=new n(0),a=new n(0);for(c.xtr_D(),i.norm(),e=i.parity(),(o=new t.BIG(i)).fshr(1),0===e&&(o.dec(1),o.norm()),r=o.nbits()-1;r>=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),m=new n(0),p=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),p++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(m)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(m)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(m)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(m)):(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),m=new n(0),p=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),p++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(m)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(m)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(m)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(m)):(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h>>8&255])^t.ROTL16(t.ftable[h[2]>>>16&255])^t.ROTL24(t.ftable[h[3]>>>24&255]),c[1]=this.fkey[r+1]^t.ftable[255&h[1]]^t.ROTL8(t.ftable[h[2]>>>8&255])^t.ROTL16(t.ftable[h[3]>>>16&255])^t.ROTL24(t.ftable[h[0]>>>24&255]),c[2]=this.fkey[r+2]^t.ftable[255&h[2]]^t.ROTL8(t.ftable[h[3]>>>8&255])^t.ROTL16(t.ftable[h[0]>>>16&255])^t.ROTL24(t.ftable[h[1]>>>24&255]),c[3]=this.fkey[r+3]^t.ftable[255&h[3]]^t.ROTL8(t.ftable[h[0]>>>8&255])^t.ROTL16(t.ftable[h[1]>>>16&255])^t.ROTL24(t.ftable[h[2]>>>24&255]),r+=4,o=0;o<4;o++)i=h[o],h[o]=c[o],c[o]=i;for(c[0]=this.fkey[r]^255&t.fbsub[255&h[0]]^t.ROTL8(255&t.fbsub[h[1]>>>8&255])^t.ROTL16(255&t.fbsub[h[2]>>>16&255])^t.ROTL24(255&t.fbsub[h[3]>>>24&255]),c[1]=this.fkey[r+1]^255&t.fbsub[255&h[1]]^t.ROTL8(255&t.fbsub[h[2]>>>8&255])^t.ROTL16(255&t.fbsub[h[3]>>>16&255])^t.ROTL24(255&t.fbsub[h[0]>>>24&255]),c[2]=this.fkey[r+2]^255&t.fbsub[255&h[2]]^t.ROTL8(255&t.fbsub[h[3]>>>8&255])^t.ROTL16(255&t.fbsub[h[0]>>>16&255])^t.ROTL24(255&t.fbsub[h[1]>>>24&255]),c[3]=this.fkey[r+3]^255&t.fbsub[255&h[3]]^t.ROTL8(255&t.fbsub[h[0]>>>8&255])^t.ROTL16(255&t.fbsub[h[1]>>>16&255])^t.ROTL24(255&t.fbsub[h[2]>>>24&255]),e=o=0;e<4;e++,o+=4)for(s=t.unpack(c[e]),r=0;r<4;r++)n[o+r]=s[r]},ecb_decrypt:function(n){var i,e,o,r,s=[],h=[],c=[];for(e=o=0;e<4;e++,o+=4){for(r=0;r<4;r++)s[r]=n[o+r];h[e]=t.pack(s),h[e]^=this.rkey[e]}for(r=4,e=1;e>>8&255])^t.ROTL16(t.rtable[h[2]>>>16&255])^t.ROTL24(t.rtable[h[1]>>>24&255]),c[1]=this.rkey[r+1]^t.rtable[255&h[1]]^t.ROTL8(t.rtable[h[0]>>>8&255])^t.ROTL16(t.rtable[h[3]>>>16&255])^t.ROTL24(t.rtable[h[2]>>>24&255]),c[2]=this.rkey[r+2]^t.rtable[255&h[2]]^t.ROTL8(t.rtable[h[1]>>>8&255])^t.ROTL16(t.rtable[h[0]>>>16&255])^t.ROTL24(t.rtable[h[3]>>>24&255]),c[3]=this.rkey[r+3]^t.rtable[255&h[3]]^t.ROTL8(t.rtable[h[2]>>>8&255])^t.ROTL16(t.rtable[h[1]>>>16&255])^t.ROTL24(t.rtable[h[0]>>>24&255]),r+=4,o=0;o<4;o++)i=h[o],h[o]=c[o],c[o]=i;for(c[0]=this.rkey[r]^255&t.rbsub[255&h[0]]^t.ROTL8(255&t.rbsub[h[3]>>>8&255])^t.ROTL16(255&t.rbsub[h[2]>>>16&255])^t.ROTL24(255&t.rbsub[h[1]>>>24&255]),c[1]=this.rkey[r+1]^255&t.rbsub[255&h[1]]^t.ROTL8(255&t.rbsub[h[0]>>>8&255])^t.ROTL16(255&t.rbsub[h[3]>>>16&255])^t.ROTL24(255&t.rbsub[h[2]>>>24&255]),c[2]=this.rkey[r+2]^255&t.rbsub[255&h[2]]^t.ROTL8(255&t.rbsub[h[1]>>>8&255])^t.ROTL16(255&t.rbsub[h[0]>>>16&255])^t.ROTL24(255&t.rbsub[h[3]>>>24&255]),c[3]=this.rkey[r+3]^255&t.rbsub[255&h[3]]^t.ROTL8(255&t.rbsub[h[2]>>>8&255])^t.ROTL16(255&t.rbsub[h[1]>>>16&255])^t.ROTL24(255&t.rbsub[h[0]>>>24&255]),e=o=0;e<4;e++,o+=4)for(s=t.unpack(c[e]),r=0;r<4;r++)n[o+r]=s[r]},encrypt:function(n){var i,e,o,r=[];switch(e=0,this.mode){case t.ECB:return this.ecb_encrypt(n),0;case t.CBC:for(o=0;o<16;o++)n[o]^=this.f[o];for(this.ecb_encrypt(n),o=0;o<16;o++)this.f[o]=n[o];return 0;case t.CFB1:case t.CFB2:case t.CFB4:for(i=this.mode-t.CFB1+1,o=0;o>>24},t.ROTL16=function(t){return t<<16|t>>>16},t.ROTL24=function(t){return t<<24|t>>>8},t.pack=function(t){return(255&t[3])<<24|(255&t[2])<<16|(255&t[1])<<8|255&t[0]},t.unpack=function(t){var n=[];return n[0]=255&t,n[1]=t>>>8&255,n[2]=t>>>16&255,n[3]=t>>>24&255,n},t.bmul=function(n,i){var e=255&i,o=255&t.ltab[255&n],r=255&t.ltab[e];return 0!==n&&0!==i?t.ptab[(o+r)%255]:0},t.SubByte=function(n){var i=t.unpack(n);return i[0]=t.fbsub[255&i[0]],i[1]=t.fbsub[255&i[1]],i[2]=t.fbsub[255&i[2]],i[3]=t.fbsub[255&i[3]],t.pack(i)},t.product=function(n,i){var e=t.unpack(n),o=t.unpack(i);return 255&(t.bmul(e[0],o[0])^t.bmul(e[1],o[1])^t.bmul(e[2],o[2])^t.bmul(e[3],o[3]))},t.InvMixCol=function(n){var i,e=[];return i=t.pack(t.InCo),e[3]=t.product(i,n),i=t.ROTL24(i),e[2]=t.product(i,n),i=t.ROTL24(i),e[1]=t.product(i,n),i=t.ROTL24(i),e[0]=t.product(i,n),t.pack(e)},t.InCo=[11,13,9,14],t.rco=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47],t.ptab=[1,3,5,15,17,51,85,255,26,46,114,150,161,248,19,53,95,225,56,72,216,115,149,164,247,2,6,10,30,34,102,170,229,52,92,228,55,89,235,38,106,190,217,112,144,171,230,49,83,245,4,12,20,60,68,204,79,209,104,184,211,110,178,205,76,212,103,169,224,59,77,215,98,166,241,8,24,40,120,136,131,158,185,208,107,189,220,127,129,152,179,206,73,219,118,154,181,196,87,249,16,48,80,240,11,29,39,105,187,214,97,163,254,25,43,125,135,146,173,236,47,113,147,174,233,32,96,160,251,22,58,78,210,109,183,194,93,231,50,86,250,21,63,65,195,94,226,61,71,201,64,192,91,237,44,116,156,191,218,117,159,186,213,100,172,239,42,126,130,157,188,223,122,142,137,128,155,182,193,88,232,35,101,175,234,37,111,177,200,67,197,84,252,31,33,99,165,244,7,9,27,45,119,153,176,203,70,202,69,207,74,222,121,139,134,145,168,227,62,66,198,81,243,14,18,54,90,238,41,123,141,140,143,138,133,148,167,242,13,23,57,75,221,124,132,151,162,253,28,36,108,180,199,82,246,1],t.ltab=[0,255,25,1,50,2,26,198,75,199,27,104,51,238,223,3,100,4,224,14,52,141,129,239,76,113,8,200,248,105,28,193,125,194,29,181,249,185,39,106,77,228,166,114,154,201,9,120,101,47,138,5,33,15,225,36,18,240,130,69,53,147,218,142,150,143,219,189,54,208,206,148,19,92,210,241,64,70,131,56,102,221,253,48,191,6,139,98,179,37,226,152,34,136,145,16,126,110,72,195,163,182,30,66,58,107,40,84,250,133,61,186,43,121,10,21,155,159,94,202,78,212,172,229,243,115,167,87,175,88,168,80,244,234,214,116,79,174,233,213,231,230,173,232,44,215,117,122,235,22,11,245,89,203,95,176,156,169,81,160,127,12,246,111,23,196,73,236,216,67,31,45,164,118,123,183,204,187,62,90,251,96,177,134,59,82,161,108,170,85,41,157,151,178,135,144,97,190,220,252,188,149,207,205,55,63,91,209,83,57,132,60,65,162,109,71,20,42,158,93,86,242,211,171,68,17,146,217,35,32,46,137,180,124,184,38,119,153,227,165,103,74,237,222,197,49,254,24,13,99,140,128,192,247,112,7],t.fbsub=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],t.rbsub=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],t.ftable=[2774754246,2222750968,2574743534,2373680118,234025727,3177933782,2976870366,1422247313,1345335392,50397442,2842126286,2099981142,436141799,1658312629,3870010189,2591454956,1170918031,2642575903,1086966153,2273148410,368769775,3948501426,3376891790,200339707,3970805057,1742001331,4255294047,3937382213,3214711843,4154762323,2524082916,1539358875,3266819957,486407649,2928907069,1780885068,1513502316,1094664062,49805301,1338821763,1546925160,4104496465,887481809,150073849,2473685474,1943591083,1395732834,1058346282,201589768,1388824469,1696801606,1589887901,672667696,2711000631,251987210,3046808111,151455502,907153956,2608889883,1038279391,652995533,1764173646,3451040383,2675275242,453576978,2659418909,1949051992,773462580,756751158,2993581788,3998898868,4221608027,4132590244,1295727478,1641469623,3467883389,2066295122,1055122397,1898917726,2542044179,4115878822,1758581177,0,753790401,1612718144,536673507,3367088505,3982187446,3194645204,1187761037,3653156455,1262041458,3729410708,3561770136,3898103984,1255133061,1808847035,720367557,3853167183,385612781,3309519750,3612167578,1429418854,2491778321,3477423498,284817897,100794884,2172616702,4031795360,1144798328,3131023141,3819481163,4082192802,4272137053,3225436288,2324664069,2912064063,3164445985,1211644016,83228145,3753688163,3249976951,1977277103,1663115586,806359072,452984805,250868733,1842533055,1288555905,336333848,890442534,804056259,3781124030,2727843637,3427026056,957814574,1472513171,4071073621,2189328124,1195195770,2892260552,3881655738,723065138,2507371494,2690670784,2558624025,3511635870,2145180835,1713513028,2116692564,2878378043,2206763019,3393603212,703524551,3552098411,1007948840,2044649127,3797835452,487262998,1994120109,1004593371,1446130276,1312438900,503974420,3679013266,168166924,1814307912,3831258296,1573044895,1859376061,4021070915,2791465668,2828112185,2761266481,937747667,2339994098,854058965,1137232011,1496790894,3077402074,2358086913,1691735473,3528347292,3769215305,3027004632,4199962284,133494003,636152527,2942657994,2390391540,3920539207,403179536,3585784431,2289596656,1864705354,1915629148,605822008,4054230615,3350508659,1371981463,602466507,2094914977,2624877800,555687742,3712699286,3703422305,2257292045,2240449039,2423288032,1111375484,3300242801,2858837708,3628615824,84083462,32962295,302911004,2741068226,1597322602,4183250862,3501832553,2441512471,1489093017,656219450,3114180135,954327513,335083755,3013122091,856756514,3144247762,1893325225,2307821063,2811532339,3063651117,572399164,2458355477,552200649,1238290055,4283782570,2015897680,2061492133,2408352771,4171342169,2156497161,386731290,3669999461,837215959,3326231172,3093850320,3275833730,2962856233,1999449434,286199582,3417354363,4233385128,3602627437,974525996],t.rtable=[1353184337,1399144830,3282310938,2522752826,3412831035,4047871263,2874735276,2466505547,1442459680,4134368941,2440481928,625738485,4242007375,3620416197,2151953702,2409849525,1230680542,1729870373,2551114309,3787521629,41234371,317738113,2744600205,3338261355,3881799427,2510066197,3950669247,3663286933,763608788,3542185048,694804553,1154009486,1787413109,2021232372,1799248025,3715217703,3058688446,397248752,1722556617,3023752829,407560035,2184256229,1613975959,1165972322,3765920945,2226023355,480281086,2485848313,1483229296,436028815,2272059028,3086515026,601060267,3791801202,1468997603,715871590,120122290,63092015,2591802758,2768779219,4068943920,2997206819,3127509762,1552029421,723308426,2461301159,4042393587,2715969870,3455375973,3586000134,526529745,2331944644,2639474228,2689987490,853641733,1978398372,971801355,2867814464,111112542,1360031421,4186579262,1023860118,2919579357,1186850381,3045938321,90031217,1876166148,4279586912,620468249,2548678102,3426959497,2006899047,3175278768,2290845959,945494503,3689859193,1191869601,3910091388,3374220536,0,2206629897,1223502642,2893025566,1316117100,4227796733,1446544655,517320253,658058550,1691946762,564550760,3511966619,976107044,2976320012,266819475,3533106868,2660342555,1338359936,2720062561,1766553434,370807324,179999714,3844776128,1138762300,488053522,185403662,2915535858,3114841645,3366526484,2233069911,1275557295,3151862254,4250959779,2670068215,3170202204,3309004356,880737115,1982415755,3703972811,1761406390,1676797112,3403428311,277177154,1076008723,538035844,2099530373,4164795346,288553390,1839278535,1261411869,4080055004,3964831245,3504587127,1813426987,2579067049,4199060497,577038663,3297574056,440397984,3626794326,4019204898,3343796615,3251714265,4272081548,906744984,3481400742,685669029,646887386,2764025151,3835509292,227702864,2613862250,1648787028,3256061430,3904428176,1593260334,4121936770,3196083615,2090061929,2838353263,3004310991,999926984,2809993232,1852021992,2075868123,158869197,4095236462,28809964,2828685187,1701746150,2129067946,147831841,3873969647,3650873274,3459673930,3557400554,3598495785,2947720241,824393514,815048134,3227951669,935087732,2798289660,2966458592,366520115,1251476721,4158319681,240176511,804688151,2379631990,1303441219,1414376140,3741619940,3820343710,461924940,3089050817,2136040774,82468509,1563790337,1937016826,776014843,1511876531,1389550482,861278441,323475053,2355222426,2047648055,2383738969,2302415851,3995576782,902390199,3991215329,1018251130,1507840668,1064563285,2043548696,3208103795,3939366739,1537932639,342834655,2262516856,2180231114,1053059257,741614648,1598071746,1925389590,203809468,2336832552,1100287487,1895934009,3736275976,2632234200,2428589668,1636092795,1890988757,1952214088,1113045200],t}(),h.GCM=function(t){var n=function(){this.table=new Array(128);for(var n=0;n<128;n++)this.table[n]=new Array(4);this.stateX=[],this.Y_0=[],this.counter=0,this.lenA=[],this.lenC=[],this.status=0,this.a=new t.AES};return n.ACCEPTING_HEADER=0,n.ACCEPTING_CIPHER=1,n.NOT_ACCEPTING_MORE=2,n.FINISHED=3,n.ENCRYPTING=0,n.DECRYPTING=1,n.prototype={precompute:function(t){var i,e,o,r=[];for(i=e=0;i<4;i++,e+=4)r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],this.table[0][i]=n.pack(r);for(i=1;i<128;i++){for(o=0,e=0;e<4;e++)this.table[i][e]=o|this.table[i-1][e]>>>1,o=this.table[i-1][e]<<31;0!==o&&(this.table[i][0]^=3774873600)}},gf2mul:function(){var t,i,e,o,r,s=[],h=[];for(s[0]=s[1]=s[2]=s[3]=0,i=8,e=0,t=0;t<128;t++){for(r=1+~(r=this.stateX[e]>>>--i&1),o=0;o<4;o++)s[o]^=this.table[t][o]&r;if(0===i&&(i=8,16==++e))break}for(t=i=0;t<4;t++,i+=4)h=n.unpack(s[t]),this.stateX[i]=h[0],this.stateX[i+1]=h[1],this.stateX[i+2]=h[2],this.stateX[i+3]=h[3]},wrap:function(){var t,i,e=[],o=[],r=[];for(e[0]=this.lenA[0]<<3|(3758096384&this.lenA[1])>>>29,e[1]=this.lenA[1]<<3,e[2]=this.lenC[0]<<3|(3758096384&this.lenC[1])>>>29,e[3]=this.lenC[1]<<3,t=i=0;t<4;t++,i+=4)r=n.unpack(e[t]),o[i]=r[0],o[i+1]=r[1],o[i+2]=r[2],o[i+3]=r[3];for(t=0;t<16;t++)this.stateX[t]^=o[t];this.gf2mul()},init:function(i,e,o,r){var s,h=[],c=[];for(s=0;s<16;s++)h[s]=0,this.stateX[s]=0;if(this.a.init(t.AES.ECB,i,e,r),this.a.ecb_encrypt(h),this.precompute(h),this.lenA[0]=this.lenC[0]=this.lenA[1]=this.lenC[1]=0,12==o){for(s=0;s<12;s++)this.a.f[s]=r[s];for(c=n.unpack(1),this.a.f[12]=c[0],this.a.f[13]=c[1],this.a.f[14]=c[2],this.a.f[15]=c[3],s=0;s<16;s++)this.Y_0[s]=this.a.f[s]}else{for(this.status=n.ACCEPTING_CIPHER,this.ghash(r,o),this.wrap(),s=0;s<16;s++)this.a.f[s]=this.stateX[s],this.Y_0[s]=this.a.f[s],this.stateX[s]=0;this.lenA[0]=this.lenC[0]=this.lenA[1]=this.lenC[1]=0}this.status=n.ACCEPTING_HEADER},add_header:function(t,i){var e,o=0;if(this.status!=n.ACCEPTING_HEADER)return!1;for(;o>>8&255,n[1]=t>>>16&255,n[0]=t>>>24&255,n},n.hex2bytes=function(t){var n,i=t.length,e=[];for(n=0;n>>0)+(t.bot>>>0),i=n>>>0,e=(this.top>>>0)+(t.top>>>0);return this.bot=i,this.top=i!=n?e+1>>>0:e,this},copy:function(){return new t(this.top,this.bot)},shlb:function(){var t=this.bot>>>24;return this.top=t+(this.top<<8),this.bot<<=8,this}},t}(),h.HASH256=function(){var t=function(){this.length=[],this.h=[],this.w=[],this.init()};return t.prototype={transform:function(){var n,i,e,o,r,s,h,c,u,a,f;for(f=16;f<64;f++)this.w[f]=t.theta1(this.w[f-2])+this.w[f-7]+t.theta0(this.w[f-15])+this.w[f-16]|0;for(n=this.h[0],i=this.h[1],e=this.h[2],o=this.h[3],r=this.h[4],s=this.h[5],h=this.h[6],c=this.h[7],f=0;f<64;f++)u=c+t.Sig1(r)+t.Ch(r,s,h)+t.HK[f]+this.w[f]|0,a=t.Sig0(n)+t.Maj(n,i,e)|0,c=h,h=s,s=r,r=o+u|0,o=e,e=i,i=n,n=u+a|0;this.h[0]+=n,this.h[1]+=i,this.h[2]+=e,this.h[3]+=o,this.h[4]+=r,this.h[5]+=s,this.h[6]+=h,this.h[7]+=c},init:function(){var n;for(n=0;n<64;n++)this.w[n]=0;this.length[0]=this.length[1]=0,this.h[0]=t.H[0],this.h[1]=t.H[1],this.h[2]=t.H[2],this.h[3]=t.H[3],this.h[4]=t.H[4],this.h[5]=t.H[5],this.h[6]=t.H[6],this.h[7]=t.H[7]},process:function(t){var n;n=(this.length[0]>>>5)%16,this.w[n]<<=8,this.w[n]|=255&t,this.length[0]+=8,4294967295&this.length[0]||(this.length[1]++,this.length[0]=0),this.length[0]%512==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var n,i,e,o=[];for(n=this.length[0],i=this.length[1],this.process(128);this.length[0]%512!=448;)this.process(0);for(this.w[14]=i,this.w[15]=n,this.transform(),e=0;e>>2]>>8*(3-e%4)&255;return this.init(),o}},t.S=function(t,n){return n>>>t|n<<32-t},t.R=function(t,n){return n>>>t},t.Ch=function(t,n,i){return t&n^~t&i},t.Maj=function(t,n,i){return t&n^t&i^n&i},t.Sig0=function(n){return t.S(2,n)^t.S(13,n)^t.S(22,n)},t.Sig1=function(n){return t.S(6,n)^t.S(11,n)^t.S(25,n)},t.theta0=function(n){return t.S(7,n)^t.S(18,n)^t.R(3,n)},t.theta1=function(n){return t.S(17,n)^t.S(19,n)^t.R(10,n)},t.len=32,t.H=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],t.HK=[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],t}(),h.HASH384=function(t){var n=function(){this.length=[],this.h=[],this.w=[],this.init()};return n.prototype={transform:function(){var t,i,e,o,r,s,h,c,u,a,f;for(f=16;f<80;f++)this.w[f]=n.theta1(this.w[f-2]).add(this.w[f-7]).add(n.theta0(this.w[f-15])).add(this.w[f-16]);for(t=this.h[0].copy(),i=this.h[1].copy(),e=this.h[2].copy(),o=this.h[3].copy(),r=this.h[4].copy(),s=this.h[5].copy(),h=this.h[6].copy(),c=this.h[7].copy(),f=0;f<80;f++)(u=c.copy()).add(n.Sig1(r)).add(n.Ch(r,s,h)).add(n.HK[f]).add(this.w[f]),(a=n.Sig0(t)).add(n.Maj(t,i,e)),c=h,h=s,s=r,(r=o.copy()).add(u),o=e,e=i,i=t,(t=u.copy()).add(a);this.h[0].add(t),this.h[1].add(i),this.h[2].add(e),this.h[3].add(o),this.h[4].add(r),this.h[5].add(s),this.h[6].add(h),this.h[7].add(c)},init:function(){var i;for(i=0;i<80;i++)this.w[i]=new t.UInt64(0,0);this.length[0]=new t.UInt64(0,0),this.length[1]=new t.UInt64(0,0),this.h[0]=n.H[0].copy(),this.h[1]=n.H[1].copy(),this.h[2]=n.H[2].copy(),this.h[3]=n.H[3].copy(),this.h[4]=n.H[4].copy(),this.h[5]=n.H[5].copy(),this.h[6]=n.H[6].copy(),this.h[7]=n.H[7].copy()},process:function(n){var i,e;i=(this.length[0].bot>>>6)%16,this.w[i].shlb(),this.w[i].bot|=255&n,e=new t.UInt64(0,8),this.length[0].add(e),0===this.length[0].top&&0==this.length[0].bot&&(e=new t.UInt64(0,1),this.length[1].add(e)),this.length[0].bot%1024==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var t,i,e,o=[];for(t=this.length[0].copy(),i=this.length[1].copy(),this.process(128);this.length[0].bot%1024!=896;)this.process(0);for(this.w[14]=i,this.w[15]=t,this.transform(),e=0;e>>3]).bot;return this.init(),o}},n.S=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n|i.bot<<32-n,i.bot>>>n|i.top<<32-n):new t.UInt64(i.bot>>>n-32|i.top<<64-n,i.top>>>n-32|i.bot<<64-n)},n.R=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n,i.bot>>>n|i.top<<32-n):new t.UInt64(0,i.top>>>n-32)},n.Ch=function(n,i,e){return new t.UInt64(n.top&i.top^~n.top&e.top,n.bot&i.bot^~n.bot&e.bot)},n.Maj=function(n,i,e){return new t.UInt64(n.top&i.top^n.top&e.top^i.top&e.top,n.bot&i.bot^n.bot&e.bot^i.bot&e.bot)},n.Sig0=function(i){var e=n.S(28,i),o=n.S(34,i),r=n.S(39,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.Sig1=function(i){var e=n.S(14,i),o=n.S(18,i),r=n.S(41,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta0=function(i){var e=n.S(1,i),o=n.S(8,i),r=n.R(7,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta1=function(i){var e=n.S(19,i),o=n.S(61,i),r=n.R(6,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.len=48,n.H=[new t.UInt64(3418070365,3238371032),new t.UInt64(1654270250,914150663),new t.UInt64(2438529370,812702999),new t.UInt64(355462360,4144912697),new t.UInt64(1731405415,4290775857),new t.UInt64(2394180231,1750603025),new t.UInt64(3675008525,1694076839),new t.UInt64(1203062813,3204075428)],n.HK=[new t.UInt64(1116352408,3609767458),new t.UInt64(1899447441,602891725),new t.UInt64(3049323471,3964484399),new t.UInt64(3921009573,2173295548),new t.UInt64(961987163,4081628472),new t.UInt64(1508970993,3053834265),new t.UInt64(2453635748,2937671579),new t.UInt64(2870763221,3664609560),new t.UInt64(3624381080,2734883394),new t.UInt64(310598401,1164996542),new t.UInt64(607225278,1323610764),new t.UInt64(1426881987,3590304994),new t.UInt64(1925078388,4068182383),new t.UInt64(2162078206,991336113),new t.UInt64(2614888103,633803317),new t.UInt64(3248222580,3479774868),new t.UInt64(3835390401,2666613458),new t.UInt64(4022224774,944711139),new t.UInt64(264347078,2341262773),new t.UInt64(604807628,2007800933),new t.UInt64(770255983,1495990901),new t.UInt64(1249150122,1856431235),new t.UInt64(1555081692,3175218132),new t.UInt64(1996064986,2198950837),new t.UInt64(2554220882,3999719339),new t.UInt64(2821834349,766784016),new t.UInt64(2952996808,2566594879),new t.UInt64(3210313671,3203337956),new t.UInt64(3336571891,1034457026),new t.UInt64(3584528711,2466948901),new t.UInt64(113926993,3758326383),new t.UInt64(338241895,168717936),new t.UInt64(666307205,1188179964),new t.UInt64(773529912,1546045734),new t.UInt64(1294757372,1522805485),new t.UInt64(1396182291,2643833823),new t.UInt64(1695183700,2343527390),new t.UInt64(1986661051,1014477480),new t.UInt64(2177026350,1206759142),new t.UInt64(2456956037,344077627),new t.UInt64(2730485921,1290863460),new t.UInt64(2820302411,3158454273),new t.UInt64(3259730800,3505952657),new t.UInt64(3345764771,106217008),new t.UInt64(3516065817,3606008344),new t.UInt64(3600352804,1432725776),new t.UInt64(4094571909,1467031594),new t.UInt64(275423344,851169720),new t.UInt64(430227734,3100823752),new t.UInt64(506948616,1363258195),new t.UInt64(659060556,3750685593),new t.UInt64(883997877,3785050280),new t.UInt64(958139571,3318307427),new t.UInt64(1322822218,3812723403),new t.UInt64(1537002063,2003034995),new t.UInt64(1747873779,3602036899),new t.UInt64(1955562222,1575990012),new t.UInt64(2024104815,1125592928),new t.UInt64(2227730452,2716904306),new t.UInt64(2361852424,442776044),new t.UInt64(2428436474,593698344),new t.UInt64(2756734187,3733110249),new t.UInt64(3204031479,2999351573),new t.UInt64(3329325298,3815920427),new t.UInt64(3391569614,3928383900),new t.UInt64(3515267271,566280711),new t.UInt64(3940187606,3454069534),new t.UInt64(4118630271,4000239992),new t.UInt64(116418474,1914138554),new t.UInt64(174292421,2731055270),new t.UInt64(289380356,3203993006),new t.UInt64(460393269,320620315),new t.UInt64(685471733,587496836),new t.UInt64(852142971,1086792851),new t.UInt64(1017036298,365543100),new t.UInt64(1126000580,2618297676),new t.UInt64(1288033470,3409855158),new t.UInt64(1501505948,4234509866),new t.UInt64(1607167915,987167468),new t.UInt64(1816402316,1246189591)],n}(h),h.HASH512=function(t){var n=function(){this.length=[],this.h=[],this.w=[],this.init()};return n.prototype={transform:function(){var t,i,e,o,r,s,h,c,u,a,f;for(f=16;f<80;f++)this.w[f]=n.theta1(this.w[f-2]).add(this.w[f-7]).add(n.theta0(this.w[f-15])).add(this.w[f-16]);for(t=this.h[0].copy(),i=this.h[1].copy(),e=this.h[2].copy(),o=this.h[3].copy(),r=this.h[4].copy(),s=this.h[5].copy(),h=this.h[6].copy(),c=this.h[7].copy(),f=0;f<80;f++)(u=c.copy()).add(n.Sig1(r)).add(n.Ch(r,s,h)).add(n.HK[f]).add(this.w[f]),(a=n.Sig0(t)).add(n.Maj(t,i,e)),c=h,h=s,s=r,(r=o.copy()).add(u),o=e,e=i,i=t,(t=u.copy()).add(a);this.h[0].add(t),this.h[1].add(i),this.h[2].add(e),this.h[3].add(o),this.h[4].add(r),this.h[5].add(s),this.h[6].add(h),this.h[7].add(c)},init:function(){var i;for(i=0;i<80;i++)this.w[i]=new t.UInt64(0,0);this.length[0]=new t.UInt64(0,0),this.length[1]=new t.UInt64(0,0),this.h[0]=n.H[0].copy(),this.h[1]=n.H[1].copy(),this.h[2]=n.H[2].copy(),this.h[3]=n.H[3].copy(),this.h[4]=n.H[4].copy(),this.h[5]=n.H[5].copy(),this.h[6]=n.H[6].copy(),this.h[7]=n.H[7].copy()},process:function(n){var i,e;i=(this.length[0].bot>>>6)%16,this.w[i].shlb(),this.w[i].bot|=255&n,e=new t.UInt64(0,8),this.length[0].add(e),0===this.length[0].top&&0==this.length[0].bot&&(e=new t.UInt64(0,1),this.length[1].add(e)),this.length[0].bot%1024==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var t,i,e,o=[];for(t=this.length[0].copy(),i=this.length[1].copy(),this.process(128);this.length[0].bot%1024!=896;)this.process(0);for(this.w[14]=i,this.w[15]=t,this.transform(),e=0;e>>3]).bot;return this.init(),o}},n.S=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n|i.bot<<32-n,i.bot>>>n|i.top<<32-n):new t.UInt64(i.bot>>>n-32|i.top<<64-n,i.top>>>n-32|i.bot<<64-n)},n.R=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n,i.bot>>>n|i.top<<32-n):new t.UInt64(0,i.top>>>n-32)},n.Ch=function(n,i,e){return new t.UInt64(n.top&i.top^~n.top&e.top,n.bot&i.bot^~n.bot&e.bot)},n.Maj=function(n,i,e){return new t.UInt64(n.top&i.top^n.top&e.top^i.top&e.top,n.bot&i.bot^n.bot&e.bot^i.bot&e.bot)},n.Sig0=function(i){var e=n.S(28,i),o=n.S(34,i),r=n.S(39,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.Sig1=function(i){var e=n.S(14,i),o=n.S(18,i),r=n.S(41,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta0=function(i){var e=n.S(1,i),o=n.S(8,i),r=n.R(7,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta1=function(i){var e=n.S(19,i),o=n.S(61,i),r=n.R(6,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.len=64,n.H=[new t.UInt64(1779033703,4089235720),new t.UInt64(3144134277,2227873595),new t.UInt64(1013904242,4271175723),new t.UInt64(2773480762,1595750129),new t.UInt64(1359893119,2917565137),new t.UInt64(2600822924,725511199),new t.UInt64(528734635,4215389547),new t.UInt64(1541459225,327033209)],n.HK=[new t.UInt64(1116352408,3609767458),new t.UInt64(1899447441,602891725),new t.UInt64(3049323471,3964484399),new t.UInt64(3921009573,2173295548),new t.UInt64(961987163,4081628472),new t.UInt64(1508970993,3053834265),new t.UInt64(2453635748,2937671579),new t.UInt64(2870763221,3664609560),new t.UInt64(3624381080,2734883394),new t.UInt64(310598401,1164996542),new t.UInt64(607225278,1323610764),new t.UInt64(1426881987,3590304994),new t.UInt64(1925078388,4068182383),new t.UInt64(2162078206,991336113),new t.UInt64(2614888103,633803317),new t.UInt64(3248222580,3479774868),new t.UInt64(3835390401,2666613458),new t.UInt64(4022224774,944711139),new t.UInt64(264347078,2341262773),new t.UInt64(604807628,2007800933),new t.UInt64(770255983,1495990901),new t.UInt64(1249150122,1856431235),new t.UInt64(1555081692,3175218132),new t.UInt64(1996064986,2198950837),new t.UInt64(2554220882,3999719339),new t.UInt64(2821834349,766784016),new t.UInt64(2952996808,2566594879),new t.UInt64(3210313671,3203337956),new t.UInt64(3336571891,1034457026),new t.UInt64(3584528711,2466948901),new t.UInt64(113926993,3758326383),new t.UInt64(338241895,168717936),new t.UInt64(666307205,1188179964),new t.UInt64(773529912,1546045734),new t.UInt64(1294757372,1522805485),new t.UInt64(1396182291,2643833823),new t.UInt64(1695183700,2343527390),new t.UInt64(1986661051,1014477480),new t.UInt64(2177026350,1206759142),new t.UInt64(2456956037,344077627),new t.UInt64(2730485921,1290863460),new t.UInt64(2820302411,3158454273),new t.UInt64(3259730800,3505952657),new t.UInt64(3345764771,106217008),new t.UInt64(3516065817,3606008344),new t.UInt64(3600352804,1432725776),new t.UInt64(4094571909,1467031594),new t.UInt64(275423344,851169720),new t.UInt64(430227734,3100823752),new t.UInt64(506948616,1363258195),new t.UInt64(659060556,3750685593),new t.UInt64(883997877,3785050280),new t.UInt64(958139571,3318307427),new t.UInt64(1322822218,3812723403),new t.UInt64(1537002063,2003034995),new t.UInt64(1747873779,3602036899),new t.UInt64(1955562222,1575990012),new t.UInt64(2024104815,1125592928),new t.UInt64(2227730452,2716904306),new t.UInt64(2361852424,442776044),new t.UInt64(2428436474,593698344),new t.UInt64(2756734187,3733110249),new t.UInt64(3204031479,2999351573),new t.UInt64(3329325298,3815920427),new t.UInt64(3391569614,3928383900),new t.UInt64(3515267271,566280711),new t.UInt64(3940187606,3454069534),new t.UInt64(4118630271,4000239992),new t.UInt64(116418474,1914138554),new t.UInt64(174292421,2731055270),new t.UInt64(289380356,3203993006),new t.UInt64(460393269,320620315),new t.UInt64(685471733,587496836),new t.UInt64(852142971,1086792851),new t.UInt64(1017036298,365543100),new t.UInt64(1126000580,2618297676),new t.UInt64(1288033470,3409855158),new t.UInt64(1501505948,4234509866),new t.UInt64(1607167915,987167468),new t.UInt64(1816402316,1246189591)],n}(h),h.SHA3=function(t){var n=function(t){this.length=0,this.rate=0,this.len=0,this.S=[],this.init(t)};return n.prototype={transform:function(){var i,e,o,r=[],s=[],h=[];for(o=0;o>=3)%5,o=Math.floor(h/5),c=new t.UInt64(0,i),r=0;r=i||c%this.rate==0){e=!0;break}h=n.rotl(h,56)}if(e)break}if(e)break}if(c>=i)break;e=!1,this.transform()}},hash:function(t){if(1==this.rate-this.length%this.rate)this.process(134);else{for(this.process(6);this.length%this.rate!=this.rate-1;)this.process(0);this.process(128)}this.squeeze(t,this.len)},shake:function(t,n){if(1==this.rate-this.length%this.rate)this.process(159);else{for(this.process(31);this.length%this.rate!=this.rate-1;)this.process(0);this.process(128)}this.squeeze(t,n)}},n.rotl=function(n,i){return 0==i?n:i<32?new t.UInt64(n.top<>>32-i,n.bot<>>32-i):new t.UInt64(n.bot<>>64-i,n.top<>>64-i)},n.xor=function(n,i){return new t.UInt64(n.top^i.top,n.bot^i.bot)},n.and=function(n,i){return new t.UInt64(n.top&i.top,n.bot&i.bot)},n.not=function(n){return new t.UInt64(~n.top,~n.bot)},n.ROUNDS=24,n.HASH224=28,n.HASH256=32,n.HASH384=48,n.HASH512=64,n.SHAKE128=16,n.SHAKE256=32,n.RC=[new t.UInt64(0,1),new t.UInt64(0,32898),new t.UInt64(2147483648,32906),new t.UInt64(2147483648,2147516416),new t.UInt64(0,32907),new t.UInt64(0,2147483649),new t.UInt64(2147483648,2147516545),new t.UInt64(2147483648,32777),new t.UInt64(0,138),new t.UInt64(0,136),new t.UInt64(0,2147516425),new t.UInt64(0,2147483658),new t.UInt64(0,2147516555),new t.UInt64(2147483648,139),new t.UInt64(2147483648,32905),new t.UInt64(2147483648,32771),new t.UInt64(2147483648,32770),new t.UInt64(2147483648,128),new t.UInt64(0,32778),new t.UInt64(2147483648,2147483658),new t.UInt64(2147483648,2147516545),new t.UInt64(2147483648,32896),new t.UInt64(0,2147483649),new t.UInt64(2147483648,2147516424)],n}(h),h.RAND=function(t){var n=function(){this.ira=[],this.rndptr=0,this.borrow=0,this.pool_ptr=0,this.pool=[],this.clean()};return n.prototype={NK:21,NJ:6,NV:8,clean:function(){var t;for(t=0;t<32;t++)this.pool[t]=0;for(t=0;t>>0)-this.ira[t]-this.borrow|0,(i>>>=0)e&&(this.borrow=1),this.ira[t]=0|i;return this.ira[0]},sirand:function(t){var n,i,e,o=1;for(this.borrow=0,this.rndptr=0,t>>>=0,this.ira[0]^=t,n=1;n0){for(o=0;o=32&&this.fill_pool(),255&t}},n.pack=function(t){return(255&t[3])<<24|(255&t[2])<<16|(255&t[1])<<8|255&t[0]},n}(h),h.NHS=function(t){var n={round:function(t,n){return Math.floor((t+(n>>1))/n)},nabs:function(t){var n=t>>31;return t+n^n},redc:function(t){return(((67108863&t)*n.ND&67108863)*n.PRIME+t)*n.MODINV},nres:function(t){return n.redc(t*n.R2MODP)},modmul:function(t,i){return n.redc(t*i)},ntt:function(t){var i,e,o,r,s,h,c,u=n.DEGREE/2,a=n.PRIME;for(o=0;o1;){for(r=0,e=0;e>n.WL-1&a},Encode:function(t,i){var e,o,r,s,h,c;for(c=n.PRIME/2,e=o=0;e<256;)for(h=t[o++],s=0;s<8;s++)r=1&h,i[e]=r*c,i[e+256]=r*c,i[e+512]=r*c,i[e+768]=r*c,h>>=1,e++},Decode:function(t,i){var e,o,r,s,h=n.PRIME/2;for(e=0;e<32;e++)i[e]=0;for(e=o=0;e<256;){for(r=0;r<8;r++)s=(s=n.nabs(t[e]-h)+n.nabs(t[e+256]-h)+n.nabs(t[e+512]-h)+n.nabs(t[e+768]-h)-n.PRIME)>>31&1,i[o]=((255&i[o])>>1)+(s<<7),e++;o++}},Parse:function(i,e){var o,r,s,h=new t.SHA3(t.SHA3.SHAKE128),c=[];for(o=0;o<32;o++)h.process(i[o]);for(h.shake(c,4*n.DEGREE),o=r=0;o>8|s<<6),i[o++]=s>>2&255,i[o++]=255&(s>>10|h<<4),i[o++]=h>>4&255,i[o++]=255&(h>>12|c<<2),i[o++]=c>>6},unpack:function(t,i){var e,o,r,s,h,c,u,a,f;for(e=o=0;e>6|h<<2|(15&c)<<10,i[e++]=c>>4|u<<4|(3&a)<<12,i[e++]=a>>2|f<<6},Compress:function(t,i){var e,o,r,s=0;for(e=o=0;e>>8&255,i[o+2]=s>>>16&255,o+=3,s=0}},Decompress:function(t,i){var e,o,r,s,h=0;for(e=o=0;e>>21,h<<=3,i[e]=n.round(s*n.PRIME,8),e++},Error:function(t,i){var e,o,r,s,h;for(s=0;s>=1,o>>=1;i[s]=r+n.PRIME}},redc_it:function(t){var i;for(i=0;i>n.WL-1&n.PRIME)},poly_hard_reduce:function(t){var i,e;for(i=0;i>n.WL-1&n.PRIME)},bytestostring:function(t){var n,i,e="",o=t.length;for(i=0;i>>4&15).toString(16),e+=(15&n).toString(16);return e},SERVER_1:function(t,i,e){var o,r=new Uint8Array(32),s=new Uint8Array(1792),h=new Int32Array(n.DEGREE),c=new Int32Array(n.DEGREE),u=new Int32Array(n.DEGREE);for(o=0;o<32;o++)r[o]=t.getByte();for(n.Parse(r,u),n.Error(t,c),n.Error(t,h),n.ntt(h),n.ntt(c),n.poly_mul(u,u,h),n.poly_add(u,u,c),n.poly_hard_reduce(u),n.redc_it(u),n.pack(u,s),o=0;o<32;o++)i[o]=r[o];for(o=0;o<1792;o++)i[o+32]=s[o];for(n.poly_hard_reduce(h),n.pack(h,s),o=0;o<1792;o++)e[o]=s[o]},CLIENT:function(i,e,o,r){var s,h=new t.SHA3(t.SHA3.HASH256),c=new Uint8Array(32),u=new Uint8Array(1792),a=new Uint8Array(32),f=new Uint8Array(384),E=new Int32Array(n.DEGREE),B=new Int32Array(n.DEGREE),y=new Int32Array(n.DEGREE),I=new Int32Array(n.DEGREE),m=new Int32Array(n.DEGREE);for(n.Error(i,E),n.Error(i,B),n.ntt(E),n.ntt(B),s=0;s<32;s++)c[s]=e[s];for(s=0;s<1792;s++)u[s]=e[s+32];for(n.Parse(c,y),n.poly_mul(y,y,E),n.poly_add(y,y,B),n.poly_hard_reduce(y),s=0;s<32;s++)a[s]=i.getByte();for(s=0;s<32;s++)h.process(a[s]);for(h.hash(a),n.Encode(a,I),n.unpack(u,m),n.nres_it(m),n.poly_mul(m,m,E),n.intt(m),n.Error(i,B),n.poly_add(m,m,B),n.poly_add(m,m,I),n.Compress(m,f),h.init(t.SHA3.HASH256),s=0;s<32;s++)h.process(a[s]);for(h.hash(a),s=0;s<32;s++)r[s]=a[s];for(n.redc_it(y),n.pack(y,u),s=0;s<1792;s++)o[s]=u[s];for(s=0;s<384;s++)o[s+1792]=f[s]},SERVER_2:function(i,e,o){var r,s=new t.SHA3(t.SHA3.HASH256),h=new Int32Array(n.DEGREE),c=new Int32Array(n.DEGREE),u=new Int32Array(n.DEGREE),a=new Uint8Array(1792),f=new Uint8Array(32),E=new Uint8Array(384);for(r=0;r<1792;r++)a[r]=e[r];for(n.unpack(a,u),n.nres_it(u),r=0;r<384;r++)E[r]=e[r+1792];for(n.Decompress(E,h),r=0;r<1792;r++)a[r]=i[r];for(n.unpack(a,c),n.poly_mul(u,u,c),n.intt(u),n.poly_sub(u,h,u),n.poly_soft_reduce(u),n.Decode(u,f),r=0;r<32;r++)s.process(f[r]);for(s.hash(f),r=0;r<32;r++)o[r]=f[r]},PRIME:12289,LGN:10,ND:50343935,ONE:10924,R2MODP:7586};return n.MODINV=Math.pow(2,-26),n.DEGREE=1024,n.WL=26,n.inv=4091,n.invpr=4401,n.roots=[10924,3439,7271,11355,11709,9879,10742,2259,7036,2539,8427,9802,10192,4635,1420,1239,6050,10731,7026,5040,6577,5505,10953,9704,9373,11614,867,8052,8079,8356,11442,11524,5127,11769,941,9207,6770,2705,895,3507,8981,1510,2703,8477,3501,7979,11817,9904,8201,12253,10369,921,1414,10113,10933,2417,9035,7667,7466,5597,6765,10100,2047,7870,560,7412,6155,2904,6540,11072,4731,7581,4991,4e3,324,75,12204,2825,7295,437,3820,3160,4680,9276,4234,5304,233,11774,251,9730,10988,7095,4248,9176,1923,6931,8295,8406,5916,4,1634,4247,9401,7069,10180,10094,1727,1879,11798,1138,7441,5705,10500,3796,1733,5294,12024,10976,11900,10037,4486,1266,6075,10623,7623,6885,10819,11266,3798,11120,7291,6353,8366,1709,9220,4410,8350,795,5533,1167,3593,7090,5367,901,452,7387,8918,8664,12,6830,11982,11649,3414,1473,4826,2255,5637,7108,6327,6585,8638,4958,10454,10385,8712,6113,10609,2342,8475,255,1311,2693,225,11317,9605,289,3623,11876,10744,11590,3250,10538,829,2809,2950,11834,8504,6520,8996,3903,11536,7677,5059,1740,6777,4641,9487,2765,4095,1972,1616,6291,3717,8029,4828,11586,3470,4672,4226,4847,4534,4008,2831,3500,6428,4674,490,341,9994,2541,11867,9688,8748,2025,8115,4268,10521,9604,3043,9466,9197,1560,11648,1786,5134,1416,853,4180,9924,7759,5761,8047,7251,4068,2763,5760,12264,108,5722,4283,11321,6148,4502,2180,9762,1577,6849,8754,12187,3390,8447,4800,10220,90,672,1521,7386,1027,7848,5913,8135,11555,1514,9681,182,1180,2759,11676,8270,8514,4584,3792,5616,1300,2623,3907,7653,11671,5443,11387,9242,8739,12216,9655,6988,12086,9954,256,9557,9836,11792,10012,1450,6025,8601,10525,4232,8262,7841,3977,7290,7832,311,7013,9453,3895,11971,3340,1991,4671,2862,6807,6659,7117,946,1812,10617,2799,11068,11665,3587,3675,8124,3246,1074,9124,2845,7372,8118,12120,10842,1827,11417,11632,10,9788,9985,3563,11528,7220,8204,7816,918,6357,7237,196,6332,11479,5956,2289,7260,3046,10889,6048,519,6606,8228,9187,10651,1669,11183,1337,11593,9397,5517,253,10901,589,2739,4389,4857,5562,1704,11318,1767,4164,878,4072,4397,10007,9376,7177,3613,2088,759,8027,4011,3318,4914,7282,9859,5582,6867,6710,588,2867,9535,5507,7529,10732,2983,12183,5855,4200,2798,3151,5436,9451,8397,5016,9062,4601,3703,4157,9738,206,2794,9067,11025,1528,3663,1872,5481,4341,10318,2616,11782,224,3754,2462,9371,2283,11159,12255,10689,6912,12259,7503,2111,11526,270,6207,10170,306,4031,10605,5450,1034,10087,173,3081,2420,10273,7726,10450,4012,964,12057,3540,11743,7747,7824,11721,4420,10435,1619,3900,7730,10826,913,4387,219,11680,3614,1639,9141,8249,2706,5458,1491,5786,7939,4930,8196,7005,11521,11931,1055,11207,2708,208,11882,11064,5292,10020,954,1724,6316,11685,8508,11356,3539,2734,11784,1741,5751,8229,7708,1460,3524,96,5484,9833,7169,9899,7867,9940,8673,5483,1383,26,10702,9172,1668,2937,6483,4166,7564,6069,7208,7397,9336,6360,6934,11311,8649,6587,3004,10523,6646,6265,12260,1422,10570,6632,10183,12218,6697,8985,7883,8251,12037,11138,6447,9898,9346,2797,4630,1800,4513,3106,2312,10488,9255,2040,5934,3920,2728,6218,8039,8913,3770,8539,3911,10359,3422,2268,525,11694,7486,1909,3059,2162,9831,8182,3487,5060,261,1631,8684,1757,6665,3182,509,5158,2787,1172,11650,8909,9686,4545,28,11438,5151,4362,327,9815,9213,12089,864,8852,7966,2931,3068,12055,1994,12131,191,10434,3098,9566,8814,6824,8862,5658,627,4205,11328,1999,5128,2008,4106,1881,7604,9406,11963,3095,6292,9294,5565,1864,8169,573,474,702,6307,3164,2553,981,11492,84,10943,10140,7809,11609,10311,9204,3496,2592,600,7422,9228,11310,10128,11733,11250,11828,5924,529,4105,10169,1785,9177,6562,1575,5485,5790,2023,783,9398,1474,7396,10461,32,5803,7374,8361,9104,10372,8773,1527,2743,7018,4583,10835,12180,10572,7909,4964,7066,4087,1515,11312,7170,1441,7047,9218,7368,12001,8126,5004,9351,7160,3478,7528,12211,8129,8140,3430,2387,8513,5498,9335,6371,12080,1886,7649,5298,12202,5783,9012,4817,2934,10920,7802,213,11360,9912,5971,4682,8023,5157,3460,7173,1601,3898,7052,3453,12114,756,3187,5403,5513,6169,6936,2971,6889,11039,11076,12122,11575,11441,9973,9022,10095,630,4704,10647,2546,7189,5780,4524,7789,7151,10598,6322,1274,8260,7024,7998,8734,10442,7510,1966,2445,9100,6072,2771,4415,7963,1234,5975,3249,12017,11778,6140,12049,10868,8233,1792,5454,7407,8810,8639,10150,5308,11051,12230,5046,8678,5731,3261,1874,5668,2177,12224,4726,2687,10063,11091,1648,8119,7745,10782,9746,663,6622,395,585,7304,3742,7921,531,1147,7712,10433,7518,2423,7626,2448,7670,11106,2160,500,6185,7690,70,7071,8450,363,6962,1384,8272,5556,6426,7632,1503,1372,7457,6619,4825,3734,1664,9033,2489,5469,3633,9375,8440,2864,823,11683,4547,9359,7417,4334,1752,1771,2573,4123,6884,6145,9421,2067,11928,5492,80,4570,6146,3926,6201,8604,4187,1083,713,2327,5313,7033,3499,10937,9820,1818,7568,2207,11202,10103,4116,7780,5300,1682,3547,1390,8592,11547,4118,4822,7297,9768,1185,4712,9623,10534,1989,7629,1343,4521,6721,1442,7269,2024,3441,10696,1063,815,1500,5809,10781,6023,8740,1568,1700,4945,4152,3692,4379,12051,1089,11517,12079,3365,2488,6948,1890,6582,9745,2142,3639,501,1283,7238,9164,1211,9278,4651,10466,4926,11705,3506,6748,10665,202,8467,5073,5612,8313,6362,11600,11333,2722,4954,2048,6391,6131,1533,8026,720,11473,2542,8587,6653,1339,10437,3635,6417,9932,8216,12168,6913,9783,7385,4715,6667,1456,9440,3714,177,8695,6678,12068,7345,8061,10400,5758,195],n.iroots=[10924,8850,934,5018,10030,1547,2410,580,11050,10869,7654,2097,2487,3862,9750,5253,765,847,3933,4210,4237,11422,675,2916,2585,1336,6784,5712,7249,5263,1558,6239,4419,10242,2189,5524,6692,4823,4622,3254,9872,1356,2176,10875,11368,1920,36,4088,2385,472,4310,8788,3812,9586,10779,3308,8782,11394,9584,5519,3082,11348,520,7162,1023,1470,5404,4666,1666,6214,11023,7803,2252,389,1313,265,6995,10556,8493,1789,6584,4848,11151,491,10410,10562,2195,2109,5220,2888,8042,10655,12285,6373,3883,3994,5358,10366,3113,8041,5194,1301,2559,12038,515,12056,6985,8055,3013,7609,9129,8469,11852,4994,9464,85,12214,11965,8289,7298,4708,7558,1217,5749,9385,6134,4877,11729,10712,2527,10109,7787,6141,968,8006,6567,12181,25,6529,9526,8221,5038,4242,6528,4530,2365,8109,11436,10873,7155,10503,641,10729,3092,2823,9246,2685,1768,8021,4174,10264,3541,2601,422,9748,2295,11948,11799,7615,5861,8789,9458,8281,7755,7442,8063,7617,8819,703,7461,4260,8572,5998,10673,10317,8194,9524,2802,7648,5512,10549,7230,4612,753,8386,3293,5769,3785,455,9339,9480,11460,1751,9039,699,1545,413,8666,12e3,2684,972,12064,9596,10978,12034,3814,9947,1680,6176,3577,1904,1835,7331,3651,5704,5962,5181,6652,10034,7463,10816,8875,640,307,5459,12277,3625,3371,4902,11837,11388,6922,5199,8696,11122,6756,11494,3939,7879,3069,10580,3923,5936,4998,1169,8491,8750,933,3781,604,5973,10565,11335,2269,6997,1225,407,12081,9581,1082,11234,358,768,5284,4093,7359,4350,6503,10798,6831,9583,4040,3148,10650,8675,609,12070,7902,11376,1463,4559,8389,10670,1854,7869,568,4465,4542,546,8749,232,11325,8277,1839,4563,2016,9869,9208,12116,2202,11255,6839,1684,8258,11983,2119,6082,12019,763,10178,4786,30,5377,1600,34,1130,10006,2918,9827,8535,12065,507,9673,1971,7948,6808,10417,8626,10761,1264,3222,9495,12083,2551,8132,8586,7688,3227,7273,3892,2838,6853,9138,9491,8089,6434,106,9306,1557,4760,6782,2754,9422,11701,5579,5422,6707,2430,5007,7375,8971,8278,4262,11530,10201,8676,5112,2913,2282,7892,8217,11411,8125,10522,971,10585,6727,7432,7900,9550,11700,1388,12036,6772,2892,696,10952,1106,10620,1638,3102,4061,5683,11770,6241,1400,9243,5029,1e4,6333,810,5957,12093,5052,5932,11371,4473,4085,5069,761,8726,2304,2501,12279,657,872,10462,1447,169,4171,4917,9444,3165,11215,9043,4165,8614,8702,624,1221,9490,1672,10477,11343,5172,5630,5482,9427,7618,10298,8949,318,8394,2836,5276,11978,4457,4999,8312,4448,4027,8057,1764,3688,6264,10839,2277,497,2453,2732,12033,2335,203,5301,2634,73,3550,3047,902,6846,618,4636,8382,9666,10989,6673,8497,7705,3775,4019,613,9530,11109,12107,2608,10775,734,4154,6376,4441,11262,4903,10768,11617,12199,2069,7489,3842,8899,102,3535,5440,12094,6531,1889,4228,4944,221,5611,3594,12112,8575,2849,10833,5622,7574,4904,2506,5376,121,4073,2357,5872,8654,1852,10950,5636,3702,9747,816,11569,4263,10756,6158,5898,10241,7335,9567,956,689,5927,3976,6677,7216,3822,12087,1624,5541,8783,584,7363,1823,7638,3011,11078,3125,5051,11006,11788,8650,10147,2544,5707,10399,5341,9801,8924,210,772,11200,238,7910,8597,8137,7344,10589,10721,3549,6266,1508,6480,10789,11474,11226,1593,8848,10265,5020,10847,5568,7768,10946,4660,10300,1755,2666,7577,11104,2521,4992,7467,8171,742,3697,10899,8742,10607,6989,4509,8173,2186,1087,10082,4721,10471,2469,1352,8790,5256,6976,9962,11576,11206,8102,3685,6088,8363,6143,7719,12209,6797,361,10222,2868,6144,5405,8166,9716,10518,10537,7955,4872,2930,7742,606,11466,9425,3849,2914,8656,6820,9800,3256,10625,8555,7464,5670,4832,10917,10786,4657,5863,6733,4017,10905,5327,11926,3839,5218,12219,4599,6104,11789,10129,1183,4619,9841,4663,9866,4771,1856,4577,11142,11758,4368,8547,4985,11704,11894,5667,11626,2543,1507,4544,4170,10641,1198,2226,9602,7563,65,10112,6621,10415,9028,6558,3611,7243,59,1238,6981,2139,3650,3479,4882,6835,10497,4056,1421,240,6149,511,272,9040,6314,11055,4326,7874,9518,6217,3189,9844,10323,4779,1847,3555,4291,5265,4029,11015,5967,1691,5138,4500,7765,6509,5100,9743,1642,7585,11659,2194,3267,2316,848,714,167,1213,1250,5400,9318,5353,6120,6776,6886,9102,11533,175,8836,5237,8391,10688,5116,8829,7132,4266,7607,6318,2377,929,12076,4487,1369,9355,7472,3277,6506,87,6991,4640,10403,209,5918,2954,6791,3776,9902,8859,4149,4160,78,4761,8811,5129,2938,7285,4163,288,4921,3071,5242,10848,5119,977,10774,8202,5223,7325,4380,1717,109,1454,7706,5271,9546,10762,3516,1917,3185,3928,4915,6486,12257,1828,4893,10815,2891,11506,10266,6499,6804,10714,5727,3112,10504,2120,8184,11760,6365,461,1039,556,2161,979,3061,4867,11689,9697,8793,3085,1978,680,4480,2149,1346,12205,797,11308,9736,9125,5982,11587,11815,11716,4120,10425,6724,2995,5997,9194,326,2883,4685,10408,8183,10281,7161,10290,961,8084,11662,6631,3427,5465,3475,2723,9191,1855,12098,158,10295,234,9221,9358,4323,3437,11425,200,3076,2474,11962,7927,7138,851,12261,7744,2603,3380,639,11117,9502,7131,11780,9107,5624,10532,3605,10658,12028,7229,8802,4107,2458,10127,9230,10380,4803,595,11764,10021,8867,1930,8378,3750,8519,3376,4250,6071,9561,8369,6355,10249,3034,1801,9977,9183,7776,10489,7659,9492,2943,2391,5842,1151,252,4038,4406,3304,5592,71,2106,5657,1719,10867,29,6024,5643,1766,9285,5702,3640,978,5355,5929,2953,4892,5081,6220,4725,8123,5806,9352,10621,3117,1587,12263,10906,6806,3616,2349,4422,2390,5120,2456,6805,12193,8765,10829,4581,4060,6538,10548,505,9555],n}(h),void 0!==r)return h.config=s[r],h.BIG=function(t){var n=function(t){switch(this.w=new Array(n.NLEN),typeof t){case"object":this.copy(t);break;case"number":this.zero(),this.w[0]=t;break;default:this.zero()}};return n.CHUNK=32,n.MODBYTES=t.config["@NB"],n.BASEBITS=t.config["@BASE"],n.NLEN=1+Math.floor((8*n.MODBYTES-1)/n.BASEBITS),n.DNLEN=2*n.NLEN,n.BMASK=(1<>n.BASEBITS;return this.w[n.NLEN-1]=this.w[n.NLEN-1]+e,this.w[n.NLEN-1]>>8*n.MODBYTES%n.BASEBITS},fshr:function(t){var i,e;for(i=this.w[0]&(1<>t|this.w[e+1]<>t,i},shr:function(t){var i,e=t%n.BASEBITS,o=Math.floor(t/n.BASEBITS);for(i=0;i>e|this.w[o+i+1]<>e,i=n.NLEN-o;i>n.BASEBITS-t,i=n.NLEN-2;i>0;i--)this.w[i]=this.w[i]<>n.BASEBITS-t;return this.w[0]=this.w[0]<>8*n.MODBYTES%n.BASEBITS},shl:function(t){var i,e=t%n.BASEBITS,o=Math.floor(t/n.BASEBITS);for(this.w[n.NLEN-1]=this.w[n.NLEN-1-o]<o+2&&(this.w[n.NLEN-1]|=this.w[n.NLEN-o-2]>>n.BASEBITS-e),i=n.NLEN-2;i>o;i--)this.w[i]=this.w[i-o]<>n.BASEBITS-e;for(this.w[o]=this.w[0]<=0&&0===this.w[e];)e--;if(e<0)return 0;for(t=n.BASEBITS*e,i=this.w[e];0!==i;)i=Math.floor(i/2),t++;return t},toString:function(){var t,i,e="",o=this.nbits();for(o%4==0?o=Math.floor(o/4):(o=Math.floor(o/4),o++),o<2*n.MODBYTES&&(o=2*n.MODBYTES),i=o-1;i>=0;i--)(t=new n(0)).copy(this),t.shr(4*i),e+=(15&t.w[0]).toString(16);return e},add:function(t){var i;for(i=0;i=0;e--)t[e+i]=255&o.w[0],o.fshr(8);return this},toBytes:function(t){this.tobytearray(t,0)},muladd:function(t,i,e,o){var r=t*i+e+this.w[o];return this.w[o]=r&n.BMASK,(r-this.w[o])*n.MODINV},pmul:function(t){var i,e,o=0;for(e=0;e=0;e--)t=o*i+this.w[e],this.w[e]=Math.floor(t/3),o=t%3;return o},mod2m:function(t){var i,e,o;for(e=Math.floor(t/n.BASEBITS),o=(1<=0);for(;i>0;)t.fshr(1),e.copy(this),e.sub(t),e.norm(),this.cmove(e,1-(e.w[n.NLEN-1]>>n.CHUNK-1&1)),i--}},div:function(t){var i=0,e=0,o=new n(1),r=new n(0),s=new n(0);for(this.norm(),r.copy(this),this.zero();n.comp(r,t)>=0;)o.fshl(1),t.fshl(1),i++;for(;i>0;)t.fshr(1),o.fshr(1),s.copy(r),s.sub(t),s.norm(),e=1-(s.w[n.NLEN-1]>>n.CHUNK-1&1),r.cmove(s,e),s.copy(this),s.add(o),s.norm(),this.cmove(s,e),i--},parity:function(){return this.w[0]%2},bit:function(t){return(this.w[Math.floor(t/n.BASEBITS)]&1<0?1:0},lastbits:function(t){var n=(1<>n.BASEBITS&&(i=!1);return i},jacobi:function(t){var i,e,o=0,r=new n(0),s=new n(0),h=new n(0),c=new n(0),u=new n(1);if(0===t.parity()||0===n.comp(this,c)||n.comp(t,u)<=0)return 0;for(this.norm(),s.copy(this),h.copy(t),s.mod(t);n.comp(h,u)>0;){if(0===n.comp(s,c))return 0;for(i=h.lastbits(3),e=0;0===s.parity();)e++,s.shr(1);e%2==1&&(o+=(i*i-1)/8),o+=(i-1)*(s.lastbits(2)-1)/4,r.copy(h),r.mod(s),h.copy(s),s.copy(r),o%=2}return 0===o?1:-1},invmodp:function(t){var i=new n(0),e=new n(0),o=new n(1),r=new n(0),s=new n(0),h=new n(1);for(this.mod(t),i.copy(this),e.copy(t);0!==n.comp(i,h)&&0!==n.comp(e,h);){for(;0===i.parity();)i.fshr(1),0!==o.parity()&&(o.add(t),o.norm()),o.fshr(1);for(;0===e.parity();)e.fshr(1),0!==r.parity()&&(r.add(t),r.norm()),r.fshr(1);n.comp(i,e)>=0?(i.sub(e),i.norm(),n.comp(o,r)>=0?o.sub(r):(s.copy(t),s.sub(r),o.add(s)),o.norm()):(e.sub(i),e.norm(),n.comp(r,o)>=0?r.sub(o):(s.copy(t),s.sub(o),r.add(s)),r.norm())}0===n.comp(i,h)?this.copy(o):this.copy(r)},powmod:function(t,i){var e,o=new n(1),r=new n(0),s=new n(0);for(this.norm(),t.norm(),r.copy(t),s.copy(this);e=r.parity(),r.fshr(1),1==e&&(o=n.modmul(o,s,i)),!r.iszilch();)s=n.modsqr(s,i);return o}},n.frombytearray=function(t,i){var e,o=new n(0);for(e=0;e=0;e--)if(t.w[e]!=i.w[e])return t.w[e]>i.w[e]?1:-1;return 0},n.random=function(t){var i,e,o=new n(0),r=0,s=0;for(i=0;i<8*n.MODBYTES;i++)0===r?s=t.getByte():s>>=1,e=1&s,o.shl(1),o.w[0]+=e,r++,r&=7;return o},n.randomnum=function(n,i){var e,o,r=new t.DBIG(0),s=0,h=0;for(e=0;e<2*n.nbits();e++)0===s?h=i.getByte():h>>=1,o=1&h,r.shl(1),r.w[0]+=o,s++,s&=7;return r.mod(n)},n.mul=function(i,e){var o,r,s,h,c,u,a=new t.DBIG(0),f=[];for(h=0;h=1+Math.floor(c/2);h--)s+=(i.w[h]-i.w[c-h])*(e.w[c-h]-e.w[h]);a.w[c]=s}for(c=n.NLEN;c<2*n.NLEN-1;c++){for(s=r-=f[c-n.NLEN],h=n.NLEN-1;h>=1+Math.floor(c/2);h--)s+=(i.w[h]-i.w[c-h])*(e.w[c-h]-e.w[h]);a.w[c]=s}for(u=0,h=0;h>1;s++)o+=i.w[r-s]*i.w[s];for(o+=o,c.w[r]=o,r++,o=i.w[r]*i.w[0],s=1;s>1;s++)o+=i.w[r-s]*i.w[s];o+=o,o+=i.w[r>>1]*i.w[r>>1],c.w[r]=o,r++}for(r=n.NLEN-1+n.NLEN%2;r>1;s++)o+=i.w[r-s]*i.w[s];for(o+=o,c.w[r]=o,r++,o=i.w[n.NLEN-1]*i.w[r-n.NLEN+1],s=r-n.NLEN+2;s>1;s++)o+=i.w[r-s]*i.w[s];o+=o,o+=i.w[r>>1]*i.w[r>>1],c.w[r]=o,r++}for(o=i.w[n.NLEN-2]*i.w[n.NLEN-1],o+=o,c.w[n.DNLEN-3]=o,o=i.w[n.NLEN-1]*i.w[n.NLEN-1],c.w[n.DNLEN-2]=o,h=0,s=0;sMath.floor(c/2);h--)s+=(a[c-h]-a[h])*(t.w[h]-t.w[c-h]);a[c]=(s&n.BMASK)*i&n.BMASK,r=(s+=a[c]*t.w[0])*n.MODINV+e.w[c+1],f[c]=a[c]*t.w[c],o+=f[c]}for(c=n.NLEN;c<2*n.NLEN-1;c++){for(s=r+o,h=n.NLEN-1;h>=1+Math.floor(c/2);h--)s+=(a[c-h]-a[h])*(t.w[h]-t.w[c-h]);u.w[c-n.NLEN]=s&n.BMASK,r=(s-u.w[c-n.NLEN])*n.MODINV+e.w[c+1],o-=f[c-n.NLEN+1]}return u.w[n.NLEN-1]=r&n.BMASK,u},n.modmul=function(t,i,e){return t.mod(e),i.mod(e),n.mul(t,i).mod(e)},n.modsqr=function(t,i){return t.mod(i),n.sqr(t).mod(i)},n.modneg=function(t,n){return t.mod(n),n.minus(t)},n.invmod256=function(t){var n,i;return i=0,i+=t>>1&1,i=2-(i&=1),i=(n=1+(i<<=1))*(3&t),i>>=2,i+=n*(t>>2&3)&3,i*=n,i=4-(i&=3),i=(n+=i<<=2)*(15&t),i>>=4,i+=n*(t>>4&15)&15,i*=n,n+((i=16-(i&=15))<<4)},n}(h),h.DBIG=function(t){var n=function(t){this.w=[],this.zero(),this.w[0]=t};return n.prototype={zero:function(){for(var n=0;n>t.BIG.BASEBITS;return this.w[t.BIG.DNLEN-1]=this.w[t.BIG.DNLEN-1]+e,this},muladd:function(n,i,e,o){var r=n*i+e+this.w[o];return this.w[o]=r&t.BIG.BMASK,(r-this.w[o])*t.BIG.MODINV},shr:function(n){var i,e=n%t.BIG.BASEBITS,o=Math.floor(n/t.BIG.BASEBITS);for(i=0;i>e|this.w[o+i+1]<>e,i=t.BIG.DNLEN-o;i>t.BIG.BASEBITS-e,i=t.BIG.DNLEN-2;i>o;i--)this.w[i]=this.w[i-o]<>t.BIG.BASEBITS-e;for(this.w[o]=this.w[0]<=0&&0===this.w[e];)e--;if(e<0)return 0;for(n=t.BIG.BASEBITS*e,i=this.w[e];0!==i;)i=Math.floor(i/2),n++;return n},toString:function(){var t,i,e="",o=this.nbits();for(o%4==0?o=Math.floor(o/4):(o=Math.floor(o/4),o++),i=o-1;i>=0;i--)(t=new n(0)).copy(this),t.shr(4*i),e+=(15&t.w[0]).toString(16);return e},mod:function(i){var e=0,o=new n(0),r=new n(0),s=new t.BIG(0);if(this.norm(),o.hcopy(i),s.hcopy(this),n.comp(this,o)<0)return s;do{o.shl(1),e++}while(n.comp(this,o)>=0);for(;e>0;)o.shr(1),r.copy(this),r.sub(o),r.norm(),this.cmove(r,1-(r.w[t.BIG.DNLEN-1]>>t.BIG.CHUNK-1&1)),e--;return s.hcopy(this),s},div:function(i){var e=0,o=0,r=new n(0),s=new n(0),h=new t.BIG(0),c=new t.BIG(0),u=new t.BIG(1);for(r.hcopy(i),this.norm();n.comp(this,r)>=0;)u.fshl(1),r.shl(1),o++;for(;o>0;)r.shr(1),u.shr(1),s.copy(this),s.sub(r),s.norm(),e=1-(s.w[t.BIG.DNLEN-1]>>t.BIG.CHUNK-1&1),this.cmove(s,e),h.copy(c),h.add(u),h.norm(),c.cmove(h,e),o--;return c},split:function(n){var i,e,o=new t.BIG(0),r=n%t.BIG.BASEBITS,s=this.w[t.BIG.DNLEN-1]<=t.BIG.NLEN-1;e--)i=this.w[e]>>r|s,s=this.w[e]<=0;e--)if(n.w[e]!=i.w[e])return n.w[e]>i.w[e]?1:-1;return 0},n}(h),void 0!==h.config.TFF?(h.FF=function(t){var n=function(n){this.v=new Array(n),this.length=n;for(var i=0;i>n.P_TBITS)},zero:function(){for(var t=0;t>t.BIG.BASEBITS)},copy:function(t){for(var n=0;n0;t--)i=this.v[t].fshr(1),this.v[t-1].ortop(i<=0;t--)n+=this.v[t].toString();return n},toBytes:function(n){var i;for(i=0;i=0);for(;i>0;)t.shr(),n.comp(this,t)>=0&&(this.sub(t),this.norm()),i--}},reduce:function(t,i){var e=t.length,o=new n(2*e),r=new n(e),s=new n(e);return r.sducopy(this),s.karmul_lower(0,this,0,i,0,o,0,e),this.karmul_upper(t,s,o,e),s.sducopy(this),r.add(t),r.sub(s),r.norm(),r},dmod:function(i){var e,o=i.length,r=new n(2*o),s=new n(2*o),h=new n(o);for(s.copy(this),s.norm(),r.dsucopy(i),e=t.BIG.BIGBITS*o;n.comp(s,r)>=0;)s.sub(r),s.norm();for(;e>0;)r.shr(),n.comp(s,r)>=0&&(s.sub(r),s.norm()),e--;return h.copy(s),h.mod(i),h},invmodp:function(t){var i=t.length,e=new n(i),o=new n(i),r=new n(i),s=new n(i),h=new n(i),c=new n(i);for(c.one(),e.copy(this),o.copy(t),r.copy(c),s.zero();0!==n.comp(e,c)&&0!==n.comp(o,c);){for(;0===e.parity();)e.shr(),0!==r.parity()&&(r.add(t),r.norm()),r.shr();for(;0===o.parity();)o.shr(),0!==s.parity()&&(s.add(t),s.norm()),s.shr();n.comp(e,o)>=0?(e.sub(o),e.norm(),n.comp(r,s)>=0?r.sub(s):(h.copy(t),h.sub(s),r.add(h)),r.norm()):(o.sub(e),o.norm(),n.comp(s,r)>=0?s.sub(r):(h.copy(t),h.sub(r),s.add(h)),s.norm())}0===n.comp(e,c)?this.copy(r):this.copy(s)},nres:function(i){var e,o=i.length;1===o?((e=new t.DBIG(0)).hcopy(this.v[0]),e.shl(t.BIG.NLEN*t.BIG.BASEBITS),this.v[0].copy(e.mod(i.v[0]))):((e=new n(2*o)).dsucopy(this),this.copy(e.dmod(i)))},redc:function(i,e){var o,r=i.length;1===r?((o=new t.DBIG(0)).hcopy(this.v[0]),this.v[0].copy(t.BIG.monty(i.v[0],(1<=Math.floor((n.P_FEXCESS-1)/(h+1))&&this.mod(e),1===c?(r=t.BIG.mul(this.v[0],i.v[0]),this.v[0].copy(t.BIG.monty(e.v[0],(1<=Math.floor((n.P_FEXCESS-1)/(r+1))&&this.mod(i),1===i.length?(o=t.BIG.sqr(this.v[0]),this.v[0].copy(t.BIG.monty(i.v[0],(1<=0;o--)r=i.v[Math.floor(o/t.BIG.BIGBITS)].bit(o%t.BIG.BIGBITS),this.copy(h),this.modmul(c,e,u),n.cswap(h,c,r),h.modsqr(e,u),c.copy(this),n.cswap(h,c,r);this.copy(h),this.redc(e,u)},skspow:function(i,e){var o,r,s=e.length,h=new n(s),c=new n(s),u=e.invmod2m();for(this.mod(e),h.one(),c.copy(this),h.nres(e),c.nres(e),o=8*t.BIG.MODBYTES-1;o>=0;o--)r=i.bit(o),this.copy(h),this.modmul(c,e,u),n.cswap(h,c,r),h.modsqr(e,u),c.copy(this),n.cswap(h,c,r);this.copy(h),this.redc(e,u)},power:function(t,i){var e=i.length,o=!0,r=new n(e),s=i.invmod2m();if(r.copy(this),r.nres(i),2==t)this.copy(r),this.modsqr(i,s);else for(;t%2==1&&(o?this.copy(r):this.modmul(r,i,s),o=!1),0!=(t>>=1);)r.modsqr(i,s);this.redc(i,s)},pow:function(i,e){var o,r=e.length,s=new n(r),h=e.invmod2m();for(s.copy(this),this.one(),this.nres(e),s.nres(e),o=8*t.BIG.MODBYTES*r-1;o>=0;o--)this.modsqr(e,h),1===i.v[Math.floor(o/t.BIG.BIGBITS)].bit(o%t.BIG.BIGBITS)&&this.modmul(s,e,h);this.redc(e,h)},pow2:function(i,e,o,r){var s,h,c,u=r.length,a=new n(u),f=new n(u),E=new n(u),B=r.invmod2m();for(a.copy(this),f.copy(e),a.nres(r),f.nres(r),E.copy(a),E.modmul(f,r,B),this.one(),this.nres(r),s=8*t.BIG.MODBYTES-1;s>=0;s--)h=i.bit(s),c=o.bit(s),this.modsqr(r,B),1==h?1==c?this.modmul(E,r,B):this.modmul(a,r,B):1==c&&this.modmul(f,r,B);this.redc(r,B)},cfactor:function(t){var i,e=this.length,o=new n(e),r=new n(e);r.set(t),o.copy(this),o.norm();do{for(o.sub(r),o.norm();!o.iszilch()&&0===o.parity();)o.shr()}while(n.comp(o,r)>0);return i=o.v[0].get(0),n.igcd(t,i)>1}},n.comp=function(n,i){var e,o;for(e=n.length-1;e>=0;e--)if(0!==(o=t.BIG.comp(n.v[e],i.v[e])))return o;return 0},n.fromBytes=function(n,i){var e;for(e=0;e>>4&15).toString(16),e+=(15&n).toString(16);return e},bytestostring:function(t){var n,i="";for(n=0;n=0&&o.process_num(e),r=o.hash()):n==this.SHA384?(o=new t.HASH384,null!=i&&o.process_array(i),e>=0&&o.process_num(e),r=o.hash()):n==this.SHA512&&(o=new t.HASH512,null!=i&&o.process_array(i),e>=0&&o.process_num(e),r=o.hash()),r},KEY_PAIR:function(n,i,e,o){for(var r=o.n.length>>1,s=new t.FF(r),h=new t.FF(r),c=new t.FF(r);;){for(e.p.random(n);3!=e.p.lastbits(2);)e.p.inc(1);for(;!t.FF.prime(e.p,n);)e.p.inc(4);if(h.copy(e.p),h.dec(1),!h.cfactor(i))break}for(;;){for(e.q.random(n);3!=e.q.lastbits(2);)e.q.inc(1);for(;!t.FF.prime(e.q,n);)e.q.inc(4);if(c.copy(e.q),c.dec(1),!c.cfactor(i))break}o.n=t.FF.mul(e.p,e.q),o.e=i,s.copy(h),s.shr(),e.dp.set(i),e.dp.invmodp(s),0===e.dp.parity()&&e.dp.add(s),e.dp.norm(),s.copy(c),s.shr(),e.dq.set(i),e.dq.invmodp(s),0===e.dq.parity()&&e.dq.add(s),e.dq.norm(),e.c.copy(e.p),e.c.invmodp(e.q)},MGF1:function(t,n,i,e){var o,r,s,h=t,c=[],u=0;for(s=0;si)for(s=0;sa-r-s-1)return null;for(u=this.hashit(t,o,-1),c=0;c=1;c--)y[c]=y[c-1];for(c=0;c>=0;c--)y[c]=0;return y},OAEP_DECODE:function(t,i,e){var o,r,s,h,c,u,a,f,E,B,y=n.RFS-1,I=[],m=[],p=[];if(y<(s=r=t)+r+1)return null;for(a=0;a=u;a--)e[a]=e[a-u];for(a=u-1;a>=0;a--)e[a]=0}for(E=this.hashit(t,i,-1),a=0;a=y-s-r)return null;if(0!==p[f])break}if(c=p[f],!o||0!==h||1!=c){for(a=0;a0&&r.add(n.q),r.sub(o),r.norm(),r=(s=t.FF.mul(n.c,r)).dmod(n.q),s=t.FF.mul(r,n.p),c.add(s),c.norm(),c.toBytes(e)}};return n}(h),h.rsa_public_key=function(t){return function(n){this.e=0,this.n=new t.FF(n)}}(h),void(h.rsa_private_key=function(t){return function(n){this.p=new t.FF(n),this.q=new t.FF(n),this.dp=new t.FF(n),this.dq=new t.FF(n),this.c=new t.FF(n)}}(h))):void 0!==h.config.CURVE?(h.ROM_CURVE=e[h.config.CURVE],h.ROM_FIELD=o[h.config.FIELD],h.FP=function(t){var n=function(i){i instanceof n?(this.f=new t.BIG(i.f),this.XES=i.XES):(this.f=new t.BIG(i),this.nres())};return n.NOT_SPECIAL=0,n.PSEUDO_MERSENNE=1,n.GENERALISED_MERSENNE=2,n.MONTGOMERY_FRIENDLY=3,n.MODBITS=t.config["@NBT"],n.MOD8=t.config["@M8"],n.MODTYPE=t.config["@MT"],n.FEXCESS=1<n.FEXCESS&&this.reduce(),e=t.BIG.mul(this.f,i.f),this.f.copy(n.mod(e)),this.XES=2,this},imul:function(t){var i,e,o=!1;return t<0&&(t=-t,o=!0),n.MODTYPE==n.PSEUDO_MERSENNE||n.MODTYPE==n.GENERALISED_MERSENNE?(i=this.f.pxmul(t),this.f.copy(n.mod(i)),this.XES=2):this.XES*t<=n.FEXCESS?(this.f.pmul(t),this.XES*=t):(e=new n(t),this.mul(e)),o&&(this.neg(),this.norm()),this},sqr:function(){var i,e;return this.XES*this.XES>n.FEXCESS&&this.reduce(),i=t.BIG.sqr(this.f),e=n.mod(i),this.f.copy(e),this.XES=2,this},add:function(t){return this.f.add(t.f),this.XES+=t.XES,this.XES>n.FEXCESS&&this.reduce(),this},neg:function(){var i,e=new t.BIG(0);return e.rcopy(t.ROM_FIELD.Modulus),i=n.logb2(this.XES-1),e.fshl(i),this.XES=1<n.FEXCESS&&this.reduce(),this},sub:function(t){var i=new n(0);return i.copy(t),i.neg(),this.add(i),this},rsub:function(t){var i=new n(0);i.copy(this),i.neg(),this.copy(t),this.add(i)},div2:function(){var n;return 0===this.f.parity()||((n=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),this.f.add(n),this.f.norm()),this.f.fshr(1),this},inverse:function(){var n=new t.BIG(0);return n.rcopy(t.ROM_FIELD.Modulus),n.dec(2),n.norm(),this.copy(this.pow(n)),this},equals:function(n){return n.reduce(),this.reduce(),0===t.BIG.comp(n.f,this.f)},pow:function(i){var e,o,r,s,h=[],c=[],u=new t.BIG(i);for(u.norm(),o=1+Math.floor((u.nbits()+3)/4),e=0;e=0;e--)s.sqr(),s.sqr(),s.sqr(),s.sqr(),s.mul(c[h[e]]);return s.reduce(),s},jacobi:function(){var n=new t.BIG(0),i=this.redc();return n.rcopy(t.ROM_FIELD.Modulus),i.jacobi(n)},sqrt:function(){var i,e,o,r=new t.BIG(0);return this.reduce(),r.rcopy(t.ROM_FIELD.Modulus),5==n.MOD8?(r.dec(5),r.norm(),r.shr(3),(i=new n(0)).copy(this),i.f.shl(1),e=i.pow(r),i.mul(e),i.mul(e),i.f.dec(1),(o=new n(0)).copy(this),o.mul(e),o.mul(i),o.reduce(),o):(r.inc(1),r.norm(),r.shr(2),this.pow(r))}},n.logb2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},n.mod=function(i){var e,o,r,s,h,c,u,a,f,E=new t.BIG(0);if(n.MODTYPE==n.PSEUDO_MERSENNE)return o=i.split(n.MODBITS),E.hcopy(i),r=1!=t.ROM_FIELD.MConst?o.pmul(t.ROM_FIELD.MConst):0,o.add(E),o.norm(),s=o.w[t.BIG.NLEN-1],o.w[t.BIG.NLEN-1]&=n.TMASK,o.inc(t.ROM_FIELD.MConst*((s>>n.TBITS)+(r<>n.TBITS,E.w[t.BIG.NLEN-1]&=n.TMASK,E.w[0]+=u,E.w[Math.floor(224/t.BIG.BASEBITS)]+=u<<224%t.BIG.BASEBITS,E.norm()),n.MODTYPE==n.NOT_SPECIAL&&((a=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),E.copy(t.BIG.monty(a,t.ROM_FIELD.MConst,i))),E},n}(h),h.ECP=function(t){var n=function(){this.x=new t.FP(0),this.y=new t.FP(1),n.CURVETYPE!=n.EDWARDS?this.z=new t.FP(0):this.z=new t.FP(1)};return n.WEIERSTRASS=0,n.EDWARDS=1,n.MONTGOMERY=2,n.NOT=0,n.BN=1,n.BLS=2,n.D_TYPE=0,n.M_TYPE=1,n.POSITIVEX=0,n.NEGATIVEX=1,n.CURVETYPE=t.config["@CT"],n.CURVE_PAIRING_TYPE=t.config["@PF"],n.SEXTIC_TWIST=t.config["@ST"],n.SIGN_OF_X=t.config["@SX"],n.HASH_TYPE=t.config["@HT"],n.AESKEY=t.config["@AK"],n.prototype={is_infinity:function(){return this.x.reduce(),this.z.reduce(),n.CURVETYPE==n.EDWARDS?(this.y.reduce(),this.x.iszilch()&&this.y.equals(this.z)):n.CURVETYPE==n.WEIERSTRASS?(this.y.reduce(),this.x.iszilch()&&this.z.iszilch()):n.CURVETYPE!=n.MONTGOMERY||this.z.iszilch()},cswap:function(t,i){this.x.cswap(t.x,i),n.CURVETYPE!=n.MONTGOMERY&&this.y.cswap(t.y,i),this.z.cswap(t.z,i)},cmove:function(t,i){this.x.cmove(t.x,i),n.CURVETYPE!=n.MONTGOMERY&&this.y.cmove(t.y,i),this.z.cmove(t.z,i)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(i){var e,o;return e=new t.FP(0),o=new t.FP(0),e.copy(this.x),e.mul(i.z),e.reduce(),o.copy(i.x),o.mul(this.z),o.reduce(),!(!e.equals(o)||n.CURVETYPE!=n.MONTGOMERY&&(e.copy(this.y),e.mul(i.z),e.reduce(),o.copy(i.y),o.mul(this.z),o.reduce(),!e.equals(o)))},copy:function(t){this.x.copy(t.x),n.CURVETYPE!=n.MONTGOMERY&&this.y.copy(t.y),this.z.copy(t.z)},neg:function(){n.CURVETYPE==n.WEIERSTRASS?(this.y.neg(),this.y.norm()):n.CURVETYPE==n.EDWARDS&&(this.x.neg(),this.x.norm())},inf:function(){this.x.zero(),n.CURVETYPE!=n.MONTGOMERY&&this.y.one(),n.CURVETYPE!=n.EDWARDS?this.z.zero():this.z.one()},setxy:function(i,e){var o,r;this.x=new t.FP(0),this.x.bcopy(i),this.y=new t.FP(0),this.y.bcopy(e),this.z=new t.FP(1),o=n.RHS(this.x),n.CURVETYPE==n.MONTGOMERY?1!=o.jacobi()&&this.inf():((r=new t.FP(0)).copy(this.y),r.sqr(),r.equals(o)||this.inf())},setxi:function(i,e){var o,r;this.x=new t.FP(0),this.x.bcopy(i),o=n.RHS(this.x),this.z=new t.FP(1),1==o.jacobi()?((r=o.sqrt()).redc().parity()!=e&&r.neg(),this.y=r):this.inf()},setx:function(i){var e;this.x=new t.FP(0),this.x.bcopy(i),e=n.RHS(this.x),this.z=new t.FP(1),1==e.jacobi()?n.CURVETYPE!=n.MONTGOMERY&&(this.y=e.sqrt()):this.inf()},affine:function(){var i;this.is_infinity()||(i=new t.FP(1),this.z.equals(i)||(this.z.inverse(),n.CURVETYPE!=n.EDWARDS&&n.CURVETYPE!=n.WEIERSTRASS||(this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z=i),n.CURVETYPE==n.MONTGOMERY&&(this.x.mul(this.z),this.x.reduce(),this.z=i)))},getX:function(){return this.affine(),this.x.redc()},getY:function(){return this.affine(),this.y.redc()},getS:function(){return this.affine(),this.getY().parity()},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(i){var e,o=[];for(n.CURVETYPE!=n.MONTGOMERY?i[0]=4:i[0]=2,this.affine(),this.x.redc().toBytes(o),e=0;e>2),p.add(y),p.norm(),this.z.copy(p),this.z.mul(a))},add:function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,m,p,d;n.CURVETYPE==n.WEIERSTRASS&&(0==t.ROM_CURVE.CURVE_A?(e=3*t.ROM_CURVE.CURVE_B_I,(o=new t.FP(0)).copy(this.x),o.mul(i.x),(r=new t.FP(0)).copy(this.y),r.mul(i.y),(s=new t.FP(0)).copy(this.z),s.mul(i.z),(h=new t.FP(0)).copy(this.x),h.add(this.y),h.norm(),(c=new t.FP(0)).copy(i.x),c.add(i.y),c.norm(),h.mul(c),c.copy(o),c.add(r),h.sub(c),h.norm(),c.copy(this.y),c.add(this.z),c.norm(),(u=new t.FP(0)).copy(i.y),u.add(i.z),u.norm(),c.mul(u),u.copy(r),u.add(s),c.sub(u),c.norm(),u.copy(this.x),u.add(this.z),u.norm(),(a=new t.FP(0)).copy(i.x),a.add(i.z),a.norm(),u.mul(a),a.copy(o),a.add(s),a.rsub(u),a.norm(),u.copy(o),u.add(o),o.add(u),o.norm(),s.imul(e),(f=new t.FP(0)).copy(r),f.add(s),f.norm(),r.sub(s),r.norm(),a.imul(e),u.copy(a),u.mul(c),s.copy(h),s.mul(r),u.rsub(s),a.mul(o),r.mul(f),a.add(r),o.mul(h),f.mul(c),f.add(o),this.x.copy(u),this.x.norm(),this.y.copy(a),this.y.norm(),this.z.copy(f),this.z.norm()):((o=new t.FP(0)).copy(this.x),(r=new t.FP(0)).copy(this.y),(s=new t.FP(0)).copy(this.z),(h=new t.FP(0)).copy(this.x),(c=new t.FP(0)).copy(i.x),f=new t.FP(0),(a=new t.FP(0)).copy(i.x),(u=new t.FP(0)).copy(i.y),e=new t.FP(0),0==t.ROM_CURVE.CURVE_B_I&&e.rcopy(t.ROM_CURVE.CURVE_B),o.mul(i.x),r.mul(i.y),s.mul(i.z),h.add(this.y),h.norm(),c.add(i.y),c.norm(),h.mul(c),c.copy(o),c.add(r),h.sub(c),h.norm(),c.copy(this.y),c.add(this.z),c.norm(),u.add(i.z),u.norm(),c.mul(u),u.copy(r),u.add(s),c.sub(u),c.norm(),u.copy(this.x),u.add(this.z),u.norm(),a.add(i.z),a.norm(),u.mul(a),a.copy(o),a.add(s),a.rsub(u),a.norm(),f.copy(s),0==t.ROM_CURVE.CURVE_B_I?f.mul(e):f.imul(t.ROM_CURVE.CURVE_B_I),u.copy(a),u.sub(f),u.norm(),f.copy(u),f.add(u),u.add(f),f.copy(r),f.sub(u),f.norm(),u.add(r),u.norm(),0==t.ROM_CURVE.CURVE_B_I?a.mul(e):a.imul(t.ROM_CURVE.CURVE_B_I),r.copy(s),r.add(s),s.add(r),a.sub(s),a.sub(o),a.norm(),r.copy(a),r.add(a),a.add(r),a.norm(),r.copy(o),r.add(o),o.add(r),o.sub(s),o.norm(),r.copy(c),r.mul(a),s.copy(o),s.mul(a),a.copy(u),a.mul(f),a.add(s),u.mul(h),u.sub(r),f.mul(c),r.copy(h),r.mul(o),f.add(r),this.x.copy(u),this.x.norm(),this.y.copy(a),this.y.norm(),this.z.copy(f),this.z.norm())),n.CURVETYPE==n.EDWARDS&&((E=new t.FP(0)).copy(this.z),B=new t.FP(0),(y=new t.FP(0)).copy(this.x),(I=new t.FP(0)).copy(this.y),m=new t.FP(0),p=new t.FP(0),d=new t.FP(0),E.mul(i.z),B.copy(E),B.sqr(),y.mul(i.x),I.mul(i.y),m.copy(y),m.mul(I),0==t.ROM_CURVE.CURVE_B_I?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),m.mul(e)):m.imul(t.ROM_CURVE.CURVE_B_I),p.copy(B),p.sub(m),d.copy(B),d.add(m),1==t.ROM_CURVE.CURVE_A&&(m.copy(I),m.sub(y)),y.add(I),B.copy(this.x),B.add(this.y),I.copy(i.x),I.add(i.y),B.norm(),I.norm(),B.mul(I),B.sub(y),B.norm(),p.norm(),B.mul(p),this.x.copy(E),this.x.mul(B),d.norm(),1==t.ROM_CURVE.CURVE_A&&(m.norm(),y.copy(m),y.mul(d)),-1==t.ROM_CURVE.CURVE_A&&(y.norm(),y.mul(d)),this.y.copy(E),this.y.mul(y),this.z.copy(p),this.z.mul(d))},dadd:function(n,i){var e,o,r,s,h,c;(e=new t.FP(0)).copy(this.x),(o=new t.FP(0)).copy(this.x),(r=new t.FP(0)).copy(n.x),(s=new t.FP(0)).copy(n.x),h=new t.FP(0),c=new t.FP(0),e.add(this.z),o.sub(this.z),r.add(n.z),s.sub(n.z),s.norm(),e.norm(),h.copy(s),h.mul(e),r.norm(),o.norm(),c.copy(r),c.mul(o),e.copy(h),e.add(c),e.norm(),e.sqr(),o.copy(h),o.sub(c),o.norm(),o.sqr(),this.x.copy(e),this.z.copy(i.x),this.z.mul(o)},sub:function(t){t.neg(),this.add(t),t.neg()},pinmul:function(i,e){var o,r,s,h,c;if(n.CURVETYPE==n.MONTGOMERY)return this.mul(new t.BIG(i));for(s=new n,h=new n,(c=new n).copy(this),o=e-1;o>=0;o--)r=i>>o&1,s.copy(c),s.add(h),h.cswap(c,r),c.copy(s),h.dbl(),h.cswap(c,r);return s.copy(h),s.affine(),s},cfp:function(){var n=t.ROM_CURVE.CURVE_Cof_I,i=new t.BIG(0);if(1!=n){if(4==n)return this.dbl(),this.dbl(),void this.affine();if(8==n)return this.dbl(),this.dbl(),this.dbl(),void this.affine();i.rcopy(t.ROM_CURVE.CURVE_Cof),this.copy(this.mul(i))}},mul:function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,m,p;if(i.iszilch()||this.is_infinity())return new n;if(e=new n,n.CURVETYPE==n.MONTGOMERY){for(o=new n,(r=new n).copy(this),(s=new n).copy(this),s.dbl(),o.copy(this),o.affine(),B=(I=i.nbits())-2;B>=0;B--)y=i.bit(B),e.copy(s),e.dadd(r,o),r.cswap(s,y),s.copy(e),r.dbl(),r.cswap(s,y);e.copy(r)}else{for(h=new t.BIG,c=new t.BIG,u=new n,a=new n,f=[],E=[],this.affine(),u.copy(this),u.dbl(),f[0]=new n,f[0].copy(this),B=1;B<8;B++)f[B]=new n,f[B].copy(f[B-1]),f[B].add(u);for(c.copy(i),m=c.parity(),c.inc(1),c.norm(),p=c.parity(),h.copy(c),h.inc(1),h.norm(),c.cmove(h,m),u.cmove(this,p),a.copy(u),I=1+Math.floor((c.nbits()+3)/4),B=0;B=0;B--)u.select(f,E[B]),e.dbl(),e.dbl(),e.dbl(),e.dbl(),e.add(u);e.sub(a)}return e.affine(),e},mul2:function(i,e,o){var r,s,h,c,u,a,f=new t.BIG,E=new t.BIG,B=new t.BIG,y=new n,I=new n,m=new n,p=[],d=[];for(this.affine(),e.affine(),f.copy(i),E.copy(o),p[1]=new n,p[1].copy(this),p[1].sub(e),p[2]=new n,p[2].copy(this),p[2].add(e),y.copy(e),y.dbl(),p[0]=new n,p[0].copy(p[1]),p[0].sub(y),p[3]=new n,p[3].copy(p[2]),p[3].add(y),I.copy(this),I.dbl(),p[5]=new n,p[5].copy(p[1]),p[5].add(I),p[6]=new n,p[6].copy(p[2]),p[6].add(I),p[4]=new n,p[4].copy(p[5]),p[4].sub(y),p[7]=new n,p[7].copy(p[6]),p[7].add(y),s=f.parity(),f.inc(1),f.norm(),h=f.parity(),B.copy(f),B.inc(1),B.norm(),f.cmove(B,s),I.cmove(this,h),m.copy(I),s=E.parity(),E.inc(1),E.norm(),h=E.parity(),B.copy(E),B.inc(1),B.norm(),E.cmove(B,s),y.cmove(e,h),m.add(y),B.copy(f),B.add(E),B.norm(),c=1+Math.floor((B.nbits()+1)/2),r=0;r=0;r--)I.select(p,d[r]),y.dbl(),y.dbl(),y.add(I);return y.sub(m),y.affine(),y}},n.generator=function(){var i=new n,e=new t.BIG(0),o=new t.BIG(0);return e.rcopy(t.ROM_CURVE.CURVE_Gx),t.ECP.CURVETYPE!=t.ECP.MONTGOMERY?(o.rcopy(t.ROM_CURVE.CURVE_Gy),i.setxy(e,o)):i.setx(e),i},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.fromBytes=function(i){var e,o,r,s=[],h=new n,c=new t.BIG(0);for(c.rcopy(t.ROM_FIELD.Modulus),r=0;r=0)return h;if(4==i[0]){for(r=0;r=0||h.setxy(e,o),h}return h.setx(e),h},n.RHS=function(i){var e,o,r,s,h=new t.FP(0);return i.norm(),h.copy(i),h.sqr(),n.CURVETYPE==n.WEIERSTRASS?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),h.mul(i),-3==t.ROM_CURVE.CURVE_A&&((o=new t.FP(0)).copy(i),o.imul(3),o.neg(),o.norm(),h.add(o)),h.add(e)):n.CURVETYPE==n.EDWARDS?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),r=new t.FP(1),e.mul(h),e.sub(r),e.norm(),-1==t.ROM_CURVE.CURVE_A&&h.neg(),h.sub(r),h.norm(),e.inverse(),h.mul(e)):n.CURVETYPE==n.MONTGOMERY&&((s=new t.FP(0)).copy(h),s.mul(i),h.imul(t.ROM_CURVE.CURVE_A),h.add(s),h.add(i)),h.reduce(),h},n.mapit=function(i){var e=new t.BIG(0),o=t.BIG.fromBytes(i),r=new n;for(e.rcopy(t.ROM_FIELD.Modulus),o.mod(e);;){for(;n.CURVETYPE!=n.MONTGOMERY?r.setxi(o,0):r.setx(o),o.inc(1),o.norm(),r.is_infinity(););if(r.cfp(),!r.is_infinity())break}return r},n}(h),h.ECDH=function(t){return{INVALID_PUBLIC_KEY:-2,ERROR:-3,INVALID:-4,EFS:t.BIG.MODBYTES,EGS:t.BIG.MODBYTES,SHA256:32,SHA384:48,SHA512:64,inttobytes:function(t,n){var i,e=[];for(i=0;i0&&i>0;)e[--i]=255&t,t=Math.floor(t/256);return e},bytestostring:function(t){var n,i,e="",o=t.length;for(i=0;i0&&h.process_num(e),null!=o&&h.process_array(o),0==(s=h.hash()).length)return null;if(0==r)return s;if(c=[],n>=r)for(u=0;ui)for(r=0;re)for(s=0;s32&&(c=128),o=new Array(c),s<4)return 0;for(r=0;rc)for(h=this.hashit(t,i,0,null,0),r=0;r=i.length){r=!0;break}o=i[E++]}if(u.decrypt(a),r)break;for(c=0;c<16;c++)f[B++]=a[c]}if(u.end(),s=!1,h=a[15],(15!=c||h<1||h>16)&&(s=!0),h>=2&&h<=16)for(c=16-h;c<16;c++)a[c]!=h&&(s=!0);if(!s)for(c=0;c<16-h;c++)f[B++]=a[c];if(e=[],s)return e;for(c=0;c=0||a.iszilch()||t.BIG.comp(a,h)>=0)&&(I=this.INVALID),0===I&&(a.invmodp(h),c=t.BIG.modmul(c,a,h),f=t.BIG.modmul(u,a,h),(B=t.ECP.fromBytes(i)).is_infinity()?I=this.ERROR:((y=new t.ECP).copy(B),(y=y.mul2(f,E,c)).is_infinity()?I=this.INVALID:((a=y.getX()).mod(h),0!==t.BIG.comp(a,u)&&(I=this.INVALID)))),I},ECIES_ENCRYPT:function(n,i,e,o,r,s,h,c){var u,a,f,E,B=[],y=[],I=[],m=[],p=[],d=[];if(0!==this.KEY_PAIR_GENERATE(o,p,h))return d;if(0!==this.ECPSVDP_DH(p,r,B))return d;for(E=0;E<2*this.EFS+1;E++)y[E]=h[E];for(E=0;E>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP4(this.a),i=new t.FP4(this.c),e=new t.FP4(this.b),o=new t.FP4(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP4(this.a),i=new t.FP4(this.b),e=new t.FP4(this.c),o=new t.FP4(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP4(this.a),e=new t.FP4(0),o=new t.FP4(this.b),r=new t.FP4(0),s=new t.FP4(this.a),h=new t.FP4(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP4(this.a),r=new t.FP4(this.b),s=new t.FP4(this.b),h=new t.FP4(0),c=new t.FP4(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP4(this.a),o=new t.FP4(0),r=new t.FP4(0),s=new t.FP4(0),h=new t.FP4(this.a),c=new t.FP4(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP4(this.a),i=new t.FP4(this.b),e=new t.FP4(this.a),o=new t.FP4(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n){var i=new t.FP2(n),e=new t.FP2(n);i.sqr(),e.mul(i),this.a.frob(e),this.b.frob(e),this.c.frob(e),this.b.pmul(n),this.c.pmul(i)},trace:function(){var n=new t.FP4(0);return n.copy(this.a),n.imul(3),n.reduce(),n},toString:function(){return"["+this.a.toString()+","+this.b.toString()+","+this.c.toString()+"]"},toBytes:function(n){var i,e=[];for(this.a.geta().getA().toBytes(e),i=0;i=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),m=E.trace(),B=B.xtr_pow2(y,I,m,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f=[];for(e=0;e>31&1},n.pow4=function(i,e){var o,r,s,h,c,u,a=[],f=new n(0),E=new n(0),B=[],y=new t.BIG(0),I=[],m=[];for(o=0;o<4;o++)B[o]=new t.BIG(e[o]),B[o].norm();for(a[0]=new n(i[0]),a[1]=new n(a[0]),a[1].mul(i[1]),a[2]=new n(a[0]),a[2].mul(i[2]),a[3]=new n(a[1]),a[3].mul(i[2]),a[4]=new n(i[0]),a[4].mul(i[3]),a[5]=new n(a[1]),a[5].mul(i[3]),a[6]=new n(a[2]),a[6].mul(i[3]),a[7]=new n(a[3]),a[7].mul(i[3]),u=1-B[0].parity(),B[0].inc(u),B[0].norm(),y.zero(),o=0;o<4;o++)y.or(B[o]);for(m[(h=1+y.nbits())-1]=1,o=0;o>1),B[r].norm(),I[o]+=c*s,s*=2;for(E.select(a,2*I[h-1]+1),o=h-2;o>=0;o--)E.usqr(),f.select(a,2*I[o]+m[o]),E.mul(f);return f.copy(i[0]),f.conj(),f.mul(E),E.cmove(f,u),E.reduce(),E},n}(h),h.ECP2=function(t){var n=function(){this.x=new t.FP2(0),this.y=new t.FP2(1),this.z=new t.FP2(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e,o,r=new n;o=((o=(i^(e=i>>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.neg(),this.cmove(r,1&e)},equals:function(n){var i,e;return(i=new t.FP2(0)).copy(this.x),(e=new t.FP2(0)).copy(n.x),i.copy(this.x),i.mul(n.z),i.reduce(),e.copy(n.x),e.mul(this.z),e.reduce(),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),i.reduce(),e.copy(n.y),e.mul(this.z),e.reduce(),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP2(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o=new n,r=new t.BIG(0),s=new t.BIG(0);return r.rcopy(t.ROM_CURVE.CURVE_Pxa),s.rcopy(t.ROM_CURVE.CURVE_Pxb),(i=new t.FP2(0)).bset(r,s),r.rcopy(t.ROM_CURVE.CURVE_Pya),s.rcopy(t.ROM_CURVE.CURVE_Pyb),(e=new t.FP2(0)).bset(r,s),o.setxy(i,e),o},n.fromBytes=function(i){var e,o,r,s,h,c,u=[];for(r=0;r>1),y[r].norm(),I[o]+=c*s,s*=2;for(f.select(E,2*I[h-1]+1),o=h-2;o>=0;o--)f.dbl(),a.select(E,2*I[o]+m[o]),f.add(a);return a.copy(f),a.sub(i[0]),f.cmove(a,u),f.affine(),f},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E=new t.BIG(0),B=new t.BIG(0);for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);u=new t.FP2(r,o),(s=new n).setx(u),s.is_infinity();)o.inc(1),o.norm();return E.rcopy(t.ROM_FIELD.Fra),B.rcopy(t.ROM_FIELD.Frb),u=new t.FP2(E,B),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(u.inverse(),u.norm()),(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&((h=new n).copy(s),h=h.mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&h.neg(),(c=new n).copy(h),c.dbl(),c.add(h),c.frob(u),s.frob(u),s.frob(u),s.frob(u),s.add(h),s.add(c),h.frob(u),h.frob(u),s.add(h)),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BLS&&(f=(a=s.mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&a.neg(),f.sub(a),f.sub(s),a.sub(s),a.frob(u),s.dbl(),s.frob(u),s.frob(u),s.add(f),s.add(a)),s.affine(),s},n}(h),h.PAIR=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,m=new t.FP12(1),p=new t.FP4(0);return n==i?(r=new t.FP2(n.getx()),s=new t.FP2(n.gety()),h=new t.FP2(n.getz()),(c=new t.FP2(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.pmul(o),r.imul(6),r.pmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_ip2(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.mul_ip(),h.add(h),c.mul_ip(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP4(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP4(r),p=new t.FP4(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP4(0),(p=new t.FP4(r)).times_i()),n.dbl()):(a=new t.FP2(n.getx()),f=new t.FP2(n.gety()),E=new t.FP2(n.getz()),B=new t.FP2(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.pmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.mul_ip(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.pmul(e),f.neg(),f.norm(),y=new t.FP4(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP4(f),p=new t.FP4(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP4(0),(p=new t.FP4(f)).times_i()),n.add(i)),m.set(y,I,p),m},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m,p;for((h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),c=new t.BIG(h),a=new t.ECP2,t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?((o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(s.inverse(),s.norm()),c.pmul(6),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX?c.inc(2):c.dec(2)):c.copy(h),c.norm(),(u=new t.BIG(c)).pmul(3),u.norm(),E=new t.FP(e.getx()),B=new t.FP(e.gety()),y=new t.ECP2,I=new t.FP12(1),y.copy(i),p=u.nbits()-2;p>=1;p--)I.sqr(),f=n.line(y,y,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),1==(m=u.bit(p)-c.bit(p))&&(f=n.line(y,i,E,B),I.smul(f,t.ECP.SEXTIC_TWIST)),-1==m&&(i.neg(),f=n.line(y,i,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&I.conj(),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&(t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&y.neg(),a.copy(i),a.frob(s),f=n.line(y,a,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),a.frob(s),a.neg(),f=n.line(y,a,E,B),I.smul(f,t.ECP.SEXTIC_TWIST)),I},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,m,p,d,l,w,_,S;for((u=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),a=new t.BIG(u),E=new t.ECP2,t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?((s=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),c=new t.FP2(s,h),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(c.inverse(),c.norm()),a.pmul(6),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX?a.inc(2):a.dec(2)):a.copy(u),a.norm(),(f=new t.BIG(a)).pmul(3),f.norm(),y=new t.FP(e.getx()),I=new t.FP(e.gety()),m=new t.FP(r.getx()),p=new t.FP(r.gety()),d=new t.ECP2,l=new t.ECP2,w=new t.FP12(1),d.copy(i),l.copy(o),S=f.nbits()-2;S>=1;S--)w.sqr(),B=n.line(d,d,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),B=n.line(l,l,m,p),w.smul(B,t.ECP.SEXTIC_TWIST),1==(_=f.bit(S)-a.bit(S))&&(B=n.line(d,i,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),B=n.line(l,o,m,p),w.smul(B,t.ECP.SEXTIC_TWIST)),-1==_&&(i.neg(),B=n.line(d,i,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),B=n.line(l,o,m,p),w.smul(B,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&w.conj(),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&(t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(d.neg(),l.neg()),E.copy(i),E.frob(c),B=n.line(d,E,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),E.frob(c),E.neg(),B=n.line(d,E,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),E.copy(o),E.frob(c),B=n.line(l,E,m,p),w.smul(B,t.ECP.SEXTIC_TWIST),E.frob(c),E.neg(),B=n.line(l,E,m,p),w.smul(B,t.ECP.SEXTIC_TWIST)),w},fexp:function(n){var i,e,o,r,s,h,c,u,a,f,E,B,y,I,m,p;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP12(n),(h=new t.FP12(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o),s.frob(o),s.mul(h),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?(h.copy(s),h.frob(o),(c=new t.FP12(h)).frob(o),h.mul(s),c.mul(h),c.frob(o),(u=new t.FP12(s)).conj(),E=s.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&E.conj(),(f=new t.FP12(E)).frob(o),a=E.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&a.conj(),(B=new t.FP12(a)).conj(),h=a.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&h.conj(),a.frob(o),s.copy(a),s.conj(),E.mul(s),a.frob(o),s.copy(h),s.frob(o),h.mul(s),h.usqr(),h.mul(E),h.mul(B),s.copy(f),s.mul(B),s.mul(h),h.mul(a),s.usqr(),s.mul(h),s.usqr(),h.copy(s),h.mul(u),s.mul(c),h.usqr(),s.mul(h),s.reduce()):((y=new t.FP12(s)).usqr(),I=y.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&I.conj(),r.fshr(1),m=I.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),r.fshl(1),(p=new t.FP12(s)).conj(),I.mul(p),I.conj(),I.mul(m),m=I.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),p=m.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&p.conj(),I.conj(),p.mul(I),I.conj(),I.frob(o),I.frob(o),I.frob(o),m.frob(o),m.frob(o),I.mul(m),m=p.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),m.mul(y),m.mul(s),I.mul(m),m.copy(p),m.frob(o),I.mul(m),s.copy(I),s.reduce()),s},glv:function(n){var i,e,o,r,s,h,c,u,a=[];if(t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN){for(i=new t.BIG(0),o=[],(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),c=0;c<2;c++)i.rcopy(t.ROM_CURVE.CURVE_W[c]),r=t.BIG.mul(i,n),o[c]=new t.BIG(r.div(e)),a[c]=new t.BIG(0);for(a[0].copy(n),c=0;c<2;c++)for(u=0;u<2;u++)i.rcopy(t.ROM_CURVE.CURVE_SB[u][c]),i.copy(t.BIG.modmul(o[u],i,e)),a[c].add(e),a[c].sub(i),a[c].mod(e)}else(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=t.BIG.smul(s,s),a[0]=new t.BIG(n),a[0].mod(h),a[1]=new t.BIG(n),a[1].div(h),a[1].rsub(e);return a},gs:function(n){var i,e,o,r,s,h,c,u,a=[];if(t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN){for(o=new t.BIG(0),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),s=[],i=0;i<4;i++)o.rcopy(t.ROM_CURVE.CURVE_WB[i]),h=t.BIG.mul(o,n),s[i]=new t.BIG(h.div(r)),a[i]=new t.BIG(0);for(a[0].copy(n),i=0;i<4;i++)for(e=0;e<4;e++)o.rcopy(t.ROM_CURVE.CURVE_BB[e][i]),o.copy(t.BIG.modmul(s[e],o,r)),a[i].add(r),a[i].sub(o),a[i].mod(r)}else{for((c=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),u=new t.BIG(n),i=0;i<3;i++)a[i]=new t.BIG(u),a[i].mod(c),u.div(c);a[3]=new t.BIG(u),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(a[1].copy(t.BIG.modneg(a[1],r)),a[3].copy(t.BIG.modneg(a[3],r)))}return a},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,m=0,p=[];if(0==n?y=c:(y=u,c=null),0!=(m=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return m;if(p=y.slice(),void 0!==B||null!=B)for(I=0;I>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP8(this.a),i=new t.FP8(this.c),e=new t.FP8(this.b),o=new t.FP8(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP8(this.a),i=new t.FP8(this.b),e=new t.FP8(this.c),o=new t.FP8(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP8(this.a),e=new t.FP8(0),o=new t.FP8(this.b),r=new t.FP8(0),s=new t.FP8(this.a),h=new t.FP8(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP8(this.a),r=new t.FP8(this.b),s=new t.FP8(this.b),h=new t.FP8(0),c=new t.FP8(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP8(this.a),o=new t.FP8(0),r=new t.FP8(0),s=new t.FP8(0),h=new t.FP8(this.a),c=new t.FP8(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP8(this.a),i=new t.FP8(this.b),e=new t.FP8(this.a),o=new t.FP8(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n,i){var e,o=new t.FP2(n),r=new t.FP2(n);for(o.sqr(),r.mul(o),r.mul_ip(),r.norm(),e=0;e=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s,1),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),m=E.trace(),B=B.xtr_pow2(y,I,m,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B=[];for(e=0;e>31&1},n.pow8=function(i,e){var o,r,s,h,c,u,a,f,E=[],B=[],y=new n(0),I=new n(0),m=[],p=new t.BIG(0),d=new t.BIG(0),l=new t.BIG(0),w=[],_=[],S=[],P=[];for(o=0;o<8;o++)m[o]=new t.BIG(e[o]),m[o].norm();for(E[0]=new n(i[0]),E[1]=new n(E[0]),E[1].mul(i[1]),E[2]=new n(E[0]),E[2].mul(i[2]),E[3]=new n(E[1]),E[3].mul(i[2]),E[4]=new n(i[0]),E[4].mul(i[3]),E[5]=new n(E[1]),E[5].mul(i[3]),E[6]=new n(E[2]),E[6].mul(i[3]),E[7]=new n(E[3]),E[7].mul(i[3]),d.rcopy(t.ROM_FIELD.Fra),l.rcopy(t.ROM_FIELD.Frb),f=new t.FP2(d,l),o=0;o<8;o++)B[o]=new n(E[o]),B[o].frob(f,4);for(u=1-m[0].parity(),m[0].inc(u),m[0].norm(),a=1-m[4].parity(),m[4].inc(a),m[4].norm(),p.zero(),o=0;o<8;o++)p.or(m[o]);for(_[(h=1+p.nbits())-1]=1,P[h-1]=1,o=0;o>1),m[r].norm(),w[o]+=c*s,s*=2;for(S[o]=0,s=1,r=5;r<8;r++)c=P[o]*m[r].parity(),m[r].fshr(1),m[r].dec(c>>1),m[r].norm(),S[o]+=c*s,s*=2}for(I.select(E,2*w[h-1]+1),y.select(B,2*S[h-1]+1),I.mul(y),o=h-2;o>=0;o--)I.usqr(),y.select(E,2*w[o]+_[o]),I.mul(y),y.select(B,2*S[o]+P[o]),I.mul(y);return y.copy(i[0]),y.conj(),y.mul(I),I.cmove(y,u),y.copy(i[4]),y.conj(),y.mul(I),I.cmove(y,a),I.reduce(),I},n}(h),h.ECP4=function(t){var n=function(){this.x=new t.FP4(0),this.y=new t.FP4(1),this.z=new t.FP4(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(n){var i,e;return i=new t.FP4(this.x),e=new t.FP4(n.x),i.mul(n.z),e.mul(this.z),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),e.copy(n.y),e.mul(this.z),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP4(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.geta().getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o,r,s,h,c=new n,u=new t.BIG(0),a=new t.BIG(0);return u.rcopy(t.ROM_CURVE.CURVE_Pxaa),a.rcopy(t.ROM_CURVE.CURVE_Pxab),i=new t.FP2(u,a),u.rcopy(t.ROM_CURVE.CURVE_Pxba),a.rcopy(t.ROM_CURVE.CURVE_Pxbb),e=new t.FP2(u,a),o=new t.FP4(i,e),u.rcopy(t.ROM_CURVE.CURVE_Pyaa),a.rcopy(t.ROM_CURVE.CURVE_Pyab),r=new t.FP2(u,a),u.rcopy(t.ROM_CURVE.CURVE_Pyba),a.rcopy(t.ROM_CURVE.CURVE_Pybb),s=new t.FP2(u,a),h=new t.FP4(r,s),c.setxy(o,h),c},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f=[];for(h=0;h>1),m[r].norm(),p[o]+=c*s,s*=2;for(l[o]=0,s=1,r=5;r<8;r++)c=w[o]*m[r].parity(),m[r].fshr(1),m[r].dec(c>>1),m[r].norm(),l[o]+=c*s,s*=2}for(E.select(B,2*p[h-1]+1),f.select(y,2*l[h-1]+1),E.add(f),o=h-2;o>=0;o--)E.dbl(),f.select(B,2*p[o]+d[o]),E.add(f),f.select(y,2*l[o]+w[o]),E.add(f);return f.copy(E),f.sub(i[0]),E.cmove(f,u),f.copy(E),f.sub(i[4]),E.cmove(f,a),E.affine(),E},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E,B=n.frob_constants();for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);c=new t.FP2(r,o),h=new t.FP4(c),(s=new n).setx(h),s.is_infinity();)o.inc(1),o.norm();return(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),E=(f=(a=(u=s.mul(o)).mul(o)).mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(u.neg(),f.neg()),E.sub(f),E.sub(s),f.sub(a),f.frob(B,1),a.sub(u),a.frob(B,2),u.sub(s),u.frob(B,3),s.dbl(),s.frob(B,4),s.add(E),s.add(f),s.add(a),s.add(u),s.affine(),s},n.frob_constants=function(){var n,i,e,o,r=new t.BIG(0),s=new t.BIG(0),h=[];return r.rcopy(t.ROM_FIELD.Fra),s.rcopy(t.ROM_FIELD.Frb),n=new t.FP2(r,s),(i=new t.FP2(n)).sqr(),(o=new t.FP2(i)).mul_ip(),o.norm(),(e=new t.FP2(o)).sqr(),o.mul(e),e.copy(n),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(e.mul_ip(),e.inverse(),i.copy(e),i.sqr()),i.mul_ip(),i.norm(),e.mul(i),h[0]=new t.FP2(i),h[1]=new t.FP2(e),h[2]=new t.FP2(o),h},n}(h),h.PAIR192=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,m,p=new t.FP24(1);return n==i?(r=new t.FP4(n.getx()),s=new t.FP4(n.gety()),h=new t.FP4(n.getz()),(c=new t.FP4(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.qmul(o),r.imul(6),r.qmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_2i(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.times_i(),h.add(h),c.times_i(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP8(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP8(r),m=new t.FP8(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP8(0),(m=new t.FP8(r)).times_i()),n.dbl()):(a=new t.FP4(n.getx()),f=new t.FP4(n.gety()),E=new t.FP4(n.getz()),B=new t.FP4(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.qmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.times_i(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.qmul(e),f.neg(),f.norm(),y=new t.FP8(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP8(f),m=new t.FP8(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP8(0),(m=new t.FP8(f)).times_i()),n.add(i)),p.set(y,I,m),p},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B;for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),r=new t.BIG(o),(s=new t.BIG(r)).pmul(3),s.norm(),c=new t.FP(e.getx()),u=new t.FP(e.gety()),a=new t.ECP4,f=new t.FP24(1),a.copy(i),B=s.nbits()-2;B>=1;B--)f.sqr(),h=n.line(a,a,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),1==(E=s.bit(B)-r.bit(B))&&(h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST)),-1==E&&(i.neg(),h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&f.conj(),f},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,m,p,d;for((s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=new t.BIG(s),(c=new t.BIG(h)).pmul(3),c.norm(),a=new t.FP(e.getx()),f=new t.FP(e.gety()),E=new t.FP(r.getx()),B=new t.FP(r.gety()),y=new t.ECP4,I=new t.ECP4,m=new t.FP24(1),y.copy(i),I.copy(o),d=c.nbits()-2;d>=1;d--)m.sqr(),u=n.line(y,y,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,I,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),1==(p=c.bit(d)-h.bit(d))&&(u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST)),-1==p&&(i.neg(),u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),m},fexp:function(n){var i,e,o,r,s,h,c,u,a,f,E,B,y,I;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP24(n),(h=new t.FP24(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o,4),s.mul(h),(I=new t.FP24(s)).usqr(),u=I.pow(r),r.fshr(1),a=u.pow(r),r.fshl(1),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&u.conj(),(f=new t.FP24(u)).conj(),a.mul(f),a.mul(s),B=(E=(f=a.pow(r)).pow(r)).pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(f.conj(),B.conj()),f.frob(o,6),E.frob(o,5),f.mul(E),y=B.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&y.conj(),B.frob(o,4),f.mul(B),(c=new t.FP24(a)).conj(),y.mul(c),B.copy(y),B.frob(o,3),f.mul(B),B=y.pow(r),y=B.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&B.conj(),c.copy(B),c.frob(o,2),f.mul(c),c.copy(y),c.frob(o,1),f.mul(c),B=y.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&B.conj(),a.frob(o,7),B.mul(I),f.mul(a),f.mul(B),s.mul(f),s.reduce(),s},glv:function(n){var i,e,o,r=[];return(i=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),o=t.BIG.smul(e,e),e=t.BIG.smul(o,o),r[0]=new t.BIG(n),r[0].mod(e),r[1]=new t.BIG(n),r[1].div(e),r[1].rsub(i),r},gs:function(n){var i,e,o,r,s=[];for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),r=new t.BIG(n),i=0;i<7;i++)s[i]=new t.BIG(r),s[i].mod(o),r.div(o);return s[7]=new t.BIG(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(s[1].copy(t.BIG.modneg(s[1],e)),s[3].copy(t.BIG.modneg(s[3],e)),s[5].copy(t.BIG.modneg(s[5],e)),s[7].copy(t.BIG.modneg(s[7],e))),s},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,m=0,p=[];if(0==n?y=c:(y=u,c=null),0!=(m=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return m;if(p=y.slice(),void 0!==B||null!=B)for(I=0;I=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),m=new n(0),p=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),p++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(m)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(m)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),m.copy(E),m.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(m)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),m.copy(B),m.xtr_D(),B.copy(y),B.conj(),y.copy(m),y.conj(),m.copy(E),m.xtr_D(),E.copy(f),f.copy(m)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),m.copy(E),m.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(m)):(u.fshr(1),I.copy(y),I.conj(),m.copy(B),m.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(m),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP16(this.a),i=new t.FP16(this.c),e=new t.FP16(this.b),o=new t.FP16(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP16(this.a),i=new t.FP16(this.b),e=new t.FP16(this.c),o=new t.FP16(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP16(this.a),e=new t.FP16(0),o=new t.FP16(this.b),r=new t.FP16(0),s=new t.FP16(this.a),h=new t.FP16(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP16(this.a),r=new t.FP16(this.b),s=new t.FP16(this.b),h=new t.FP16(0),c=new t.FP16(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP16(this.a),o=new t.FP16(0),r=new t.FP16(0),s=new t.FP16(0),h=new t.FP16(this.a),c=new t.FP16(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP16(this.a),i=new t.FP16(this.b),e=new t.FP16(this.a),o=new t.FP16(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n,i){var e,o=new t.FP2(n),r=new t.FP2(n);for(o.sqr(),r.mul(o),r.mul_ip(),r.norm(),r.mul_ip(),r.norm(),e=0;e=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,m;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s,1),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),m=E.trace(),B=B.xtr_pow2(y,I,m,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I=[];for(e=0;e>31&1},n.pow16=function(i,e){var o,r,s,h,c,u,a,f,E,B,y=[],I=[],m=[],p=[],d=new n(0),l=new n(0),w=[],_=new t.BIG(0),S=new t.BIG(0),P=new t.BIG(0),T=[],C=[],b=[],G=[],R=[],g=[],M=[],O=[];for(o=0;o<16;o++)w[o]=new t.BIG(e[o]),w[o].norm();for(y[0]=new n(i[0]),y[1]=new n(y[0]),y[1].mul(i[1]),y[2]=new n(y[0]),y[2].mul(i[2]),y[3]=new n(y[1]),y[3].mul(i[2]),y[4]=new n(i[0]),y[4].mul(i[3]),y[5]=new n(y[1]),y[5].mul(i[3]),y[6]=new n(y[2]),y[6].mul(i[3]),y[7]=new n(y[3]),y[7].mul(i[3]),S.rcopy(t.ROM_FIELD.Fra),P.rcopy(t.ROM_FIELD.Frb),B=new t.FP2(S,P),o=0;o<8;o++)I[o]=new n(y[o]),I[o].frob(B,4),m[o]=new n(I[o]),m[o].frob(B,4),p[o]=new n(m[o]),p[o].frob(B,4);for(u=1-w[0].parity(),w[0].inc(u),w[0].norm(),a=1-w[4].parity(),w[4].inc(a),w[4].norm(),f=1-w[8].parity(),w[8].inc(f),w[8].norm(),E=1-w[12].parity(),w[12].inc(E),w[12].norm(),_.zero(),o=0;o<16;o++)_.or(w[o]);for(C[(h=1+_.nbits())-1]=1,G[h-1]=1,g[h-1]=1,O[h-1]=1,o=0;o>1),w[r].norm(),T[o]+=c*s,s*=2;for(b[o]=0,s=1,r=5;r<8;r++)c=G[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),b[o]+=c*s,s*=2;for(R[o]=0,s=1,r=9;r<12;r++)c=g[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),R[o]+=c*s,s*=2;for(M[o]=0,s=1,r=13;r<16;r++)c=O[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),M[o]+=c*s,s*=2}for(l.select(y,2*T[h-1]+1),d.select(I,2*b[h-1]+1),l.mul(d),d.select(m,2*R[h-1]+1),l.mul(d),d.select(p,2*M[h-1]+1),l.mul(d),o=h-2;o>=0;o--)l.usqr(),d.select(y,2*T[o]+C[o]),l.mul(d),d.select(I,2*b[o]+G[o]),l.mul(d),d.select(m,2*R[o]+g[o]),l.mul(d),d.select(p,2*M[o]+O[o]),l.mul(d);return d.copy(i[0]),d.conj(),d.mul(l),l.cmove(d,u),d.copy(i[4]),d.conj(),d.mul(l),l.cmove(d,a),d.copy(i[8]),d.conj(),d.mul(l),l.cmove(d,f),d.copy(i[12]),d.conj(),d.mul(l),l.cmove(d,E),l.reduce(),l},n}(h),h.ECP8=function(t){var n=function(){this.x=new t.FP8(0),this.y=new t.FP8(1),this.z=new t.FP8(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(n){var i,e;return i=new t.FP8(this.x),e=new t.FP8(n.x),i.mul(n.z),e.mul(this.z),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),e.copy(n.y),e.mul(this.z),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP8(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.geta().geta().getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o,r,s,h,c,u,a,f,E,B,y,I,m=new n,p=new t.BIG(0),d=new t.BIG(0);return p.rcopy(t.ROM_CURVE.CURVE_Pxaaa),d.rcopy(t.ROM_CURVE.CURVE_Pxaab),i=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pxaba),d.rcopy(t.ROM_CURVE.CURVE_Pxabb),e=new t.FP2(p,d),o=new t.FP4(i,e),p.rcopy(t.ROM_CURVE.CURVE_Pxbaa),d.rcopy(t.ROM_CURVE.CURVE_Pxbab),r=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pxbba),d.rcopy(t.ROM_CURVE.CURVE_Pxbbb),s=new t.FP2(p,d),h=new t.FP4(r,s),c=new t.FP8(o,h),p.rcopy(t.ROM_CURVE.CURVE_Pyaaa),d.rcopy(t.ROM_CURVE.CURVE_Pyaab),u=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pyaba),d.rcopy(t.ROM_CURVE.CURVE_Pyabb),a=new t.FP2(p,d),f=new t.FP4(u,a),p.rcopy(t.ROM_CURVE.CURVE_Pybaa),d.rcopy(t.ROM_CURVE.CURVE_Pybab),E=new t.FP2(p,d),p.rcopy(t.ROM_CURVE.CURVE_Pybba),d.rcopy(t.ROM_CURVE.CURVE_Pybbb),B=new t.FP2(p,d),y=new t.FP4(E,B),I=new t.FP8(f,y),m.setxy(c,I),m},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B=[];for(u=0;u>1),w[r].norm(),_[o]+=c*s,s*=2;for(P[o]=0,s=1,r=5;r<8;r++)c=T[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),P[o]+=c*s,s*=2;for(C[o]=0,s=1,r=9;r<12;r++)c=b[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),C[o]+=c*s,s*=2;for(G[o]=0,s=1,r=13;r<16;r++)c=R[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),G[o]+=c*s,s*=2}for(y.select(I,2*_[h-1]+1),B.select(m,2*P[h-1]+1),y.add(B),B.select(p,2*C[h-1]+1),y.add(B),B.select(d,2*G[h-1]+1),y.add(B),o=h-2;o>=0;o--)y.dbl(),B.select(I,2*_[o]+S[o]),y.add(B),B.select(m,2*P[o]+T[o]),y.add(B),B.select(p,2*C[o]+b[o]),y.add(B),B.select(d,2*G[o]+R[o]),y.add(B);return B.copy(y),B.sub(i[0]),y.cmove(B,u),B.copy(y),B.sub(i[4]),y.cmove(B,a),B.copy(y),B.sub(i[8]),y.cmove(B,f),B.copy(y),B.sub(i[12]),y.cmove(B,E),y.affine(),y},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,m,p,d=n.frob_constants();for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);c=new t.FP2(r,o),u=new t.FP4(c),h=new t.FP8(u),(s=new n).setx(h),s.is_infinity();)o.inc(1),o.norm();return(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),p=(m=(I=(y=(B=(E=(f=(a=s.mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(a.neg(),E.neg(),y.neg(),m.neg()),p.sub(m),p.sub(s),m.sub(I),m.frob(d,1),I.sub(y),I.frob(d,2),y.sub(B),y.frob(d,3),B.sub(E),B.frob(d,4),E.sub(f),E.frob(d,5),f.sub(a),f.frob(d,6),a.sub(s),a.frob(d,7),s.dbl(),s.frob(d,8),s.add(p),s.add(m),s.add(I),s.add(y),s.add(B),s.add(E),s.add(f),s.add(a),s.affine(),s},n.frob_constants=function(){var n,i,e,o,r=new t.BIG(0),s=new t.BIG(0),h=[];return r.rcopy(t.ROM_FIELD.Fra),s.rcopy(t.ROM_FIELD.Frb),n=new t.FP2(r,s),(i=new t.FP2(n)).sqr(),(o=new t.FP2(i)).mul_ip(),o.norm(),(e=new t.FP2(o)).sqr(),o.mul(e),o.mul_ip(),o.norm(),e.copy(n),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(e.mul_ip(),e.inverse(),i.copy(e),i.sqr()),i.mul_ip(),i.norm(),e.mul(i),h[0]=new t.FP2(i),h[1]=new t.FP2(e),h[2]=new t.FP2(o),h},n}(h),h.PAIR256=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,m,p=new t.FP48(1);return n==i?(r=new t.FP8(n.getx()),s=new t.FP8(n.gety()),h=new t.FP8(n.getz()),(c=new t.FP8(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.tmul(o),r.imul(6),r.tmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_2i(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.times_i(),h.add(h),c.times_i(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP16(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP16(r),m=new t.FP16(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP16(0),(m=new t.FP16(r)).times_i()),n.dbl()):(a=new t.FP8(n.getx()),f=new t.FP8(n.gety()),E=new t.FP8(n.getz()),B=new t.FP8(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.tmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.times_i(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.tmul(e),f.neg(),f.norm(),y=new t.FP16(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP16(f),m=new t.FP16(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP16(0),(m=new t.FP16(f)).times_i()),n.add(i)),p.set(y,I,m),p},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B;for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),r=new t.BIG(o),(s=new t.BIG(r)).pmul(3),s.norm(),c=new t.FP(e.getx()),u=new t.FP(e.gety()),a=new t.ECP8,f=new t.FP48(1),a.copy(i),B=s.nbits()-2;B>=1;B--)f.sqr(),h=n.line(a,a,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),1==(E=s.bit(B)-r.bit(B))&&(h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST)),-1==E&&(i.neg(),h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&f.conj(),f},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,m,p,d;for((s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=new t.BIG(s),(c=new t.BIG(h)).pmul(3),c.norm(),a=new t.FP(e.getx()),f=new t.FP(e.gety()),E=new t.FP(r.getx()),B=new t.FP(r.gety()),y=new t.ECP8,I=new t.ECP8,m=new t.FP48(1),y.copy(i),I.copy(o),d=c.nbits()-2;d>=1;d--)m.sqr(),u=n.line(y,y,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,I,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),1==(p=c.bit(d)-h.bit(d))&&(u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST)),-1==p&&(i.neg(),u=n.line(y,i,a,f),m.smul(u,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),u=n.line(I,o,E,B),m.smul(u,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),m},fexp:function(n){var i,e,o,r,s,h,c,u,a,f;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP48(n),(h=new t.FP48(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o,8),s.mul(h),(f=new t.FP48(s)).usqr(),c=f.pow(r),r.fshr(1),u=c.pow(r),r.fshl(1),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),(a=new t.FP48(c)).conj(),u.mul(a),u.mul(s),s.mul(f),c=u.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,14),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,13),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,12),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,11),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,10),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,9),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,8),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(u),a.conj(),c.mul(a),a.copy(c),a.frob(o,7),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,6),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,5),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,4),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,3),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,2),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,1),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),s.mul(c),u.frob(o,15),s.mul(u),s.reduce(),s},glv:function(n){var i,e,o,r=[];return(i=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),o=t.BIG.smul(e,e),e=t.BIG.smul(o,o),o=t.BIG.smul(e,e),r[0]=new t.BIG(n),r[0].mod(o),r[1]=new t.BIG(n),r[1].div(o),r[1].rsub(i),r},gs:function(n){var i,e,o,r,s=[];for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),r=new t.BIG(n),i=0;i<15;i++)s[i]=new t.BIG(r),s[i].mod(o),r.div(o);return s[15]=new t.BIG(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(s[1].copy(t.BIG.modneg(s[1],e)),s[3].copy(t.BIG.modneg(s[3],e)),s[5].copy(t.BIG.modneg(s[5],e)),s[7].copy(t.BIG.modneg(s[7],e)),s[9].copy(t.BIG.modneg(s[9],e)),s[11].copy(t.BIG.modneg(s[11],e)),s[13].copy(t.BIG.modneg(s[13],e)),s[15].copy(t.BIG.modneg(s[15],e))),s},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,m=0,p=[];if(0==n?y=c:(y=u,c=null),0!=(m=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return m;if(p=y.slice(),void 0!==B||null!=B)for(I=0;I6||t.defaultPinLength<4)&&(t.defaultPinLength=4),t.requestTimeout&&!isNaN(t.requestTimeout)||(t.requestTimeout=4e3),t.oidc||(t.oidc={}),t.clientName="MIRACL Client.js/8.7.0"+(t.applicationInfo?" "+t.applicationInfo:""),n.options=t,n.http=new u(t.requestTimeout,t.clientName,t.projectId,t.cors),n.crypto=new h(t.seed),n.users=new c(t.userStorage,t.projectId,"mfa")}h.prototype._crypto=function(t){return t||(t="BN254CX"),s[t]||(s[t]=new r(t),s[t].MPIN.MAXPIN=1e6,s[t].MPIN.PBLEN=20,s[t].MPIN.TRAP=2e3),s[t]},h.prototype.generateKeypair=function(t){var n,i=this,e=[],o=[];if(0!=(n=i._crypto(t).MPIN.GET_DVS_KEYPAIR(i.rng,e,o)))throw new Error("Could not generate key pair: "+n);return{publicKey:i._bytesToHex(o),privateKey:i._bytesToHex(e)}},h.prototype.addShares=function(t,n,i,e){var o,r,s,h,c=this,u=[];if(o=c._hexToBytes(t),r=c._hexToBytes(n),s=c._hexToBytes(i),0!==(h=c._crypto(e).MPIN.RECOMBINE_G1(r,s,u)))throw new Error("Could not combine the client secret shares: "+h);if(0!=(h=c._crypto(e).MPIN.GET_G1_MULTIPLE(null,0,o,u,u)))throw new Error("Could not combine private key with client secret: "+h);return c._bytesToHex(u)},h.prototype.extractPin=function(t,n,i,e,o){var r,s,h,c=this;if(r=c._hexToBytes(e),s=c._hexToBytes(c._mpinIdWithPublicKey(t,n)),0!==(h=c._crypto(o).MPIN.EXTRACT_PIN(c._crypto(o).MPIN.SHA256,s,i,r)))throw new Error("Could not extract PIN from client secret: "+h);return c._bytesToHex(r)},h.prototype.calculatePass1=function(t,n,i,e,o,r,s){var h,c,u=this,a=[],f=[];if(h=u._mpinIdWithPublicKey(n,i),0!==(c=u._crypto(t).MPIN.CLIENT_1(u._crypto(t).MPIN.SHA256,0,u._hexToBytes(h),u.rng,r,o,u._hexToBytes(e),s,a,f,u._hexToBytes(0))))throw new Error("Could not calculate pass 1 request data: "+c);return{UT:u._bytesToHex(f),U:u._bytesToHex(a)}},h.prototype.calculatePass2=function(t,n,i,e){var o,r=this;if(0!==(o=r._crypto(t).MPIN.CLIENT_2(n,r._hexToBytes(i),e)))throw new Error("Could not calculate pass 2 request data: "+o);return r._bytesToHex(e)},h.prototype.sign=function(t,n,i,e,o,r,s){var h,c,u=this,a=[],f=[];if(h=u._mpinIdWithPublicKey(n,i),0!=(c=u._crypto(t).MPIN.CLIENT(u._crypto(t).MPIN.SHA256,0,u._hexToBytes(h),u.rng,[],o,u._hexToBytes(e),a,f,null,null,s,[],u._hexToBytes(r))))throw new Error("Could not sign message: "+c);return{U:u._bytesToHex(f),V:u._bytesToHex(a)}},h.prototype._mpinIdWithPublicKey=function(t,n){var i,e=this,o=e._hexToBytes(t),r=e._hexToBytes(n);if(o){if(!r)return t;for(i=0;i>>4&15).toString(16),e+=(15&n).toString(16);return e},c.prototype.data=[],c.prototype.states={start:"STARTED",register:"REGISTERED",revoked:"REVOKED"},c.prototype.loadData=function(){var t=this;t.data=JSON.parse(t.storage.getItem(t.storageKey))||[],t.store(),t.data.sort((function(t,n){return t.lastUsed&&(!n.lastUsed||t.lastUsed>n.lastUsed)?1:n.lastUsed&&(!t.lastUsed||t.lastUsed{t(...n,(function(t,n){t?e(t):i(n)}))}))}return class extends a{fetchAccessId(t){return f(super.fetchAccessId.bind(this),t)}fetchStatus(){return f(super.fetchStatus.bind(this))}sendPushNotificationForAuth(t){return f(super.sendPushNotificationForAuth.bind(this),t)}sendVerificationEmail(t){return f(super.sendVerificationEmail.bind(this),t)}getActivationToken(t){return f(super.getActivationToken.bind(this),t)}register(t,n,i){return f(super.register.bind(this),t,n,i)}authenticate(t,n){return f(super.authenticate.bind(this),t,n)}authenticateWithQRCode(t,n,i){return f(super.authenticateWithQRCode.bind(this),t,n,i)}authenticateWithAppLink(t,n,i){return f(super.authenticateWithAppLink.bind(this),t,n,i)}authenticateWithNotificationPayload(t,n){return f(super.authenticateWithNotificationPayload.bind(this),t,n)}generateQuickCode(t,n){return f(super.generateQuickCode.bind(this),t,n)}sign(t,n,i,e){return f(super.sign.bind(this),t,n,i,e)}}}(); +var MIRACLTrust=function(){"use strict";function t(t){var n=function(i,e){i instanceof n?(this.a=new t.FP(i.a),this.b=new t.FP(i.b)):(this.a=new t.FP(i),this.b=new t.FP(e))};return n.prototype={reduce:function(){this.a.reduce(),this.b.reduce()},norm:function(){this.a.norm(),this.b.norm()},iszilch:function(){return this.reduce(),this.a.iszilch()&&this.b.iszilch()},isunity:function(){var n=new t.FP(1);return this.a.equals(n)&&this.b.iszilch()},cmove:function(t,n){this.a.cmove(t.a,n),this.b.cmove(t.b,n)},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)},getA:function(){return this.a.redc()},getB:function(){return this.b.redc()},set:function(t,n){this.a.copy(t),this.b.copy(n)},seta:function(t){this.a.copy(t),this.b.zero()},bset:function(t,n){this.a.bcopy(t),this.b.bcopy(n)},bseta:function(t){this.a.bcopy(t),this.b.zero()},copy:function(t){this.a.copy(t.a),this.b.copy(t.b)},zero:function(){this.a.zero(),this.b.zero()},one:function(){this.a.one(),this.b.zero()},neg:function(){var n=new t.FP(this.a),i=new t.FP(0);n.add(this.b),n.neg(),i.copy(n),i.add(this.b),this.b.copy(n),this.b.add(this.a),this.a.copy(i)},conj:function(){this.b.neg(),this.b.norm()},add:function(t){this.a.add(t.a),this.b.add(t.b)},sub:function(t){var i=new n(t);i.neg(),this.add(i)},rsub:function(t){this.neg(),this.add(t)},pmul:function(t){this.a.mul(t),this.b.mul(t)},imul:function(t){this.a.imul(t),this.b.imul(t)},sqr:function(){var n=new t.FP(this.a),i=new t.FP(this.a),e=new t.FP(this.b);n.add(this.b),i.add(this.a),i.norm(),this.b.mul(i),e.neg(),this.a.add(e),this.a.norm(),n.norm(),this.a.mul(n)},mul:function(n){var i,e,o,r,s,h,c=new t.BIG(0),u=new t.DBIG(0);c.rcopy(t.ROM_FIELD.Modulus),u.ucopy(c),(this.a.XES+this.b.XES)*(n.a.XES+n.b.XES)>t.FP.FEXCESS&&(this.a.XES>1&&this.a.reduce(),this.b.XES>1&&this.b.reduce()),i=t.BIG.mul(this.a.f,n.a.f),e=t.BIG.mul(this.b.f,n.b.f),o=new t.BIG(this.a.f),r=new t.BIG(n.a.f),o.add(this.b.f),o.norm(),r.add(n.b.f),r.norm(),s=t.BIG.mul(o,r),(h=new t.DBIG(0)).copy(i),h.add(e),e.rsub(u),i.add(e),i.norm(),s.sub(h),s.norm(),this.a.f.copy(t.FP.mod(i)),this.a.XES=3,this.b.f.copy(t.FP.mod(s)),this.b.XES=2},sqrt:function(){var n,i;return!!this.iszilch()||(n=new t.FP(this.b),i=new t.FP(this.a),n.sqr(),i.sqr(),n.add(i),1!=n.jacobi()?(this.zero(),!1):(n=n.sqrt(),i.copy(this.a),i.add(n),i.norm(),i.div2(),1!=i.jacobi()&&(i.copy(this.a),i.sub(n),i.norm(),i.div2(),1!=i.jacobi())?(this.zero(),!1):(i=i.sqrt(),this.a.copy(i),i.add(i),i.inverse(),this.b.mul(i),!0)))},toString:function(){return"["+this.a.toString()+","+this.b.toString()+"]"},inverse:function(){var n,i;this.norm(),n=new t.FP(this.a),i=new t.FP(this.b),n.sqr(),i.sqr(),n.add(i),n.inverse(),this.a.mul(n),n.neg(),n.norm(),this.b.mul(n)},div2:function(){this.a.div2(),this.b.div2()},times_i:function(){var n=new t.FP(this.a);this.a.copy(this.b),this.a.neg(),this.b.copy(n)},mul_ip:function(){var i=new n(this),e=new t.FP(this.a);this.a.copy(this.b),this.a.neg(),this.b.copy(e),this.add(i)},div_ip2:function(){var t=new n(0);this.norm(),t.a.copy(this.a),t.a.add(this.b),t.b.copy(this.b),t.b.sub(this.a),this.copy(t),this.norm()},div_ip:function(){var t=new n(0);this.norm(),t.a.copy(this.a),t.a.add(this.b),t.b.copy(this.b),t.b.sub(this.a),this.copy(t),this.norm(),this.div2()},pow:function(t){this.norm();var i,e=new n(1),o=new n(this);for(t.norm();i=t.parity(),t.fshr(1),1==i&&e.mul(o),!t.iszilch();)o.sqr();return e.reduce(),e}},n}function n(t){var n=function(i,e){i instanceof n?(this.a=new t.FP2(i.a),this.b=new t.FP2(i.b)):(this.a=new t.FP2(i),this.b=new t.FP2(e))};return n.prototype={reduce:function(){this.a.reduce(),this.b.reduce()},norm:function(){this.a.norm(),this.b.norm()},iszilch:function(){return this.reduce(),this.a.iszilch()&&this.b.iszilch()},isunity:function(){var n=new t.FP2(1);return this.a.equals(n)&&this.b.iszilch()},cmove:function(t,n){this.a.cmove(t.a,n),this.b.cmove(t.b,n)},isreal:function(){return this.b.iszilch()},real:function(){return this.a},geta:function(){return this.a},getb:function(){return this.b},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b)},zero:function(){this.a.zero(),this.b.zero()},one:function(){this.a.one(),this.b.zero()},set:function(t,n){this.a.copy(t),this.b.copy(n)},seta:function(t){this.a.copy(t),this.b.zero()},neg:function(){this.norm();var n=new t.FP2(this.a),i=new t.FP2(0);n.add(this.b),n.neg(),i.copy(n),i.add(this.b),this.b.copy(n),this.b.add(this.a),this.a.copy(i),this.norm()},conj:function(){this.b.neg(),this.norm()},nconj:function(){this.a.neg(),this.norm()},add:function(t){this.a.add(t.a),this.b.add(t.b)},sub:function(t){var i=new n(t);i.neg(),this.add(i)},rsub:function(t){this.neg(),this.add(t)},pmul:function(t){this.a.mul(t),this.b.mul(t)},imul:function(t){this.a.imul(t),this.b.imul(t)},sqr:function(){var n=new t.FP2(this.a),i=new t.FP2(this.b),e=new t.FP2(this.a);e.mul(this.b),n.add(this.b),n.norm(),i.mul_ip(),i.add(this.a),i.norm(),this.a.copy(n),this.a.mul(i),i.copy(e),i.mul_ip(),i.add(e),i.norm(),i.neg(),this.a.add(i),this.b.copy(e),this.b.add(e),this.norm()},mul:function(n){var i=new t.FP2(this.a),e=new t.FP2(this.b),o=new t.FP2(0),r=new t.FP2(this.b);i.mul(n.a),e.mul(n.b),o.copy(n.b),o.add(n.a),r.add(this.a),o.norm(),r.norm(),r.mul(o),o.copy(i),o.neg(),r.add(o),o.copy(e),o.neg(),this.b.copy(r),this.b.add(o),e.mul_ip(),this.a.copy(e),this.a.add(i),this.norm()},toString:function(){return"["+this.a.toString()+","+this.b.toString()+"]"},inverse:function(){this.norm();var n=new t.FP2(this.a),i=new t.FP2(this.b);n.sqr(),i.sqr(),i.mul_ip(),i.norm(),n.sub(i),n.inverse(),this.a.mul(n),n.neg(),n.norm(),this.b.mul(n)},times_i:function(){var n=new t.FP2(this.b),i=new t.FP2(this.b);n.times_i(),i.add(n),this.b.copy(this.a),this.a.copy(i),this.norm()},frob:function(t){this.a.conj(),this.b.conj(),this.b.mul(t)},pow:function(i){this.norm(),i.norm();for(var e,o=new n(this),r=new t.BIG(i),s=new n(1);e=r.parity(),r.fshr(1),1===e&&s.mul(o),!r.iszilch();)o.sqr();return s.reduce(),s},xtr_A:function(t,i,e){var o=new n(t),r=new n(t);o.sub(i),o.norm(),o.pmul(this.a),r.add(i),r.norm(),r.pmul(this.b),r.times_i(),this.copy(o),this.add(r),this.add(e),this.reduce()},xtr_D:function(){var t=new n(this);this.sqr(),t.conj(),t.add(t),this.sub(t),this.reduce()},xtr_pow:function(i){var e,o,r,s=new n(3),h=new n(this),c=new n(h),u=new n(0),a=new n(0);for(c.xtr_D(),i.norm(),e=i.parity(),(o=new t.BIG(i)).fshr(1),0===e&&(o.dec(1),o.norm()),r=o.nbits()-1;r>=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),p=new n(0),m=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),m++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),p.copy(E),p.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(p)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),p.copy(B),p.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(p),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),p.copy(E),p.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(p)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),p.copy(B),p.xtr_D(),B.copy(y),B.conj(),y.copy(p),y.conj(),p.copy(E),p.xtr_D(),E.copy(f),f.copy(p))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),p.copy(E),p.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(p)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),p.copy(B),p.xtr_D(),B.copy(y),B.conj(),y.copy(p),y.conj(),p.copy(E),p.xtr_D(),E.copy(f),f.copy(p)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),p.copy(E),p.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(p)):(u.fshr(1),I.copy(y),I.conj(),p.copy(B),p.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(p),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),p=new n(0),m=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),m++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),p.copy(E),p.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(p)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),p.copy(B),p.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(p),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),p.copy(E),p.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(p)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),p.copy(B),p.xtr_D(),B.copy(y),B.conj(),y.copy(p),y.conj(),p.copy(E),p.xtr_D(),E.copy(f),f.copy(p))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),p.copy(E),p.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(p)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),p.copy(B),p.xtr_D(),B.copy(y),B.conj(),y.copy(p),y.conj(),p.copy(E),p.xtr_D(),E.copy(f),f.copy(p)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),p.copy(E),p.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(p)):(u.fshr(1),I.copy(y),I.conj(),p.copy(B),p.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(p),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h>>8&255])^t.ROTL16(t.ftable[h[2]>>>16&255])^t.ROTL24(t.ftable[h[3]>>>24&255]),c[1]=this.fkey[r+1]^t.ftable[255&h[1]]^t.ROTL8(t.ftable[h[2]>>>8&255])^t.ROTL16(t.ftable[h[3]>>>16&255])^t.ROTL24(t.ftable[h[0]>>>24&255]),c[2]=this.fkey[r+2]^t.ftable[255&h[2]]^t.ROTL8(t.ftable[h[3]>>>8&255])^t.ROTL16(t.ftable[h[0]>>>16&255])^t.ROTL24(t.ftable[h[1]>>>24&255]),c[3]=this.fkey[r+3]^t.ftable[255&h[3]]^t.ROTL8(t.ftable[h[0]>>>8&255])^t.ROTL16(t.ftable[h[1]>>>16&255])^t.ROTL24(t.ftable[h[2]>>>24&255]),r+=4,o=0;o<4;o++)i=h[o],h[o]=c[o],c[o]=i;for(c[0]=this.fkey[r]^255&t.fbsub[255&h[0]]^t.ROTL8(255&t.fbsub[h[1]>>>8&255])^t.ROTL16(255&t.fbsub[h[2]>>>16&255])^t.ROTL24(255&t.fbsub[h[3]>>>24&255]),c[1]=this.fkey[r+1]^255&t.fbsub[255&h[1]]^t.ROTL8(255&t.fbsub[h[2]>>>8&255])^t.ROTL16(255&t.fbsub[h[3]>>>16&255])^t.ROTL24(255&t.fbsub[h[0]>>>24&255]),c[2]=this.fkey[r+2]^255&t.fbsub[255&h[2]]^t.ROTL8(255&t.fbsub[h[3]>>>8&255])^t.ROTL16(255&t.fbsub[h[0]>>>16&255])^t.ROTL24(255&t.fbsub[h[1]>>>24&255]),c[3]=this.fkey[r+3]^255&t.fbsub[255&h[3]]^t.ROTL8(255&t.fbsub[h[0]>>>8&255])^t.ROTL16(255&t.fbsub[h[1]>>>16&255])^t.ROTL24(255&t.fbsub[h[2]>>>24&255]),e=o=0;e<4;e++,o+=4)for(s=t.unpack(c[e]),r=0;r<4;r++)n[o+r]=s[r]},ecb_decrypt:function(n){var i,e,o,r,s=[],h=[],c=[];for(e=o=0;e<4;e++,o+=4){for(r=0;r<4;r++)s[r]=n[o+r];h[e]=t.pack(s),h[e]^=this.rkey[e]}for(r=4,e=1;e>>8&255])^t.ROTL16(t.rtable[h[2]>>>16&255])^t.ROTL24(t.rtable[h[1]>>>24&255]),c[1]=this.rkey[r+1]^t.rtable[255&h[1]]^t.ROTL8(t.rtable[h[0]>>>8&255])^t.ROTL16(t.rtable[h[3]>>>16&255])^t.ROTL24(t.rtable[h[2]>>>24&255]),c[2]=this.rkey[r+2]^t.rtable[255&h[2]]^t.ROTL8(t.rtable[h[1]>>>8&255])^t.ROTL16(t.rtable[h[0]>>>16&255])^t.ROTL24(t.rtable[h[3]>>>24&255]),c[3]=this.rkey[r+3]^t.rtable[255&h[3]]^t.ROTL8(t.rtable[h[2]>>>8&255])^t.ROTL16(t.rtable[h[1]>>>16&255])^t.ROTL24(t.rtable[h[0]>>>24&255]),r+=4,o=0;o<4;o++)i=h[o],h[o]=c[o],c[o]=i;for(c[0]=this.rkey[r]^255&t.rbsub[255&h[0]]^t.ROTL8(255&t.rbsub[h[3]>>>8&255])^t.ROTL16(255&t.rbsub[h[2]>>>16&255])^t.ROTL24(255&t.rbsub[h[1]>>>24&255]),c[1]=this.rkey[r+1]^255&t.rbsub[255&h[1]]^t.ROTL8(255&t.rbsub[h[0]>>>8&255])^t.ROTL16(255&t.rbsub[h[3]>>>16&255])^t.ROTL24(255&t.rbsub[h[2]>>>24&255]),c[2]=this.rkey[r+2]^255&t.rbsub[255&h[2]]^t.ROTL8(255&t.rbsub[h[1]>>>8&255])^t.ROTL16(255&t.rbsub[h[0]>>>16&255])^t.ROTL24(255&t.rbsub[h[3]>>>24&255]),c[3]=this.rkey[r+3]^255&t.rbsub[255&h[3]]^t.ROTL8(255&t.rbsub[h[2]>>>8&255])^t.ROTL16(255&t.rbsub[h[1]>>>16&255])^t.ROTL24(255&t.rbsub[h[0]>>>24&255]),e=o=0;e<4;e++,o+=4)for(s=t.unpack(c[e]),r=0;r<4;r++)n[o+r]=s[r]},encrypt:function(n){var i,e,o,r=[];switch(e=0,this.mode){case t.ECB:return this.ecb_encrypt(n),0;case t.CBC:for(o=0;o<16;o++)n[o]^=this.f[o];for(this.ecb_encrypt(n),o=0;o<16;o++)this.f[o]=n[o];return 0;case t.CFB1:case t.CFB2:case t.CFB4:for(i=this.mode-t.CFB1+1,o=0;o>>24},t.ROTL16=function(t){return t<<16|t>>>16},t.ROTL24=function(t){return t<<24|t>>>8},t.pack=function(t){return(255&t[3])<<24|(255&t[2])<<16|(255&t[1])<<8|255&t[0]},t.unpack=function(t){var n=[];return n[0]=255&t,n[1]=t>>>8&255,n[2]=t>>>16&255,n[3]=t>>>24&255,n},t.bmul=function(n,i){var e=255&i,o=255&t.ltab[255&n],r=255&t.ltab[e];return 0!==n&&0!==i?t.ptab[(o+r)%255]:0},t.SubByte=function(n){var i=t.unpack(n);return i[0]=t.fbsub[255&i[0]],i[1]=t.fbsub[255&i[1]],i[2]=t.fbsub[255&i[2]],i[3]=t.fbsub[255&i[3]],t.pack(i)},t.product=function(n,i){var e=t.unpack(n),o=t.unpack(i);return 255&(t.bmul(e[0],o[0])^t.bmul(e[1],o[1])^t.bmul(e[2],o[2])^t.bmul(e[3],o[3]))},t.InvMixCol=function(n){var i,e=[];return i=t.pack(t.InCo),e[3]=t.product(i,n),i=t.ROTL24(i),e[2]=t.product(i,n),i=t.ROTL24(i),e[1]=t.product(i,n),i=t.ROTL24(i),e[0]=t.product(i,n),t.pack(e)},t.InCo=[11,13,9,14],t.rco=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47],t.ptab=[1,3,5,15,17,51,85,255,26,46,114,150,161,248,19,53,95,225,56,72,216,115,149,164,247,2,6,10,30,34,102,170,229,52,92,228,55,89,235,38,106,190,217,112,144,171,230,49,83,245,4,12,20,60,68,204,79,209,104,184,211,110,178,205,76,212,103,169,224,59,77,215,98,166,241,8,24,40,120,136,131,158,185,208,107,189,220,127,129,152,179,206,73,219,118,154,181,196,87,249,16,48,80,240,11,29,39,105,187,214,97,163,254,25,43,125,135,146,173,236,47,113,147,174,233,32,96,160,251,22,58,78,210,109,183,194,93,231,50,86,250,21,63,65,195,94,226,61,71,201,64,192,91,237,44,116,156,191,218,117,159,186,213,100,172,239,42,126,130,157,188,223,122,142,137,128,155,182,193,88,232,35,101,175,234,37,111,177,200,67,197,84,252,31,33,99,165,244,7,9,27,45,119,153,176,203,70,202,69,207,74,222,121,139,134,145,168,227,62,66,198,81,243,14,18,54,90,238,41,123,141,140,143,138,133,148,167,242,13,23,57,75,221,124,132,151,162,253,28,36,108,180,199,82,246,1],t.ltab=[0,255,25,1,50,2,26,198,75,199,27,104,51,238,223,3,100,4,224,14,52,141,129,239,76,113,8,200,248,105,28,193,125,194,29,181,249,185,39,106,77,228,166,114,154,201,9,120,101,47,138,5,33,15,225,36,18,240,130,69,53,147,218,142,150,143,219,189,54,208,206,148,19,92,210,241,64,70,131,56,102,221,253,48,191,6,139,98,179,37,226,152,34,136,145,16,126,110,72,195,163,182,30,66,58,107,40,84,250,133,61,186,43,121,10,21,155,159,94,202,78,212,172,229,243,115,167,87,175,88,168,80,244,234,214,116,79,174,233,213,231,230,173,232,44,215,117,122,235,22,11,245,89,203,95,176,156,169,81,160,127,12,246,111,23,196,73,236,216,67,31,45,164,118,123,183,204,187,62,90,251,96,177,134,59,82,161,108,170,85,41,157,151,178,135,144,97,190,220,252,188,149,207,205,55,63,91,209,83,57,132,60,65,162,109,71,20,42,158,93,86,242,211,171,68,17,146,217,35,32,46,137,180,124,184,38,119,153,227,165,103,74,237,222,197,49,254,24,13,99,140,128,192,247,112,7],t.fbsub=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],t.rbsub=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],t.ftable=[2774754246,2222750968,2574743534,2373680118,234025727,3177933782,2976870366,1422247313,1345335392,50397442,2842126286,2099981142,436141799,1658312629,3870010189,2591454956,1170918031,2642575903,1086966153,2273148410,368769775,3948501426,3376891790,200339707,3970805057,1742001331,4255294047,3937382213,3214711843,4154762323,2524082916,1539358875,3266819957,486407649,2928907069,1780885068,1513502316,1094664062,49805301,1338821763,1546925160,4104496465,887481809,150073849,2473685474,1943591083,1395732834,1058346282,201589768,1388824469,1696801606,1589887901,672667696,2711000631,251987210,3046808111,151455502,907153956,2608889883,1038279391,652995533,1764173646,3451040383,2675275242,453576978,2659418909,1949051992,773462580,756751158,2993581788,3998898868,4221608027,4132590244,1295727478,1641469623,3467883389,2066295122,1055122397,1898917726,2542044179,4115878822,1758581177,0,753790401,1612718144,536673507,3367088505,3982187446,3194645204,1187761037,3653156455,1262041458,3729410708,3561770136,3898103984,1255133061,1808847035,720367557,3853167183,385612781,3309519750,3612167578,1429418854,2491778321,3477423498,284817897,100794884,2172616702,4031795360,1144798328,3131023141,3819481163,4082192802,4272137053,3225436288,2324664069,2912064063,3164445985,1211644016,83228145,3753688163,3249976951,1977277103,1663115586,806359072,452984805,250868733,1842533055,1288555905,336333848,890442534,804056259,3781124030,2727843637,3427026056,957814574,1472513171,4071073621,2189328124,1195195770,2892260552,3881655738,723065138,2507371494,2690670784,2558624025,3511635870,2145180835,1713513028,2116692564,2878378043,2206763019,3393603212,703524551,3552098411,1007948840,2044649127,3797835452,487262998,1994120109,1004593371,1446130276,1312438900,503974420,3679013266,168166924,1814307912,3831258296,1573044895,1859376061,4021070915,2791465668,2828112185,2761266481,937747667,2339994098,854058965,1137232011,1496790894,3077402074,2358086913,1691735473,3528347292,3769215305,3027004632,4199962284,133494003,636152527,2942657994,2390391540,3920539207,403179536,3585784431,2289596656,1864705354,1915629148,605822008,4054230615,3350508659,1371981463,602466507,2094914977,2624877800,555687742,3712699286,3703422305,2257292045,2240449039,2423288032,1111375484,3300242801,2858837708,3628615824,84083462,32962295,302911004,2741068226,1597322602,4183250862,3501832553,2441512471,1489093017,656219450,3114180135,954327513,335083755,3013122091,856756514,3144247762,1893325225,2307821063,2811532339,3063651117,572399164,2458355477,552200649,1238290055,4283782570,2015897680,2061492133,2408352771,4171342169,2156497161,386731290,3669999461,837215959,3326231172,3093850320,3275833730,2962856233,1999449434,286199582,3417354363,4233385128,3602627437,974525996],t.rtable=[1353184337,1399144830,3282310938,2522752826,3412831035,4047871263,2874735276,2466505547,1442459680,4134368941,2440481928,625738485,4242007375,3620416197,2151953702,2409849525,1230680542,1729870373,2551114309,3787521629,41234371,317738113,2744600205,3338261355,3881799427,2510066197,3950669247,3663286933,763608788,3542185048,694804553,1154009486,1787413109,2021232372,1799248025,3715217703,3058688446,397248752,1722556617,3023752829,407560035,2184256229,1613975959,1165972322,3765920945,2226023355,480281086,2485848313,1483229296,436028815,2272059028,3086515026,601060267,3791801202,1468997603,715871590,120122290,63092015,2591802758,2768779219,4068943920,2997206819,3127509762,1552029421,723308426,2461301159,4042393587,2715969870,3455375973,3586000134,526529745,2331944644,2639474228,2689987490,853641733,1978398372,971801355,2867814464,111112542,1360031421,4186579262,1023860118,2919579357,1186850381,3045938321,90031217,1876166148,4279586912,620468249,2548678102,3426959497,2006899047,3175278768,2290845959,945494503,3689859193,1191869601,3910091388,3374220536,0,2206629897,1223502642,2893025566,1316117100,4227796733,1446544655,517320253,658058550,1691946762,564550760,3511966619,976107044,2976320012,266819475,3533106868,2660342555,1338359936,2720062561,1766553434,370807324,179999714,3844776128,1138762300,488053522,185403662,2915535858,3114841645,3366526484,2233069911,1275557295,3151862254,4250959779,2670068215,3170202204,3309004356,880737115,1982415755,3703972811,1761406390,1676797112,3403428311,277177154,1076008723,538035844,2099530373,4164795346,288553390,1839278535,1261411869,4080055004,3964831245,3504587127,1813426987,2579067049,4199060497,577038663,3297574056,440397984,3626794326,4019204898,3343796615,3251714265,4272081548,906744984,3481400742,685669029,646887386,2764025151,3835509292,227702864,2613862250,1648787028,3256061430,3904428176,1593260334,4121936770,3196083615,2090061929,2838353263,3004310991,999926984,2809993232,1852021992,2075868123,158869197,4095236462,28809964,2828685187,1701746150,2129067946,147831841,3873969647,3650873274,3459673930,3557400554,3598495785,2947720241,824393514,815048134,3227951669,935087732,2798289660,2966458592,366520115,1251476721,4158319681,240176511,804688151,2379631990,1303441219,1414376140,3741619940,3820343710,461924940,3089050817,2136040774,82468509,1563790337,1937016826,776014843,1511876531,1389550482,861278441,323475053,2355222426,2047648055,2383738969,2302415851,3995576782,902390199,3991215329,1018251130,1507840668,1064563285,2043548696,3208103795,3939366739,1537932639,342834655,2262516856,2180231114,1053059257,741614648,1598071746,1925389590,203809468,2336832552,1100287487,1895934009,3736275976,2632234200,2428589668,1636092795,1890988757,1952214088,1113045200],t}(),h.GCM=function(t){var n=function(){this.table=new Array(128);for(var n=0;n<128;n++)this.table[n]=new Array(4);this.stateX=[],this.Y_0=[],this.counter=0,this.lenA=[],this.lenC=[],this.status=0,this.a=new t.AES};return n.ACCEPTING_HEADER=0,n.ACCEPTING_CIPHER=1,n.NOT_ACCEPTING_MORE=2,n.FINISHED=3,n.ENCRYPTING=0,n.DECRYPTING=1,n.prototype={precompute:function(t){var i,e,o,r=[];for(i=e=0;i<4;i++,e+=4)r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],this.table[0][i]=n.pack(r);for(i=1;i<128;i++){for(o=0,e=0;e<4;e++)this.table[i][e]=o|this.table[i-1][e]>>>1,o=this.table[i-1][e]<<31;0!==o&&(this.table[i][0]^=3774873600)}},gf2mul:function(){var t,i,e,o,r,s=[],h=[];for(s[0]=s[1]=s[2]=s[3]=0,i=8,e=0,t=0;t<128;t++){for(r=1+~(r=this.stateX[e]>>>--i&1),o=0;o<4;o++)s[o]^=this.table[t][o]&r;if(0===i&&(i=8,16==++e))break}for(t=i=0;t<4;t++,i+=4)h=n.unpack(s[t]),this.stateX[i]=h[0],this.stateX[i+1]=h[1],this.stateX[i+2]=h[2],this.stateX[i+3]=h[3]},wrap:function(){var t,i,e=[],o=[],r=[];for(e[0]=this.lenA[0]<<3|(3758096384&this.lenA[1])>>>29,e[1]=this.lenA[1]<<3,e[2]=this.lenC[0]<<3|(3758096384&this.lenC[1])>>>29,e[3]=this.lenC[1]<<3,t=i=0;t<4;t++,i+=4)r=n.unpack(e[t]),o[i]=r[0],o[i+1]=r[1],o[i+2]=r[2],o[i+3]=r[3];for(t=0;t<16;t++)this.stateX[t]^=o[t];this.gf2mul()},init:function(i,e,o,r){var s,h=[],c=[];for(s=0;s<16;s++)h[s]=0,this.stateX[s]=0;if(this.a.init(t.AES.ECB,i,e,r),this.a.ecb_encrypt(h),this.precompute(h),this.lenA[0]=this.lenC[0]=this.lenA[1]=this.lenC[1]=0,12==o){for(s=0;s<12;s++)this.a.f[s]=r[s];for(c=n.unpack(1),this.a.f[12]=c[0],this.a.f[13]=c[1],this.a.f[14]=c[2],this.a.f[15]=c[3],s=0;s<16;s++)this.Y_0[s]=this.a.f[s]}else{for(this.status=n.ACCEPTING_CIPHER,this.ghash(r,o),this.wrap(),s=0;s<16;s++)this.a.f[s]=this.stateX[s],this.Y_0[s]=this.a.f[s],this.stateX[s]=0;this.lenA[0]=this.lenC[0]=this.lenA[1]=this.lenC[1]=0}this.status=n.ACCEPTING_HEADER},add_header:function(t,i){var e,o=0;if(this.status!=n.ACCEPTING_HEADER)return!1;for(;o>>8&255,n[1]=t>>>16&255,n[0]=t>>>24&255,n},n.hex2bytes=function(t){var n,i=t.length,e=[];for(n=0;n>>0)+(t.bot>>>0),i=n>>>0,e=(this.top>>>0)+(t.top>>>0);return this.bot=i,this.top=i!=n?e+1>>>0:e,this},copy:function(){return new t(this.top,this.bot)},shlb:function(){var t=this.bot>>>24;return this.top=t+(this.top<<8),this.bot<<=8,this}},t}(),h.HASH256=function(){var t=function(){this.length=[],this.h=[],this.w=[],this.init()};return t.prototype={transform:function(){var n,i,e,o,r,s,h,c,u,a,f;for(f=16;f<64;f++)this.w[f]=t.theta1(this.w[f-2])+this.w[f-7]+t.theta0(this.w[f-15])+this.w[f-16]|0;for(n=this.h[0],i=this.h[1],e=this.h[2],o=this.h[3],r=this.h[4],s=this.h[5],h=this.h[6],c=this.h[7],f=0;f<64;f++)u=c+t.Sig1(r)+t.Ch(r,s,h)+t.HK[f]+this.w[f]|0,a=t.Sig0(n)+t.Maj(n,i,e)|0,c=h,h=s,s=r,r=o+u|0,o=e,e=i,i=n,n=u+a|0;this.h[0]+=n,this.h[1]+=i,this.h[2]+=e,this.h[3]+=o,this.h[4]+=r,this.h[5]+=s,this.h[6]+=h,this.h[7]+=c},init:function(){var n;for(n=0;n<64;n++)this.w[n]=0;this.length[0]=this.length[1]=0,this.h[0]=t.H[0],this.h[1]=t.H[1],this.h[2]=t.H[2],this.h[3]=t.H[3],this.h[4]=t.H[4],this.h[5]=t.H[5],this.h[6]=t.H[6],this.h[7]=t.H[7]},process:function(t){var n;n=(this.length[0]>>>5)%16,this.w[n]<<=8,this.w[n]|=255&t,this.length[0]+=8,4294967295&this.length[0]||(this.length[1]++,this.length[0]=0),this.length[0]%512==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var n,i,e,o=[];for(n=this.length[0],i=this.length[1],this.process(128);this.length[0]%512!=448;)this.process(0);for(this.w[14]=i,this.w[15]=n,this.transform(),e=0;e>>2]>>8*(3-e%4)&255;return this.init(),o}},t.S=function(t,n){return n>>>t|n<<32-t},t.R=function(t,n){return n>>>t},t.Ch=function(t,n,i){return t&n^~t&i},t.Maj=function(t,n,i){return t&n^t&i^n&i},t.Sig0=function(n){return t.S(2,n)^t.S(13,n)^t.S(22,n)},t.Sig1=function(n){return t.S(6,n)^t.S(11,n)^t.S(25,n)},t.theta0=function(n){return t.S(7,n)^t.S(18,n)^t.R(3,n)},t.theta1=function(n){return t.S(17,n)^t.S(19,n)^t.R(10,n)},t.len=32,t.H=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],t.HK=[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],t}(),h.HASH384=function(t){var n=function(){this.length=[],this.h=[],this.w=[],this.init()};return n.prototype={transform:function(){var t,i,e,o,r,s,h,c,u,a,f;for(f=16;f<80;f++)this.w[f]=n.theta1(this.w[f-2]).add(this.w[f-7]).add(n.theta0(this.w[f-15])).add(this.w[f-16]);for(t=this.h[0].copy(),i=this.h[1].copy(),e=this.h[2].copy(),o=this.h[3].copy(),r=this.h[4].copy(),s=this.h[5].copy(),h=this.h[6].copy(),c=this.h[7].copy(),f=0;f<80;f++)(u=c.copy()).add(n.Sig1(r)).add(n.Ch(r,s,h)).add(n.HK[f]).add(this.w[f]),(a=n.Sig0(t)).add(n.Maj(t,i,e)),c=h,h=s,s=r,(r=o.copy()).add(u),o=e,e=i,i=t,(t=u.copy()).add(a);this.h[0].add(t),this.h[1].add(i),this.h[2].add(e),this.h[3].add(o),this.h[4].add(r),this.h[5].add(s),this.h[6].add(h),this.h[7].add(c)},init:function(){var i;for(i=0;i<80;i++)this.w[i]=new t.UInt64(0,0);this.length[0]=new t.UInt64(0,0),this.length[1]=new t.UInt64(0,0),this.h[0]=n.H[0].copy(),this.h[1]=n.H[1].copy(),this.h[2]=n.H[2].copy(),this.h[3]=n.H[3].copy(),this.h[4]=n.H[4].copy(),this.h[5]=n.H[5].copy(),this.h[6]=n.H[6].copy(),this.h[7]=n.H[7].copy()},process:function(n){var i,e;i=(this.length[0].bot>>>6)%16,this.w[i].shlb(),this.w[i].bot|=255&n,e=new t.UInt64(0,8),this.length[0].add(e),0===this.length[0].top&&0==this.length[0].bot&&(e=new t.UInt64(0,1),this.length[1].add(e)),this.length[0].bot%1024==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var t,i,e,o=[];for(t=this.length[0].copy(),i=this.length[1].copy(),this.process(128);this.length[0].bot%1024!=896;)this.process(0);for(this.w[14]=i,this.w[15]=t,this.transform(),e=0;e>>3]).bot;return this.init(),o}},n.S=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n|i.bot<<32-n,i.bot>>>n|i.top<<32-n):new t.UInt64(i.bot>>>n-32|i.top<<64-n,i.top>>>n-32|i.bot<<64-n)},n.R=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n,i.bot>>>n|i.top<<32-n):new t.UInt64(0,i.top>>>n-32)},n.Ch=function(n,i,e){return new t.UInt64(n.top&i.top^~n.top&e.top,n.bot&i.bot^~n.bot&e.bot)},n.Maj=function(n,i,e){return new t.UInt64(n.top&i.top^n.top&e.top^i.top&e.top,n.bot&i.bot^n.bot&e.bot^i.bot&e.bot)},n.Sig0=function(i){var e=n.S(28,i),o=n.S(34,i),r=n.S(39,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.Sig1=function(i){var e=n.S(14,i),o=n.S(18,i),r=n.S(41,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta0=function(i){var e=n.S(1,i),o=n.S(8,i),r=n.R(7,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta1=function(i){var e=n.S(19,i),o=n.S(61,i),r=n.R(6,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.len=48,n.H=[new t.UInt64(3418070365,3238371032),new t.UInt64(1654270250,914150663),new t.UInt64(2438529370,812702999),new t.UInt64(355462360,4144912697),new t.UInt64(1731405415,4290775857),new t.UInt64(2394180231,1750603025),new t.UInt64(3675008525,1694076839),new t.UInt64(1203062813,3204075428)],n.HK=[new t.UInt64(1116352408,3609767458),new t.UInt64(1899447441,602891725),new t.UInt64(3049323471,3964484399),new t.UInt64(3921009573,2173295548),new t.UInt64(961987163,4081628472),new t.UInt64(1508970993,3053834265),new t.UInt64(2453635748,2937671579),new t.UInt64(2870763221,3664609560),new t.UInt64(3624381080,2734883394),new t.UInt64(310598401,1164996542),new t.UInt64(607225278,1323610764),new t.UInt64(1426881987,3590304994),new t.UInt64(1925078388,4068182383),new t.UInt64(2162078206,991336113),new t.UInt64(2614888103,633803317),new t.UInt64(3248222580,3479774868),new t.UInt64(3835390401,2666613458),new t.UInt64(4022224774,944711139),new t.UInt64(264347078,2341262773),new t.UInt64(604807628,2007800933),new t.UInt64(770255983,1495990901),new t.UInt64(1249150122,1856431235),new t.UInt64(1555081692,3175218132),new t.UInt64(1996064986,2198950837),new t.UInt64(2554220882,3999719339),new t.UInt64(2821834349,766784016),new t.UInt64(2952996808,2566594879),new t.UInt64(3210313671,3203337956),new t.UInt64(3336571891,1034457026),new t.UInt64(3584528711,2466948901),new t.UInt64(113926993,3758326383),new t.UInt64(338241895,168717936),new t.UInt64(666307205,1188179964),new t.UInt64(773529912,1546045734),new t.UInt64(1294757372,1522805485),new t.UInt64(1396182291,2643833823),new t.UInt64(1695183700,2343527390),new t.UInt64(1986661051,1014477480),new t.UInt64(2177026350,1206759142),new t.UInt64(2456956037,344077627),new t.UInt64(2730485921,1290863460),new t.UInt64(2820302411,3158454273),new t.UInt64(3259730800,3505952657),new t.UInt64(3345764771,106217008),new t.UInt64(3516065817,3606008344),new t.UInt64(3600352804,1432725776),new t.UInt64(4094571909,1467031594),new t.UInt64(275423344,851169720),new t.UInt64(430227734,3100823752),new t.UInt64(506948616,1363258195),new t.UInt64(659060556,3750685593),new t.UInt64(883997877,3785050280),new t.UInt64(958139571,3318307427),new t.UInt64(1322822218,3812723403),new t.UInt64(1537002063,2003034995),new t.UInt64(1747873779,3602036899),new t.UInt64(1955562222,1575990012),new t.UInt64(2024104815,1125592928),new t.UInt64(2227730452,2716904306),new t.UInt64(2361852424,442776044),new t.UInt64(2428436474,593698344),new t.UInt64(2756734187,3733110249),new t.UInt64(3204031479,2999351573),new t.UInt64(3329325298,3815920427),new t.UInt64(3391569614,3928383900),new t.UInt64(3515267271,566280711),new t.UInt64(3940187606,3454069534),new t.UInt64(4118630271,4000239992),new t.UInt64(116418474,1914138554),new t.UInt64(174292421,2731055270),new t.UInt64(289380356,3203993006),new t.UInt64(460393269,320620315),new t.UInt64(685471733,587496836),new t.UInt64(852142971,1086792851),new t.UInt64(1017036298,365543100),new t.UInt64(1126000580,2618297676),new t.UInt64(1288033470,3409855158),new t.UInt64(1501505948,4234509866),new t.UInt64(1607167915,987167468),new t.UInt64(1816402316,1246189591)],n}(h),h.HASH512=function(t){var n=function(){this.length=[],this.h=[],this.w=[],this.init()};return n.prototype={transform:function(){var t,i,e,o,r,s,h,c,u,a,f;for(f=16;f<80;f++)this.w[f]=n.theta1(this.w[f-2]).add(this.w[f-7]).add(n.theta0(this.w[f-15])).add(this.w[f-16]);for(t=this.h[0].copy(),i=this.h[1].copy(),e=this.h[2].copy(),o=this.h[3].copy(),r=this.h[4].copy(),s=this.h[5].copy(),h=this.h[6].copy(),c=this.h[7].copy(),f=0;f<80;f++)(u=c.copy()).add(n.Sig1(r)).add(n.Ch(r,s,h)).add(n.HK[f]).add(this.w[f]),(a=n.Sig0(t)).add(n.Maj(t,i,e)),c=h,h=s,s=r,(r=o.copy()).add(u),o=e,e=i,i=t,(t=u.copy()).add(a);this.h[0].add(t),this.h[1].add(i),this.h[2].add(e),this.h[3].add(o),this.h[4].add(r),this.h[5].add(s),this.h[6].add(h),this.h[7].add(c)},init:function(){var i;for(i=0;i<80;i++)this.w[i]=new t.UInt64(0,0);this.length[0]=new t.UInt64(0,0),this.length[1]=new t.UInt64(0,0),this.h[0]=n.H[0].copy(),this.h[1]=n.H[1].copy(),this.h[2]=n.H[2].copy(),this.h[3]=n.H[3].copy(),this.h[4]=n.H[4].copy(),this.h[5]=n.H[5].copy(),this.h[6]=n.H[6].copy(),this.h[7]=n.H[7].copy()},process:function(n){var i,e;i=(this.length[0].bot>>>6)%16,this.w[i].shlb(),this.w[i].bot|=255&n,e=new t.UInt64(0,8),this.length[0].add(e),0===this.length[0].top&&0==this.length[0].bot&&(e=new t.UInt64(0,1),this.length[1].add(e)),this.length[0].bot%1024==0&&this.transform()},process_array:function(t){for(var n=0;n>24&255),this.process(t>>16&255),this.process(t>>8&255),this.process(255&t)},hash:function(){var t,i,e,o=[];for(t=this.length[0].copy(),i=this.length[1].copy(),this.process(128);this.length[0].bot%1024!=896;)this.process(0);for(this.w[14]=i,this.w[15]=t,this.transform(),e=0;e>>3]).bot;return this.init(),o}},n.S=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n|i.bot<<32-n,i.bot>>>n|i.top<<32-n):new t.UInt64(i.bot>>>n-32|i.top<<64-n,i.top>>>n-32|i.bot<<64-n)},n.R=function(n,i){return 0==n?i:n<32?new t.UInt64(i.top>>>n,i.bot>>>n|i.top<<32-n):new t.UInt64(0,i.top>>>n-32)},n.Ch=function(n,i,e){return new t.UInt64(n.top&i.top^~n.top&e.top,n.bot&i.bot^~n.bot&e.bot)},n.Maj=function(n,i,e){return new t.UInt64(n.top&i.top^n.top&e.top^i.top&e.top,n.bot&i.bot^n.bot&e.bot^i.bot&e.bot)},n.Sig0=function(i){var e=n.S(28,i),o=n.S(34,i),r=n.S(39,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.Sig1=function(i){var e=n.S(14,i),o=n.S(18,i),r=n.S(41,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta0=function(i){var e=n.S(1,i),o=n.S(8,i),r=n.R(7,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.theta1=function(i){var e=n.S(19,i),o=n.S(61,i),r=n.R(6,i);return new t.UInt64(e.top^o.top^r.top,e.bot^o.bot^r.bot)},n.len=64,n.H=[new t.UInt64(1779033703,4089235720),new t.UInt64(3144134277,2227873595),new t.UInt64(1013904242,4271175723),new t.UInt64(2773480762,1595750129),new t.UInt64(1359893119,2917565137),new t.UInt64(2600822924,725511199),new t.UInt64(528734635,4215389547),new t.UInt64(1541459225,327033209)],n.HK=[new t.UInt64(1116352408,3609767458),new t.UInt64(1899447441,602891725),new t.UInt64(3049323471,3964484399),new t.UInt64(3921009573,2173295548),new t.UInt64(961987163,4081628472),new t.UInt64(1508970993,3053834265),new t.UInt64(2453635748,2937671579),new t.UInt64(2870763221,3664609560),new t.UInt64(3624381080,2734883394),new t.UInt64(310598401,1164996542),new t.UInt64(607225278,1323610764),new t.UInt64(1426881987,3590304994),new t.UInt64(1925078388,4068182383),new t.UInt64(2162078206,991336113),new t.UInt64(2614888103,633803317),new t.UInt64(3248222580,3479774868),new t.UInt64(3835390401,2666613458),new t.UInt64(4022224774,944711139),new t.UInt64(264347078,2341262773),new t.UInt64(604807628,2007800933),new t.UInt64(770255983,1495990901),new t.UInt64(1249150122,1856431235),new t.UInt64(1555081692,3175218132),new t.UInt64(1996064986,2198950837),new t.UInt64(2554220882,3999719339),new t.UInt64(2821834349,766784016),new t.UInt64(2952996808,2566594879),new t.UInt64(3210313671,3203337956),new t.UInt64(3336571891,1034457026),new t.UInt64(3584528711,2466948901),new t.UInt64(113926993,3758326383),new t.UInt64(338241895,168717936),new t.UInt64(666307205,1188179964),new t.UInt64(773529912,1546045734),new t.UInt64(1294757372,1522805485),new t.UInt64(1396182291,2643833823),new t.UInt64(1695183700,2343527390),new t.UInt64(1986661051,1014477480),new t.UInt64(2177026350,1206759142),new t.UInt64(2456956037,344077627),new t.UInt64(2730485921,1290863460),new t.UInt64(2820302411,3158454273),new t.UInt64(3259730800,3505952657),new t.UInt64(3345764771,106217008),new t.UInt64(3516065817,3606008344),new t.UInt64(3600352804,1432725776),new t.UInt64(4094571909,1467031594),new t.UInt64(275423344,851169720),new t.UInt64(430227734,3100823752),new t.UInt64(506948616,1363258195),new t.UInt64(659060556,3750685593),new t.UInt64(883997877,3785050280),new t.UInt64(958139571,3318307427),new t.UInt64(1322822218,3812723403),new t.UInt64(1537002063,2003034995),new t.UInt64(1747873779,3602036899),new t.UInt64(1955562222,1575990012),new t.UInt64(2024104815,1125592928),new t.UInt64(2227730452,2716904306),new t.UInt64(2361852424,442776044),new t.UInt64(2428436474,593698344),new t.UInt64(2756734187,3733110249),new t.UInt64(3204031479,2999351573),new t.UInt64(3329325298,3815920427),new t.UInt64(3391569614,3928383900),new t.UInt64(3515267271,566280711),new t.UInt64(3940187606,3454069534),new t.UInt64(4118630271,4000239992),new t.UInt64(116418474,1914138554),new t.UInt64(174292421,2731055270),new t.UInt64(289380356,3203993006),new t.UInt64(460393269,320620315),new t.UInt64(685471733,587496836),new t.UInt64(852142971,1086792851),new t.UInt64(1017036298,365543100),new t.UInt64(1126000580,2618297676),new t.UInt64(1288033470,3409855158),new t.UInt64(1501505948,4234509866),new t.UInt64(1607167915,987167468),new t.UInt64(1816402316,1246189591)],n}(h),h.SHA3=function(t){var n=function(t){this.length=0,this.rate=0,this.len=0,this.S=[],this.init(t)};return n.prototype={transform:function(){var i,e,o,r=[],s=[],h=[];for(o=0;o>=3)%5,o=Math.floor(h/5),c=new t.UInt64(0,i),r=0;r=i||c%this.rate==0){e=!0;break}h=n.rotl(h,56)}if(e)break}if(e)break}if(c>=i)break;e=!1,this.transform()}},hash:function(t){if(1==this.rate-this.length%this.rate)this.process(134);else{for(this.process(6);this.length%this.rate!=this.rate-1;)this.process(0);this.process(128)}this.squeeze(t,this.len)},shake:function(t,n){if(1==this.rate-this.length%this.rate)this.process(159);else{for(this.process(31);this.length%this.rate!=this.rate-1;)this.process(0);this.process(128)}this.squeeze(t,n)}},n.rotl=function(n,i){return 0==i?n:i<32?new t.UInt64(n.top<>>32-i,n.bot<>>32-i):new t.UInt64(n.bot<>>64-i,n.top<>>64-i)},n.xor=function(n,i){return new t.UInt64(n.top^i.top,n.bot^i.bot)},n.and=function(n,i){return new t.UInt64(n.top&i.top,n.bot&i.bot)},n.not=function(n){return new t.UInt64(~n.top,~n.bot)},n.ROUNDS=24,n.HASH224=28,n.HASH256=32,n.HASH384=48,n.HASH512=64,n.SHAKE128=16,n.SHAKE256=32,n.RC=[new t.UInt64(0,1),new t.UInt64(0,32898),new t.UInt64(2147483648,32906),new t.UInt64(2147483648,2147516416),new t.UInt64(0,32907),new t.UInt64(0,2147483649),new t.UInt64(2147483648,2147516545),new t.UInt64(2147483648,32777),new t.UInt64(0,138),new t.UInt64(0,136),new t.UInt64(0,2147516425),new t.UInt64(0,2147483658),new t.UInt64(0,2147516555),new t.UInt64(2147483648,139),new t.UInt64(2147483648,32905),new t.UInt64(2147483648,32771),new t.UInt64(2147483648,32770),new t.UInt64(2147483648,128),new t.UInt64(0,32778),new t.UInt64(2147483648,2147483658),new t.UInt64(2147483648,2147516545),new t.UInt64(2147483648,32896),new t.UInt64(0,2147483649),new t.UInt64(2147483648,2147516424)],n}(h),h.RAND=function(t){var n=function(){this.ira=[],this.rndptr=0,this.borrow=0,this.pool_ptr=0,this.pool=[],this.clean()};return n.prototype={NK:21,NJ:6,NV:8,clean:function(){var t;for(t=0;t<32;t++)this.pool[t]=0;for(t=0;t>>0)-this.ira[t]-this.borrow|0,(i>>>=0)e&&(this.borrow=1),this.ira[t]=0|i;return this.ira[0]},sirand:function(t){var n,i,e,o=1;for(this.borrow=0,this.rndptr=0,t>>>=0,this.ira[0]^=t,n=1;n0){for(o=0;o=32&&this.fill_pool(),255&t}},n.pack=function(t){return(255&t[3])<<24|(255&t[2])<<16|(255&t[1])<<8|255&t[0]},n}(h),h.NHS=function(t){var n={round:function(t,n){return Math.floor((t+(n>>1))/n)},nabs:function(t){var n=t>>31;return t+n^n},redc:function(t){return(((67108863&t)*n.ND&67108863)*n.PRIME+t)*n.MODINV},nres:function(t){return n.redc(t*n.R2MODP)},modmul:function(t,i){return n.redc(t*i)},ntt:function(t){var i,e,o,r,s,h,c,u=n.DEGREE/2,a=n.PRIME;for(o=0;o1;){for(r=0,e=0;e>n.WL-1&a},Encode:function(t,i){var e,o,r,s,h,c;for(c=n.PRIME/2,e=o=0;e<256;)for(h=t[o++],s=0;s<8;s++)r=1&h,i[e]=r*c,i[e+256]=r*c,i[e+512]=r*c,i[e+768]=r*c,h>>=1,e++},Decode:function(t,i){var e,o,r,s,h=n.PRIME/2;for(e=0;e<32;e++)i[e]=0;for(e=o=0;e<256;){for(r=0;r<8;r++)s=(s=n.nabs(t[e]-h)+n.nabs(t[e+256]-h)+n.nabs(t[e+512]-h)+n.nabs(t[e+768]-h)-n.PRIME)>>31&1,i[o]=((255&i[o])>>1)+(s<<7),e++;o++}},Parse:function(i,e){var o,r,s,h=new t.SHA3(t.SHA3.SHAKE128),c=[];for(o=0;o<32;o++)h.process(i[o]);for(h.shake(c,4*n.DEGREE),o=r=0;o>8|s<<6),i[o++]=s>>2&255,i[o++]=255&(s>>10|h<<4),i[o++]=h>>4&255,i[o++]=255&(h>>12|c<<2),i[o++]=c>>6},unpack:function(t,i){var e,o,r,s,h,c,u,a,f;for(e=o=0;e>6|h<<2|(15&c)<<10,i[e++]=c>>4|u<<4|(3&a)<<12,i[e++]=a>>2|f<<6},Compress:function(t,i){var e,o,r,s=0;for(e=o=0;e>>8&255,i[o+2]=s>>>16&255,o+=3,s=0}},Decompress:function(t,i){var e,o,r,s,h=0;for(e=o=0;e>>21,h<<=3,i[e]=n.round(s*n.PRIME,8),e++},Error:function(t,i){var e,o,r,s,h;for(s=0;s>=1,o>>=1;i[s]=r+n.PRIME}},redc_it:function(t){var i;for(i=0;i>n.WL-1&n.PRIME)},poly_hard_reduce:function(t){var i,e;for(i=0;i>n.WL-1&n.PRIME)},bytestostring:function(t){var n,i,e="",o=t.length;for(i=0;i>>4&15).toString(16),e+=(15&n).toString(16);return e},SERVER_1:function(t,i,e){var o,r=new Uint8Array(32),s=new Uint8Array(1792),h=new Int32Array(n.DEGREE),c=new Int32Array(n.DEGREE),u=new Int32Array(n.DEGREE);for(o=0;o<32;o++)r[o]=t.getByte();for(n.Parse(r,u),n.Error(t,c),n.Error(t,h),n.ntt(h),n.ntt(c),n.poly_mul(u,u,h),n.poly_add(u,u,c),n.poly_hard_reduce(u),n.redc_it(u),n.pack(u,s),o=0;o<32;o++)i[o]=r[o];for(o=0;o<1792;o++)i[o+32]=s[o];for(n.poly_hard_reduce(h),n.pack(h,s),o=0;o<1792;o++)e[o]=s[o]},CLIENT:function(i,e,o,r){var s,h=new t.SHA3(t.SHA3.HASH256),c=new Uint8Array(32),u=new Uint8Array(1792),a=new Uint8Array(32),f=new Uint8Array(384),E=new Int32Array(n.DEGREE),B=new Int32Array(n.DEGREE),y=new Int32Array(n.DEGREE),I=new Int32Array(n.DEGREE),p=new Int32Array(n.DEGREE);for(n.Error(i,E),n.Error(i,B),n.ntt(E),n.ntt(B),s=0;s<32;s++)c[s]=e[s];for(s=0;s<1792;s++)u[s]=e[s+32];for(n.Parse(c,y),n.poly_mul(y,y,E),n.poly_add(y,y,B),n.poly_hard_reduce(y),s=0;s<32;s++)a[s]=i.getByte();for(s=0;s<32;s++)h.process(a[s]);for(h.hash(a),n.Encode(a,I),n.unpack(u,p),n.nres_it(p),n.poly_mul(p,p,E),n.intt(p),n.Error(i,B),n.poly_add(p,p,B),n.poly_add(p,p,I),n.Compress(p,f),h.init(t.SHA3.HASH256),s=0;s<32;s++)h.process(a[s]);for(h.hash(a),s=0;s<32;s++)r[s]=a[s];for(n.redc_it(y),n.pack(y,u),s=0;s<1792;s++)o[s]=u[s];for(s=0;s<384;s++)o[s+1792]=f[s]},SERVER_2:function(i,e,o){var r,s=new t.SHA3(t.SHA3.HASH256),h=new Int32Array(n.DEGREE),c=new Int32Array(n.DEGREE),u=new Int32Array(n.DEGREE),a=new Uint8Array(1792),f=new Uint8Array(32),E=new Uint8Array(384);for(r=0;r<1792;r++)a[r]=e[r];for(n.unpack(a,u),n.nres_it(u),r=0;r<384;r++)E[r]=e[r+1792];for(n.Decompress(E,h),r=0;r<1792;r++)a[r]=i[r];for(n.unpack(a,c),n.poly_mul(u,u,c),n.intt(u),n.poly_sub(u,h,u),n.poly_soft_reduce(u),n.Decode(u,f),r=0;r<32;r++)s.process(f[r]);for(s.hash(f),r=0;r<32;r++)o[r]=f[r]},PRIME:12289,LGN:10,ND:50343935,ONE:10924,R2MODP:7586};return n.MODINV=Math.pow(2,-26),n.DEGREE=1024,n.WL=26,n.inv=4091,n.invpr=4401,n.roots=[10924,3439,7271,11355,11709,9879,10742,2259,7036,2539,8427,9802,10192,4635,1420,1239,6050,10731,7026,5040,6577,5505,10953,9704,9373,11614,867,8052,8079,8356,11442,11524,5127,11769,941,9207,6770,2705,895,3507,8981,1510,2703,8477,3501,7979,11817,9904,8201,12253,10369,921,1414,10113,10933,2417,9035,7667,7466,5597,6765,10100,2047,7870,560,7412,6155,2904,6540,11072,4731,7581,4991,4e3,324,75,12204,2825,7295,437,3820,3160,4680,9276,4234,5304,233,11774,251,9730,10988,7095,4248,9176,1923,6931,8295,8406,5916,4,1634,4247,9401,7069,10180,10094,1727,1879,11798,1138,7441,5705,10500,3796,1733,5294,12024,10976,11900,10037,4486,1266,6075,10623,7623,6885,10819,11266,3798,11120,7291,6353,8366,1709,9220,4410,8350,795,5533,1167,3593,7090,5367,901,452,7387,8918,8664,12,6830,11982,11649,3414,1473,4826,2255,5637,7108,6327,6585,8638,4958,10454,10385,8712,6113,10609,2342,8475,255,1311,2693,225,11317,9605,289,3623,11876,10744,11590,3250,10538,829,2809,2950,11834,8504,6520,8996,3903,11536,7677,5059,1740,6777,4641,9487,2765,4095,1972,1616,6291,3717,8029,4828,11586,3470,4672,4226,4847,4534,4008,2831,3500,6428,4674,490,341,9994,2541,11867,9688,8748,2025,8115,4268,10521,9604,3043,9466,9197,1560,11648,1786,5134,1416,853,4180,9924,7759,5761,8047,7251,4068,2763,5760,12264,108,5722,4283,11321,6148,4502,2180,9762,1577,6849,8754,12187,3390,8447,4800,10220,90,672,1521,7386,1027,7848,5913,8135,11555,1514,9681,182,1180,2759,11676,8270,8514,4584,3792,5616,1300,2623,3907,7653,11671,5443,11387,9242,8739,12216,9655,6988,12086,9954,256,9557,9836,11792,10012,1450,6025,8601,10525,4232,8262,7841,3977,7290,7832,311,7013,9453,3895,11971,3340,1991,4671,2862,6807,6659,7117,946,1812,10617,2799,11068,11665,3587,3675,8124,3246,1074,9124,2845,7372,8118,12120,10842,1827,11417,11632,10,9788,9985,3563,11528,7220,8204,7816,918,6357,7237,196,6332,11479,5956,2289,7260,3046,10889,6048,519,6606,8228,9187,10651,1669,11183,1337,11593,9397,5517,253,10901,589,2739,4389,4857,5562,1704,11318,1767,4164,878,4072,4397,10007,9376,7177,3613,2088,759,8027,4011,3318,4914,7282,9859,5582,6867,6710,588,2867,9535,5507,7529,10732,2983,12183,5855,4200,2798,3151,5436,9451,8397,5016,9062,4601,3703,4157,9738,206,2794,9067,11025,1528,3663,1872,5481,4341,10318,2616,11782,224,3754,2462,9371,2283,11159,12255,10689,6912,12259,7503,2111,11526,270,6207,10170,306,4031,10605,5450,1034,10087,173,3081,2420,10273,7726,10450,4012,964,12057,3540,11743,7747,7824,11721,4420,10435,1619,3900,7730,10826,913,4387,219,11680,3614,1639,9141,8249,2706,5458,1491,5786,7939,4930,8196,7005,11521,11931,1055,11207,2708,208,11882,11064,5292,10020,954,1724,6316,11685,8508,11356,3539,2734,11784,1741,5751,8229,7708,1460,3524,96,5484,9833,7169,9899,7867,9940,8673,5483,1383,26,10702,9172,1668,2937,6483,4166,7564,6069,7208,7397,9336,6360,6934,11311,8649,6587,3004,10523,6646,6265,12260,1422,10570,6632,10183,12218,6697,8985,7883,8251,12037,11138,6447,9898,9346,2797,4630,1800,4513,3106,2312,10488,9255,2040,5934,3920,2728,6218,8039,8913,3770,8539,3911,10359,3422,2268,525,11694,7486,1909,3059,2162,9831,8182,3487,5060,261,1631,8684,1757,6665,3182,509,5158,2787,1172,11650,8909,9686,4545,28,11438,5151,4362,327,9815,9213,12089,864,8852,7966,2931,3068,12055,1994,12131,191,10434,3098,9566,8814,6824,8862,5658,627,4205,11328,1999,5128,2008,4106,1881,7604,9406,11963,3095,6292,9294,5565,1864,8169,573,474,702,6307,3164,2553,981,11492,84,10943,10140,7809,11609,10311,9204,3496,2592,600,7422,9228,11310,10128,11733,11250,11828,5924,529,4105,10169,1785,9177,6562,1575,5485,5790,2023,783,9398,1474,7396,10461,32,5803,7374,8361,9104,10372,8773,1527,2743,7018,4583,10835,12180,10572,7909,4964,7066,4087,1515,11312,7170,1441,7047,9218,7368,12001,8126,5004,9351,7160,3478,7528,12211,8129,8140,3430,2387,8513,5498,9335,6371,12080,1886,7649,5298,12202,5783,9012,4817,2934,10920,7802,213,11360,9912,5971,4682,8023,5157,3460,7173,1601,3898,7052,3453,12114,756,3187,5403,5513,6169,6936,2971,6889,11039,11076,12122,11575,11441,9973,9022,10095,630,4704,10647,2546,7189,5780,4524,7789,7151,10598,6322,1274,8260,7024,7998,8734,10442,7510,1966,2445,9100,6072,2771,4415,7963,1234,5975,3249,12017,11778,6140,12049,10868,8233,1792,5454,7407,8810,8639,10150,5308,11051,12230,5046,8678,5731,3261,1874,5668,2177,12224,4726,2687,10063,11091,1648,8119,7745,10782,9746,663,6622,395,585,7304,3742,7921,531,1147,7712,10433,7518,2423,7626,2448,7670,11106,2160,500,6185,7690,70,7071,8450,363,6962,1384,8272,5556,6426,7632,1503,1372,7457,6619,4825,3734,1664,9033,2489,5469,3633,9375,8440,2864,823,11683,4547,9359,7417,4334,1752,1771,2573,4123,6884,6145,9421,2067,11928,5492,80,4570,6146,3926,6201,8604,4187,1083,713,2327,5313,7033,3499,10937,9820,1818,7568,2207,11202,10103,4116,7780,5300,1682,3547,1390,8592,11547,4118,4822,7297,9768,1185,4712,9623,10534,1989,7629,1343,4521,6721,1442,7269,2024,3441,10696,1063,815,1500,5809,10781,6023,8740,1568,1700,4945,4152,3692,4379,12051,1089,11517,12079,3365,2488,6948,1890,6582,9745,2142,3639,501,1283,7238,9164,1211,9278,4651,10466,4926,11705,3506,6748,10665,202,8467,5073,5612,8313,6362,11600,11333,2722,4954,2048,6391,6131,1533,8026,720,11473,2542,8587,6653,1339,10437,3635,6417,9932,8216,12168,6913,9783,7385,4715,6667,1456,9440,3714,177,8695,6678,12068,7345,8061,10400,5758,195],n.iroots=[10924,8850,934,5018,10030,1547,2410,580,11050,10869,7654,2097,2487,3862,9750,5253,765,847,3933,4210,4237,11422,675,2916,2585,1336,6784,5712,7249,5263,1558,6239,4419,10242,2189,5524,6692,4823,4622,3254,9872,1356,2176,10875,11368,1920,36,4088,2385,472,4310,8788,3812,9586,10779,3308,8782,11394,9584,5519,3082,11348,520,7162,1023,1470,5404,4666,1666,6214,11023,7803,2252,389,1313,265,6995,10556,8493,1789,6584,4848,11151,491,10410,10562,2195,2109,5220,2888,8042,10655,12285,6373,3883,3994,5358,10366,3113,8041,5194,1301,2559,12038,515,12056,6985,8055,3013,7609,9129,8469,11852,4994,9464,85,12214,11965,8289,7298,4708,7558,1217,5749,9385,6134,4877,11729,10712,2527,10109,7787,6141,968,8006,6567,12181,25,6529,9526,8221,5038,4242,6528,4530,2365,8109,11436,10873,7155,10503,641,10729,3092,2823,9246,2685,1768,8021,4174,10264,3541,2601,422,9748,2295,11948,11799,7615,5861,8789,9458,8281,7755,7442,8063,7617,8819,703,7461,4260,8572,5998,10673,10317,8194,9524,2802,7648,5512,10549,7230,4612,753,8386,3293,5769,3785,455,9339,9480,11460,1751,9039,699,1545,413,8666,12e3,2684,972,12064,9596,10978,12034,3814,9947,1680,6176,3577,1904,1835,7331,3651,5704,5962,5181,6652,10034,7463,10816,8875,640,307,5459,12277,3625,3371,4902,11837,11388,6922,5199,8696,11122,6756,11494,3939,7879,3069,10580,3923,5936,4998,1169,8491,8750,933,3781,604,5973,10565,11335,2269,6997,1225,407,12081,9581,1082,11234,358,768,5284,4093,7359,4350,6503,10798,6831,9583,4040,3148,10650,8675,609,12070,7902,11376,1463,4559,8389,10670,1854,7869,568,4465,4542,546,8749,232,11325,8277,1839,4563,2016,9869,9208,12116,2202,11255,6839,1684,8258,11983,2119,6082,12019,763,10178,4786,30,5377,1600,34,1130,10006,2918,9827,8535,12065,507,9673,1971,7948,6808,10417,8626,10761,1264,3222,9495,12083,2551,8132,8586,7688,3227,7273,3892,2838,6853,9138,9491,8089,6434,106,9306,1557,4760,6782,2754,9422,11701,5579,5422,6707,2430,5007,7375,8971,8278,4262,11530,10201,8676,5112,2913,2282,7892,8217,11411,8125,10522,971,10585,6727,7432,7900,9550,11700,1388,12036,6772,2892,696,10952,1106,10620,1638,3102,4061,5683,11770,6241,1400,9243,5029,1e4,6333,810,5957,12093,5052,5932,11371,4473,4085,5069,761,8726,2304,2501,12279,657,872,10462,1447,169,4171,4917,9444,3165,11215,9043,4165,8614,8702,624,1221,9490,1672,10477,11343,5172,5630,5482,9427,7618,10298,8949,318,8394,2836,5276,11978,4457,4999,8312,4448,4027,8057,1764,3688,6264,10839,2277,497,2453,2732,12033,2335,203,5301,2634,73,3550,3047,902,6846,618,4636,8382,9666,10989,6673,8497,7705,3775,4019,613,9530,11109,12107,2608,10775,734,4154,6376,4441,11262,4903,10768,11617,12199,2069,7489,3842,8899,102,3535,5440,12094,6531,1889,4228,4944,221,5611,3594,12112,8575,2849,10833,5622,7574,4904,2506,5376,121,4073,2357,5872,8654,1852,10950,5636,3702,9747,816,11569,4263,10756,6158,5898,10241,7335,9567,956,689,5927,3976,6677,7216,3822,12087,1624,5541,8783,584,7363,1823,7638,3011,11078,3125,5051,11006,11788,8650,10147,2544,5707,10399,5341,9801,8924,210,772,11200,238,7910,8597,8137,7344,10589,10721,3549,6266,1508,6480,10789,11474,11226,1593,8848,10265,5020,10847,5568,7768,10946,4660,10300,1755,2666,7577,11104,2521,4992,7467,8171,742,3697,10899,8742,10607,6989,4509,8173,2186,1087,10082,4721,10471,2469,1352,8790,5256,6976,9962,11576,11206,8102,3685,6088,8363,6143,7719,12209,6797,361,10222,2868,6144,5405,8166,9716,10518,10537,7955,4872,2930,7742,606,11466,9425,3849,2914,8656,6820,9800,3256,10625,8555,7464,5670,4832,10917,10786,4657,5863,6733,4017,10905,5327,11926,3839,5218,12219,4599,6104,11789,10129,1183,4619,9841,4663,9866,4771,1856,4577,11142,11758,4368,8547,4985,11704,11894,5667,11626,2543,1507,4544,4170,10641,1198,2226,9602,7563,65,10112,6621,10415,9028,6558,3611,7243,59,1238,6981,2139,3650,3479,4882,6835,10497,4056,1421,240,6149,511,272,9040,6314,11055,4326,7874,9518,6217,3189,9844,10323,4779,1847,3555,4291,5265,4029,11015,5967,1691,5138,4500,7765,6509,5100,9743,1642,7585,11659,2194,3267,2316,848,714,167,1213,1250,5400,9318,5353,6120,6776,6886,9102,11533,175,8836,5237,8391,10688,5116,8829,7132,4266,7607,6318,2377,929,12076,4487,1369,9355,7472,3277,6506,87,6991,4640,10403,209,5918,2954,6791,3776,9902,8859,4149,4160,78,4761,8811,5129,2938,7285,4163,288,4921,3071,5242,10848,5119,977,10774,8202,5223,7325,4380,1717,109,1454,7706,5271,9546,10762,3516,1917,3185,3928,4915,6486,12257,1828,4893,10815,2891,11506,10266,6499,6804,10714,5727,3112,10504,2120,8184,11760,6365,461,1039,556,2161,979,3061,4867,11689,9697,8793,3085,1978,680,4480,2149,1346,12205,797,11308,9736,9125,5982,11587,11815,11716,4120,10425,6724,2995,5997,9194,326,2883,4685,10408,8183,10281,7161,10290,961,8084,11662,6631,3427,5465,3475,2723,9191,1855,12098,158,10295,234,9221,9358,4323,3437,11425,200,3076,2474,11962,7927,7138,851,12261,7744,2603,3380,639,11117,9502,7131,11780,9107,5624,10532,3605,10658,12028,7229,8802,4107,2458,10127,9230,10380,4803,595,11764,10021,8867,1930,8378,3750,8519,3376,4250,6071,9561,8369,6355,10249,3034,1801,9977,9183,7776,10489,7659,9492,2943,2391,5842,1151,252,4038,4406,3304,5592,71,2106,5657,1719,10867,29,6024,5643,1766,9285,5702,3640,978,5355,5929,2953,4892,5081,6220,4725,8123,5806,9352,10621,3117,1587,12263,10906,6806,3616,2349,4422,2390,5120,2456,6805,12193,8765,10829,4581,4060,6538,10548,505,9555],n}(h),void 0!==r)return h.config=s[r],h.BIG=function(t){var n=function(t){switch(this.w=new Array(n.NLEN),typeof t){case"object":this.copy(t);break;case"number":this.zero(),this.w[0]=t;break;default:this.zero()}};return n.CHUNK=32,n.MODBYTES=t.config["@NB"],n.BASEBITS=t.config["@BASE"],n.NLEN=1+Math.floor((8*n.MODBYTES-1)/n.BASEBITS),n.DNLEN=2*n.NLEN,n.BMASK=(1<>n.BASEBITS;return this.w[n.NLEN-1]=this.w[n.NLEN-1]+e,this.w[n.NLEN-1]>>8*n.MODBYTES%n.BASEBITS},fshr:function(t){var i,e;for(i=this.w[0]&(1<>t|this.w[e+1]<>t,i},shr:function(t){var i,e=t%n.BASEBITS,o=Math.floor(t/n.BASEBITS);for(i=0;i>e|this.w[o+i+1]<>e,i=n.NLEN-o;i>n.BASEBITS-t,i=n.NLEN-2;i>0;i--)this.w[i]=this.w[i]<>n.BASEBITS-t;return this.w[0]=this.w[0]<>8*n.MODBYTES%n.BASEBITS},shl:function(t){var i,e=t%n.BASEBITS,o=Math.floor(t/n.BASEBITS);for(this.w[n.NLEN-1]=this.w[n.NLEN-1-o]<o+2&&(this.w[n.NLEN-1]|=this.w[n.NLEN-o-2]>>n.BASEBITS-e),i=n.NLEN-2;i>o;i--)this.w[i]=this.w[i-o]<>n.BASEBITS-e;for(this.w[o]=this.w[0]<=0&&0===this.w[e];)e--;if(e<0)return 0;for(t=n.BASEBITS*e,i=this.w[e];0!==i;)i=Math.floor(i/2),t++;return t},toString:function(){var t,i,e="",o=this.nbits();for(o%4==0?o=Math.floor(o/4):(o=Math.floor(o/4),o++),o<2*n.MODBYTES&&(o=2*n.MODBYTES),i=o-1;i>=0;i--)(t=new n(0)).copy(this),t.shr(4*i),e+=(15&t.w[0]).toString(16);return e},add:function(t){var i;for(i=0;i=0;e--)t[e+i]=255&o.w[0],o.fshr(8);return this},toBytes:function(t){this.tobytearray(t,0)},muladd:function(t,i,e,o){var r=t*i+e+this.w[o];return this.w[o]=r&n.BMASK,(r-this.w[o])*n.MODINV},pmul:function(t){var i,e,o=0;for(e=0;e=0;e--)t=o*i+this.w[e],this.w[e]=Math.floor(t/3),o=t%3;return o},mod2m:function(t){var i,e,o;for(e=Math.floor(t/n.BASEBITS),o=(1<=0);for(;i>0;)t.fshr(1),e.copy(this),e.sub(t),e.norm(),this.cmove(e,1-(e.w[n.NLEN-1]>>n.CHUNK-1&1)),i--}},div:function(t){var i=0,e=0,o=new n(1),r=new n(0),s=new n(0);for(this.norm(),r.copy(this),this.zero();n.comp(r,t)>=0;)o.fshl(1),t.fshl(1),i++;for(;i>0;)t.fshr(1),o.fshr(1),s.copy(r),s.sub(t),s.norm(),e=1-(s.w[n.NLEN-1]>>n.CHUNK-1&1),r.cmove(s,e),s.copy(this),s.add(o),s.norm(),this.cmove(s,e),i--},parity:function(){return this.w[0]%2},bit:function(t){return(this.w[Math.floor(t/n.BASEBITS)]&1<0?1:0},lastbits:function(t){var n=(1<>n.BASEBITS&&(i=!1);return i},jacobi:function(t){var i,e,o=0,r=new n(0),s=new n(0),h=new n(0),c=new n(0),u=new n(1);if(0===t.parity()||0===n.comp(this,c)||n.comp(t,u)<=0)return 0;for(this.norm(),s.copy(this),h.copy(t),s.mod(t);n.comp(h,u)>0;){if(0===n.comp(s,c))return 0;for(i=h.lastbits(3),e=0;0===s.parity();)e++,s.shr(1);e%2==1&&(o+=(i*i-1)/8),o+=(i-1)*(s.lastbits(2)-1)/4,r.copy(h),r.mod(s),h.copy(s),s.copy(r),o%=2}return 0===o?1:-1},invmodp:function(t){var i=new n(0),e=new n(0),o=new n(1),r=new n(0),s=new n(0),h=new n(1);for(this.mod(t),i.copy(this),e.copy(t);0!==n.comp(i,h)&&0!==n.comp(e,h);){for(;0===i.parity();)i.fshr(1),0!==o.parity()&&(o.add(t),o.norm()),o.fshr(1);for(;0===e.parity();)e.fshr(1),0!==r.parity()&&(r.add(t),r.norm()),r.fshr(1);n.comp(i,e)>=0?(i.sub(e),i.norm(),n.comp(o,r)>=0?o.sub(r):(s.copy(t),s.sub(r),o.add(s)),o.norm()):(e.sub(i),e.norm(),n.comp(r,o)>=0?r.sub(o):(s.copy(t),s.sub(o),r.add(s)),r.norm())}0===n.comp(i,h)?this.copy(o):this.copy(r)},powmod:function(t,i){var e,o=new n(1),r=new n(0),s=new n(0);for(this.norm(),t.norm(),r.copy(t),s.copy(this);e=r.parity(),r.fshr(1),1==e&&(o=n.modmul(o,s,i)),!r.iszilch();)s=n.modsqr(s,i);return o}},n.frombytearray=function(t,i){var e,o=new n(0);for(e=0;e=0;e--)if(t.w[e]!=i.w[e])return t.w[e]>i.w[e]?1:-1;return 0},n.random=function(t){var i,e,o=new n(0),r=0,s=0;for(i=0;i<8*n.MODBYTES;i++)0===r?s=t.getByte():s>>=1,e=1&s,o.shl(1),o.w[0]+=e,r++,r&=7;return o},n.randomnum=function(n,i){var e,o,r=new t.DBIG(0),s=0,h=0;for(e=0;e<2*n.nbits();e++)0===s?h=i.getByte():h>>=1,o=1&h,r.shl(1),r.w[0]+=o,s++,s&=7;return r.mod(n)},n.mul=function(i,e){var o,r,s,h,c,u,a=new t.DBIG(0),f=[];for(h=0;h=1+Math.floor(c/2);h--)s+=(i.w[h]-i.w[c-h])*(e.w[c-h]-e.w[h]);a.w[c]=s}for(c=n.NLEN;c<2*n.NLEN-1;c++){for(s=r-=f[c-n.NLEN],h=n.NLEN-1;h>=1+Math.floor(c/2);h--)s+=(i.w[h]-i.w[c-h])*(e.w[c-h]-e.w[h]);a.w[c]=s}for(u=0,h=0;h>1;s++)o+=i.w[r-s]*i.w[s];for(o+=o,c.w[r]=o,r++,o=i.w[r]*i.w[0],s=1;s>1;s++)o+=i.w[r-s]*i.w[s];o+=o,o+=i.w[r>>1]*i.w[r>>1],c.w[r]=o,r++}for(r=n.NLEN-1+n.NLEN%2;r>1;s++)o+=i.w[r-s]*i.w[s];for(o+=o,c.w[r]=o,r++,o=i.w[n.NLEN-1]*i.w[r-n.NLEN+1],s=r-n.NLEN+2;s>1;s++)o+=i.w[r-s]*i.w[s];o+=o,o+=i.w[r>>1]*i.w[r>>1],c.w[r]=o,r++}for(o=i.w[n.NLEN-2]*i.w[n.NLEN-1],o+=o,c.w[n.DNLEN-3]=o,o=i.w[n.NLEN-1]*i.w[n.NLEN-1],c.w[n.DNLEN-2]=o,h=0,s=0;sMath.floor(c/2);h--)s+=(a[c-h]-a[h])*(t.w[h]-t.w[c-h]);a[c]=(s&n.BMASK)*i&n.BMASK,r=(s+=a[c]*t.w[0])*n.MODINV+e.w[c+1],f[c]=a[c]*t.w[c],o+=f[c]}for(c=n.NLEN;c<2*n.NLEN-1;c++){for(s=r+o,h=n.NLEN-1;h>=1+Math.floor(c/2);h--)s+=(a[c-h]-a[h])*(t.w[h]-t.w[c-h]);u.w[c-n.NLEN]=s&n.BMASK,r=(s-u.w[c-n.NLEN])*n.MODINV+e.w[c+1],o-=f[c-n.NLEN+1]}return u.w[n.NLEN-1]=r&n.BMASK,u},n.modmul=function(t,i,e){return t.mod(e),i.mod(e),n.mul(t,i).mod(e)},n.modsqr=function(t,i){return t.mod(i),n.sqr(t).mod(i)},n.modneg=function(t,n){return t.mod(n),n.minus(t)},n.invmod256=function(t){var n,i;return i=0,i+=t>>1&1,i=2-(i&=1),i=(n=1+(i<<=1))*(3&t),i>>=2,i+=n*(t>>2&3)&3,i*=n,i=4-(i&=3),i=(n+=i<<=2)*(15&t),i>>=4,i+=n*(t>>4&15)&15,i*=n,n+((i=16-(i&=15))<<4)},n}(h),h.DBIG=function(t){var n=function(t){this.w=[],this.zero(),this.w[0]=t};return n.prototype={zero:function(){for(var n=0;n>t.BIG.BASEBITS;return this.w[t.BIG.DNLEN-1]=this.w[t.BIG.DNLEN-1]+e,this},muladd:function(n,i,e,o){var r=n*i+e+this.w[o];return this.w[o]=r&t.BIG.BMASK,(r-this.w[o])*t.BIG.MODINV},shr:function(n){var i,e=n%t.BIG.BASEBITS,o=Math.floor(n/t.BIG.BASEBITS);for(i=0;i>e|this.w[o+i+1]<>e,i=t.BIG.DNLEN-o;i>t.BIG.BASEBITS-e,i=t.BIG.DNLEN-2;i>o;i--)this.w[i]=this.w[i-o]<>t.BIG.BASEBITS-e;for(this.w[o]=this.w[0]<=0&&0===this.w[e];)e--;if(e<0)return 0;for(n=t.BIG.BASEBITS*e,i=this.w[e];0!==i;)i=Math.floor(i/2),n++;return n},toString:function(){var t,i,e="",o=this.nbits();for(o%4==0?o=Math.floor(o/4):(o=Math.floor(o/4),o++),i=o-1;i>=0;i--)(t=new n(0)).copy(this),t.shr(4*i),e+=(15&t.w[0]).toString(16);return e},mod:function(i){var e=0,o=new n(0),r=new n(0),s=new t.BIG(0);if(this.norm(),o.hcopy(i),s.hcopy(this),n.comp(this,o)<0)return s;do{o.shl(1),e++}while(n.comp(this,o)>=0);for(;e>0;)o.shr(1),r.copy(this),r.sub(o),r.norm(),this.cmove(r,1-(r.w[t.BIG.DNLEN-1]>>t.BIG.CHUNK-1&1)),e--;return s.hcopy(this),s},div:function(i){var e=0,o=0,r=new n(0),s=new n(0),h=new t.BIG(0),c=new t.BIG(0),u=new t.BIG(1);for(r.hcopy(i),this.norm();n.comp(this,r)>=0;)u.fshl(1),r.shl(1),o++;for(;o>0;)r.shr(1),u.shr(1),s.copy(this),s.sub(r),s.norm(),e=1-(s.w[t.BIG.DNLEN-1]>>t.BIG.CHUNK-1&1),this.cmove(s,e),h.copy(c),h.add(u),h.norm(),c.cmove(h,e),o--;return c},split:function(n){var i,e,o=new t.BIG(0),r=n%t.BIG.BASEBITS,s=this.w[t.BIG.DNLEN-1]<=t.BIG.NLEN-1;e--)i=this.w[e]>>r|s,s=this.w[e]<=0;e--)if(n.w[e]!=i.w[e])return n.w[e]>i.w[e]?1:-1;return 0},n}(h),void 0!==h.config.TFF?(h.FF=function(t){var n=function(n){this.v=new Array(n),this.length=n;for(var i=0;i>n.P_TBITS)},zero:function(){for(var t=0;t>t.BIG.BASEBITS)},copy:function(t){for(var n=0;n0;t--)i=this.v[t].fshr(1),this.v[t-1].ortop(i<=0;t--)n+=this.v[t].toString();return n},toBytes:function(n){var i;for(i=0;i=0);for(;i>0;)t.shr(),n.comp(this,t)>=0&&(this.sub(t),this.norm()),i--}},reduce:function(t,i){var e=t.length,o=new n(2*e),r=new n(e),s=new n(e);return r.sducopy(this),s.karmul_lower(0,this,0,i,0,o,0,e),this.karmul_upper(t,s,o,e),s.sducopy(this),r.add(t),r.sub(s),r.norm(),r},dmod:function(i){var e,o=i.length,r=new n(2*o),s=new n(2*o),h=new n(o);for(s.copy(this),s.norm(),r.dsucopy(i),e=t.BIG.BIGBITS*o;n.comp(s,r)>=0;)s.sub(r),s.norm();for(;e>0;)r.shr(),n.comp(s,r)>=0&&(s.sub(r),s.norm()),e--;return h.copy(s),h.mod(i),h},invmodp:function(t){var i=t.length,e=new n(i),o=new n(i),r=new n(i),s=new n(i),h=new n(i),c=new n(i);for(c.one(),e.copy(this),o.copy(t),r.copy(c),s.zero();0!==n.comp(e,c)&&0!==n.comp(o,c);){for(;0===e.parity();)e.shr(),0!==r.parity()&&(r.add(t),r.norm()),r.shr();for(;0===o.parity();)o.shr(),0!==s.parity()&&(s.add(t),s.norm()),s.shr();n.comp(e,o)>=0?(e.sub(o),e.norm(),n.comp(r,s)>=0?r.sub(s):(h.copy(t),h.sub(s),r.add(h)),r.norm()):(o.sub(e),o.norm(),n.comp(s,r)>=0?s.sub(r):(h.copy(t),h.sub(r),s.add(h)),s.norm())}0===n.comp(e,c)?this.copy(r):this.copy(s)},nres:function(i){var e,o=i.length;1===o?((e=new t.DBIG(0)).hcopy(this.v[0]),e.shl(t.BIG.NLEN*t.BIG.BASEBITS),this.v[0].copy(e.mod(i.v[0]))):((e=new n(2*o)).dsucopy(this),this.copy(e.dmod(i)))},redc:function(i,e){var o,r=i.length;1===r?((o=new t.DBIG(0)).hcopy(this.v[0]),this.v[0].copy(t.BIG.monty(i.v[0],(1<=Math.floor((n.P_FEXCESS-1)/(h+1))&&this.mod(e),1===c?(r=t.BIG.mul(this.v[0],i.v[0]),this.v[0].copy(t.BIG.monty(e.v[0],(1<=Math.floor((n.P_FEXCESS-1)/(r+1))&&this.mod(i),1===i.length?(o=t.BIG.sqr(this.v[0]),this.v[0].copy(t.BIG.monty(i.v[0],(1<=0;o--)r=i.v[Math.floor(o/t.BIG.BIGBITS)].bit(o%t.BIG.BIGBITS),this.copy(h),this.modmul(c,e,u),n.cswap(h,c,r),h.modsqr(e,u),c.copy(this),n.cswap(h,c,r);this.copy(h),this.redc(e,u)},skspow:function(i,e){var o,r,s=e.length,h=new n(s),c=new n(s),u=e.invmod2m();for(this.mod(e),h.one(),c.copy(this),h.nres(e),c.nres(e),o=8*t.BIG.MODBYTES-1;o>=0;o--)r=i.bit(o),this.copy(h),this.modmul(c,e,u),n.cswap(h,c,r),h.modsqr(e,u),c.copy(this),n.cswap(h,c,r);this.copy(h),this.redc(e,u)},power:function(t,i){var e=i.length,o=!0,r=new n(e),s=i.invmod2m();if(r.copy(this),r.nres(i),2==t)this.copy(r),this.modsqr(i,s);else for(;t%2==1&&(o?this.copy(r):this.modmul(r,i,s),o=!1),0!=(t>>=1);)r.modsqr(i,s);this.redc(i,s)},pow:function(i,e){var o,r=e.length,s=new n(r),h=e.invmod2m();for(s.copy(this),this.one(),this.nres(e),s.nres(e),o=8*t.BIG.MODBYTES*r-1;o>=0;o--)this.modsqr(e,h),1===i.v[Math.floor(o/t.BIG.BIGBITS)].bit(o%t.BIG.BIGBITS)&&this.modmul(s,e,h);this.redc(e,h)},pow2:function(i,e,o,r){var s,h,c,u=r.length,a=new n(u),f=new n(u),E=new n(u),B=r.invmod2m();for(a.copy(this),f.copy(e),a.nres(r),f.nres(r),E.copy(a),E.modmul(f,r,B),this.one(),this.nres(r),s=8*t.BIG.MODBYTES-1;s>=0;s--)h=i.bit(s),c=o.bit(s),this.modsqr(r,B),1==h?1==c?this.modmul(E,r,B):this.modmul(a,r,B):1==c&&this.modmul(f,r,B);this.redc(r,B)},cfactor:function(t){var i,e=this.length,o=new n(e),r=new n(e);r.set(t),o.copy(this),o.norm();do{for(o.sub(r),o.norm();!o.iszilch()&&0===o.parity();)o.shr()}while(n.comp(o,r)>0);return i=o.v[0].get(0),n.igcd(t,i)>1}},n.comp=function(n,i){var e,o;for(e=n.length-1;e>=0;e--)if(0!==(o=t.BIG.comp(n.v[e],i.v[e])))return o;return 0},n.fromBytes=function(n,i){var e;for(e=0;e>>4&15).toString(16),e+=(15&n).toString(16);return e},bytestostring:function(t){var n,i="";for(n=0;n=0&&o.process_num(e),r=o.hash()):n==this.SHA384?(o=new t.HASH384,null!=i&&o.process_array(i),e>=0&&o.process_num(e),r=o.hash()):n==this.SHA512&&(o=new t.HASH512,null!=i&&o.process_array(i),e>=0&&o.process_num(e),r=o.hash()),r},KEY_PAIR:function(n,i,e,o){for(var r=o.n.length>>1,s=new t.FF(r),h=new t.FF(r),c=new t.FF(r);;){for(e.p.random(n);3!=e.p.lastbits(2);)e.p.inc(1);for(;!t.FF.prime(e.p,n);)e.p.inc(4);if(h.copy(e.p),h.dec(1),!h.cfactor(i))break}for(;;){for(e.q.random(n);3!=e.q.lastbits(2);)e.q.inc(1);for(;!t.FF.prime(e.q,n);)e.q.inc(4);if(c.copy(e.q),c.dec(1),!c.cfactor(i))break}o.n=t.FF.mul(e.p,e.q),o.e=i,s.copy(h),s.shr(),e.dp.set(i),e.dp.invmodp(s),0===e.dp.parity()&&e.dp.add(s),e.dp.norm(),s.copy(c),s.shr(),e.dq.set(i),e.dq.invmodp(s),0===e.dq.parity()&&e.dq.add(s),e.dq.norm(),e.c.copy(e.p),e.c.invmodp(e.q)},MGF1:function(t,n,i,e){var o,r,s,h=t,c=[],u=0;for(s=0;si)for(s=0;sa-r-s-1)return null;for(u=this.hashit(t,o,-1),c=0;c=1;c--)y[c]=y[c-1];for(c=0;c>=0;c--)y[c]=0;return y},OAEP_DECODE:function(t,i,e){var o,r,s,h,c,u,a,f,E,B,y=n.RFS-1,I=[],p=[],m=[];if(y<(s=r=t)+r+1)return null;for(a=0;a=u;a--)e[a]=e[a-u];for(a=u-1;a>=0;a--)e[a]=0}for(E=this.hashit(t,i,-1),a=0;a=y-s-r)return null;if(0!==m[f])break}if(c=m[f],!o||0!==h||1!=c){for(a=0;a0&&r.add(n.q),r.sub(o),r.norm(),r=(s=t.FF.mul(n.c,r)).dmod(n.q),s=t.FF.mul(r,n.p),c.add(s),c.norm(),c.toBytes(e)}};return n}(h),h.rsa_public_key=function(t){return function(n){this.e=0,this.n=new t.FF(n)}}(h),void(h.rsa_private_key=function(t){return function(n){this.p=new t.FF(n),this.q=new t.FF(n),this.dp=new t.FF(n),this.dq=new t.FF(n),this.c=new t.FF(n)}}(h))):void 0!==h.config.CURVE?(h.ROM_CURVE=e[h.config.CURVE],h.ROM_FIELD=o[h.config.FIELD],h.FP=function(t){var n=function(i){i instanceof n?(this.f=new t.BIG(i.f),this.XES=i.XES):(this.f=new t.BIG(i),this.nres())};return n.NOT_SPECIAL=0,n.PSEUDO_MERSENNE=1,n.GENERALISED_MERSENNE=2,n.MONTGOMERY_FRIENDLY=3,n.MODBITS=t.config["@NBT"],n.MOD8=t.config["@M8"],n.MODTYPE=t.config["@MT"],n.FEXCESS=1<n.FEXCESS&&this.reduce(),e=t.BIG.mul(this.f,i.f),this.f.copy(n.mod(e)),this.XES=2,this},imul:function(t){var i,e,o=!1;return t<0&&(t=-t,o=!0),n.MODTYPE==n.PSEUDO_MERSENNE||n.MODTYPE==n.GENERALISED_MERSENNE?(i=this.f.pxmul(t),this.f.copy(n.mod(i)),this.XES=2):this.XES*t<=n.FEXCESS?(this.f.pmul(t),this.XES*=t):(e=new n(t),this.mul(e)),o&&(this.neg(),this.norm()),this},sqr:function(){var i,e;return this.XES*this.XES>n.FEXCESS&&this.reduce(),i=t.BIG.sqr(this.f),e=n.mod(i),this.f.copy(e),this.XES=2,this},add:function(t){return this.f.add(t.f),this.XES+=t.XES,this.XES>n.FEXCESS&&this.reduce(),this},neg:function(){var i,e=new t.BIG(0);return e.rcopy(t.ROM_FIELD.Modulus),i=n.logb2(this.XES-1),e.fshl(i),this.XES=1<n.FEXCESS&&this.reduce(),this},sub:function(t){var i=new n(0);return i.copy(t),i.neg(),this.add(i),this},rsub:function(t){var i=new n(0);i.copy(this),i.neg(),this.copy(t),this.add(i)},div2:function(){var n;return 0===this.f.parity()||((n=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),this.f.add(n),this.f.norm()),this.f.fshr(1),this},inverse:function(){var n=new t.BIG(0);return n.rcopy(t.ROM_FIELD.Modulus),n.dec(2),n.norm(),this.copy(this.pow(n)),this},equals:function(n){return n.reduce(),this.reduce(),0===t.BIG.comp(n.f,this.f)},pow:function(i){var e,o,r,s,h=[],c=[],u=new t.BIG(i);for(u.norm(),o=1+Math.floor((u.nbits()+3)/4),e=0;e=0;e--)s.sqr(),s.sqr(),s.sqr(),s.sqr(),s.mul(c[h[e]]);return s.reduce(),s},jacobi:function(){var n=new t.BIG(0),i=this.redc();return n.rcopy(t.ROM_FIELD.Modulus),i.jacobi(n)},sqrt:function(){var i,e,o,r=new t.BIG(0);return this.reduce(),r.rcopy(t.ROM_FIELD.Modulus),5==n.MOD8?(r.dec(5),r.norm(),r.shr(3),(i=new n(0)).copy(this),i.f.shl(1),e=i.pow(r),i.mul(e),i.mul(e),i.f.dec(1),(o=new n(0)).copy(this),o.mul(e),o.mul(i),o.reduce(),o):(r.inc(1),r.norm(),r.shr(2),this.pow(r))}},n.logb2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},n.mod=function(i){var e,o,r,s,h,c,u,a,f,E=new t.BIG(0);if(n.MODTYPE==n.PSEUDO_MERSENNE)return o=i.split(n.MODBITS),E.hcopy(i),r=1!=t.ROM_FIELD.MConst?o.pmul(t.ROM_FIELD.MConst):0,o.add(E),o.norm(),s=o.w[t.BIG.NLEN-1],o.w[t.BIG.NLEN-1]&=n.TMASK,o.inc(t.ROM_FIELD.MConst*((s>>n.TBITS)+(r<>n.TBITS,E.w[t.BIG.NLEN-1]&=n.TMASK,E.w[0]+=u,E.w[Math.floor(224/t.BIG.BASEBITS)]+=u<<224%t.BIG.BASEBITS,E.norm()),n.MODTYPE==n.NOT_SPECIAL&&((a=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),E.copy(t.BIG.monty(a,t.ROM_FIELD.MConst,i))),E},n}(h),h.ECP=function(t){var n=function(){this.x=new t.FP(0),this.y=new t.FP(1),n.CURVETYPE!=n.EDWARDS?this.z=new t.FP(0):this.z=new t.FP(1)};return n.WEIERSTRASS=0,n.EDWARDS=1,n.MONTGOMERY=2,n.NOT=0,n.BN=1,n.BLS=2,n.D_TYPE=0,n.M_TYPE=1,n.POSITIVEX=0,n.NEGATIVEX=1,n.CURVETYPE=t.config["@CT"],n.CURVE_PAIRING_TYPE=t.config["@PF"],n.SEXTIC_TWIST=t.config["@ST"],n.SIGN_OF_X=t.config["@SX"],n.HASH_TYPE=t.config["@HT"],n.AESKEY=t.config["@AK"],n.prototype={is_infinity:function(){return this.x.reduce(),this.z.reduce(),n.CURVETYPE==n.EDWARDS?(this.y.reduce(),this.x.iszilch()&&this.y.equals(this.z)):n.CURVETYPE==n.WEIERSTRASS?(this.y.reduce(),this.x.iszilch()&&this.z.iszilch()):n.CURVETYPE!=n.MONTGOMERY||this.z.iszilch()},cswap:function(t,i){this.x.cswap(t.x,i),n.CURVETYPE!=n.MONTGOMERY&&this.y.cswap(t.y,i),this.z.cswap(t.z,i)},cmove:function(t,i){this.x.cmove(t.x,i),n.CURVETYPE!=n.MONTGOMERY&&this.y.cmove(t.y,i),this.z.cmove(t.z,i)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(i){var e,o;return e=new t.FP(0),o=new t.FP(0),e.copy(this.x),e.mul(i.z),e.reduce(),o.copy(i.x),o.mul(this.z),o.reduce(),!(!e.equals(o)||n.CURVETYPE!=n.MONTGOMERY&&(e.copy(this.y),e.mul(i.z),e.reduce(),o.copy(i.y),o.mul(this.z),o.reduce(),!e.equals(o)))},copy:function(t){this.x.copy(t.x),n.CURVETYPE!=n.MONTGOMERY&&this.y.copy(t.y),this.z.copy(t.z)},neg:function(){n.CURVETYPE==n.WEIERSTRASS?(this.y.neg(),this.y.norm()):n.CURVETYPE==n.EDWARDS&&(this.x.neg(),this.x.norm())},inf:function(){this.x.zero(),n.CURVETYPE!=n.MONTGOMERY&&this.y.one(),n.CURVETYPE!=n.EDWARDS?this.z.zero():this.z.one()},setxy:function(i,e){var o,r;this.x=new t.FP(0),this.x.bcopy(i),this.y=new t.FP(0),this.y.bcopy(e),this.z=new t.FP(1),o=n.RHS(this.x),n.CURVETYPE==n.MONTGOMERY?1!=o.jacobi()&&this.inf():((r=new t.FP(0)).copy(this.y),r.sqr(),r.equals(o)||this.inf())},setxi:function(i,e){var o,r;this.x=new t.FP(0),this.x.bcopy(i),o=n.RHS(this.x),this.z=new t.FP(1),1==o.jacobi()?((r=o.sqrt()).redc().parity()!=e&&r.neg(),this.y=r):this.inf()},setx:function(i){var e;this.x=new t.FP(0),this.x.bcopy(i),e=n.RHS(this.x),this.z=new t.FP(1),1==e.jacobi()?n.CURVETYPE!=n.MONTGOMERY&&(this.y=e.sqrt()):this.inf()},affine:function(){var i;this.is_infinity()||(i=new t.FP(1),this.z.equals(i)||(this.z.inverse(),n.CURVETYPE!=n.EDWARDS&&n.CURVETYPE!=n.WEIERSTRASS||(this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z=i),n.CURVETYPE==n.MONTGOMERY&&(this.x.mul(this.z),this.x.reduce(),this.z=i)))},getX:function(){return this.affine(),this.x.redc()},getY:function(){return this.affine(),this.y.redc()},getS:function(){return this.affine(),this.getY().parity()},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(i){var e,o=[];for(n.CURVETYPE!=n.MONTGOMERY?i[0]=4:i[0]=2,this.affine(),this.x.redc().toBytes(o),e=0;e>2),m.add(y),m.norm(),this.z.copy(m),this.z.mul(a))},add:function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,p,m,d;n.CURVETYPE==n.WEIERSTRASS&&(0==t.ROM_CURVE.CURVE_A?(e=3*t.ROM_CURVE.CURVE_B_I,(o=new t.FP(0)).copy(this.x),o.mul(i.x),(r=new t.FP(0)).copy(this.y),r.mul(i.y),(s=new t.FP(0)).copy(this.z),s.mul(i.z),(h=new t.FP(0)).copy(this.x),h.add(this.y),h.norm(),(c=new t.FP(0)).copy(i.x),c.add(i.y),c.norm(),h.mul(c),c.copy(o),c.add(r),h.sub(c),h.norm(),c.copy(this.y),c.add(this.z),c.norm(),(u=new t.FP(0)).copy(i.y),u.add(i.z),u.norm(),c.mul(u),u.copy(r),u.add(s),c.sub(u),c.norm(),u.copy(this.x),u.add(this.z),u.norm(),(a=new t.FP(0)).copy(i.x),a.add(i.z),a.norm(),u.mul(a),a.copy(o),a.add(s),a.rsub(u),a.norm(),u.copy(o),u.add(o),o.add(u),o.norm(),s.imul(e),(f=new t.FP(0)).copy(r),f.add(s),f.norm(),r.sub(s),r.norm(),a.imul(e),u.copy(a),u.mul(c),s.copy(h),s.mul(r),u.rsub(s),a.mul(o),r.mul(f),a.add(r),o.mul(h),f.mul(c),f.add(o),this.x.copy(u),this.x.norm(),this.y.copy(a),this.y.norm(),this.z.copy(f),this.z.norm()):((o=new t.FP(0)).copy(this.x),(r=new t.FP(0)).copy(this.y),(s=new t.FP(0)).copy(this.z),(h=new t.FP(0)).copy(this.x),(c=new t.FP(0)).copy(i.x),f=new t.FP(0),(a=new t.FP(0)).copy(i.x),(u=new t.FP(0)).copy(i.y),e=new t.FP(0),0==t.ROM_CURVE.CURVE_B_I&&e.rcopy(t.ROM_CURVE.CURVE_B),o.mul(i.x),r.mul(i.y),s.mul(i.z),h.add(this.y),h.norm(),c.add(i.y),c.norm(),h.mul(c),c.copy(o),c.add(r),h.sub(c),h.norm(),c.copy(this.y),c.add(this.z),c.norm(),u.add(i.z),u.norm(),c.mul(u),u.copy(r),u.add(s),c.sub(u),c.norm(),u.copy(this.x),u.add(this.z),u.norm(),a.add(i.z),a.norm(),u.mul(a),a.copy(o),a.add(s),a.rsub(u),a.norm(),f.copy(s),0==t.ROM_CURVE.CURVE_B_I?f.mul(e):f.imul(t.ROM_CURVE.CURVE_B_I),u.copy(a),u.sub(f),u.norm(),f.copy(u),f.add(u),u.add(f),f.copy(r),f.sub(u),f.norm(),u.add(r),u.norm(),0==t.ROM_CURVE.CURVE_B_I?a.mul(e):a.imul(t.ROM_CURVE.CURVE_B_I),r.copy(s),r.add(s),s.add(r),a.sub(s),a.sub(o),a.norm(),r.copy(a),r.add(a),a.add(r),a.norm(),r.copy(o),r.add(o),o.add(r),o.sub(s),o.norm(),r.copy(c),r.mul(a),s.copy(o),s.mul(a),a.copy(u),a.mul(f),a.add(s),u.mul(h),u.sub(r),f.mul(c),r.copy(h),r.mul(o),f.add(r),this.x.copy(u),this.x.norm(),this.y.copy(a),this.y.norm(),this.z.copy(f),this.z.norm())),n.CURVETYPE==n.EDWARDS&&((E=new t.FP(0)).copy(this.z),B=new t.FP(0),(y=new t.FP(0)).copy(this.x),(I=new t.FP(0)).copy(this.y),p=new t.FP(0),m=new t.FP(0),d=new t.FP(0),E.mul(i.z),B.copy(E),B.sqr(),y.mul(i.x),I.mul(i.y),p.copy(y),p.mul(I),0==t.ROM_CURVE.CURVE_B_I?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),p.mul(e)):p.imul(t.ROM_CURVE.CURVE_B_I),m.copy(B),m.sub(p),d.copy(B),d.add(p),1==t.ROM_CURVE.CURVE_A&&(p.copy(I),p.sub(y)),y.add(I),B.copy(this.x),B.add(this.y),I.copy(i.x),I.add(i.y),B.norm(),I.norm(),B.mul(I),B.sub(y),B.norm(),m.norm(),B.mul(m),this.x.copy(E),this.x.mul(B),d.norm(),1==t.ROM_CURVE.CURVE_A&&(p.norm(),y.copy(p),y.mul(d)),-1==t.ROM_CURVE.CURVE_A&&(y.norm(),y.mul(d)),this.y.copy(E),this.y.mul(y),this.z.copy(m),this.z.mul(d))},dadd:function(n,i){var e,o,r,s,h,c;(e=new t.FP(0)).copy(this.x),(o=new t.FP(0)).copy(this.x),(r=new t.FP(0)).copy(n.x),(s=new t.FP(0)).copy(n.x),h=new t.FP(0),c=new t.FP(0),e.add(this.z),o.sub(this.z),r.add(n.z),s.sub(n.z),s.norm(),e.norm(),h.copy(s),h.mul(e),r.norm(),o.norm(),c.copy(r),c.mul(o),e.copy(h),e.add(c),e.norm(),e.sqr(),o.copy(h),o.sub(c),o.norm(),o.sqr(),this.x.copy(e),this.z.copy(i.x),this.z.mul(o)},sub:function(t){t.neg(),this.add(t),t.neg()},pinmul:function(i,e){var o,r,s,h,c;if(n.CURVETYPE==n.MONTGOMERY)return this.mul(new t.BIG(i));for(s=new n,h=new n,(c=new n).copy(this),o=e-1;o>=0;o--)r=i>>o&1,s.copy(c),s.add(h),h.cswap(c,r),c.copy(s),h.dbl(),h.cswap(c,r);return s.copy(h),s.affine(),s},cfp:function(){var n=t.ROM_CURVE.CURVE_Cof_I,i=new t.BIG(0);if(1!=n){if(4==n)return this.dbl(),this.dbl(),void this.affine();if(8==n)return this.dbl(),this.dbl(),this.dbl(),void this.affine();i.rcopy(t.ROM_CURVE.CURVE_Cof),this.copy(this.mul(i))}},mul:function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,p,m;if(i.iszilch()||this.is_infinity())return new n;if(e=new n,n.CURVETYPE==n.MONTGOMERY){for(o=new n,(r=new n).copy(this),(s=new n).copy(this),s.dbl(),o.copy(this),o.affine(),B=(I=i.nbits())-2;B>=0;B--)y=i.bit(B),e.copy(s),e.dadd(r,o),r.cswap(s,y),s.copy(e),r.dbl(),r.cswap(s,y);e.copy(r)}else{for(h=new t.BIG,c=new t.BIG,u=new n,a=new n,f=[],E=[],this.affine(),u.copy(this),u.dbl(),f[0]=new n,f[0].copy(this),B=1;B<8;B++)f[B]=new n,f[B].copy(f[B-1]),f[B].add(u);for(c.copy(i),p=c.parity(),c.inc(1),c.norm(),m=c.parity(),h.copy(c),h.inc(1),h.norm(),c.cmove(h,p),u.cmove(this,m),a.copy(u),I=1+Math.floor((c.nbits()+3)/4),B=0;B=0;B--)u.select(f,E[B]),e.dbl(),e.dbl(),e.dbl(),e.dbl(),e.add(u);e.sub(a)}return e.affine(),e},mul2:function(i,e,o){var r,s,h,c,u,a,f=new t.BIG,E=new t.BIG,B=new t.BIG,y=new n,I=new n,p=new n,m=[],d=[];for(this.affine(),e.affine(),f.copy(i),E.copy(o),m[1]=new n,m[1].copy(this),m[1].sub(e),m[2]=new n,m[2].copy(this),m[2].add(e),y.copy(e),y.dbl(),m[0]=new n,m[0].copy(m[1]),m[0].sub(y),m[3]=new n,m[3].copy(m[2]),m[3].add(y),I.copy(this),I.dbl(),m[5]=new n,m[5].copy(m[1]),m[5].add(I),m[6]=new n,m[6].copy(m[2]),m[6].add(I),m[4]=new n,m[4].copy(m[5]),m[4].sub(y),m[7]=new n,m[7].copy(m[6]),m[7].add(y),s=f.parity(),f.inc(1),f.norm(),h=f.parity(),B.copy(f),B.inc(1),B.norm(),f.cmove(B,s),I.cmove(this,h),p.copy(I),s=E.parity(),E.inc(1),E.norm(),h=E.parity(),B.copy(E),B.inc(1),B.norm(),E.cmove(B,s),y.cmove(e,h),p.add(y),B.copy(f),B.add(E),B.norm(),c=1+Math.floor((B.nbits()+1)/2),r=0;r=0;r--)I.select(m,d[r]),y.dbl(),y.dbl(),y.add(I);return y.sub(p),y.affine(),y}},n.generator=function(){var i=new n,e=new t.BIG(0),o=new t.BIG(0);return e.rcopy(t.ROM_CURVE.CURVE_Gx),t.ECP.CURVETYPE!=t.ECP.MONTGOMERY?(o.rcopy(t.ROM_CURVE.CURVE_Gy),i.setxy(e,o)):i.setx(e),i},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.fromBytes=function(i){var e,o,r,s=[],h=new n,c=new t.BIG(0);for(c.rcopy(t.ROM_FIELD.Modulus),r=0;r=0)return h;if(4==i[0]){for(r=0;r=0||h.setxy(e,o),h}return h.setx(e),h},n.RHS=function(i){var e,o,r,s,h=new t.FP(0);return i.norm(),h.copy(i),h.sqr(),n.CURVETYPE==n.WEIERSTRASS?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),h.mul(i),-3==t.ROM_CURVE.CURVE_A&&((o=new t.FP(0)).copy(i),o.imul(3),o.neg(),o.norm(),h.add(o)),h.add(e)):n.CURVETYPE==n.EDWARDS?((e=new t.FP(0)).rcopy(t.ROM_CURVE.CURVE_B),r=new t.FP(1),e.mul(h),e.sub(r),e.norm(),-1==t.ROM_CURVE.CURVE_A&&h.neg(),h.sub(r),h.norm(),e.inverse(),h.mul(e)):n.CURVETYPE==n.MONTGOMERY&&((s=new t.FP(0)).copy(h),s.mul(i),h.imul(t.ROM_CURVE.CURVE_A),h.add(s),h.add(i)),h.reduce(),h},n.mapit=function(i){var e=new t.BIG(0),o=t.BIG.fromBytes(i),r=new n;for(e.rcopy(t.ROM_FIELD.Modulus),o.mod(e);;){for(;n.CURVETYPE!=n.MONTGOMERY?r.setxi(o,0):r.setx(o),o.inc(1),o.norm(),r.is_infinity(););if(r.cfp(),!r.is_infinity())break}return r},n}(h),h.ECDH=function(t){return{INVALID_PUBLIC_KEY:-2,ERROR:-3,INVALID:-4,EFS:t.BIG.MODBYTES,EGS:t.BIG.MODBYTES,SHA256:32,SHA384:48,SHA512:64,inttobytes:function(t,n){var i,e=[];for(i=0;i0&&i>0;)e[--i]=255&t,t=Math.floor(t/256);return e},bytestostring:function(t){var n,i,e="",o=t.length;for(i=0;i0&&h.process_num(e),null!=o&&h.process_array(o),0==(s=h.hash()).length)return null;if(0==r)return s;if(c=[],n>=r)for(u=0;ui)for(r=0;re)for(s=0;s32&&(c=128),o=new Array(c),s<4)return 0;for(r=0;rc)for(h=this.hashit(t,i,0,null,0),r=0;r=i.length){r=!0;break}o=i[E++]}if(u.decrypt(a),r)break;for(c=0;c<16;c++)f[B++]=a[c]}if(u.end(),s=!1,h=a[15],(15!=c||h<1||h>16)&&(s=!0),h>=2&&h<=16)for(c=16-h;c<16;c++)a[c]!=h&&(s=!0);if(!s)for(c=0;c<16-h;c++)f[B++]=a[c];if(e=[],s)return e;for(c=0;c=0||a.iszilch()||t.BIG.comp(a,h)>=0)&&(I=this.INVALID),0===I&&(a.invmodp(h),c=t.BIG.modmul(c,a,h),f=t.BIG.modmul(u,a,h),(B=t.ECP.fromBytes(i)).is_infinity()?I=this.ERROR:((y=new t.ECP).copy(B),(y=y.mul2(f,E,c)).is_infinity()?I=this.INVALID:((a=y.getX()).mod(h),0!==t.BIG.comp(a,u)&&(I=this.INVALID)))),I},ECIES_ENCRYPT:function(n,i,e,o,r,s,h,c){var u,a,f,E,B=[],y=[],I=[],p=[],m=[],d=[];if(0!==this.KEY_PAIR_GENERATE(o,m,h))return d;if(0!==this.ECPSVDP_DH(m,r,B))return d;for(E=0;E<2*this.EFS+1;E++)y[E]=h[E];for(E=0;E>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP4(this.a),i=new t.FP4(this.c),e=new t.FP4(this.b),o=new t.FP4(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP4(this.a),i=new t.FP4(this.b),e=new t.FP4(this.c),o=new t.FP4(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP4(this.a),e=new t.FP4(0),o=new t.FP4(this.b),r=new t.FP4(0),s=new t.FP4(this.a),h=new t.FP4(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP4(this.a),r=new t.FP4(this.b),s=new t.FP4(this.b),h=new t.FP4(0),c=new t.FP4(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP4(this.a),o=new t.FP4(0),r=new t.FP4(0),s=new t.FP4(0),h=new t.FP4(this.a),c=new t.FP4(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP4(this.a),i=new t.FP4(this.b),e=new t.FP4(this.a),o=new t.FP4(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n){var i=new t.FP2(n),e=new t.FP2(n);i.sqr(),e.mul(i),this.a.frob(e),this.b.frob(e),this.c.frob(e),this.b.pmul(n),this.c.pmul(i)},trace:function(){var n=new t.FP4(0);return n.copy(this.a),n.imul(3),n.reduce(),n},toString:function(){return"["+this.a.toString()+","+this.b.toString()+","+this.c.toString()+"]"},toBytes:function(n){var i,e=[];for(this.a.geta().getA().toBytes(e),i=0;i=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,p;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),p=E.trace(),B=B.xtr_pow2(y,I,p,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f=[];for(e=0;e>31&1},n.pow4=function(i,e){var o,r,s,h,c,u,a=[],f=new n(0),E=new n(0),B=[],y=new t.BIG(0),I=[],p=[];for(o=0;o<4;o++)B[o]=new t.BIG(e[o]),B[o].norm();for(a[0]=new n(i[0]),a[1]=new n(a[0]),a[1].mul(i[1]),a[2]=new n(a[0]),a[2].mul(i[2]),a[3]=new n(a[1]),a[3].mul(i[2]),a[4]=new n(i[0]),a[4].mul(i[3]),a[5]=new n(a[1]),a[5].mul(i[3]),a[6]=new n(a[2]),a[6].mul(i[3]),a[7]=new n(a[3]),a[7].mul(i[3]),u=1-B[0].parity(),B[0].inc(u),B[0].norm(),y.zero(),o=0;o<4;o++)y.or(B[o]);for(p[(h=1+y.nbits())-1]=1,o=0;o>1),B[r].norm(),I[o]+=c*s,s*=2;for(E.select(a,2*I[h-1]+1),o=h-2;o>=0;o--)E.usqr(),f.select(a,2*I[o]+p[o]),E.mul(f);return f.copy(i[0]),f.conj(),f.mul(E),E.cmove(f,u),E.reduce(),E},n}(h),h.ECP2=function(t){var n=function(){this.x=new t.FP2(0),this.y=new t.FP2(1),this.z=new t.FP2(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e,o,r=new n;o=((o=(i^(e=i>>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.neg(),this.cmove(r,1&e)},equals:function(n){var i,e;return(i=new t.FP2(0)).copy(this.x),(e=new t.FP2(0)).copy(n.x),i.copy(this.x),i.mul(n.z),i.reduce(),e.copy(n.x),e.mul(this.z),e.reduce(),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),i.reduce(),e.copy(n.y),e.mul(this.z),e.reduce(),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP2(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o=new n,r=new t.BIG(0),s=new t.BIG(0);return r.rcopy(t.ROM_CURVE.CURVE_Pxa),s.rcopy(t.ROM_CURVE.CURVE_Pxb),(i=new t.FP2(0)).bset(r,s),r.rcopy(t.ROM_CURVE.CURVE_Pya),s.rcopy(t.ROM_CURVE.CURVE_Pyb),(e=new t.FP2(0)).bset(r,s),o.setxy(i,e),o},n.fromBytes=function(i){var e,o,r,s,h,c,u=[];for(r=0;r>1),y[r].norm(),I[o]+=c*s,s*=2;for(f.select(E,2*I[h-1]+1),o=h-2;o>=0;o--)f.dbl(),a.select(E,2*I[o]+p[o]),f.add(a);return a.copy(f),a.sub(i[0]),f.cmove(a,u),f.affine(),f},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E=new t.BIG(0),B=new t.BIG(0);for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);u=new t.FP2(r,o),(s=new n).setx(u),s.is_infinity();)o.inc(1),o.norm();return E.rcopy(t.ROM_FIELD.Fra),B.rcopy(t.ROM_FIELD.Frb),u=new t.FP2(E,B),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(u.inverse(),u.norm()),(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&((h=new n).copy(s),h=h.mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&h.neg(),(c=new n).copy(h),c.dbl(),c.add(h),c.frob(u),s.frob(u),s.frob(u),s.frob(u),s.add(h),s.add(c),h.frob(u),h.frob(u),s.add(h)),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BLS&&(f=(a=s.mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&a.neg(),f.sub(a),f.sub(s),a.sub(s),a.frob(u),s.dbl(),s.frob(u),s.frob(u),s.add(f),s.add(a)),s.affine(),s},n}(h),h.PAIR=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,p=new t.FP12(1),m=new t.FP4(0);return n==i?(r=new t.FP2(n.getx()),s=new t.FP2(n.gety()),h=new t.FP2(n.getz()),(c=new t.FP2(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.pmul(o),r.imul(6),r.pmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_ip2(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.mul_ip(),h.add(h),c.mul_ip(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP4(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP4(r),m=new t.FP4(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP4(0),(m=new t.FP4(r)).times_i()),n.dbl()):(a=new t.FP2(n.getx()),f=new t.FP2(n.gety()),E=new t.FP2(n.getz()),B=new t.FP2(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.pmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.mul_ip(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.pmul(e),f.neg(),f.norm(),y=new t.FP4(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP4(f),m=new t.FP4(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP4(0),(m=new t.FP4(f)).times_i()),n.add(i)),p.set(y,I,m),p},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,p,m;for((h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),c=new t.BIG(h),a=new t.ECP2,t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?((o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(s.inverse(),s.norm()),c.pmul(6),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX?c.inc(2):c.dec(2)):c.copy(h),c.norm(),(u=new t.BIG(c)).pmul(3),u.norm(),E=new t.FP(e.getx()),B=new t.FP(e.gety()),y=new t.ECP2,I=new t.FP12(1),y.copy(i),m=u.nbits()-2;m>=1;m--)I.sqr(),f=n.line(y,y,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),1==(p=u.bit(m)-c.bit(m))&&(f=n.line(y,i,E,B),I.smul(f,t.ECP.SEXTIC_TWIST)),-1==p&&(i.neg(),f=n.line(y,i,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&I.conj(),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&(t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&y.neg(),a.copy(i),a.frob(s),f=n.line(y,a,E,B),I.smul(f,t.ECP.SEXTIC_TWIST),a.frob(s),a.neg(),f=n.line(y,a,E,B),I.smul(f,t.ECP.SEXTIC_TWIST)),I},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,p,m,d,l,w,_,S;for((u=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),a=new t.BIG(u),E=new t.ECP2,t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?((s=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),c=new t.FP2(s,h),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(c.inverse(),c.norm()),a.pmul(6),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX?a.inc(2):a.dec(2)):a.copy(u),a.norm(),(f=new t.BIG(a)).pmul(3),f.norm(),y=new t.FP(e.getx()),I=new t.FP(e.gety()),p=new t.FP(r.getx()),m=new t.FP(r.gety()),d=new t.ECP2,l=new t.ECP2,w=new t.FP12(1),d.copy(i),l.copy(o),S=f.nbits()-2;S>=1;S--)w.sqr(),B=n.line(d,d,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),B=n.line(l,l,p,m),w.smul(B,t.ECP.SEXTIC_TWIST),1==(_=f.bit(S)-a.bit(S))&&(B=n.line(d,i,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),B=n.line(l,o,p,m),w.smul(B,t.ECP.SEXTIC_TWIST)),-1==_&&(i.neg(),B=n.line(d,i,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),B=n.line(l,o,p,m),w.smul(B,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&w.conj(),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN&&(t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(d.neg(),l.neg()),E.copy(i),E.frob(c),B=n.line(d,E,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),E.frob(c),E.neg(),B=n.line(d,E,y,I),w.smul(B,t.ECP.SEXTIC_TWIST),E.copy(o),E.frob(c),B=n.line(l,E,p,m),w.smul(B,t.ECP.SEXTIC_TWIST),E.frob(c),E.neg(),B=n.line(l,E,p,m),w.smul(B,t.ECP.SEXTIC_TWIST)),w},fexp:function(n){var i,e,o,r,s,h,c,u,a,f,E,B,y,I,p,m;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP12(n),(h=new t.FP12(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o),s.frob(o),s.mul(h),t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN?(h.copy(s),h.frob(o),(c=new t.FP12(h)).frob(o),h.mul(s),c.mul(h),c.frob(o),(u=new t.FP12(s)).conj(),E=s.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&E.conj(),(f=new t.FP12(E)).frob(o),a=E.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&a.conj(),(B=new t.FP12(a)).conj(),h=a.pow(r),t.ECP.SIGN_OF_X==t.ECP.POSITIVEX&&h.conj(),a.frob(o),s.copy(a),s.conj(),E.mul(s),a.frob(o),s.copy(h),s.frob(o),h.mul(s),h.usqr(),h.mul(E),h.mul(B),s.copy(f),s.mul(B),s.mul(h),h.mul(a),s.usqr(),s.mul(h),s.usqr(),h.copy(s),h.mul(u),s.mul(c),h.usqr(),s.mul(h),s.reduce()):((y=new t.FP12(s)).usqr(),I=y.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&I.conj(),r.fshr(1),p=I.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&p.conj(),r.fshl(1),(m=new t.FP12(s)).conj(),I.mul(m),I.conj(),I.mul(p),p=I.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&p.conj(),m=p.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&m.conj(),I.conj(),m.mul(I),I.conj(),I.frob(o),I.frob(o),I.frob(o),p.frob(o),p.frob(o),I.mul(p),p=m.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&p.conj(),p.mul(y),p.mul(s),I.mul(p),p.copy(m),p.frob(o),I.mul(p),s.copy(I),s.reduce()),s},glv:function(n){var i,e,o,r,s,h,c,u,a=[];if(t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN){for(i=new t.BIG(0),o=[],(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),c=0;c<2;c++)i.rcopy(t.ROM_CURVE.CURVE_W[c]),r=t.BIG.mul(i,n),o[c]=new t.BIG(r.div(e)),a[c]=new t.BIG(0);for(a[0].copy(n),c=0;c<2;c++)for(u=0;u<2;u++)i.rcopy(t.ROM_CURVE.CURVE_SB[u][c]),i.copy(t.BIG.modmul(o[u],i,e)),a[c].add(e),a[c].sub(i),a[c].mod(e)}else(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=t.BIG.smul(s,s),a[0]=new t.BIG(n),a[0].mod(h),a[1]=new t.BIG(n),a[1].div(h),a[1].rsub(e);return a},gs:function(n){var i,e,o,r,s,h,c,u,a=[];if(t.ECP.CURVE_PAIRING_TYPE==t.ECP.BN){for(o=new t.BIG(0),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),s=[],i=0;i<4;i++)o.rcopy(t.ROM_CURVE.CURVE_WB[i]),h=t.BIG.mul(o,n),s[i]=new t.BIG(h.div(r)),a[i]=new t.BIG(0);for(a[0].copy(n),i=0;i<4;i++)for(e=0;e<4;e++)o.rcopy(t.ROM_CURVE.CURVE_BB[e][i]),o.copy(t.BIG.modmul(s[e],o,r)),a[i].add(r),a[i].sub(o),a[i].mod(r)}else{for((c=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),u=new t.BIG(n),i=0;i<3;i++)a[i]=new t.BIG(u),a[i].mod(c),u.div(c);a[3]=new t.BIG(u),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(a[1].copy(t.BIG.modneg(a[1],r)),a[3].copy(t.BIG.modneg(a[3],r)))}return a},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,p=0,m=[];if(0==n?y=c:(y=u,c=null),0!=(p=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return p;if(m=y.slice(),void 0!==B||null!=B)for(I=0;I>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP8(this.a),i=new t.FP8(this.c),e=new t.FP8(this.b),o=new t.FP8(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP8(this.a),i=new t.FP8(this.b),e=new t.FP8(this.c),o=new t.FP8(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP8(this.a),e=new t.FP8(0),o=new t.FP8(this.b),r=new t.FP8(0),s=new t.FP8(this.a),h=new t.FP8(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP8(this.a),r=new t.FP8(this.b),s=new t.FP8(this.b),h=new t.FP8(0),c=new t.FP8(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP8(this.a),o=new t.FP8(0),r=new t.FP8(0),s=new t.FP8(0),h=new t.FP8(this.a),c=new t.FP8(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP8(this.a),i=new t.FP8(this.b),e=new t.FP8(this.a),o=new t.FP8(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n,i){var e,o=new t.FP2(n),r=new t.FP2(n);for(o.sqr(),r.mul(o),r.mul_ip(),r.norm(),e=0;e=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,p;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s,1),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),p=E.trace(),B=B.xtr_pow2(y,I,p,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B=[];for(e=0;e>31&1},n.pow8=function(i,e){var o,r,s,h,c,u,a,f,E=[],B=[],y=new n(0),I=new n(0),p=[],m=new t.BIG(0),d=new t.BIG(0),l=new t.BIG(0),w=[],_=[],S=[],P=[];for(o=0;o<8;o++)p[o]=new t.BIG(e[o]),p[o].norm();for(E[0]=new n(i[0]),E[1]=new n(E[0]),E[1].mul(i[1]),E[2]=new n(E[0]),E[2].mul(i[2]),E[3]=new n(E[1]),E[3].mul(i[2]),E[4]=new n(i[0]),E[4].mul(i[3]),E[5]=new n(E[1]),E[5].mul(i[3]),E[6]=new n(E[2]),E[6].mul(i[3]),E[7]=new n(E[3]),E[7].mul(i[3]),d.rcopy(t.ROM_FIELD.Fra),l.rcopy(t.ROM_FIELD.Frb),f=new t.FP2(d,l),o=0;o<8;o++)B[o]=new n(E[o]),B[o].frob(f,4);for(u=1-p[0].parity(),p[0].inc(u),p[0].norm(),a=1-p[4].parity(),p[4].inc(a),p[4].norm(),m.zero(),o=0;o<8;o++)m.or(p[o]);for(_[(h=1+m.nbits())-1]=1,P[h-1]=1,o=0;o>1),p[r].norm(),w[o]+=c*s,s*=2;for(S[o]=0,s=1,r=5;r<8;r++)c=P[o]*p[r].parity(),p[r].fshr(1),p[r].dec(c>>1),p[r].norm(),S[o]+=c*s,s*=2}for(I.select(E,2*w[h-1]+1),y.select(B,2*S[h-1]+1),I.mul(y),o=h-2;o>=0;o--)I.usqr(),y.select(E,2*w[o]+_[o]),I.mul(y),y.select(B,2*S[o]+P[o]),I.mul(y);return y.copy(i[0]),y.conj(),y.mul(I),I.cmove(y,u),y.copy(i[4]),y.conj(),y.mul(I),I.cmove(y,a),I.reduce(),I},n}(h),h.ECP4=function(t){var n=function(){this.x=new t.FP4(0),this.y=new t.FP4(1),this.z=new t.FP4(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(n){var i,e;return i=new t.FP4(this.x),e=new t.FP4(n.x),i.mul(n.z),e.mul(this.z),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),e.copy(n.y),e.mul(this.z),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP4(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.geta().getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o,r,s,h,c=new n,u=new t.BIG(0),a=new t.BIG(0);return u.rcopy(t.ROM_CURVE.CURVE_Pxaa),a.rcopy(t.ROM_CURVE.CURVE_Pxab),i=new t.FP2(u,a),u.rcopy(t.ROM_CURVE.CURVE_Pxba),a.rcopy(t.ROM_CURVE.CURVE_Pxbb),e=new t.FP2(u,a),o=new t.FP4(i,e),u.rcopy(t.ROM_CURVE.CURVE_Pyaa),a.rcopy(t.ROM_CURVE.CURVE_Pyab),r=new t.FP2(u,a),u.rcopy(t.ROM_CURVE.CURVE_Pyba),a.rcopy(t.ROM_CURVE.CURVE_Pybb),s=new t.FP2(u,a),h=new t.FP4(r,s),c.setxy(o,h),c},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f=[];for(h=0;h>1),p[r].norm(),m[o]+=c*s,s*=2;for(l[o]=0,s=1,r=5;r<8;r++)c=w[o]*p[r].parity(),p[r].fshr(1),p[r].dec(c>>1),p[r].norm(),l[o]+=c*s,s*=2}for(E.select(B,2*m[h-1]+1),f.select(y,2*l[h-1]+1),E.add(f),o=h-2;o>=0;o--)E.dbl(),f.select(B,2*m[o]+d[o]),E.add(f),f.select(y,2*l[o]+w[o]),E.add(f);return f.copy(E),f.sub(i[0]),E.cmove(f,u),f.copy(E),f.sub(i[4]),E.cmove(f,a),E.affine(),E},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E,B=n.frob_constants();for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);c=new t.FP2(r,o),h=new t.FP4(c),(s=new n).setx(h),s.is_infinity();)o.inc(1),o.norm();return(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),E=(f=(a=(u=s.mul(o)).mul(o)).mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(u.neg(),f.neg()),E.sub(f),E.sub(s),f.sub(a),f.frob(B,1),a.sub(u),a.frob(B,2),u.sub(s),u.frob(B,3),s.dbl(),s.frob(B,4),s.add(E),s.add(f),s.add(a),s.add(u),s.affine(),s},n.frob_constants=function(){var n,i,e,o,r=new t.BIG(0),s=new t.BIG(0),h=[];return r.rcopy(t.ROM_FIELD.Fra),s.rcopy(t.ROM_FIELD.Frb),n=new t.FP2(r,s),(i=new t.FP2(n)).sqr(),(o=new t.FP2(i)).mul_ip(),o.norm(),(e=new t.FP2(o)).sqr(),o.mul(e),e.copy(n),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(e.mul_ip(),e.inverse(),i.copy(e),i.sqr()),i.mul_ip(),i.norm(),e.mul(i),h[0]=new t.FP2(i),h[1]=new t.FP2(e),h[2]=new t.FP2(o),h},n}(h),h.PAIR192=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,p,m=new t.FP24(1);return n==i?(r=new t.FP4(n.getx()),s=new t.FP4(n.gety()),h=new t.FP4(n.getz()),(c=new t.FP4(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.qmul(o),r.imul(6),r.qmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_2i(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.times_i(),h.add(h),c.times_i(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP8(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP8(r),p=new t.FP8(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP8(0),(p=new t.FP8(r)).times_i()),n.dbl()):(a=new t.FP4(n.getx()),f=new t.FP4(n.gety()),E=new t.FP4(n.getz()),B=new t.FP4(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.qmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.times_i(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.qmul(e),f.neg(),f.norm(),y=new t.FP8(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP8(f),p=new t.FP8(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP8(0),(p=new t.FP8(f)).times_i()),n.add(i)),m.set(y,I,p),m},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B;for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),r=new t.BIG(o),(s=new t.BIG(r)).pmul(3),s.norm(),c=new t.FP(e.getx()),u=new t.FP(e.gety()),a=new t.ECP4,f=new t.FP24(1),a.copy(i),B=s.nbits()-2;B>=1;B--)f.sqr(),h=n.line(a,a,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),1==(E=s.bit(B)-r.bit(B))&&(h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST)),-1==E&&(i.neg(),h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&f.conj(),f},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,p,m,d;for((s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=new t.BIG(s),(c=new t.BIG(h)).pmul(3),c.norm(),a=new t.FP(e.getx()),f=new t.FP(e.gety()),E=new t.FP(r.getx()),B=new t.FP(r.gety()),y=new t.ECP4,I=new t.ECP4,p=new t.FP24(1),y.copy(i),I.copy(o),d=c.nbits()-2;d>=1;d--)p.sqr(),u=n.line(y,y,a,f),p.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,I,E,B),p.smul(u,t.ECP.SEXTIC_TWIST),1==(m=c.bit(d)-h.bit(d))&&(u=n.line(y,i,a,f),p.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,o,E,B),p.smul(u,t.ECP.SEXTIC_TWIST)),-1==m&&(i.neg(),u=n.line(y,i,a,f),p.smul(u,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),u=n.line(I,o,E,B),p.smul(u,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&p.conj(),p},fexp:function(n){var i,e,o,r,s,h,c,u,a,f,E,B,y,I;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP24(n),(h=new t.FP24(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o,4),s.mul(h),(I=new t.FP24(s)).usqr(),u=I.pow(r),r.fshr(1),a=u.pow(r),r.fshl(1),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&u.conj(),(f=new t.FP24(u)).conj(),a.mul(f),a.mul(s),B=(E=(f=a.pow(r)).pow(r)).pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(f.conj(),B.conj()),f.frob(o,6),E.frob(o,5),f.mul(E),y=B.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&y.conj(),B.frob(o,4),f.mul(B),(c=new t.FP24(a)).conj(),y.mul(c),B.copy(y),B.frob(o,3),f.mul(B),B=y.pow(r),y=B.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&B.conj(),c.copy(B),c.frob(o,2),f.mul(c),c.copy(y),c.frob(o,1),f.mul(c),B=y.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&B.conj(),a.frob(o,7),B.mul(I),f.mul(a),f.mul(B),s.mul(f),s.reduce(),s},glv:function(n){var i,e,o,r=[];return(i=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),o=t.BIG.smul(e,e),e=t.BIG.smul(o,o),r[0]=new t.BIG(n),r[0].mod(e),r[1]=new t.BIG(n),r[1].div(e),r[1].rsub(i),r},gs:function(n){var i,e,o,r,s=[];for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),r=new t.BIG(n),i=0;i<7;i++)s[i]=new t.BIG(r),s[i].mod(o),r.div(o);return s[7]=new t.BIG(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(s[1].copy(t.BIG.modneg(s[1],e)),s[3].copy(t.BIG.modneg(s[3],e)),s[5].copy(t.BIG.modneg(s[5],e)),s[7].copy(t.BIG.modneg(s[7],e))),s},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,p=0,m=[];if(0==n?y=c:(y=u,c=null),0!=(p=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return p;if(m=y.slice(),void 0!==B||null!=B)for(I=0;I=0;r--)1!=o.bit(r)?(u.copy(h),this.conj(),c.conj(),h.xtr_A(s,this,c),this.conj(),c.copy(u),c.xtr_D(),s.xtr_D()):(u.copy(s),u.conj(),s.copy(h),s.xtr_D(),h.xtr_A(c,this,u),c.xtr_D());return 0===e?a.copy(c):a.copy(h),a.reduce(),a},xtr_pow2:function(i,e,o,r,s){r.norm(),s.norm();for(var h,c=new t.BIG(r),u=new t.BIG(s),a=new t.BIG(0),f=new n(i),E=new n(this),B=new n(e),y=new n(o),I=new n(0),p=new n(0),m=0;0===u.parity()&&0===c.parity();)u.fshr(1),c.fshr(1),m++;for(;0!==t.BIG.comp(u,c);)t.BIG.comp(u,c)>0&&(a.copy(c),a.imul(4),a.norm(),t.BIG.comp(u,a)<=0?(a.copy(u),u.copy(c),c.rsub(a),c.norm(),p.copy(E),p.xtr_A(f,B,y),y.copy(B),y.conj(),B.copy(E),E.copy(f),f.copy(p)):0===u.parity()?(u.fshr(1),I.copy(y),I.conj(),p.copy(B),p.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(p),f.xtr_D()):1==c.parity()?(u.sub(c),u.norm(),u.fshr(1),p.copy(E),p.xtr_A(f,B,y),f.xtr_D(),y.copy(E),y.xtr_D(),y.conj(),E.copy(p)):(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),p.copy(B),p.xtr_D(),B.copy(y),B.conj(),y.copy(p),y.conj(),p.copy(E),p.xtr_D(),E.copy(f),f.copy(p))),t.BIG.comp(u,c)<0&&(a.copy(u),a.imul(4),a.norm(),t.BIG.comp(c,a)<=0?(c.sub(u),c.norm(),p.copy(E),p.xtr_A(f,B,y),y.copy(B),B.copy(f),f.copy(p)):0===c.parity()?(a.copy(u),u.copy(c),u.fshr(1),c.copy(a),p.copy(B),p.xtr_D(),B.copy(y),B.conj(),y.copy(p),y.conj(),p.copy(E),p.xtr_D(),E.copy(f),f.copy(p)):1==u.parity()?(a.copy(c),c.copy(u),a.sub(u),a.norm(),u.copy(a),u.fshr(1),p.copy(E),p.xtr_A(f,B,y),B.conj(),y.copy(f),y.xtr_D(),y.conj(),f.copy(E),f.xtr_D(),E.copy(p)):(u.fshr(1),I.copy(y),I.conj(),p.copy(B),p.xtr_A(f,E,I),y.copy(B),y.xtr_D(),B.copy(p),f.xtr_D()));for(I.copy(E),I.xtr_A(f,B,y),h=0;h>31))-e)-1)/2,this.cmove(t[0],n.teq(o,0)),this.cmove(t[1],n.teq(o,1)),this.cmove(t[2],n.teq(o,2)),this.cmove(t[3],n.teq(o,3)),this.cmove(t[4],n.teq(o,4)),this.cmove(t[5],n.teq(o,5)),this.cmove(t[6],n.teq(o,6)),this.cmove(t[7],n.teq(o,7)),r.copy(this),r.conj(),this.cmove(r,1&e)},geta:function(){return this.a},getb:function(){return this.b},getc:function(){return this.c},equals:function(t){return this.a.equals(t.a)&&this.b.equals(t.b)&&this.c.equals(t.c)},copy:function(t){this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c)},one:function(){this.a.one(),this.b.zero(),this.c.zero()},conj:function(){this.a.conj(),this.b.nconj(),this.c.conj()},set:function(t,n,i){this.a.copy(t),this.b.copy(n),this.c.copy(i)},seta:function(t){this.a.copy(t),this.b.zero(),this.c.zero()},usqr:function(){var n=new t.FP16(this.a),i=new t.FP16(this.c),e=new t.FP16(this.b),o=new t.FP16(0);this.a.sqr(),o.copy(this.a),o.add(this.a),this.a.add(o),n.nconj(),n.add(n),this.a.add(n),i.sqr(),i.times_i(),o.copy(i),o.add(i),i.add(o),e.sqr(),o.copy(e),o.add(e),e.add(o),this.b.conj(),this.b.add(this.b),this.c.nconj(),this.c.add(this.c),this.b.add(i),this.c.add(e),this.reduce()},sqr:function(){var n=new t.FP16(this.a),i=new t.FP16(this.b),e=new t.FP16(this.c),o=new t.FP16(this.a);n.sqr(),i.mul(this.c),i.add(i),e.sqr(),o.mul(this.b),o.add(o),this.c.add(this.a),this.c.add(this.b),this.c.norm(),this.c.sqr(),this.a.copy(n),n.add(i),n.add(e),n.add(o),n.neg(),i.times_i(),e.times_i(),this.a.add(i),this.b.copy(e),this.b.add(o),this.c.add(n),this.norm()},mul:function(n){var i=new t.FP16(this.a),e=new t.FP16(0),o=new t.FP16(this.b),r=new t.FP16(0),s=new t.FP16(this.a),h=new t.FP16(n.a);i.mul(n.a),o.mul(n.b),s.add(this.b),h.add(n.b),s.norm(),h.norm(),e.copy(s),e.mul(h),s.copy(this.b),s.add(this.c),h.copy(n.b),h.add(n.c),s.norm(),h.norm(),r.copy(s),r.mul(h),s.copy(i),s.neg(),h.copy(o),h.neg(),e.add(s),this.b.copy(e),this.b.add(h),r.add(h),o.add(s),s.copy(this.a),s.add(this.c),h.copy(n.a),h.add(n.c),s.norm(),h.norm(),s.mul(h),o.add(s),s.copy(this.c),s.mul(n.c),h.copy(s),h.neg(),this.c.copy(o),this.c.add(h),r.add(h),s.times_i(),this.b.add(s),r.times_i(),this.a.copy(i),this.a.add(r),this.norm()},smul:function(n,i){var e,o,r,s,h,c;i==t.ECP.D_TYPE&&(e=new t.FP16(this.a),r=new t.FP16(this.b),s=new t.FP16(this.b),h=new t.FP16(0),c=new t.FP16(n.a),e.mul(n.a),r.pmul(n.b.real()),this.b.add(this.a),c.real().add(n.b.real()),this.b.norm(),c.norm(),this.b.mul(c),s.add(this.c),s.norm(),s.pmul(n.b.real()),h.copy(e),h.neg(),c.copy(r),c.neg(),this.b.add(h),this.b.add(c),s.add(c),r.add(h),h.copy(this.a),h.add(this.c),h.norm(),h.mul(n.a),this.c.copy(r),this.c.add(h),s.times_i(),this.a.copy(e),this.a.add(s)),i==t.ECP.M_TYPE&&(e=new t.FP16(this.a),o=new t.FP16(0),r=new t.FP16(0),s=new t.FP16(0),h=new t.FP16(this.a),c=new t.FP16(0),e.mul(n.a),h.add(this.b),h.norm(),o.copy(h),o.mul(n.a),h.copy(this.b),h.add(this.c),h.norm(),s.copy(h),s.pmul(n.c.getb()),s.times_i(),h.copy(e),h.neg(),o.add(h),this.b.copy(o),r.copy(h),h.copy(this.a),h.add(this.c),c.copy(n.a),c.add(n.c),h.norm(),c.norm(),h.mul(c),r.add(h),h.copy(this.c),h.pmul(n.c.getb()),h.times_i(),c.copy(h),c.neg(),this.c.copy(r),this.c.add(c),s.add(c),h.times_i(),this.b.add(h),s.norm(),s.times_i(),this.a.copy(e),this.a.add(s)),this.norm()},inverse:function(){var n=new t.FP16(this.a),i=new t.FP16(this.b),e=new t.FP16(this.a),o=new t.FP16(0);n.sqr(),i.mul(this.c),i.times_i(),n.sub(i),n.norm(),i.copy(this.c),i.sqr(),i.times_i(),e.mul(this.b),i.sub(e),i.norm(),e.copy(this.b),e.sqr(),o.copy(this.a),o.mul(this.c),e.sub(o),e.norm(),o.copy(this.b),o.mul(e),o.times_i(),this.a.mul(n),o.add(this.a),this.c.mul(i),this.c.times_i(),o.add(this.c),o.norm(),o.inverse(),this.a.copy(n),this.a.mul(o),this.b.copy(i),this.b.mul(o),this.c.copy(e),this.c.mul(o)},frob:function(n,i){var e,o=new t.FP2(n),r=new t.FP2(n);for(o.sqr(),r.mul(o),r.mul_ip(),r.norm(),r.mul_ip(),r.norm(),e=0;e=1;r--)o.usqr(),1==(s=e.bit(r)-i.bit(r))&&o.mul(this),-1==s&&(this.conj(),o.mul(this),this.conj());return o.reduce(),o},pinpow:function(t,i){var e,o,r=[];for(r[0]=new n(1),r[1]=new n(this),e=i-1;e>=0;e--)r[1-(o=t>>e&1)].mul(r[o]),r[o].usqr();this.copy(r[0])},compow:function(i,e){var o,r,s,h,c,u,a,f,E,B,y,I,p;return(o=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(r=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),s=new t.FP2(o,r),(h=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),(c=new t.BIG(h)).mod(e),(u=new t.BIG(i)).mod(c),(a=new t.BIG(i)).div(c),f=new n(0),E=new n(0),f.copy(this),B=f.trace(),a.iszilch()?B=B.xtr_pow(i):(E.copy(f),E.frob(s,1),y=E.trace(),f.conj(),E.mul(f),I=E.trace(),E.mul(f),p=E.trace(),B=B.xtr_pow2(y,I,p,u,a))}},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I=[];for(e=0;e>31&1},n.pow16=function(i,e){var o,r,s,h,c,u,a,f,E,B,y=[],I=[],p=[],m=[],d=new n(0),l=new n(0),w=[],_=new t.BIG(0),S=new t.BIG(0),P=new t.BIG(0),T=[],C=[],b=[],G=[],R=[],g=[],M=[],O=[];for(o=0;o<16;o++)w[o]=new t.BIG(e[o]),w[o].norm();for(y[0]=new n(i[0]),y[1]=new n(y[0]),y[1].mul(i[1]),y[2]=new n(y[0]),y[2].mul(i[2]),y[3]=new n(y[1]),y[3].mul(i[2]),y[4]=new n(i[0]),y[4].mul(i[3]),y[5]=new n(y[1]),y[5].mul(i[3]),y[6]=new n(y[2]),y[6].mul(i[3]),y[7]=new n(y[3]),y[7].mul(i[3]),S.rcopy(t.ROM_FIELD.Fra),P.rcopy(t.ROM_FIELD.Frb),B=new t.FP2(S,P),o=0;o<8;o++)I[o]=new n(y[o]),I[o].frob(B,4),p[o]=new n(I[o]),p[o].frob(B,4),m[o]=new n(p[o]),m[o].frob(B,4);for(u=1-w[0].parity(),w[0].inc(u),w[0].norm(),a=1-w[4].parity(),w[4].inc(a),w[4].norm(),f=1-w[8].parity(),w[8].inc(f),w[8].norm(),E=1-w[12].parity(),w[12].inc(E),w[12].norm(),_.zero(),o=0;o<16;o++)_.or(w[o]);for(C[(h=1+_.nbits())-1]=1,G[h-1]=1,g[h-1]=1,O[h-1]=1,o=0;o>1),w[r].norm(),T[o]+=c*s,s*=2;for(b[o]=0,s=1,r=5;r<8;r++)c=G[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),b[o]+=c*s,s*=2;for(R[o]=0,s=1,r=9;r<12;r++)c=g[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),R[o]+=c*s,s*=2;for(M[o]=0,s=1,r=13;r<16;r++)c=O[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),M[o]+=c*s,s*=2}for(l.select(y,2*T[h-1]+1),d.select(I,2*b[h-1]+1),l.mul(d),d.select(p,2*R[h-1]+1),l.mul(d),d.select(m,2*M[h-1]+1),l.mul(d),o=h-2;o>=0;o--)l.usqr(),d.select(y,2*T[o]+C[o]),l.mul(d),d.select(I,2*b[o]+G[o]),l.mul(d),d.select(p,2*R[o]+g[o]),l.mul(d),d.select(m,2*M[o]+O[o]),l.mul(d);return d.copy(i[0]),d.conj(),d.mul(l),l.cmove(d,u),d.copy(i[4]),d.conj(),d.mul(l),l.cmove(d,a),d.copy(i[8]),d.conj(),d.mul(l),l.cmove(d,f),d.copy(i[12]),d.conj(),d.mul(l),l.cmove(d,E),l.reduce(),l},n}(h),h.ECP8=function(t){var n=function(){this.x=new t.FP8(0),this.y=new t.FP8(1),this.z=new t.FP8(0)};return n.prototype={is_infinity:function(){return this.x.reduce(),this.y.reduce(),this.z.reduce(),this.x.iszilch()&&this.z.iszilch()},copy:function(t){this.x.copy(t.x),this.y.copy(t.y),this.z.copy(t.z)},inf:function(){this.x.zero(),this.y.one(),this.z.zero()},cmove:function(t,n){this.x.cmove(t.x,n),this.y.cmove(t.y,n),this.z.cmove(t.z,n)},select:function(t,i){var e=new n,o=i>>31,r=(i^o)-o;r=(r-1)/2,this.cmove(t[0],n.teq(r,0)),this.cmove(t[1],n.teq(r,1)),this.cmove(t[2],n.teq(r,2)),this.cmove(t[3],n.teq(r,3)),this.cmove(t[4],n.teq(r,4)),this.cmove(t[5],n.teq(r,5)),this.cmove(t[6],n.teq(r,6)),this.cmove(t[7],n.teq(r,7)),e.copy(this),e.neg(),this.cmove(e,1&o)},equals:function(n){var i,e;return i=new t.FP8(this.x),e=new t.FP8(n.x),i.mul(n.z),e.mul(this.z),!!i.equals(e)&&(i.copy(this.y),i.mul(n.z),e.copy(n.y),e.mul(this.z),!!i.equals(e))},neg:function(){this.y.norm(),this.y.neg(),this.y.norm()},affine:function(){var n;if(!this.is_infinity()){if(n=new t.FP8(1),this.z.equals(n))return this.x.reduce(),void this.y.reduce();this.z.inverse(),this.x.mul(this.z),this.x.reduce(),this.y.mul(this.z),this.y.reduce(),this.z.copy(n)}},getX:function(){return this.affine(),this.x},getY:function(){return this.affine(),this.y},getx:function(){return this.x},gety:function(){return this.y},getz:function(){return this.z},toBytes:function(n){var i,e=[];for(this.affine(),this.x.geta().geta().getA().toBytes(e),i=0;i=0;e--)f.select(E,B[e]),a.dbl(),a.dbl(),a.dbl(),a.dbl(),a.add(f);return a.sub(u),a.affine(),a}},n.generator=function(){var i,e,o,r,s,h,c,u,a,f,E,B,y,I,p=new n,m=new t.BIG(0),d=new t.BIG(0);return m.rcopy(t.ROM_CURVE.CURVE_Pxaaa),d.rcopy(t.ROM_CURVE.CURVE_Pxaab),i=new t.FP2(m,d),m.rcopy(t.ROM_CURVE.CURVE_Pxaba),d.rcopy(t.ROM_CURVE.CURVE_Pxabb),e=new t.FP2(m,d),o=new t.FP4(i,e),m.rcopy(t.ROM_CURVE.CURVE_Pxbaa),d.rcopy(t.ROM_CURVE.CURVE_Pxbab),r=new t.FP2(m,d),m.rcopy(t.ROM_CURVE.CURVE_Pxbba),d.rcopy(t.ROM_CURVE.CURVE_Pxbbb),s=new t.FP2(m,d),h=new t.FP4(r,s),c=new t.FP8(o,h),m.rcopy(t.ROM_CURVE.CURVE_Pyaaa),d.rcopy(t.ROM_CURVE.CURVE_Pyaab),u=new t.FP2(m,d),m.rcopy(t.ROM_CURVE.CURVE_Pyaba),d.rcopy(t.ROM_CURVE.CURVE_Pyabb),a=new t.FP2(m,d),f=new t.FP4(u,a),m.rcopy(t.ROM_CURVE.CURVE_Pybaa),d.rcopy(t.ROM_CURVE.CURVE_Pybab),E=new t.FP2(m,d),m.rcopy(t.ROM_CURVE.CURVE_Pybba),d.rcopy(t.ROM_CURVE.CURVE_Pybbb),B=new t.FP2(m,d),y=new t.FP4(E,B),I=new t.FP8(f,y),p.setxy(c,I),p},n.fromBytes=function(i){var e,o,r,s,h,c,u,a,f,E,B=[];for(u=0;u>1),w[r].norm(),_[o]+=c*s,s*=2;for(P[o]=0,s=1,r=5;r<8;r++)c=T[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),P[o]+=c*s,s*=2;for(C[o]=0,s=1,r=9;r<12;r++)c=b[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),C[o]+=c*s,s*=2;for(G[o]=0,s=1,r=13;r<16;r++)c=R[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),G[o]+=c*s,s*=2}for(y.select(I,2*_[h-1]+1),B.select(p,2*P[h-1]+1),y.add(B),B.select(m,2*C[h-1]+1),y.add(B),B.select(d,2*G[h-1]+1),y.add(B),o=h-2;o>=0;o--)y.dbl(),B.select(I,2*_[o]+S[o]),y.add(B),B.select(p,2*P[o]+T[o]),y.add(B),B.select(m,2*C[o]+b[o]),y.add(B),B.select(d,2*G[o]+R[o]),y.add(B);return B.copy(y),B.sub(i[0]),y.cmove(B,u),B.copy(y),B.sub(i[4]),y.cmove(B,a),B.copy(y),B.sub(i[8]),y.cmove(B,f),B.copy(y),B.sub(i[12]),y.cmove(B,E),y.affine(),y},n.teq=function(t,n){var i=t^n;return(i-=1)>>31&1},n.mapit=function(i){var e,o,r,s,h,c,u,a,f,E,B,y,I,p,m,d=n.frob_constants();for((e=new t.BIG(0)).rcopy(t.ROM_FIELD.Modulus),o=t.BIG.fromBytes(i),r=new t.BIG(1),o.mod(e);c=new t.FP2(r,o),u=new t.FP4(c),h=new t.FP8(u),(s=new n).setx(h),s.is_infinity();)o.inc(1),o.norm();return(o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),m=(p=(I=(y=(B=(E=(f=(a=s.mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o)).mul(o),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(a.neg(),E.neg(),y.neg(),p.neg()),m.sub(p),m.sub(s),p.sub(I),p.frob(d,1),I.sub(y),I.frob(d,2),y.sub(B),y.frob(d,3),B.sub(E),B.frob(d,4),E.sub(f),E.frob(d,5),f.sub(a),f.frob(d,6),a.sub(s),a.frob(d,7),s.dbl(),s.frob(d,8),s.add(m),s.add(p),s.add(I),s.add(y),s.add(B),s.add(E),s.add(f),s.add(a),s.affine(),s},n.frob_constants=function(){var n,i,e,o,r=new t.BIG(0),s=new t.BIG(0),h=[];return r.rcopy(t.ROM_FIELD.Fra),s.rcopy(t.ROM_FIELD.Frb),n=new t.FP2(r,s),(i=new t.FP2(n)).sqr(),(o=new t.FP2(i)).mul_ip(),o.norm(),(e=new t.FP2(o)).sqr(),o.mul(e),o.mul_ip(),o.norm(),e.copy(n),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(e.mul_ip(),e.inverse(),i.copy(e),i.sqr()),i.mul_ip(),i.norm(),e.mul(i),h[0]=new t.FP2(i),h[1]=new t.FP2(e),h[2]=new t.FP2(o),h},n}(h),h.PAIR256=function(t){var n={line:function(n,i,e,o){var r,s,h,c,u,a,f,E,B,y,I,p,m=new t.FP48(1);return n==i?(r=new t.FP8(n.getx()),s=new t.FP8(n.gety()),h=new t.FP8(n.getz()),(c=new t.FP8(s)).mul(h),r.sqr(),s.sqr(),h.sqr(),c.imul(4),c.neg(),c.norm(),c.tmul(o),r.imul(6),r.tmul(e),u=3*t.ROM_CURVE.CURVE_B_I,h.imul(u),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&h.div_2i(),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(h.times_i(),h.add(h),c.times_i(),c.norm()),h.norm(),s.add(s),h.sub(s),h.norm(),y=new t.FP16(c,h),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP16(r),p=new t.FP16(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP16(0),(p=new t.FP16(r)).times_i()),n.dbl()):(a=new t.FP8(n.getx()),f=new t.FP8(n.gety()),E=new t.FP8(n.getz()),B=new t.FP8(n.getz()),E.mul(i.gety()),B.mul(i.getx()),a.sub(B),a.norm(),f.sub(E),f.norm(),E.copy(a),a.tmul(o),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(a.times_i(),a.norm()),E.mul(i.gety()),B.copy(f),B.mul(i.getx()),B.sub(E),B.norm(),f.tmul(e),f.neg(),f.norm(),y=new t.FP16(a,B),t.ECP.SEXTIC_TWIST==t.ECP.D_TYPE&&(I=new t.FP16(f),p=new t.FP16(0)),t.ECP.SEXTIC_TWIST==t.ECP.M_TYPE&&(I=new t.FP16(0),(p=new t.FP16(f)).times_i()),n.add(i)),m.set(y,I,p),m},ate:function(i,e){var o,r,s,h,c,u,a,f,E,B;for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),r=new t.BIG(o),(s=new t.BIG(r)).pmul(3),s.norm(),c=new t.FP(e.getx()),u=new t.FP(e.gety()),a=new t.ECP8,f=new t.FP48(1),a.copy(i),B=s.nbits()-2;B>=1;B--)f.sqr(),h=n.line(a,a,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),1==(E=s.bit(B)-r.bit(B))&&(h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST)),-1==E&&(i.neg(),h=n.line(a,i,c,u),f.smul(h,t.ECP.SEXTIC_TWIST),i.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&f.conj(),f},ate2:function(i,e,o,r){var s,h,c,u,a,f,E,B,y,I,p,m,d;for((s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),h=new t.BIG(s),(c=new t.BIG(h)).pmul(3),c.norm(),a=new t.FP(e.getx()),f=new t.FP(e.gety()),E=new t.FP(r.getx()),B=new t.FP(r.gety()),y=new t.ECP8,I=new t.ECP8,p=new t.FP48(1),y.copy(i),I.copy(o),d=c.nbits()-2;d>=1;d--)p.sqr(),u=n.line(y,y,a,f),p.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,I,E,B),p.smul(u,t.ECP.SEXTIC_TWIST),1==(m=c.bit(d)-h.bit(d))&&(u=n.line(y,i,a,f),p.smul(u,t.ECP.SEXTIC_TWIST),u=n.line(I,o,E,B),p.smul(u,t.ECP.SEXTIC_TWIST)),-1==m&&(i.neg(),u=n.line(y,i,a,f),p.smul(u,t.ECP.SEXTIC_TWIST),i.neg(),o.neg(),u=n.line(I,o,E,B),p.smul(u,t.ECP.SEXTIC_TWIST),o.neg());return t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&p.conj(),p},fexp:function(n){var i,e,o,r,s,h,c,u,a,f;return(i=new t.BIG(0)).rcopy(t.ROM_FIELD.Fra),(e=new t.BIG(0)).rcopy(t.ROM_FIELD.Frb),o=new t.FP2(i,e),(r=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),s=new t.FP48(n),(h=new t.FP48(s)).inverse(),s.conj(),s.mul(h),h.copy(s),s.frob(o,8),s.mul(h),(f=new t.FP48(s)).usqr(),c=f.pow(r),r.fshr(1),u=c.pow(r),r.fshl(1),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),(a=new t.FP48(c)).conj(),u.mul(a),u.mul(s),s.mul(f),c=u.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,14),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,13),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,12),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,11),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,10),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,9),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,8),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(u),a.conj(),c.mul(a),a.copy(c),a.frob(o,7),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,6),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,5),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,4),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,3),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,2),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),a.copy(c),a.frob(o,1),s.mul(a),c=c.pow(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&c.conj(),s.mul(c),u.frob(o,15),s.mul(u),s.reduce(),s},glv:function(n){var i,e,o,r=[];return(i=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),o=t.BIG.smul(e,e),e=t.BIG.smul(o,o),o=t.BIG.smul(e,e),r[0]=new t.BIG(n),r[0].mod(o),r[1]=new t.BIG(n),r[1].div(o),r[1].rsub(i),r},gs:function(n){var i,e,o,r,s=[];for((o=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Bnx),(e=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),r=new t.BIG(n),i=0;i<15;i++)s[i]=new t.BIG(r),s[i].mod(o),r.div(o);return s[15]=new t.BIG(r),t.ECP.SIGN_OF_X==t.ECP.NEGATIVEX&&(s[1].copy(t.BIG.modneg(s[1],e)),s[3].copy(t.BIG.modneg(s[3],e)),s[5].copy(t.BIG.modneg(s[5],e)),s[7].copy(t.BIG.modneg(s[7],e)),s[9].copy(t.BIG.modneg(s[9],e)),s[11].copy(t.BIG.modneg(s[11],e)),s[13].copy(t.BIG.modneg(s[13],e)),s[15].copy(t.BIG.modneg(s[15],e))),s},G1mul:function(i,e){var o,r,s,h,c,u,a,f;return t.ROM_CURVE.USE_GLV?(i.affine(),(o=new t.ECP).copy(i),(r=new t.ECP).copy(i),(s=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Order),(h=new t.BIG(0)).rcopy(t.ROM_CURVE.CURVE_Cru),c=new t.FP(h),u=new t.BIG(0),a=n.glv(e),r.getx().mul(c),f=a[0].nbits(),u.copy(t.BIG.modneg(a[0],s)),u.nbits()>>4&15).toString(16),e+=(15&n).toString(16);return e},stringtobytes:function(t){var n,i=[];for(n=0;n0&&r.process_num(i),r.process_array(e),0==(o=r.hash()).length)return null;if(s=[],n>=(c=t.BIG.MODBYTES))for(h=0;h>1&1,h=this.map(r,e),(c=this.map(s,o)).add(h),r=c.getX(),s=c.getY(),n[0]=4,r.toBytes(u),i=0;i4*this.TRAP);){if(e=f.geta().geta().geta().geta().getA().lastbits(20)%this.TS,f.mul(I[e]),c+=B[e],f.equals(y)){u=c-h;break}if(f.equals(E)){u=h-c;break}}return(a>4*this.TRAP||c-h>=this.MAXPIN)&&(u=0),u},GET_TIME:function(){var t=new Date;return Math.floor(t.getTime()/1e3)},GET_Y:function(n,i,e,o){var r=new t.BIG(0),s=this.hashit(n,i,e),h=t.BIG.fromBytes(s);return r.rcopy(t.ROM_CURVE.CURVE_Order),h.mod(r),h.toBytes(o),0},CLIENT:function(t,n,i,e,o,r,s,h,c,u,a,f,E,B){var y,I,p=0,m=[];if(0==n?y=c:(y=u,c=null),0!=(p=this.CLIENT_1(t,n,i,e,o,r,s,h,c,u,a)))return p;if(m=y.slice(),void 0!==B||null!=B)for(I=0;I6||t.defaultPinLength<4)&&(t.defaultPinLength=4),t.requestTimeout&&!isNaN(t.requestTimeout)||(t.requestTimeout=4e3),t.oidc||(t.oidc={}),t.clientName="MIRACL Client.js/8.8.0"+(t.applicationInfo?" "+t.applicationInfo:""),n.options=t,n.http=new u(t.requestTimeout,t.clientName,t.projectId,t.cors),n.crypto=new h(t.seed),n.users=new c(t.userStorage,t.projectId,"mfa")}h.prototype._crypto=function(t){return t||(t="BN254CX"),s[t]||(s[t]=new r(t),s[t].MPIN.MAXPIN=1e6,s[t].MPIN.PBLEN=20,s[t].MPIN.TRAP=2e3),s[t]},h.prototype.generateKeypair=function(t){var n,i=this,e=[],o=[];if(0!=(n=i._crypto(t).MPIN.GET_DVS_KEYPAIR(i.rng,e,o)))throw new Error("Could not generate key pair: "+n);return{publicKey:i._bytesToHex(o),privateKey:i._bytesToHex(e)}},h.prototype.addShares=function(t,n,i,e){var o,r,s,h,c=this,u=[];if(o=c._hexToBytes(t),r=c._hexToBytes(n),s=c._hexToBytes(i),0!==(h=c._crypto(e).MPIN.RECOMBINE_G1(r,s,u)))throw new Error("Could not combine the client secret shares: "+h);if(0!=(h=c._crypto(e).MPIN.GET_G1_MULTIPLE(null,0,o,u,u)))throw new Error("Could not combine private key with client secret: "+h);return c._bytesToHex(u)},h.prototype.extractPin=function(t,n,i,e,o){var r,s,h,c=this;if(r=c._hexToBytes(e),s=c._hexToBytes(c._mpinIdWithPublicKey(t,n)),0!==(h=c._crypto(o).MPIN.EXTRACT_PIN(c._crypto(o).MPIN.SHA256,s,i,r)))throw new Error("Could not extract PIN from client secret: "+h);return c._bytesToHex(r)},h.prototype.calculatePass1=function(t,n,i,e,o,r,s){var h,c,u=this,a=[],f=[];if(h=u._mpinIdWithPublicKey(n,i),0!==(c=u._crypto(t).MPIN.CLIENT_1(u._crypto(t).MPIN.SHA256,0,u._hexToBytes(h),u.rng,r,o,u._hexToBytes(e),s,a,f,u._hexToBytes(0))))throw new Error("Could not calculate pass 1 request data: "+c);return{UT:u._bytesToHex(f),U:u._bytesToHex(a)}},h.prototype.calculatePass2=function(t,n,i,e){var o,r=this;if(0!==(o=r._crypto(t).MPIN.CLIENT_2(n,r._hexToBytes(i),e)))throw new Error("Could not calculate pass 2 request data: "+o);return r._bytesToHex(e)},h.prototype.sign=function(t,n,i,e,o,r,s){var h,c,u=this,a=[],f=[];if(h=u._mpinIdWithPublicKey(n,i),0!=(c=u._crypto(t).MPIN.CLIENT(u._crypto(t).MPIN.SHA256,0,u._hexToBytes(h),u.rng,[],o,u._hexToBytes(e),a,f,null,null,s,[],u._hexToBytes(r))))throw new Error("Could not sign message: "+c);return{U:u._bytesToHex(f),V:u._bytesToHex(a)}},h.prototype._mpinIdWithPublicKey=function(t,n){var i,e=this,o=e._hexToBytes(t),r=e._hexToBytes(n);if(o){if(!r)return t;for(i=0;i>>4&15).toString(16),e+=(15&n).toString(16);return e},c.prototype.data=[],c.prototype.states={start:"STARTED",register:"REGISTERED",revoked:"REVOKED"},c.prototype.loadData=function(){var t=this;t.data=JSON.parse(t.storage.getItem(t.storageKey))||[],t.store(),t.data.sort((function(t,n){return t.lastUsed&&(!n.lastUsed||t.lastUsed>n.lastUsed)?1:n.lastUsed&&(!t.lastUsed||t.lastUsed{t(...n,(function(t,n){t?e(t):i(n)}))}))}return class extends a{fetchAccessId(t){return f(super.fetchAccessId.bind(this),t)}fetchStatus(){return f(super.fetchStatus.bind(this))}sendPushNotificationForAuth(t){return f(super.sendPushNotificationForAuth.bind(this),t)}sendVerificationEmail(t){return f(super.sendVerificationEmail.bind(this),t)}getActivationToken(t){return f(super.getActivationToken.bind(this),t)}register(t,n,i){return f(super.register.bind(this),t,n,i)}authenticate(t,n){return f(super.authenticate.bind(this),t,n)}authenticateWithQRCode(t,n,i){return f(super.authenticateWithQRCode.bind(this),t,n,i)}authenticateWithAppLink(t,n,i){return f(super.authenticateWithAppLink.bind(this),t,n,i)}authenticateWithNotificationPayload(t,n){return f(super.authenticateWithNotificationPayload.bind(this),t,n)}generateQuickCode(t,n){return f(super.generateQuickCode.bind(this),t,n)}sign(t,n,i,e){return f(super.sign.bind(this),t,n,i,e)}}}(); diff --git a/example/example.html b/example/example.html deleted file mode 100644 index dc937dd..0000000 --- a/example/example.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - MFA example - - - - - - -
MFA example:
- Setup flow - - - - diff --git a/package-lock.json b/package-lock.json index cf890f9..a957955 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@miracl/client-js", - "version": "8.7.0", + "version": "8.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@miracl/client-js", - "version": "8.7.0", + "version": "8.8.0", "license": "Apache-2.0", "dependencies": { "@miracl/crypto-js": "^4.0.0" diff --git a/package.json b/package.json index e7149af..ad6d1f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@miracl/client-js", - "version": "8.7.0", + "version": "8.8.0", "description": "MIRACL Trust client library", "main": "./src/client.js", "exports": { diff --git a/src/client.js b/src/client.js index 0d64038..d374741 100644 --- a/src/client.js +++ b/src/client.js @@ -5,7 +5,7 @@ import HTTP from "./http.js"; /** * @class * @param {Object} options - * @param {string} options.server - Server address, defaults to https://api.mpin.io + * @param {string} options.projectUrl - MIRACL Trust Project URL that is used for communication with the MIRACL Trust API * @param {string} options.projectId - MIRACL Trust Project ID * @param {string} options.seed - Hex encoded random number generator seed * @param {string} options.deviceName - Name of the current device @@ -35,11 +35,11 @@ export default function Client(options) { throw new Error("Invalid user storage"); } - if (!options.server) { - options.server = "https://api.mpin.io"; + if (!options.projectUrl) { + options.projectUrl = "https://api.mpin.io"; } else { // remove trailing slash from url, if there is one - options.server = options.server.replace(/\/$/, ""); + options.projectUrl = options.projectUrl.replace(/\/$/, ""); } // Ensure that default PIN lenght is between 4 and 6 @@ -56,7 +56,7 @@ export default function Client(options) { } // Set the client name using the current lib version and provided application info - options.clientName = "MIRACL Client.js/8.7.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); + options.clientName = "MIRACL Client.js/8.8.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); self.options = options; @@ -91,7 +91,7 @@ Client.prototype.fetchAccessId = function (userId, callback) { reqData; reqData = { - url: self.options.server + "/rps/v2/session", + url: self.options.projectUrl + "/rps/v2/session", type: "POST", data: { projectId: self.options.projectId, @@ -120,7 +120,7 @@ Client.prototype.fetchStatus = function (callback) { reqData; reqData = { - url: self.options.server + "/rps/v2/access", + url: self.options.projectUrl + "/rps/v2/access", type: "POST", data: { webOTT: self.session.webOTT @@ -151,7 +151,7 @@ Client.prototype.sendPushNotificationForAuth = function (userId, callback) { } reqData = { - url: self.options.server + "/pushauth?" + self._urlEncode(self.options.oidc), + url: self.options.projectUrl + "/pushauth?" + self._urlEncode(self.options.oidc), type: "POST", data: { prerollId: userId @@ -187,7 +187,7 @@ Client.prototype.sendVerificationEmail = function (userId, callback) { return callback(new Error("Empty user ID"), null); } - reqData.url = self.options.server + "/verification/email"; + reqData.url = self.options.projectUrl + "/verification/email"; reqData.type = "POST"; reqData.data = { userId: userId, @@ -236,7 +236,7 @@ Client.prototype.getActivationToken = function (verificationURI, callback) { return callback(new Error("Empty verification code"), null); } - reqData.url = self.options.server + "/verification/confirmation"; + reqData.url = self.options.projectUrl + "/verification/confirmation"; reqData.type = "POST"; reqData.data = { userId: params["user_id"], @@ -326,7 +326,7 @@ Client.prototype._createMPinID = function (userId, activationToken, keypair, cal var self = this, regData = {}; - regData.url = self.options.server + "/registration"; + regData.url = self.options.projectUrl + "/registration"; regData.type = "POST"; regData.data = { userId: userId, @@ -475,7 +475,7 @@ Client.prototype.generateQuickCode = function (userId, userPin, callback) { } self.http.request({ - url: self.options.server + "/verification/quickcode", + url: self.options.projectUrl + "/verification/quickcode", type: "POST", data: { projectId: self.options.projectId, @@ -589,7 +589,7 @@ Client.prototype._getPass1 = function (identityData, userPin, scope, X, SEC, cal U: res.U }; - self.http.request({ url: self.options.server + "/rps/v2/pass1", type: "POST", data: requestData }, callback); + self.http.request({ url: self.options.projectUrl + "/rps/v2/pass1", type: "POST", data: requestData }, callback); }; /** @@ -624,7 +624,7 @@ Client.prototype._getPass2 = function (identityData, scope, yHex, X, SEC, callba V: vHex }; - self.http.request({ url: self.options.server + "/rps/v2/pass2", type: "POST", data: requestData}, callback); + self.http.request({ url: self.options.projectUrl + "/rps/v2/pass2", type: "POST", data: requestData}, callback); }; Client.prototype._finishAuthentication = function (userId, userPin, scope, authOTT, callback) { @@ -636,7 +636,7 @@ Client.prototype._finishAuthentication = function (userId, userPin, scope, authO "wam": "dvs" }; - self.http.request({ url: self.options.server + "/rps/v2/authenticate", type: "POST", data: requestData }, function (err, result) { + self.http.request({ url: self.options.projectUrl + "/rps/v2/authenticate", type: "POST", data: requestData }, function (err, result) { if (err) { return callback(err, result); } diff --git a/test/init.js b/test/init.js index 332f8aa..2c85ea1 100644 --- a/test/init.js +++ b/test/init.js @@ -5,7 +5,7 @@ import storage from "./storage.js"; global.testData = { init: function () { return { - server: "http://server.com", + projectUrl: "https://project.miracl.io", projectId: "projectID", seed: "hexSeed", defaultPinLength: 4, diff --git a/test/test-authentication.js b/test/test-authentication.js index 583e7b9..f2aa941 100644 --- a/test/test-authentication.js +++ b/test/test-authentication.js @@ -15,7 +15,7 @@ describe("Client _getPass1", function () { client._getPass1({}, "1234", ["oidc"], [], [], function () { expect(requestStub.calledOnce).to.be.true; - expect(requestStub.firstCall.args[0].url).to.equal("http://server.com/rps/v2/pass1"); + expect(requestStub.firstCall.args[0].url).to.equal("https://project.miracl.io/rps/v2/pass1"); expect(requestStub.firstCall.args[0].type).to.equal("POST"); done(); }); @@ -72,7 +72,7 @@ describe("Client _getPass2", function () { client._getPass2({}, ["oidc"], "yHex", [], [], function () { expect(stub.calledOnce).to.be.true; - expect(stub.firstCall.args[0].url).to.equal("http://server.com/rps/v2/pass2"); + expect(stub.firstCall.args[0].url).to.equal("https://project.miracl.io/rps/v2/pass2"); expect(stub.firstCall.args[0].type).to.equal("POST"); done(); }); diff --git a/test/test-client.js b/test/test-client.js index 32a68ca..bbdb6be 100644 --- a/test/test-client.js +++ b/test/test-client.js @@ -31,11 +31,11 @@ describe("Client", function() { expect(client).to.be.an.instanceof(Client); }); - it("should set default server address if there is none", function () { + it("should set default server address if there is no projectUrl", function () { var config = testData.init(); - delete config["server"]; + delete config["projectUrl"]; var client = new Client(config); - expect(client.options.server).to.equal("https://api.mpin.io"); + expect(client.options.projectUrl).to.equal("https://api.mpin.io"); }); it("should set default PIN length to 4 if there is none", function () { @@ -187,7 +187,7 @@ describe("Client sendPushNotificationForAuth", function () { client.sendPushNotificationForAuth("test@example.com", function (err, data) { expect(data).to.exist; - expect(requestStub.firstCall.args[0].url).to.equal("http://server.com/pushauth?client_id=testClientID"); + expect(requestStub.firstCall.args[0].url).to.equal("https://project.miracl.io/pushauth?client_id=testClientID"); expect(data.webOTT).to.equal("test"); }); });