diff --git a/cjs/client.cjs b/cjs/client.cjs index fee74b7..8fdcc02 100644 --- a/cjs/client.cjs +++ b/cjs/client.cjs @@ -23938,14 +23938,14 @@ function Client(options) { } // Set the client name using the current lib version and provided application info - options.clientName = "MIRACL Client.js/8.12.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); + options.clientName = "MIRACL Client.js/8.13.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); this.options = options; - this.http = new HTTP(options.requestTimeout, options.clientName, this._getDeviceName(), this._getDeviceTag(), options.projectId, options.cors); - this.crypto = new Crypto(options.seed); + this.http = new HTTP(options.requestTimeout, options.clientName, this._getDeviceName(), this._getDeviceTag(), options.projectId, options.cors); + this.users = new Users(options.userStorage, options.projectId, "mfa"); } @@ -24324,6 +24324,8 @@ Client.prototype.authenticate = function (userId, userPin, callback) { }; /** + * @deprecated Use `getCrossDeviceSessionFromQRCode` and `authenticateCrossDeviceSession` instead + * * Authenticate the user for the session specified by the qrCode parameter * * @param {string} userId - The unique identifier of the user @@ -24338,6 +24340,8 @@ Client.prototype.authenticateWithQRCode = function (userId, qrCode, userPin, cal }; /** + * @deprecated Use `getCrossDeviceSessionFromLink` and `authenticateCrossDeviceSession` instead + * * Authenticate the user for the session specified by the appLink parameter * * @param {string} userId - The unique identifier of the user @@ -24352,6 +24356,8 @@ Client.prototype.authenticateWithAppLink = function (userId, appLink, userPin, c }; /** + * @deprecated Use `getCrossDeviceSessionFromNotificationPayload` and `authenticateCrossDeviceSession` instead + * * Authenticate the session specified by the push notification payload * * @param {[key: string]: string} payload - The push notification payload @@ -24593,12 +24599,6 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) return callback(new Error("Empty message"), null); } - const identityData = this.users.get(userId); - - if (!identityData.publicKey) { - return callback(new Error("Empty public key"), null); - } - this._authentication(userId, userPin, ["dvs-auth"], "", (err) => { if (err) { switch (err.message) { @@ -24611,6 +24611,8 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) } } + const identityData = this.users.get(userId); + let res; try { @@ -24634,6 +24636,7 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) /** * @typedef {Object} CrossDeviceSession + * @property {string} type * @property {string} projectId * @property {string} token * @property {string} sessionId @@ -24674,6 +24677,7 @@ Client.prototype.createCrossDeviceSession = function (userId, description, signi } callback(null, { + type: signingHash ? "signing" : "authentication", projectId: this.options.projectId, token: res.webOTT, sessionId: res.accessId, @@ -24731,7 +24735,7 @@ Client.prototype.checkCrossDeviceSessionStatus = function (crossDeviceSession, c * Send push notification for an existing cross-device session * * @param {CrossDeviceSession} crossDeviceSession - * @param (function(Error, any): void) callback + * @param {function(Error, any): void} callback */ Client.prototype.sendPushNotification = function (crossDeviceSession, callback) { if (!crossDeviceSession.userId) { @@ -24761,4 +24765,158 @@ Client.prototype.sendPushNotification = function (crossDeviceSession, callback) }); }; +/** + * Gets the CrossDeviceSession for a QR code + * + * @param {string} qrCode - The QR code URL that initiated the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromQRCode = function (qrCode, callback) { + this._getCrossDeviceSession(qrCode, callback); +}; + +/** + * Gets CrossDeviceSession for app link or universal link + * + * @param {string} link - The app link that initiated the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromLink = function (link, callback) { + this._getCrossDeviceSession(link, callback); +}; + +/** + * Gets the CrossDeviceSession from a notification payload + * + * @param {[key: string]: string} payload - The push notification payload + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromNotificationPayload = function (payload, callback) { + if (!payload || !payload["qrURL"]) { + return callback(new Error("Invalid push notification payload"), null); + } + + this._getCrossDeviceSession(payload["qrURL"], callback); +}; + +/** + * @private + * + * Get a cross-device session from a session URL + * + * @param {string} url - The URL of the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype._getCrossDeviceSession = function (url, callback) { + const accessId = url.split("#").pop(); + + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "wid", + wid: accessId + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Get cross-device session request failed", { cause: error }), null); + } + + callback(null, { + type: data.hash ? "signing" : "authentication", + projectId: data.projectId, + token: null, + sessionId: accessId, + url: url, + userId: data.prerollId || null, + description: data.description || null, + signingHash: data.hash || null, + expireTime: data.expireTime + }); + }); +}; + +/** + * Authenticate a cross-device session + * + * @param {CrossDeviceSession} crossDeviceSession + * @param {string} userId - The unique identifier of the user + * @param {string} userPin - The PIN associated with the userId + * @param {function(Error, any): void} callback + */ +Client.prototype.authenticateCrossDeviceSession = function (crossDeviceSession, userId, userPin, callback) { + if (crossDeviceSession.userId && crossDeviceSession.userId !== userId) { + return callback(new Error("Cross-device session was initiated for different user ID"), null); + } + + this._authentication(userId, userPin, ["jwt"], crossDeviceSession.sessionId, callback); +}; + +/** + * Generates a signature for a hash provided by the crossDeviceSession and updates the session + * + * @param {CrossDeviceSession} crossDeviceSession + * @param {string} userId - The unique identifier of the user + * @param {string} userPin - The PIN associated with the userId + * @param {function(Error, any): void} callback + */ +Client.prototype.signCrossDeviceSession = function (crossDeviceSession, userId, userPin, callback) { + if (crossDeviceSession.userId && crossDeviceSession.userId !== userId) { + return callback(new Error("Cross-device session was initiated for different user ID"), null); + } + + const timestamp = Math.floor(new Date().getTime() / 1000); + + this.sign(userId, userPin, crossDeviceSession.signingHash, timestamp, (error, signature) => { + if (error) { + return callback(error, null); + } + + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "signed", + wid: crossDeviceSession.sessionId, + signature: btoa(JSON.stringify(signature)) + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Updating cross-device session failed", { cause: error }), null); + } + + callback(null, data); + }); + }); +}; + +/** + * Abort a cross-device session + * + * @param {CrossDeviceSession} crossDeviceSession - The session to abort + * @param {function(Error, any): void} callback + */ +Client.prototype.abortCrossDeviceSession = function (crossDeviceSession, callback) { + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "abort", + wid: crossDeviceSession.sessionId + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Aborting cross-device session failed", { cause: error }), null); + } + + callback(null, data); + }); +}; + module.exports = Client; diff --git a/cjs/promise.cjs b/cjs/promise.cjs index fa6fb8b..f207b4a 100644 --- a/cjs/promise.cjs +++ b/cjs/promise.cjs @@ -23938,14 +23938,14 @@ function Client(options) { } // Set the client name using the current lib version and provided application info - options.clientName = "MIRACL Client.js/8.12.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); + options.clientName = "MIRACL Client.js/8.13.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); this.options = options; - this.http = new HTTP(options.requestTimeout, options.clientName, this._getDeviceName(), this._getDeviceTag(), options.projectId, options.cors); - this.crypto = new Crypto(options.seed); + this.http = new HTTP(options.requestTimeout, options.clientName, this._getDeviceName(), this._getDeviceTag(), options.projectId, options.cors); + this.users = new Users(options.userStorage, options.projectId, "mfa"); } @@ -24324,6 +24324,8 @@ Client.prototype.authenticate = function (userId, userPin, callback) { }; /** + * @deprecated Use `getCrossDeviceSessionFromQRCode` and `authenticateCrossDeviceSession` instead + * * Authenticate the user for the session specified by the qrCode parameter * * @param {string} userId - The unique identifier of the user @@ -24338,6 +24340,8 @@ Client.prototype.authenticateWithQRCode = function (userId, qrCode, userPin, cal }; /** + * @deprecated Use `getCrossDeviceSessionFromLink` and `authenticateCrossDeviceSession` instead + * * Authenticate the user for the session specified by the appLink parameter * * @param {string} userId - The unique identifier of the user @@ -24352,6 +24356,8 @@ Client.prototype.authenticateWithAppLink = function (userId, appLink, userPin, c }; /** + * @deprecated Use `getCrossDeviceSessionFromNotificationPayload` and `authenticateCrossDeviceSession` instead + * * Authenticate the session specified by the push notification payload * * @param {[key: string]: string} payload - The push notification payload @@ -24593,12 +24599,6 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) return callback(new Error("Empty message"), null); } - const identityData = this.users.get(userId); - - if (!identityData.publicKey) { - return callback(new Error("Empty public key"), null); - } - this._authentication(userId, userPin, ["dvs-auth"], "", (err) => { if (err) { switch (err.message) { @@ -24611,6 +24611,8 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) } } + const identityData = this.users.get(userId); + let res; try { @@ -24634,6 +24636,7 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) /** * @typedef {Object} CrossDeviceSession + * @property {string} type * @property {string} projectId * @property {string} token * @property {string} sessionId @@ -24674,6 +24677,7 @@ Client.prototype.createCrossDeviceSession = function (userId, description, signi } callback(null, { + type: signingHash ? "signing" : "authentication", projectId: this.options.projectId, token: res.webOTT, sessionId: res.accessId, @@ -24731,7 +24735,7 @@ Client.prototype.checkCrossDeviceSessionStatus = function (crossDeviceSession, c * Send push notification for an existing cross-device session * * @param {CrossDeviceSession} crossDeviceSession - * @param (function(Error, any): void) callback + * @param {function(Error, any): void} callback */ Client.prototype.sendPushNotification = function (crossDeviceSession, callback) { if (!crossDeviceSession.userId) { @@ -24761,6 +24765,160 @@ Client.prototype.sendPushNotification = function (crossDeviceSession, callback) }); }; +/** + * Gets the CrossDeviceSession for a QR code + * + * @param {string} qrCode - The QR code URL that initiated the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromQRCode = function (qrCode, callback) { + this._getCrossDeviceSession(qrCode, callback); +}; + +/** + * Gets CrossDeviceSession for app link or universal link + * + * @param {string} link - The app link that initiated the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromLink = function (link, callback) { + this._getCrossDeviceSession(link, callback); +}; + +/** + * Gets the CrossDeviceSession from a notification payload + * + * @param {[key: string]: string} payload - The push notification payload + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromNotificationPayload = function (payload, callback) { + if (!payload || !payload["qrURL"]) { + return callback(new Error("Invalid push notification payload"), null); + } + + this._getCrossDeviceSession(payload["qrURL"], callback); +}; + +/** + * @private + * + * Get a cross-device session from a session URL + * + * @param {string} url - The URL of the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype._getCrossDeviceSession = function (url, callback) { + const accessId = url.split("#").pop(); + + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "wid", + wid: accessId + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Get cross-device session request failed", { cause: error }), null); + } + + callback(null, { + type: data.hash ? "signing" : "authentication", + projectId: data.projectId, + token: null, + sessionId: accessId, + url: url, + userId: data.prerollId || null, + description: data.description || null, + signingHash: data.hash || null, + expireTime: data.expireTime + }); + }); +}; + +/** + * Authenticate a cross-device session + * + * @param {CrossDeviceSession} crossDeviceSession + * @param {string} userId - The unique identifier of the user + * @param {string} userPin - The PIN associated with the userId + * @param {function(Error, any): void} callback + */ +Client.prototype.authenticateCrossDeviceSession = function (crossDeviceSession, userId, userPin, callback) { + if (crossDeviceSession.userId && crossDeviceSession.userId !== userId) { + return callback(new Error("Cross-device session was initiated for different user ID"), null); + } + + this._authentication(userId, userPin, ["jwt"], crossDeviceSession.sessionId, callback); +}; + +/** + * Generates a signature for a hash provided by the crossDeviceSession and updates the session + * + * @param {CrossDeviceSession} crossDeviceSession + * @param {string} userId - The unique identifier of the user + * @param {string} userPin - The PIN associated with the userId + * @param {function(Error, any): void} callback + */ +Client.prototype.signCrossDeviceSession = function (crossDeviceSession, userId, userPin, callback) { + if (crossDeviceSession.userId && crossDeviceSession.userId !== userId) { + return callback(new Error("Cross-device session was initiated for different user ID"), null); + } + + const timestamp = Math.floor(new Date().getTime() / 1000); + + this.sign(userId, userPin, crossDeviceSession.signingHash, timestamp, (error, signature) => { + if (error) { + return callback(error, null); + } + + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "signed", + wid: crossDeviceSession.sessionId, + signature: btoa(JSON.stringify(signature)) + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Updating cross-device session failed", { cause: error }), null); + } + + callback(null, data); + }); + }); +}; + +/** + * Abort a cross-device session + * + * @param {CrossDeviceSession} crossDeviceSession - The session to abort + * @param {function(Error, any): void} callback + */ +Client.prototype.abortCrossDeviceSession = function (crossDeviceSession, callback) { + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "abort", + wid: crossDeviceSession.sessionId + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Aborting cross-device session failed", { cause: error }), null); + } + + callback(null, data); + }); +}; + class PromiseInterface extends Client { /** * @deprecated Use `createCrossDeviceSession` instead @@ -24830,6 +24988,30 @@ class PromiseInterface extends Client { sendPushNotification(crossDeviceSession) { return promisify(super.sendPushNotification.bind(this), crossDeviceSession); } + + getCrossDeviceSessionFromQRCode(qrCode) { + return promisify(super.getCrossDeviceSessionFromQRCode.bind(this), qrCode); + } + + getCrossDeviceSessionFromLink(link) { + return promisify(super.getCrossDeviceSessionFromLink.bind(this), link); + } + + getCrossDeviceSessionFromNotificationPayload(payload) { + return promisify(super.getCrossDeviceSessionFromNotificationPayload.bind(this), payload); + } + + authenticateCrossDeviceSession(crossDeviceSession, userId, userPin) { + return promisify(super.authenticateCrossDeviceSession.bind(this), crossDeviceSession, userId, userPin); + } + + signCrossDeviceSession(crossDeviceSession, userId, userPin) { + return promisify(super.signCrossDeviceSession.bind(this), crossDeviceSession, userId, userPin); + } + + abortCrossDeviceSession(crossDeviceSession) { + return promisify(super.abortCrossDeviceSession.bind(this), crossDeviceSession); + } } function promisify (original, ...args) { diff --git a/dist/client.js b/dist/client.js index 023d794..20da4cc 100644 --- a/dist/client.js +++ b/dist/client.js @@ -23939,14 +23939,14 @@ function Client(options) { } // Set the client name using the current lib version and provided application info - options.clientName = "MIRACL Client.js/8.12.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); + options.clientName = "MIRACL Client.js/8.13.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); this.options = options; - this.http = new HTTP(options.requestTimeout, options.clientName, this._getDeviceName(), this._getDeviceTag(), options.projectId, options.cors); - this.crypto = new Crypto(options.seed); + this.http = new HTTP(options.requestTimeout, options.clientName, this._getDeviceName(), this._getDeviceTag(), options.projectId, options.cors); + this.users = new Users(options.userStorage, options.projectId, "mfa"); } @@ -24325,6 +24325,8 @@ Client.prototype.authenticate = function (userId, userPin, callback) { }; /** + * @deprecated Use `getCrossDeviceSessionFromQRCode` and `authenticateCrossDeviceSession` instead + * * Authenticate the user for the session specified by the qrCode parameter * * @param {string} userId - The unique identifier of the user @@ -24339,6 +24341,8 @@ Client.prototype.authenticateWithQRCode = function (userId, qrCode, userPin, cal }; /** + * @deprecated Use `getCrossDeviceSessionFromLink` and `authenticateCrossDeviceSession` instead + * * Authenticate the user for the session specified by the appLink parameter * * @param {string} userId - The unique identifier of the user @@ -24353,6 +24357,8 @@ Client.prototype.authenticateWithAppLink = function (userId, appLink, userPin, c }; /** + * @deprecated Use `getCrossDeviceSessionFromNotificationPayload` and `authenticateCrossDeviceSession` instead + * * Authenticate the session specified by the push notification payload * * @param {[key: string]: string} payload - The push notification payload @@ -24594,12 +24600,6 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) return callback(new Error("Empty message"), null); } - const identityData = this.users.get(userId); - - if (!identityData.publicKey) { - return callback(new Error("Empty public key"), null); - } - this._authentication(userId, userPin, ["dvs-auth"], "", (err) => { if (err) { switch (err.message) { @@ -24612,6 +24612,8 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) } } + const identityData = this.users.get(userId); + let res; try { @@ -24635,6 +24637,7 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) /** * @typedef {Object} CrossDeviceSession + * @property {string} type * @property {string} projectId * @property {string} token * @property {string} sessionId @@ -24675,6 +24678,7 @@ Client.prototype.createCrossDeviceSession = function (userId, description, signi } callback(null, { + type: signingHash ? "signing" : "authentication", projectId: this.options.projectId, token: res.webOTT, sessionId: res.accessId, @@ -24732,7 +24736,7 @@ Client.prototype.checkCrossDeviceSessionStatus = function (crossDeviceSession, c * Send push notification for an existing cross-device session * * @param {CrossDeviceSession} crossDeviceSession - * @param (function(Error, any): void) callback + * @param {function(Error, any): void} callback */ Client.prototype.sendPushNotification = function (crossDeviceSession, callback) { if (!crossDeviceSession.userId) { @@ -24762,6 +24766,160 @@ Client.prototype.sendPushNotification = function (crossDeviceSession, callback) }); }; +/** + * Gets the CrossDeviceSession for a QR code + * + * @param {string} qrCode - The QR code URL that initiated the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromQRCode = function (qrCode, callback) { + this._getCrossDeviceSession(qrCode, callback); +}; + +/** + * Gets CrossDeviceSession for app link or universal link + * + * @param {string} link - The app link that initiated the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromLink = function (link, callback) { + this._getCrossDeviceSession(link, callback); +}; + +/** + * Gets the CrossDeviceSession from a notification payload + * + * @param {[key: string]: string} payload - The push notification payload + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromNotificationPayload = function (payload, callback) { + if (!payload || !payload["qrURL"]) { + return callback(new Error("Invalid push notification payload"), null); + } + + this._getCrossDeviceSession(payload["qrURL"], callback); +}; + +/** + * @private + * + * Get a cross-device session from a session URL + * + * @param {string} url - The URL of the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype._getCrossDeviceSession = function (url, callback) { + const accessId = url.split("#").pop(); + + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "wid", + wid: accessId + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Get cross-device session request failed", { cause: error }), null); + } + + callback(null, { + type: data.hash ? "signing" : "authentication", + projectId: data.projectId, + token: null, + sessionId: accessId, + url: url, + userId: data.prerollId || null, + description: data.description || null, + signingHash: data.hash || null, + expireTime: data.expireTime + }); + }); +}; + +/** + * Authenticate a cross-device session + * + * @param {CrossDeviceSession} crossDeviceSession + * @param {string} userId - The unique identifier of the user + * @param {string} userPin - The PIN associated with the userId + * @param {function(Error, any): void} callback + */ +Client.prototype.authenticateCrossDeviceSession = function (crossDeviceSession, userId, userPin, callback) { + if (crossDeviceSession.userId && crossDeviceSession.userId !== userId) { + return callback(new Error("Cross-device session was initiated for different user ID"), null); + } + + this._authentication(userId, userPin, ["jwt"], crossDeviceSession.sessionId, callback); +}; + +/** + * Generates a signature for a hash provided by the crossDeviceSession and updates the session + * + * @param {CrossDeviceSession} crossDeviceSession + * @param {string} userId - The unique identifier of the user + * @param {string} userPin - The PIN associated with the userId + * @param {function(Error, any): void} callback + */ +Client.prototype.signCrossDeviceSession = function (crossDeviceSession, userId, userPin, callback) { + if (crossDeviceSession.userId && crossDeviceSession.userId !== userId) { + return callback(new Error("Cross-device session was initiated for different user ID"), null); + } + + const timestamp = Math.floor(new Date().getTime() / 1000); + + this.sign(userId, userPin, crossDeviceSession.signingHash, timestamp, (error, signature) => { + if (error) { + return callback(error, null); + } + + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "signed", + wid: crossDeviceSession.sessionId, + signature: btoa(JSON.stringify(signature)) + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Updating cross-device session failed", { cause: error }), null); + } + + callback(null, data); + }); + }); +}; + +/** + * Abort a cross-device session + * + * @param {CrossDeviceSession} crossDeviceSession - The session to abort + * @param {function(Error, any): void} callback + */ +Client.prototype.abortCrossDeviceSession = function (crossDeviceSession, callback) { + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "abort", + wid: crossDeviceSession.sessionId + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Aborting cross-device session failed", { cause: error }), null); + } + + callback(null, data); + }); +}; + return Client; })(); diff --git a/dist/client.min.js b/dist/client.min.js index 8046c83..4d4ea61 100644 --- a/dist/client.min.js +++ b/dist/client.min.js @@ -1 +1 @@ -var MIRACLTrust=function(){"use strict";function t(t){const n=[];for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.push(encodeURIComponent(i)+"="+encodeURIComponent(t[i]));return n.join("&")}function n(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 i(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!==t)return h.config=s[t],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=o[h.config.CURVE],h.ROM_FIELD=r[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=[],O=[],M=[];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,M[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(O[o]=0,s=1,r=13;r<16;r++)c=M[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),O[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*O[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*O[o]+M[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.12.0"+(t.applicationInfo?" "+t.applicationInfo:""),this.options=t,this.http=new u(t.requestTimeout,t.clientName,this._getDeviceName(),this._getDeviceTag(),t.projectId,t.cors),this.crypto=new c(t.seed),this.users=new a(t.userStorage,t.projectId,"mfa")}return c.prototype._crypto=function(t){return t||(t="BN254CX"),h[t]||(h[t]=new s(t),h[t].MPIN.MAXPIN=1e6,h[t].MPIN.PBLEN=20,h[t].MPIN.TRAP=2e3),h[t]},c.prototype.generateKeypair=function(t){const n=[],i=[],e=this._crypto(t).MPIN.GET_DVS_KEYPAIR(this.rng,n,i);if(0!==e)throw new Error("Could not generate key pair: "+e);return{publicKey:this._bytesToHex(i),privateKey:this._bytesToHex(n)}},c.prototype.addShares=function(t,n,i,e){const o=this._hexToBytes(t),r=this._hexToBytes(n),s=this._hexToBytes(i),h=[],c=this._crypto(e).MPIN.RECOMBINE_G1(r,s,h);if(0!==c)throw new Error("Could not combine the client secret shares: "+c);const u=this._crypto(e).MPIN.GET_G1_MULTIPLE(null,0,o,h,h);if(0!==u)throw new Error("Could not combine private key with client secret: "+u);return this._bytesToHex(h)},c.prototype.extractPin=function(t,n,i,e,o){const r=this._hexToBytes(e),s=this._hexToBytes(this._mpinIdWithPublicKey(t,n)),h=this._crypto(o).MPIN.EXTRACT_PIN(this._crypto(o).MPIN.SHA256,s,i,r);if(0!==h)throw new Error("Could not extract PIN from client secret: "+h);return this._bytesToHex(r)},c.prototype.calculatePass1=function(t,n,i,e,o,r,s){const h=[],c=[],u=this._mpinIdWithPublicKey(t,n),a=this._crypto(s).MPIN.CLIENT_1(this._crypto(s).MPIN.SHA256,0,this._hexToBytes(u),this.rng,o,e,this._hexToBytes(i),r,h,c,this._hexToBytes(0));if(0!==a)throw new Error("Could not calculate pass 1 request data: "+a);return{UT:this._bytesToHex(c),U:this._bytesToHex(h)}},c.prototype.calculatePass2=function(t,n,i,e){const o=this._crypto(e).MPIN.CLIENT_2(t,this._hexToBytes(n),i);if(0!==o)throw new Error("Could not calculate pass 2 request data: "+o);return this._bytesToHex(i)},c.prototype.sign=function(t,n,i,e,o,r,s){const h=[],c=[],u=this._mpinIdWithPublicKey(t,n),a=this._crypto(s).MPIN.CLIENT(this._crypto(s).MPIN.SHA256,0,this._hexToBytes(u),this.rng,[],e,this._hexToBytes(i),h,c,null,null,r,[],this._hexToBytes(o));if(0!==a)throw new Error("Could not sign message: "+a);return{U:this._bytesToHex(c),V:this._bytesToHex(h)}},c.prototype.randomString=function(t){const n=new Array(t);for(let i=0;i>>4&15).toString(16),n+=(15&e).toString(16)}return n},u.prototype.request=function(t,n){if("function"!=typeof n)throw new Error("Bad or missing callback");if(!t.url)throw new Error("Missing URL for request");const i=new XMLHttpRequest;i.onreadystatechange=function(){let t;if(4===i.readyState&&200===i.status){try{t=JSON.parse(i.responseText)}catch(n){t=i.responseText}n(null,t)}else if(4===i.readyState){if(0===i.status)return void n(new Error("The request was aborted"),{status:0});try{t=JSON.parse(i.responseText)}catch(t){return void n(new Error(i.statusText),{status:i.status})}n(new Error(t.info),{status:i.status,error:t.error,context:t.context})}};let e=t.url;this.cors&&(e+=(-1!==e.indexOf("?")?"&":"?")+"project_id="+this.projectId);const o=t.type||"GET";return i.open(o,e,!0),i.timeout=this.requestTimeout,i.setRequestHeader("X-Miracl-Client",this.clientName),i.setRequestHeader("X-Miracl-Device-Name",this.deviceName),i.setRequestHeader("X-Miracl-Device-Tag",this.deviceTag),t.authorization&&i.setRequestHeader("Authorization",t.authorization),t.data?(i.setRequestHeader("Content-Type","application/json"),i.send(JSON.stringify(t.data))):i.send(),i},a.prototype.data=[],a.prototype.states={start:"STARTED",register:"REGISTERED",revoked:"REVOKED"},a.prototype.loadData=function(){this.data=JSON.parse(this.storage.getItem(this.storageKey))||[],this.store(),this.data.sort(((t,n)=>t.lastUsed&&(!n.lastUsed||t.lastUsed>n.lastUsed)?1:n.lastUsed&&(!t.lastUsed||t.lastUsed{if(t)return n(t,null);this.session=i,n(null,i)}))},f.prototype.fetchStatus=function(t){const n={url:this.options.projectUrl+"/rps/v2/access",type:"POST",data:{webOTT:this.session.webOTT}};this.http.request(n,((n,i)=>{if(n)return t(n,null);t(null,i)}))},f.prototype.sendPushNotificationForAuth=function(n,i){if(!n)return i(new Error("Empty user ID"),null);const e={url:this.options.projectUrl+"/pushauth?"+t(this.options.oidc),type:"POST",data:{prerollId:n}};this.http.request(e,((t,n)=>{if(t)return n&&"NO_PUSH_TOKEN"===n.error?i(new Error("No push token",{cause:t}),null):i(t,null);this.session.webOTT=n.webOTT,i(null,n)}))},f.prototype.sendVerificationEmail=function(t,n){if(!t)return n(new Error("Empty user ID"),null);const i={url:this.options.projectUrl+"/verification/email",type:"POST",data:{userId:t,mpinId:this.users.get(t,"mpinId"),projectId:this.options.projectId,accessId:this.session.accessId,deviceName:this._getDeviceName(),deviceTag:this._getDeviceTag(),clientId:this.options.oidc.client_id,redirectURI:this.options.oidc.redirect_uri,scope:this.options.oidc.scope?this.options.oidc.scope.split(" "):[],state:this.options.oidc.state,nonce:this.options.oidc.nonce}};this.http.request(i,((t,i)=>{if(t)return i&&"REQUEST_BACKOFF"===i.error?n(new Error("Request backoff",{cause:t}),i):n(new Error("Verification fail",{cause:t}),i);n(null,i)}))},f.prototype.getActivationToken=function(t,n){const i=function(t){const n=t.split("?").pop(),i=n.split("&"),e={};if(!n.length||!i.length)return e;for(let t=0;t{if(t)return e&&"UNSUCCESSFUL_VERIFICATION"===e.error?n(new Error("Unsuccessful verification",{cause:t}),e):n(new Error("Get activation token fail",{cause:t}),e);e.userId=i.user_id,n(null,e)}))},f.prototype.register=function(t,n,i,e){if(!t)return e(new Error("Empty user ID"),null);if(!n)return e(new Error("Empty activation token"),null);const o=this.crypto.generateKeypair();this._createMPinID(t,n,o,((n,r)=>{if(n)return r&&"INVALID_ACTIVATION_TOKEN"===r.error?e(new Error("Invalid activation token",{cause:n}),null):e(new Error("Registration fail",{cause:n}),null);if(r.projectId!==this.options.projectId)return e(new Error("Project mismatch"),null);let s=r.pinLength;s||(s=this.options.defaultPinLength),this._getTAShares(r.designatedTAs,r.mpinId,o.publicKey,((n,h)=>{if(n)return e(new Error("Registration fail",{cause:n}),null);i((n=>{this._createIdentity(t,n,r,h[0],h[1],o,e)}),s)}))}))},f.prototype._createMPinID=function(t,n,i,e){const o={url:this.options.projectUrl+"/registration",type:"POST",data:{userId:t,deviceName:this._getDeviceName(),deviceTag:this._getDeviceTag(),activationToken:n,publicKey:i.publicKey,ver:2}};this.http.request(o,((t,n)=>{if(t)return e(t,n);e(null,n)}))},f.prototype._getDeviceName=function(){return this.options.deviceName?this.options.deviceName:"Browser"},f.prototype._getDeviceTag=function(){const t=this.options.userStorage.getItem("miraclDeviceTag");if(t)return t;let n;try{n=this.crypto.randomString(16),this.options.userStorage.setItem("miraclDeviceTag",n)}catch(t){n=""}return n},f.prototype._getTAShares=function(t,n,i,e){const o=[],r=[];let s=t.length;for(let h=0;h{if(t?r.push(t):o[h]=n,0==--s){if(r.length>0)return e(new Error("Failed to get shares",{cause:r}),null);e(null,o)}}))},f.prototype._getTAShare=function(t,n,i,e){const o={type:"POST",url:t.url,authorization:"Bearer "+t.token,data:{mpinId:n,pubKey:i}};this.http.request(o,((t,n)=>{if(t)return e(t,null);e(null,n)}))},f.prototype._createIdentity=function(t,n,i,e,o,r,s){let h,c;try{h=this.crypto.addShares(r.privateKey,e.share,o.share),c=this.crypto.extractPin(i.mpinId,r.publicKey,n,h)}catch(t){return s(t,null)}const u=btoa(JSON.stringify([e.node,o.node])),a={mpinId:i.mpinId,token:c,curve:"BN254CX",dtas:u,publicKey:r.publicKey,pinLength:i.pinLength,projectId:i.projectId,verificationType:i.verificationType,state:this.users.states.register,nowTime:i.nowTime,updated:Math.floor(Date.now()/1e3)};this.users.write(t,a),s(null,a)},f.prototype.authenticate=function(t,n,i){this._authentication(t,n,["jwt"],"",i)},f.prototype.authenticateWithQRCode=function(t,n,i,e){const o=n.split("#").pop();this._authentication(t,i,["oidc"],o,e)},f.prototype.authenticateWithAppLink=function(t,n,i,e){const o=n.split("#").pop();this._authentication(t,i,["oidc"],o,e)},f.prototype.authenticateWithNotificationPayload=function(t,n,i){if(!t||!t.userID||!t.qrURL)return i(new Error("Invalid push notification payload"),null);const e=t.qrURL.split("#").pop();this._authentication(t.userID,n,["oidc"],e,i)},f.prototype.generateQuickCode=function(t,n,i){this._authentication(t,n,["reg-code"],"",((t,n)=>{if(t)return i(t,null);this.http.request({url:this.options.projectUrl+"/verification/quickcode",type:"POST",data:{projectId:this.options.projectId,jwt:n.jwt,deviceName:this._getDeviceName()}},((t,n)=>{if(t)return i(t,null);i(null,{code:n.code,expireTime:n.expireTime,ttlSeconds:n.ttlSeconds,OTP:n.code})}))}))},f.prototype._authentication=function(t,n,i,e,o){if(!t)return o(new Error("Empty user ID"),null);if(!this.users.exists(t))return o(new Error("User not found"),null);const r=this.users.get(t),s=[],h=[];this._getPass1(r,n,i,h,s,((c,u)=>{if(c)return u&&"EXPIRED_MPINID"===u.error?(this.users.write(t,{state:this.users.states.revoked}),o(new Error("Revoked",{cause:c}),null)):o(new Error("Authentication fail",{cause:c}),null);this._getPass2(r,i,e,u.y,h,s,((r,s)=>{if(r)return o(new Error("Authentication fail",{cause:r}),null);this._finishAuthentication(t,n,i,e,s.authOTT,((n,i)=>{if(n)return i&&"UNSUCCESSFUL_AUTHENTICATION"===i.error?o(new Error("Unsuccessful authentication",{cause:n}),null):i&&"REVOKED_MPINID"===i.error?(this.users.write(t,{state:this.users.states.revoked}),o(new Error("Revoked",{cause:n}),null)):o(new Error("Authentication fail",{cause:n}),null);o(null,i)}))}))}))},f.prototype._getPass1=function(t,n,i,e,o,r){let s;try{s=this.crypto.calculatePass1(t.mpinId,t.publicKey,t.token,n,e,o)}catch(t){return r(t,null)}const h={scope:i,mpin_id:t.mpinId,dtas:t.dtas,publicKey:t.publicKey,UT:s.UT,U:s.U};this.http.request({url:this.options.projectUrl+"/rps/v2/pass1",type:"POST",data:h},r)},f.prototype._getPass2=function(t,n,i,e,o,r,s){let h;try{h=this.crypto.calculatePass2(o,e,r)}catch(t){return s(t,null)}const c={mpin_id:t.mpinId,WID:i,V:h};this.http.request({url:this.options.projectUrl+"/rps/v2/pass2",type:"POST",data:c},s)},f.prototype._finishAuthentication=function(t,n,i,e,o,r){const s={authOTT:o,wam:"dvs"};this.http.request({url:this.options.projectUrl+"/rps/v2/authenticate",type:"POST",data:s},((o,s)=>{if(o)return r(o,s);s.dvsRegister?this._renewSecret(t,n,s.dvsRegister,(o=>{if(o)return r(o,null);this._authentication(t,n,i,e,r)})):(this.users.updateLastUsed(t),r(null,s))}))},f.prototype._renewSecret=function(t,n,i,e){const o=this.crypto.generateKeypair();this._createMPinID(t,i.token,o,((i,r)=>{if(i)return e(i,null);this._getTAShares(r.designatedTAs,r.mpinId,o.publicKey,((i,s)=>{if(i)return e(i,null);this._createIdentity(t,n,r,s[0],s[1],o,e)}))}))},f.prototype.sign=function(t,n,i,e,o){if(!t)return o(new Error("Empty user ID"),null);if(!this.users.exists(t))return o(new Error("User not found"),null);if(!i)return o(new Error("Empty message"),null);const r=this.users.get(t);if(!r.publicKey)return o(new Error("Empty public key"),null);this._authentication(t,n,["dvs-auth"],"",(t=>{if(t)switch(t.message){case"Unsuccessful authentication":case"Revoked":return o(t,null);default:return o(new Error("Signing fail",{cause:t.cause}),null)}let s;try{s=this.crypto.sign(r.mpinId,r.publicKey,r.token,n,i,e)}catch(t){return o(new Error("Signing fail",{cause:t}),null)}const h={hash:i,u:s.U,v:s.V,mpinId:r.mpinId,publicKey:r.publicKey,dtas:r.dtas};o(null,h)}))},f.prototype.createCrossDeviceSession=function(t,n,i,e){if(i&&!t)return e(new Error("Session for signing must be created with user ID"),null);const o={url:this.options.projectUrl+"/rps/v2/session",type:"POST",data:{projectId:this.options.projectId,userId:t,hash:i,description:n}};this.http.request(o,((o,r)=>{if(o)return e(o,null);e(null,{projectId:this.options.projectId,token:r.webOTT,sessionId:r.accessId,url:r.qrURL,userId:t||null,description:n||null,signingHash:i||null,expireTime:r.expireTime})}))},f.prototype.checkCrossDeviceSessionStatus=function(t,n){if(!t.token)return n(new Error("Invalid cross-device session"),null);const i={url:this.options.projectUrl+"/rps/v2/access",type:"POST",data:{webOTT:t.token}};this.http.request(i,((t,i)=>{if(t)return n(t,null);n(null,{status:i.status,userId:i.userId||null,jwt:i.jwt||null,signature:i.signature||null})}))},f.prototype.sendPushNotification=function(t,n){if(!t.userId)return n(new Error("Cross device session created without user ID"),null);const i={url:this.options.projectUrl+"/push",type:"POST",data:{projectId:this.options.projectId,userId:t.userId,accessId:t.sessionId}};this.http.request(i,((t,i)=>{if(t)return i&&"NO_PUSH_TOKEN"===i.error?n(new Error("No push token",{cause:t}),null):n(t,null);n(null,i)}))},f}(); +var MIRACLTrust=function(){"use strict";function t(t){const n=[];for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.push(encodeURIComponent(i)+"="+encodeURIComponent(t[i]));return n.join("&")}function n(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 i(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!==t)return h.config=s[t],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=o[h.config.CURVE],h.ROM_FIELD=r[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=[],O=[],M=[];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,M[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(O[o]=0,s=1,r=13;r<16;r++)c=M[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),O[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*O[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*O[o]+M[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.13.0"+(t.applicationInfo?" "+t.applicationInfo:""),this.options=t,this.crypto=new c(t.seed),this.http=new u(t.requestTimeout,t.clientName,this._getDeviceName(),this._getDeviceTag(),t.projectId,t.cors),this.users=new a(t.userStorage,t.projectId,"mfa")}return c.prototype._crypto=function(t){return t||(t="BN254CX"),h[t]||(h[t]=new s(t),h[t].MPIN.MAXPIN=1e6,h[t].MPIN.PBLEN=20,h[t].MPIN.TRAP=2e3),h[t]},c.prototype.generateKeypair=function(t){const n=[],i=[],e=this._crypto(t).MPIN.GET_DVS_KEYPAIR(this.rng,n,i);if(0!==e)throw new Error("Could not generate key pair: "+e);return{publicKey:this._bytesToHex(i),privateKey:this._bytesToHex(n)}},c.prototype.addShares=function(t,n,i,e){const o=this._hexToBytes(t),r=this._hexToBytes(n),s=this._hexToBytes(i),h=[],c=this._crypto(e).MPIN.RECOMBINE_G1(r,s,h);if(0!==c)throw new Error("Could not combine the client secret shares: "+c);const u=this._crypto(e).MPIN.GET_G1_MULTIPLE(null,0,o,h,h);if(0!==u)throw new Error("Could not combine private key with client secret: "+u);return this._bytesToHex(h)},c.prototype.extractPin=function(t,n,i,e,o){const r=this._hexToBytes(e),s=this._hexToBytes(this._mpinIdWithPublicKey(t,n)),h=this._crypto(o).MPIN.EXTRACT_PIN(this._crypto(o).MPIN.SHA256,s,i,r);if(0!==h)throw new Error("Could not extract PIN from client secret: "+h);return this._bytesToHex(r)},c.prototype.calculatePass1=function(t,n,i,e,o,r,s){const h=[],c=[],u=this._mpinIdWithPublicKey(t,n),a=this._crypto(s).MPIN.CLIENT_1(this._crypto(s).MPIN.SHA256,0,this._hexToBytes(u),this.rng,o,e,this._hexToBytes(i),r,h,c,this._hexToBytes(0));if(0!==a)throw new Error("Could not calculate pass 1 request data: "+a);return{UT:this._bytesToHex(c),U:this._bytesToHex(h)}},c.prototype.calculatePass2=function(t,n,i,e){const o=this._crypto(e).MPIN.CLIENT_2(t,this._hexToBytes(n),i);if(0!==o)throw new Error("Could not calculate pass 2 request data: "+o);return this._bytesToHex(i)},c.prototype.sign=function(t,n,i,e,o,r,s){const h=[],c=[],u=this._mpinIdWithPublicKey(t,n),a=this._crypto(s).MPIN.CLIENT(this._crypto(s).MPIN.SHA256,0,this._hexToBytes(u),this.rng,[],e,this._hexToBytes(i),h,c,null,null,r,[],this._hexToBytes(o));if(0!==a)throw new Error("Could not sign message: "+a);return{U:this._bytesToHex(c),V:this._bytesToHex(h)}},c.prototype.randomString=function(t){const n=new Array(t);for(let i=0;i>>4&15).toString(16),n+=(15&e).toString(16)}return n},u.prototype.request=function(t,n){if("function"!=typeof n)throw new Error("Bad or missing callback");if(!t.url)throw new Error("Missing URL for request");const i=new XMLHttpRequest;i.onreadystatechange=function(){let t;if(4===i.readyState&&200===i.status){try{t=JSON.parse(i.responseText)}catch(n){t=i.responseText}n(null,t)}else if(4===i.readyState){if(0===i.status)return void n(new Error("The request was aborted"),{status:0});try{t=JSON.parse(i.responseText)}catch(t){return void n(new Error(i.statusText),{status:i.status})}n(new Error(t.info),{status:i.status,error:t.error,context:t.context})}};let e=t.url;this.cors&&(e+=(-1!==e.indexOf("?")?"&":"?")+"project_id="+this.projectId);const o=t.type||"GET";return i.open(o,e,!0),i.timeout=this.requestTimeout,i.setRequestHeader("X-Miracl-Client",this.clientName),i.setRequestHeader("X-Miracl-Device-Name",this.deviceName),i.setRequestHeader("X-Miracl-Device-Tag",this.deviceTag),t.authorization&&i.setRequestHeader("Authorization",t.authorization),t.data?(i.setRequestHeader("Content-Type","application/json"),i.send(JSON.stringify(t.data))):i.send(),i},a.prototype.data=[],a.prototype.states={start:"STARTED",register:"REGISTERED",revoked:"REVOKED"},a.prototype.loadData=function(){this.data=JSON.parse(this.storage.getItem(this.storageKey))||[],this.store(),this.data.sort(((t,n)=>t.lastUsed&&(!n.lastUsed||t.lastUsed>n.lastUsed)?1:n.lastUsed&&(!t.lastUsed||t.lastUsed{if(t)return n(t,null);this.session=i,n(null,i)}))},f.prototype.fetchStatus=function(t){const n={url:this.options.projectUrl+"/rps/v2/access",type:"POST",data:{webOTT:this.session.webOTT}};this.http.request(n,((n,i)=>{if(n)return t(n,null);t(null,i)}))},f.prototype.sendPushNotificationForAuth=function(n,i){if(!n)return i(new Error("Empty user ID"),null);const e={url:this.options.projectUrl+"/pushauth?"+t(this.options.oidc),type:"POST",data:{prerollId:n}};this.http.request(e,((t,n)=>{if(t)return n&&"NO_PUSH_TOKEN"===n.error?i(new Error("No push token",{cause:t}),null):i(t,null);this.session.webOTT=n.webOTT,i(null,n)}))},f.prototype.sendVerificationEmail=function(t,n){if(!t)return n(new Error("Empty user ID"),null);const i={url:this.options.projectUrl+"/verification/email",type:"POST",data:{userId:t,mpinId:this.users.get(t,"mpinId"),projectId:this.options.projectId,accessId:this.session.accessId,deviceName:this._getDeviceName(),deviceTag:this._getDeviceTag(),clientId:this.options.oidc.client_id,redirectURI:this.options.oidc.redirect_uri,scope:this.options.oidc.scope?this.options.oidc.scope.split(" "):[],state:this.options.oidc.state,nonce:this.options.oidc.nonce}};this.http.request(i,((t,i)=>{if(t)return i&&"REQUEST_BACKOFF"===i.error?n(new Error("Request backoff",{cause:t}),i):n(new Error("Verification fail",{cause:t}),i);n(null,i)}))},f.prototype.getActivationToken=function(t,n){const i=function(t){const n=t.split("?").pop(),i=n.split("&"),e={};if(!n.length||!i.length)return e;for(let t=0;t{if(t)return e&&"UNSUCCESSFUL_VERIFICATION"===e.error?n(new Error("Unsuccessful verification",{cause:t}),e):n(new Error("Get activation token fail",{cause:t}),e);e.userId=i.user_id,n(null,e)}))},f.prototype.register=function(t,n,i,e){if(!t)return e(new Error("Empty user ID"),null);if(!n)return e(new Error("Empty activation token"),null);const o=this.crypto.generateKeypair();this._createMPinID(t,n,o,((n,r)=>{if(n)return r&&"INVALID_ACTIVATION_TOKEN"===r.error?e(new Error("Invalid activation token",{cause:n}),null):e(new Error("Registration fail",{cause:n}),null);if(r.projectId!==this.options.projectId)return e(new Error("Project mismatch"),null);let s=r.pinLength;s||(s=this.options.defaultPinLength),this._getTAShares(r.designatedTAs,r.mpinId,o.publicKey,((n,h)=>{if(n)return e(new Error("Registration fail",{cause:n}),null);i((n=>{this._createIdentity(t,n,r,h[0],h[1],o,e)}),s)}))}))},f.prototype._createMPinID=function(t,n,i,e){const o={url:this.options.projectUrl+"/registration",type:"POST",data:{userId:t,deviceName:this._getDeviceName(),deviceTag:this._getDeviceTag(),activationToken:n,publicKey:i.publicKey,ver:2}};this.http.request(o,((t,n)=>{if(t)return e(t,n);e(null,n)}))},f.prototype._getDeviceName=function(){return this.options.deviceName?this.options.deviceName:"Browser"},f.prototype._getDeviceTag=function(){const t=this.options.userStorage.getItem("miraclDeviceTag");if(t)return t;let n;try{n=this.crypto.randomString(16),this.options.userStorage.setItem("miraclDeviceTag",n)}catch(t){n=""}return n},f.prototype._getTAShares=function(t,n,i,e){const o=[],r=[];let s=t.length;for(let h=0;h{if(t?r.push(t):o[h]=n,0==--s){if(r.length>0)return e(new Error("Failed to get shares",{cause:r}),null);e(null,o)}}))},f.prototype._getTAShare=function(t,n,i,e){const o={type:"POST",url:t.url,authorization:"Bearer "+t.token,data:{mpinId:n,pubKey:i}};this.http.request(o,((t,n)=>{if(t)return e(t,null);e(null,n)}))},f.prototype._createIdentity=function(t,n,i,e,o,r,s){let h,c;try{h=this.crypto.addShares(r.privateKey,e.share,o.share),c=this.crypto.extractPin(i.mpinId,r.publicKey,n,h)}catch(t){return s(t,null)}const u=btoa(JSON.stringify([e.node,o.node])),a={mpinId:i.mpinId,token:c,curve:"BN254CX",dtas:u,publicKey:r.publicKey,pinLength:i.pinLength,projectId:i.projectId,verificationType:i.verificationType,state:this.users.states.register,nowTime:i.nowTime,updated:Math.floor(Date.now()/1e3)};this.users.write(t,a),s(null,a)},f.prototype.authenticate=function(t,n,i){this._authentication(t,n,["jwt"],"",i)},f.prototype.authenticateWithQRCode=function(t,n,i,e){const o=n.split("#").pop();this._authentication(t,i,["oidc"],o,e)},f.prototype.authenticateWithAppLink=function(t,n,i,e){const o=n.split("#").pop();this._authentication(t,i,["oidc"],o,e)},f.prototype.authenticateWithNotificationPayload=function(t,n,i){if(!t||!t.userID||!t.qrURL)return i(new Error("Invalid push notification payload"),null);const e=t.qrURL.split("#").pop();this._authentication(t.userID,n,["oidc"],e,i)},f.prototype.generateQuickCode=function(t,n,i){this._authentication(t,n,["reg-code"],"",((t,n)=>{if(t)return i(t,null);this.http.request({url:this.options.projectUrl+"/verification/quickcode",type:"POST",data:{projectId:this.options.projectId,jwt:n.jwt,deviceName:this._getDeviceName()}},((t,n)=>{if(t)return i(t,null);i(null,{code:n.code,expireTime:n.expireTime,ttlSeconds:n.ttlSeconds,OTP:n.code})}))}))},f.prototype._authentication=function(t,n,i,e,o){if(!t)return o(new Error("Empty user ID"),null);if(!this.users.exists(t))return o(new Error("User not found"),null);const r=this.users.get(t),s=[],h=[];this._getPass1(r,n,i,h,s,((c,u)=>{if(c)return u&&"EXPIRED_MPINID"===u.error?(this.users.write(t,{state:this.users.states.revoked}),o(new Error("Revoked",{cause:c}),null)):o(new Error("Authentication fail",{cause:c}),null);this._getPass2(r,i,e,u.y,h,s,((r,s)=>{if(r)return o(new Error("Authentication fail",{cause:r}),null);this._finishAuthentication(t,n,i,e,s.authOTT,((n,i)=>{if(n)return i&&"UNSUCCESSFUL_AUTHENTICATION"===i.error?o(new Error("Unsuccessful authentication",{cause:n}),null):i&&"REVOKED_MPINID"===i.error?(this.users.write(t,{state:this.users.states.revoked}),o(new Error("Revoked",{cause:n}),null)):o(new Error("Authentication fail",{cause:n}),null);o(null,i)}))}))}))},f.prototype._getPass1=function(t,n,i,e,o,r){let s;try{s=this.crypto.calculatePass1(t.mpinId,t.publicKey,t.token,n,e,o)}catch(t){return r(t,null)}const h={scope:i,mpin_id:t.mpinId,dtas:t.dtas,publicKey:t.publicKey,UT:s.UT,U:s.U};this.http.request({url:this.options.projectUrl+"/rps/v2/pass1",type:"POST",data:h},r)},f.prototype._getPass2=function(t,n,i,e,o,r,s){let h;try{h=this.crypto.calculatePass2(o,e,r)}catch(t){return s(t,null)}const c={mpin_id:t.mpinId,WID:i,V:h};this.http.request({url:this.options.projectUrl+"/rps/v2/pass2",type:"POST",data:c},s)},f.prototype._finishAuthentication=function(t,n,i,e,o,r){const s={authOTT:o,wam:"dvs"};this.http.request({url:this.options.projectUrl+"/rps/v2/authenticate",type:"POST",data:s},((o,s)=>{if(o)return r(o,s);s.dvsRegister?this._renewSecret(t,n,s.dvsRegister,(o=>{if(o)return r(o,null);this._authentication(t,n,i,e,r)})):(this.users.updateLastUsed(t),r(null,s))}))},f.prototype._renewSecret=function(t,n,i,e){const o=this.crypto.generateKeypair();this._createMPinID(t,i.token,o,((i,r)=>{if(i)return e(i,null);this._getTAShares(r.designatedTAs,r.mpinId,o.publicKey,((i,s)=>{if(i)return e(i,null);this._createIdentity(t,n,r,s[0],s[1],o,e)}))}))},f.prototype.sign=function(t,n,i,e,o){return t?this.users.exists(t)?i?void this._authentication(t,n,["dvs-auth"],"",(r=>{if(r)switch(r.message){case"Unsuccessful authentication":case"Revoked":return o(r,null);default:return o(new Error("Signing fail",{cause:r.cause}),null)}const s=this.users.get(t);let h;try{h=this.crypto.sign(s.mpinId,s.publicKey,s.token,n,i,e)}catch(r){return o(new Error("Signing fail",{cause:r}),null)}const c={hash:i,u:h.U,v:h.V,mpinId:s.mpinId,publicKey:s.publicKey,dtas:s.dtas};o(null,c)})):o(new Error("Empty message"),null):o(new Error("User not found"),null):o(new Error("Empty user ID"),null)},f.prototype.createCrossDeviceSession=function(t,n,i,e){if(i&&!t)return e(new Error("Session for signing must be created with user ID"),null);const o={url:this.options.projectUrl+"/rps/v2/session",type:"POST",data:{projectId:this.options.projectId,userId:t,hash:i,description:n}};this.http.request(o,((o,r)=>{if(o)return e(o,null);e(null,{type:i?"signing":"authentication",projectId:this.options.projectId,token:r.webOTT,sessionId:r.accessId,url:r.qrURL,userId:t||null,description:n||null,signingHash:i||null,expireTime:r.expireTime})}))},f.prototype.checkCrossDeviceSessionStatus=function(t,n){if(!t.token)return n(new Error("Invalid cross-device session"),null);const i={url:this.options.projectUrl+"/rps/v2/access",type:"POST",data:{webOTT:t.token}};this.http.request(i,((t,i)=>{if(t)return n(t,null);n(null,{status:i.status,userId:i.userId||null,jwt:i.jwt||null,signature:i.signature||null})}))},f.prototype.sendPushNotification=function(t,n){if(!t.userId)return n(new Error("Cross device session created without user ID"),null);const i={url:this.options.projectUrl+"/push",type:"POST",data:{projectId:this.options.projectId,userId:t.userId,accessId:t.sessionId}};this.http.request(i,((t,i)=>{if(t)return i&&"NO_PUSH_TOKEN"===i.error?n(new Error("No push token",{cause:t}),null):n(t,null);n(null,i)}))},f.prototype.getCrossDeviceSessionFromQRCode=function(t,n){this._getCrossDeviceSession(t,n)},f.prototype.getCrossDeviceSessionFromLink=function(t,n){this._getCrossDeviceSession(t,n)},f.prototype.getCrossDeviceSessionFromNotificationPayload=function(t,n){if(!t||!t.qrURL)return n(new Error("Invalid push notification payload"),null);this._getCrossDeviceSession(t.qrURL,n)},f.prototype._getCrossDeviceSession=function(t,n){const i=t.split("#").pop(),e={url:this.options.projectUrl+"/rps/v2/codeStatus",type:"POST",data:{status:"wid",wid:i}};this.http.request(e,((e,o)=>{if(e)return n(new Error("Get cross-device session request failed",{cause:e}),null);n(null,{type:o.hash?"signing":"authentication",projectId:o.projectId,token:null,sessionId:i,url:t,userId:o.prerollId||null,description:o.description||null,signingHash:o.hash||null,expireTime:o.expireTime})}))},f.prototype.authenticateCrossDeviceSession=function(t,n,i,e){if(t.userId&&t.userId!==n)return e(new Error("Cross-device session was initiated for different user ID"),null);this._authentication(n,i,["jwt"],t.sessionId,e)},f.prototype.signCrossDeviceSession=function(t,n,i,e){if(t.userId&&t.userId!==n)return e(new Error("Cross-device session was initiated for different user ID"),null);const o=Math.floor((new Date).getTime()/1e3);this.sign(n,i,t.signingHash,o,((n,i)=>{if(n)return e(n,null);const o={url:this.options.projectUrl+"/rps/v2/codeStatus",type:"POST",data:{status:"signed",wid:t.sessionId,signature:btoa(JSON.stringify(i))}};this.http.request(o,((t,n)=>{if(t)return e(new Error("Updating cross-device session failed",{cause:t}),null);e(null,n)}))}))},f.prototype.abortCrossDeviceSession=function(t,n){const i={url:this.options.projectUrl+"/rps/v2/codeStatus",type:"POST",data:{status:"abort",wid:t.sessionId}};this.http.request(i,((t,i)=>{if(t)return n(new Error("Aborting cross-device session failed",{cause:t}),null);n(null,i)}))},f}(); diff --git a/dist/client.promise.js b/dist/client.promise.js index d7b3d6d..faf181b 100644 --- a/dist/client.promise.js +++ b/dist/client.promise.js @@ -23939,14 +23939,14 @@ function Client(options) { } // Set the client name using the current lib version and provided application info - options.clientName = "MIRACL Client.js/8.12.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); + options.clientName = "MIRACL Client.js/8.13.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); this.options = options; - this.http = new HTTP(options.requestTimeout, options.clientName, this._getDeviceName(), this._getDeviceTag(), options.projectId, options.cors); - this.crypto = new Crypto(options.seed); + this.http = new HTTP(options.requestTimeout, options.clientName, this._getDeviceName(), this._getDeviceTag(), options.projectId, options.cors); + this.users = new Users(options.userStorage, options.projectId, "mfa"); } @@ -24325,6 +24325,8 @@ Client.prototype.authenticate = function (userId, userPin, callback) { }; /** + * @deprecated Use `getCrossDeviceSessionFromQRCode` and `authenticateCrossDeviceSession` instead + * * Authenticate the user for the session specified by the qrCode parameter * * @param {string} userId - The unique identifier of the user @@ -24339,6 +24341,8 @@ Client.prototype.authenticateWithQRCode = function (userId, qrCode, userPin, cal }; /** + * @deprecated Use `getCrossDeviceSessionFromLink` and `authenticateCrossDeviceSession` instead + * * Authenticate the user for the session specified by the appLink parameter * * @param {string} userId - The unique identifier of the user @@ -24353,6 +24357,8 @@ Client.prototype.authenticateWithAppLink = function (userId, appLink, userPin, c }; /** + * @deprecated Use `getCrossDeviceSessionFromNotificationPayload` and `authenticateCrossDeviceSession` instead + * * Authenticate the session specified by the push notification payload * * @param {[key: string]: string} payload - The push notification payload @@ -24594,12 +24600,6 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) return callback(new Error("Empty message"), null); } - const identityData = this.users.get(userId); - - if (!identityData.publicKey) { - return callback(new Error("Empty public key"), null); - } - this._authentication(userId, userPin, ["dvs-auth"], "", (err) => { if (err) { switch (err.message) { @@ -24612,6 +24612,8 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) } } + const identityData = this.users.get(userId); + let res; try { @@ -24635,6 +24637,7 @@ Client.prototype.sign = function (userId, userPin, message, timestamp, callback) /** * @typedef {Object} CrossDeviceSession + * @property {string} type * @property {string} projectId * @property {string} token * @property {string} sessionId @@ -24675,6 +24678,7 @@ Client.prototype.createCrossDeviceSession = function (userId, description, signi } callback(null, { + type: signingHash ? "signing" : "authentication", projectId: this.options.projectId, token: res.webOTT, sessionId: res.accessId, @@ -24732,7 +24736,7 @@ Client.prototype.checkCrossDeviceSessionStatus = function (crossDeviceSession, c * Send push notification for an existing cross-device session * * @param {CrossDeviceSession} crossDeviceSession - * @param (function(Error, any): void) callback + * @param {function(Error, any): void} callback */ Client.prototype.sendPushNotification = function (crossDeviceSession, callback) { if (!crossDeviceSession.userId) { @@ -24762,6 +24766,160 @@ Client.prototype.sendPushNotification = function (crossDeviceSession, callback) }); }; +/** + * Gets the CrossDeviceSession for a QR code + * + * @param {string} qrCode - The QR code URL that initiated the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromQRCode = function (qrCode, callback) { + this._getCrossDeviceSession(qrCode, callback); +}; + +/** + * Gets CrossDeviceSession for app link or universal link + * + * @param {string} link - The app link that initiated the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromLink = function (link, callback) { + this._getCrossDeviceSession(link, callback); +}; + +/** + * Gets the CrossDeviceSession from a notification payload + * + * @param {[key: string]: string} payload - The push notification payload + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype.getCrossDeviceSessionFromNotificationPayload = function (payload, callback) { + if (!payload || !payload["qrURL"]) { + return callback(new Error("Invalid push notification payload"), null); + } + + this._getCrossDeviceSession(payload["qrURL"], callback); +}; + +/** + * @private + * + * Get a cross-device session from a session URL + * + * @param {string} url - The URL of the session + * @param {function(Error, CrossDeviceSession): void} callback + */ +Client.prototype._getCrossDeviceSession = function (url, callback) { + const accessId = url.split("#").pop(); + + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "wid", + wid: accessId + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Get cross-device session request failed", { cause: error }), null); + } + + callback(null, { + type: data.hash ? "signing" : "authentication", + projectId: data.projectId, + token: null, + sessionId: accessId, + url: url, + userId: data.prerollId || null, + description: data.description || null, + signingHash: data.hash || null, + expireTime: data.expireTime + }); + }); +}; + +/** + * Authenticate a cross-device session + * + * @param {CrossDeviceSession} crossDeviceSession + * @param {string} userId - The unique identifier of the user + * @param {string} userPin - The PIN associated with the userId + * @param {function(Error, any): void} callback + */ +Client.prototype.authenticateCrossDeviceSession = function (crossDeviceSession, userId, userPin, callback) { + if (crossDeviceSession.userId && crossDeviceSession.userId !== userId) { + return callback(new Error("Cross-device session was initiated for different user ID"), null); + } + + this._authentication(userId, userPin, ["jwt"], crossDeviceSession.sessionId, callback); +}; + +/** + * Generates a signature for a hash provided by the crossDeviceSession and updates the session + * + * @param {CrossDeviceSession} crossDeviceSession + * @param {string} userId - The unique identifier of the user + * @param {string} userPin - The PIN associated with the userId + * @param {function(Error, any): void} callback + */ +Client.prototype.signCrossDeviceSession = function (crossDeviceSession, userId, userPin, callback) { + if (crossDeviceSession.userId && crossDeviceSession.userId !== userId) { + return callback(new Error("Cross-device session was initiated for different user ID"), null); + } + + const timestamp = Math.floor(new Date().getTime() / 1000); + + this.sign(userId, userPin, crossDeviceSession.signingHash, timestamp, (error, signature) => { + if (error) { + return callback(error, null); + } + + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "signed", + wid: crossDeviceSession.sessionId, + signature: btoa(JSON.stringify(signature)) + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Updating cross-device session failed", { cause: error }), null); + } + + callback(null, data); + }); + }); +}; + +/** + * Abort a cross-device session + * + * @param {CrossDeviceSession} crossDeviceSession - The session to abort + * @param {function(Error, any): void} callback + */ +Client.prototype.abortCrossDeviceSession = function (crossDeviceSession, callback) { + const reqData = { + url: this.options.projectUrl + "/rps/v2/codeStatus", + type: "POST", + data: { + status: "abort", + wid: crossDeviceSession.sessionId + } + }; + + this.http.request(reqData, (error, data) => { + if (error) { + return callback(new Error("Aborting cross-device session failed", { cause: error }), null); + } + + callback(null, data); + }); +}; + class PromiseInterface extends Client { /** * @deprecated Use `createCrossDeviceSession` instead @@ -24831,6 +24989,30 @@ class PromiseInterface extends Client { sendPushNotification(crossDeviceSession) { return promisify(super.sendPushNotification.bind(this), crossDeviceSession); } + + getCrossDeviceSessionFromQRCode(qrCode) { + return promisify(super.getCrossDeviceSessionFromQRCode.bind(this), qrCode); + } + + getCrossDeviceSessionFromLink(link) { + return promisify(super.getCrossDeviceSessionFromLink.bind(this), link); + } + + getCrossDeviceSessionFromNotificationPayload(payload) { + return promisify(super.getCrossDeviceSessionFromNotificationPayload.bind(this), payload); + } + + authenticateCrossDeviceSession(crossDeviceSession, userId, userPin) { + return promisify(super.authenticateCrossDeviceSession.bind(this), crossDeviceSession, userId, userPin); + } + + signCrossDeviceSession(crossDeviceSession, userId, userPin) { + return promisify(super.signCrossDeviceSession.bind(this), crossDeviceSession, userId, userPin); + } + + abortCrossDeviceSession(crossDeviceSession) { + return promisify(super.abortCrossDeviceSession.bind(this), crossDeviceSession); + } } function promisify (original, ...args) { diff --git a/dist/client.promise.min.js b/dist/client.promise.min.js index 56351e2..42c8178 100644 --- a/dist/client.promise.min.js +++ b/dist/client.promise.min.js @@ -1 +1 @@ -var MIRACLTrust=function(){"use strict";function t(t){const n=[];for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.push(encodeURIComponent(i)+"="+encodeURIComponent(t[i]));return n.join("&")}function n(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 i(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!==t)return h.config=s[t],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=o[h.config.CURVE],h.ROM_FIELD=r[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=[],O=[],M=[];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,M[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(O[o]=0,s=1,r=13;r<16;r++)c=M[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),O[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*O[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*O[o]+M[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.12.0"+(t.applicationInfo?" "+t.applicationInfo:""),this.options=t,this.http=new u(t.requestTimeout,t.clientName,this._getDeviceName(),this._getDeviceTag(),t.projectId,t.cors),this.crypto=new c(t.seed),this.users=new a(t.userStorage,t.projectId,"mfa")}c.prototype._crypto=function(t){return t||(t="BN254CX"),h[t]||(h[t]=new s(t),h[t].MPIN.MAXPIN=1e6,h[t].MPIN.PBLEN=20,h[t].MPIN.TRAP=2e3),h[t]},c.prototype.generateKeypair=function(t){const n=[],i=[],e=this._crypto(t).MPIN.GET_DVS_KEYPAIR(this.rng,n,i);if(0!==e)throw new Error("Could not generate key pair: "+e);return{publicKey:this._bytesToHex(i),privateKey:this._bytesToHex(n)}},c.prototype.addShares=function(t,n,i,e){const o=this._hexToBytes(t),r=this._hexToBytes(n),s=this._hexToBytes(i),h=[],c=this._crypto(e).MPIN.RECOMBINE_G1(r,s,h);if(0!==c)throw new Error("Could not combine the client secret shares: "+c);const u=this._crypto(e).MPIN.GET_G1_MULTIPLE(null,0,o,h,h);if(0!==u)throw new Error("Could not combine private key with client secret: "+u);return this._bytesToHex(h)},c.prototype.extractPin=function(t,n,i,e,o){const r=this._hexToBytes(e),s=this._hexToBytes(this._mpinIdWithPublicKey(t,n)),h=this._crypto(o).MPIN.EXTRACT_PIN(this._crypto(o).MPIN.SHA256,s,i,r);if(0!==h)throw new Error("Could not extract PIN from client secret: "+h);return this._bytesToHex(r)},c.prototype.calculatePass1=function(t,n,i,e,o,r,s){const h=[],c=[],u=this._mpinIdWithPublicKey(t,n),a=this._crypto(s).MPIN.CLIENT_1(this._crypto(s).MPIN.SHA256,0,this._hexToBytes(u),this.rng,o,e,this._hexToBytes(i),r,h,c,this._hexToBytes(0));if(0!==a)throw new Error("Could not calculate pass 1 request data: "+a);return{UT:this._bytesToHex(c),U:this._bytesToHex(h)}},c.prototype.calculatePass2=function(t,n,i,e){const o=this._crypto(e).MPIN.CLIENT_2(t,this._hexToBytes(n),i);if(0!==o)throw new Error("Could not calculate pass 2 request data: "+o);return this._bytesToHex(i)},c.prototype.sign=function(t,n,i,e,o,r,s){const h=[],c=[],u=this._mpinIdWithPublicKey(t,n),a=this._crypto(s).MPIN.CLIENT(this._crypto(s).MPIN.SHA256,0,this._hexToBytes(u),this.rng,[],e,this._hexToBytes(i),h,c,null,null,r,[],this._hexToBytes(o));if(0!==a)throw new Error("Could not sign message: "+a);return{U:this._bytesToHex(c),V:this._bytesToHex(h)}},c.prototype.randomString=function(t){const n=new Array(t);for(let i=0;i>>4&15).toString(16),n+=(15&e).toString(16)}return n},u.prototype.request=function(t,n){if("function"!=typeof n)throw new Error("Bad or missing callback");if(!t.url)throw new Error("Missing URL for request");const i=new XMLHttpRequest;i.onreadystatechange=function(){let t;if(4===i.readyState&&200===i.status){try{t=JSON.parse(i.responseText)}catch(n){t=i.responseText}n(null,t)}else if(4===i.readyState){if(0===i.status)return void n(new Error("The request was aborted"),{status:0});try{t=JSON.parse(i.responseText)}catch(t){return void n(new Error(i.statusText),{status:i.status})}n(new Error(t.info),{status:i.status,error:t.error,context:t.context})}};let e=t.url;this.cors&&(e+=(-1!==e.indexOf("?")?"&":"?")+"project_id="+this.projectId);const o=t.type||"GET";return i.open(o,e,!0),i.timeout=this.requestTimeout,i.setRequestHeader("X-Miracl-Client",this.clientName),i.setRequestHeader("X-Miracl-Device-Name",this.deviceName),i.setRequestHeader("X-Miracl-Device-Tag",this.deviceTag),t.authorization&&i.setRequestHeader("Authorization",t.authorization),t.data?(i.setRequestHeader("Content-Type","application/json"),i.send(JSON.stringify(t.data))):i.send(),i},a.prototype.data=[],a.prototype.states={start:"STARTED",register:"REGISTERED",revoked:"REVOKED"},a.prototype.loadData=function(){this.data=JSON.parse(this.storage.getItem(this.storageKey))||[],this.store(),this.data.sort(((t,n)=>t.lastUsed&&(!n.lastUsed||t.lastUsed>n.lastUsed)?1:n.lastUsed&&(!t.lastUsed||t.lastUsed{if(t)return n(t,null);this.session=i,n(null,i)}))},f.prototype.fetchStatus=function(t){const n={url:this.options.projectUrl+"/rps/v2/access",type:"POST",data:{webOTT:this.session.webOTT}};this.http.request(n,((n,i)=>{if(n)return t(n,null);t(null,i)}))},f.prototype.sendPushNotificationForAuth=function(n,i){if(!n)return i(new Error("Empty user ID"),null);const e={url:this.options.projectUrl+"/pushauth?"+t(this.options.oidc),type:"POST",data:{prerollId:n}};this.http.request(e,((t,n)=>{if(t)return n&&"NO_PUSH_TOKEN"===n.error?i(new Error("No push token",{cause:t}),null):i(t,null);this.session.webOTT=n.webOTT,i(null,n)}))},f.prototype.sendVerificationEmail=function(t,n){if(!t)return n(new Error("Empty user ID"),null);const i={url:this.options.projectUrl+"/verification/email",type:"POST",data:{userId:t,mpinId:this.users.get(t,"mpinId"),projectId:this.options.projectId,accessId:this.session.accessId,deviceName:this._getDeviceName(),deviceTag:this._getDeviceTag(),clientId:this.options.oidc.client_id,redirectURI:this.options.oidc.redirect_uri,scope:this.options.oidc.scope?this.options.oidc.scope.split(" "):[],state:this.options.oidc.state,nonce:this.options.oidc.nonce}};this.http.request(i,((t,i)=>{if(t)return i&&"REQUEST_BACKOFF"===i.error?n(new Error("Request backoff",{cause:t}),i):n(new Error("Verification fail",{cause:t}),i);n(null,i)}))},f.prototype.getActivationToken=function(t,n){const i=function(t){const n=t.split("?").pop(),i=n.split("&"),e={};if(!n.length||!i.length)return e;for(let t=0;t{if(t)return e&&"UNSUCCESSFUL_VERIFICATION"===e.error?n(new Error("Unsuccessful verification",{cause:t}),e):n(new Error("Get activation token fail",{cause:t}),e);e.userId=i.user_id,n(null,e)}))},f.prototype.register=function(t,n,i,e){if(!t)return e(new Error("Empty user ID"),null);if(!n)return e(new Error("Empty activation token"),null);const o=this.crypto.generateKeypair();this._createMPinID(t,n,o,((n,r)=>{if(n)return r&&"INVALID_ACTIVATION_TOKEN"===r.error?e(new Error("Invalid activation token",{cause:n}),null):e(new Error("Registration fail",{cause:n}),null);if(r.projectId!==this.options.projectId)return e(new Error("Project mismatch"),null);let s=r.pinLength;s||(s=this.options.defaultPinLength),this._getTAShares(r.designatedTAs,r.mpinId,o.publicKey,((n,h)=>{if(n)return e(new Error("Registration fail",{cause:n}),null);i((n=>{this._createIdentity(t,n,r,h[0],h[1],o,e)}),s)}))}))},f.prototype._createMPinID=function(t,n,i,e){const o={url:this.options.projectUrl+"/registration",type:"POST",data:{userId:t,deviceName:this._getDeviceName(),deviceTag:this._getDeviceTag(),activationToken:n,publicKey:i.publicKey,ver:2}};this.http.request(o,((t,n)=>{if(t)return e(t,n);e(null,n)}))},f.prototype._getDeviceName=function(){return this.options.deviceName?this.options.deviceName:"Browser"},f.prototype._getDeviceTag=function(){const t=this.options.userStorage.getItem("miraclDeviceTag");if(t)return t;let n;try{n=this.crypto.randomString(16),this.options.userStorage.setItem("miraclDeviceTag",n)}catch(t){n=""}return n},f.prototype._getTAShares=function(t,n,i,e){const o=[],r=[];let s=t.length;for(let h=0;h{if(t?r.push(t):o[h]=n,0==--s){if(r.length>0)return e(new Error("Failed to get shares",{cause:r}),null);e(null,o)}}))},f.prototype._getTAShare=function(t,n,i,e){const o={type:"POST",url:t.url,authorization:"Bearer "+t.token,data:{mpinId:n,pubKey:i}};this.http.request(o,((t,n)=>{if(t)return e(t,null);e(null,n)}))},f.prototype._createIdentity=function(t,n,i,e,o,r,s){let h,c;try{h=this.crypto.addShares(r.privateKey,e.share,o.share),c=this.crypto.extractPin(i.mpinId,r.publicKey,n,h)}catch(t){return s(t,null)}const u=btoa(JSON.stringify([e.node,o.node])),a={mpinId:i.mpinId,token:c,curve:"BN254CX",dtas:u,publicKey:r.publicKey,pinLength:i.pinLength,projectId:i.projectId,verificationType:i.verificationType,state:this.users.states.register,nowTime:i.nowTime,updated:Math.floor(Date.now()/1e3)};this.users.write(t,a),s(null,a)},f.prototype.authenticate=function(t,n,i){this._authentication(t,n,["jwt"],"",i)},f.prototype.authenticateWithQRCode=function(t,n,i,e){const o=n.split("#").pop();this._authentication(t,i,["oidc"],o,e)},f.prototype.authenticateWithAppLink=function(t,n,i,e){const o=n.split("#").pop();this._authentication(t,i,["oidc"],o,e)},f.prototype.authenticateWithNotificationPayload=function(t,n,i){if(!t||!t.userID||!t.qrURL)return i(new Error("Invalid push notification payload"),null);const e=t.qrURL.split("#").pop();this._authentication(t.userID,n,["oidc"],e,i)},f.prototype.generateQuickCode=function(t,n,i){this._authentication(t,n,["reg-code"],"",((t,n)=>{if(t)return i(t,null);this.http.request({url:this.options.projectUrl+"/verification/quickcode",type:"POST",data:{projectId:this.options.projectId,jwt:n.jwt,deviceName:this._getDeviceName()}},((t,n)=>{if(t)return i(t,null);i(null,{code:n.code,expireTime:n.expireTime,ttlSeconds:n.ttlSeconds,OTP:n.code})}))}))},f.prototype._authentication=function(t,n,i,e,o){if(!t)return o(new Error("Empty user ID"),null);if(!this.users.exists(t))return o(new Error("User not found"),null);const r=this.users.get(t),s=[],h=[];this._getPass1(r,n,i,h,s,((c,u)=>{if(c)return u&&"EXPIRED_MPINID"===u.error?(this.users.write(t,{state:this.users.states.revoked}),o(new Error("Revoked",{cause:c}),null)):o(new Error("Authentication fail",{cause:c}),null);this._getPass2(r,i,e,u.y,h,s,((r,s)=>{if(r)return o(new Error("Authentication fail",{cause:r}),null);this._finishAuthentication(t,n,i,e,s.authOTT,((n,i)=>{if(n)return i&&"UNSUCCESSFUL_AUTHENTICATION"===i.error?o(new Error("Unsuccessful authentication",{cause:n}),null):i&&"REVOKED_MPINID"===i.error?(this.users.write(t,{state:this.users.states.revoked}),o(new Error("Revoked",{cause:n}),null)):o(new Error("Authentication fail",{cause:n}),null);o(null,i)}))}))}))},f.prototype._getPass1=function(t,n,i,e,o,r){let s;try{s=this.crypto.calculatePass1(t.mpinId,t.publicKey,t.token,n,e,o)}catch(t){return r(t,null)}const h={scope:i,mpin_id:t.mpinId,dtas:t.dtas,publicKey:t.publicKey,UT:s.UT,U:s.U};this.http.request({url:this.options.projectUrl+"/rps/v2/pass1",type:"POST",data:h},r)},f.prototype._getPass2=function(t,n,i,e,o,r,s){let h;try{h=this.crypto.calculatePass2(o,e,r)}catch(t){return s(t,null)}const c={mpin_id:t.mpinId,WID:i,V:h};this.http.request({url:this.options.projectUrl+"/rps/v2/pass2",type:"POST",data:c},s)},f.prototype._finishAuthentication=function(t,n,i,e,o,r){const s={authOTT:o,wam:"dvs"};this.http.request({url:this.options.projectUrl+"/rps/v2/authenticate",type:"POST",data:s},((o,s)=>{if(o)return r(o,s);s.dvsRegister?this._renewSecret(t,n,s.dvsRegister,(o=>{if(o)return r(o,null);this._authentication(t,n,i,e,r)})):(this.users.updateLastUsed(t),r(null,s))}))},f.prototype._renewSecret=function(t,n,i,e){const o=this.crypto.generateKeypair();this._createMPinID(t,i.token,o,((i,r)=>{if(i)return e(i,null);this._getTAShares(r.designatedTAs,r.mpinId,o.publicKey,((i,s)=>{if(i)return e(i,null);this._createIdentity(t,n,r,s[0],s[1],o,e)}))}))},f.prototype.sign=function(t,n,i,e,o){if(!t)return o(new Error("Empty user ID"),null);if(!this.users.exists(t))return o(new Error("User not found"),null);if(!i)return o(new Error("Empty message"),null);const r=this.users.get(t);if(!r.publicKey)return o(new Error("Empty public key"),null);this._authentication(t,n,["dvs-auth"],"",(t=>{if(t)switch(t.message){case"Unsuccessful authentication":case"Revoked":return o(t,null);default:return o(new Error("Signing fail",{cause:t.cause}),null)}let s;try{s=this.crypto.sign(r.mpinId,r.publicKey,r.token,n,i,e)}catch(t){return o(new Error("Signing fail",{cause:t}),null)}const h={hash:i,u:s.U,v:s.V,mpinId:r.mpinId,publicKey:r.publicKey,dtas:r.dtas};o(null,h)}))},f.prototype.createCrossDeviceSession=function(t,n,i,e){if(i&&!t)return e(new Error("Session for signing must be created with user ID"),null);const o={url:this.options.projectUrl+"/rps/v2/session",type:"POST",data:{projectId:this.options.projectId,userId:t,hash:i,description:n}};this.http.request(o,((o,r)=>{if(o)return e(o,null);e(null,{projectId:this.options.projectId,token:r.webOTT,sessionId:r.accessId,url:r.qrURL,userId:t||null,description:n||null,signingHash:i||null,expireTime:r.expireTime})}))},f.prototype.checkCrossDeviceSessionStatus=function(t,n){if(!t.token)return n(new Error("Invalid cross-device session"),null);const i={url:this.options.projectUrl+"/rps/v2/access",type:"POST",data:{webOTT:t.token}};this.http.request(i,((t,i)=>{if(t)return n(t,null);n(null,{status:i.status,userId:i.userId||null,jwt:i.jwt||null,signature:i.signature||null})}))},f.prototype.sendPushNotification=function(t,n){if(!t.userId)return n(new Error("Cross device session created without user ID"),null);const i={url:this.options.projectUrl+"/push",type:"POST",data:{projectId:this.options.projectId,userId:t.userId,accessId:t.sessionId}};this.http.request(i,((t,i)=>{if(t)return i&&"NO_PUSH_TOKEN"===i.error?n(new Error("No push token",{cause:t}),null):n(t,null);n(null,i)}))};function E(t,...n){return new Promise(((i,e)=>{t(...n,((t,n)=>{t?e(t):i(n)}))}))}return class extends f{fetchAccessId(t){return E(super.fetchAccessId.bind(this),t)}fetchStatus(){return E(super.fetchStatus.bind(this))}sendPushNotificationForAuth(t){return E(super.sendPushNotificationForAuth.bind(this),t)}sendVerificationEmail(t){return E(super.sendVerificationEmail.bind(this),t)}getActivationToken(t){return E(super.getActivationToken.bind(this),t)}register(t,n,i){return E(super.register.bind(this),t,n,i)}authenticate(t,n){return E(super.authenticate.bind(this),t,n)}authenticateWithQRCode(t,n,i){return E(super.authenticateWithQRCode.bind(this),t,n,i)}authenticateWithAppLink(t,n,i){return E(super.authenticateWithAppLink.bind(this),t,n,i)}authenticateWithNotificationPayload(t,n){return E(super.authenticateWithNotificationPayload.bind(this),t,n)}generateQuickCode(t,n){return E(super.generateQuickCode.bind(this),t,n)}sign(t,n,i,e){return E(super.sign.bind(this),t,n,i,e)}createCrossDeviceSession(t,n,i){return E(super.createCrossDeviceSession.bind(this),t,n,i)}checkCrossDeviceSessionStatus(t){return E(super.checkCrossDeviceSessionStatus.bind(this),t)}sendPushNotification(t){return E(super.sendPushNotification.bind(this),t)}}}(); +var MIRACLTrust=function(){"use strict";function t(t){const n=[];for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.push(encodeURIComponent(i)+"="+encodeURIComponent(t[i]));return n.join("&")}function n(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 i(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!==t)return h.config=s[t],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=o[h.config.CURVE],h.ROM_FIELD=r[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=[],O=[],F=[];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,F[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(O[o]=0,s=1,r=13;r<16;r++)c=F[o]*w[r].parity(),w[r].fshr(1),w[r].dec(c>>1),w[r].norm(),O[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*O[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*O[o]+F[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.13.0"+(t.applicationInfo?" "+t.applicationInfo:""),this.options=t,this.crypto=new c(t.seed),this.http=new u(t.requestTimeout,t.clientName,this._getDeviceName(),this._getDeviceTag(),t.projectId,t.cors),this.users=new a(t.userStorage,t.projectId,"mfa")}c.prototype._crypto=function(t){return t||(t="BN254CX"),h[t]||(h[t]=new s(t),h[t].MPIN.MAXPIN=1e6,h[t].MPIN.PBLEN=20,h[t].MPIN.TRAP=2e3),h[t]},c.prototype.generateKeypair=function(t){const n=[],i=[],e=this._crypto(t).MPIN.GET_DVS_KEYPAIR(this.rng,n,i);if(0!==e)throw new Error("Could not generate key pair: "+e);return{publicKey:this._bytesToHex(i),privateKey:this._bytesToHex(n)}},c.prototype.addShares=function(t,n,i,e){const o=this._hexToBytes(t),r=this._hexToBytes(n),s=this._hexToBytes(i),h=[],c=this._crypto(e).MPIN.RECOMBINE_G1(r,s,h);if(0!==c)throw new Error("Could not combine the client secret shares: "+c);const u=this._crypto(e).MPIN.GET_G1_MULTIPLE(null,0,o,h,h);if(0!==u)throw new Error("Could not combine private key with client secret: "+u);return this._bytesToHex(h)},c.prototype.extractPin=function(t,n,i,e,o){const r=this._hexToBytes(e),s=this._hexToBytes(this._mpinIdWithPublicKey(t,n)),h=this._crypto(o).MPIN.EXTRACT_PIN(this._crypto(o).MPIN.SHA256,s,i,r);if(0!==h)throw new Error("Could not extract PIN from client secret: "+h);return this._bytesToHex(r)},c.prototype.calculatePass1=function(t,n,i,e,o,r,s){const h=[],c=[],u=this._mpinIdWithPublicKey(t,n),a=this._crypto(s).MPIN.CLIENT_1(this._crypto(s).MPIN.SHA256,0,this._hexToBytes(u),this.rng,o,e,this._hexToBytes(i),r,h,c,this._hexToBytes(0));if(0!==a)throw new Error("Could not calculate pass 1 request data: "+a);return{UT:this._bytesToHex(c),U:this._bytesToHex(h)}},c.prototype.calculatePass2=function(t,n,i,e){const o=this._crypto(e).MPIN.CLIENT_2(t,this._hexToBytes(n),i);if(0!==o)throw new Error("Could not calculate pass 2 request data: "+o);return this._bytesToHex(i)},c.prototype.sign=function(t,n,i,e,o,r,s){const h=[],c=[],u=this._mpinIdWithPublicKey(t,n),a=this._crypto(s).MPIN.CLIENT(this._crypto(s).MPIN.SHA256,0,this._hexToBytes(u),this.rng,[],e,this._hexToBytes(i),h,c,null,null,r,[],this._hexToBytes(o));if(0!==a)throw new Error("Could not sign message: "+a);return{U:this._bytesToHex(c),V:this._bytesToHex(h)}},c.prototype.randomString=function(t){const n=new Array(t);for(let i=0;i>>4&15).toString(16),n+=(15&e).toString(16)}return n},u.prototype.request=function(t,n){if("function"!=typeof n)throw new Error("Bad or missing callback");if(!t.url)throw new Error("Missing URL for request");const i=new XMLHttpRequest;i.onreadystatechange=function(){let t;if(4===i.readyState&&200===i.status){try{t=JSON.parse(i.responseText)}catch(n){t=i.responseText}n(null,t)}else if(4===i.readyState){if(0===i.status)return void n(new Error("The request was aborted"),{status:0});try{t=JSON.parse(i.responseText)}catch(t){return void n(new Error(i.statusText),{status:i.status})}n(new Error(t.info),{status:i.status,error:t.error,context:t.context})}};let e=t.url;this.cors&&(e+=(-1!==e.indexOf("?")?"&":"?")+"project_id="+this.projectId);const o=t.type||"GET";return i.open(o,e,!0),i.timeout=this.requestTimeout,i.setRequestHeader("X-Miracl-Client",this.clientName),i.setRequestHeader("X-Miracl-Device-Name",this.deviceName),i.setRequestHeader("X-Miracl-Device-Tag",this.deviceTag),t.authorization&&i.setRequestHeader("Authorization",t.authorization),t.data?(i.setRequestHeader("Content-Type","application/json"),i.send(JSON.stringify(t.data))):i.send(),i},a.prototype.data=[],a.prototype.states={start:"STARTED",register:"REGISTERED",revoked:"REVOKED"},a.prototype.loadData=function(){this.data=JSON.parse(this.storage.getItem(this.storageKey))||[],this.store(),this.data.sort(((t,n)=>t.lastUsed&&(!n.lastUsed||t.lastUsed>n.lastUsed)?1:n.lastUsed&&(!t.lastUsed||t.lastUsed{if(t)return n(t,null);this.session=i,n(null,i)}))},f.prototype.fetchStatus=function(t){const n={url:this.options.projectUrl+"/rps/v2/access",type:"POST",data:{webOTT:this.session.webOTT}};this.http.request(n,((n,i)=>{if(n)return t(n,null);t(null,i)}))},f.prototype.sendPushNotificationForAuth=function(n,i){if(!n)return i(new Error("Empty user ID"),null);const e={url:this.options.projectUrl+"/pushauth?"+t(this.options.oidc),type:"POST",data:{prerollId:n}};this.http.request(e,((t,n)=>{if(t)return n&&"NO_PUSH_TOKEN"===n.error?i(new Error("No push token",{cause:t}),null):i(t,null);this.session.webOTT=n.webOTT,i(null,n)}))},f.prototype.sendVerificationEmail=function(t,n){if(!t)return n(new Error("Empty user ID"),null);const i={url:this.options.projectUrl+"/verification/email",type:"POST",data:{userId:t,mpinId:this.users.get(t,"mpinId"),projectId:this.options.projectId,accessId:this.session.accessId,deviceName:this._getDeviceName(),deviceTag:this._getDeviceTag(),clientId:this.options.oidc.client_id,redirectURI:this.options.oidc.redirect_uri,scope:this.options.oidc.scope?this.options.oidc.scope.split(" "):[],state:this.options.oidc.state,nonce:this.options.oidc.nonce}};this.http.request(i,((t,i)=>{if(t)return i&&"REQUEST_BACKOFF"===i.error?n(new Error("Request backoff",{cause:t}),i):n(new Error("Verification fail",{cause:t}),i);n(null,i)}))},f.prototype.getActivationToken=function(t,n){const i=function(t){const n=t.split("?").pop(),i=n.split("&"),e={};if(!n.length||!i.length)return e;for(let t=0;t{if(t)return e&&"UNSUCCESSFUL_VERIFICATION"===e.error?n(new Error("Unsuccessful verification",{cause:t}),e):n(new Error("Get activation token fail",{cause:t}),e);e.userId=i.user_id,n(null,e)}))},f.prototype.register=function(t,n,i,e){if(!t)return e(new Error("Empty user ID"),null);if(!n)return e(new Error("Empty activation token"),null);const o=this.crypto.generateKeypair();this._createMPinID(t,n,o,((n,r)=>{if(n)return r&&"INVALID_ACTIVATION_TOKEN"===r.error?e(new Error("Invalid activation token",{cause:n}),null):e(new Error("Registration fail",{cause:n}),null);if(r.projectId!==this.options.projectId)return e(new Error("Project mismatch"),null);let s=r.pinLength;s||(s=this.options.defaultPinLength),this._getTAShares(r.designatedTAs,r.mpinId,o.publicKey,((n,h)=>{if(n)return e(new Error("Registration fail",{cause:n}),null);i((n=>{this._createIdentity(t,n,r,h[0],h[1],o,e)}),s)}))}))},f.prototype._createMPinID=function(t,n,i,e){const o={url:this.options.projectUrl+"/registration",type:"POST",data:{userId:t,deviceName:this._getDeviceName(),deviceTag:this._getDeviceTag(),activationToken:n,publicKey:i.publicKey,ver:2}};this.http.request(o,((t,n)=>{if(t)return e(t,n);e(null,n)}))},f.prototype._getDeviceName=function(){return this.options.deviceName?this.options.deviceName:"Browser"},f.prototype._getDeviceTag=function(){const t=this.options.userStorage.getItem("miraclDeviceTag");if(t)return t;let n;try{n=this.crypto.randomString(16),this.options.userStorage.setItem("miraclDeviceTag",n)}catch(t){n=""}return n},f.prototype._getTAShares=function(t,n,i,e){const o=[],r=[];let s=t.length;for(let h=0;h{if(t?r.push(t):o[h]=n,0==--s){if(r.length>0)return e(new Error("Failed to get shares",{cause:r}),null);e(null,o)}}))},f.prototype._getTAShare=function(t,n,i,e){const o={type:"POST",url:t.url,authorization:"Bearer "+t.token,data:{mpinId:n,pubKey:i}};this.http.request(o,((t,n)=>{if(t)return e(t,null);e(null,n)}))},f.prototype._createIdentity=function(t,n,i,e,o,r,s){let h,c;try{h=this.crypto.addShares(r.privateKey,e.share,o.share),c=this.crypto.extractPin(i.mpinId,r.publicKey,n,h)}catch(t){return s(t,null)}const u=btoa(JSON.stringify([e.node,o.node])),a={mpinId:i.mpinId,token:c,curve:"BN254CX",dtas:u,publicKey:r.publicKey,pinLength:i.pinLength,projectId:i.projectId,verificationType:i.verificationType,state:this.users.states.register,nowTime:i.nowTime,updated:Math.floor(Date.now()/1e3)};this.users.write(t,a),s(null,a)},f.prototype.authenticate=function(t,n,i){this._authentication(t,n,["jwt"],"",i)},f.prototype.authenticateWithQRCode=function(t,n,i,e){const o=n.split("#").pop();this._authentication(t,i,["oidc"],o,e)},f.prototype.authenticateWithAppLink=function(t,n,i,e){const o=n.split("#").pop();this._authentication(t,i,["oidc"],o,e)},f.prototype.authenticateWithNotificationPayload=function(t,n,i){if(!t||!t.userID||!t.qrURL)return i(new Error("Invalid push notification payload"),null);const e=t.qrURL.split("#").pop();this._authentication(t.userID,n,["oidc"],e,i)},f.prototype.generateQuickCode=function(t,n,i){this._authentication(t,n,["reg-code"],"",((t,n)=>{if(t)return i(t,null);this.http.request({url:this.options.projectUrl+"/verification/quickcode",type:"POST",data:{projectId:this.options.projectId,jwt:n.jwt,deviceName:this._getDeviceName()}},((t,n)=>{if(t)return i(t,null);i(null,{code:n.code,expireTime:n.expireTime,ttlSeconds:n.ttlSeconds,OTP:n.code})}))}))},f.prototype._authentication=function(t,n,i,e,o){if(!t)return o(new Error("Empty user ID"),null);if(!this.users.exists(t))return o(new Error("User not found"),null);const r=this.users.get(t),s=[],h=[];this._getPass1(r,n,i,h,s,((c,u)=>{if(c)return u&&"EXPIRED_MPINID"===u.error?(this.users.write(t,{state:this.users.states.revoked}),o(new Error("Revoked",{cause:c}),null)):o(new Error("Authentication fail",{cause:c}),null);this._getPass2(r,i,e,u.y,h,s,((r,s)=>{if(r)return o(new Error("Authentication fail",{cause:r}),null);this._finishAuthentication(t,n,i,e,s.authOTT,((n,i)=>{if(n)return i&&"UNSUCCESSFUL_AUTHENTICATION"===i.error?o(new Error("Unsuccessful authentication",{cause:n}),null):i&&"REVOKED_MPINID"===i.error?(this.users.write(t,{state:this.users.states.revoked}),o(new Error("Revoked",{cause:n}),null)):o(new Error("Authentication fail",{cause:n}),null);o(null,i)}))}))}))},f.prototype._getPass1=function(t,n,i,e,o,r){let s;try{s=this.crypto.calculatePass1(t.mpinId,t.publicKey,t.token,n,e,o)}catch(t){return r(t,null)}const h={scope:i,mpin_id:t.mpinId,dtas:t.dtas,publicKey:t.publicKey,UT:s.UT,U:s.U};this.http.request({url:this.options.projectUrl+"/rps/v2/pass1",type:"POST",data:h},r)},f.prototype._getPass2=function(t,n,i,e,o,r,s){let h;try{h=this.crypto.calculatePass2(o,e,r)}catch(t){return s(t,null)}const c={mpin_id:t.mpinId,WID:i,V:h};this.http.request({url:this.options.projectUrl+"/rps/v2/pass2",type:"POST",data:c},s)},f.prototype._finishAuthentication=function(t,n,i,e,o,r){const s={authOTT:o,wam:"dvs"};this.http.request({url:this.options.projectUrl+"/rps/v2/authenticate",type:"POST",data:s},((o,s)=>{if(o)return r(o,s);s.dvsRegister?this._renewSecret(t,n,s.dvsRegister,(o=>{if(o)return r(o,null);this._authentication(t,n,i,e,r)})):(this.users.updateLastUsed(t),r(null,s))}))},f.prototype._renewSecret=function(t,n,i,e){const o=this.crypto.generateKeypair();this._createMPinID(t,i.token,o,((i,r)=>{if(i)return e(i,null);this._getTAShares(r.designatedTAs,r.mpinId,o.publicKey,((i,s)=>{if(i)return e(i,null);this._createIdentity(t,n,r,s[0],s[1],o,e)}))}))},f.prototype.sign=function(t,n,i,e,o){return t?this.users.exists(t)?i?void this._authentication(t,n,["dvs-auth"],"",(r=>{if(r)switch(r.message){case"Unsuccessful authentication":case"Revoked":return o(r,null);default:return o(new Error("Signing fail",{cause:r.cause}),null)}const s=this.users.get(t);let h;try{h=this.crypto.sign(s.mpinId,s.publicKey,s.token,n,i,e)}catch(r){return o(new Error("Signing fail",{cause:r}),null)}const c={hash:i,u:h.U,v:h.V,mpinId:s.mpinId,publicKey:s.publicKey,dtas:s.dtas};o(null,c)})):o(new Error("Empty message"),null):o(new Error("User not found"),null):o(new Error("Empty user ID"),null)},f.prototype.createCrossDeviceSession=function(t,n,i,e){if(i&&!t)return e(new Error("Session for signing must be created with user ID"),null);const o={url:this.options.projectUrl+"/rps/v2/session",type:"POST",data:{projectId:this.options.projectId,userId:t,hash:i,description:n}};this.http.request(o,((o,r)=>{if(o)return e(o,null);e(null,{type:i?"signing":"authentication",projectId:this.options.projectId,token:r.webOTT,sessionId:r.accessId,url:r.qrURL,userId:t||null,description:n||null,signingHash:i||null,expireTime:r.expireTime})}))},f.prototype.checkCrossDeviceSessionStatus=function(t,n){if(!t.token)return n(new Error("Invalid cross-device session"),null);const i={url:this.options.projectUrl+"/rps/v2/access",type:"POST",data:{webOTT:t.token}};this.http.request(i,((t,i)=>{if(t)return n(t,null);n(null,{status:i.status,userId:i.userId||null,jwt:i.jwt||null,signature:i.signature||null})}))},f.prototype.sendPushNotification=function(t,n){if(!t.userId)return n(new Error("Cross device session created without user ID"),null);const i={url:this.options.projectUrl+"/push",type:"POST",data:{projectId:this.options.projectId,userId:t.userId,accessId:t.sessionId}};this.http.request(i,((t,i)=>{if(t)return i&&"NO_PUSH_TOKEN"===i.error?n(new Error("No push token",{cause:t}),null):n(t,null);n(null,i)}))},f.prototype.getCrossDeviceSessionFromQRCode=function(t,n){this._getCrossDeviceSession(t,n)},f.prototype.getCrossDeviceSessionFromLink=function(t,n){this._getCrossDeviceSession(t,n)},f.prototype.getCrossDeviceSessionFromNotificationPayload=function(t,n){if(!t||!t.qrURL)return n(new Error("Invalid push notification payload"),null);this._getCrossDeviceSession(t.qrURL,n)},f.prototype._getCrossDeviceSession=function(t,n){const i=t.split("#").pop(),e={url:this.options.projectUrl+"/rps/v2/codeStatus",type:"POST",data:{status:"wid",wid:i}};this.http.request(e,((e,o)=>{if(e)return n(new Error("Get cross-device session request failed",{cause:e}),null);n(null,{type:o.hash?"signing":"authentication",projectId:o.projectId,token:null,sessionId:i,url:t,userId:o.prerollId||null,description:o.description||null,signingHash:o.hash||null,expireTime:o.expireTime})}))},f.prototype.authenticateCrossDeviceSession=function(t,n,i,e){if(t.userId&&t.userId!==n)return e(new Error("Cross-device session was initiated for different user ID"),null);this._authentication(n,i,["jwt"],t.sessionId,e)},f.prototype.signCrossDeviceSession=function(t,n,i,e){if(t.userId&&t.userId!==n)return e(new Error("Cross-device session was initiated for different user ID"),null);const o=Math.floor((new Date).getTime()/1e3);this.sign(n,i,t.signingHash,o,((n,i)=>{if(n)return e(n,null);const o={url:this.options.projectUrl+"/rps/v2/codeStatus",type:"POST",data:{status:"signed",wid:t.sessionId,signature:btoa(JSON.stringify(i))}};this.http.request(o,((t,n)=>{if(t)return e(new Error("Updating cross-device session failed",{cause:t}),null);e(null,n)}))}))},f.prototype.abortCrossDeviceSession=function(t,n){const i={url:this.options.projectUrl+"/rps/v2/codeStatus",type:"POST",data:{status:"abort",wid:t.sessionId}};this.http.request(i,((t,i)=>{if(t)return n(new Error("Aborting cross-device session failed",{cause:t}),null);n(null,i)}))};function E(t,...n){return new Promise(((i,e)=>{t(...n,((t,n)=>{t?e(t):i(n)}))}))}return class extends f{fetchAccessId(t){return E(super.fetchAccessId.bind(this),t)}fetchStatus(){return E(super.fetchStatus.bind(this))}sendPushNotificationForAuth(t){return E(super.sendPushNotificationForAuth.bind(this),t)}sendVerificationEmail(t){return E(super.sendVerificationEmail.bind(this),t)}getActivationToken(t){return E(super.getActivationToken.bind(this),t)}register(t,n,i){return E(super.register.bind(this),t,n,i)}authenticate(t,n){return E(super.authenticate.bind(this),t,n)}authenticateWithQRCode(t,n,i){return E(super.authenticateWithQRCode.bind(this),t,n,i)}authenticateWithAppLink(t,n,i){return E(super.authenticateWithAppLink.bind(this),t,n,i)}authenticateWithNotificationPayload(t,n){return E(super.authenticateWithNotificationPayload.bind(this),t,n)}generateQuickCode(t,n){return E(super.generateQuickCode.bind(this),t,n)}sign(t,n,i,e){return E(super.sign.bind(this),t,n,i,e)}createCrossDeviceSession(t,n,i){return E(super.createCrossDeviceSession.bind(this),t,n,i)}checkCrossDeviceSessionStatus(t){return E(super.checkCrossDeviceSessionStatus.bind(this),t)}sendPushNotification(t){return E(super.sendPushNotification.bind(this),t)}getCrossDeviceSessionFromQRCode(t){return E(super.getCrossDeviceSessionFromQRCode.bind(this),t)}getCrossDeviceSessionFromLink(t){return E(super.getCrossDeviceSessionFromLink.bind(this),t)}getCrossDeviceSessionFromNotificationPayload(t){return E(super.getCrossDeviceSessionFromNotificationPayload.bind(this),t)}authenticateCrossDeviceSession(t,n,i){return E(super.authenticateCrossDeviceSession.bind(this),t,n,i)}signCrossDeviceSession(t,n,i){return E(super.signCrossDeviceSession.bind(this),t,n,i)}abortCrossDeviceSession(t){return E(super.abortCrossDeviceSession.bind(this),t)}}}(); diff --git a/package-lock.json b/package-lock.json index aca6093..7d69cdc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@miracl/client-js", - "version": "8.12.0", + "version": "8.13.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@miracl/client-js", - "version": "8.12.0", + "version": "8.13.0", "license": "Apache-2.0", "dependencies": { "@miracl/crypto-js": "^4.0.0" @@ -18,8 +18,7 @@ "chai": "^6.2.1", "chai-as-promised": "^8.0.2", "eslint": "^8.57.0", - "mocha": "^11.7.6", - "nodemon": "^3.1.0", + "mocha": "^12.0.3", "rollup": "^4.13.0", "sinon": "^17.0.1" } @@ -171,42 +170,6 @@ "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, "node_modules/@istanbuljs/schema": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.6.tgz", @@ -315,17 +278,6 @@ "node": ">= 8" } }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=14" - } - }, "node_modules/@rollup/plugin-node-resolve": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.3.tgz", @@ -858,12 +810,6 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "dev": true }, - "node_modules/abbrev": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", - "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", - "dev": true - }, "node_modules/acorn": { "version": "8.11.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", @@ -928,19 +874,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -953,19 +886,10 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "node_modules/binary-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", - "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/brace-expansion": { - "version": "1.1.18", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", - "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", + "version": "1.1.21", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", + "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", "dev": true, "license": "MIT", "dependencies": { @@ -973,19 +897,6 @@ "concat-map": "0.0.1" } }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, - "license": "MIT", - "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -1266,79 +1177,19 @@ } }, "node_modules/chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/cliui/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz", + "integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==", "dev": true, + "license": "MIT", "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" + "readdirp": "^5.0.0" }, "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" + "node": ">= 20.19.0" }, - "engines": { - "node": ">=8" + "funding": { + "url": "https://paulmillr.com/funding/" } }, "node_modules/commander": { @@ -1468,18 +1319,6 @@ "node": ">=6.0.0" } }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true - }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -1879,26 +1718,17 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "node_modules/find-up-simple": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/find-up-simple/-/find-up-simple-1.0.1.tgz", + "integrity": "sha512-afd4O7zpqHeRyg4PfDQsXmlDe2PfdHtJt6Akt8jOWaApLOZk5JXs6VMR29lz03pRe9mpykrRCYIYxaJYcfpncQ==", "dev": true, "license": "MIT", - "dependencies": { - "to-regex-range": "^5.0.1" - }, "engines": { - "node": ">=8" - } - }, - "node_modules/flat": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", - "dev": true, - "bin": { - "flat": "cli.js" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/flat-cache": { @@ -2005,18 +1835,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -2044,15 +1862,6 @@ "node": ">=8" } }, - "node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true, - "bin": { - "he": "bin/he" - } - }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -2068,12 +1877,6 @@ "node": ">= 4" } }, - "node_modules/ignore-by-default": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", - "integrity": "sha1-SMptcvbGo68Aqa1K5odr44ieKwk=", - "dev": true - }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -2115,18 +1918,6 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/is-core-module": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", @@ -2148,15 +1939,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -2175,16 +1957,6 @@ "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", "dev": true }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -2199,6 +1971,7 @@ "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -2260,26 +2033,10 @@ "node": ">=8" } }, - "node_modules/jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" - } - }, "node_modules/js-yaml": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz", - "integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", + "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", "dev": true, "funding": [ { @@ -2337,83 +2094,6 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/log-symbols/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/log-symbols/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/log-symbols/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/log-symbols/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/log-symbols/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -2465,232 +2145,154 @@ } }, "node_modules/mocha": { - "version": "11.8.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-11.8.0.tgz", - "integrity": "sha512-VyCeUdGN3A9lmCTTgG4yuvY9ixxaDk+xt2R/7/+1AP6EqNG+G9OKkzBwhVtVYoNX8YsxNSgAl8mOv3IAeOpFbw==", + "version": "12.0.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-12.0.3.tgz", + "integrity": "sha512-beammieDdiWdkjANWeWPpkxUROYGi5FN88fPOkLiticz7HTg3Y+Pho3EYE6SUdcuWnZ3h2WD8EXCA55JF4o6wg==", "dev": true, "license": "MIT", "dependencies": { "browser-stdout": "^1.3.1", - "chokidar": "^4.0.1", + "chokidar": "^5.0.0", "debug": "^4.3.5", - "diff": "^7.0.0", - "escape-string-regexp": "^4.0.0", - "find-up": "^5.0.0", - "glob": "^10.4.5", - "he": "^1.2.0", - "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimatch": "^9.0.5", + "diff": "^9.0.0", + "find-up-simple": "^1.0.1", + "glob": "^13.0.0", + "is-path-inside": "^4.0.0", + "is-unicode-supported": "^0.1.0", + "js-yaml": "^5.0.0", + "minimatch": "^10.2.2", "ms": "^2.1.3", "picocolors": "^1.1.1", - "serialize-javascript": "^6.0.2", - "strip-json-comments": "^3.1.1", + "serialize-javascript": "^7.1.1", + "strip-json-comments": "^5.0.3", "supports-color": "^8.1.1", - "workerpool": "^9.2.0", - "yargs": "^17.7.2", - "yargs-parser": "^21.1.1", - "yargs-unparser": "^2.0.0" + "workerpool": "^10.0.0" }, "bin": { - "_mocha": "bin/_mocha", "mocha": "bin/mocha.js" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/mocha/node_modules/brace-expansion": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz", - "integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==", + "node_modules/mocha/node_modules/argparse": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-3.0.3.tgz", + "integrity": "sha512-Sn98ftV3KfsO8xfLPHG6oT8y+b0yvbrLgZjgPDXsharNY15tTAjqIsIju4S32nl6/iEUNNE4v+yL2Zhm8ooP3w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "PSF-2.0" + }, + "node_modules/mocha/node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", "dev": true, "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" + "engines": { + "node": "18 || 20 || >=22" } }, - "node_modules/mocha/node_modules/chokidar": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", - "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "node_modules/mocha/node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", "dev": true, "license": "MIT", "dependencies": { - "readdirp": "^4.0.1" + "balanced-match": "^4.0.2" }, "engines": { - "node": ">= 14.16.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" + "node": "20 || >=22" } }, "node_modules/mocha/node_modules/diff": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", - "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-9.0.0.tgz", + "integrity": "sha512-svtcdpS8CgJyqAjEQIXdb3OjhFVVYjzGAPO8WGCmRbrml64SPw/jJD4GoE98aR7r25A0XcgrK3F02yw9R/vhQw==", "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" } }, - "node_modules/mocha/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/mocha/node_modules/glob": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", - "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", - "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", - "dev": true, - "license": "ISC", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/mocha/node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/minimatch": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", - "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "version": "13.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", + "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "dependencies": { - "brace-expansion": "^2.0.2" + "minimatch": "^10.2.2", + "minipass": "^7.1.3", + "path-scurry": "^2.0.2" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "18 || 20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/mocha/node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "node_modules/mocha/node_modules/is-path-inside": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz", + "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==", "dev": true, - "dependencies": { - "p-limit": "^3.0.2" - }, + "license": "MIT", "engines": { - "node": ">=10" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mocha/node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/mocha/node_modules/readdirp": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", - "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "node_modules/mocha/node_modules/js-yaml": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.5.0.tgz", + "integrity": "sha512-paNr4LFIFPjeeSmwNYdrb8FafLLG/Cr2Af3GjbsHJ5CxIjH4r0c2emlmRdAtpPAieP1gRVzk6buBbVP5gBMGAg==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], "license": "MIT", - "engines": { - "node": ">= 14.18.0" + "dependencies": { + "argparse": "^3.0.3" }, - "funding": { - "type": "individual", - "url": "https://paulmillr.com/funding/" + "bin": { + "js-yaml": "bin/js-yaml.mjs" } }, - "node_modules/mocha/node_modules/serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "node_modules/mocha/node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", "dev": true, - "license": "BSD-3-Clause", + "license": "BlueOak-1.0.0", "dependencies": { - "randombytes": "^2.1.0" - } - }, - "node_modules/mocha/node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true, + "brace-expansion": "^5.0.8" + }, "engines": { - "node": ">=8" + "node": "18 || 20 || >=22" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/mocha/node_modules/supports-color": { @@ -2735,64 +2337,6 @@ "path-to-regexp": "^6.2.1" } }, - "node_modules/nodemon": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.0.tgz", - "integrity": "sha512-xqlktYlDMCepBJd43ZQhjWwMw2obW/JRvkrLxq5RCNcuDDX1DbcPT+qT1IlIIdf+DhnWs90JpTMe+Y5KxOchvA==", - "dev": true, - "dependencies": { - "chokidar": "^3.5.2", - "debug": "^4", - "ignore-by-default": "^1.0.1", - "minimatch": "^3.1.2", - "pstree.remy": "^1.1.8", - "semver": "^7.5.3", - "simple-update-notifier": "^2.0.0", - "supports-color": "^5.5.0", - "touch": "^3.1.0", - "undefsafe": "^2.0.5" - }, - "bin": { - "nodemon": "bin/nodemon.js" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nodemon" - } - }, - "node_modules/nodemon/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/nodemon/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -2819,13 +2363,6 @@ "node": ">= 0.8.0" } }, - "node_modules/package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "dev": true, - "license": "BlueOak-1.0.0" - }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -2854,28 +2391,31 @@ "dev": true }, "node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", + "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" }, "engines": { - "node": ">=16 || 14 >=14.18" + "node": "18 || 20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/path-scurry/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "dev": true, - "license": "ISC" + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } }, "node_modules/path-to-regexp": { "version": "6.3.0", @@ -2913,12 +2453,6 @@ "node": ">= 0.8.0" } }, - "node_modules/pstree.remy": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", - "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", - "dev": true - }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -2948,35 +2482,18 @@ } ] }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.1.1.tgz", + "integrity": "sha512-Kko+Y5XQ6fM+Ce3dq3m9YGxnacYZYl9cA1wZjaF3Vbry2L3i1qVg8+CAgNPsXRArPMUMCaOR7oa9Nqntc43JKA==", "dev": true, + "license": "MIT", "engines": { - "node": ">=0.10.0" + "node": ">= 20.19.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" } }, "node_modules/resolve": { @@ -3098,12 +2615,6 @@ "queue-microtask": "^1.2.2" } }, - "node_modules/safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", - "dev": true - }, "node_modules/semver": { "version": "7.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", @@ -3120,9 +2631,9 @@ } }, "node_modules/serialize-javascript": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-7.0.5.tgz", - "integrity": "sha512-F4LcB0UqUl1zErq+1nYEEzSHJnIwb3AF2XWB94b+afhrekOUijwooAYqFyRbjYkm2PAKBabx6oYv/xDxNi8IBw==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-7.1.2.tgz", + "integrity": "sha512-GL2BWwVa6JydKO6l/ljVgjAZF4QJ3S7dWDWi53s5GZT8PJzD2fNxi67HANQGKAqPrwEpL5ba7gUBGi0Ls/sEoQ==", "dev": true, "license": "BSD-3-Clause", "engines": { @@ -3141,18 +2652,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/simple-update-notifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", - "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", - "dev": true, - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/sinon": { "version": "17.0.1", "resolved": "https://registry.npmjs.org/sinon/-/sinon-17.0.1.tgz", @@ -3209,130 +2708,57 @@ "node": ">=0.10.0" } }, - "node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", "dev": true, + "license": "MIT", "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" + "ansi-regex": "^6.2.2" }, "engines": { "node": ">=12" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "node_modules/strip-json-comments": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz", + "integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==", "dev": true, "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, "engines": { - "node": ">=8" + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/string-width-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true, - "license": "MIT", "engines": { - "node": ">=8" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/string-width-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "node_modules/terser": { + "version": "5.29.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.29.2.tgz", + "integrity": "sha512-ZiGkhUBIM+7LwkNjXYJq8svgkd+QK3UUr0wJqY4MieaezBSAIPgbSPZyIx0idM6XWK5CMzSWa8MJIzmRcB8Caw==", "dev": true, - "license": "MIT", "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width/node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true - }, - "node_modules/strip-ansi": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", - "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.2.2" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/terser": { - "version": "5.29.2", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.29.2.tgz", - "integrity": "sha512-ZiGkhUBIM+7LwkNjXYJq8svgkd+QK3UUr0wJqY4MieaezBSAIPgbSPZyIx0idM6XWK5CMzSWa8MJIzmRcB8Caw==", - "dev": true, - "dependencies": { - "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" }, "bin": { "terser": "bin/terser" @@ -3367,9 +2793,9 @@ } }, "node_modules/test-exclude/node_modules/brace-expansion": { - "version": "5.0.9", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", - "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==", + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", "dev": true, "license": "MIT", "dependencies": { @@ -3397,16 +2823,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/test-exclude/node_modules/lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": "20 || >=22" - } - }, "node_modules/test-exclude/node_modules/minimatch": { "version": "10.2.6", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", @@ -3423,69 +2839,12 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/test-exclude/node_modules/path-scurry": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", - "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "lru-cache": "^11.0.0", - "minipass": "^7.1.2" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/touch": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", - "dev": true, - "dependencies": { - "nopt": "~1.0.10" - }, - "bin": { - "nodetouch": "bin/nodetouch.js" - } - }, - "node_modules/touch/node_modules/nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", - "dev": true, - "dependencies": { - "abbrev": "1" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -3508,12 +2867,6 @@ "node": ">=4" } }, - "node_modules/undefsafe": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", - "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", - "dev": true - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -3544,190 +2897,12 @@ "dev": true }, "node_modules/workerpool": { - "version": "9.3.4", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-9.3.4.tgz", - "integrity": "sha512-TmPRQYYSAnnDiEB0P/Ytip7bFGvqnSU6I2BcuSw7Hx+JSg/DsUi5ebYfc8GYaSdpuvOcEs6dXxPurOYpe9QFwg==", + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-10.0.3.tgz", + "integrity": "sha512-6z2Iis68Wqth93/G/wJP9u+R3O+d2XTlgWChGCwuT1qLbBsOYueGRZuJ++v3mtDP5KjYdy+WzvWC+VWETSVXJA==", "dev": true, "license": "Apache-2.0" }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "license": "MIT" - }, - "node_modules/wrap-ansi-cjs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/wrap-ansi/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/wrap-ansi/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -3749,24 +2924,6 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, - "node_modules/yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dev": true, - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/yargs-parser": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", @@ -3777,89 +2934,6 @@ "node": ">=12" } }, - "node_modules/yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", - "dev": true, - "dependencies": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-unparser/node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/yargs-unparser/node_modules/decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/yargs-unparser/node_modules/is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -3961,41 +3035,14 @@ "@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true - }, - "@humanwhocodes/object-schema": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", - "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", - "dev": true - }, - "@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, - "requires": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "dependencies": { - "wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "requires": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - } - } - } + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true + }, + "@humanwhocodes/object-schema": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", + "dev": true }, "@istanbuljs/schema": { "version": "0.1.6", @@ -4085,13 +3132,6 @@ "fastq": "^1.6.0" } }, - "@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "optional": true - }, "@rollup/plugin-node-resolve": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.3.tgz", @@ -4368,12 +3408,6 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "dev": true }, - "abbrev": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", - "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", - "dev": true - }, "acorn": { "version": "8.11.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", @@ -4411,16 +3445,6 @@ "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", "dev": true }, - "anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, "argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -4433,31 +3457,16 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "binary-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", - "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", - "dev": true - }, "brace-expansion": { - "version": "1.1.18", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", - "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", + "version": "1.1.21", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", + "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, - "requires": { - "fill-range": "^7.1.1" - } - }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -4648,58 +3657,12 @@ "dev": true }, "chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "requires": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "fsevents": "~2.3.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - } - }, - "cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz", + "integrity": "sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==", "dev": true, "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - } + "readdirp": "^5.0.0" } }, "commander": { @@ -4793,18 +3756,6 @@ "esutils": "^2.0.2" } }, - "eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -5089,19 +4040,10 @@ "flat-cache": "^3.0.4" } }, - "fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "flat": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "find-up-simple": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/find-up-simple/-/find-up-simple-1.0.1.tgz", + "integrity": "sha512-afd4O7zpqHeRyg4PfDQsXmlDe2PfdHtJt6Akt8jOWaApLOZk5JXs6VMR29lz03pRe9mpykrRCYIYxaJYcfpncQ==", "dev": true }, "flat-cache": { @@ -5175,15 +4117,6 @@ "path-is-absolute": "^1.0.0" } }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, "graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -5205,12 +4138,6 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, - "he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true - }, "html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -5223,12 +4150,6 @@ "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", "dev": true }, - "ignore-by-default": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", - "integrity": "sha1-SMptcvbGo68Aqa1K5odr44ieKwk=", - "dev": true - }, "import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -5261,15 +4182,6 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "requires": { - "binary-extensions": "^2.0.0" - } - }, "is-core-module": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", @@ -5285,12 +4197,6 @@ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "dev": true }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, "is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -5306,12 +4212,6 @@ "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", "dev": true }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true - }, "is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -5368,20 +4268,10 @@ "istanbul-lib-report": "^3.0.0" } }, - "jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", - "dev": true, - "requires": { - "@isaacs/cliui": "^8.0.2", - "@pkgjs/parseargs": "^0.11.0" - } - }, "js-yaml": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz", - "integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", + "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", "dev": true, "requires": { "argparse": "^2.0.1" @@ -5421,61 +4311,6 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "requires": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -5510,151 +4345,91 @@ "dev": true }, "mocha": { - "version": "11.8.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-11.8.0.tgz", - "integrity": "sha512-VyCeUdGN3A9lmCTTgG4yuvY9ixxaDk+xt2R/7/+1AP6EqNG+G9OKkzBwhVtVYoNX8YsxNSgAl8mOv3IAeOpFbw==", + "version": "12.0.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-12.0.3.tgz", + "integrity": "sha512-beammieDdiWdkjANWeWPpkxUROYGi5FN88fPOkLiticz7HTg3Y+Pho3EYE6SUdcuWnZ3h2WD8EXCA55JF4o6wg==", "dev": true, "requires": { "browser-stdout": "^1.3.1", - "chokidar": "^4.0.1", + "chokidar": "^5.0.0", "debug": "^4.3.5", - "diff": "^7.0.0", - "escape-string-regexp": "^4.0.0", - "find-up": "^5.0.0", - "glob": "^10.4.5", - "he": "^1.2.0", - "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimatch": "^9.0.5", + "diff": "^9.0.0", + "find-up-simple": "^1.0.1", + "glob": "^13.0.0", + "is-path-inside": "^4.0.0", + "is-unicode-supported": "^0.1.0", + "js-yaml": "^5.0.0", + "minimatch": "^10.2.2", "ms": "^2.1.3", "picocolors": "^1.1.1", - "serialize-javascript": "^6.0.2", - "strip-json-comments": "^3.1.1", + "serialize-javascript": "^7.1.1", + "strip-json-comments": "^5.0.3", "supports-color": "^8.1.1", - "workerpool": "^9.2.0", - "yargs": "^17.7.2", - "yargs-parser": "^21.1.1", - "yargs-unparser": "^2.0.0" + "workerpool": "^10.0.0" }, "dependencies": { - "brace-expansion": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz", - "integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - }, - "chokidar": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", - "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", - "dev": true, - "requires": { - "readdirp": "^4.0.1" - } - }, - "diff": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", - "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", + "argparse": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-3.0.3.tgz", + "integrity": "sha512-Sn98ftV3KfsO8xfLPHG6oT8y+b0yvbrLgZjgPDXsharNY15tTAjqIsIju4S32nl6/iEUNNE4v+yL2Zhm8ooP3w==", "dev": true }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", "dev": true }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, - "glob": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", - "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", + "brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", "dev": true, "requires": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" + "balanced-match": "^4.0.2" } }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } + "diff": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-9.0.0.tgz", + "integrity": "sha512-svtcdpS8CgJyqAjEQIXdb3OjhFVVYjzGAPO8WGCmRbrml64SPw/jJD4GoE98aR7r25A0XcgrK3F02yw9R/vhQw==", + "dev": true }, - "minimatch": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", - "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "glob": { + "version": "13.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", + "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", "dev": true, "requires": { - "brace-expansion": "^2.0.2" + "minimatch": "^10.2.2", + "minipass": "^7.1.3", + "path-scurry": "^2.0.2" } }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } + "is-path-inside": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz", + "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==", + "dev": true }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "js-yaml": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.5.0.tgz", + "integrity": "sha512-paNr4LFIFPjeeSmwNYdrb8FafLLG/Cr2Af3GjbsHJ5CxIjH4r0c2emlmRdAtpPAieP1gRVzk6buBbVP5gBMGAg==", "dev": true, "requires": { - "p-limit": "^3.0.2" + "argparse": "^3.0.3" } }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "readdirp": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", - "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", - "dev": true - }, - "serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", "dev": true, "requires": { - "randombytes": "^2.1.0" + "brace-expansion": "^5.0.8" } }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, "supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -5682,56 +4457,15 @@ "version": "5.1.9", "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.9.tgz", "integrity": "sha512-qOnoujW4SV6e40dYxJOb3uvuoPHtmLzIk4TFo+j0jPJoC+5Z9xja5qH5JZobEPsa8+YYphMrOSwnrshEhG2qww==", - "dev": true, - "requires": { - "@sinonjs/commons": "^3.0.0", - "@sinonjs/fake-timers": "^11.2.2", - "@sinonjs/text-encoding": "^0.7.2", - "just-extend": "^6.2.0", - "path-to-regexp": "^6.2.1" - } - }, - "nodemon": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.0.tgz", - "integrity": "sha512-xqlktYlDMCepBJd43ZQhjWwMw2obW/JRvkrLxq5RCNcuDDX1DbcPT+qT1IlIIdf+DhnWs90JpTMe+Y5KxOchvA==", - "dev": true, - "requires": { - "chokidar": "^3.5.2", - "debug": "^4", - "ignore-by-default": "^1.0.1", - "minimatch": "^3.1.2", - "pstree.remy": "^1.1.8", - "semver": "^7.5.3", - "simple-update-notifier": "^2.0.0", - "supports-color": "^5.5.0", - "touch": "^3.1.0", - "undefsafe": "^2.0.5" - }, - "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } + "dev": true, + "requires": { + "@sinonjs/commons": "^3.0.0", + "@sinonjs/fake-timers": "^11.2.2", + "@sinonjs/text-encoding": "^0.7.2", + "just-extend": "^6.2.0", + "path-to-regexp": "^6.2.1" } }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -5755,12 +4489,6 @@ "type-check": "^0.4.0" } }, - "package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "dev": true - }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -5783,19 +4511,19 @@ "dev": true }, "path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", + "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", "dev": true, "requires": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" }, "dependencies": { "lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "dev": true } } @@ -5824,12 +4552,6 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, - "pstree.remy": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", - "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", - "dev": true - }, "punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -5842,28 +4564,10 @@ "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", "dev": true }, - "randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "requires": { - "safe-buffer": "^5.1.0" - } - }, "readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "requires": { - "picomatch": "^2.2.1" - } - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.1.1.tgz", + "integrity": "sha512-Kko+Y5XQ6fM+Ce3dq3m9YGxnacYZYl9cA1wZjaF3Vbry2L3i1qVg8+CAgNPsXRArPMUMCaOR7oa9Nqntc43JKA==", "dev": true }, "resolve": { @@ -5942,12 +4646,6 @@ "queue-microtask": "^1.2.2" } }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", - "dev": true - }, "semver": { "version": "7.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", @@ -5958,9 +4656,9 @@ } }, "serialize-javascript": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-7.0.5.tgz", - "integrity": "sha512-F4LcB0UqUl1zErq+1nYEEzSHJnIwb3AF2XWB94b+afhrekOUijwooAYqFyRbjYkm2PAKBabx6oYv/xDxNi8IBw==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-7.1.2.tgz", + "integrity": "sha512-GL2BWwVa6JydKO6l/ljVgjAZF4QJ3S7dWDWi53s5GZT8PJzD2fNxi67HANQGKAqPrwEpL5ba7gUBGi0Ls/sEoQ==", "dev": true }, "signal-exit": { @@ -5969,15 +4667,6 @@ "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true }, - "simple-update-notifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", - "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", - "dev": true, - "requires": { - "semver": "^7.5.3" - } - }, "sinon": { "version": "17.0.1", "resolved": "https://registry.npmjs.org/sinon/-/sinon-17.0.1.tgz", @@ -6027,53 +4716,6 @@ } } }, - "string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "requires": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "dependencies": { - "emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true - } - } - }, - "string-width-cjs": { - "version": "npm:string-width@4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - } - } - }, "strip-ansi": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", @@ -6083,22 +4725,11 @@ "ansi-regex": "^6.2.2" } }, - "strip-ansi-cjs": { - "version": "npm:strip-ansi@6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - } - } + "strip-json-comments": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz", + "integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==", + "dev": true }, "supports-preserve-symlinks-flag": { "version": "1.0.0", @@ -6136,9 +4767,9 @@ "dev": true }, "brace-expansion": { - "version": "5.0.9", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", - "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==", + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", "dev": true, "requires": { "balanced-match": "^4.0.2" @@ -6155,12 +4786,6 @@ "path-scurry": "^2.0.2" } }, - "lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", - "dev": true - }, "minimatch": { "version": "10.2.6", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", @@ -6169,16 +4794,6 @@ "requires": { "brace-expansion": "^5.0.8" } - }, - "path-scurry": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", - "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", - "dev": true, - "requires": { - "lru-cache": "^11.0.0", - "minipass": "^7.1.2" - } } } }, @@ -6188,35 +4803,6 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "requires": { - "is-number": "^7.0.0" - } - }, - "touch": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", - "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", - "dev": true, - "requires": { - "nopt": "~1.0.10" - }, - "dependencies": { - "nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", - "dev": true, - "requires": { - "abbrev": "1" - } - } - } - }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -6232,12 +4818,6 @@ "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, - "undefsafe": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", - "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", - "dev": true - }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -6267,137 +4847,11 @@ } }, "workerpool": { - "version": "9.3.4", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-9.3.4.tgz", - "integrity": "sha512-TmPRQYYSAnnDiEB0P/Ytip7bFGvqnSU6I2BcuSw7Hx+JSg/DsUi5ebYfc8GYaSdpuvOcEs6dXxPurOYpe9QFwg==", + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-10.0.3.tgz", + "integrity": "sha512-6z2Iis68Wqth93/G/wJP9u+R3O+d2XTlgWChGCwuT1qLbBsOYueGRZuJ++v3mtDP5KjYdy+WzvWC+VWETSVXJA==", "dev": true }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - } - } - }, - "wrap-ansi-cjs": { - "version": "npm:wrap-ansi@7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - } - } - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -6416,87 +4870,12 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, - "yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dev": true, - "requires": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - } - } - }, "yargs-parser": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true }, - "yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", - "dev": true, - "requires": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - }, - "dependencies": { - "camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "dev": true - }, - "decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true - }, - "is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true - } - } - }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index e9fc5d1..efa6470 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@miracl/client-js", - "version": "8.12.0", + "version": "8.13.0", "description": "MIRACL Trust client library", "main": "./src/client.js", "exports": { @@ -19,8 +19,7 @@ "dist": "npm run build", "test": "mocha", "cover": "c8 -r text -r html npm run test", - "lint": "eslint .", - "watch": "nodemon --exec 'npm run build' --watch src --watch lib --ext js" + "lint": "eslint ." }, "mocha": { "recursive": true, @@ -47,8 +46,7 @@ "chai": "^6.2.1", "chai-as-promised": "^8.0.2", "eslint": "^8.57.0", - "mocha": "^11.7.6", - "nodemon": "^3.1.0", + "mocha": "^12.0.3", "rollup": "^4.13.0", "sinon": "^17.0.1" } diff --git a/src/client.js b/src/client.js index c72307d..0057091 100644 --- a/src/client.js +++ b/src/client.js @@ -55,7 +55,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.12.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); + options.clientName = "MIRACL Client.js/8.13.0" + (options.applicationInfo ? " " + options.applicationInfo : ""); this.options = options;