github.com/ur-technology/go-ur@v1.5.5/internal/jsre/ethereum_js.go (about)

     1  // Copyright 2015 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package jsre
    18  
    19  const Web3_JS = `
    20  require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
    21  module.exports=[
    22    {
    23      "constant": true,
    24      "inputs": [
    25        {
    26          "name": "_owner",
    27          "type": "address"
    28        }
    29      ],
    30      "name": "name",
    31      "outputs": [
    32        {
    33          "name": "o_name",
    34          "type": "bytes32"
    35        }
    36      ],
    37      "type": "function"
    38    },
    39    {
    40      "constant": true,
    41      "inputs": [
    42        {
    43          "name": "_name",
    44          "type": "bytes32"
    45        }
    46      ],
    47      "name": "owner",
    48      "outputs": [
    49        {
    50          "name": "",
    51          "type": "address"
    52        }
    53      ],
    54      "type": "function"
    55    },
    56    {
    57      "constant": true,
    58      "inputs": [
    59        {
    60          "name": "_name",
    61          "type": "bytes32"
    62        }
    63      ],
    64      "name": "content",
    65      "outputs": [
    66        {
    67          "name": "",
    68          "type": "bytes32"
    69        }
    70      ],
    71      "type": "function"
    72    },
    73    {
    74      "constant": true,
    75      "inputs": [
    76        {
    77          "name": "_name",
    78          "type": "bytes32"
    79        }
    80      ],
    81      "name": "addr",
    82      "outputs": [
    83        {
    84          "name": "",
    85          "type": "address"
    86        }
    87      ],
    88      "type": "function"
    89    },
    90    {
    91      "constant": false,
    92      "inputs": [
    93        {
    94          "name": "_name",
    95          "type": "bytes32"
    96        }
    97      ],
    98      "name": "reserve",
    99      "outputs": [],
   100      "type": "function"
   101    },
   102    {
   103      "constant": true,
   104      "inputs": [
   105        {
   106          "name": "_name",
   107          "type": "bytes32"
   108        }
   109      ],
   110      "name": "subRegistrar",
   111      "outputs": [
   112        {
   113          "name": "",
   114          "type": "address"
   115        }
   116      ],
   117      "type": "function"
   118    },
   119    {
   120      "constant": false,
   121      "inputs": [
   122        {
   123          "name": "_name",
   124          "type": "bytes32"
   125        },
   126        {
   127          "name": "_newOwner",
   128          "type": "address"
   129        }
   130      ],
   131      "name": "transfer",
   132      "outputs": [],
   133      "type": "function"
   134    },
   135    {
   136      "constant": false,
   137      "inputs": [
   138        {
   139          "name": "_name",
   140          "type": "bytes32"
   141        },
   142        {
   143          "name": "_registrar",
   144          "type": "address"
   145        }
   146      ],
   147      "name": "setSubRegistrar",
   148      "outputs": [],
   149      "type": "function"
   150    },
   151    {
   152      "constant": false,
   153      "inputs": [],
   154      "name": "Registrar",
   155      "outputs": [],
   156      "type": "function"
   157    },
   158    {
   159      "constant": false,
   160      "inputs": [
   161        {
   162          "name": "_name",
   163          "type": "bytes32"
   164        },
   165        {
   166          "name": "_a",
   167          "type": "address"
   168        },
   169        {
   170          "name": "_primary",
   171          "type": "bool"
   172        }
   173      ],
   174      "name": "setAddress",
   175      "outputs": [],
   176      "type": "function"
   177    },
   178    {
   179      "constant": false,
   180      "inputs": [
   181        {
   182          "name": "_name",
   183          "type": "bytes32"
   184        },
   185        {
   186          "name": "_content",
   187          "type": "bytes32"
   188        }
   189      ],
   190      "name": "setContent",
   191      "outputs": [],
   192      "type": "function"
   193    },
   194    {
   195      "constant": false,
   196      "inputs": [
   197        {
   198          "name": "_name",
   199          "type": "bytes32"
   200        }
   201      ],
   202      "name": "disown",
   203      "outputs": [],
   204      "type": "function"
   205    },
   206    {
   207      "anonymous": false,
   208      "inputs": [
   209        {
   210          "indexed": true,
   211          "name": "_name",
   212          "type": "bytes32"
   213        },
   214        {
   215          "indexed": false,
   216          "name": "_winner",
   217          "type": "address"
   218        }
   219      ],
   220      "name": "AuctionEnded",
   221      "type": "event"
   222    },
   223    {
   224      "anonymous": false,
   225      "inputs": [
   226        {
   227          "indexed": true,
   228          "name": "_name",
   229          "type": "bytes32"
   230        },
   231        {
   232          "indexed": false,
   233          "name": "_bidder",
   234          "type": "address"
   235        },
   236        {
   237          "indexed": false,
   238          "name": "_value",
   239          "type": "uint256"
   240        }
   241      ],
   242      "name": "NewBid",
   243      "type": "event"
   244    },
   245    {
   246      "anonymous": false,
   247      "inputs": [
   248        {
   249          "indexed": true,
   250          "name": "name",
   251          "type": "bytes32"
   252        }
   253      ],
   254      "name": "Changed",
   255      "type": "event"
   256    },
   257    {
   258      "anonymous": false,
   259      "inputs": [
   260        {
   261          "indexed": true,
   262          "name": "name",
   263          "type": "bytes32"
   264        },
   265        {
   266          "indexed": true,
   267          "name": "addr",
   268          "type": "address"
   269        }
   270      ],
   271      "name": "PrimaryChanged",
   272      "type": "event"
   273    }
   274  ]
   275  
   276  },{}],2:[function(require,module,exports){
   277  module.exports=[
   278    {
   279      "constant": true,
   280      "inputs": [
   281        {
   282          "name": "_name",
   283          "type": "bytes32"
   284        }
   285      ],
   286      "name": "owner",
   287      "outputs": [
   288        {
   289          "name": "",
   290          "type": "address"
   291        }
   292      ],
   293      "type": "function"
   294    },
   295    {
   296      "constant": false,
   297      "inputs": [
   298        {
   299          "name": "_name",
   300          "type": "bytes32"
   301        },
   302        {
   303          "name": "_refund",
   304          "type": "address"
   305        }
   306      ],
   307      "name": "disown",
   308      "outputs": [],
   309      "type": "function"
   310    },
   311    {
   312      "constant": true,
   313      "inputs": [
   314        {
   315          "name": "_name",
   316          "type": "bytes32"
   317        }
   318      ],
   319      "name": "addr",
   320      "outputs": [
   321        {
   322          "name": "",
   323          "type": "address"
   324        }
   325      ],
   326      "type": "function"
   327    },
   328    {
   329      "constant": false,
   330      "inputs": [
   331        {
   332          "name": "_name",
   333          "type": "bytes32"
   334        }
   335      ],
   336      "name": "reserve",
   337      "outputs": [],
   338      "type": "function"
   339    },
   340    {
   341      "constant": false,
   342      "inputs": [
   343        {
   344          "name": "_name",
   345          "type": "bytes32"
   346        },
   347        {
   348          "name": "_newOwner",
   349          "type": "address"
   350        }
   351      ],
   352      "name": "transfer",
   353      "outputs": [],
   354      "type": "function"
   355    },
   356    {
   357      "constant": false,
   358      "inputs": [
   359        {
   360          "name": "_name",
   361          "type": "bytes32"
   362        },
   363        {
   364          "name": "_a",
   365          "type": "address"
   366        }
   367      ],
   368      "name": "setAddr",
   369      "outputs": [],
   370      "type": "function"
   371    },
   372    {
   373      "anonymous": false,
   374      "inputs": [
   375        {
   376          "indexed": true,
   377          "name": "name",
   378          "type": "bytes32"
   379        }
   380      ],
   381      "name": "Changed",
   382      "type": "event"
   383    }
   384  ]
   385  
   386  },{}],3:[function(require,module,exports){
   387  module.exports=[
   388    {
   389      "constant": false,
   390      "inputs": [
   391        {
   392          "name": "from",
   393          "type": "bytes32"
   394        },
   395        {
   396          "name": "to",
   397          "type": "address"
   398        },
   399        {
   400          "name": "value",
   401          "type": "uint256"
   402        }
   403      ],
   404      "name": "transfer",
   405      "outputs": [],
   406      "type": "function"
   407    },
   408    {
   409      "constant": false,
   410      "inputs": [
   411        {
   412          "name": "from",
   413          "type": "bytes32"
   414        },
   415        {
   416          "name": "to",
   417          "type": "address"
   418        },
   419        {
   420          "name": "indirectId",
   421          "type": "bytes32"
   422        },
   423        {
   424          "name": "value",
   425          "type": "uint256"
   426        }
   427      ],
   428      "name": "icapTransfer",
   429      "outputs": [],
   430      "type": "function"
   431    },
   432    {
   433      "constant": false,
   434      "inputs": [
   435        {
   436          "name": "to",
   437          "type": "bytes32"
   438        }
   439      ],
   440      "name": "deposit",
   441      "outputs": [],
   442      "type": "function"
   443    },
   444    {
   445      "anonymous": false,
   446      "inputs": [
   447        {
   448          "indexed": true,
   449          "name": "from",
   450          "type": "address"
   451        },
   452        {
   453          "indexed": false,
   454          "name": "value",
   455          "type": "uint256"
   456        }
   457      ],
   458      "name": "AnonymousDeposit",
   459      "type": "event"
   460    },
   461    {
   462      "anonymous": false,
   463      "inputs": [
   464        {
   465          "indexed": true,
   466          "name": "from",
   467          "type": "address"
   468        },
   469        {
   470          "indexed": true,
   471          "name": "to",
   472          "type": "bytes32"
   473        },
   474        {
   475          "indexed": false,
   476          "name": "value",
   477          "type": "uint256"
   478        }
   479      ],
   480      "name": "Deposit",
   481      "type": "event"
   482    },
   483    {
   484      "anonymous": false,
   485      "inputs": [
   486        {
   487          "indexed": true,
   488          "name": "from",
   489          "type": "bytes32"
   490        },
   491        {
   492          "indexed": true,
   493          "name": "to",
   494          "type": "address"
   495        },
   496        {
   497          "indexed": false,
   498          "name": "value",
   499          "type": "uint256"
   500        }
   501      ],
   502      "name": "Transfer",
   503      "type": "event"
   504    },
   505    {
   506      "anonymous": false,
   507      "inputs": [
   508        {
   509          "indexed": true,
   510          "name": "from",
   511          "type": "bytes32"
   512        },
   513        {
   514          "indexed": true,
   515          "name": "to",
   516          "type": "address"
   517        },
   518        {
   519          "indexed": false,
   520          "name": "indirectId",
   521          "type": "bytes32"
   522        },
   523        {
   524          "indexed": false,
   525          "name": "value",
   526          "type": "uint256"
   527        }
   528      ],
   529      "name": "IcapTransfer",
   530      "type": "event"
   531    }
   532  ]
   533  
   534  },{}],4:[function(require,module,exports){
   535  var f = require('./formatters');
   536  var SolidityType = require('./type');
   537  
   538  /**
   539   * SolidityTypeAddress is a prootype that represents address type
   540   * It matches:
   541   * address
   542   * address[]
   543   * address[4]
   544   * address[][]
   545   * address[3][]
   546   * address[][6][], ...
   547   */
   548  var SolidityTypeAddress = function () {
   549      this._inputFormatter = f.formatInputInt;
   550      this._outputFormatter = f.formatOutputAddress;
   551  };
   552  
   553  SolidityTypeAddress.prototype = new SolidityType({});
   554  SolidityTypeAddress.prototype.constructor = SolidityTypeAddress;
   555  
   556  SolidityTypeAddress.prototype.isType = function (name) {
   557      return !!name.match(/address(\[([0-9]*)\])?/);
   558  };
   559  
   560  SolidityTypeAddress.prototype.staticPartLength = function (name) {
   561      return 32 * this.staticArrayLength(name);
   562  };
   563  
   564  module.exports = SolidityTypeAddress;
   565  
   566  
   567  },{"./formatters":9,"./type":14}],5:[function(require,module,exports){
   568  var f = require('./formatters');
   569  var SolidityType = require('./type');
   570  
   571  /**
   572   * SolidityTypeBool is a prootype that represents bool type
   573   * It matches:
   574   * bool
   575   * bool[]
   576   * bool[4]
   577   * bool[][]
   578   * bool[3][]
   579   * bool[][6][], ...
   580   */
   581  var SolidityTypeBool = function () {
   582      this._inputFormatter = f.formatInputBool;
   583      this._outputFormatter = f.formatOutputBool;
   584  };
   585  
   586  SolidityTypeBool.prototype = new SolidityType({});
   587  SolidityTypeBool.prototype.constructor = SolidityTypeBool;
   588  
   589  SolidityTypeBool.prototype.isType = function (name) {
   590      return !!name.match(/^bool(\[([0-9]*)\])*$/);
   591  };
   592  
   593  SolidityTypeBool.prototype.staticPartLength = function (name) {
   594      return 32 * this.staticArrayLength(name);
   595  };
   596  
   597  module.exports = SolidityTypeBool;
   598  
   599  },{"./formatters":9,"./type":14}],6:[function(require,module,exports){
   600  var f = require('./formatters');
   601  var SolidityType = require('./type');
   602  
   603  /**
   604   * SolidityTypeBytes is a prootype that represents bytes type
   605   * It matches:
   606   * bytes
   607   * bytes[]
   608   * bytes[4]
   609   * bytes[][]
   610   * bytes[3][]
   611   * bytes[][6][], ...
   612   * bytes32
   613   * bytes64[]
   614   * bytes8[4]
   615   * bytes256[][]
   616   * bytes[3][]
   617   * bytes64[][6][], ...
   618   */
   619  var SolidityTypeBytes = function () {
   620      this._inputFormatter = f.formatInputBytes;
   621      this._outputFormatter = f.formatOutputBytes;
   622  };
   623  
   624  SolidityTypeBytes.prototype = new SolidityType({});
   625  SolidityTypeBytes.prototype.constructor = SolidityTypeBytes;
   626  
   627  SolidityTypeBytes.prototype.isType = function (name) {
   628      return !!name.match(/^bytes([0-9]{1,})(\[([0-9]*)\])*$/);
   629  };
   630  
   631  SolidityTypeBytes.prototype.staticPartLength = function (name) {
   632      var matches = name.match(/^bytes([0-9]*)/);
   633      var size = parseInt(matches[1]);
   634      return size * this.staticArrayLength(name);
   635  };
   636  
   637  module.exports = SolidityTypeBytes;
   638  
   639  },{"./formatters":9,"./type":14}],7:[function(require,module,exports){
   640  /*
   641      This file is part of web3.js.
   642  
   643      web3.js is free software: you can redistribute it and/or modify
   644      it under the terms of the GNU Lesser General Public License as published by
   645      the Free Software Foundation, either version 3 of the License, or
   646      (at your option) any later version.
   647  
   648      web3.js is distributed in the hope that it will be useful,
   649      but WITHOUT ANY WARRANTY; without even the implied warranty of
   650      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   651      GNU Lesser General Public License for more details.
   652  
   653      You should have received a copy of the GNU Lesser General Public License
   654      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
   655  */
   656  /**
   657   * @file coder.js
   658   * @author Marek Kotewicz <marek@ethdev.com>
   659   * @date 2015
   660   */
   661  
   662  var f = require('./formatters');
   663  
   664  var SolidityTypeAddress = require('./address');
   665  var SolidityTypeBool = require('./bool');
   666  var SolidityTypeInt = require('./int');
   667  var SolidityTypeUInt = require('./uint');
   668  var SolidityTypeDynamicBytes = require('./dynamicbytes');
   669  var SolidityTypeString = require('./string');
   670  var SolidityTypeReal = require('./real');
   671  var SolidityTypeUReal = require('./ureal');
   672  var SolidityTypeBytes = require('./bytes');
   673  
   674  /**
   675   * SolidityCoder prototype should be used to encode/decode solidity params of any type
   676   */
   677  var SolidityCoder = function (types) {
   678      this._types = types;
   679  };
   680  
   681  /**
   682   * This method should be used to transform type to SolidityType
   683   *
   684   * @method _requireType
   685   * @param {String} type
   686   * @returns {SolidityType}
   687   * @throws {Error} throws if no matching type is found
   688   */
   689  SolidityCoder.prototype._requireType = function (type) {
   690      var solidityType = this._types.filter(function (t) {
   691          return t.isType(type);
   692      })[0];
   693  
   694      if (!solidityType) {
   695          throw Error('invalid solidity type!: ' + type);
   696      }
   697  
   698      return solidityType;
   699  };
   700  
   701  /**
   702   * Should be used to encode plain param
   703   *
   704   * @method encodeParam
   705   * @param {String} type
   706   * @param {Object} plain param
   707   * @return {String} encoded plain param
   708   */
   709  SolidityCoder.prototype.encodeParam = function (type, param) {
   710      return this.encodeParams([type], [param]);
   711  };
   712  
   713  /**
   714   * Should be used to encode list of params
   715   *
   716   * @method encodeParams
   717   * @param {Array} types
   718   * @param {Array} params
   719   * @return {String} encoded list of params
   720   */
   721  SolidityCoder.prototype.encodeParams = function (types, params) {
   722      var solidityTypes = this.getSolidityTypes(types);
   723  
   724      var encodeds = solidityTypes.map(function (solidityType, index) {
   725          return solidityType.encode(params[index], types[index]);
   726      });
   727  
   728      var dynamicOffset = solidityTypes.reduce(function (acc, solidityType, index) {
   729          var staticPartLength = solidityType.staticPartLength(types[index]);
   730          var roundedStaticPartLength = Math.floor((staticPartLength + 31) / 32) * 32;
   731          return acc + roundedStaticPartLength;
   732      }, 0);
   733  
   734      var result = this.encodeMultiWithOffset(types, solidityTypes, encodeds, dynamicOffset);
   735  
   736      return result;
   737  };
   738  
   739  SolidityCoder.prototype.encodeMultiWithOffset = function (types, solidityTypes, encodeds, dynamicOffset) {
   740      var result = "";
   741      var self = this;
   742  
   743      var isDynamic = function (i) {
   744         return solidityTypes[i].isDynamicArray(types[i]) || solidityTypes[i].isDynamicType(types[i]);
   745      };
   746  
   747      types.forEach(function (type, i) {
   748          if (isDynamic(i)) {
   749              result += f.formatInputInt(dynamicOffset).encode();
   750              var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   751              dynamicOffset += e.length / 2;
   752          } else {
   753              // don't add length to dynamicOffset. it's already counted
   754              result += self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   755          }
   756  
   757          // TODO: figure out nested arrays
   758      });
   759  
   760      types.forEach(function (type, i) {
   761          if (isDynamic(i)) {
   762              var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   763              dynamicOffset += e.length / 2;
   764              result += e;
   765          }
   766      });
   767      return result;
   768  };
   769  
   770  // TODO: refactor whole encoding!
   771  SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded, offset) {
   772      var self = this;
   773      if (solidityType.isDynamicArray(type)) {
   774          return (function () {
   775              // offset was already set
   776              var nestedName = solidityType.nestedName(type);
   777              var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
   778              var result = encoded[0];
   779  
   780              (function () {
   781                  var previousLength = 2; // in int
   782                  if (solidityType.isDynamicArray(nestedName)) {
   783                      for (var i = 1; i < encoded.length; i++) {
   784                          previousLength += +(encoded[i - 1])[0] || 0;
   785                          result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
   786                      }
   787                  }
   788              })();
   789  
   790              // first element is length, skip it
   791              (function () {
   792                  for (var i = 0; i < encoded.length - 1; i++) {
   793                      var additionalOffset = result / 2;
   794                      result += self.encodeWithOffset(nestedName, solidityType, encoded[i + 1], offset +  additionalOffset);
   795                  }
   796              })();
   797  
   798              return result;
   799          })();
   800  
   801      } else if (solidityType.isStaticArray(type)) {
   802          return (function () {
   803              var nestedName = solidityType.nestedName(type);
   804              var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
   805              var result = "";
   806  
   807  
   808              if (solidityType.isDynamicArray(nestedName)) {
   809                  (function () {
   810                      var previousLength = 0; // in int
   811                      for (var i = 0; i < encoded.length; i++) {
   812                          // calculate length of previous item
   813                          previousLength += +(encoded[i - 1] || [])[0] || 0;
   814                          result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
   815                      }
   816                  })();
   817              }
   818  
   819              (function () {
   820                  for (var i = 0; i < encoded.length; i++) {
   821                      var additionalOffset = result / 2;
   822                      result += self.encodeWithOffset(nestedName, solidityType, encoded[i], offset + additionalOffset);
   823                  }
   824              })();
   825  
   826              return result;
   827          })();
   828      }
   829  
   830      return encoded;
   831  };
   832  
   833  /**
   834   * Should be used to decode bytes to plain param
   835   *
   836   * @method decodeParam
   837   * @param {String} type
   838   * @param {String} bytes
   839   * @return {Object} plain param
   840   */
   841  SolidityCoder.prototype.decodeParam = function (type, bytes) {
   842      return this.decodeParams([type], bytes)[0];
   843  };
   844  
   845  /**
   846   * Should be used to decode list of params
   847   *
   848   * @method decodeParam
   849   * @param {Array} types
   850   * @param {String} bytes
   851   * @return {Array} array of plain params
   852   */
   853  SolidityCoder.prototype.decodeParams = function (types, bytes) {
   854      var solidityTypes = this.getSolidityTypes(types);
   855      var offsets = this.getOffsets(types, solidityTypes);
   856  
   857      return solidityTypes.map(function (solidityType, index) {
   858          return solidityType.decode(bytes, offsets[index],  types[index], index);
   859      });
   860  };
   861  
   862  SolidityCoder.prototype.getOffsets = function (types, solidityTypes) {
   863      var lengths =  solidityTypes.map(function (solidityType, index) {
   864          return solidityType.staticPartLength(types[index]);
   865      });
   866  
   867      for (var i = 1; i < lengths.length; i++) {
   868           // sum with length of previous element
   869          lengths[i] += lengths[i - 1];
   870      }
   871  
   872      return lengths.map(function (length, index) {
   873          // remove the current length, so the length is sum of previous elements
   874          var staticPartLength = solidityTypes[index].staticPartLength(types[index]);
   875          return length - staticPartLength;
   876      });
   877  };
   878  
   879  SolidityCoder.prototype.getSolidityTypes = function (types) {
   880      var self = this;
   881      return types.map(function (type) {
   882          return self._requireType(type);
   883      });
   884  };
   885  
   886  var coder = new SolidityCoder([
   887      new SolidityTypeAddress(),
   888      new SolidityTypeBool(),
   889      new SolidityTypeInt(),
   890      new SolidityTypeUInt(),
   891      new SolidityTypeDynamicBytes(),
   892      new SolidityTypeBytes(),
   893      new SolidityTypeString(),
   894      new SolidityTypeReal(),
   895      new SolidityTypeUReal()
   896  ]);
   897  
   898  module.exports = coder;
   899  
   900  
   901  },{"./address":4,"./bool":5,"./bytes":6,"./dynamicbytes":8,"./formatters":9,"./int":10,"./real":12,"./string":13,"./uint":15,"./ureal":16}],8:[function(require,module,exports){
   902  var f = require('./formatters');
   903  var SolidityType = require('./type');
   904  
   905  var SolidityTypeDynamicBytes = function () {
   906      this._inputFormatter = f.formatInputDynamicBytes;
   907      this._outputFormatter = f.formatOutputDynamicBytes;
   908  };
   909  
   910  SolidityTypeDynamicBytes.prototype = new SolidityType({});
   911  SolidityTypeDynamicBytes.prototype.constructor = SolidityTypeDynamicBytes;
   912  
   913  SolidityTypeDynamicBytes.prototype.isType = function (name) {
   914      return !!name.match(/^bytes(\[([0-9]*)\])*$/);
   915  };
   916  
   917  SolidityTypeDynamicBytes.prototype.staticPartLength = function (name) {
   918      return 32 * this.staticArrayLength(name);
   919  };
   920  
   921  SolidityTypeDynamicBytes.prototype.isDynamicType = function () {
   922      return true;
   923  };
   924  
   925  module.exports = SolidityTypeDynamicBytes;
   926  
   927  
   928  },{"./formatters":9,"./type":14}],9:[function(require,module,exports){
   929  /*
   930      This file is part of web3.js.
   931  
   932      web3.js is free software: you can redistribute it and/or modify
   933      it under the terms of the GNU Lesser General Public License as published by
   934      the Free Software Foundation, either version 3 of the License, or
   935      (at your option) any later version.
   936  
   937      web3.js is distributed in the hope that it will be useful,
   938      but WITHOUT ANY WARRANTY; without even the implied warranty of
   939      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   940      GNU Lesser General Public License for more details.
   941  
   942      You should have received a copy of the GNU Lesser General Public License
   943      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
   944  */
   945  /**
   946   * @file formatters.js
   947   * @author Marek Kotewicz <marek@ethdev.com>
   948   * @date 2015
   949   */
   950  
   951  var BigNumber = require('bignumber.js');
   952  var utils = require('../utils/utils');
   953  var c = require('../utils/config');
   954  var SolidityParam = require('./param');
   955  
   956  
   957  /**
   958   * Formats input value to byte representation of int
   959   * If value is negative, return it's two's complement
   960   * If the value is floating point, round it down
   961   *
   962   * @method formatInputInt
   963   * @param {String|Number|BigNumber} value that needs to be formatted
   964   * @returns {SolidityParam}
   965   */
   966  var formatInputInt = function (value) {
   967      BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
   968      var result = utils.padLeft(utils.toTwosComplement(value).round().toString(16), 64);
   969      return new SolidityParam(result);
   970  };
   971  
   972  /**
   973   * Formats input bytes
   974   *
   975   * @method formatInputBytes
   976   * @param {String}
   977   * @returns {SolidityParam}
   978   */
   979  var formatInputBytes = function (value) {
   980      var result = utils.toHex(value).substr(2);
   981      var l = Math.floor((result.length + 63) / 64);
   982      result = utils.padRight(result, l * 64);
   983      return new SolidityParam(result);
   984  };
   985  
   986  /**
   987   * Formats input bytes
   988   *
   989   * @method formatDynamicInputBytes
   990   * @param {String}
   991   * @returns {SolidityParam}
   992   */
   993  var formatInputDynamicBytes = function (value) {
   994      var result = utils.toHex(value).substr(2);
   995      var length = result.length / 2;
   996      var l = Math.floor((result.length + 63) / 64);
   997      result = utils.padRight(result, l * 64);
   998      return new SolidityParam(formatInputInt(length).value + result);
   999  };
  1000  
  1001  /**
  1002   * Formats input value to byte representation of string
  1003   *
  1004   * @method formatInputString
  1005   * @param {String}
  1006   * @returns {SolidityParam}
  1007   */
  1008  var formatInputString = function (value) {
  1009      var result = utils.fromUtf8(value).substr(2);
  1010      var length = result.length / 2;
  1011      var l = Math.floor((result.length + 63) / 64);
  1012      result = utils.padRight(result, l * 64);
  1013      return new SolidityParam(formatInputInt(length).value + result);
  1014  };
  1015  
  1016  /**
  1017   * Formats input value to byte representation of bool
  1018   *
  1019   * @method formatInputBool
  1020   * @param {Boolean}
  1021   * @returns {SolidityParam}
  1022   */
  1023  var formatInputBool = function (value) {
  1024      var result = '000000000000000000000000000000000000000000000000000000000000000' + (value ?  '1' : '0');
  1025      return new SolidityParam(result);
  1026  };
  1027  
  1028  /**
  1029   * Formats input value to byte representation of real
  1030   * Values are multiplied by 2^m and encoded as integers
  1031   *
  1032   * @method formatInputReal
  1033   * @param {String|Number|BigNumber}
  1034   * @returns {SolidityParam}
  1035   */
  1036  var formatInputReal = function (value) {
  1037      return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
  1038  };
  1039  
  1040  /**
  1041   * Check if input value is negative
  1042   *
  1043   * @method signedIsNegative
  1044   * @param {String} value is hex format
  1045   * @returns {Boolean} true if it is negative, otherwise false
  1046   */
  1047  var signedIsNegative = function (value) {
  1048      return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
  1049  };
  1050  
  1051  /**
  1052   * Formats right-aligned output bytes to int
  1053   *
  1054   * @method formatOutputInt
  1055   * @param {SolidityParam} param
  1056   * @returns {BigNumber} right-aligned output bytes formatted to big number
  1057   */
  1058  var formatOutputInt = function (param) {
  1059      var value = param.staticPart() || "0";
  1060  
  1061      // check if it's negative number
  1062      // it it is, return two's complement
  1063      if (signedIsNegative(value)) {
  1064          return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
  1065      }
  1066      return new BigNumber(value, 16);
  1067  };
  1068  
  1069  /**
  1070   * Formats right-aligned output bytes to uint
  1071   *
  1072   * @method formatOutputUInt
  1073   * @param {SolidityParam}
  1074   * @returns {BigNumeber} right-aligned output bytes formatted to uint
  1075   */
  1076  var formatOutputUInt = function (param) {
  1077      var value = param.staticPart() || "0";
  1078      return new BigNumber(value, 16);
  1079  };
  1080  
  1081  /**
  1082   * Formats right-aligned output bytes to real
  1083   *
  1084   * @method formatOutputReal
  1085   * @param {SolidityParam}
  1086   * @returns {BigNumber} input bytes formatted to real
  1087   */
  1088  var formatOutputReal = function (param) {
  1089      return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
  1090  };
  1091  
  1092  /**
  1093   * Formats right-aligned output bytes to ureal
  1094   *
  1095   * @method formatOutputUReal
  1096   * @param {SolidityParam}
  1097   * @returns {BigNumber} input bytes formatted to ureal
  1098   */
  1099  var formatOutputUReal = function (param) {
  1100      return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
  1101  };
  1102  
  1103  /**
  1104   * Should be used to format output bool
  1105   *
  1106   * @method formatOutputBool
  1107   * @param {SolidityParam}
  1108   * @returns {Boolean} right-aligned input bytes formatted to bool
  1109   */
  1110  var formatOutputBool = function (param) {
  1111      return param.staticPart() === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
  1112  };
  1113  
  1114  /**
  1115   * Should be used to format output bytes
  1116   *
  1117   * @method formatOutputBytes
  1118   * @param {SolidityParam} left-aligned hex representation of string
  1119   * @returns {String} hex string
  1120   */
  1121  var formatOutputBytes = function (param) {
  1122      return '0x' + param.staticPart();
  1123  };
  1124  
  1125  /**
  1126   * Should be used to format output bytes
  1127   *
  1128   * @method formatOutputDynamicBytes
  1129   * @param {SolidityParam} left-aligned hex representation of string
  1130   * @returns {String} hex string
  1131   */
  1132  var formatOutputDynamicBytes = function (param) {
  1133      var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1134      return '0x' + param.dynamicPart().substr(64, length);
  1135  };
  1136  
  1137  /**
  1138   * Should be used to format output string
  1139   *
  1140   * @method formatOutputString
  1141   * @param {SolidityParam} left-aligned hex representation of string
  1142   * @returns {String} ascii string
  1143   */
  1144  var formatOutputString = function (param) {
  1145      var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1146      return utils.toUtf8(param.dynamicPart().substr(64, length));
  1147  };
  1148  
  1149  /**
  1150   * Should be used to format output address
  1151   *
  1152   * @method formatOutputAddress
  1153   * @param {SolidityParam} right-aligned input bytes
  1154   * @returns {String} address
  1155   */
  1156  var formatOutputAddress = function (param) {
  1157      var value = param.staticPart();
  1158      return "0x" + value.slice(value.length - 40, value.length);
  1159  };
  1160  
  1161  module.exports = {
  1162      formatInputInt: formatInputInt,
  1163      formatInputBytes: formatInputBytes,
  1164      formatInputDynamicBytes: formatInputDynamicBytes,
  1165      formatInputString: formatInputString,
  1166      formatInputBool: formatInputBool,
  1167      formatInputReal: formatInputReal,
  1168      formatOutputInt: formatOutputInt,
  1169      formatOutputUInt: formatOutputUInt,
  1170      formatOutputReal: formatOutputReal,
  1171      formatOutputUReal: formatOutputUReal,
  1172      formatOutputBool: formatOutputBool,
  1173      formatOutputBytes: formatOutputBytes,
  1174      formatOutputDynamicBytes: formatOutputDynamicBytes,
  1175      formatOutputString: formatOutputString,
  1176      formatOutputAddress: formatOutputAddress
  1177  };
  1178  
  1179  
  1180  },{"../utils/config":18,"../utils/utils":20,"./param":11,"bignumber.js":"bignumber.js"}],10:[function(require,module,exports){
  1181  var f = require('./formatters');
  1182  var SolidityType = require('./type');
  1183  
  1184  /**
  1185   * SolidityTypeInt is a prootype that represents int type
  1186   * It matches:
  1187   * int
  1188   * int[]
  1189   * int[4]
  1190   * int[][]
  1191   * int[3][]
  1192   * int[][6][], ...
  1193   * int32
  1194   * int64[]
  1195   * int8[4]
  1196   * int256[][]
  1197   * int[3][]
  1198   * int64[][6][], ...
  1199   */
  1200  var SolidityTypeInt = function () {
  1201      this._inputFormatter = f.formatInputInt;
  1202      this._outputFormatter = f.formatOutputInt;
  1203  };
  1204  
  1205  SolidityTypeInt.prototype = new SolidityType({});
  1206  SolidityTypeInt.prototype.constructor = SolidityTypeInt;
  1207  
  1208  SolidityTypeInt.prototype.isType = function (name) {
  1209      return !!name.match(/^int([0-9]*)?(\[([0-9]*)\])*$/);
  1210  };
  1211  
  1212  SolidityTypeInt.prototype.staticPartLength = function (name) {
  1213      return 32 * this.staticArrayLength(name);
  1214  };
  1215  
  1216  module.exports = SolidityTypeInt;
  1217  
  1218  },{"./formatters":9,"./type":14}],11:[function(require,module,exports){
  1219  /*
  1220      This file is part of web3.js.
  1221  
  1222      web3.js is free software: you can redistribute it and/or modify
  1223      it under the terms of the GNU Lesser General Public License as published by
  1224      the Free Software Foundation, either version 3 of the License, or
  1225      (at your option) any later version.
  1226  
  1227      web3.js is distributed in the hope that it will be useful,
  1228      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1229      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1230      GNU Lesser General Public License for more details.
  1231  
  1232      You should have received a copy of the GNU Lesser General Public License
  1233      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1234  */
  1235  /**
  1236   * @file param.js
  1237   * @author Marek Kotewicz <marek@ethdev.com>
  1238   * @date 2015
  1239   */
  1240  
  1241  var utils = require('../utils/utils');
  1242  
  1243  /**
  1244   * SolidityParam object prototype.
  1245   * Should be used when encoding, decoding solidity bytes
  1246   */
  1247  var SolidityParam = function (value, offset) {
  1248      this.value = value || '';
  1249      this.offset = offset; // offset in bytes
  1250  };
  1251  
  1252  /**
  1253   * This method should be used to get length of params's dynamic part
  1254   *
  1255   * @method dynamicPartLength
  1256   * @returns {Number} length of dynamic part (in bytes)
  1257   */
  1258  SolidityParam.prototype.dynamicPartLength = function () {
  1259      return this.dynamicPart().length / 2;
  1260  };
  1261  
  1262  /**
  1263   * This method should be used to create copy of solidity param with different offset
  1264   *
  1265   * @method withOffset
  1266   * @param {Number} offset length in bytes
  1267   * @returns {SolidityParam} new solidity param with applied offset
  1268   */
  1269  SolidityParam.prototype.withOffset = function (offset) {
  1270      return new SolidityParam(this.value, offset);
  1271  };
  1272  
  1273  /**
  1274   * This method should be used to combine solidity params together
  1275   * eg. when appending an array
  1276   *
  1277   * @method combine
  1278   * @param {SolidityParam} param with which we should combine
  1279   * @param {SolidityParam} result of combination
  1280   */
  1281  SolidityParam.prototype.combine = function (param) {
  1282      return new SolidityParam(this.value + param.value);
  1283  };
  1284  
  1285  /**
  1286   * This method should be called to check if param has dynamic size.
  1287   * If it has, it returns true, otherwise false
  1288   *
  1289   * @method isDynamic
  1290   * @returns {Boolean}
  1291   */
  1292  SolidityParam.prototype.isDynamic = function () {
  1293      return this.offset !== undefined;
  1294  };
  1295  
  1296  /**
  1297   * This method should be called to transform offset to bytes
  1298   *
  1299   * @method offsetAsBytes
  1300   * @returns {String} bytes representation of offset
  1301   */
  1302  SolidityParam.prototype.offsetAsBytes = function () {
  1303      return !this.isDynamic() ? '' : utils.padLeft(utils.toTwosComplement(this.offset).toString(16), 64);
  1304  };
  1305  
  1306  /**
  1307   * This method should be called to get static part of param
  1308   *
  1309   * @method staticPart
  1310   * @returns {String} offset if it is a dynamic param, otherwise value
  1311   */
  1312  SolidityParam.prototype.staticPart = function () {
  1313      if (!this.isDynamic()) {
  1314          return this.value;
  1315      }
  1316      return this.offsetAsBytes();
  1317  };
  1318  
  1319  /**
  1320   * This method should be called to get dynamic part of param
  1321   *
  1322   * @method dynamicPart
  1323   * @returns {String} returns a value if it is a dynamic param, otherwise empty string
  1324   */
  1325  SolidityParam.prototype.dynamicPart = function () {
  1326      return this.isDynamic() ? this.value : '';
  1327  };
  1328  
  1329  /**
  1330   * This method should be called to encode param
  1331   *
  1332   * @method encode
  1333   * @returns {String}
  1334   */
  1335  SolidityParam.prototype.encode = function () {
  1336      return this.staticPart() + this.dynamicPart();
  1337  };
  1338  
  1339  /**
  1340   * This method should be called to encode array of params
  1341   *
  1342   * @method encodeList
  1343   * @param {Array[SolidityParam]} params
  1344   * @returns {String}
  1345   */
  1346  SolidityParam.encodeList = function (params) {
  1347  
  1348      // updating offsets
  1349      var totalOffset = params.length * 32;
  1350      var offsetParams = params.map(function (param) {
  1351          if (!param.isDynamic()) {
  1352              return param;
  1353          }
  1354          var offset = totalOffset;
  1355          totalOffset += param.dynamicPartLength();
  1356          return param.withOffset(offset);
  1357      });
  1358  
  1359      // encode everything!
  1360      return offsetParams.reduce(function (result, param) {
  1361          return result + param.dynamicPart();
  1362      }, offsetParams.reduce(function (result, param) {
  1363          return result + param.staticPart();
  1364      }, ''));
  1365  };
  1366  
  1367  
  1368  
  1369  module.exports = SolidityParam;
  1370  
  1371  
  1372  },{"../utils/utils":20}],12:[function(require,module,exports){
  1373  var f = require('./formatters');
  1374  var SolidityType = require('./type');
  1375  
  1376  /**
  1377   * SolidityTypeReal is a prootype that represents real type
  1378   * It matches:
  1379   * real
  1380   * real[]
  1381   * real[4]
  1382   * real[][]
  1383   * real[3][]
  1384   * real[][6][], ...
  1385   * real32
  1386   * real64[]
  1387   * real8[4]
  1388   * real256[][]
  1389   * real[3][]
  1390   * real64[][6][], ...
  1391   */
  1392  var SolidityTypeReal = function () {
  1393      this._inputFormatter = f.formatInputReal;
  1394      this._outputFormatter = f.formatOutputReal;
  1395  };
  1396  
  1397  SolidityTypeReal.prototype = new SolidityType({});
  1398  SolidityTypeReal.prototype.constructor = SolidityTypeReal;
  1399  
  1400  SolidityTypeReal.prototype.isType = function (name) {
  1401      return !!name.match(/real([0-9]*)?(\[([0-9]*)\])?/);
  1402  };
  1403  
  1404  SolidityTypeReal.prototype.staticPartLength = function (name) {
  1405      return 32 * this.staticArrayLength(name);
  1406  };
  1407  
  1408  module.exports = SolidityTypeReal;
  1409  
  1410  },{"./formatters":9,"./type":14}],13:[function(require,module,exports){
  1411  var f = require('./formatters');
  1412  var SolidityType = require('./type');
  1413  
  1414  var SolidityTypeString = function () {
  1415      this._inputFormatter = f.formatInputString;
  1416      this._outputFormatter = f.formatOutputString;
  1417  };
  1418  
  1419  SolidityTypeString.prototype = new SolidityType({});
  1420  SolidityTypeString.prototype.constructor = SolidityTypeString;
  1421  
  1422  SolidityTypeString.prototype.isType = function (name) {
  1423      return !!name.match(/^string(\[([0-9]*)\])*$/);
  1424  };
  1425  
  1426  SolidityTypeString.prototype.staticPartLength = function (name) {
  1427      return 32 * this.staticArrayLength(name);
  1428  };
  1429  
  1430  SolidityTypeString.prototype.isDynamicType = function () {
  1431      return true;
  1432  };
  1433  
  1434  module.exports = SolidityTypeString;
  1435  
  1436  
  1437  },{"./formatters":9,"./type":14}],14:[function(require,module,exports){
  1438  var f = require('./formatters');
  1439  var SolidityParam = require('./param');
  1440  
  1441  /**
  1442   * SolidityType prototype is used to encode/decode solidity params of certain type
  1443   */
  1444  var SolidityType = function (config) {
  1445      this._inputFormatter = config.inputFormatter;
  1446      this._outputFormatter = config.outputFormatter;
  1447  };
  1448  
  1449  /**
  1450   * Should be used to determine if this SolidityType do match given name
  1451   *
  1452   * @method isType
  1453   * @param {String} name
  1454   * @return {Bool} true if type match this SolidityType, otherwise false
  1455   */
  1456  SolidityType.prototype.isType = function (name) {
  1457      throw "this method should be overrwritten for type " + name;
  1458  };
  1459  
  1460  /**
  1461   * Should be used to determine what is the length of static part in given type
  1462   *
  1463   * @method staticPartLength
  1464   * @param {String} name
  1465   * @return {Number} length of static part in bytes
  1466   */
  1467  SolidityType.prototype.staticPartLength = function (name) {
  1468      throw "this method should be overrwritten for type: " + name;
  1469  };
  1470  
  1471  /**
  1472   * Should be used to determine if type is dynamic array
  1473   * eg:
  1474   * "type[]" => true
  1475   * "type[4]" => false
  1476   *
  1477   * @method isDynamicArray
  1478   * @param {String} name
  1479   * @return {Bool} true if the type is dynamic array
  1480   */
  1481  SolidityType.prototype.isDynamicArray = function (name) {
  1482      var nestedTypes = this.nestedTypes(name);
  1483      return !!nestedTypes && !nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1484  };
  1485  
  1486  /**
  1487   * Should be used to determine if type is static array
  1488   * eg:
  1489   * "type[]" => false
  1490   * "type[4]" => true
  1491   *
  1492   * @method isStaticArray
  1493   * @param {String} name
  1494   * @return {Bool} true if the type is static array
  1495   */
  1496  SolidityType.prototype.isStaticArray = function (name) {
  1497      var nestedTypes = this.nestedTypes(name);
  1498      return !!nestedTypes && !!nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1499  };
  1500  
  1501  /**
  1502   * Should return length of static array
  1503   * eg.
  1504   * "int[32]" => 32
  1505   * "int256[14]" => 14
  1506   * "int[2][3]" => 3
  1507   * "int" => 1
  1508   * "int[1]" => 1
  1509   * "int[]" => 1
  1510   *
  1511   * @method staticArrayLength
  1512   * @param {String} name
  1513   * @return {Number} static array length
  1514   */
  1515  SolidityType.prototype.staticArrayLength = function (name) {
  1516      var nestedTypes = this.nestedTypes(name);
  1517      if (nestedTypes) {
  1518         return parseInt(nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g) || 1);
  1519      }
  1520      return 1;
  1521  };
  1522  
  1523  /**
  1524   * Should return nested type
  1525   * eg.
  1526   * "int[32]" => "int"
  1527   * "int256[14]" => "int256"
  1528   * "int[2][3]" => "int[2]"
  1529   * "int" => "int"
  1530   * "int[]" => "int"
  1531   *
  1532   * @method nestedName
  1533   * @param {String} name
  1534   * @return {String} nested name
  1535   */
  1536  SolidityType.prototype.nestedName = function (name) {
  1537      // remove last [] in name
  1538      var nestedTypes = this.nestedTypes(name);
  1539      if (!nestedTypes) {
  1540          return name;
  1541      }
  1542  
  1543      return name.substr(0, name.length - nestedTypes[nestedTypes.length - 1].length);
  1544  };
  1545  
  1546  /**
  1547   * Should return true if type has dynamic size by default
  1548   * such types are "string", "bytes"
  1549   *
  1550   * @method isDynamicType
  1551   * @param {String} name
  1552   * @return {Bool} true if is dynamic, otherwise false
  1553   */
  1554  SolidityType.prototype.isDynamicType = function () {
  1555      return false;
  1556  };
  1557  
  1558  /**
  1559   * Should return array of nested types
  1560   * eg.
  1561   * "int[2][3][]" => ["[2]", "[3]", "[]"]
  1562   * "int[] => ["[]"]
  1563   * "int" => null
  1564   *
  1565   * @method nestedTypes
  1566   * @param {String} name
  1567   * @return {Array} array of nested types
  1568   */
  1569  SolidityType.prototype.nestedTypes = function (name) {
  1570      // return list of strings eg. "[]", "[3]", "[]", "[2]"
  1571      return name.match(/(\[[0-9]*\])/g);
  1572  };
  1573  
  1574  /**
  1575   * Should be used to encode the value
  1576   *
  1577   * @method encode
  1578   * @param {Object} value
  1579   * @param {String} name
  1580   * @return {String} encoded value
  1581   */
  1582  SolidityType.prototype.encode = function (value, name) {
  1583      var self = this;
  1584      if (this.isDynamicArray(name)) {
  1585  
  1586          return (function () {
  1587              var length = value.length;                          // in int
  1588              var nestedName = self.nestedName(name);
  1589  
  1590              var result = [];
  1591              result.push(f.formatInputInt(length).encode());
  1592  
  1593              value.forEach(function (v) {
  1594                  result.push(self.encode(v, nestedName));
  1595              });
  1596  
  1597              return result;
  1598          })();
  1599  
  1600      } else if (this.isStaticArray(name)) {
  1601  
  1602          return (function () {
  1603              var length = self.staticArrayLength(name);          // in int
  1604              var nestedName = self.nestedName(name);
  1605  
  1606              var result = [];
  1607              for (var i = 0; i < length; i++) {
  1608                  result.push(self.encode(value[i], nestedName));
  1609              }
  1610  
  1611              return result;
  1612          })();
  1613  
  1614      }
  1615  
  1616      return this._inputFormatter(value, name).encode();
  1617  };
  1618  
  1619  /**
  1620   * Should be used to decode value from bytes
  1621   *
  1622   * @method decode
  1623   * @param {String} bytes
  1624   * @param {Number} offset in bytes
  1625   * @param {String} name type name
  1626   * @returns {Object} decoded value
  1627   */
  1628  SolidityType.prototype.decode = function (bytes, offset, name) {
  1629      var self = this;
  1630  
  1631      if (this.isDynamicArray(name)) {
  1632  
  1633          return (function () {
  1634              var arrayOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
  1635              var length = parseInt('0x' + bytes.substr(arrayOffset * 2, 64)); // in int
  1636              var arrayStart = arrayOffset + 32; // array starts after length; // in bytes
  1637  
  1638              var nestedName = self.nestedName(name);
  1639              var nestedStaticPartLength = self.staticPartLength(nestedName);  // in bytes
  1640              var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1641              var result = [];
  1642  
  1643              for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1644                  result.push(self.decode(bytes, arrayStart + i, nestedName));
  1645              }
  1646  
  1647              return result;
  1648          })();
  1649  
  1650      } else if (this.isStaticArray(name)) {
  1651  
  1652          return (function () {
  1653              var length = self.staticArrayLength(name);                      // in int
  1654              var arrayStart = offset;                                        // in bytes
  1655  
  1656              var nestedName = self.nestedName(name);
  1657              var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
  1658              var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1659              var result = [];
  1660  
  1661              for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1662                  result.push(self.decode(bytes, arrayStart + i, nestedName));
  1663              }
  1664  
  1665              return result;
  1666          })();
  1667      } else if (this.isDynamicType(name)) {
  1668  
  1669          return (function () {
  1670              var dynamicOffset = parseInt('0x' + bytes.substr(offset * 2, 64));      // in bytes
  1671              var length = parseInt('0x' + bytes.substr(dynamicOffset * 2, 64));      // in bytes
  1672              var roundedLength = Math.floor((length + 31) / 32);                     // in int
  1673  
  1674              return self._outputFormatter(new SolidityParam(bytes.substr(dynamicOffset * 2, ( 1 + roundedLength) * 64), 0));
  1675          })();
  1676      }
  1677  
  1678      var length = this.staticPartLength(name);
  1679      return this._outputFormatter(new SolidityParam(bytes.substr(offset * 2, length * 2)));
  1680  };
  1681  
  1682  module.exports = SolidityType;
  1683  
  1684  },{"./formatters":9,"./param":11}],15:[function(require,module,exports){
  1685  var f = require('./formatters');
  1686  var SolidityType = require('./type');
  1687  
  1688  /**
  1689   * SolidityTypeUInt is a prootype that represents uint type
  1690   * It matches:
  1691   * uint
  1692   * uint[]
  1693   * uint[4]
  1694   * uint[][]
  1695   * uint[3][]
  1696   * uint[][6][], ...
  1697   * uint32
  1698   * uint64[]
  1699   * uint8[4]
  1700   * uint256[][]
  1701   * uint[3][]
  1702   * uint64[][6][], ...
  1703   */
  1704  var SolidityTypeUInt = function () {
  1705      this._inputFormatter = f.formatInputInt;
  1706      this._outputFormatter = f.formatOutputUInt;
  1707  };
  1708  
  1709  SolidityTypeUInt.prototype = new SolidityType({});
  1710  SolidityTypeUInt.prototype.constructor = SolidityTypeUInt;
  1711  
  1712  SolidityTypeUInt.prototype.isType = function (name) {
  1713      return !!name.match(/^uint([0-9]*)?(\[([0-9]*)\])*$/);
  1714  };
  1715  
  1716  SolidityTypeUInt.prototype.staticPartLength = function (name) {
  1717      return 32 * this.staticArrayLength(name);
  1718  };
  1719  
  1720  module.exports = SolidityTypeUInt;
  1721  
  1722  },{"./formatters":9,"./type":14}],16:[function(require,module,exports){
  1723  var f = require('./formatters');
  1724  var SolidityType = require('./type');
  1725  
  1726  /**
  1727   * SolidityTypeUReal is a prootype that represents ureal type
  1728   * It matches:
  1729   * ureal
  1730   * ureal[]
  1731   * ureal[4]
  1732   * ureal[][]
  1733   * ureal[3][]
  1734   * ureal[][6][], ...
  1735   * ureal32
  1736   * ureal64[]
  1737   * ureal8[4]
  1738   * ureal256[][]
  1739   * ureal[3][]
  1740   * ureal64[][6][], ...
  1741   */
  1742  var SolidityTypeUReal = function () {
  1743      this._inputFormatter = f.formatInputReal;
  1744      this._outputFormatter = f.formatOutputUReal;
  1745  };
  1746  
  1747  SolidityTypeUReal.prototype = new SolidityType({});
  1748  SolidityTypeUReal.prototype.constructor = SolidityTypeUReal;
  1749  
  1750  SolidityTypeUReal.prototype.isType = function (name) {
  1751      return !!name.match(/^ureal([0-9]*)?(\[([0-9]*)\])*$/);
  1752  };
  1753  
  1754  SolidityTypeUReal.prototype.staticPartLength = function (name) {
  1755      return 32 * this.staticArrayLength(name);
  1756  };
  1757  
  1758  module.exports = SolidityTypeUReal;
  1759  
  1760  },{"./formatters":9,"./type":14}],17:[function(require,module,exports){
  1761  'use strict';
  1762  
  1763  // go env doesn't have and need XMLHttpRequest
  1764  if (typeof XMLHttpRequest === 'undefined') {
  1765      exports.XMLHttpRequest = {};
  1766  } else {
  1767      exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line
  1768  }
  1769  
  1770  
  1771  },{}],18:[function(require,module,exports){
  1772  /*
  1773      This file is part of web3.js.
  1774  
  1775      web3.js is free software: you can redistribute it and/or modify
  1776      it under the terms of the GNU Lesser General Public License as published by
  1777      the Free Software Foundation, either version 3 of the License, or
  1778      (at your option) any later version.
  1779  
  1780      web3.js is distributed in the hope that it will be useful,
  1781      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1782      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1783      GNU Lesser General Public License for more details.
  1784  
  1785      You should have received a copy of the GNU Lesser General Public License
  1786      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1787  */
  1788  /** @file config.js
  1789   * @authors:
  1790   *   Marek Kotewicz <marek@ethdev.com>
  1791   * @date 2015
  1792   */
  1793  
  1794  /**
  1795   * Utils
  1796   *
  1797   * @module utils
  1798   */
  1799  
  1800  /**
  1801   * Utility functions
  1802   *
  1803   * @class [utils] config
  1804   * @constructor
  1805   */
  1806  
  1807  
  1808  /// required to define ETH_BIGNUMBER_ROUNDING_MODE
  1809  var BigNumber = require('bignumber.js');
  1810  
  1811  var ETH_UNITS = [
  1812      'wei',
  1813      'kwei',
  1814      'Mwei',
  1815      'Gwei',
  1816      'szabo',
  1817      'finney',
  1818      'femtoether',
  1819      'picoether',
  1820      'nanoether',
  1821      'microether',
  1822      'milliether',
  1823      'nano',
  1824      'micro',
  1825      'milli',
  1826      'ether',
  1827      'grand',
  1828      'Mether',
  1829      'Gether',
  1830      'Tether',
  1831      'Pether',
  1832      'Eether',
  1833      'Zether',
  1834      'Yether',
  1835      'Nether',
  1836      'Dether',
  1837      'Vether',
  1838      'Uether'
  1839  ];
  1840  
  1841  module.exports = {
  1842      ETH_PADDING: 32,
  1843      ETH_SIGNATURE_LENGTH: 4,
  1844      ETH_UNITS: ETH_UNITS,
  1845      ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
  1846      ETH_POLLING_TIMEOUT: 1000/2,
  1847      defaultBlock: 'latest',
  1848      defaultAccount: undefined
  1849  };
  1850  
  1851  
  1852  },{"bignumber.js":"bignumber.js"}],19:[function(require,module,exports){
  1853  /*
  1854      This file is part of web3.js.
  1855  
  1856      web3.js is free software: you can redistribute it and/or modify
  1857      it under the terms of the GNU Lesser General Public License as published by
  1858      the Free Software Foundation, either version 3 of the License, or
  1859      (at your option) any later version.
  1860  
  1861      web3.js is distributed in the hope that it will be useful,
  1862      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1863      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1864      GNU Lesser General Public License for more details.
  1865  
  1866      You should have received a copy of the GNU Lesser General Public License
  1867      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1868  */
  1869  /**
  1870   * @file sha3.js
  1871   * @author Marek Kotewicz <marek@ethdev.com>
  1872   * @date 2015
  1873   */
  1874  
  1875  var CryptoJS = require('crypto-js');
  1876  var sha3 = require('crypto-js/sha3');
  1877  
  1878  module.exports = function (value, options) {
  1879      if (options && options.encoding === 'hex') {
  1880          if (value.length > 2 && value.substr(0, 2) === '0x') {
  1881              value = value.substr(2);
  1882          }
  1883          value = CryptoJS.enc.Hex.parse(value);
  1884      }
  1885  
  1886      return sha3(value, {
  1887          outputLength: 256
  1888      }).toString();
  1889  };
  1890  
  1891  
  1892  },{"crypto-js":58,"crypto-js/sha3":79}],20:[function(require,module,exports){
  1893  /*
  1894      This file is part of web3.js.
  1895  
  1896      web3.js is free software: you can redistribute it and/or modify
  1897      it under the terms of the GNU Lesser General Public License as published by
  1898      the Free Software Foundation, either version 3 of the License, or
  1899      (at your option) any later version.
  1900  
  1901      web3.js is distributed in the hope that it will be useful,
  1902      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1903      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1904      GNU Lesser General Public License for more details.
  1905  
  1906      You should have received a copy of the GNU Lesser General Public License
  1907      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1908  */
  1909  /**
  1910   * @file utils.js
  1911   * @author Marek Kotewicz <marek@ethdev.com>
  1912   * @date 2015
  1913   */
  1914  
  1915  /**
  1916   * Utils
  1917   *
  1918   * @module utils
  1919   */
  1920  
  1921  /**
  1922   * Utility functions
  1923   *
  1924   * @class [utils] utils
  1925   * @constructor
  1926   */
  1927  
  1928  
  1929  var BigNumber = require('bignumber.js');
  1930  var sha3 = require('./sha3.js');
  1931  var utf8 = require('utf8');
  1932  
  1933  var unitMap = {
  1934      'noether':      '0',
  1935      'wei':          '1',
  1936      'kwei':         '1000',
  1937      'Kwei':         '1000',
  1938      'babbage':      '1000',
  1939      'femtoether':   '1000',
  1940      'mwei':         '1000000',
  1941      'Mwei':         '1000000',
  1942      'lovelace':     '1000000',
  1943      'picoether':    '1000000',
  1944      'gwei':         '1000000000',
  1945      'Gwei':         '1000000000',
  1946      'shannon':      '1000000000',
  1947      'nanoether':    '1000000000',
  1948      'nano':         '1000000000',
  1949      'szabo':        '1000000000000',
  1950      'microether':   '1000000000000',
  1951      'micro':        '1000000000000',
  1952      'finney':       '1000000000000000',
  1953      'milliether':    '1000000000000000',
  1954      'milli':         '1000000000000000',
  1955      'ether':        '1000000000000000000',
  1956      'kether':       '1000000000000000000000',
  1957      'grand':        '1000000000000000000000',
  1958      'mether':       '1000000000000000000000000',
  1959      'gether':       '1000000000000000000000000000',
  1960      'tether':       '1000000000000000000000000000000'
  1961  };
  1962  
  1963  /**
  1964   * Should be called to pad string to expected length
  1965   *
  1966   * @method padLeft
  1967   * @param {String} string to be padded
  1968   * @param {Number} characters that result string should have
  1969   * @param {String} sign, by default 0
  1970   * @returns {String} right aligned string
  1971   */
  1972  var padLeft = function (string, chars, sign) {
  1973      return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
  1974  };
  1975  
  1976  /**
  1977   * Should be called to pad string to expected length
  1978   *
  1979   * @method padRight
  1980   * @param {String} string to be padded
  1981   * @param {Number} characters that result string should have
  1982   * @param {String} sign, by default 0
  1983   * @returns {String} right aligned string
  1984   */
  1985  var padRight = function (string, chars, sign) {
  1986      return string + (new Array(chars - string.length + 1).join(sign ? sign : "0"));
  1987  };
  1988  
  1989  /**
  1990   * Should be called to get utf8 from its hex representation
  1991   *
  1992   * @method toUtf8
  1993   * @param {String} string in hex
  1994   * @returns {String} ascii string representation of hex value
  1995   */
  1996  var toUtf8 = function(hex) {
  1997  // Find termination
  1998      var str = "";
  1999      var i = 0, l = hex.length;
  2000      if (hex.substring(0, 2) === '0x') {
  2001          i = 2;
  2002      }
  2003      for (; i < l; i+=2) {
  2004          var code = parseInt(hex.substr(i, 2), 16);
  2005          if (code === 0)
  2006              break;
  2007          str += String.fromCharCode(code);
  2008      }
  2009  
  2010      return utf8.decode(str);
  2011  };
  2012  
  2013  /**
  2014   * Should be called to get ascii from its hex representation
  2015   *
  2016   * @method toAscii
  2017   * @param {String} string in hex
  2018   * @returns {String} ascii string representation of hex value
  2019   */
  2020  var toAscii = function(hex) {
  2021  // Find termination
  2022      var str = "";
  2023      var i = 0, l = hex.length;
  2024      if (hex.substring(0, 2) === '0x') {
  2025          i = 2;
  2026      }
  2027      for (; i < l; i+=2) {
  2028          var code = parseInt(hex.substr(i, 2), 16);
  2029          str += String.fromCharCode(code);
  2030      }
  2031  
  2032      return str;
  2033  };
  2034  
  2035  /**
  2036   * Should be called to get hex representation (prefixed by 0x) of utf8 string
  2037   *
  2038   * @method fromUtf8
  2039   * @param {String} string
  2040   * @param {Number} optional padding
  2041   * @returns {String} hex representation of input string
  2042   */
  2043  var fromUtf8 = function(str) {
  2044      str = utf8.encode(str);
  2045      var hex = "";
  2046      for(var i = 0; i < str.length; i++) {
  2047          var code = str.charCodeAt(i);
  2048          if (code === 0)
  2049              break;
  2050          var n = code.toString(16);
  2051          hex += n.length < 2 ? '0' + n : n;
  2052      }
  2053  
  2054      return "0x" + hex;
  2055  };
  2056  
  2057  /**
  2058   * Should be called to get hex representation (prefixed by 0x) of ascii string
  2059   *
  2060   * @method fromAscii
  2061   * @param {String} string
  2062   * @param {Number} optional padding
  2063   * @returns {String} hex representation of input string
  2064   */
  2065  var fromAscii = function(str) {
  2066      var hex = "";
  2067      for(var i = 0; i < str.length; i++) {
  2068          var code = str.charCodeAt(i);
  2069          var n = code.toString(16);
  2070          hex += n.length < 2 ? '0' + n : n;
  2071      }
  2072  
  2073      return "0x" + hex;
  2074  };
  2075  
  2076  /**
  2077   * Should be used to create full function/event name from json abi
  2078   *
  2079   * @method transformToFullName
  2080   * @param {Object} json-abi
  2081   * @return {String} full fnction/event name
  2082   */
  2083  var transformToFullName = function (json) {
  2084      if (json.name.indexOf('(') !== -1) {
  2085          return json.name;
  2086      }
  2087  
  2088      var typeName = json.inputs.map(function(i){return i.type; }).join();
  2089      return json.name + '(' + typeName + ')';
  2090  };
  2091  
  2092  /**
  2093   * Should be called to get display name of contract function
  2094   *
  2095   * @method extractDisplayName
  2096   * @param {String} name of function/event
  2097   * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
  2098   */
  2099  var extractDisplayName = function (name) {
  2100      var length = name.indexOf('(');
  2101      return length !== -1 ? name.substr(0, length) : name;
  2102  };
  2103  
  2104  /// @returns overloaded part of function/event name
  2105  var extractTypeName = function (name) {
  2106      /// TODO: make it invulnerable
  2107      var length = name.indexOf('(');
  2108      return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
  2109  };
  2110  
  2111  /**
  2112   * Converts value to its decimal representation in string
  2113   *
  2114   * @method toDecimal
  2115   * @param {String|Number|BigNumber}
  2116   * @return {String}
  2117   */
  2118  var toDecimal = function (value) {
  2119      return toBigNumber(value).toNumber();
  2120  };
  2121  
  2122  /**
  2123   * Converts value to its hex representation
  2124   *
  2125   * @method fromDecimal
  2126   * @param {String|Number|BigNumber}
  2127   * @return {String}
  2128   */
  2129  var fromDecimal = function (value) {
  2130      var number = toBigNumber(value);
  2131      var result = number.toString(16);
  2132  
  2133      return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
  2134  };
  2135  
  2136  /**
  2137   * Auto converts any given value into its hex representation.
  2138   *
  2139   * And even stringifys objects before.
  2140   *
  2141   * @method toHex
  2142   * @param {String|Number|BigNumber|Object}
  2143   * @return {String}
  2144   */
  2145  var toHex = function (val) {
  2146      /*jshint maxcomplexity: 8 */
  2147  
  2148      if (isBoolean(val))
  2149          return fromDecimal(+val);
  2150  
  2151      if (isBigNumber(val))
  2152          return fromDecimal(val);
  2153  
  2154      if (isObject(val))
  2155          return fromUtf8(JSON.stringify(val));
  2156  
  2157      // if its a negative number, pass it through fromDecimal
  2158      if (isString(val)) {
  2159          if (val.indexOf('-0x') === 0)
  2160              return fromDecimal(val);
  2161          else if(val.indexOf('0x') === 0)
  2162              return val;
  2163          else if (!isFinite(val))
  2164              return fromAscii(val);
  2165      }
  2166  
  2167      return fromDecimal(val);
  2168  };
  2169  
  2170  /**
  2171   * Returns value of unit in Wei
  2172   *
  2173   * @method getValueOfUnit
  2174   * @param {String} unit the unit to convert to, default ether
  2175   * @returns {BigNumber} value of the unit (in Wei)
  2176   * @throws error if the unit is not correct:w
  2177   */
  2178  var getValueOfUnit = function (unit) {
  2179      unit = unit ? unit.toLowerCase() : 'ether';
  2180      var unitValue = unitMap[unit];
  2181      if (unitValue === undefined) {
  2182          throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
  2183      }
  2184      return new BigNumber(unitValue, 10);
  2185  };
  2186  
  2187  /**
  2188   * Takes a number of wei and converts it to any other ether unit.
  2189   *
  2190   * Possible units are:
  2191   *   SI Short   SI Full        Effigy       Other
  2192   * - kwei       femtoether     babbage
  2193   * - mwei       picoether      lovelace
  2194   * - gwei       nanoether      shannon      nano
  2195   * - --         microether     szabo        micro
  2196   * - --         milliether     finney       milli
  2197   * - ether      --             --
  2198   * - kether                    --           grand
  2199   * - mether
  2200   * - gether
  2201   * - tether
  2202   *
  2203   * @method fromWei
  2204   * @param {Number|String} number can be a number, number string or a HEX of a decimal
  2205   * @param {String} unit the unit to convert to, default ether
  2206   * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2207  */
  2208  var fromWei = function(number, unit) {
  2209      var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
  2210  
  2211      return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2212  };
  2213  
  2214  /**
  2215   * Takes a number of a unit and converts it to wei.
  2216   *
  2217   * Possible units are:
  2218   *   SI Short   SI Full        Effigy       Other
  2219   * - kwei       femtoether     babbage
  2220   * - mwei       picoether      lovelace
  2221   * - gwei       nanoether      shannon      nano
  2222   * - --         microether     szabo        micro
  2223   * - --         microether     szabo        micro
  2224   * - --         milliether     finney       milli
  2225   * - ether      --             --
  2226   * - kether                    --           grand
  2227   * - mether
  2228   * - gether
  2229   * - tether
  2230   *
  2231   * @method toWei
  2232   * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
  2233   * @param {String} unit the unit to convert from, default ether
  2234   * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2235  */
  2236  var toWei = function(number, unit) {
  2237      var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
  2238  
  2239      return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2240  };
  2241  
  2242  /**
  2243   * Takes an input and transforms it into an bignumber
  2244   *
  2245   * @method toBigNumber
  2246   * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
  2247   * @return {BigNumber} BigNumber
  2248  */
  2249  var toBigNumber = function(number) {
  2250      /*jshint maxcomplexity:5 */
  2251      number = number || 0;
  2252      if (isBigNumber(number))
  2253          return number;
  2254  
  2255      if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
  2256          return new BigNumber(number.replace('0x',''), 16);
  2257      }
  2258  
  2259      return new BigNumber(number.toString(10), 10);
  2260  };
  2261  
  2262  /**
  2263   * Takes and input transforms it into bignumber and if it is negative value, into two's complement
  2264   *
  2265   * @method toTwosComplement
  2266   * @param {Number|String|BigNumber}
  2267   * @return {BigNumber}
  2268   */
  2269  var toTwosComplement = function (number) {
  2270      var bigNumber = toBigNumber(number);
  2271      if (bigNumber.lessThan(0)) {
  2272          return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
  2273      }
  2274      return bigNumber;
  2275  };
  2276  
  2277  /**
  2278   * Checks if the given string is strictly an address
  2279   *
  2280   * @method isStrictAddress
  2281   * @param {String} address the given HEX adress
  2282   * @return {Boolean}
  2283  */
  2284  var isStrictAddress = function (address) {
  2285      return /^0x[0-9a-f]{40}$/i.test(address);
  2286  };
  2287  
  2288  /**
  2289   * Checks if the given string is an address
  2290   *
  2291   * @method isAddress
  2292   * @param {String} address the given HEX adress
  2293   * @return {Boolean}
  2294  */
  2295  var isAddress = function (address) {
  2296      if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
  2297          // check if it has the basic requirements of an address
  2298          return false;
  2299      } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
  2300          // If it's all small caps or all all caps, return true
  2301          return true;
  2302      } else {
  2303          // Otherwise check each case
  2304          return isChecksumAddress(address);
  2305      }
  2306  };
  2307  
  2308  
  2309  
  2310  /**
  2311   * Checks if the given string is a checksummed address
  2312   *
  2313   * @method isChecksumAddress
  2314   * @param {String} address the given HEX adress
  2315   * @return {Boolean}
  2316  */
  2317  var isChecksumAddress = function (address) {
  2318      // Check each case
  2319      address = address.replace('0x','');
  2320      var addressHash = sha3(address.toLowerCase());
  2321  
  2322      for (var i = 0; i < 40; i++ ) {
  2323          // the nth letter should be uppercase if the nth digit of casemap is 1
  2324          if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
  2325              return false;
  2326          }
  2327      }
  2328      return true;
  2329  };
  2330  
  2331  
  2332  
  2333  /**
  2334   * Makes a checksum address
  2335   *
  2336   * @method toChecksumAddress
  2337   * @param {String} address the given HEX adress
  2338   * @return {String}
  2339  */
  2340  var toChecksumAddress = function (address) {
  2341      if (typeof address === 'undefined') return '';
  2342  
  2343      address = address.toLowerCase().replace('0x','');
  2344      var addressHash = sha3(address);
  2345      var checksumAddress = '0x';
  2346  
  2347      for (var i = 0; i < address.length; i++ ) {
  2348          // If ith character is 9 to f then make it uppercase
  2349          if (parseInt(addressHash[i], 16) > 7) {
  2350            checksumAddress += address[i].toUpperCase();
  2351          } else {
  2352              checksumAddress += address[i];
  2353          }
  2354      }
  2355      return checksumAddress;
  2356  };
  2357  
  2358  /**
  2359   * Transforms given string to valid 20 bytes-length addres with 0x prefix
  2360   *
  2361   * @method toAddress
  2362   * @param {String} address
  2363   * @return {String} formatted address
  2364   */
  2365  var toAddress = function (address) {
  2366      if (isStrictAddress(address)) {
  2367          return address;
  2368      }
  2369  
  2370      if (/^[0-9a-f]{40}$/.test(address)) {
  2371          return '0x' + address;
  2372      }
  2373  
  2374      return '0x' + padLeft(toHex(address).substr(2), 40);
  2375  };
  2376  
  2377  /**
  2378   * Returns true if object is BigNumber, otherwise false
  2379   *
  2380   * @method isBigNumber
  2381   * @param {Object}
  2382   * @return {Boolean}
  2383   */
  2384  var isBigNumber = function (object) {
  2385      return object instanceof BigNumber ||
  2386          (object && object.constructor && object.constructor.name === 'BigNumber');
  2387  };
  2388  
  2389  /**
  2390   * Returns true if object is string, otherwise false
  2391   *
  2392   * @method isString
  2393   * @param {Object}
  2394   * @return {Boolean}
  2395   */
  2396  var isString = function (object) {
  2397      return typeof object === 'string' ||
  2398          (object && object.constructor && object.constructor.name === 'String');
  2399  };
  2400  
  2401  /**
  2402   * Returns true if object is function, otherwise false
  2403   *
  2404   * @method isFunction
  2405   * @param {Object}
  2406   * @return {Boolean}
  2407   */
  2408  var isFunction = function (object) {
  2409      return typeof object === 'function';
  2410  };
  2411  
  2412  /**
  2413   * Returns true if object is Objet, otherwise false
  2414   *
  2415   * @method isObject
  2416   * @param {Object}
  2417   * @return {Boolean}
  2418   */
  2419  var isObject = function (object) {
  2420      return typeof object === 'object';
  2421  };
  2422  
  2423  /**
  2424   * Returns true if object is boolean, otherwise false
  2425   *
  2426   * @method isBoolean
  2427   * @param {Object}
  2428   * @return {Boolean}
  2429   */
  2430  var isBoolean = function (object) {
  2431      return typeof object === 'boolean';
  2432  };
  2433  
  2434  /**
  2435   * Returns true if object is array, otherwise false
  2436   *
  2437   * @method isArray
  2438   * @param {Object}
  2439   * @return {Boolean}
  2440   */
  2441  var isArray = function (object) {
  2442      return object instanceof Array;
  2443  };
  2444  
  2445  /**
  2446   * Returns true if given string is valid json object
  2447   *
  2448   * @method isJson
  2449   * @param {String}
  2450   * @return {Boolean}
  2451   */
  2452  var isJson = function (str) {
  2453      try {
  2454          return !!JSON.parse(str);
  2455      } catch (e) {
  2456          return false;
  2457      }
  2458  };
  2459  
  2460  module.exports = {
  2461      padLeft: padLeft,
  2462      padRight: padRight,
  2463      toHex: toHex,
  2464      toDecimal: toDecimal,
  2465      fromDecimal: fromDecimal,
  2466      toUtf8: toUtf8,
  2467      toAscii: toAscii,
  2468      fromUtf8: fromUtf8,
  2469      fromAscii: fromAscii,
  2470      transformToFullName: transformToFullName,
  2471      extractDisplayName: extractDisplayName,
  2472      extractTypeName: extractTypeName,
  2473      toWei: toWei,
  2474      fromWei: fromWei,
  2475      toBigNumber: toBigNumber,
  2476      toTwosComplement: toTwosComplement,
  2477      toAddress: toAddress,
  2478      isBigNumber: isBigNumber,
  2479      isStrictAddress: isStrictAddress,
  2480      isAddress: isAddress,
  2481      isChecksumAddress: isChecksumAddress,
  2482      toChecksumAddress: toChecksumAddress,
  2483      isFunction: isFunction,
  2484      isString: isString,
  2485      isObject: isObject,
  2486      isBoolean: isBoolean,
  2487      isArray: isArray,
  2488      isJson: isJson
  2489  };
  2490  
  2491  },{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":84}],21:[function(require,module,exports){
  2492  module.exports={
  2493      "version": "0.15.3"
  2494  }
  2495  
  2496  },{}],22:[function(require,module,exports){
  2497  /*
  2498      This file is part of web3.js.
  2499  
  2500      web3.js is free software: you can redistribute it and/or modify
  2501      it under the terms of the GNU Lesser General Public License as published by
  2502      the Free Software Foundation, either version 3 of the License, or
  2503      (at your option) any later version.
  2504  
  2505      web3.js is distributed in the hope that it will be useful,
  2506      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2507      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2508      GNU Lesser General Public License for more details.
  2509  
  2510      You should have received a copy of the GNU Lesser General Public License
  2511      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2512  */
  2513  /**
  2514   * @file web3.js
  2515   * @authors:
  2516   *   Jeffrey Wilcke <jeff@ethdev.com>
  2517   *   Marek Kotewicz <marek@ethdev.com>
  2518   *   Marian Oancea <marian@ethdev.com>
  2519   *   Fabian Vogelsteller <fabian@ethdev.com>
  2520   *   Gav Wood <g@ethdev.com>
  2521   * @date 2014
  2522   */
  2523  
  2524  var RequestManager = require('./web3/requestmanager');
  2525  var Iban = require('./web3/iban');
  2526  var Eth = require('./web3/methods/eth');
  2527  var DB = require('./web3/methods/db');
  2528  var Shh = require('./web3/methods/shh');
  2529  var Net = require('./web3/methods/net');
  2530  var Personal = require('./web3/methods/personal');
  2531  var Settings = require('./web3/settings');
  2532  var version = require('./version.json');
  2533  var utils = require('./utils/utils');
  2534  var sha3 = require('./utils/sha3');
  2535  var extend = require('./web3/extend');
  2536  var Batch = require('./web3/batch');
  2537  var Property = require('./web3/property');
  2538  var HttpProvider = require('./web3/httpprovider');
  2539  var IpcProvider = require('./web3/ipcprovider');
  2540  
  2541  
  2542  
  2543  function Web3 (provider) {
  2544      this._requestManager = new RequestManager(provider);
  2545      this.currentProvider = provider;
  2546      this.eth = new Eth(this);
  2547      this.db = new DB(this);
  2548      this.shh = new Shh(this);
  2549      this.net = new Net(this);
  2550      this.personal = new Personal(this);
  2551      this.settings = new Settings();
  2552      this.version = {
  2553          api: version.version
  2554      };
  2555      this.providers = {
  2556          HttpProvider: HttpProvider,
  2557          IpcProvider: IpcProvider
  2558      };
  2559      this._extend = extend(this);
  2560      this._extend({
  2561          properties: properties()
  2562      });
  2563  }
  2564  
  2565  // expose providers on the class
  2566  Web3.providers = {
  2567      HttpProvider: HttpProvider,
  2568      IpcProvider: IpcProvider
  2569  };
  2570  
  2571  Web3.prototype.setProvider = function (provider) {
  2572      this._requestManager.setProvider(provider);
  2573      this.currentProvider = provider;
  2574  };
  2575  
  2576  Web3.prototype.reset = function (keepIsSyncing) {
  2577      this._requestManager.reset(keepIsSyncing);
  2578      this.settings = new Settings();
  2579  };
  2580  
  2581  Web3.prototype.toHex = utils.toHex;
  2582  Web3.prototype.toAscii = utils.toAscii;
  2583  Web3.prototype.toUtf8 = utils.toUtf8;
  2584  Web3.prototype.fromAscii = utils.fromAscii;
  2585  Web3.prototype.fromUtf8 = utils.fromUtf8;
  2586  Web3.prototype.toDecimal = utils.toDecimal;
  2587  Web3.prototype.fromDecimal = utils.fromDecimal;
  2588  Web3.prototype.toBigNumber = utils.toBigNumber;
  2589  Web3.prototype.toWei = utils.toWei;
  2590  Web3.prototype.fromWei = utils.fromWei;
  2591  Web3.prototype.isAddress = utils.isAddress;
  2592  Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
  2593  Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
  2594  Web3.prototype.isIBAN = utils.isIBAN;
  2595  
  2596  
  2597  Web3.prototype.sha3 = function(string, options) {
  2598      return '0x' + sha3(string, options);
  2599  };
  2600  
  2601  /**
  2602   * Transforms direct icap to address
  2603   */
  2604  Web3.prototype.fromICAP = function (icap) {
  2605      var iban = new Iban(icap);
  2606      return iban.address();
  2607  };
  2608  
  2609  var properties = function () {
  2610      return [
  2611          new Property({
  2612              name: 'version.node',
  2613              getter: 'web3_clientVersion'
  2614          }),
  2615          new Property({
  2616              name: 'version.network',
  2617              getter: 'net_version',
  2618              inputFormatter: utils.toDecimal
  2619          }),
  2620          new Property({
  2621              name: 'version.ethereum',
  2622              getter: 'eth_protocolVersion',
  2623              inputFormatter: utils.toDecimal
  2624          }),
  2625          new Property({
  2626              name: 'version.whisper',
  2627              getter: 'shh_version',
  2628              inputFormatter: utils.toDecimal
  2629          })
  2630      ];
  2631  };
  2632  
  2633  Web3.prototype.isConnected = function(){
  2634      return (this.currentProvider && this.currentProvider.isConnected());
  2635  };
  2636  
  2637  Web3.prototype.createBatch = function () {
  2638      return new Batch(this);
  2639  };
  2640  
  2641  module.exports = Web3;
  2642  
  2643  
  2644  },{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/eth":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/methods/shh":41,"./web3/property":44,"./web3/requestmanager":45,"./web3/settings":46}],23:[function(require,module,exports){
  2645  /*
  2646      This file is part of web3.js.
  2647  
  2648      web3.js is free software: you can redistribute it and/or modify
  2649      it under the terms of the GNU Lesser General Public License as published by
  2650      the Free Software Foundation, either version 3 of the License, or
  2651      (at your option) any later version.
  2652  
  2653      web3.js is distributed in the hope that it will be useful,
  2654      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2655      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2656      GNU Lesser General Public License for more details.
  2657  
  2658      You should have received a copy of the GNU Lesser General Public License
  2659      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2660  */
  2661  /**
  2662   * @file allevents.js
  2663   * @author Marek Kotewicz <marek@ethdev.com>
  2664   * @date 2014
  2665   */
  2666  
  2667  var sha3 = require('../utils/sha3');
  2668  var SolidityEvent = require('./event');
  2669  var formatters = require('./formatters');
  2670  var utils = require('../utils/utils');
  2671  var Filter = require('./filter');
  2672  var watches = require('./methods/watches');
  2673  
  2674  var AllSolidityEvents = function (requestManager, json, address) {
  2675      this._requestManager = requestManager;
  2676      this._json = json;
  2677      this._address = address;
  2678  };
  2679  
  2680  AllSolidityEvents.prototype.encode = function (options) {
  2681      options = options || {};
  2682      var result = {};
  2683  
  2684      ['fromBlock', 'toBlock'].filter(function (f) {
  2685          return options[f] !== undefined;
  2686      }).forEach(function (f) {
  2687          result[f] = formatters.inputBlockNumberFormatter(options[f]);
  2688      });
  2689  
  2690      result.address = this._address;
  2691  
  2692      return result;
  2693  };
  2694  
  2695  AllSolidityEvents.prototype.decode = function (data) {
  2696      data.data = data.data || '';
  2697      data.topics = data.topics || [];
  2698  
  2699      var eventTopic = data.topics[0].slice(2);
  2700      var match = this._json.filter(function (j) {
  2701          return eventTopic === sha3(utils.transformToFullName(j));
  2702      })[0];
  2703  
  2704      if (!match) { // cannot find matching event?
  2705          console.warn('cannot find event for log');
  2706          return data;
  2707      }
  2708  
  2709      var event = new SolidityEvent(this._requestManager, match, this._address);
  2710      return event.decode(data);
  2711  };
  2712  
  2713  AllSolidityEvents.prototype.execute = function (options, callback) {
  2714  
  2715      if (utils.isFunction(arguments[arguments.length - 1])) {
  2716          callback = arguments[arguments.length - 1];
  2717          if(arguments.length === 1)
  2718              options = null;
  2719      }
  2720  
  2721      var o = this.encode(options);
  2722      var formatter = this.decode.bind(this);
  2723      return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
  2724  };
  2725  
  2726  AllSolidityEvents.prototype.attachToContract = function (contract) {
  2727      var execute = this.execute.bind(this);
  2728      contract.allEvents = execute;
  2729  };
  2730  
  2731  module.exports = AllSolidityEvents;
  2732  
  2733  
  2734  },{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":42}],24:[function(require,module,exports){
  2735  /*
  2736      This file is part of web3.js.
  2737  
  2738      web3.js is free software: you can redistribute it and/or modify
  2739      it under the terms of the GNU Lesser General Public License as published by
  2740      the Free Software Foundation, either version 3 of the License, or
  2741      (at your option) any later version.
  2742  
  2743      web3.js is distributed in the hope that it will be useful,
  2744      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2745      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2746      GNU Lesser General Public License for more details.
  2747  
  2748      You should have received a copy of the GNU Lesser General Public License
  2749      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2750  */
  2751  /**
  2752   * @file batch.js
  2753   * @author Marek Kotewicz <marek@ethdev.com>
  2754   * @date 2015
  2755   */
  2756  
  2757  var Jsonrpc = require('./jsonrpc');
  2758  var errors = require('./errors');
  2759  
  2760  var Batch = function (web3) {
  2761      this.requestManager = web3._requestManager;
  2762      this.requests = [];
  2763  };
  2764  
  2765  /**
  2766   * Should be called to add create new request to batch request
  2767   *
  2768   * @method add
  2769   * @param {Object} jsonrpc requet object
  2770   */
  2771  Batch.prototype.add = function (request) {
  2772      this.requests.push(request);
  2773  };
  2774  
  2775  /**
  2776   * Should be called to execute batch request
  2777   *
  2778   * @method execute
  2779   */
  2780  Batch.prototype.execute = function () {
  2781      var requests = this.requests;
  2782      this.requestManager.sendBatch(requests, function (err, results) {
  2783          results = results || [];
  2784          requests.map(function (request, index) {
  2785              return results[index] || {};
  2786          }).forEach(function (result, index) {
  2787              if (requests[index].callback) {
  2788  
  2789                  if (!Jsonrpc.getInstance().isValidResponse(result)) {
  2790                      return requests[index].callback(errors.InvalidResponse(result));
  2791                  }
  2792  
  2793                  requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));
  2794              }
  2795          });
  2796      });
  2797  };
  2798  
  2799  module.exports = Batch;
  2800  
  2801  
  2802  },{"./errors":26,"./jsonrpc":35}],25:[function(require,module,exports){
  2803  /*
  2804      This file is part of web3.js.
  2805  
  2806      web3.js is free software: you can redistribute it and/or modify
  2807      it under the terms of the GNU Lesser General Public License as published by
  2808      the Free Software Foundation, either version 3 of the License, or
  2809      (at your option) any later version.
  2810  
  2811      web3.js is distributed in the hope that it will be useful,
  2812      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2813      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2814      GNU Lesser General Public License for more details.
  2815  
  2816      You should have received a copy of the GNU Lesser General Public License
  2817      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2818  */
  2819  /**
  2820   * @file contract.js
  2821   * @author Marek Kotewicz <marek@ethdev.com>
  2822   * @date 2014
  2823   */
  2824  
  2825  var utils = require('../utils/utils');
  2826  var coder = require('../solidity/coder');
  2827  var SolidityEvent = require('./event');
  2828  var SolidityFunction = require('./function');
  2829  var AllEvents = require('./allevents');
  2830  
  2831  /**
  2832   * Should be called to encode constructor params
  2833   *
  2834   * @method encodeConstructorParams
  2835   * @param {Array} abi
  2836   * @param {Array} constructor params
  2837   */
  2838  var encodeConstructorParams = function (abi, params) {
  2839      return abi.filter(function (json) {
  2840          return json.type === 'constructor' && json.inputs.length === params.length;
  2841      }).map(function (json) {
  2842          return json.inputs.map(function (input) {
  2843              return input.type;
  2844          });
  2845      }).map(function (types) {
  2846          return coder.encodeParams(types, params);
  2847      })[0] || '';
  2848  };
  2849  
  2850  /**
  2851   * Should be called to add functions to contract object
  2852   *
  2853   * @method addFunctionsToContract
  2854   * @param {Contract} contract
  2855   * @param {Array} abi
  2856   */
  2857  var addFunctionsToContract = function (contract) {
  2858      contract.abi.filter(function (json) {
  2859          return json.type === 'function';
  2860      }).map(function (json) {
  2861          return new SolidityFunction(contract._eth, json, contract.address);
  2862      }).forEach(function (f) {
  2863          f.attachToContract(contract);
  2864      });
  2865  };
  2866  
  2867  /**
  2868   * Should be called to add events to contract object
  2869   *
  2870   * @method addEventsToContract
  2871   * @param {Contract} contract
  2872   * @param {Array} abi
  2873   */
  2874  var addEventsToContract = function (contract) {
  2875      var events = contract.abi.filter(function (json) {
  2876          return json.type === 'event';
  2877      });
  2878  
  2879      var All = new AllEvents(contract._eth._requestManager, events, contract.address);
  2880      All.attachToContract(contract);
  2881  
  2882      events.map(function (json) {
  2883          return new SolidityEvent(contract._eth._requestManager, json, contract.address);
  2884      }).forEach(function (e) {
  2885          e.attachToContract(contract);
  2886      });
  2887  };
  2888  
  2889  
  2890  /**
  2891   * Should be called to check if the contract gets properly deployed on the blockchain.
  2892   *
  2893   * @method checkForContractAddress
  2894   * @param {Object} contract
  2895   * @param {Function} callback
  2896   * @returns {Undefined}
  2897   */
  2898  var checkForContractAddress = function(contract, callback){
  2899      var count = 0,
  2900          callbackFired = false;
  2901  
  2902      // wait for receipt
  2903      var filter = contract._eth.filter('latest', function(e){
  2904          if (!e && !callbackFired) {
  2905              count++;
  2906  
  2907              // stop watching after 50 blocks (timeout)
  2908              if (count > 50) {
  2909  
  2910                  filter.stopWatching();
  2911                  callbackFired = true;
  2912  
  2913                  if (callback)
  2914                      callback(new Error('Contract transaction couldn\'t be found after 50 blocks'));
  2915                  else
  2916                      throw new Error('Contract transaction couldn\'t be found after 50 blocks');
  2917  
  2918  
  2919              } else {
  2920  
  2921                  contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
  2922                      if(receipt && !callbackFired) {
  2923  
  2924                          contract._eth.getCode(receipt.contractAddress, function(e, code){
  2925                              /*jshint maxcomplexity: 6 */
  2926  
  2927                              if(callbackFired || !code)
  2928                                  return;
  2929  
  2930                              filter.stopWatching();
  2931                              callbackFired = true;
  2932  
  2933                              if(code.length > 2) {
  2934  
  2935                                  // console.log('Contract code deployed!');
  2936  
  2937                                  contract.address = receipt.contractAddress;
  2938  
  2939                                  // attach events and methods again after we have
  2940                                  addFunctionsToContract(contract);
  2941                                  addEventsToContract(contract);
  2942  
  2943                                  // call callback for the second time
  2944                                  if(callback)
  2945                                      callback(null, contract);
  2946  
  2947                              } else {
  2948                                  if(callback)
  2949                                      callback(new Error('The contract code couldn\'t be stored, please check your gas amount.'));
  2950                                  else
  2951                                      throw new Error('The contract code couldn\'t be stored, please check your gas amount.');
  2952                              }
  2953                          });
  2954                      }
  2955                  });
  2956              }
  2957          }
  2958      });
  2959  };
  2960  
  2961  /**
  2962   * Should be called to create new ContractFactory instance
  2963   *
  2964   * @method ContractFactory
  2965   * @param {Array} abi
  2966   */
  2967  var ContractFactory = function (eth, abi) {
  2968      this.eth = eth;
  2969      this.abi = abi;
  2970  
  2971      /**
  2972       * Should be called to create new contract on a blockchain
  2973       *
  2974       * @method new
  2975       * @param {Any} contract constructor param1 (optional)
  2976       * @param {Any} contract constructor param2 (optional)
  2977       * @param {Object} contract transaction object (required)
  2978       * @param {Function} callback
  2979       * @returns {Contract} returns contract instance
  2980       */
  2981      this.new = function () {
  2982          var contract = new Contract(this.eth, this.abi);
  2983  
  2984          // parse arguments
  2985          var options = {}; // required!
  2986          var callback;
  2987  
  2988          var args = Array.prototype.slice.call(arguments);
  2989          if (utils.isFunction(args[args.length - 1])) {
  2990              callback = args.pop();
  2991          }
  2992  
  2993          var last = args[args.length - 1];
  2994          if (utils.isObject(last) && !utils.isArray(last)) {
  2995              options = args.pop();
  2996          }
  2997  
  2998          var bytes = encodeConstructorParams(this.abi, args);
  2999          options.data += bytes;
  3000  
  3001          if (callback) {
  3002  
  3003              // wait for the contract address adn check if the code was deployed
  3004              this.eth.sendTransaction(options, function (err, hash) {
  3005                  if (err) {
  3006                      callback(err);
  3007                  } else {
  3008                      // add the transaction hash
  3009                      contract.transactionHash = hash;
  3010  
  3011                      // call callback for the first time
  3012                      callback(null, contract);
  3013  
  3014                      checkForContractAddress(contract, callback);
  3015                  }
  3016              });
  3017          } else {
  3018              var hash = this.eth.sendTransaction(options);
  3019              // add the transaction hash
  3020              contract.transactionHash = hash;
  3021              checkForContractAddress(contract);
  3022          }
  3023  
  3024          return contract;
  3025      };
  3026  
  3027      this.new.getData = this.getData.bind(this);
  3028  };
  3029  
  3030  /**
  3031   * Should be called to create new ContractFactory
  3032   *
  3033   * @method contract
  3034   * @param {Array} abi
  3035   * @returns {ContractFactory} new contract factory
  3036   */
  3037  //var contract = function (abi) {
  3038      //return new ContractFactory(abi);
  3039  //};
  3040  
  3041  
  3042  
  3043  /**
  3044   * Should be called to get access to existing contract on a blockchain
  3045   *
  3046   * @method at
  3047   * @param {Address} contract address (required)
  3048   * @param {Function} callback {optional)
  3049   * @returns {Contract} returns contract if no callback was passed,
  3050   * otherwise calls callback function (err, contract)
  3051   */
  3052  ContractFactory.prototype.at = function (address, callback) {
  3053      var contract = new Contract(this.eth, this.abi, address);
  3054  
  3055      // this functions are not part of prototype,
  3056      // because we dont want to spoil the interface
  3057      addFunctionsToContract(contract);
  3058      addEventsToContract(contract);
  3059  
  3060      if (callback) {
  3061          callback(null, contract);
  3062      }
  3063      return contract;
  3064  };
  3065  
  3066  /**
  3067   * Gets the data, which is data to deploy plus constructor params
  3068   *
  3069   * @method getData
  3070   */
  3071  ContractFactory.prototype.getData = function () {
  3072      var options = {}; // required!
  3073      var args = Array.prototype.slice.call(arguments);
  3074  
  3075      var last = args[args.length - 1];
  3076      if (utils.isObject(last) && !utils.isArray(last)) {
  3077          options = args.pop();
  3078      }
  3079  
  3080      var bytes = encodeConstructorParams(this.abi, args);
  3081      options.data += bytes;
  3082  
  3083      return options.data;
  3084  };
  3085  
  3086  /**
  3087   * Should be called to create new contract instance
  3088   *
  3089   * @method Contract
  3090   * @param {Array} abi
  3091   * @param {Address} contract address
  3092   */
  3093  var Contract = function (eth, abi, address) {
  3094      this._eth = eth;
  3095      this.transactionHash = null;
  3096      this.address = address;
  3097      this.abi = abi;
  3098  };
  3099  
  3100  module.exports = ContractFactory;
  3101  
  3102  },{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(require,module,exports){
  3103  /*
  3104      This file is part of web3.js.
  3105  
  3106      web3.js is free software: you can redistribute it and/or modify
  3107      it under the terms of the GNU Lesser General Public License as published by
  3108      the Free Software Foundation, either version 3 of the License, or
  3109      (at your option) any later version.
  3110  
  3111      web3.js is distributed in the hope that it will be useful,
  3112      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3113      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3114      GNU Lesser General Public License for more details.
  3115  
  3116      You should have received a copy of the GNU Lesser General Public License
  3117      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3118  */
  3119  /**
  3120   * @file errors.js
  3121   * @author Marek Kotewicz <marek@ethdev.com>
  3122   * @date 2015
  3123   */
  3124  
  3125  module.exports = {
  3126      InvalidNumberOfParams: function () {
  3127          return new Error('Invalid number of input parameters');
  3128      },
  3129      InvalidConnection: function (host){
  3130          return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
  3131      },
  3132      InvalidProvider: function () {
  3133          return new Error('Provider not set or invalid');
  3134      },
  3135      InvalidResponse: function (result){
  3136          var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);
  3137          return new Error(message);
  3138      }
  3139  };
  3140  
  3141  
  3142  },{}],27:[function(require,module,exports){
  3143  /*
  3144      This file is part of web3.js.
  3145  
  3146      web3.js is free software: you can redistribute it and/or modify
  3147      it under the terms of the GNU Lesser General Public License as published by
  3148      the Free Software Foundation, either version 3 of the License, or
  3149      (at your option) any later version.
  3150  
  3151      web3.js is distributed in the hope that it will be useful,
  3152      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3153      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3154      GNU Lesser General Public License for more details.
  3155  
  3156      You should have received a copy of the GNU Lesser General Public License
  3157      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3158  */
  3159  /**
  3160   * @file event.js
  3161   * @author Marek Kotewicz <marek@ethdev.com>
  3162   * @date 2014
  3163   */
  3164  
  3165  var utils = require('../utils/utils');
  3166  var coder = require('../solidity/coder');
  3167  var formatters = require('./formatters');
  3168  var sha3 = require('../utils/sha3');
  3169  var Filter = require('./filter');
  3170  var watches = require('./methods/watches');
  3171  
  3172  /**
  3173   * This prototype should be used to create event filters
  3174   */
  3175  var SolidityEvent = function (requestManager, json, address) {
  3176      this._requestManager = requestManager;
  3177      this._params = json.inputs;
  3178      this._name = utils.transformToFullName(json);
  3179      this._address = address;
  3180      this._anonymous = json.anonymous;
  3181  };
  3182  
  3183  /**
  3184   * Should be used to get filtered param types
  3185   *
  3186   * @method types
  3187   * @param {Bool} decide if returned typed should be indexed
  3188   * @return {Array} array of types
  3189   */
  3190  SolidityEvent.prototype.types = function (indexed) {
  3191      return this._params.filter(function (i) {
  3192          return i.indexed === indexed;
  3193      }).map(function (i) {
  3194          return i.type;
  3195      });
  3196  };
  3197  
  3198  /**
  3199   * Should be used to get event display name
  3200   *
  3201   * @method displayName
  3202   * @return {String} event display name
  3203   */
  3204  SolidityEvent.prototype.displayName = function () {
  3205      return utils.extractDisplayName(this._name);
  3206  };
  3207  
  3208  /**
  3209   * Should be used to get event type name
  3210   *
  3211   * @method typeName
  3212   * @return {String} event type name
  3213   */
  3214  SolidityEvent.prototype.typeName = function () {
  3215      return utils.extractTypeName(this._name);
  3216  };
  3217  
  3218  /**
  3219   * Should be used to get event signature
  3220   *
  3221   * @method signature
  3222   * @return {String} event signature
  3223   */
  3224  SolidityEvent.prototype.signature = function () {
  3225      return sha3(this._name);
  3226  };
  3227  
  3228  /**
  3229   * Should be used to encode indexed params and options to one final object
  3230   *
  3231   * @method encode
  3232   * @param {Object} indexed
  3233   * @param {Object} options
  3234   * @return {Object} everything combined together and encoded
  3235   */
  3236  SolidityEvent.prototype.encode = function (indexed, options) {
  3237      indexed = indexed || {};
  3238      options = options || {};
  3239      var result = {};
  3240  
  3241      ['fromBlock', 'toBlock'].filter(function (f) {
  3242          return options[f] !== undefined;
  3243      }).forEach(function (f) {
  3244          result[f] = formatters.inputBlockNumberFormatter(options[f]);
  3245      });
  3246  
  3247      result.topics = [];
  3248  
  3249      result.address = this._address;
  3250      if (!this._anonymous) {
  3251          result.topics.push('0x' + this.signature());
  3252      }
  3253  
  3254      var indexedTopics = this._params.filter(function (i) {
  3255          return i.indexed === true;
  3256      }).map(function (i) {
  3257          var value = indexed[i.name];
  3258          if (value === undefined || value === null) {
  3259              return null;
  3260          }
  3261  
  3262          if (utils.isArray(value)) {
  3263              return value.map(function (v) {
  3264                  return '0x' + coder.encodeParam(i.type, v);
  3265              });
  3266          }
  3267          return '0x' + coder.encodeParam(i.type, value);
  3268      });
  3269  
  3270      result.topics = result.topics.concat(indexedTopics);
  3271  
  3272      return result;
  3273  };
  3274  
  3275  /**
  3276   * Should be used to decode indexed params and options
  3277   *
  3278   * @method decode
  3279   * @param {Object} data
  3280   * @return {Object} result object with decoded indexed && not indexed params
  3281   */
  3282  SolidityEvent.prototype.decode = function (data) {
  3283  
  3284      data.data = data.data || '';
  3285      data.topics = data.topics || [];
  3286  
  3287      var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
  3288      var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
  3289      var indexedParams = coder.decodeParams(this.types(true), indexedData);
  3290  
  3291      var notIndexedData = data.data.slice(2);
  3292      var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
  3293  
  3294      var result = formatters.outputLogFormatter(data);
  3295      result.event = this.displayName();
  3296      result.address = data.address;
  3297  
  3298      result.args = this._params.reduce(function (acc, current) {
  3299          acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();
  3300          return acc;
  3301      }, {});
  3302  
  3303      delete result.data;
  3304      delete result.topics;
  3305  
  3306      return result;
  3307  };
  3308  
  3309  /**
  3310   * Should be used to create new filter object from event
  3311   *
  3312   * @method execute
  3313   * @param {Object} indexed
  3314   * @param {Object} options
  3315   * @return {Object} filter object
  3316   */
  3317  SolidityEvent.prototype.execute = function (indexed, options, callback) {
  3318  
  3319      if (utils.isFunction(arguments[arguments.length - 1])) {
  3320          callback = arguments[arguments.length - 1];
  3321          if(arguments.length === 2)
  3322              options = null;
  3323          if(arguments.length === 1) {
  3324              options = null;
  3325              indexed = {};
  3326          }
  3327      }
  3328  
  3329      var o = this.encode(indexed, options);
  3330      var formatter = this.decode.bind(this);
  3331      return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
  3332  };
  3333  
  3334  /**
  3335   * Should be used to attach event to contract object
  3336   *
  3337   * @method attachToContract
  3338   * @param {Contract}
  3339   */
  3340  SolidityEvent.prototype.attachToContract = function (contract) {
  3341      var execute = this.execute.bind(this);
  3342      var displayName = this.displayName();
  3343      if (!contract[displayName]) {
  3344          contract[displayName] = execute;
  3345      }
  3346      contract[displayName][this.typeName()] = this.execute.bind(this, contract);
  3347  };
  3348  
  3349  module.exports = SolidityEvent;
  3350  
  3351  
  3352  },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":42}],28:[function(require,module,exports){
  3353  var formatters = require('./formatters');
  3354  var utils = require('./../utils/utils');
  3355  var Method = require('./method');
  3356  var Property = require('./property');
  3357  
  3358  // TODO: refactor, so the input params are not altered.
  3359  // it's necessary to make same 'extension' work with multiple providers
  3360  var extend = function (web3) {
  3361      /* jshint maxcomplexity:5 */
  3362      var ex = function (extension) {
  3363  
  3364          var extendedObject;
  3365          if (extension.property) {
  3366              if (!web3[extension.property]) {
  3367                  web3[extension.property] = {};
  3368              }
  3369              extendedObject = web3[extension.property];
  3370          } else {
  3371              extendedObject = web3;
  3372          }
  3373  
  3374          if (extension.methods) {
  3375              extension.methods.forEach(function (method) {
  3376                  method.attachToObject(extendedObject);
  3377                  method.setRequestManager(web3._requestManager);
  3378              });
  3379          }
  3380  
  3381          if (extension.properties) {
  3382              extension.properties.forEach(function (property) {
  3383                  property.attachToObject(extendedObject);
  3384                  property.setRequestManager(web3._requestManager);
  3385              });
  3386          }
  3387      };
  3388  
  3389      ex.formatters = formatters;
  3390      ex.utils = utils;
  3391      ex.Method = Method;
  3392      ex.Property = Property;
  3393  
  3394      return ex;
  3395  };
  3396  
  3397  
  3398  
  3399  module.exports = extend;
  3400  
  3401  
  3402  },{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":44}],29:[function(require,module,exports){
  3403  /*
  3404      This file is part of web3.js.
  3405  
  3406      web3.js is free software: you can redistribute it and/or modify
  3407      it under the terms of the GNU Lesser General Public License as published by
  3408      the Free Software Foundation, either version 3 of the License, or
  3409      (at your option) any later version.
  3410  
  3411      web3.js is distributed in the hope that it will be useful,
  3412      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3413      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3414      GNU Lesser General Public License for more details.
  3415  
  3416      You should have received a copy of the GNU Lesser General Public License
  3417      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3418  */
  3419  /** @file filter.js
  3420   * @authors:
  3421   *   Jeffrey Wilcke <jeff@ethdev.com>
  3422   *   Marek Kotewicz <marek@ethdev.com>
  3423   *   Marian Oancea <marian@ethdev.com>
  3424   *   Fabian Vogelsteller <fabian@ethdev.com>
  3425   *   Gav Wood <g@ethdev.com>
  3426   * @date 2014
  3427   */
  3428  
  3429  var formatters = require('./formatters');
  3430  var utils = require('../utils/utils');
  3431  
  3432  /**
  3433  * Converts a given topic to a hex string, but also allows null values.
  3434  *
  3435  * @param {Mixed} value
  3436  * @return {String}
  3437  */
  3438  var toTopic = function(value){
  3439  
  3440      if(value === null || typeof value === 'undefined')
  3441          return null;
  3442  
  3443      value = String(value);
  3444  
  3445      if(value.indexOf('0x') === 0)
  3446          return value;
  3447      else
  3448          return utils.fromUtf8(value);
  3449  };
  3450  
  3451  /// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
  3452  /// @param should be string or object
  3453  /// @returns options string or object
  3454  var getOptions = function (options) {
  3455  
  3456      if (utils.isString(options)) {
  3457          return options;
  3458      }
  3459  
  3460      options = options || {};
  3461  
  3462      // make sure topics, get converted to hex
  3463      options.topics = options.topics || [];
  3464      options.topics = options.topics.map(function(topic){
  3465          return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
  3466      });
  3467  
  3468      return {
  3469          topics: options.topics,
  3470          from: options.from,
  3471          to: options.to,
  3472          address: options.address,
  3473          fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
  3474          toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
  3475      };
  3476  };
  3477  
  3478  /**
  3479  Adds the callback and sets up the methods, to iterate over the results.
  3480  
  3481  @method getLogsAtStart
  3482  @param {Object} self
  3483  @param {funciton}
  3484  */
  3485  var getLogsAtStart = function(self, callback){
  3486      // call getFilterLogs for the first watch callback start
  3487      if (!utils.isString(self.options)) {
  3488          self.get(function (err, messages) {
  3489              // don't send all the responses to all the watches again... just to self one
  3490              if (err) {
  3491                  callback(err);
  3492              }
  3493  
  3494              if(utils.isArray(messages)) {
  3495                  messages.forEach(function (message) {
  3496                      callback(null, message);
  3497                  });
  3498              }
  3499          });
  3500      }
  3501  };
  3502  
  3503  /**
  3504  Adds the callback and sets up the methods, to iterate over the results.
  3505  
  3506  @method pollFilter
  3507  @param {Object} self
  3508  */
  3509  var pollFilter = function(self) {
  3510  
  3511      var onMessage = function (error, messages) {
  3512          if (error) {
  3513              return self.callbacks.forEach(function (callback) {
  3514                  callback(error);
  3515              });
  3516          }
  3517  
  3518          if(utils.isArray(messages)) {
  3519              messages.forEach(function (message) {
  3520                  message = self.formatter ? self.formatter(message) : message;
  3521                  self.callbacks.forEach(function (callback) {
  3522                      callback(null, message);
  3523                  });
  3524              });
  3525          }
  3526      };
  3527  
  3528      self.requestManager.startPolling({
  3529          method: self.implementation.poll.call,
  3530          params: [self.filterId],
  3531      }, self.filterId, onMessage, self.stopWatching.bind(self));
  3532  
  3533  };
  3534  
  3535  var Filter = function (requestManager, options, methods, formatter, callback) {
  3536      var self = this;
  3537      var implementation = {};
  3538      methods.forEach(function (method) {
  3539          method.setRequestManager(requestManager);
  3540          method.attachToObject(implementation);
  3541      });
  3542      this.requestManager = requestManager;
  3543      this.options = getOptions(options);
  3544      this.implementation = implementation;
  3545      this.filterId = null;
  3546      this.callbacks = [];
  3547      this.getLogsCallbacks = [];
  3548      this.pollFilters = [];
  3549      this.formatter = formatter;
  3550      this.implementation.newFilter(this.options, function(error, id){
  3551          if(error) {
  3552              self.callbacks.forEach(function(cb){
  3553                  cb(error);
  3554              });
  3555          } else {
  3556              self.filterId = id;
  3557  
  3558              // check if there are get pending callbacks as a consequence
  3559              // of calling get() with filterId unassigned.
  3560              self.getLogsCallbacks.forEach(function (cb){
  3561                  self.get(cb);
  3562              });
  3563              self.getLogsCallbacks = [];
  3564  
  3565              // get filter logs for the already existing watch calls
  3566              self.callbacks.forEach(function(cb){
  3567                  getLogsAtStart(self, cb);
  3568              });
  3569              if(self.callbacks.length > 0)
  3570                  pollFilter(self);
  3571  
  3572              // start to watch immediately
  3573              if(typeof callback === 'function') {
  3574                  return self.watch(callback);
  3575              }
  3576          }
  3577      });
  3578  
  3579      return this;
  3580  };
  3581  
  3582  Filter.prototype.watch = function (callback) {
  3583      this.callbacks.push(callback);
  3584  
  3585      if(this.filterId) {
  3586          getLogsAtStart(this, callback);
  3587          pollFilter(this);
  3588      }
  3589  
  3590      return this;
  3591  };
  3592  
  3593  Filter.prototype.stopWatching = function () {
  3594      this.requestManager.stopPolling(this.filterId);
  3595      // remove filter async
  3596      this.implementation.uninstallFilter(this.filterId, function(){});
  3597      this.callbacks = [];
  3598  };
  3599  
  3600  Filter.prototype.get = function (callback) {
  3601      var self = this;
  3602      if (utils.isFunction(callback)) {
  3603          if (this.filterId === null) {
  3604              // If filterId is not set yet, call it back
  3605              // when newFilter() assigns it.
  3606              this.getLogsCallbacks.push(callback);
  3607          } else {
  3608              this.implementation.getLogs(this.filterId, function(err, res){
  3609                  if (err) {
  3610                      callback(err);
  3611                  } else {
  3612                      callback(null, res.map(function (log) {
  3613                          return self.formatter ? self.formatter(log) : log;
  3614                      }));
  3615                  }
  3616              });
  3617          }
  3618      } else {
  3619          if (this.filterId === null) {
  3620              throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.');
  3621          }
  3622          var logs = this.implementation.getLogs(this.filterId);
  3623          return logs.map(function (log) {
  3624              return self.formatter ? self.formatter(log) : log;
  3625          });
  3626      }
  3627  
  3628      return this;
  3629  };
  3630  
  3631  module.exports = Filter;
  3632  
  3633  
  3634  },{"../utils/utils":20,"./formatters":30}],30:[function(require,module,exports){
  3635  /*
  3636      This file is part of web3.js.
  3637  
  3638      web3.js is free software: you can redistribute it and/or modify
  3639      it under the terms of the GNU Lesser General Public License as published by
  3640      the Free Software Foundation, either version 3 of the License, or
  3641      (at your option) any later version.
  3642  
  3643      web3.js is distributed in the hope that it will be useful,
  3644      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3645      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3646      GNU Lesser General Public License for more details.
  3647  
  3648      You should have received a copy of the GNU Lesser General Public License
  3649      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3650  */
  3651  /**
  3652   * @file formatters.js
  3653   * @author Marek Kotewicz <marek@ethdev.com>
  3654   * @author Fabian Vogelsteller <fabian@ethdev.com>
  3655   * @date 2015
  3656   */
  3657  
  3658  var utils = require('../utils/utils');
  3659  var config = require('../utils/config');
  3660  var Iban = require('./iban');
  3661  
  3662  /**
  3663   * Should the format output to a big number
  3664   *
  3665   * @method outputBigNumberFormatter
  3666   * @param {String|Number|BigNumber}
  3667   * @returns {BigNumber} object
  3668   */
  3669  var outputBigNumberFormatter = function (number) {
  3670      return utils.toBigNumber(number);
  3671  };
  3672  
  3673  var isPredefinedBlockNumber = function (blockNumber) {
  3674      return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
  3675  };
  3676  
  3677  var inputDefaultBlockNumberFormatter = function (blockNumber) {
  3678      if (blockNumber === undefined) {
  3679          return config.defaultBlock;
  3680      }
  3681      return inputBlockNumberFormatter(blockNumber);
  3682  };
  3683  
  3684  var inputBlockNumberFormatter = function (blockNumber) {
  3685      if (blockNumber === undefined) {
  3686          return undefined;
  3687      } else if (isPredefinedBlockNumber(blockNumber)) {
  3688          return blockNumber;
  3689      }
  3690      return utils.toHex(blockNumber);
  3691  };
  3692  
  3693  /**
  3694   * Formats the input of a transaction and converts all values to HEX
  3695   *
  3696   * @method inputCallFormatter
  3697   * @param {Object} transaction options
  3698   * @returns object
  3699  */
  3700  var inputCallFormatter = function (options){
  3701  
  3702      options.from = options.from || config.defaultAccount;
  3703  
  3704      if (options.from) {
  3705          options.from = inputAddressFormatter(options.from);
  3706      }
  3707  
  3708      if (options.to) { // it might be contract creation
  3709          options.to = inputAddressFormatter(options.to);
  3710      }
  3711  
  3712      ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3713          return options[key] !== undefined;
  3714      }).forEach(function(key){
  3715          options[key] = utils.fromDecimal(options[key]);
  3716      });
  3717  
  3718      return options;
  3719  };
  3720  
  3721  /**
  3722   * Formats the input of a transaction and converts all values to HEX
  3723   *
  3724   * @method inputTransactionFormatter
  3725   * @param {Object} transaction options
  3726   * @returns object
  3727  */
  3728  var inputTransactionFormatter = function (options){
  3729  
  3730      options.from = options.from || config.defaultAccount;
  3731      options.from = inputAddressFormatter(options.from);
  3732  
  3733      if (options.to) { // it might be contract creation
  3734          options.to = inputAddressFormatter(options.to);
  3735      }
  3736  
  3737      ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3738          return options[key] !== undefined;
  3739      }).forEach(function(key){
  3740          options[key] = utils.fromDecimal(options[key]);
  3741      });
  3742  
  3743      return options;
  3744  };
  3745  
  3746  /**
  3747   * Formats the output of a transaction to its proper values
  3748   *
  3749   * @method outputTransactionFormatter
  3750   * @param {Object} tx
  3751   * @returns {Object}
  3752  */
  3753  var outputTransactionFormatter = function (tx){
  3754      if(tx.blockNumber !== null)
  3755          tx.blockNumber = utils.toDecimal(tx.blockNumber);
  3756      if(tx.transactionIndex !== null)
  3757          tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
  3758      tx.nonce = utils.toDecimal(tx.nonce);
  3759      tx.gas = utils.toDecimal(tx.gas);
  3760      tx.gasPrice = utils.toBigNumber(tx.gasPrice);
  3761      tx.value = utils.toBigNumber(tx.value);
  3762      return tx;
  3763  };
  3764  
  3765  /**
  3766   * Formats the output of a transaction receipt to its proper values
  3767   *
  3768   * @method outputTransactionReceiptFormatter
  3769   * @param {Object} receipt
  3770   * @returns {Object}
  3771  */
  3772  var outputTransactionReceiptFormatter = function (receipt){
  3773      if(receipt.blockNumber !== null)
  3774          receipt.blockNumber = utils.toDecimal(receipt.blockNumber);
  3775      if(receipt.transactionIndex !== null)
  3776          receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
  3777      receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
  3778      receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
  3779  
  3780      if(utils.isArray(receipt.logs)) {
  3781          receipt.logs = receipt.logs.map(function(log){
  3782              return outputLogFormatter(log);
  3783          });
  3784      }
  3785  
  3786      return receipt;
  3787  };
  3788  
  3789  /**
  3790   * Formats the output of a block to its proper values
  3791   *
  3792   * @method outputBlockFormatter
  3793   * @param {Object} block
  3794   * @returns {Object}
  3795  */
  3796  var outputBlockFormatter = function(block) {
  3797  
  3798      // transform to number
  3799      block.gasLimit = utils.toDecimal(block.gasLimit);
  3800      block.gasUsed = utils.toDecimal(block.gasUsed);
  3801      block.size = utils.toDecimal(block.size);
  3802      block.timestamp = utils.toDecimal(block.timestamp);
  3803      if(block.number !== null)
  3804          block.number = utils.toDecimal(block.number);
  3805  
  3806      block.difficulty = utils.toBigNumber(block.difficulty);
  3807      block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
  3808  
  3809      if (utils.isArray(block.transactions)) {
  3810          block.transactions.forEach(function(item){
  3811              if(!utils.isString(item))
  3812                  return outputTransactionFormatter(item);
  3813          });
  3814      }
  3815  
  3816      return block;
  3817  };
  3818  
  3819  /**
  3820   * Formats the output of a log
  3821   *
  3822   * @method outputLogFormatter
  3823   * @param {Object} log object
  3824   * @returns {Object} log
  3825  */
  3826  var outputLogFormatter = function(log) {
  3827      if(log.blockNumber !== null)
  3828          log.blockNumber = utils.toDecimal(log.blockNumber);
  3829      if(log.transactionIndex !== null)
  3830          log.transactionIndex = utils.toDecimal(log.transactionIndex);
  3831      if(log.logIndex !== null)
  3832          log.logIndex = utils.toDecimal(log.logIndex);
  3833  
  3834      return log;
  3835  };
  3836  
  3837  /**
  3838   * Formats the input of a whisper post and converts all values to HEX
  3839   *
  3840   * @method inputPostFormatter
  3841   * @param {Object} transaction object
  3842   * @returns {Object}
  3843  */
  3844  var inputPostFormatter = function(post) {
  3845  
  3846      // post.payload = utils.toHex(post.payload);
  3847      post.ttl = utils.fromDecimal(post.ttl);
  3848      post.workToProve = utils.fromDecimal(post.workToProve);
  3849      post.priority = utils.fromDecimal(post.priority);
  3850  
  3851      // fallback
  3852      if (!utils.isArray(post.topics)) {
  3853          post.topics = post.topics ? [post.topics] : [];
  3854      }
  3855  
  3856      // format the following options
  3857      post.topics = post.topics.map(function(topic){
  3858          // convert only if not hex
  3859          return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);
  3860      });
  3861  
  3862      return post;
  3863  };
  3864  
  3865  /**
  3866   * Formats the output of a received post message
  3867   *
  3868   * @method outputPostFormatter
  3869   * @param {Object}
  3870   * @returns {Object}
  3871   */
  3872  var outputPostFormatter = function(post){
  3873  
  3874      post.expiry = utils.toDecimal(post.expiry);
  3875      post.sent = utils.toDecimal(post.sent);
  3876      post.ttl = utils.toDecimal(post.ttl);
  3877      post.workProved = utils.toDecimal(post.workProved);
  3878      // post.payloadRaw = post.payload;
  3879      // post.payload = utils.toAscii(post.payload);
  3880  
  3881      // if (utils.isJson(post.payload)) {
  3882      //     post.payload = JSON.parse(post.payload);
  3883      // }
  3884  
  3885      // format the following options
  3886      if (!post.topics) {
  3887          post.topics = [];
  3888      }
  3889      post.topics = post.topics.map(function(topic){
  3890          return utils.toAscii(topic);
  3891      });
  3892  
  3893      return post;
  3894  };
  3895  
  3896  var inputAddressFormatter = function (address) {
  3897      var iban = new Iban(address);
  3898      if (iban.isValid() && iban.isDirect()) {
  3899          return '0x' + iban.address();
  3900      } else if (utils.isStrictAddress(address)) {
  3901          return address;
  3902      } else if (utils.isAddress(address)) {
  3903          return '0x' + address;
  3904      }
  3905      throw new Error('invalid address');
  3906  };
  3907  
  3908  
  3909  var outputSyncingFormatter = function(result) {
  3910  
  3911      result.startingBlock = utils.toDecimal(result.startingBlock);
  3912      result.currentBlock = utils.toDecimal(result.currentBlock);
  3913      result.highestBlock = utils.toDecimal(result.highestBlock);
  3914      if (result.knownStates !== undefined) {
  3915        result.knownStates = utils.toDecimal(result.knownStates);
  3916      }
  3917      if (result.pulledStates !== undefined) {
  3918        result.pulledStates = utils.toDecimal(result.pulledStates);
  3919      }
  3920      return result;
  3921  };
  3922  
  3923  module.exports = {
  3924      inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
  3925      inputBlockNumberFormatter: inputBlockNumberFormatter,
  3926      inputCallFormatter: inputCallFormatter,
  3927      inputTransactionFormatter: inputTransactionFormatter,
  3928      inputAddressFormatter: inputAddressFormatter,
  3929      inputPostFormatter: inputPostFormatter,
  3930      outputBigNumberFormatter: outputBigNumberFormatter,
  3931      outputTransactionFormatter: outputTransactionFormatter,
  3932      outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
  3933      outputBlockFormatter: outputBlockFormatter,
  3934      outputLogFormatter: outputLogFormatter,
  3935      outputPostFormatter: outputPostFormatter,
  3936      outputSyncingFormatter: outputSyncingFormatter
  3937  };
  3938  
  3939  
  3940  },{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(require,module,exports){
  3941  /*
  3942      This file is part of web3.js.
  3943  
  3944      web3.js is free software: you can redistribute it and/or modify
  3945      it under the terms of the GNU Lesser General Public License as published by
  3946      the Free Software Foundation, either version 3 of the License, or
  3947      (at your option) any later version.
  3948  
  3949      web3.js is distributed in the hope that it will be useful,
  3950      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3951      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3952      GNU Lesser General Public License for more details.
  3953  
  3954      You should have received a copy of the GNU Lesser General Public License
  3955      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3956  */
  3957  /**
  3958   * @file function.js
  3959   * @author Marek Kotewicz <marek@ethdev.com>
  3960   * @date 2015
  3961   */
  3962  
  3963  var coder = require('../solidity/coder');
  3964  var utils = require('../utils/utils');
  3965  var formatters = require('./formatters');
  3966  var sha3 = require('../utils/sha3');
  3967  
  3968  /**
  3969   * This prototype should be used to call/sendTransaction to solidity functions
  3970   */
  3971  var SolidityFunction = function (eth, json, address) {
  3972      this._eth = eth;
  3973      this._inputTypes = json.inputs.map(function (i) {
  3974          return i.type;
  3975      });
  3976      this._outputTypes = json.outputs.map(function (i) {
  3977          return i.type;
  3978      });
  3979      this._constant = json.constant;
  3980      this._name = utils.transformToFullName(json);
  3981      this._address = address;
  3982  };
  3983  
  3984  SolidityFunction.prototype.extractCallback = function (args) {
  3985      if (utils.isFunction(args[args.length - 1])) {
  3986          return args.pop(); // modify the args array!
  3987      }
  3988  };
  3989  
  3990  SolidityFunction.prototype.extractDefaultBlock = function (args) {
  3991      if (args.length > this._inputTypes.length && !utils.isObject(args[args.length -1])) {
  3992          return formatters.inputDefaultBlockNumberFormatter(args.pop()); // modify the args array!
  3993      }
  3994  };
  3995  
  3996  /**
  3997   * Should be used to create payload from arguments
  3998   *
  3999   * @method toPayload
  4000   * @param {Array} solidity function params
  4001   * @param {Object} optional payload options
  4002   */
  4003  SolidityFunction.prototype.toPayload = function (args) {
  4004      var options = {};
  4005      if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
  4006          options = args[args.length - 1];
  4007      }
  4008      options.to = this._address;
  4009      options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
  4010      return options;
  4011  };
  4012  
  4013  /**
  4014   * Should be used to get function signature
  4015   *
  4016   * @method signature
  4017   * @return {String} function signature
  4018   */
  4019  SolidityFunction.prototype.signature = function () {
  4020      return sha3(this._name).slice(0, 8);
  4021  };
  4022  
  4023  
  4024  SolidityFunction.prototype.unpackOutput = function (output) {
  4025      if (!output) {
  4026          return;
  4027      }
  4028  
  4029      output = output.length >= 2 ? output.slice(2) : output;
  4030      var result = coder.decodeParams(this._outputTypes, output);
  4031      return result.length === 1 ? result[0] : result;
  4032  };
  4033  
  4034  /**
  4035   * Calls a contract function.
  4036   *
  4037   * @method call
  4038   * @param {...Object} Contract function arguments
  4039   * @param {function} If the last argument is a function, the contract function
  4040   *   call will be asynchronous, and the callback will be passed the
  4041   *   error and result.
  4042   * @return {String} output bytes
  4043   */
  4044  SolidityFunction.prototype.call = function () {
  4045      var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4046      var callback = this.extractCallback(args);
  4047      var defaultBlock = this.extractDefaultBlock(args);
  4048      var payload = this.toPayload(args);
  4049  
  4050  
  4051      if (!callback) {
  4052          var output = this._eth.call(payload, defaultBlock);
  4053          return this.unpackOutput(output);
  4054      }
  4055  
  4056      var self = this;
  4057      this._eth.call(payload, defaultBlock, function (error, output) {
  4058          callback(error, self.unpackOutput(output));
  4059      });
  4060  };
  4061  
  4062  /**
  4063   * Should be used to sendTransaction to solidity function
  4064   *
  4065   * @method sendTransaction
  4066   */
  4067  SolidityFunction.prototype.sendTransaction = function () {
  4068      var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4069      var callback = this.extractCallback(args);
  4070      var payload = this.toPayload(args);
  4071  
  4072      if (!callback) {
  4073          return this._eth.sendTransaction(payload);
  4074      }
  4075  
  4076      this._eth.sendTransaction(payload, callback);
  4077  };
  4078  
  4079  /**
  4080   * Should be used to estimateGas of solidity function
  4081   *
  4082   * @method estimateGas
  4083   */
  4084  SolidityFunction.prototype.estimateGas = function () {
  4085      var args = Array.prototype.slice.call(arguments);
  4086      var callback = this.extractCallback(args);
  4087      var payload = this.toPayload(args);
  4088  
  4089      if (!callback) {
  4090          return this._eth.estimateGas(payload);
  4091      }
  4092  
  4093      this._eth.estimateGas(payload, callback);
  4094  };
  4095  
  4096  /**
  4097   * Return the encoded data of the call
  4098   *
  4099   * @method getData
  4100   * @return {String} the encoded data
  4101   */
  4102  SolidityFunction.prototype.getData = function () {
  4103      var args = Array.prototype.slice.call(arguments);
  4104      var payload = this.toPayload(args);
  4105  
  4106      return payload.data;
  4107  };
  4108  
  4109  /**
  4110   * Should be used to get function display name
  4111   *
  4112   * @method displayName
  4113   * @return {String} display name of the function
  4114   */
  4115  SolidityFunction.prototype.displayName = function () {
  4116      return utils.extractDisplayName(this._name);
  4117  };
  4118  
  4119  /**
  4120   * Should be used to get function type name
  4121   *
  4122   * @method typeName
  4123   * @return {String} type name of the function
  4124   */
  4125  SolidityFunction.prototype.typeName = function () {
  4126      return utils.extractTypeName(this._name);
  4127  };
  4128  
  4129  /**
  4130   * Should be called to get rpc requests from solidity function
  4131   *
  4132   * @method request
  4133   * @returns {Object}
  4134   */
  4135  SolidityFunction.prototype.request = function () {
  4136      var args = Array.prototype.slice.call(arguments);
  4137      var callback = this.extractCallback(args);
  4138      var payload = this.toPayload(args);
  4139      var format = this.unpackOutput.bind(this);
  4140  
  4141      return {
  4142          method: this._constant ? 'eth_call' : 'eth_sendTransaction',
  4143          callback: callback,
  4144          params: [payload],
  4145          format: format
  4146      };
  4147  };
  4148  
  4149  /**
  4150   * Should be called to execute function
  4151   *
  4152   * @method execute
  4153   */
  4154  SolidityFunction.prototype.execute = function () {
  4155      var transaction = !this._constant;
  4156  
  4157      // send transaction
  4158      if (transaction) {
  4159          return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
  4160      }
  4161  
  4162      // call
  4163      return this.call.apply(this, Array.prototype.slice.call(arguments));
  4164  };
  4165  
  4166  /**
  4167   * Should be called to attach function to contract
  4168   *
  4169   * @method attachToContract
  4170   * @param {Contract}
  4171   */
  4172  SolidityFunction.prototype.attachToContract = function (contract) {
  4173      var execute = this.execute.bind(this);
  4174      execute.request = this.request.bind(this);
  4175      execute.call = this.call.bind(this);
  4176      execute.sendTransaction = this.sendTransaction.bind(this);
  4177      execute.estimateGas = this.estimateGas.bind(this);
  4178      execute.getData = this.getData.bind(this);
  4179      var displayName = this.displayName();
  4180      if (!contract[displayName]) {
  4181          contract[displayName] = execute;
  4182      }
  4183      contract[displayName][this.typeName()] = execute; // circular!!!!
  4184  };
  4185  
  4186  module.exports = SolidityFunction;
  4187  
  4188  
  4189  },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./formatters":30}],32:[function(require,module,exports){
  4190  /*
  4191      This file is part of web3.js.
  4192  
  4193      web3.js is free software: you can redistribute it and/or modify
  4194      it under the terms of the GNU Lesser General Public License as published by
  4195      the Free Software Foundation, either version 3 of the License, or
  4196      (at your option) any later version.
  4197  
  4198      web3.js is distributed in the hope that it will be useful,
  4199      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4200      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4201      GNU Lesser General Public License for more details.
  4202  
  4203      You should have received a copy of the GNU Lesser General Public License
  4204      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4205  */
  4206  /** @file httpprovider.js
  4207   * @authors:
  4208   *   Marek Kotewicz <marek@ethdev.com>
  4209   *   Marian Oancea <marian@ethdev.com>
  4210   *   Fabian Vogelsteller <fabian@ethdev.com>
  4211   * @date 2015
  4212   */
  4213  
  4214  "use strict";
  4215  
  4216  var errors = require('./errors');
  4217  
  4218  // workaround to use httpprovider in different envs
  4219  var XMLHttpRequest; // jshint ignore: line
  4220  
  4221  // meteor server environment
  4222  if (typeof Meteor !== 'undefined' && Meteor.isServer) { // jshint ignore: line
  4223      XMLHttpRequest = Npm.require('xmlhttprequest').XMLHttpRequest; // jshint ignore: line
  4224  
  4225  // browser
  4226  } else if (typeof window !== 'undefined' && window.XMLHttpRequest) {
  4227      XMLHttpRequest = window.XMLHttpRequest; // jshint ignore: line
  4228  
  4229  // node
  4230  } else {
  4231      XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore: line
  4232  }
  4233  
  4234  /**
  4235   * HttpProvider should be used to send rpc calls over http
  4236   */
  4237  var HttpProvider = function (host) {
  4238      this.host = host || 'http://localhost:8545';
  4239  };
  4240  
  4241  /**
  4242   * Should be called to prepare new XMLHttpRequest
  4243   *
  4244   * @method prepareRequest
  4245   * @param {Boolean} true if request should be async
  4246   * @return {XMLHttpRequest} object
  4247   */
  4248  HttpProvider.prototype.prepareRequest = function (async) {
  4249      var request = new XMLHttpRequest();
  4250      request.open('POST', this.host, async);
  4251      request.setRequestHeader('Content-Type','application/json');
  4252      return request;
  4253  };
  4254  
  4255  /**
  4256   * Should be called to make sync request
  4257   *
  4258   * @method send
  4259   * @param {Object} payload
  4260   * @return {Object} result
  4261   */
  4262  HttpProvider.prototype.send = function (payload) {
  4263      var request = this.prepareRequest(false);
  4264  
  4265      try {
  4266          request.send(JSON.stringify(payload));
  4267      } catch(error) {
  4268          throw errors.InvalidConnection(this.host);
  4269      }
  4270  
  4271      var result = request.responseText;
  4272  
  4273      try {
  4274          result = JSON.parse(result);
  4275      } catch(e) {
  4276          throw errors.InvalidResponse(request.responseText);
  4277      }
  4278  
  4279      return result;
  4280  };
  4281  
  4282  /**
  4283   * Should be used to make async request
  4284   *
  4285   * @method sendAsync
  4286   * @param {Object} payload
  4287   * @param {Function} callback triggered on end with (err, result)
  4288   */
  4289  HttpProvider.prototype.sendAsync = function (payload, callback) {
  4290      var request = this.prepareRequest(true);
  4291  
  4292      request.onreadystatechange = function() {
  4293          if (request.readyState === 4) {
  4294              var result = request.responseText;
  4295              var error = null;
  4296  
  4297              try {
  4298                  result = JSON.parse(result);
  4299              } catch(e) {
  4300                  error = errors.InvalidResponse(request.responseText);
  4301              }
  4302  
  4303              callback(error, result);
  4304          }
  4305      };
  4306  
  4307      try {
  4308          request.send(JSON.stringify(payload));
  4309      } catch(error) {
  4310          callback(errors.InvalidConnection(this.host));
  4311      }
  4312  };
  4313  
  4314  /**
  4315   * Synchronously tries to make Http request
  4316   *
  4317   * @method isConnected
  4318   * @return {Boolean} returns true if request haven't failed. Otherwise false
  4319   */
  4320  HttpProvider.prototype.isConnected = function() {
  4321      try {
  4322          this.send({
  4323              id: 9999999999,
  4324              jsonrpc: '2.0',
  4325              method: 'net_listening',
  4326              params: []
  4327          });
  4328          return true;
  4329      } catch(e) {
  4330          return false;
  4331      }
  4332  };
  4333  
  4334  module.exports = HttpProvider;
  4335  
  4336  
  4337  },{"./errors":26,"xmlhttprequest":17}],33:[function(require,module,exports){
  4338  /*
  4339      This file is part of web3.js.
  4340  
  4341      web3.js is free software: you can redistribute it and/or modify
  4342      it under the terms of the GNU Lesser General Public License as published by
  4343      the Free Software Foundation, either version 3 of the License, or
  4344      (at your option) any later version.
  4345  
  4346      web3.js is distributed in the hope that it will be useful,
  4347      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4348      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4349      GNU Lesser General Public License for more details.
  4350  
  4351      You should have received a copy of the GNU Lesser General Public License
  4352      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4353  */
  4354  /**
  4355   * @file iban.js
  4356   * @author Marek Kotewicz <marek@ethdev.com>
  4357   * @date 2015
  4358   */
  4359  
  4360  var BigNumber = require('bignumber.js');
  4361  
  4362  var padLeft = function (string, bytes) {
  4363      var result = string;
  4364      while (result.length < bytes * 2) {
  4365          result = '00' + result;
  4366      }
  4367      return result;
  4368  };
  4369  
  4370  /**
  4371   * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to
  4372   * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.
  4373   *
  4374   * @method iso13616Prepare
  4375   * @param {String} iban the IBAN
  4376   * @returns {String} the prepared IBAN
  4377   */
  4378  var iso13616Prepare = function (iban) {
  4379      var A = 'A'.charCodeAt(0);
  4380      var Z = 'Z'.charCodeAt(0);
  4381  
  4382      iban = iban.toUpperCase();
  4383      iban = iban.substr(4) + iban.substr(0,4);
  4384  
  4385      return iban.split('').map(function(n){
  4386          var code = n.charCodeAt(0);
  4387          if (code >= A && code <= Z){
  4388              // A = 10, B = 11, ... Z = 35
  4389              return code - A + 10;
  4390          } else {
  4391              return n;
  4392          }
  4393      }).join('');
  4394  };
  4395  
  4396  /**
  4397   * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064.
  4398   *
  4399   * @method mod9710
  4400   * @param {String} iban
  4401   * @returns {Number}
  4402   */
  4403  var mod9710 = function (iban) {
  4404      var remainder = iban,
  4405          block;
  4406  
  4407      while (remainder.length > 2){
  4408          block = remainder.slice(0, 9);
  4409          remainder = parseInt(block, 10) % 97 + remainder.slice(block.length);
  4410      }
  4411  
  4412      return parseInt(remainder, 10) % 97;
  4413  };
  4414  
  4415  /**
  4416   * This prototype should be used to create iban object from iban correct string
  4417   *
  4418   * @param {String} iban
  4419   */
  4420  var Iban = function (iban) {
  4421      this._iban = iban;
  4422  };
  4423  
  4424  /**
  4425   * This method should be used to create iban object from ethereum address
  4426   *
  4427   * @method fromAddress
  4428   * @param {String} address
  4429   * @return {Iban} the IBAN object
  4430   */
  4431  Iban.fromAddress = function (address) {
  4432      var asBn = new BigNumber(address, 16);
  4433      var base36 = asBn.toString(36);
  4434      var padded = padLeft(base36, 15);
  4435      return Iban.fromBban(padded.toUpperCase());
  4436  };
  4437  
  4438  /**
  4439   * Convert the passed BBAN to an IBAN for this country specification.
  4440   * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>.
  4441   * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
  4442   *
  4443   * @method fromBban
  4444   * @param {String} bban the BBAN to convert to IBAN
  4445   * @returns {Iban} the IBAN object
  4446   */
  4447  Iban.fromBban = function (bban) {
  4448      var countryCode = 'XE';
  4449  
  4450      var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban));
  4451      var checkDigit = ('0' + (98 - remainder)).slice(-2);
  4452  
  4453      return new Iban(countryCode + checkDigit + bban);
  4454  };
  4455  
  4456  /**
  4457   * Should be used to create IBAN object for given institution and identifier
  4458   *
  4459   * @method createIndirect
  4460   * @param {Object} options, required options are "institution" and "identifier"
  4461   * @return {Iban} the IBAN object
  4462   */
  4463  Iban.createIndirect = function (options) {
  4464      return Iban.fromBban('ETH' + options.institution + options.identifier);
  4465  };
  4466  
  4467  /**
  4468   * Thos method should be used to check if given string is valid iban object
  4469   *
  4470   * @method isValid
  4471   * @param {String} iban string
  4472   * @return {Boolean} true if it is valid IBAN
  4473   */
  4474  Iban.isValid = function (iban) {
  4475      var i = new Iban(iban);
  4476      return i.isValid();
  4477  };
  4478  
  4479  /**
  4480   * Should be called to check if iban is correct
  4481   *
  4482   * @method isValid
  4483   * @returns {Boolean} true if it is, otherwise false
  4484   */
  4485  Iban.prototype.isValid = function () {
  4486      return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) &&
  4487          mod9710(iso13616Prepare(this._iban)) === 1;
  4488  };
  4489  
  4490  /**
  4491   * Should be called to check if iban number is direct
  4492   *
  4493   * @method isDirect
  4494   * @returns {Boolean} true if it is, otherwise false
  4495   */
  4496  Iban.prototype.isDirect = function () {
  4497      return this._iban.length === 34 || this._iban.length === 35;
  4498  };
  4499  
  4500  /**
  4501   * Should be called to check if iban number if indirect
  4502   *
  4503   * @method isIndirect
  4504   * @returns {Boolean} true if it is, otherwise false
  4505   */
  4506  Iban.prototype.isIndirect = function () {
  4507      return this._iban.length === 20;
  4508  };
  4509  
  4510  /**
  4511   * Should be called to get iban checksum
  4512   * Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
  4513   *
  4514   * @method checksum
  4515   * @returns {String} checksum
  4516   */
  4517  Iban.prototype.checksum = function () {
  4518      return this._iban.substr(2, 2);
  4519  };
  4520  
  4521  /**
  4522   * Should be called to get institution identifier
  4523   * eg. XREG
  4524   *
  4525   * @method institution
  4526   * @returns {String} institution identifier
  4527   */
  4528  Iban.prototype.institution = function () {
  4529      return this.isIndirect() ? this._iban.substr(7, 4) : '';
  4530  };
  4531  
  4532  /**
  4533   * Should be called to get client identifier within institution
  4534   * eg. GAVOFYORK
  4535   *
  4536   * @method client
  4537   * @returns {String} client identifier
  4538   */
  4539  Iban.prototype.client = function () {
  4540      return this.isIndirect() ? this._iban.substr(11) : '';
  4541  };
  4542  
  4543  /**
  4544   * Should be called to get client direct address
  4545   *
  4546   * @method address
  4547   * @returns {String} client direct address
  4548   */
  4549  Iban.prototype.address = function () {
  4550      if (this.isDirect()) {
  4551          var base36 = this._iban.substr(4);
  4552          var asBn = new BigNumber(base36, 36);
  4553          return padLeft(asBn.toString(16), 20);
  4554      }
  4555  
  4556      return '';
  4557  };
  4558  
  4559  Iban.prototype.toString = function () {
  4560      return this._iban;
  4561  };
  4562  
  4563  module.exports = Iban;
  4564  
  4565  
  4566  },{"bignumber.js":"bignumber.js"}],34:[function(require,module,exports){
  4567  /*
  4568      This file is part of web3.js.
  4569  
  4570      web3.js is free software: you can redistribute it and/or modify
  4571      it under the terms of the GNU Lesser General Public License as published by
  4572      the Free Software Foundation, either version 3 of the License, or
  4573      (at your option) any later version.
  4574  
  4575      web3.js is distributed in the hope that it will be useful,
  4576      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4577      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4578      GNU Lesser General Public License for more details.
  4579  
  4580      You should have received a copy of the GNU Lesser General Public License
  4581      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4582  */
  4583  /** @file ipcprovider.js
  4584   * @authors:
  4585   *   Fabian Vogelsteller <fabian@ethdev.com>
  4586   * @date 2015
  4587   */
  4588  
  4589  "use strict";
  4590  
  4591  var utils = require('../utils/utils');
  4592  var errors = require('./errors');
  4593  
  4594  
  4595  var IpcProvider = function (path, net) {
  4596      var _this = this;
  4597      this.responseCallbacks = {};
  4598      this.path = path;
  4599  
  4600      this.connection = net.connect({path: this.path});
  4601  
  4602      this.connection.on('error', function(e){
  4603          console.error('IPC Connection Error', e);
  4604          _this._timeout();
  4605      });
  4606  
  4607      this.connection.on('end', function(){
  4608          _this._timeout();
  4609      });
  4610  
  4611  
  4612      // LISTEN FOR CONNECTION RESPONSES
  4613      this.connection.on('data', function(data) {
  4614          /*jshint maxcomplexity: 6 */
  4615  
  4616          _this._parseResponse(data.toString()).forEach(function(result){
  4617  
  4618              var id = null;
  4619  
  4620              // get the id which matches the returned id
  4621              if(utils.isArray(result)) {
  4622                  result.forEach(function(load){
  4623                      if(_this.responseCallbacks[load.id])
  4624                          id = load.id;
  4625                  });
  4626              } else {
  4627                  id = result.id;
  4628              }
  4629  
  4630              // fire the callback
  4631              if(_this.responseCallbacks[id]) {
  4632                  _this.responseCallbacks[id](null, result);
  4633                  delete _this.responseCallbacks[id];
  4634              }
  4635          });
  4636      });
  4637  };
  4638  
  4639  /**
  4640  Will parse the response and make an array out of it.
  4641  
  4642  @method _parseResponse
  4643  @param {String} data
  4644  */
  4645  IpcProvider.prototype._parseResponse = function(data) {
  4646      var _this = this,
  4647          returnValues = [];
  4648  
  4649      // DE-CHUNKER
  4650      var dechunkedData = data
  4651          .replace(/\}[\n\r]?\{/g,'}|--|{') // }{
  4652          .replace(/\}\][\n\r]?\[\{/g,'}]|--|[{') // }][{
  4653          .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{
  4654          .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{
  4655          .split('|--|');
  4656  
  4657      dechunkedData.forEach(function(data){
  4658  
  4659          // prepend the last chunk
  4660          if(_this.lastChunk)
  4661              data = _this.lastChunk + data;
  4662  
  4663          var result = null;
  4664  
  4665          try {
  4666              result = JSON.parse(data);
  4667  
  4668          } catch(e) {
  4669  
  4670              _this.lastChunk = data;
  4671  
  4672              // start timeout to cancel all requests
  4673              clearTimeout(_this.lastChunkTimeout);
  4674              _this.lastChunkTimeout = setTimeout(function(){
  4675                  _this._timeout();
  4676                  throw errors.InvalidResponse(data);
  4677              }, 1000 * 15);
  4678  
  4679              return;
  4680          }
  4681  
  4682          // cancel timeout and set chunk to null
  4683          clearTimeout(_this.lastChunkTimeout);
  4684          _this.lastChunk = null;
  4685  
  4686          if(result)
  4687              returnValues.push(result);
  4688      });
  4689  
  4690      return returnValues;
  4691  };
  4692  
  4693  
  4694  /**
  4695  Get the adds a callback to the responseCallbacks object,
  4696  which will be called if a response matching the response Id will arrive.
  4697  
  4698  @method _addResponseCallback
  4699  */
  4700  IpcProvider.prototype._addResponseCallback = function(payload, callback) {
  4701      var id = payload.id || payload[0].id;
  4702      var method = payload.method || payload[0].method;
  4703  
  4704      this.responseCallbacks[id] = callback;
  4705      this.responseCallbacks[id].method = method;
  4706  };
  4707  
  4708  /**
  4709  Timeout all requests when the end/error event is fired
  4710  
  4711  @method _timeout
  4712  */
  4713  IpcProvider.prototype._timeout = function() {
  4714      for(var key in this.responseCallbacks) {
  4715          if(this.responseCallbacks.hasOwnProperty(key)){
  4716              this.responseCallbacks[key](errors.InvalidConnection('on IPC'));
  4717              delete this.responseCallbacks[key];
  4718          }
  4719      }
  4720  };
  4721  
  4722  
  4723  /**
  4724  Check if the current connection is still valid.
  4725  
  4726  @method isConnected
  4727  */
  4728  IpcProvider.prototype.isConnected = function() {
  4729      var _this = this;
  4730  
  4731      // try reconnect, when connection is gone
  4732      if(!_this.connection.writable)
  4733          _this.connection.connect({path: _this.path});
  4734  
  4735      return !!this.connection.writable;
  4736  };
  4737  
  4738  IpcProvider.prototype.send = function (payload) {
  4739  
  4740      if(this.connection.writeSync) {
  4741          var result;
  4742  
  4743          // try reconnect, when connection is gone
  4744          if(!this.connection.writable)
  4745              this.connection.connect({path: this.path});
  4746  
  4747          var data = this.connection.writeSync(JSON.stringify(payload));
  4748  
  4749          try {
  4750              result = JSON.parse(data);
  4751          } catch(e) {
  4752              throw errors.InvalidResponse(data);
  4753          }
  4754  
  4755          return result;
  4756  
  4757      } else {
  4758          throw new Error('You tried to send "'+ payload.method +'" synchronously. Synchronous requests are not supported by the IPC provider.');
  4759      }
  4760  };
  4761  
  4762  IpcProvider.prototype.sendAsync = function (payload, callback) {
  4763      // try reconnect, when connection is gone
  4764      if(!this.connection.writable)
  4765          this.connection.connect({path: this.path});
  4766  
  4767  
  4768      this.connection.write(JSON.stringify(payload));
  4769      this._addResponseCallback(payload, callback);
  4770  };
  4771  
  4772  module.exports = IpcProvider;
  4773  
  4774  
  4775  },{"../utils/utils":20,"./errors":26}],35:[function(require,module,exports){
  4776  /*
  4777      This file is part of web3.js.
  4778  
  4779      web3.js is free software: you can redistribute it and/or modify
  4780      it under the terms of the GNU Lesser General Public License as published by
  4781      the Free Software Foundation, either version 3 of the License, or
  4782      (at your option) any later version.
  4783  
  4784      web3.js is distributed in the hope that it will be useful,
  4785      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4786      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4787      GNU Lesser General Public License for more details.
  4788  
  4789      You should have received a copy of the GNU Lesser General Public License
  4790      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4791  */
  4792  /** @file jsonrpc.js
  4793   * @authors:
  4794   *   Marek Kotewicz <marek@ethdev.com>
  4795   * @date 2015
  4796   */
  4797  
  4798  var Jsonrpc = function () {
  4799      // singleton pattern
  4800      if (arguments.callee._singletonInstance) {
  4801          return arguments.callee._singletonInstance;
  4802      }
  4803      arguments.callee._singletonInstance = this;
  4804  
  4805      this.messageId = 1;
  4806  };
  4807  
  4808  /**
  4809   * @return {Jsonrpc} singleton
  4810   */
  4811  Jsonrpc.getInstance = function () {
  4812      var instance = new Jsonrpc();
  4813      return instance;
  4814  };
  4815  
  4816  /**
  4817   * Should be called to valid json create payload object
  4818   *
  4819   * @method toPayload
  4820   * @param {Function} method of jsonrpc call, required
  4821   * @param {Array} params, an array of method params, optional
  4822   * @returns {Object} valid jsonrpc payload object
  4823   */
  4824  Jsonrpc.prototype.toPayload = function (method, params) {
  4825      if (!method)
  4826          console.error('jsonrpc method should be specified!');
  4827  
  4828      return {
  4829          jsonrpc: '2.0',
  4830          method: method,
  4831          params: params || [],
  4832          id: this.messageId++
  4833      };
  4834  };
  4835  
  4836  /**
  4837   * Should be called to check if jsonrpc response is valid
  4838   *
  4839   * @method isValidResponse
  4840   * @param {Object}
  4841   * @returns {Boolean} true if response is valid, otherwise false
  4842   */
  4843  Jsonrpc.prototype.isValidResponse = function (response) {
  4844      return !!response &&
  4845          !response.error &&
  4846          response.jsonrpc === '2.0' &&
  4847          typeof response.id === 'number' &&
  4848          response.result !== undefined; // only undefined is not valid json object
  4849  };
  4850  
  4851  /**
  4852   * Should be called to create batch payload object
  4853   *
  4854   * @method toBatchPayload
  4855   * @param {Array} messages, an array of objects with method (required) and params (optional) fields
  4856   * @returns {Array} batch payload
  4857   */
  4858  Jsonrpc.prototype.toBatchPayload = function (messages) {
  4859      var self = this;
  4860      return messages.map(function (message) {
  4861          return self.toPayload(message.method, message.params);
  4862      });
  4863  };
  4864  
  4865  module.exports = Jsonrpc;
  4866  
  4867  
  4868  },{}],36:[function(require,module,exports){
  4869  /*
  4870      This file is part of web3.js.
  4871  
  4872      web3.js is free software: you can redistribute it and/or modify
  4873      it under the terms of the GNU Lesser General Public License as published by
  4874      the Free Software Foundation, either version 3 of the License, or
  4875      (at your option) any later version.
  4876  
  4877      web3.js is distributed in the hope that it will be useful,
  4878      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4879      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4880      GNU Lesser General Public License for more details.
  4881  
  4882      You should have received a copy of the GNU Lesser General Public License
  4883      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4884  */
  4885  /**
  4886   * @file method.js
  4887   * @author Marek Kotewicz <marek@ethdev.com>
  4888   * @date 2015
  4889   */
  4890  
  4891  var utils = require('../utils/utils');
  4892  var errors = require('./errors');
  4893  
  4894  var Method = function (options) {
  4895      this.name = options.name;
  4896      this.call = options.call;
  4897      this.params = options.params || 0;
  4898      this.inputFormatter = options.inputFormatter;
  4899      this.outputFormatter = options.outputFormatter;
  4900      this.requestManager = null;
  4901  };
  4902  
  4903  Method.prototype.setRequestManager = function (rm) {
  4904      this.requestManager = rm;
  4905  };
  4906  
  4907  /**
  4908   * Should be used to determine name of the jsonrpc method based on arguments
  4909   *
  4910   * @method getCall
  4911   * @param {Array} arguments
  4912   * @return {String} name of jsonrpc method
  4913   */
  4914  Method.prototype.getCall = function (args) {
  4915      return utils.isFunction(this.call) ? this.call(args) : this.call;
  4916  };
  4917  
  4918  /**
  4919   * Should be used to extract callback from array of arguments. Modifies input param
  4920   *
  4921   * @method extractCallback
  4922   * @param {Array} arguments
  4923   * @return {Function|Null} callback, if exists
  4924   */
  4925  Method.prototype.extractCallback = function (args) {
  4926      if (utils.isFunction(args[args.length - 1])) {
  4927          return args.pop(); // modify the args array!
  4928      }
  4929  };
  4930  
  4931  /**
  4932   * Should be called to check if the number of arguments is correct
  4933   *
  4934   * @method validateArgs
  4935   * @param {Array} arguments
  4936   * @throws {Error} if it is not
  4937   */
  4938  Method.prototype.validateArgs = function (args) {
  4939      if (args.length !== this.params) {
  4940          throw errors.InvalidNumberOfParams();
  4941      }
  4942  };
  4943  
  4944  /**
  4945   * Should be called to format input args of method
  4946   *
  4947   * @method formatInput
  4948   * @param {Array}
  4949   * @return {Array}
  4950   */
  4951  Method.prototype.formatInput = function (args) {
  4952      if (!this.inputFormatter) {
  4953          return args;
  4954      }
  4955  
  4956      return this.inputFormatter.map(function (formatter, index) {
  4957          return formatter ? formatter(args[index]) : args[index];
  4958      });
  4959  };
  4960  
  4961  /**
  4962   * Should be called to format output(result) of method
  4963   *
  4964   * @method formatOutput
  4965   * @param {Object}
  4966   * @return {Object}
  4967   */
  4968  Method.prototype.formatOutput = function (result) {
  4969      return this.outputFormatter && result ? this.outputFormatter(result) : result;
  4970  };
  4971  
  4972  /**
  4973   * Should create payload from given input args
  4974   *
  4975   * @method toPayload
  4976   * @param {Array} args
  4977   * @return {Object}
  4978   */
  4979  Method.prototype.toPayload = function (args) {
  4980      var call = this.getCall(args);
  4981      var callback = this.extractCallback(args);
  4982      var params = this.formatInput(args);
  4983      this.validateArgs(params);
  4984  
  4985      return {
  4986          method: call,
  4987          params: params,
  4988          callback: callback
  4989      };
  4990  };
  4991  
  4992  Method.prototype.attachToObject = function (obj) {
  4993      var func = this.buildCall();
  4994      func.call = this.call; // TODO!!! that's ugly. filter.js uses it
  4995      var name = this.name.split('.');
  4996      if (name.length > 1) {
  4997          obj[name[0]] = obj[name[0]] || {};
  4998          obj[name[0]][name[1]] = func;
  4999      } else {
  5000          obj[name[0]] = func;
  5001      }
  5002  };
  5003  
  5004  Method.prototype.buildCall = function() {
  5005      var method = this;
  5006      var send = function () {
  5007          var payload = method.toPayload(Array.prototype.slice.call(arguments));
  5008          if (payload.callback) {
  5009              return method.requestManager.sendAsync(payload, function (err, result) {
  5010                  payload.callback(err, method.formatOutput(result));
  5011              });
  5012          }
  5013          return method.formatOutput(method.requestManager.send(payload));
  5014      };
  5015      send.request = this.request.bind(this);
  5016      return send;
  5017  };
  5018  
  5019  /**
  5020   * Should be called to create pure JSONRPC request which can be used in batch request
  5021   *
  5022   * @method request
  5023   * @param {...} params
  5024   * @return {Object} jsonrpc request
  5025   */
  5026  Method.prototype.request = function () {
  5027      var payload = this.toPayload(Array.prototype.slice.call(arguments));
  5028      payload.format = this.formatOutput.bind(this);
  5029      return payload;
  5030  };
  5031  
  5032  module.exports = Method;
  5033  
  5034  
  5035  },{"../utils/utils":20,"./errors":26}],37:[function(require,module,exports){
  5036  /*
  5037      This file is part of web3.js.
  5038  
  5039      web3.js is free software: you can redistribute it and/or modify
  5040      it under the terms of the GNU Lesser General Public License as published by
  5041      the Free Software Foundation, either version 3 of the License, or
  5042      (at your option) any later version.
  5043  
  5044      web3.js is distributed in the hope that it will be useful,
  5045      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5046      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5047      GNU Lesser General Public License for more details.
  5048  
  5049      You should have received a copy of the GNU Lesser General Public License
  5050      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5051  */
  5052  /** @file db.js
  5053   * @authors:
  5054   *   Marek Kotewicz <marek@ethdev.com>
  5055   * @date 2015
  5056   */
  5057  
  5058  var Method = require('../method');
  5059  
  5060  var DB = function (web3) {
  5061      this._requestManager = web3._requestManager;
  5062  
  5063      var self = this;
  5064  
  5065      methods().forEach(function(method) {
  5066          method.attachToObject(self);
  5067          method.setRequestManager(web3._requestManager);
  5068      });
  5069  };
  5070  
  5071  var methods = function () {
  5072      var putString = new Method({
  5073          name: 'putString',
  5074          call: 'db_putString',
  5075          params: 3
  5076      });
  5077  
  5078      var getString = new Method({
  5079          name: 'getString',
  5080          call: 'db_getString',
  5081          params: 2
  5082      });
  5083  
  5084      var putHex = new Method({
  5085          name: 'putHex',
  5086          call: 'db_putHex',
  5087          params: 3
  5088      });
  5089  
  5090      var getHex = new Method({
  5091          name: 'getHex',
  5092          call: 'db_getHex',
  5093          params: 2
  5094      });
  5095  
  5096      return [
  5097          putString, getString, putHex, getHex
  5098      ];
  5099  };
  5100  
  5101  module.exports = DB;
  5102  
  5103  },{"../method":36}],38:[function(require,module,exports){
  5104  /*
  5105      This file is part of web3.js.
  5106  
  5107      web3.js is free software: you can redistribute it and/or modify
  5108      it under the terms of the GNU Lesser General Public License as published by
  5109      the Free Software Foundation, either version 3 of the License, or
  5110      (at your option) any later version.
  5111  
  5112      web3.js is distributed in the hope that it will be useful,
  5113      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5114      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5115      GNU Lesser General Public License for more details.
  5116  
  5117      You should have received a copy of the GNU Lesser General Public License
  5118      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5119  */
  5120  /**
  5121   * @file eth.js
  5122   * @author Marek Kotewicz <marek@ethdev.com>
  5123   * @author Fabian Vogelsteller <fabian@ethdev.com>
  5124   * @date 2015
  5125   */
  5126  
  5127  "use strict";
  5128  
  5129  var formatters = require('../formatters');
  5130  var utils = require('../../utils/utils');
  5131  var Method = require('../method');
  5132  var Property = require('../property');
  5133  var c = require('../../utils/config');
  5134  var Contract = require('../contract');
  5135  var watches = require('./watches');
  5136  var Filter = require('../filter');
  5137  var IsSyncing = require('../syncing');
  5138  var namereg = require('../namereg');
  5139  var Iban = require('../iban');
  5140  var transfer = require('../transfer');
  5141  
  5142  var blockCall = function (args) {
  5143      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
  5144  };
  5145  
  5146  var transactionFromBlockCall = function (args) {
  5147      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
  5148  };
  5149  
  5150  var uncleCall = function (args) {
  5151      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
  5152  };
  5153  
  5154  var getBlockTransactionCountCall = function (args) {
  5155      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
  5156  };
  5157  
  5158  var uncleCountCall = function (args) {
  5159      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
  5160  };
  5161  
  5162  function Eth(web3) {
  5163      this._requestManager = web3._requestManager;
  5164  
  5165      var self = this;
  5166  
  5167      methods().forEach(function(method) {
  5168          method.attachToObject(self);
  5169          method.setRequestManager(self._requestManager);
  5170      });
  5171  
  5172      properties().forEach(function(p) {
  5173          p.attachToObject(self);
  5174          p.setRequestManager(self._requestManager);
  5175      });
  5176  
  5177  
  5178      this.iban = Iban;
  5179      this.sendIBANTransaction = transfer.bind(null, this);
  5180  }
  5181  
  5182  Object.defineProperty(Eth.prototype, 'defaultBlock', {
  5183      get: function () {
  5184          return c.defaultBlock;
  5185      },
  5186      set: function (val) {
  5187          c.defaultBlock = val;
  5188          return val;
  5189      }
  5190  });
  5191  
  5192  Object.defineProperty(Eth.prototype, 'defaultAccount', {
  5193      get: function () {
  5194          return c.defaultAccount;
  5195      },
  5196      set: function (val) {
  5197          c.defaultAccount = val;
  5198          return val;
  5199      }
  5200  });
  5201  
  5202  var methods = function () {
  5203      var getBalance = new Method({
  5204          name: 'getBalance',
  5205          call: 'eth_getBalance',
  5206          params: 2,
  5207          inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
  5208          outputFormatter: formatters.outputBigNumberFormatter
  5209      });
  5210  
  5211      var getStorageAt = new Method({
  5212          name: 'getStorageAt',
  5213          call: 'eth_getStorageAt',
  5214          params: 3,
  5215          inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
  5216      });
  5217  
  5218      var getCode = new Method({
  5219          name: 'getCode',
  5220          call: 'eth_getCode',
  5221          params: 2,
  5222          inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
  5223      });
  5224  
  5225      var getBlock = new Method({
  5226          name: 'getBlock',
  5227          call: blockCall,
  5228          params: 2,
  5229          inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
  5230          outputFormatter: formatters.outputBlockFormatter
  5231      });
  5232  
  5233      var getUncle = new Method({
  5234          name: 'getUncle',
  5235          call: uncleCall,
  5236          params: 2,
  5237          inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5238          outputFormatter: formatters.outputBlockFormatter,
  5239  
  5240      });
  5241  
  5242      var getCompilers = new Method({
  5243          name: 'getCompilers',
  5244          call: 'eth_getCompilers',
  5245          params: 0
  5246      });
  5247  
  5248      var getBlockTransactionCount = new Method({
  5249          name: 'getBlockTransactionCount',
  5250          call: getBlockTransactionCountCall,
  5251          params: 1,
  5252          inputFormatter: [formatters.inputBlockNumberFormatter],
  5253          outputFormatter: utils.toDecimal
  5254      });
  5255  
  5256      var getBlockUncleCount = new Method({
  5257          name: 'getBlockUncleCount',
  5258          call: uncleCountCall,
  5259          params: 1,
  5260          inputFormatter: [formatters.inputBlockNumberFormatter],
  5261          outputFormatter: utils.toDecimal
  5262      });
  5263  
  5264      var getTransaction = new Method({
  5265          name: 'getTransaction',
  5266          call: 'eth_getTransactionByHash',
  5267          params: 1,
  5268          outputFormatter: formatters.outputTransactionFormatter
  5269      });
  5270  
  5271      var getTransactionFromBlock = new Method({
  5272          name: 'getTransactionFromBlock',
  5273          call: transactionFromBlockCall,
  5274          params: 2,
  5275          inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5276          outputFormatter: formatters.outputTransactionFormatter
  5277      });
  5278  
  5279      var getTransactionReceipt = new Method({
  5280          name: 'getTransactionReceipt',
  5281          call: 'eth_getTransactionReceipt',
  5282          params: 1,
  5283          outputFormatter: formatters.outputTransactionReceiptFormatter
  5284      });
  5285  
  5286      var getTransactionCount = new Method({
  5287          name: 'getTransactionCount',
  5288          call: 'eth_getTransactionCount',
  5289          params: 2,
  5290          inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
  5291          outputFormatter: utils.toDecimal
  5292      });
  5293  
  5294      var sendRawTransaction = new Method({
  5295          name: 'sendRawTransaction',
  5296          call: 'eth_sendRawTransaction',
  5297          params: 1,
  5298          inputFormatter: [null]
  5299      });
  5300  
  5301      var sendTransaction = new Method({
  5302          name: 'sendTransaction',
  5303          call: 'eth_sendTransaction',
  5304          params: 1,
  5305          inputFormatter: [formatters.inputTransactionFormatter]
  5306      });
  5307  
  5308      var sign = new Method({
  5309          name: 'sign',
  5310          call: 'eth_sign',
  5311          params: 2,
  5312          inputFormatter: [formatters.inputAddressFormatter, null]
  5313      });
  5314  
  5315      var call = new Method({
  5316          name: 'call',
  5317          call: 'eth_call',
  5318          params: 2,
  5319          inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
  5320      });
  5321  
  5322      var estimateGas = new Method({
  5323          name: 'estimateGas',
  5324          call: 'eth_estimateGas',
  5325          params: 1,
  5326          inputFormatter: [formatters.inputCallFormatter],
  5327          outputFormatter: utils.toDecimal
  5328      });
  5329  
  5330      var compileSolidity = new Method({
  5331          name: 'compile.solidity',
  5332          call: 'eth_compileSolidity',
  5333          params: 1
  5334      });
  5335  
  5336      var compileLLL = new Method({
  5337          name: 'compile.lll',
  5338          call: 'eth_compileLLL',
  5339          params: 1
  5340      });
  5341  
  5342      var compileSerpent = new Method({
  5343          name: 'compile.serpent',
  5344          call: 'eth_compileSerpent',
  5345          params: 1
  5346      });
  5347  
  5348      var submitWork = new Method({
  5349          name: 'submitWork',
  5350          call: 'eth_submitWork',
  5351          params: 3
  5352      });
  5353  
  5354      var getWork = new Method({
  5355          name: 'getWork',
  5356          call: 'eth_getWork',
  5357          params: 0
  5358      });
  5359  
  5360      return [
  5361          getBalance,
  5362          getStorageAt,
  5363          getCode,
  5364          getBlock,
  5365          getUncle,
  5366          getCompilers,
  5367          getBlockTransactionCount,
  5368          getBlockUncleCount,
  5369          getTransaction,
  5370          getTransactionFromBlock,
  5371          getTransactionReceipt,
  5372          getTransactionCount,
  5373          call,
  5374          estimateGas,
  5375          sendRawTransaction,
  5376          sendTransaction,
  5377          sign,
  5378          compileSolidity,
  5379          compileLLL,
  5380          compileSerpent,
  5381          submitWork,
  5382          getWork
  5383      ];
  5384  };
  5385  
  5386  
  5387  var properties = function () {
  5388      return [
  5389          new Property({
  5390              name: 'coinbase',
  5391              getter: 'eth_coinbase'
  5392          }),
  5393          new Property({
  5394              name: 'mining',
  5395              getter: 'eth_mining'
  5396          }),
  5397          new Property({
  5398              name: 'hashrate',
  5399              getter: 'eth_hashrate',
  5400              outputFormatter: utils.toDecimal
  5401          }),
  5402          new Property({
  5403              name: 'syncing',
  5404              getter: 'eth_syncing',
  5405              outputFormatter: formatters.outputSyncingFormatter
  5406          }),
  5407          new Property({
  5408              name: 'gasPrice',
  5409              getter: 'eth_gasPrice',
  5410              outputFormatter: formatters.outputBigNumberFormatter
  5411          }),
  5412          new Property({
  5413              name: 'accounts',
  5414              getter: 'eth_accounts'
  5415          }),
  5416          new Property({
  5417              name: 'blockNumber',
  5418              getter: 'eth_blockNumber',
  5419              outputFormatter: utils.toDecimal
  5420          })
  5421      ];
  5422  };
  5423  
  5424  Eth.prototype.contract = function (abi) {
  5425      var factory = new Contract(this, abi);
  5426      return factory;
  5427  };
  5428  
  5429  Eth.prototype.filter = function (fil, callback) {
  5430      return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback);
  5431  };
  5432  
  5433  Eth.prototype.namereg = function () {
  5434      return this.contract(namereg.global.abi).at(namereg.global.address);
  5435  };
  5436  
  5437  Eth.prototype.icapNamereg = function () {
  5438      return this.contract(namereg.icap.abi).at(namereg.icap.address);
  5439  };
  5440  
  5441  Eth.prototype.isSyncing = function (callback) {
  5442      return new IsSyncing(this._requestManager, callback);
  5443  };
  5444  
  5445  module.exports = Eth;
  5446  
  5447  
  5448  },{"../../utils/config":18,"../../utils/utils":20,"../contract":25,"../filter":29,"../formatters":30,"../iban":33,"../method":36,"../namereg":43,"../property":44,"../syncing":47,"../transfer":48,"./watches":42}],39:[function(require,module,exports){
  5449  /*
  5450      This file is part of web3.js.
  5451  
  5452      web3.js is free software: you can redistribute it and/or modify
  5453      it under the terms of the GNU Lesser General Public License as published by
  5454      the Free Software Foundation, either version 3 of the License, or
  5455      (at your option) any later version.
  5456  
  5457      web3.js is distributed in the hope that it will be useful,
  5458      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5459      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5460      GNU Lesser General Public License for more details.
  5461  
  5462      You should have received a copy of the GNU Lesser General Public License
  5463      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5464  */
  5465  /** @file eth.js
  5466   * @authors:
  5467   *   Marek Kotewicz <marek@ethdev.com>
  5468   * @date 2015
  5469   */
  5470  
  5471  var utils = require('../../utils/utils');
  5472  var Property = require('../property');
  5473  
  5474  var Net = function (web3) {
  5475      this._requestManager = web3._requestManager;
  5476  
  5477      var self = this;
  5478  
  5479      properties().forEach(function(p) {
  5480          p.attachToObject(self);
  5481          p.setRequestManager(web3._requestManager);
  5482      });
  5483  };
  5484  
  5485  /// @returns an array of objects describing web3.eth api properties
  5486  var properties = function () {
  5487      return [
  5488          new Property({
  5489              name: 'listening',
  5490              getter: 'net_listening'
  5491          }),
  5492          new Property({
  5493              name: 'peerCount',
  5494              getter: 'net_peerCount',
  5495              outputFormatter: utils.toDecimal
  5496          })
  5497      ];
  5498  };
  5499  
  5500  module.exports = Net;
  5501  
  5502  },{"../../utils/utils":20,"../property":44}],40:[function(require,module,exports){
  5503  /*
  5504      This file is part of web3.js.
  5505  
  5506      web3.js is free software: you can redistribute it and/or modify
  5507      it under the terms of the GNU Lesser General Public License as published by
  5508      the Free Software Foundation, either version 3 of the License, or
  5509      (at your option) any later version.
  5510  
  5511      web3.js is distributed in the hope that it will be useful,
  5512      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5513      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5514      GNU Lesser General Public License for more details.
  5515  
  5516      You should have received a copy of the GNU Lesser General Public License
  5517      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5518  */
  5519  /**
  5520   * @file eth.js
  5521   * @author Marek Kotewicz <marek@ethdev.com>
  5522   * @author Fabian Vogelsteller <fabian@ethdev.com>
  5523   * @date 2015
  5524   */
  5525  
  5526  "use strict";
  5527  
  5528  var Method = require('../method');
  5529  var Property = require('../property');
  5530  var formatters = require('../formatters');
  5531  
  5532  function Personal(web3) {
  5533      this._requestManager = web3._requestManager;
  5534  
  5535      var self = this;
  5536  
  5537      methods().forEach(function(method) {
  5538          method.attachToObject(self);
  5539          method.setRequestManager(self._requestManager);
  5540      });
  5541  
  5542      properties().forEach(function(p) {
  5543          p.attachToObject(self);
  5544          p.setRequestManager(self._requestManager);
  5545      });
  5546  }
  5547  
  5548  var methods = function () {
  5549      var newAccount = new Method({
  5550          name: 'newAccount',
  5551          call: 'personal_newAccount',
  5552          params: 1,
  5553          inputFormatter: [null]
  5554      });
  5555  
  5556      var unlockAccount = new Method({
  5557          name: 'unlockAccount',
  5558          call: 'personal_unlockAccount',
  5559          params: 3,
  5560          inputFormatter: [formatters.inputAddressFormatter, null, null]
  5561      });
  5562  
  5563      var lockAccount = new Method({
  5564          name: 'lockAccount',
  5565          call: 'personal_lockAccount',
  5566          params: 1,
  5567          inputFormatter: [formatters.inputAddressFormatter]
  5568      });
  5569  
  5570      return [
  5571          newAccount,
  5572          unlockAccount,
  5573          lockAccount
  5574      ];
  5575  };
  5576  
  5577  var properties = function () {
  5578      return [
  5579          new Property({
  5580              name: 'listAccounts',
  5581              getter: 'personal_listAccounts'
  5582          })
  5583      ];
  5584  };
  5585  
  5586  
  5587  module.exports = Personal;
  5588  
  5589  },{"../formatters":30,"../method":36,"../property":44}],41:[function(require,module,exports){
  5590  /*
  5591      This file is part of web3.js.
  5592  
  5593      web3.js is free software: you can redistribute it and/or modify
  5594      it under the terms of the GNU Lesser General Public License as published by
  5595      the Free Software Foundation, either version 3 of the License, or
  5596      (at your option) any later version.
  5597  
  5598      web3.js is distributed in the hope that it will be useful,
  5599      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5600      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5601      GNU Lesser General Public License for more details.
  5602  
  5603      You should have received a copy of the GNU Lesser General Public License
  5604      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5605  */
  5606  /** @file shh.js
  5607   * @authors:
  5608   *   Marek Kotewicz <marek@ethdev.com>
  5609   * @date 2015
  5610   */
  5611  
  5612  var Method = require('../method');
  5613  var formatters = require('../formatters');
  5614  var Filter = require('../filter');
  5615  var watches = require('./watches');
  5616  
  5617  var Shh = function (web3) {
  5618      this._requestManager = web3._requestManager;
  5619  
  5620      var self = this;
  5621  
  5622      methods().forEach(function(method) {
  5623          method.attachToObject(self);
  5624          method.setRequestManager(self._requestManager);
  5625      });
  5626  };
  5627  
  5628  Shh.prototype.filter = function (fil, callback) {
  5629      return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback);
  5630  };
  5631  
  5632  var methods = function () {
  5633  
  5634      var post = new Method({
  5635          name: 'post',
  5636          call: 'shh_post',
  5637          params: 1,
  5638          inputFormatter: [formatters.inputPostFormatter]
  5639      });
  5640  
  5641      var newIdentity = new Method({
  5642          name: 'newIdentity',
  5643          call: 'shh_newIdentity',
  5644          params: 0
  5645      });
  5646  
  5647      var hasIdentity = new Method({
  5648          name: 'hasIdentity',
  5649          call: 'shh_hasIdentity',
  5650          params: 1
  5651      });
  5652  
  5653      var newGroup = new Method({
  5654          name: 'newGroup',
  5655          call: 'shh_newGroup',
  5656          params: 0
  5657      });
  5658  
  5659      var addToGroup = new Method({
  5660          name: 'addToGroup',
  5661          call: 'shh_addToGroup',
  5662          params: 0
  5663      });
  5664  
  5665      return [
  5666          post,
  5667          newIdentity,
  5668          hasIdentity,
  5669          newGroup,
  5670          addToGroup
  5671      ];
  5672  };
  5673  
  5674  module.exports = Shh;
  5675  
  5676  
  5677  },{"../filter":29,"../formatters":30,"../method":36,"./watches":42}],42:[function(require,module,exports){
  5678  /*
  5679      This file is part of web3.js.
  5680  
  5681      web3.js is free software: you can redistribute it and/or modify
  5682      it under the terms of the GNU Lesser General Public License as published by
  5683      the Free Software Foundation, either version 3 of the License, or
  5684      (at your option) any later version.
  5685  
  5686      web3.js is distributed in the hope that it will be useful,
  5687      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5688      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5689      GNU Lesser General Public License for more details.
  5690  
  5691      You should have received a copy of the GNU Lesser General Public License
  5692      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5693  */
  5694  /** @file watches.js
  5695   * @authors:
  5696   *   Marek Kotewicz <marek@ethdev.com>
  5697   * @date 2015
  5698   */
  5699  
  5700  var Method = require('../method');
  5701  
  5702  /// @returns an array of objects describing web3.eth.filter api methods
  5703  var eth = function () {
  5704      var newFilterCall = function (args) {
  5705          var type = args[0];
  5706  
  5707          switch(type) {
  5708              case 'latest':
  5709                  args.shift();
  5710                  this.params = 0;
  5711                  return 'eth_newBlockFilter';
  5712              case 'pending':
  5713                  args.shift();
  5714                  this.params = 0;
  5715                  return 'eth_newPendingTransactionFilter';
  5716              default:
  5717                  return 'eth_newFilter';
  5718          }
  5719      };
  5720  
  5721      var newFilter = new Method({
  5722          name: 'newFilter',
  5723          call: newFilterCall,
  5724          params: 1
  5725      });
  5726  
  5727      var uninstallFilter = new Method({
  5728          name: 'uninstallFilter',
  5729          call: 'eth_uninstallFilter',
  5730          params: 1
  5731      });
  5732  
  5733      var getLogs = new Method({
  5734          name: 'getLogs',
  5735          call: 'eth_getFilterLogs',
  5736          params: 1
  5737      });
  5738  
  5739      var poll = new Method({
  5740          name: 'poll',
  5741          call: 'eth_getFilterChanges',
  5742          params: 1
  5743      });
  5744  
  5745      return [
  5746          newFilter,
  5747          uninstallFilter,
  5748          getLogs,
  5749          poll
  5750      ];
  5751  };
  5752  
  5753  /// @returns an array of objects describing web3.shh.watch api methods
  5754  var shh = function () {
  5755      var newFilter = new Method({
  5756          name: 'newFilter',
  5757          call: 'shh_newFilter',
  5758          params: 1
  5759      });
  5760  
  5761      var uninstallFilter = new Method({
  5762          name: 'uninstallFilter',
  5763          call: 'shh_uninstallFilter',
  5764          params: 1
  5765      });
  5766  
  5767      var getLogs = new Method({
  5768          name: 'getLogs',
  5769          call: 'shh_getMessages',
  5770          params: 1
  5771      });
  5772  
  5773      var poll = new Method({
  5774          name: 'poll',
  5775          call: 'shh_getFilterChanges',
  5776          params: 1
  5777      });
  5778  
  5779      return [
  5780          newFilter,
  5781          uninstallFilter,
  5782          getLogs,
  5783          poll
  5784      ];
  5785  };
  5786  
  5787  module.exports = {
  5788      eth: eth,
  5789      shh: shh
  5790  };
  5791  
  5792  
  5793  },{"../method":36}],43:[function(require,module,exports){
  5794  /*
  5795      This file is part of web3.js.
  5796  
  5797      web3.js is free software: you can redistribute it and/or modify
  5798      it under the terms of the GNU Lesser General Public License as published by
  5799      the Free Software Foundation, either version 3 of the License, or
  5800      (at your option) any later version.
  5801  
  5802      web3.js is distributed in the hope that it will be useful,
  5803      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5804      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5805      GNU Lesser General Public License for more details.
  5806  
  5807      You should have received a copy of the GNU Lesser General Public License
  5808      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5809  */
  5810  /**
  5811   * @file namereg.js
  5812   * @author Marek Kotewicz <marek@ethdev.com>
  5813   * @date 2015
  5814   */
  5815  
  5816  var globalRegistrarAbi = require('../contracts/GlobalRegistrar.json');
  5817  var icapRegistrarAbi= require('../contracts/ICAPRegistrar.json');
  5818  
  5819  var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
  5820  var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
  5821  
  5822  module.exports = {
  5823      global: {
  5824          abi: globalRegistrarAbi,
  5825          address: globalNameregAddress
  5826      },
  5827      icap: {
  5828          abi: icapRegistrarAbi,
  5829          address: icapNameregAddress
  5830      }
  5831  };
  5832  
  5833  
  5834  },{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],44:[function(require,module,exports){
  5835  /*
  5836      This file is part of web3.js.
  5837  
  5838      web3.js is free software: you can redistribute it and/or modify
  5839      it under the terms of the GNU Lesser General Public License as published by
  5840      the Free Software Foundation, either version 3 of the License, or
  5841      (at your option) any later version.
  5842  
  5843      web3.js is distributed in the hope that it will be useful,
  5844      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5845      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5846      GNU Lesser General Public License for more details.
  5847  
  5848      You should have received a copy of the GNU Lesser General Public License
  5849      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5850  */
  5851  /**
  5852   * @file property.js
  5853   * @author Fabian Vogelsteller <fabian@frozeman.de>
  5854   * @author Marek Kotewicz <marek@ethdev.com>
  5855   * @date 2015
  5856   */
  5857  
  5858  var utils = require('../utils/utils');
  5859  
  5860  var Property = function (options) {
  5861      this.name = options.name;
  5862      this.getter = options.getter;
  5863      this.setter = options.setter;
  5864      this.outputFormatter = options.outputFormatter;
  5865      this.inputFormatter = options.inputFormatter;
  5866      this.requestManager = null;
  5867  };
  5868  
  5869  Property.prototype.setRequestManager = function (rm) {
  5870      this.requestManager = rm;
  5871  };
  5872  
  5873  /**
  5874   * Should be called to format input args of method
  5875   *
  5876   * @method formatInput
  5877   * @param {Array}
  5878   * @return {Array}
  5879   */
  5880  Property.prototype.formatInput = function (arg) {
  5881      return this.inputFormatter ? this.inputFormatter(arg) : arg;
  5882  };
  5883  
  5884  /**
  5885   * Should be called to format output(result) of method
  5886   *
  5887   * @method formatOutput
  5888   * @param {Object}
  5889   * @return {Object}
  5890   */
  5891  Property.prototype.formatOutput = function (result) {
  5892      return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;
  5893  };
  5894  
  5895  /**
  5896   * Should be used to extract callback from array of arguments. Modifies input param
  5897   *
  5898   * @method extractCallback
  5899   * @param {Array} arguments
  5900   * @return {Function|Null} callback, if exists
  5901   */
  5902  Property.prototype.extractCallback = function (args) {
  5903      if (utils.isFunction(args[args.length - 1])) {
  5904          return args.pop(); // modify the args array!
  5905      }
  5906  };
  5907  
  5908  
  5909  /**
  5910   * Should attach function to method
  5911   *
  5912   * @method attachToObject
  5913   * @param {Object}
  5914   * @param {Function}
  5915   */
  5916  Property.prototype.attachToObject = function (obj) {
  5917      var proto = {
  5918          get: this.buildGet(),
  5919          enumerable: true
  5920      };
  5921  
  5922      var names = this.name.split('.');
  5923      var name = names[0];
  5924      if (names.length > 1) {
  5925          obj[names[0]] = obj[names[0]] || {};
  5926          obj = obj[names[0]];
  5927          name = names[1];
  5928      }
  5929  
  5930      Object.defineProperty(obj, name, proto);
  5931      obj[asyncGetterName(name)] = this.buildAsyncGet();
  5932  };
  5933  
  5934  var asyncGetterName = function (name) {
  5935      return 'get' + name.charAt(0).toUpperCase() + name.slice(1);
  5936  };
  5937  
  5938  Property.prototype.buildGet = function () {
  5939      var property = this;
  5940      return function get() {
  5941          return property.formatOutput(property.requestManager.send({
  5942              method: property.getter
  5943          }));
  5944      };
  5945  };
  5946  
  5947  Property.prototype.buildAsyncGet = function () {
  5948      var property = this;
  5949      var get = function (callback) {
  5950          property.requestManager.sendAsync({
  5951              method: property.getter
  5952          }, function (err, result) {
  5953              callback(err, property.formatOutput(result));
  5954          });
  5955      };
  5956      get.request = this.request.bind(this);
  5957      return get;
  5958  };
  5959  
  5960  /**
  5961   * Should be called to create pure JSONRPC request which can be used in batch request
  5962   *
  5963   * @method request
  5964   * @param {...} params
  5965   * @return {Object} jsonrpc request
  5966   */
  5967  Property.prototype.request = function () {
  5968      var payload = {
  5969          method: this.getter,
  5970          params: [],
  5971          callback: this.extractCallback(Array.prototype.slice.call(arguments))
  5972      };
  5973      payload.format = this.formatOutput.bind(this);
  5974      return payload;
  5975  };
  5976  
  5977  module.exports = Property;
  5978  
  5979  
  5980  },{"../utils/utils":20}],45:[function(require,module,exports){
  5981  /*
  5982      This file is part of web3.js.
  5983  
  5984      web3.js is free software: you can redistribute it and/or modify
  5985      it under the terms of the GNU Lesser General Public License as published by
  5986      the Free Software Foundation, either version 3 of the License, or
  5987      (at your option) any later version.
  5988  
  5989      web3.js is distributed in the hope that it will be useful,
  5990      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5991      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5992      GNU Lesser General Public License for more details.
  5993  
  5994      You should have received a copy of the GNU Lesser General Public License
  5995      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5996  */
  5997  /**
  5998   * @file requestmanager.js
  5999   * @author Jeffrey Wilcke <jeff@ethdev.com>
  6000   * @author Marek Kotewicz <marek@ethdev.com>
  6001   * @author Marian Oancea <marian@ethdev.com>
  6002   * @author Fabian Vogelsteller <fabian@ethdev.com>
  6003   * @author Gav Wood <g@ethdev.com>
  6004   * @date 2014
  6005   */
  6006  
  6007  var Jsonrpc = require('./jsonrpc');
  6008  var utils = require('../utils/utils');
  6009  var c = require('../utils/config');
  6010  var errors = require('./errors');
  6011  
  6012  /**
  6013   * It's responsible for passing messages to providers
  6014   * It's also responsible for polling the ethereum node for incoming messages
  6015   * Default poll timeout is 1 second
  6016   * Singleton
  6017   */
  6018  var RequestManager = function (provider) {
  6019      this.provider = provider;
  6020      this.polls = {};
  6021      this.timeout = null;
  6022  };
  6023  
  6024  /**
  6025   * Should be used to synchronously send request
  6026   *
  6027   * @method send
  6028   * @param {Object} data
  6029   * @return {Object}
  6030   */
  6031  RequestManager.prototype.send = function (data) {
  6032      if (!this.provider) {
  6033          console.error(errors.InvalidProvider());
  6034          return null;
  6035      }
  6036  
  6037      var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);
  6038      var result = this.provider.send(payload);
  6039  
  6040      if (!Jsonrpc.getInstance().isValidResponse(result)) {
  6041          throw errors.InvalidResponse(result);
  6042      }
  6043  
  6044      return result.result;
  6045  };
  6046  
  6047  /**
  6048   * Should be used to asynchronously send request
  6049   *
  6050   * @method sendAsync
  6051   * @param {Object} data
  6052   * @param {Function} callback
  6053   */
  6054  RequestManager.prototype.sendAsync = function (data, callback) {
  6055      if (!this.provider) {
  6056          return callback(errors.InvalidProvider());
  6057      }
  6058  
  6059      var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);
  6060      this.provider.sendAsync(payload, function (err, result) {
  6061          if (err) {
  6062              return callback(err);
  6063          }
  6064  
  6065          if (!Jsonrpc.getInstance().isValidResponse(result)) {
  6066              return callback(errors.InvalidResponse(result));
  6067          }
  6068  
  6069          callback(null, result.result);
  6070      });
  6071  };
  6072  
  6073  /**
  6074   * Should be called to asynchronously send batch request
  6075   *
  6076   * @method sendBatch
  6077   * @param {Array} batch data
  6078   * @param {Function} callback
  6079   */
  6080  RequestManager.prototype.sendBatch = function (data, callback) {
  6081      if (!this.provider) {
  6082          return callback(errors.InvalidProvider());
  6083      }
  6084  
  6085      var payload = Jsonrpc.getInstance().toBatchPayload(data);
  6086  
  6087      this.provider.sendAsync(payload, function (err, results) {
  6088          if (err) {
  6089              return callback(err);
  6090          }
  6091  
  6092          if (!utils.isArray(results)) {
  6093              return callback(errors.InvalidResponse(results));
  6094          }
  6095  
  6096          callback(err, results);
  6097      });
  6098  };
  6099  
  6100  /**
  6101   * Should be used to set provider of request manager
  6102   *
  6103   * @method setProvider
  6104   * @param {Object}
  6105   */
  6106  RequestManager.prototype.setProvider = function (p) {
  6107      this.provider = p;
  6108  };
  6109  
  6110  /**
  6111   * Should be used to start polling
  6112   *
  6113   * @method startPolling
  6114   * @param {Object} data
  6115   * @param {Number} pollId
  6116   * @param {Function} callback
  6117   * @param {Function} uninstall
  6118   *
  6119   * @todo cleanup number of params
  6120   */
  6121  RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
  6122      this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
  6123  
  6124  
  6125      // start polling
  6126      if (!this.timeout) {
  6127          this.poll();
  6128      }
  6129  };
  6130  
  6131  /**
  6132   * Should be used to stop polling for filter with given id
  6133   *
  6134   * @method stopPolling
  6135   * @param {Number} pollId
  6136   */
  6137  RequestManager.prototype.stopPolling = function (pollId) {
  6138      delete this.polls[pollId];
  6139  
  6140      // stop polling
  6141      if(Object.keys(this.polls).length === 0 && this.timeout) {
  6142          clearTimeout(this.timeout);
  6143          this.timeout = null;
  6144      }
  6145  };
  6146  
  6147  /**
  6148   * Should be called to reset the polling mechanism of the request manager
  6149   *
  6150   * @method reset
  6151   */
  6152  RequestManager.prototype.reset = function (keepIsSyncing) {
  6153      /*jshint maxcomplexity:5 */
  6154  
  6155      for (var key in this.polls) {
  6156          // remove all polls, except sync polls,
  6157          // they need to be removed manually by calling syncing.stopWatching()
  6158          if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) {
  6159              this.polls[key].uninstall();
  6160              delete this.polls[key];
  6161          }
  6162      }
  6163  
  6164      // stop polling
  6165      if(Object.keys(this.polls).length === 0 && this.timeout) {
  6166          clearTimeout(this.timeout);
  6167          this.timeout = null;
  6168      }
  6169  };
  6170  
  6171  /**
  6172   * Should be called to poll for changes on filter with given id
  6173   *
  6174   * @method poll
  6175   */
  6176  RequestManager.prototype.poll = function () {
  6177      /*jshint maxcomplexity: 6 */
  6178      this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
  6179  
  6180      if (Object.keys(this.polls).length === 0) {
  6181          return;
  6182      }
  6183  
  6184      if (!this.provider) {
  6185          console.error(errors.InvalidProvider());
  6186          return;
  6187      }
  6188  
  6189      var pollsData = [];
  6190      var pollsIds = [];
  6191      for (var key in this.polls) {
  6192          pollsData.push(this.polls[key].data);
  6193          pollsIds.push(key);
  6194      }
  6195  
  6196      if (pollsData.length === 0) {
  6197          return;
  6198      }
  6199  
  6200      var payload = Jsonrpc.getInstance().toBatchPayload(pollsData);
  6201  
  6202      // map the request id to they poll id
  6203      var pollsIdMap = {};
  6204      payload.forEach(function(load, index){
  6205          pollsIdMap[load.id] = pollsIds[index];
  6206      });
  6207  
  6208  
  6209      var self = this;
  6210      this.provider.sendAsync(payload, function (error, results) {
  6211  
  6212  
  6213          // TODO: console log?
  6214          if (error) {
  6215              return;
  6216          }
  6217  
  6218          if (!utils.isArray(results)) {
  6219              throw errors.InvalidResponse(results);
  6220          }
  6221          results.map(function (result) {
  6222              var id = pollsIdMap[result.id];
  6223  
  6224              // make sure the filter is still installed after arrival of the request
  6225              if (self.polls[id]) {
  6226                  result.callback = self.polls[id].callback;
  6227                  return result;
  6228              } else
  6229                  return false;
  6230          }).filter(function (result) {
  6231              return !!result;
  6232          }).filter(function (result) {
  6233              var valid = Jsonrpc.getInstance().isValidResponse(result);
  6234              if (!valid) {
  6235                  result.callback(errors.InvalidResponse(result));
  6236              }
  6237              return valid;
  6238          }).forEach(function (result) {
  6239              result.callback(null, result.result);
  6240          });
  6241      });
  6242  };
  6243  
  6244  module.exports = RequestManager;
  6245  
  6246  
  6247  },{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],46:[function(require,module,exports){
  6248  
  6249  
  6250  var Settings = function () {
  6251      this.defaultBlock = 'latest';
  6252      this.defaultAccount = undefined;
  6253  };
  6254  
  6255  module.exports = Settings;
  6256  
  6257  
  6258  },{}],47:[function(require,module,exports){
  6259  /*
  6260      This file is part of web3.js.
  6261  
  6262      web3.js is free software: you can redistribute it and/or modify
  6263      it under the terms of the GNU Lesser General Public License as published by
  6264      the Free Software Foundation, either version 3 of the License, or
  6265      (at your option) any later version.
  6266  
  6267      web3.js is distributed in the hope that it will be useful,
  6268      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6269      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6270      GNU Lesser General Public License for more details.
  6271  
  6272      You should have received a copy of the GNU Lesser General Public License
  6273      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6274  */
  6275  /** @file syncing.js
  6276   * @authors:
  6277   *   Fabian Vogelsteller <fabian@ethdev.com>
  6278   * @date 2015
  6279   */
  6280  
  6281  var formatters = require('./formatters');
  6282  var utils = require('../utils/utils');
  6283  
  6284  var count = 1;
  6285  
  6286  /**
  6287  Adds the callback and sets up the methods, to iterate over the results.
  6288  
  6289  @method pollSyncing
  6290  @param {Object} self
  6291  */
  6292  var pollSyncing = function(self) {
  6293  
  6294      var onMessage = function (error, sync) {
  6295          if (error) {
  6296              return self.callbacks.forEach(function (callback) {
  6297                  callback(error);
  6298              });
  6299          }
  6300  
  6301          if(utils.isObject(sync) && sync.startingBlock)
  6302              sync = formatters.outputSyncingFormatter(sync);
  6303  
  6304          self.callbacks.forEach(function (callback) {
  6305              if (self.lastSyncState !== sync) {
  6306  
  6307                  // call the callback with true first so the app can stop anything, before receiving the sync data
  6308                  if(!self.lastSyncState && utils.isObject(sync))
  6309                      callback(null, true);
  6310  
  6311                  // call on the next CPU cycle, so the actions of the sync stop can be processes first
  6312                  setTimeout(function() {
  6313                      callback(null, sync);
  6314                  }, 0);
  6315  
  6316                  self.lastSyncState = sync;
  6317              }
  6318          });
  6319      };
  6320  
  6321      self.requestManager.startPolling({
  6322          method: 'eth_syncing',
  6323          params: [],
  6324      }, self.pollId, onMessage, self.stopWatching.bind(self));
  6325  
  6326  };
  6327  
  6328  var IsSyncing = function (requestManager, callback) {
  6329      this.requestManager = requestManager;
  6330      this.pollId = 'syncPoll_'+ count++;
  6331      this.callbacks = [];
  6332      this.addCallback(callback);
  6333      this.lastSyncState = false;
  6334      pollSyncing(this);
  6335  
  6336      return this;
  6337  };
  6338  
  6339  IsSyncing.prototype.addCallback = function (callback) {
  6340      if(callback)
  6341          this.callbacks.push(callback);
  6342      return this;
  6343  };
  6344  
  6345  IsSyncing.prototype.stopWatching = function () {
  6346      this.requestManager.stopPolling(this.pollId);
  6347      this.callbacks = [];
  6348  };
  6349  
  6350  module.exports = IsSyncing;
  6351  
  6352  
  6353  },{"../utils/utils":20,"./formatters":30}],48:[function(require,module,exports){
  6354  /*
  6355      This file is part of web3.js.
  6356  
  6357      web3.js is free software: you can redistribute it and/or modify
  6358      it under the terms of the GNU Lesser General Public License as published by
  6359      the Free Software Foundation, either version 3 of the License, or
  6360      (at your option) any later version.
  6361  
  6362      web3.js is distributed in the hope that it will be useful,
  6363      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6364      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6365      GNU Lesser General Public License for more details.
  6366  
  6367      You should have received a copy of the GNU Lesser General Public License
  6368      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6369  */
  6370  /**
  6371   * @file transfer.js
  6372   * @author Marek Kotewicz <marek@ethdev.com>
  6373   * @date 2015
  6374   */
  6375  
  6376  var Iban = require('./iban');
  6377  var exchangeAbi = require('../contracts/SmartExchange.json');
  6378  
  6379  /**
  6380   * Should be used to make Iban transfer
  6381   *
  6382   * @method transfer
  6383   * @param {String} from
  6384   * @param {String} to iban
  6385   * @param {Value} value to be tranfered
  6386   * @param {Function} callback, callback
  6387   */
  6388  var transfer = function (eth, from, to, value, callback) {
  6389      var iban = new Iban(to);
  6390      if (!iban.isValid()) {
  6391          throw new Error('invalid iban address');
  6392      }
  6393  
  6394      if (iban.isDirect()) {
  6395          return transferToAddress(eth, from, iban.address(), value, callback);
  6396      }
  6397  
  6398      if (!callback) {
  6399          var address = eth.icapNamereg().addr(iban.institution());
  6400          return deposit(eth, from, address, value, iban.client());
  6401      }
  6402  
  6403      eth.icapNamereg().addr(iban.institution(), function (err, address) {
  6404          return deposit(eth, from, address, value, iban.client(), callback);
  6405      });
  6406  
  6407  };
  6408  
  6409  /**
  6410   * Should be used to transfer funds to certain address
  6411   *
  6412   * @method transferToAddress
  6413   * @param {String} from
  6414   * @param {String} to
  6415   * @param {Value} value to be tranfered
  6416   * @param {Function} callback, callback
  6417   */
  6418  var transferToAddress = function (eth, from, to, value, callback) {
  6419      return eth.sendTransaction({
  6420          address: to,
  6421          from: from,
  6422          value: value
  6423      }, callback);
  6424  };
  6425  
  6426  /**
  6427   * Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
  6428   *
  6429   * @method deposit
  6430   * @param {String} from
  6431   * @param {String} to
  6432   * @param {Value} value to be transfered
  6433   * @param {String} client unique identifier
  6434   * @param {Function} callback, callback
  6435   */
  6436  var deposit = function (eth, from, to, value, client, callback) {
  6437      var abi = exchangeAbi;
  6438      return eth.contract(abi).at(to).deposit(client, {
  6439          from: from,
  6440          value: value
  6441      }, callback);
  6442  };
  6443  
  6444  module.exports = transfer;
  6445  
  6446  
  6447  },{"../contracts/SmartExchange.json":3,"./iban":33}],49:[function(require,module,exports){
  6448  
  6449  },{}],50:[function(require,module,exports){
  6450  ;(function (root, factory, undef) {
  6451  	if (typeof exports === "object") {
  6452  		// CommonJS
  6453  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  6454  	}
  6455  	else if (typeof define === "function" && define.amd) {
  6456  		// AMD
  6457  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  6458  	}
  6459  	else {
  6460  		// Global (browser)
  6461  		factory(root.CryptoJS);
  6462  	}
  6463  }(this, function (CryptoJS) {
  6464  
  6465  	(function () {
  6466  	    // Shortcuts
  6467  	    var C = CryptoJS;
  6468  	    var C_lib = C.lib;
  6469  	    var BlockCipher = C_lib.BlockCipher;
  6470  	    var C_algo = C.algo;
  6471  
  6472  	    // Lookup tables
  6473  	    var SBOX = [];
  6474  	    var INV_SBOX = [];
  6475  	    var SUB_MIX_0 = [];
  6476  	    var SUB_MIX_1 = [];
  6477  	    var SUB_MIX_2 = [];
  6478  	    var SUB_MIX_3 = [];
  6479  	    var INV_SUB_MIX_0 = [];
  6480  	    var INV_SUB_MIX_1 = [];
  6481  	    var INV_SUB_MIX_2 = [];
  6482  	    var INV_SUB_MIX_3 = [];
  6483  
  6484  	    // Compute lookup tables
  6485  	    (function () {
  6486  	        // Compute double table
  6487  	        var d = [];
  6488  	        for (var i = 0; i < 256; i++) {
  6489  	            if (i < 128) {
  6490  	                d[i] = i << 1;
  6491  	            } else {
  6492  	                d[i] = (i << 1) ^ 0x11b;
  6493  	            }
  6494  	        }
  6495  
  6496  	        // Walk GF(2^8)
  6497  	        var x = 0;
  6498  	        var xi = 0;
  6499  	        for (var i = 0; i < 256; i++) {
  6500  	            // Compute sbox
  6501  	            var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  6502  	            sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  6503  	            SBOX[x] = sx;
  6504  	            INV_SBOX[sx] = x;
  6505  
  6506  	            // Compute multiplication
  6507  	            var x2 = d[x];
  6508  	            var x4 = d[x2];
  6509  	            var x8 = d[x4];
  6510  
  6511  	            // Compute sub bytes, mix columns tables
  6512  	            var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  6513  	            SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  6514  	            SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  6515  	            SUB_MIX_2[x] = (t << 8)  | (t >>> 24);
  6516  	            SUB_MIX_3[x] = t;
  6517  
  6518  	            // Compute inv sub bytes, inv mix columns tables
  6519  	            var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  6520  	            INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  6521  	            INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  6522  	            INV_SUB_MIX_2[sx] = (t << 8)  | (t >>> 24);
  6523  	            INV_SUB_MIX_3[sx] = t;
  6524  
  6525  	            // Compute next counter
  6526  	            if (!x) {
  6527  	                x = xi = 1;
  6528  	            } else {
  6529  	                x = x2 ^ d[d[d[x8 ^ x2]]];
  6530  	                xi ^= d[d[xi]];
  6531  	            }
  6532  	        }
  6533  	    }());
  6534  
  6535  	    // Precomputed Rcon lookup
  6536  	    var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  6537  
  6538  	    /**
  6539  	     * AES block cipher algorithm.
  6540  	     */
  6541  	    var AES = C_algo.AES = BlockCipher.extend({
  6542  	        _doReset: function () {
  6543  	            // Shortcuts
  6544  	            var key = this._key;
  6545  	            var keyWords = key.words;
  6546  	            var keySize = key.sigBytes / 4;
  6547  
  6548  	            // Compute number of rounds
  6549  	            var nRounds = this._nRounds = keySize + 6
  6550  
  6551  	            // Compute number of key schedule rows
  6552  	            var ksRows = (nRounds + 1) * 4;
  6553  
  6554  	            // Compute key schedule
  6555  	            var keySchedule = this._keySchedule = [];
  6556  	            for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  6557  	                if (ksRow < keySize) {
  6558  	                    keySchedule[ksRow] = keyWords[ksRow];
  6559  	                } else {
  6560  	                    var t = keySchedule[ksRow - 1];
  6561  
  6562  	                    if (!(ksRow % keySize)) {
  6563  	                        // Rot word
  6564  	                        t = (t << 8) | (t >>> 24);
  6565  
  6566  	                        // Sub word
  6567  	                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6568  
  6569  	                        // Mix Rcon
  6570  	                        t ^= RCON[(ksRow / keySize) | 0] << 24;
  6571  	                    } else if (keySize > 6 && ksRow % keySize == 4) {
  6572  	                        // Sub word
  6573  	                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6574  	                    }
  6575  
  6576  	                    keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  6577  	                }
  6578  	            }
  6579  
  6580  	            // Compute inv key schedule
  6581  	            var invKeySchedule = this._invKeySchedule = [];
  6582  	            for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  6583  	                var ksRow = ksRows - invKsRow;
  6584  
  6585  	                if (invKsRow % 4) {
  6586  	                    var t = keySchedule[ksRow];
  6587  	                } else {
  6588  	                    var t = keySchedule[ksRow - 4];
  6589  	                }
  6590  
  6591  	                if (invKsRow < 4 || ksRow <= 4) {
  6592  	                    invKeySchedule[invKsRow] = t;
  6593  	                } else {
  6594  	                    invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  6595  	                                               INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  6596  	                }
  6597  	            }
  6598  	        },
  6599  
  6600  	        encryptBlock: function (M, offset) {
  6601  	            this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  6602  	        },
  6603  
  6604  	        decryptBlock: function (M, offset) {
  6605  	            // Swap 2nd and 4th rows
  6606  	            var t = M[offset + 1];
  6607  	            M[offset + 1] = M[offset + 3];
  6608  	            M[offset + 3] = t;
  6609  
  6610  	            this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  6611  
  6612  	            // Inv swap 2nd and 4th rows
  6613  	            var t = M[offset + 1];
  6614  	            M[offset + 1] = M[offset + 3];
  6615  	            M[offset + 3] = t;
  6616  	        },
  6617  
  6618  	        _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  6619  	            // Shortcut
  6620  	            var nRounds = this._nRounds;
  6621  
  6622  	            // Get input, add round key
  6623  	            var s0 = M[offset]     ^ keySchedule[0];
  6624  	            var s1 = M[offset + 1] ^ keySchedule[1];
  6625  	            var s2 = M[offset + 2] ^ keySchedule[2];
  6626  	            var s3 = M[offset + 3] ^ keySchedule[3];
  6627  
  6628  	            // Key schedule row counter
  6629  	            var ksRow = 4;
  6630  
  6631  	            // Rounds
  6632  	            for (var round = 1; round < nRounds; round++) {
  6633  	                // Shift rows, sub bytes, mix columns, add round key
  6634  	                var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
  6635  	                var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
  6636  	                var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
  6637  	                var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
  6638  
  6639  	                // Update state
  6640  	                s0 = t0;
  6641  	                s1 = t1;
  6642  	                s2 = t2;
  6643  	                s3 = t3;
  6644  	            }
  6645  
  6646  	            // Shift rows, sub bytes, add round key
  6647  	            var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  6648  	            var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  6649  	            var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  6650  	            var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  6651  
  6652  	            // Set output
  6653  	            M[offset]     = t0;
  6654  	            M[offset + 1] = t1;
  6655  	            M[offset + 2] = t2;
  6656  	            M[offset + 3] = t3;
  6657  	        },
  6658  
  6659  	        keySize: 256/32
  6660  	    });
  6661  
  6662  	    /**
  6663  	     * Shortcut functions to the cipher's object interface.
  6664  	     *
  6665  	     * @example
  6666  	     *
  6667  	     *     var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  6668  	     *     var plaintext  = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  6669  	     */
  6670  	    C.AES = BlockCipher._createHelper(AES);
  6671  	}());
  6672  
  6673  
  6674  	return CryptoJS.AES;
  6675  
  6676  }));
  6677  },{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],51:[function(require,module,exports){
  6678  ;(function (root, factory) {
  6679  	if (typeof exports === "object") {
  6680  		// CommonJS
  6681  		module.exports = exports = factory(require("./core"));
  6682  	}
  6683  	else if (typeof define === "function" && define.amd) {
  6684  		// AMD
  6685  		define(["./core"], factory);
  6686  	}
  6687  	else {
  6688  		// Global (browser)
  6689  		factory(root.CryptoJS);
  6690  	}
  6691  }(this, function (CryptoJS) {
  6692  
  6693  	/**
  6694  	 * Cipher core components.
  6695  	 */
  6696  	CryptoJS.lib.Cipher || (function (undefined) {
  6697  	    // Shortcuts
  6698  	    var C = CryptoJS;
  6699  	    var C_lib = C.lib;
  6700  	    var Base = C_lib.Base;
  6701  	    var WordArray = C_lib.WordArray;
  6702  	    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  6703  	    var C_enc = C.enc;
  6704  	    var Utf8 = C_enc.Utf8;
  6705  	    var Base64 = C_enc.Base64;
  6706  	    var C_algo = C.algo;
  6707  	    var EvpKDF = C_algo.EvpKDF;
  6708  
  6709  	    /**
  6710  	     * Abstract base cipher template.
  6711  	     *
  6712  	     * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  6713  	     * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  6714  	     * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  6715  	     * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  6716  	     */
  6717  	    var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  6718  	        /**
  6719  	         * Configuration options.
  6720  	         *
  6721  	         * @property {WordArray} iv The IV to use for this operation.
  6722  	         */
  6723  	        cfg: Base.extend(),
  6724  
  6725  	        /**
  6726  	         * Creates this cipher in encryption mode.
  6727  	         *
  6728  	         * @param {WordArray} key The key.
  6729  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6730  	         *
  6731  	         * @return {Cipher} A cipher instance.
  6732  	         *
  6733  	         * @static
  6734  	         *
  6735  	         * @example
  6736  	         *
  6737  	         *     var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  6738  	         */
  6739  	        createEncryptor: function (key, cfg) {
  6740  	            return this.create(this._ENC_XFORM_MODE, key, cfg);
  6741  	        },
  6742  
  6743  	        /**
  6744  	         * Creates this cipher in decryption mode.
  6745  	         *
  6746  	         * @param {WordArray} key The key.
  6747  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6748  	         *
  6749  	         * @return {Cipher} A cipher instance.
  6750  	         *
  6751  	         * @static
  6752  	         *
  6753  	         * @example
  6754  	         *
  6755  	         *     var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  6756  	         */
  6757  	        createDecryptor: function (key, cfg) {
  6758  	            return this.create(this._DEC_XFORM_MODE, key, cfg);
  6759  	        },
  6760  
  6761  	        /**
  6762  	         * Initializes a newly created cipher.
  6763  	         *
  6764  	         * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  6765  	         * @param {WordArray} key The key.
  6766  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6767  	         *
  6768  	         * @example
  6769  	         *
  6770  	         *     var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  6771  	         */
  6772  	        init: function (xformMode, key, cfg) {
  6773  	            // Apply config defaults
  6774  	            this.cfg = this.cfg.extend(cfg);
  6775  
  6776  	            // Store transform mode and key
  6777  	            this._xformMode = xformMode;
  6778  	            this._key = key;
  6779  
  6780  	            // Set initial values
  6781  	            this.reset();
  6782  	        },
  6783  
  6784  	        /**
  6785  	         * Resets this cipher to its initial state.
  6786  	         *
  6787  	         * @example
  6788  	         *
  6789  	         *     cipher.reset();
  6790  	         */
  6791  	        reset: function () {
  6792  	            // Reset data buffer
  6793  	            BufferedBlockAlgorithm.reset.call(this);
  6794  
  6795  	            // Perform concrete-cipher logic
  6796  	            this._doReset();
  6797  	        },
  6798  
  6799  	        /**
  6800  	         * Adds data to be encrypted or decrypted.
  6801  	         *
  6802  	         * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  6803  	         *
  6804  	         * @return {WordArray} The data after processing.
  6805  	         *
  6806  	         * @example
  6807  	         *
  6808  	         *     var encrypted = cipher.process('data');
  6809  	         *     var encrypted = cipher.process(wordArray);
  6810  	         */
  6811  	        process: function (dataUpdate) {
  6812  	            // Append
  6813  	            this._append(dataUpdate);
  6814  
  6815  	            // Process available blocks
  6816  	            return this._process();
  6817  	        },
  6818  
  6819  	        /**
  6820  	         * Finalizes the encryption or decryption process.
  6821  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  6822  	         *
  6823  	         * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  6824  	         *
  6825  	         * @return {WordArray} The data after final processing.
  6826  	         *
  6827  	         * @example
  6828  	         *
  6829  	         *     var encrypted = cipher.finalize();
  6830  	         *     var encrypted = cipher.finalize('data');
  6831  	         *     var encrypted = cipher.finalize(wordArray);
  6832  	         */
  6833  	        finalize: function (dataUpdate) {
  6834  	            // Final data update
  6835  	            if (dataUpdate) {
  6836  	                this._append(dataUpdate);
  6837  	            }
  6838  
  6839  	            // Perform concrete-cipher logic
  6840  	            var finalProcessedData = this._doFinalize();
  6841  
  6842  	            return finalProcessedData;
  6843  	        },
  6844  
  6845  	        keySize: 128/32,
  6846  
  6847  	        ivSize: 128/32,
  6848  
  6849  	        _ENC_XFORM_MODE: 1,
  6850  
  6851  	        _DEC_XFORM_MODE: 2,
  6852  
  6853  	        /**
  6854  	         * Creates shortcut functions to a cipher's object interface.
  6855  	         *
  6856  	         * @param {Cipher} cipher The cipher to create a helper for.
  6857  	         *
  6858  	         * @return {Object} An object with encrypt and decrypt shortcut functions.
  6859  	         *
  6860  	         * @static
  6861  	         *
  6862  	         * @example
  6863  	         *
  6864  	         *     var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  6865  	         */
  6866  	        _createHelper: (function () {
  6867  	            function selectCipherStrategy(key) {
  6868  	                if (typeof key == 'string') {
  6869  	                    return PasswordBasedCipher;
  6870  	                } else {
  6871  	                    return SerializableCipher;
  6872  	                }
  6873  	            }
  6874  
  6875  	            return function (cipher) {
  6876  	                return {
  6877  	                    encrypt: function (message, key, cfg) {
  6878  	                        return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  6879  	                    },
  6880  
  6881  	                    decrypt: function (ciphertext, key, cfg) {
  6882  	                        return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  6883  	                    }
  6884  	                };
  6885  	            };
  6886  	        }())
  6887  	    });
  6888  
  6889  	    /**
  6890  	     * Abstract base stream cipher template.
  6891  	     *
  6892  	     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  6893  	     */
  6894  	    var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  6895  	        _doFinalize: function () {
  6896  	            // Process partial blocks
  6897  	            var finalProcessedBlocks = this._process(!!'flush');
  6898  
  6899  	            return finalProcessedBlocks;
  6900  	        },
  6901  
  6902  	        blockSize: 1
  6903  	    });
  6904  
  6905  	    /**
  6906  	     * Mode namespace.
  6907  	     */
  6908  	    var C_mode = C.mode = {};
  6909  
  6910  	    /**
  6911  	     * Abstract base block cipher mode template.
  6912  	     */
  6913  	    var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  6914  	        /**
  6915  	         * Creates this mode for encryption.
  6916  	         *
  6917  	         * @param {Cipher} cipher A block cipher instance.
  6918  	         * @param {Array} iv The IV words.
  6919  	         *
  6920  	         * @static
  6921  	         *
  6922  	         * @example
  6923  	         *
  6924  	         *     var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  6925  	         */
  6926  	        createEncryptor: function (cipher, iv) {
  6927  	            return this.Encryptor.create(cipher, iv);
  6928  	        },
  6929  
  6930  	        /**
  6931  	         * Creates this mode for decryption.
  6932  	         *
  6933  	         * @param {Cipher} cipher A block cipher instance.
  6934  	         * @param {Array} iv The IV words.
  6935  	         *
  6936  	         * @static
  6937  	         *
  6938  	         * @example
  6939  	         *
  6940  	         *     var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  6941  	         */
  6942  	        createDecryptor: function (cipher, iv) {
  6943  	            return this.Decryptor.create(cipher, iv);
  6944  	        },
  6945  
  6946  	        /**
  6947  	         * Initializes a newly created mode.
  6948  	         *
  6949  	         * @param {Cipher} cipher A block cipher instance.
  6950  	         * @param {Array} iv The IV words.
  6951  	         *
  6952  	         * @example
  6953  	         *
  6954  	         *     var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  6955  	         */
  6956  	        init: function (cipher, iv) {
  6957  	            this._cipher = cipher;
  6958  	            this._iv = iv;
  6959  	        }
  6960  	    });
  6961  
  6962  	    /**
  6963  	     * Cipher Block Chaining mode.
  6964  	     */
  6965  	    var CBC = C_mode.CBC = (function () {
  6966  	        /**
  6967  	         * Abstract base CBC mode.
  6968  	         */
  6969  	        var CBC = BlockCipherMode.extend();
  6970  
  6971  	        /**
  6972  	         * CBC encryptor.
  6973  	         */
  6974  	        CBC.Encryptor = CBC.extend({
  6975  	            /**
  6976  	             * Processes the data block at offset.
  6977  	             *
  6978  	             * @param {Array} words The data words to operate on.
  6979  	             * @param {number} offset The offset where the block starts.
  6980  	             *
  6981  	             * @example
  6982  	             *
  6983  	             *     mode.processBlock(data.words, offset);
  6984  	             */
  6985  	            processBlock: function (words, offset) {
  6986  	                // Shortcuts
  6987  	                var cipher = this._cipher;
  6988  	                var blockSize = cipher.blockSize;
  6989  
  6990  	                // XOR and encrypt
  6991  	                xorBlock.call(this, words, offset, blockSize);
  6992  	                cipher.encryptBlock(words, offset);
  6993  
  6994  	                // Remember this block to use with next block
  6995  	                this._prevBlock = words.slice(offset, offset + blockSize);
  6996  	            }
  6997  	        });
  6998  
  6999  	        /**
  7000  	         * CBC decryptor.
  7001  	         */
  7002  	        CBC.Decryptor = CBC.extend({
  7003  	            /**
  7004  	             * Processes the data block at offset.
  7005  	             *
  7006  	             * @param {Array} words The data words to operate on.
  7007  	             * @param {number} offset The offset where the block starts.
  7008  	             *
  7009  	             * @example
  7010  	             *
  7011  	             *     mode.processBlock(data.words, offset);
  7012  	             */
  7013  	            processBlock: function (words, offset) {
  7014  	                // Shortcuts
  7015  	                var cipher = this._cipher;
  7016  	                var blockSize = cipher.blockSize;
  7017  
  7018  	                // Remember this block to use with next block
  7019  	                var thisBlock = words.slice(offset, offset + blockSize);
  7020  
  7021  	                // Decrypt and XOR
  7022  	                cipher.decryptBlock(words, offset);
  7023  	                xorBlock.call(this, words, offset, blockSize);
  7024  
  7025  	                // This block becomes the previous block
  7026  	                this._prevBlock = thisBlock;
  7027  	            }
  7028  	        });
  7029  
  7030  	        function xorBlock(words, offset, blockSize) {
  7031  	            // Shortcut
  7032  	            var iv = this._iv;
  7033  
  7034  	            // Choose mixing block
  7035  	            if (iv) {
  7036  	                var block = iv;
  7037  
  7038  	                // Remove IV for subsequent blocks
  7039  	                this._iv = undefined;
  7040  	            } else {
  7041  	                var block = this._prevBlock;
  7042  	            }
  7043  
  7044  	            // XOR blocks
  7045  	            for (var i = 0; i < blockSize; i++) {
  7046  	                words[offset + i] ^= block[i];
  7047  	            }
  7048  	        }
  7049  
  7050  	        return CBC;
  7051  	    }());
  7052  
  7053  	    /**
  7054  	     * Padding namespace.
  7055  	     */
  7056  	    var C_pad = C.pad = {};
  7057  
  7058  	    /**
  7059  	     * PKCS #5/7 padding strategy.
  7060  	     */
  7061  	    var Pkcs7 = C_pad.Pkcs7 = {
  7062  	        /**
  7063  	         * Pads data using the algorithm defined in PKCS #5/7.
  7064  	         *
  7065  	         * @param {WordArray} data The data to pad.
  7066  	         * @param {number} blockSize The multiple that the data should be padded to.
  7067  	         *
  7068  	         * @static
  7069  	         *
  7070  	         * @example
  7071  	         *
  7072  	         *     CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  7073  	         */
  7074  	        pad: function (data, blockSize) {
  7075  	            // Shortcut
  7076  	            var blockSizeBytes = blockSize * 4;
  7077  
  7078  	            // Count padding bytes
  7079  	            var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  7080  
  7081  	            // Create padding word
  7082  	            var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  7083  
  7084  	            // Create padding
  7085  	            var paddingWords = [];
  7086  	            for (var i = 0; i < nPaddingBytes; i += 4) {
  7087  	                paddingWords.push(paddingWord);
  7088  	            }
  7089  	            var padding = WordArray.create(paddingWords, nPaddingBytes);
  7090  
  7091  	            // Add padding
  7092  	            data.concat(padding);
  7093  	        },
  7094  
  7095  	        /**
  7096  	         * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  7097  	         *
  7098  	         * @param {WordArray} data The data to unpad.
  7099  	         *
  7100  	         * @static
  7101  	         *
  7102  	         * @example
  7103  	         *
  7104  	         *     CryptoJS.pad.Pkcs7.unpad(wordArray);
  7105  	         */
  7106  	        unpad: function (data) {
  7107  	            // Get number of padding bytes from last byte
  7108  	            var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  7109  
  7110  	            // Remove padding
  7111  	            data.sigBytes -= nPaddingBytes;
  7112  	        }
  7113  	    };
  7114  
  7115  	    /**
  7116  	     * Abstract base block cipher template.
  7117  	     *
  7118  	     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  7119  	     */
  7120  	    var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  7121  	        /**
  7122  	         * Configuration options.
  7123  	         *
  7124  	         * @property {Mode} mode The block mode to use. Default: CBC
  7125  	         * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  7126  	         */
  7127  	        cfg: Cipher.cfg.extend({
  7128  	            mode: CBC,
  7129  	            padding: Pkcs7
  7130  	        }),
  7131  
  7132  	        reset: function () {
  7133  	            // Reset cipher
  7134  	            Cipher.reset.call(this);
  7135  
  7136  	            // Shortcuts
  7137  	            var cfg = this.cfg;
  7138  	            var iv = cfg.iv;
  7139  	            var mode = cfg.mode;
  7140  
  7141  	            // Reset block mode
  7142  	            if (this._xformMode == this._ENC_XFORM_MODE) {
  7143  	                var modeCreator = mode.createEncryptor;
  7144  	            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7145  	                var modeCreator = mode.createDecryptor;
  7146  
  7147  	                // Keep at least one block in the buffer for unpadding
  7148  	                this._minBufferSize = 1;
  7149  	            }
  7150  	            this._mode = modeCreator.call(mode, this, iv && iv.words);
  7151  	        },
  7152  
  7153  	        _doProcessBlock: function (words, offset) {
  7154  	            this._mode.processBlock(words, offset);
  7155  	        },
  7156  
  7157  	        _doFinalize: function () {
  7158  	            // Shortcut
  7159  	            var padding = this.cfg.padding;
  7160  
  7161  	            // Finalize
  7162  	            if (this._xformMode == this._ENC_XFORM_MODE) {
  7163  	                // Pad data
  7164  	                padding.pad(this._data, this.blockSize);
  7165  
  7166  	                // Process final blocks
  7167  	                var finalProcessedBlocks = this._process(!!'flush');
  7168  	            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7169  	                // Process final blocks
  7170  	                var finalProcessedBlocks = this._process(!!'flush');
  7171  
  7172  	                // Unpad data
  7173  	                padding.unpad(finalProcessedBlocks);
  7174  	            }
  7175  
  7176  	            return finalProcessedBlocks;
  7177  	        },
  7178  
  7179  	        blockSize: 128/32
  7180  	    });
  7181  
  7182  	    /**
  7183  	     * A collection of cipher parameters.
  7184  	     *
  7185  	     * @property {WordArray} ciphertext The raw ciphertext.
  7186  	     * @property {WordArray} key The key to this ciphertext.
  7187  	     * @property {WordArray} iv The IV used in the ciphering operation.
  7188  	     * @property {WordArray} salt The salt used with a key derivation function.
  7189  	     * @property {Cipher} algorithm The cipher algorithm.
  7190  	     * @property {Mode} mode The block mode used in the ciphering operation.
  7191  	     * @property {Padding} padding The padding scheme used in the ciphering operation.
  7192  	     * @property {number} blockSize The block size of the cipher.
  7193  	     * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  7194  	     */
  7195  	    var CipherParams = C_lib.CipherParams = Base.extend({
  7196  	        /**
  7197  	         * Initializes a newly created cipher params object.
  7198  	         *
  7199  	         * @param {Object} cipherParams An object with any of the possible cipher parameters.
  7200  	         *
  7201  	         * @example
  7202  	         *
  7203  	         *     var cipherParams = CryptoJS.lib.CipherParams.create({
  7204  	         *         ciphertext: ciphertextWordArray,
  7205  	         *         key: keyWordArray,
  7206  	         *         iv: ivWordArray,
  7207  	         *         salt: saltWordArray,
  7208  	         *         algorithm: CryptoJS.algo.AES,
  7209  	         *         mode: CryptoJS.mode.CBC,
  7210  	         *         padding: CryptoJS.pad.PKCS7,
  7211  	         *         blockSize: 4,
  7212  	         *         formatter: CryptoJS.format.OpenSSL
  7213  	         *     });
  7214  	         */
  7215  	        init: function (cipherParams) {
  7216  	            this.mixIn(cipherParams);
  7217  	        },
  7218  
  7219  	        /**
  7220  	         * Converts this cipher params object to a string.
  7221  	         *
  7222  	         * @param {Format} formatter (Optional) The formatting strategy to use.
  7223  	         *
  7224  	         * @return {string} The stringified cipher params.
  7225  	         *
  7226  	         * @throws Error If neither the formatter nor the default formatter is set.
  7227  	         *
  7228  	         * @example
  7229  	         *
  7230  	         *     var string = cipherParams + '';
  7231  	         *     var string = cipherParams.toString();
  7232  	         *     var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  7233  	         */
  7234  	        toString: function (formatter) {
  7235  	            return (formatter || this.formatter).stringify(this);
  7236  	        }
  7237  	    });
  7238  
  7239  	    /**
  7240  	     * Format namespace.
  7241  	     */
  7242  	    var C_format = C.format = {};
  7243  
  7244  	    /**
  7245  	     * OpenSSL formatting strategy.
  7246  	     */
  7247  	    var OpenSSLFormatter = C_format.OpenSSL = {
  7248  	        /**
  7249  	         * Converts a cipher params object to an OpenSSL-compatible string.
  7250  	         *
  7251  	         * @param {CipherParams} cipherParams The cipher params object.
  7252  	         *
  7253  	         * @return {string} The OpenSSL-compatible string.
  7254  	         *
  7255  	         * @static
  7256  	         *
  7257  	         * @example
  7258  	         *
  7259  	         *     var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  7260  	         */
  7261  	        stringify: function (cipherParams) {
  7262  	            // Shortcuts
  7263  	            var ciphertext = cipherParams.ciphertext;
  7264  	            var salt = cipherParams.salt;
  7265  
  7266  	            // Format
  7267  	            if (salt) {
  7268  	                var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  7269  	            } else {
  7270  	                var wordArray = ciphertext;
  7271  	            }
  7272  
  7273  	            return wordArray.toString(Base64);
  7274  	        },
  7275  
  7276  	        /**
  7277  	         * Converts an OpenSSL-compatible string to a cipher params object.
  7278  	         *
  7279  	         * @param {string} openSSLStr The OpenSSL-compatible string.
  7280  	         *
  7281  	         * @return {CipherParams} The cipher params object.
  7282  	         *
  7283  	         * @static
  7284  	         *
  7285  	         * @example
  7286  	         *
  7287  	         *     var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  7288  	         */
  7289  	        parse: function (openSSLStr) {
  7290  	            // Parse base64
  7291  	            var ciphertext = Base64.parse(openSSLStr);
  7292  
  7293  	            // Shortcut
  7294  	            var ciphertextWords = ciphertext.words;
  7295  
  7296  	            // Test for salt
  7297  	            if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  7298  	                // Extract salt
  7299  	                var salt = WordArray.create(ciphertextWords.slice(2, 4));
  7300  
  7301  	                // Remove salt from ciphertext
  7302  	                ciphertextWords.splice(0, 4);
  7303  	                ciphertext.sigBytes -= 16;
  7304  	            }
  7305  
  7306  	            return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  7307  	        }
  7308  	    };
  7309  
  7310  	    /**
  7311  	     * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  7312  	     */
  7313  	    var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  7314  	        /**
  7315  	         * Configuration options.
  7316  	         *
  7317  	         * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  7318  	         */
  7319  	        cfg: Base.extend({
  7320  	            format: OpenSSLFormatter
  7321  	        }),
  7322  
  7323  	        /**
  7324  	         * Encrypts a message.
  7325  	         *
  7326  	         * @param {Cipher} cipher The cipher algorithm to use.
  7327  	         * @param {WordArray|string} message The message to encrypt.
  7328  	         * @param {WordArray} key The key.
  7329  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7330  	         *
  7331  	         * @return {CipherParams} A cipher params object.
  7332  	         *
  7333  	         * @static
  7334  	         *
  7335  	         * @example
  7336  	         *
  7337  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  7338  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  7339  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7340  	         */
  7341  	        encrypt: function (cipher, message, key, cfg) {
  7342  	            // Apply config defaults
  7343  	            cfg = this.cfg.extend(cfg);
  7344  
  7345  	            // Encrypt
  7346  	            var encryptor = cipher.createEncryptor(key, cfg);
  7347  	            var ciphertext = encryptor.finalize(message);
  7348  
  7349  	            // Shortcut
  7350  	            var cipherCfg = encryptor.cfg;
  7351  
  7352  	            // Create and return serializable cipher params
  7353  	            return CipherParams.create({
  7354  	                ciphertext: ciphertext,
  7355  	                key: key,
  7356  	                iv: cipherCfg.iv,
  7357  	                algorithm: cipher,
  7358  	                mode: cipherCfg.mode,
  7359  	                padding: cipherCfg.padding,
  7360  	                blockSize: cipher.blockSize,
  7361  	                formatter: cfg.format
  7362  	            });
  7363  	        },
  7364  
  7365  	        /**
  7366  	         * Decrypts serialized ciphertext.
  7367  	         *
  7368  	         * @param {Cipher} cipher The cipher algorithm to use.
  7369  	         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7370  	         * @param {WordArray} key The key.
  7371  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7372  	         *
  7373  	         * @return {WordArray} The plaintext.
  7374  	         *
  7375  	         * @static
  7376  	         *
  7377  	         * @example
  7378  	         *
  7379  	         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7380  	         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7381  	         */
  7382  	        decrypt: function (cipher, ciphertext, key, cfg) {
  7383  	            // Apply config defaults
  7384  	            cfg = this.cfg.extend(cfg);
  7385  
  7386  	            // Convert string to CipherParams
  7387  	            ciphertext = this._parse(ciphertext, cfg.format);
  7388  
  7389  	            // Decrypt
  7390  	            var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  7391  
  7392  	            return plaintext;
  7393  	        },
  7394  
  7395  	        /**
  7396  	         * Converts serialized ciphertext to CipherParams,
  7397  	         * else assumed CipherParams already and returns ciphertext unchanged.
  7398  	         *
  7399  	         * @param {CipherParams|string} ciphertext The ciphertext.
  7400  	         * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  7401  	         *
  7402  	         * @return {CipherParams} The unserialized ciphertext.
  7403  	         *
  7404  	         * @static
  7405  	         *
  7406  	         * @example
  7407  	         *
  7408  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  7409  	         */
  7410  	        _parse: function (ciphertext, format) {
  7411  	            if (typeof ciphertext == 'string') {
  7412  	                return format.parse(ciphertext, this);
  7413  	            } else {
  7414  	                return ciphertext;
  7415  	            }
  7416  	        }
  7417  	    });
  7418  
  7419  	    /**
  7420  	     * Key derivation function namespace.
  7421  	     */
  7422  	    var C_kdf = C.kdf = {};
  7423  
  7424  	    /**
  7425  	     * OpenSSL key derivation function.
  7426  	     */
  7427  	    var OpenSSLKdf = C_kdf.OpenSSL = {
  7428  	        /**
  7429  	         * Derives a key and IV from a password.
  7430  	         *
  7431  	         * @param {string} password The password to derive from.
  7432  	         * @param {number} keySize The size in words of the key to generate.
  7433  	         * @param {number} ivSize The size in words of the IV to generate.
  7434  	         * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  7435  	         *
  7436  	         * @return {CipherParams} A cipher params object with the key, IV, and salt.
  7437  	         *
  7438  	         * @static
  7439  	         *
  7440  	         * @example
  7441  	         *
  7442  	         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  7443  	         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  7444  	         */
  7445  	        execute: function (password, keySize, ivSize, salt) {
  7446  	            // Generate random salt
  7447  	            if (!salt) {
  7448  	                salt = WordArray.random(64/8);
  7449  	            }
  7450  
  7451  	            // Derive key and IV
  7452  	            var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  7453  
  7454  	            // Separate key and IV
  7455  	            var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  7456  	            key.sigBytes = keySize * 4;
  7457  
  7458  	            // Return params
  7459  	            return CipherParams.create({ key: key, iv: iv, salt: salt });
  7460  	        }
  7461  	    };
  7462  
  7463  	    /**
  7464  	     * A serializable cipher wrapper that derives the key from a password,
  7465  	     * and returns ciphertext as a serializable cipher params object.
  7466  	     */
  7467  	    var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  7468  	        /**
  7469  	         * Configuration options.
  7470  	         *
  7471  	         * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  7472  	         */
  7473  	        cfg: SerializableCipher.cfg.extend({
  7474  	            kdf: OpenSSLKdf
  7475  	        }),
  7476  
  7477  	        /**
  7478  	         * Encrypts a message using a password.
  7479  	         *
  7480  	         * @param {Cipher} cipher The cipher algorithm to use.
  7481  	         * @param {WordArray|string} message The message to encrypt.
  7482  	         * @param {string} password The password.
  7483  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7484  	         *
  7485  	         * @return {CipherParams} A cipher params object.
  7486  	         *
  7487  	         * @static
  7488  	         *
  7489  	         * @example
  7490  	         *
  7491  	         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  7492  	         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  7493  	         */
  7494  	        encrypt: function (cipher, message, password, cfg) {
  7495  	            // Apply config defaults
  7496  	            cfg = this.cfg.extend(cfg);
  7497  
  7498  	            // Derive key and other params
  7499  	            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  7500  
  7501  	            // Add IV to config
  7502  	            cfg.iv = derivedParams.iv;
  7503  
  7504  	            // Encrypt
  7505  	            var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  7506  
  7507  	            // Mix in derived params
  7508  	            ciphertext.mixIn(derivedParams);
  7509  
  7510  	            return ciphertext;
  7511  	        },
  7512  
  7513  	        /**
  7514  	         * Decrypts serialized ciphertext using a password.
  7515  	         *
  7516  	         * @param {Cipher} cipher The cipher algorithm to use.
  7517  	         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7518  	         * @param {string} password The password.
  7519  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7520  	         *
  7521  	         * @return {WordArray} The plaintext.
  7522  	         *
  7523  	         * @static
  7524  	         *
  7525  	         * @example
  7526  	         *
  7527  	         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  7528  	         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  7529  	         */
  7530  	        decrypt: function (cipher, ciphertext, password, cfg) {
  7531  	            // Apply config defaults
  7532  	            cfg = this.cfg.extend(cfg);
  7533  
  7534  	            // Convert string to CipherParams
  7535  	            ciphertext = this._parse(ciphertext, cfg.format);
  7536  
  7537  	            // Derive key and other params
  7538  	            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  7539  
  7540  	            // Add IV to config
  7541  	            cfg.iv = derivedParams.iv;
  7542  
  7543  	            // Decrypt
  7544  	            var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  7545  
  7546  	            return plaintext;
  7547  	        }
  7548  	    });
  7549  	}());
  7550  
  7551  
  7552  }));
  7553  },{"./core":52}],52:[function(require,module,exports){
  7554  ;(function (root, factory) {
  7555  	if (typeof exports === "object") {
  7556  		// CommonJS
  7557  		module.exports = exports = factory();
  7558  	}
  7559  	else if (typeof define === "function" && define.amd) {
  7560  		// AMD
  7561  		define([], factory);
  7562  	}
  7563  	else {
  7564  		// Global (browser)
  7565  		root.CryptoJS = factory();
  7566  	}
  7567  }(this, function () {
  7568  
  7569  	/**
  7570  	 * CryptoJS core components.
  7571  	 */
  7572  	var CryptoJS = CryptoJS || (function (Math, undefined) {
  7573  	    /**
  7574  	     * CryptoJS namespace.
  7575  	     */
  7576  	    var C = {};
  7577  
  7578  	    /**
  7579  	     * Library namespace.
  7580  	     */
  7581  	    var C_lib = C.lib = {};
  7582  
  7583  	    /**
  7584  	     * Base object for prototypal inheritance.
  7585  	     */
  7586  	    var Base = C_lib.Base = (function () {
  7587  	        function F() {}
  7588  
  7589  	        return {
  7590  	            /**
  7591  	             * Creates a new object that inherits from this object.
  7592  	             *
  7593  	             * @param {Object} overrides Properties to copy into the new object.
  7594  	             *
  7595  	             * @return {Object} The new object.
  7596  	             *
  7597  	             * @static
  7598  	             *
  7599  	             * @example
  7600  	             *
  7601  	             *     var MyType = CryptoJS.lib.Base.extend({
  7602  	             *         field: 'value',
  7603  	             *
  7604  	             *         method: function () {
  7605  	             *         }
  7606  	             *     });
  7607  	             */
  7608  	            extend: function (overrides) {
  7609  	                // Spawn
  7610  	                F.prototype = this;
  7611  	                var subtype = new F();
  7612  
  7613  	                // Augment
  7614  	                if (overrides) {
  7615  	                    subtype.mixIn(overrides);
  7616  	                }
  7617  
  7618  	                // Create default initializer
  7619  	                if (!subtype.hasOwnProperty('init')) {
  7620  	                    subtype.init = function () {
  7621  	                        subtype.$super.init.apply(this, arguments);
  7622  	                    };
  7623  	                }
  7624  
  7625  	                // Initializer's prototype is the subtype object
  7626  	                subtype.init.prototype = subtype;
  7627  
  7628  	                // Reference supertype
  7629  	                subtype.$super = this;
  7630  
  7631  	                return subtype;
  7632  	            },
  7633  
  7634  	            /**
  7635  	             * Extends this object and runs the init method.
  7636  	             * Arguments to create() will be passed to init().
  7637  	             *
  7638  	             * @return {Object} The new object.
  7639  	             *
  7640  	             * @static
  7641  	             *
  7642  	             * @example
  7643  	             *
  7644  	             *     var instance = MyType.create();
  7645  	             */
  7646  	            create: function () {
  7647  	                var instance = this.extend();
  7648  	                instance.init.apply(instance, arguments);
  7649  
  7650  	                return instance;
  7651  	            },
  7652  
  7653  	            /**
  7654  	             * Initializes a newly created object.
  7655  	             * Override this method to add some logic when your objects are created.
  7656  	             *
  7657  	             * @example
  7658  	             *
  7659  	             *     var MyType = CryptoJS.lib.Base.extend({
  7660  	             *         init: function () {
  7661  	             *             // ...
  7662  	             *         }
  7663  	             *     });
  7664  	             */
  7665  	            init: function () {
  7666  	            },
  7667  
  7668  	            /**
  7669  	             * Copies properties into this object.
  7670  	             *
  7671  	             * @param {Object} properties The properties to mix in.
  7672  	             *
  7673  	             * @example
  7674  	             *
  7675  	             *     MyType.mixIn({
  7676  	             *         field: 'value'
  7677  	             *     });
  7678  	             */
  7679  	            mixIn: function (properties) {
  7680  	                for (var propertyName in properties) {
  7681  	                    if (properties.hasOwnProperty(propertyName)) {
  7682  	                        this[propertyName] = properties[propertyName];
  7683  	                    }
  7684  	                }
  7685  
  7686  	                // IE won't copy toString using the loop above
  7687  	                if (properties.hasOwnProperty('toString')) {
  7688  	                    this.toString = properties.toString;
  7689  	                }
  7690  	            },
  7691  
  7692  	            /**
  7693  	             * Creates a copy of this object.
  7694  	             *
  7695  	             * @return {Object} The clone.
  7696  	             *
  7697  	             * @example
  7698  	             *
  7699  	             *     var clone = instance.clone();
  7700  	             */
  7701  	            clone: function () {
  7702  	                return this.init.prototype.extend(this);
  7703  	            }
  7704  	        };
  7705  	    }());
  7706  
  7707  	    /**
  7708  	     * An array of 32-bit words.
  7709  	     *
  7710  	     * @property {Array} words The array of 32-bit words.
  7711  	     * @property {number} sigBytes The number of significant bytes in this word array.
  7712  	     */
  7713  	    var WordArray = C_lib.WordArray = Base.extend({
  7714  	        /**
  7715  	         * Initializes a newly created word array.
  7716  	         *
  7717  	         * @param {Array} words (Optional) An array of 32-bit words.
  7718  	         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  7719  	         *
  7720  	         * @example
  7721  	         *
  7722  	         *     var wordArray = CryptoJS.lib.WordArray.create();
  7723  	         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  7724  	         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  7725  	         */
  7726  	        init: function (words, sigBytes) {
  7727  	            words = this.words = words || [];
  7728  
  7729  	            if (sigBytes != undefined) {
  7730  	                this.sigBytes = sigBytes;
  7731  	            } else {
  7732  	                this.sigBytes = words.length * 4;
  7733  	            }
  7734  	        },
  7735  
  7736  	        /**
  7737  	         * Converts this word array to a string.
  7738  	         *
  7739  	         * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  7740  	         *
  7741  	         * @return {string} The stringified word array.
  7742  	         *
  7743  	         * @example
  7744  	         *
  7745  	         *     var string = wordArray + '';
  7746  	         *     var string = wordArray.toString();
  7747  	         *     var string = wordArray.toString(CryptoJS.enc.Utf8);
  7748  	         */
  7749  	        toString: function (encoder) {
  7750  	            return (encoder || Hex).stringify(this);
  7751  	        },
  7752  
  7753  	        /**
  7754  	         * Concatenates a word array to this word array.
  7755  	         *
  7756  	         * @param {WordArray} wordArray The word array to append.
  7757  	         *
  7758  	         * @return {WordArray} This word array.
  7759  	         *
  7760  	         * @example
  7761  	         *
  7762  	         *     wordArray1.concat(wordArray2);
  7763  	         */
  7764  	        concat: function (wordArray) {
  7765  	            // Shortcuts
  7766  	            var thisWords = this.words;
  7767  	            var thatWords = wordArray.words;
  7768  	            var thisSigBytes = this.sigBytes;
  7769  	            var thatSigBytes = wordArray.sigBytes;
  7770  
  7771  	            // Clamp excess bits
  7772  	            this.clamp();
  7773  
  7774  	            // Concat
  7775  	            if (thisSigBytes % 4) {
  7776  	                // Copy one byte at a time
  7777  	                for (var i = 0; i < thatSigBytes; i++) {
  7778  	                    var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  7779  	                    thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  7780  	                }
  7781  	            } else {
  7782  	                // Copy one word at a time
  7783  	                for (var i = 0; i < thatSigBytes; i += 4) {
  7784  	                    thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
  7785  	                }
  7786  	            }
  7787  	            this.sigBytes += thatSigBytes;
  7788  
  7789  	            // Chainable
  7790  	            return this;
  7791  	        },
  7792  
  7793  	        /**
  7794  	         * Removes insignificant bits.
  7795  	         *
  7796  	         * @example
  7797  	         *
  7798  	         *     wordArray.clamp();
  7799  	         */
  7800  	        clamp: function () {
  7801  	            // Shortcuts
  7802  	            var words = this.words;
  7803  	            var sigBytes = this.sigBytes;
  7804  
  7805  	            // Clamp
  7806  	            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  7807  	            words.length = Math.ceil(sigBytes / 4);
  7808  	        },
  7809  
  7810  	        /**
  7811  	         * Creates a copy of this word array.
  7812  	         *
  7813  	         * @return {WordArray} The clone.
  7814  	         *
  7815  	         * @example
  7816  	         *
  7817  	         *     var clone = wordArray.clone();
  7818  	         */
  7819  	        clone: function () {
  7820  	            var clone = Base.clone.call(this);
  7821  	            clone.words = this.words.slice(0);
  7822  
  7823  	            return clone;
  7824  	        },
  7825  
  7826  	        /**
  7827  	         * Creates a word array filled with random bytes.
  7828  	         *
  7829  	         * @param {number} nBytes The number of random bytes to generate.
  7830  	         *
  7831  	         * @return {WordArray} The random word array.
  7832  	         *
  7833  	         * @static
  7834  	         *
  7835  	         * @example
  7836  	         *
  7837  	         *     var wordArray = CryptoJS.lib.WordArray.random(16);
  7838  	         */
  7839  	        random: function (nBytes) {
  7840  	            var words = [];
  7841  
  7842  	            var r = (function (m_w) {
  7843  	                var m_w = m_w;
  7844  	                var m_z = 0x3ade68b1;
  7845  	                var mask = 0xffffffff;
  7846  
  7847  	                return function () {
  7848  	                    m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
  7849  	                    m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
  7850  	                    var result = ((m_z << 0x10) + m_w) & mask;
  7851  	                    result /= 0x100000000;
  7852  	                    result += 0.5;
  7853  	                    return result * (Math.random() > .5 ? 1 : -1);
  7854  	                }
  7855  	            });
  7856  
  7857  	            for (var i = 0, rcache; i < nBytes; i += 4) {
  7858  	                var _r = r((rcache || Math.random()) * 0x100000000);
  7859  
  7860  	                rcache = _r() * 0x3ade67b7;
  7861  	                words.push((_r() * 0x100000000) | 0);
  7862  	            }
  7863  
  7864  	            return new WordArray.init(words, nBytes);
  7865  	        }
  7866  	    });
  7867  
  7868  	    /**
  7869  	     * Encoder namespace.
  7870  	     */
  7871  	    var C_enc = C.enc = {};
  7872  
  7873  	    /**
  7874  	     * Hex encoding strategy.
  7875  	     */
  7876  	    var Hex = C_enc.Hex = {
  7877  	        /**
  7878  	         * Converts a word array to a hex string.
  7879  	         *
  7880  	         * @param {WordArray} wordArray The word array.
  7881  	         *
  7882  	         * @return {string} The hex string.
  7883  	         *
  7884  	         * @static
  7885  	         *
  7886  	         * @example
  7887  	         *
  7888  	         *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  7889  	         */
  7890  	        stringify: function (wordArray) {
  7891  	            // Shortcuts
  7892  	            var words = wordArray.words;
  7893  	            var sigBytes = wordArray.sigBytes;
  7894  
  7895  	            // Convert
  7896  	            var hexChars = [];
  7897  	            for (var i = 0; i < sigBytes; i++) {
  7898  	                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  7899  	                hexChars.push((bite >>> 4).toString(16));
  7900  	                hexChars.push((bite & 0x0f).toString(16));
  7901  	            }
  7902  
  7903  	            return hexChars.join('');
  7904  	        },
  7905  
  7906  	        /**
  7907  	         * Converts a hex string to a word array.
  7908  	         *
  7909  	         * @param {string} hexStr The hex string.
  7910  	         *
  7911  	         * @return {WordArray} The word array.
  7912  	         *
  7913  	         * @static
  7914  	         *
  7915  	         * @example
  7916  	         *
  7917  	         *     var wordArray = CryptoJS.enc.Hex.parse(hexString);
  7918  	         */
  7919  	        parse: function (hexStr) {
  7920  	            // Shortcut
  7921  	            var hexStrLength = hexStr.length;
  7922  
  7923  	            // Convert
  7924  	            var words = [];
  7925  	            for (var i = 0; i < hexStrLength; i += 2) {
  7926  	                words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  7927  	            }
  7928  
  7929  	            return new WordArray.init(words, hexStrLength / 2);
  7930  	        }
  7931  	    };
  7932  
  7933  	    /**
  7934  	     * Latin1 encoding strategy.
  7935  	     */
  7936  	    var Latin1 = C_enc.Latin1 = {
  7937  	        /**
  7938  	         * Converts a word array to a Latin1 string.
  7939  	         *
  7940  	         * @param {WordArray} wordArray The word array.
  7941  	         *
  7942  	         * @return {string} The Latin1 string.
  7943  	         *
  7944  	         * @static
  7945  	         *
  7946  	         * @example
  7947  	         *
  7948  	         *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  7949  	         */
  7950  	        stringify: function (wordArray) {
  7951  	            // Shortcuts
  7952  	            var words = wordArray.words;
  7953  	            var sigBytes = wordArray.sigBytes;
  7954  
  7955  	            // Convert
  7956  	            var latin1Chars = [];
  7957  	            for (var i = 0; i < sigBytes; i++) {
  7958  	                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  7959  	                latin1Chars.push(String.fromCharCode(bite));
  7960  	            }
  7961  
  7962  	            return latin1Chars.join('');
  7963  	        },
  7964  
  7965  	        /**
  7966  	         * Converts a Latin1 string to a word array.
  7967  	         *
  7968  	         * @param {string} latin1Str The Latin1 string.
  7969  	         *
  7970  	         * @return {WordArray} The word array.
  7971  	         *
  7972  	         * @static
  7973  	         *
  7974  	         * @example
  7975  	         *
  7976  	         *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  7977  	         */
  7978  	        parse: function (latin1Str) {
  7979  	            // Shortcut
  7980  	            var latin1StrLength = latin1Str.length;
  7981  
  7982  	            // Convert
  7983  	            var words = [];
  7984  	            for (var i = 0; i < latin1StrLength; i++) {
  7985  	                words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  7986  	            }
  7987  
  7988  	            return new WordArray.init(words, latin1StrLength);
  7989  	        }
  7990  	    };
  7991  
  7992  	    /**
  7993  	     * UTF-8 encoding strategy.
  7994  	     */
  7995  	    var Utf8 = C_enc.Utf8 = {
  7996  	        /**
  7997  	         * Converts a word array to a UTF-8 string.
  7998  	         *
  7999  	         * @param {WordArray} wordArray The word array.
  8000  	         *
  8001  	         * @return {string} The UTF-8 string.
  8002  	         *
  8003  	         * @static
  8004  	         *
  8005  	         * @example
  8006  	         *
  8007  	         *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  8008  	         */
  8009  	        stringify: function (wordArray) {
  8010  	            try {
  8011  	                return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  8012  	            } catch (e) {
  8013  	                throw new Error('Malformed UTF-8 data');
  8014  	            }
  8015  	        },
  8016  
  8017  	        /**
  8018  	         * Converts a UTF-8 string to a word array.
  8019  	         *
  8020  	         * @param {string} utf8Str The UTF-8 string.
  8021  	         *
  8022  	         * @return {WordArray} The word array.
  8023  	         *
  8024  	         * @static
  8025  	         *
  8026  	         * @example
  8027  	         *
  8028  	         *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  8029  	         */
  8030  	        parse: function (utf8Str) {
  8031  	            return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  8032  	        }
  8033  	    };
  8034  
  8035  	    /**
  8036  	     * Abstract buffered block algorithm template.
  8037  	     *
  8038  	     * The property blockSize must be implemented in a concrete subtype.
  8039  	     *
  8040  	     * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  8041  	     */
  8042  	    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  8043  	        /**
  8044  	         * Resets this block algorithm's data buffer to its initial state.
  8045  	         *
  8046  	         * @example
  8047  	         *
  8048  	         *     bufferedBlockAlgorithm.reset();
  8049  	         */
  8050  	        reset: function () {
  8051  	            // Initial values
  8052  	            this._data = new WordArray.init();
  8053  	            this._nDataBytes = 0;
  8054  	        },
  8055  
  8056  	        /**
  8057  	         * Adds new data to this block algorithm's buffer.
  8058  	         *
  8059  	         * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  8060  	         *
  8061  	         * @example
  8062  	         *
  8063  	         *     bufferedBlockAlgorithm._append('data');
  8064  	         *     bufferedBlockAlgorithm._append(wordArray);
  8065  	         */
  8066  	        _append: function (data) {
  8067  	            // Convert string to WordArray, else assume WordArray already
  8068  	            if (typeof data == 'string') {
  8069  	                data = Utf8.parse(data);
  8070  	            }
  8071  
  8072  	            // Append
  8073  	            this._data.concat(data);
  8074  	            this._nDataBytes += data.sigBytes;
  8075  	        },
  8076  
  8077  	        /**
  8078  	         * Processes available data blocks.
  8079  	         *
  8080  	         * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  8081  	         *
  8082  	         * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  8083  	         *
  8084  	         * @return {WordArray} The processed data.
  8085  	         *
  8086  	         * @example
  8087  	         *
  8088  	         *     var processedData = bufferedBlockAlgorithm._process();
  8089  	         *     var processedData = bufferedBlockAlgorithm._process(!!'flush');
  8090  	         */
  8091  	        _process: function (doFlush) {
  8092  	            // Shortcuts
  8093  	            var data = this._data;
  8094  	            var dataWords = data.words;
  8095  	            var dataSigBytes = data.sigBytes;
  8096  	            var blockSize = this.blockSize;
  8097  	            var blockSizeBytes = blockSize * 4;
  8098  
  8099  	            // Count blocks ready
  8100  	            var nBlocksReady = dataSigBytes / blockSizeBytes;
  8101  	            if (doFlush) {
  8102  	                // Round up to include partial blocks
  8103  	                nBlocksReady = Math.ceil(nBlocksReady);
  8104  	            } else {
  8105  	                // Round down to include only full blocks,
  8106  	                // less the number of blocks that must remain in the buffer
  8107  	                nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  8108  	            }
  8109  
  8110  	            // Count words ready
  8111  	            var nWordsReady = nBlocksReady * blockSize;
  8112  
  8113  	            // Count bytes ready
  8114  	            var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  8115  
  8116  	            // Process blocks
  8117  	            if (nWordsReady) {
  8118  	                for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  8119  	                    // Perform concrete-algorithm logic
  8120  	                    this._doProcessBlock(dataWords, offset);
  8121  	                }
  8122  
  8123  	                // Remove processed words
  8124  	                var processedWords = dataWords.splice(0, nWordsReady);
  8125  	                data.sigBytes -= nBytesReady;
  8126  	            }
  8127  
  8128  	            // Return processed words
  8129  	            return new WordArray.init(processedWords, nBytesReady);
  8130  	        },
  8131  
  8132  	        /**
  8133  	         * Creates a copy of this object.
  8134  	         *
  8135  	         * @return {Object} The clone.
  8136  	         *
  8137  	         * @example
  8138  	         *
  8139  	         *     var clone = bufferedBlockAlgorithm.clone();
  8140  	         */
  8141  	        clone: function () {
  8142  	            var clone = Base.clone.call(this);
  8143  	            clone._data = this._data.clone();
  8144  
  8145  	            return clone;
  8146  	        },
  8147  
  8148  	        _minBufferSize: 0
  8149  	    });
  8150  
  8151  	    /**
  8152  	     * Abstract hasher template.
  8153  	     *
  8154  	     * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  8155  	     */
  8156  	    var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  8157  	        /**
  8158  	         * Configuration options.
  8159  	         */
  8160  	        cfg: Base.extend(),
  8161  
  8162  	        /**
  8163  	         * Initializes a newly created hasher.
  8164  	         *
  8165  	         * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  8166  	         *
  8167  	         * @example
  8168  	         *
  8169  	         *     var hasher = CryptoJS.algo.SHA256.create();
  8170  	         */
  8171  	        init: function (cfg) {
  8172  	            // Apply config defaults
  8173  	            this.cfg = this.cfg.extend(cfg);
  8174  
  8175  	            // Set initial values
  8176  	            this.reset();
  8177  	        },
  8178  
  8179  	        /**
  8180  	         * Resets this hasher to its initial state.
  8181  	         *
  8182  	         * @example
  8183  	         *
  8184  	         *     hasher.reset();
  8185  	         */
  8186  	        reset: function () {
  8187  	            // Reset data buffer
  8188  	            BufferedBlockAlgorithm.reset.call(this);
  8189  
  8190  	            // Perform concrete-hasher logic
  8191  	            this._doReset();
  8192  	        },
  8193  
  8194  	        /**
  8195  	         * Updates this hasher with a message.
  8196  	         *
  8197  	         * @param {WordArray|string} messageUpdate The message to append.
  8198  	         *
  8199  	         * @return {Hasher} This hasher.
  8200  	         *
  8201  	         * @example
  8202  	         *
  8203  	         *     hasher.update('message');
  8204  	         *     hasher.update(wordArray);
  8205  	         */
  8206  	        update: function (messageUpdate) {
  8207  	            // Append
  8208  	            this._append(messageUpdate);
  8209  
  8210  	            // Update the hash
  8211  	            this._process();
  8212  
  8213  	            // Chainable
  8214  	            return this;
  8215  	        },
  8216  
  8217  	        /**
  8218  	         * Finalizes the hash computation.
  8219  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  8220  	         *
  8221  	         * @param {WordArray|string} messageUpdate (Optional) A final message update.
  8222  	         *
  8223  	         * @return {WordArray} The hash.
  8224  	         *
  8225  	         * @example
  8226  	         *
  8227  	         *     var hash = hasher.finalize();
  8228  	         *     var hash = hasher.finalize('message');
  8229  	         *     var hash = hasher.finalize(wordArray);
  8230  	         */
  8231  	        finalize: function (messageUpdate) {
  8232  	            // Final message update
  8233  	            if (messageUpdate) {
  8234  	                this._append(messageUpdate);
  8235  	            }
  8236  
  8237  	            // Perform concrete-hasher logic
  8238  	            var hash = this._doFinalize();
  8239  
  8240  	            return hash;
  8241  	        },
  8242  
  8243  	        blockSize: 512/32,
  8244  
  8245  	        /**
  8246  	         * Creates a shortcut function to a hasher's object interface.
  8247  	         *
  8248  	         * @param {Hasher} hasher The hasher to create a helper for.
  8249  	         *
  8250  	         * @return {Function} The shortcut function.
  8251  	         *
  8252  	         * @static
  8253  	         *
  8254  	         * @example
  8255  	         *
  8256  	         *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  8257  	         */
  8258  	        _createHelper: function (hasher) {
  8259  	            return function (message, cfg) {
  8260  	                return new hasher.init(cfg).finalize(message);
  8261  	            };
  8262  	        },
  8263  
  8264  	        /**
  8265  	         * Creates a shortcut function to the HMAC's object interface.
  8266  	         *
  8267  	         * @param {Hasher} hasher The hasher to use in this HMAC helper.
  8268  	         *
  8269  	         * @return {Function} The shortcut function.
  8270  	         *
  8271  	         * @static
  8272  	         *
  8273  	         * @example
  8274  	         *
  8275  	         *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  8276  	         */
  8277  	        _createHmacHelper: function (hasher) {
  8278  	            return function (message, key) {
  8279  	                return new C_algo.HMAC.init(hasher, key).finalize(message);
  8280  	            };
  8281  	        }
  8282  	    });
  8283  
  8284  	    /**
  8285  	     * Algorithm namespace.
  8286  	     */
  8287  	    var C_algo = C.algo = {};
  8288  
  8289  	    return C;
  8290  	}(Math));
  8291  
  8292  
  8293  	return CryptoJS;
  8294  
  8295  }));
  8296  },{}],53:[function(require,module,exports){
  8297  ;(function (root, factory) {
  8298  	if (typeof exports === "object") {
  8299  		// CommonJS
  8300  		module.exports = exports = factory(require("./core"));
  8301  	}
  8302  	else if (typeof define === "function" && define.amd) {
  8303  		// AMD
  8304  		define(["./core"], factory);
  8305  	}
  8306  	else {
  8307  		// Global (browser)
  8308  		factory(root.CryptoJS);
  8309  	}
  8310  }(this, function (CryptoJS) {
  8311  
  8312  	(function () {
  8313  	    // Shortcuts
  8314  	    var C = CryptoJS;
  8315  	    var C_lib = C.lib;
  8316  	    var WordArray = C_lib.WordArray;
  8317  	    var C_enc = C.enc;
  8318  
  8319  	    /**
  8320  	     * Base64 encoding strategy.
  8321  	     */
  8322  	    var Base64 = C_enc.Base64 = {
  8323  	        /**
  8324  	         * Converts a word array to a Base64 string.
  8325  	         *
  8326  	         * @param {WordArray} wordArray The word array.
  8327  	         *
  8328  	         * @return {string} The Base64 string.
  8329  	         *
  8330  	         * @static
  8331  	         *
  8332  	         * @example
  8333  	         *
  8334  	         *     var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  8335  	         */
  8336  	        stringify: function (wordArray) {
  8337  	            // Shortcuts
  8338  	            var words = wordArray.words;
  8339  	            var sigBytes = wordArray.sigBytes;
  8340  	            var map = this._map;
  8341  
  8342  	            // Clamp excess bits
  8343  	            wordArray.clamp();
  8344  
  8345  	            // Convert
  8346  	            var base64Chars = [];
  8347  	            for (var i = 0; i < sigBytes; i += 3) {
  8348  	                var byte1 = (words[i >>> 2]       >>> (24 - (i % 4) * 8))       & 0xff;
  8349  	                var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  8350  	                var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  8351  
  8352  	                var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  8353  
  8354  	                for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  8355  	                    base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  8356  	                }
  8357  	            }
  8358  
  8359  	            // Add padding
  8360  	            var paddingChar = map.charAt(64);
  8361  	            if (paddingChar) {
  8362  	                while (base64Chars.length % 4) {
  8363  	                    base64Chars.push(paddingChar);
  8364  	                }
  8365  	            }
  8366  
  8367  	            return base64Chars.join('');
  8368  	        },
  8369  
  8370  	        /**
  8371  	         * Converts a Base64 string to a word array.
  8372  	         *
  8373  	         * @param {string} base64Str The Base64 string.
  8374  	         *
  8375  	         * @return {WordArray} The word array.
  8376  	         *
  8377  	         * @static
  8378  	         *
  8379  	         * @example
  8380  	         *
  8381  	         *     var wordArray = CryptoJS.enc.Base64.parse(base64String);
  8382  	         */
  8383  	        parse: function (base64Str) {
  8384  	            // Shortcuts
  8385  	            var base64StrLength = base64Str.length;
  8386  	            var map = this._map;
  8387  
  8388  	            // Ignore padding
  8389  	            var paddingChar = map.charAt(64);
  8390  	            if (paddingChar) {
  8391  	                var paddingIndex = base64Str.indexOf(paddingChar);
  8392  	                if (paddingIndex != -1) {
  8393  	                    base64StrLength = paddingIndex;
  8394  	                }
  8395  	            }
  8396  
  8397  	            // Convert
  8398  	            var words = [];
  8399  	            var nBytes = 0;
  8400  	            for (var i = 0; i < base64StrLength; i++) {
  8401  	                if (i % 4) {
  8402  	                    var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
  8403  	                    var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
  8404  	                    words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
  8405  	                    nBytes++;
  8406  	                }
  8407  	            }
  8408  
  8409  	            return WordArray.create(words, nBytes);
  8410  	        },
  8411  
  8412  	        _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  8413  	    };
  8414  	}());
  8415  
  8416  
  8417  	return CryptoJS.enc.Base64;
  8418  
  8419  }));
  8420  },{"./core":52}],54:[function(require,module,exports){
  8421  ;(function (root, factory) {
  8422  	if (typeof exports === "object") {
  8423  		// CommonJS
  8424  		module.exports = exports = factory(require("./core"));
  8425  	}
  8426  	else if (typeof define === "function" && define.amd) {
  8427  		// AMD
  8428  		define(["./core"], factory);
  8429  	}
  8430  	else {
  8431  		// Global (browser)
  8432  		factory(root.CryptoJS);
  8433  	}
  8434  }(this, function (CryptoJS) {
  8435  
  8436  	(function () {
  8437  	    // Shortcuts
  8438  	    var C = CryptoJS;
  8439  	    var C_lib = C.lib;
  8440  	    var WordArray = C_lib.WordArray;
  8441  	    var C_enc = C.enc;
  8442  
  8443  	    /**
  8444  	     * UTF-16 BE encoding strategy.
  8445  	     */
  8446  	    var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
  8447  	        /**
  8448  	         * Converts a word array to a UTF-16 BE string.
  8449  	         *
  8450  	         * @param {WordArray} wordArray The word array.
  8451  	         *
  8452  	         * @return {string} The UTF-16 BE string.
  8453  	         *
  8454  	         * @static
  8455  	         *
  8456  	         * @example
  8457  	         *
  8458  	         *     var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
  8459  	         */
  8460  	        stringify: function (wordArray) {
  8461  	            // Shortcuts
  8462  	            var words = wordArray.words;
  8463  	            var sigBytes = wordArray.sigBytes;
  8464  
  8465  	            // Convert
  8466  	            var utf16Chars = [];
  8467  	            for (var i = 0; i < sigBytes; i += 2) {
  8468  	                var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
  8469  	                utf16Chars.push(String.fromCharCode(codePoint));
  8470  	            }
  8471  
  8472  	            return utf16Chars.join('');
  8473  	        },
  8474  
  8475  	        /**
  8476  	         * Converts a UTF-16 BE string to a word array.
  8477  	         *
  8478  	         * @param {string} utf16Str The UTF-16 BE string.
  8479  	         *
  8480  	         * @return {WordArray} The word array.
  8481  	         *
  8482  	         * @static
  8483  	         *
  8484  	         * @example
  8485  	         *
  8486  	         *     var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
  8487  	         */
  8488  	        parse: function (utf16Str) {
  8489  	            // Shortcut
  8490  	            var utf16StrLength = utf16Str.length;
  8491  
  8492  	            // Convert
  8493  	            var words = [];
  8494  	            for (var i = 0; i < utf16StrLength; i++) {
  8495  	                words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
  8496  	            }
  8497  
  8498  	            return WordArray.create(words, utf16StrLength * 2);
  8499  	        }
  8500  	    };
  8501  
  8502  	    /**
  8503  	     * UTF-16 LE encoding strategy.
  8504  	     */
  8505  	    C_enc.Utf16LE = {
  8506  	        /**
  8507  	         * Converts a word array to a UTF-16 LE string.
  8508  	         *
  8509  	         * @param {WordArray} wordArray The word array.
  8510  	         *
  8511  	         * @return {string} The UTF-16 LE string.
  8512  	         *
  8513  	         * @static
  8514  	         *
  8515  	         * @example
  8516  	         *
  8517  	         *     var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
  8518  	         */
  8519  	        stringify: function (wordArray) {
  8520  	            // Shortcuts
  8521  	            var words = wordArray.words;
  8522  	            var sigBytes = wordArray.sigBytes;
  8523  
  8524  	            // Convert
  8525  	            var utf16Chars = [];
  8526  	            for (var i = 0; i < sigBytes; i += 2) {
  8527  	                var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
  8528  	                utf16Chars.push(String.fromCharCode(codePoint));
  8529  	            }
  8530  
  8531  	            return utf16Chars.join('');
  8532  	        },
  8533  
  8534  	        /**
  8535  	         * Converts a UTF-16 LE string to a word array.
  8536  	         *
  8537  	         * @param {string} utf16Str The UTF-16 LE string.
  8538  	         *
  8539  	         * @return {WordArray} The word array.
  8540  	         *
  8541  	         * @static
  8542  	         *
  8543  	         * @example
  8544  	         *
  8545  	         *     var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
  8546  	         */
  8547  	        parse: function (utf16Str) {
  8548  	            // Shortcut
  8549  	            var utf16StrLength = utf16Str.length;
  8550  
  8551  	            // Convert
  8552  	            var words = [];
  8553  	            for (var i = 0; i < utf16StrLength; i++) {
  8554  	                words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
  8555  	            }
  8556  
  8557  	            return WordArray.create(words, utf16StrLength * 2);
  8558  	        }
  8559  	    };
  8560  
  8561  	    function swapEndian(word) {
  8562  	        return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
  8563  	    }
  8564  	}());
  8565  
  8566  
  8567  	return CryptoJS.enc.Utf16;
  8568  
  8569  }));
  8570  },{"./core":52}],55:[function(require,module,exports){
  8571  ;(function (root, factory, undef) {
  8572  	if (typeof exports === "object") {
  8573  		// CommonJS
  8574  		module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
  8575  	}
  8576  	else if (typeof define === "function" && define.amd) {
  8577  		// AMD
  8578  		define(["./core", "./sha1", "./hmac"], factory);
  8579  	}
  8580  	else {
  8581  		// Global (browser)
  8582  		factory(root.CryptoJS);
  8583  	}
  8584  }(this, function (CryptoJS) {
  8585  
  8586  	(function () {
  8587  	    // Shortcuts
  8588  	    var C = CryptoJS;
  8589  	    var C_lib = C.lib;
  8590  	    var Base = C_lib.Base;
  8591  	    var WordArray = C_lib.WordArray;
  8592  	    var C_algo = C.algo;
  8593  	    var MD5 = C_algo.MD5;
  8594  
  8595  	    /**
  8596  	     * This key derivation function is meant to conform with EVP_BytesToKey.
  8597  	     * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  8598  	     */
  8599  	    var EvpKDF = C_algo.EvpKDF = Base.extend({
  8600  	        /**
  8601  	         * Configuration options.
  8602  	         *
  8603  	         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  8604  	         * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  8605  	         * @property {number} iterations The number of iterations to perform. Default: 1
  8606  	         */
  8607  	        cfg: Base.extend({
  8608  	            keySize: 128/32,
  8609  	            hasher: MD5,
  8610  	            iterations: 1
  8611  	        }),
  8612  
  8613  	        /**
  8614  	         * Initializes a newly created key derivation function.
  8615  	         *
  8616  	         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  8617  	         *
  8618  	         * @example
  8619  	         *
  8620  	         *     var kdf = CryptoJS.algo.EvpKDF.create();
  8621  	         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  8622  	         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  8623  	         */
  8624  	        init: function (cfg) {
  8625  	            this.cfg = this.cfg.extend(cfg);
  8626  	        },
  8627  
  8628  	        /**
  8629  	         * Derives a key from a password.
  8630  	         *
  8631  	         * @param {WordArray|string} password The password.
  8632  	         * @param {WordArray|string} salt A salt.
  8633  	         *
  8634  	         * @return {WordArray} The derived key.
  8635  	         *
  8636  	         * @example
  8637  	         *
  8638  	         *     var key = kdf.compute(password, salt);
  8639  	         */
  8640  	        compute: function (password, salt) {
  8641  	            // Shortcut
  8642  	            var cfg = this.cfg;
  8643  
  8644  	            // Init hasher
  8645  	            var hasher = cfg.hasher.create();
  8646  
  8647  	            // Initial values
  8648  	            var derivedKey = WordArray.create();
  8649  
  8650  	            // Shortcuts
  8651  	            var derivedKeyWords = derivedKey.words;
  8652  	            var keySize = cfg.keySize;
  8653  	            var iterations = cfg.iterations;
  8654  
  8655  	            // Generate key
  8656  	            while (derivedKeyWords.length < keySize) {
  8657  	                if (block) {
  8658  	                    hasher.update(block);
  8659  	                }
  8660  	                var block = hasher.update(password).finalize(salt);
  8661  	                hasher.reset();
  8662  
  8663  	                // Iterations
  8664  	                for (var i = 1; i < iterations; i++) {
  8665  	                    block = hasher.finalize(block);
  8666  	                    hasher.reset();
  8667  	                }
  8668  
  8669  	                derivedKey.concat(block);
  8670  	            }
  8671  	            derivedKey.sigBytes = keySize * 4;
  8672  
  8673  	            return derivedKey;
  8674  	        }
  8675  	    });
  8676  
  8677  	    /**
  8678  	     * Derives a key from a password.
  8679  	     *
  8680  	     * @param {WordArray|string} password The password.
  8681  	     * @param {WordArray|string} salt A salt.
  8682  	     * @param {Object} cfg (Optional) The configuration options to use for this computation.
  8683  	     *
  8684  	     * @return {WordArray} The derived key.
  8685  	     *
  8686  	     * @static
  8687  	     *
  8688  	     * @example
  8689  	     *
  8690  	     *     var key = CryptoJS.EvpKDF(password, salt);
  8691  	     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  8692  	     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  8693  	     */
  8694  	    C.EvpKDF = function (password, salt, cfg) {
  8695  	        return EvpKDF.create(cfg).compute(password, salt);
  8696  	    };
  8697  	}());
  8698  
  8699  
  8700  	return CryptoJS.EvpKDF;
  8701  
  8702  }));
  8703  },{"./core":52,"./hmac":57,"./sha1":76}],56:[function(require,module,exports){
  8704  ;(function (root, factory, undef) {
  8705  	if (typeof exports === "object") {
  8706  		// CommonJS
  8707  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8708  	}
  8709  	else if (typeof define === "function" && define.amd) {
  8710  		// AMD
  8711  		define(["./core", "./cipher-core"], factory);
  8712  	}
  8713  	else {
  8714  		// Global (browser)
  8715  		factory(root.CryptoJS);
  8716  	}
  8717  }(this, function (CryptoJS) {
  8718  
  8719  	(function (undefined) {
  8720  	    // Shortcuts
  8721  	    var C = CryptoJS;
  8722  	    var C_lib = C.lib;
  8723  	    var CipherParams = C_lib.CipherParams;
  8724  	    var C_enc = C.enc;
  8725  	    var Hex = C_enc.Hex;
  8726  	    var C_format = C.format;
  8727  
  8728  	    var HexFormatter = C_format.Hex = {
  8729  	        /**
  8730  	         * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  8731  	         *
  8732  	         * @param {CipherParams} cipherParams The cipher params object.
  8733  	         *
  8734  	         * @return {string} The hexadecimally encoded string.
  8735  	         *
  8736  	         * @static
  8737  	         *
  8738  	         * @example
  8739  	         *
  8740  	         *     var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  8741  	         */
  8742  	        stringify: function (cipherParams) {
  8743  	            return cipherParams.ciphertext.toString(Hex);
  8744  	        },
  8745  
  8746  	        /**
  8747  	         * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  8748  	         *
  8749  	         * @param {string} input The hexadecimally encoded string.
  8750  	         *
  8751  	         * @return {CipherParams} The cipher params object.
  8752  	         *
  8753  	         * @static
  8754  	         *
  8755  	         * @example
  8756  	         *
  8757  	         *     var cipherParams = CryptoJS.format.Hex.parse(hexString);
  8758  	         */
  8759  	        parse: function (input) {
  8760  	            var ciphertext = Hex.parse(input);
  8761  	            return CipherParams.create({ ciphertext: ciphertext });
  8762  	        }
  8763  	    };
  8764  	}());
  8765  
  8766  
  8767  	return CryptoJS.format.Hex;
  8768  
  8769  }));
  8770  },{"./cipher-core":51,"./core":52}],57:[function(require,module,exports){
  8771  ;(function (root, factory) {
  8772  	if (typeof exports === "object") {
  8773  		// CommonJS
  8774  		module.exports = exports = factory(require("./core"));
  8775  	}
  8776  	else if (typeof define === "function" && define.amd) {
  8777  		// AMD
  8778  		define(["./core"], factory);
  8779  	}
  8780  	else {
  8781  		// Global (browser)
  8782  		factory(root.CryptoJS);
  8783  	}
  8784  }(this, function (CryptoJS) {
  8785  
  8786  	(function () {
  8787  	    // Shortcuts
  8788  	    var C = CryptoJS;
  8789  	    var C_lib = C.lib;
  8790  	    var Base = C_lib.Base;
  8791  	    var C_enc = C.enc;
  8792  	    var Utf8 = C_enc.Utf8;
  8793  	    var C_algo = C.algo;
  8794  
  8795  	    /**
  8796  	     * HMAC algorithm.
  8797  	     */
  8798  	    var HMAC = C_algo.HMAC = Base.extend({
  8799  	        /**
  8800  	         * Initializes a newly created HMAC.
  8801  	         *
  8802  	         * @param {Hasher} hasher The hash algorithm to use.
  8803  	         * @param {WordArray|string} key The secret key.
  8804  	         *
  8805  	         * @example
  8806  	         *
  8807  	         *     var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  8808  	         */
  8809  	        init: function (hasher, key) {
  8810  	            // Init hasher
  8811  	            hasher = this._hasher = new hasher.init();
  8812  
  8813  	            // Convert string to WordArray, else assume WordArray already
  8814  	            if (typeof key == 'string') {
  8815  	                key = Utf8.parse(key);
  8816  	            }
  8817  
  8818  	            // Shortcuts
  8819  	            var hasherBlockSize = hasher.blockSize;
  8820  	            var hasherBlockSizeBytes = hasherBlockSize * 4;
  8821  
  8822  	            // Allow arbitrary length keys
  8823  	            if (key.sigBytes > hasherBlockSizeBytes) {
  8824  	                key = hasher.finalize(key);
  8825  	            }
  8826  
  8827  	            // Clamp excess bits
  8828  	            key.clamp();
  8829  
  8830  	            // Clone key for inner and outer pads
  8831  	            var oKey = this._oKey = key.clone();
  8832  	            var iKey = this._iKey = key.clone();
  8833  
  8834  	            // Shortcuts
  8835  	            var oKeyWords = oKey.words;
  8836  	            var iKeyWords = iKey.words;
  8837  
  8838  	            // XOR keys with pad constants
  8839  	            for (var i = 0; i < hasherBlockSize; i++) {
  8840  	                oKeyWords[i] ^= 0x5c5c5c5c;
  8841  	                iKeyWords[i] ^= 0x36363636;
  8842  	            }
  8843  	            oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  8844  
  8845  	            // Set initial values
  8846  	            this.reset();
  8847  	        },
  8848  
  8849  	        /**
  8850  	         * Resets this HMAC to its initial state.
  8851  	         *
  8852  	         * @example
  8853  	         *
  8854  	         *     hmacHasher.reset();
  8855  	         */
  8856  	        reset: function () {
  8857  	            // Shortcut
  8858  	            var hasher = this._hasher;
  8859  
  8860  	            // Reset
  8861  	            hasher.reset();
  8862  	            hasher.update(this._iKey);
  8863  	        },
  8864  
  8865  	        /**
  8866  	         * Updates this HMAC with a message.
  8867  	         *
  8868  	         * @param {WordArray|string} messageUpdate The message to append.
  8869  	         *
  8870  	         * @return {HMAC} This HMAC instance.
  8871  	         *
  8872  	         * @example
  8873  	         *
  8874  	         *     hmacHasher.update('message');
  8875  	         *     hmacHasher.update(wordArray);
  8876  	         */
  8877  	        update: function (messageUpdate) {
  8878  	            this._hasher.update(messageUpdate);
  8879  
  8880  	            // Chainable
  8881  	            return this;
  8882  	        },
  8883  
  8884  	        /**
  8885  	         * Finalizes the HMAC computation.
  8886  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  8887  	         *
  8888  	         * @param {WordArray|string} messageUpdate (Optional) A final message update.
  8889  	         *
  8890  	         * @return {WordArray} The HMAC.
  8891  	         *
  8892  	         * @example
  8893  	         *
  8894  	         *     var hmac = hmacHasher.finalize();
  8895  	         *     var hmac = hmacHasher.finalize('message');
  8896  	         *     var hmac = hmacHasher.finalize(wordArray);
  8897  	         */
  8898  	        finalize: function (messageUpdate) {
  8899  	            // Shortcut
  8900  	            var hasher = this._hasher;
  8901  
  8902  	            // Compute HMAC
  8903  	            var innerHash = hasher.finalize(messageUpdate);
  8904  	            hasher.reset();
  8905  	            var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  8906  
  8907  	            return hmac;
  8908  	        }
  8909  	    });
  8910  	}());
  8911  
  8912  
  8913  }));
  8914  },{"./core":52}],58:[function(require,module,exports){
  8915  ;(function (root, factory, undef) {
  8916  	if (typeof exports === "object") {
  8917  		// CommonJS
  8918  		module.exports = exports = factory(require("./core"), require("./x64-core"), require("./lib-typedarrays"), require("./enc-utf16"), require("./enc-base64"), require("./md5"), require("./sha1"), require("./sha256"), require("./sha224"), require("./sha512"), require("./sha384"), require("./sha3"), require("./ripemd160"), require("./hmac"), require("./pbkdf2"), require("./evpkdf"), require("./cipher-core"), require("./mode-cfb"), require("./mode-ctr"), require("./mode-ctr-gladman"), require("./mode-ofb"), require("./mode-ecb"), require("./pad-ansix923"), require("./pad-iso10126"), require("./pad-iso97971"), require("./pad-zeropadding"), require("./pad-nopadding"), require("./format-hex"), require("./aes"), require("./tripledes"), require("./rc4"), require("./rabbit"), require("./rabbit-legacy"));
  8919  	}
  8920  	else if (typeof define === "function" && define.amd) {
  8921  		// AMD
  8922  		define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory);
  8923  	}
  8924  	else {
  8925  		// Global (browser)
  8926  		root.CryptoJS = factory(root.CryptoJS);
  8927  	}
  8928  }(this, function (CryptoJS) {
  8929  
  8930  	return CryptoJS;
  8931  
  8932  }));
  8933  },{"./aes":50,"./cipher-core":51,"./core":52,"./enc-base64":53,"./enc-utf16":54,"./evpkdf":55,"./format-hex":56,"./hmac":57,"./lib-typedarrays":59,"./md5":60,"./mode-cfb":61,"./mode-ctr":63,"./mode-ctr-gladman":62,"./mode-ecb":64,"./mode-ofb":65,"./pad-ansix923":66,"./pad-iso10126":67,"./pad-iso97971":68,"./pad-nopadding":69,"./pad-zeropadding":70,"./pbkdf2":71,"./rabbit":73,"./rabbit-legacy":72,"./rc4":74,"./ripemd160":75,"./sha1":76,"./sha224":77,"./sha256":78,"./sha3":79,"./sha384":80,"./sha512":81,"./tripledes":82,"./x64-core":83}],59:[function(require,module,exports){
  8934  ;(function (root, factory) {
  8935  	if (typeof exports === "object") {
  8936  		// CommonJS
  8937  		module.exports = exports = factory(require("./core"));
  8938  	}
  8939  	else if (typeof define === "function" && define.amd) {
  8940  		// AMD
  8941  		define(["./core"], factory);
  8942  	}
  8943  	else {
  8944  		// Global (browser)
  8945  		factory(root.CryptoJS);
  8946  	}
  8947  }(this, function (CryptoJS) {
  8948  
  8949  	(function () {
  8950  	    // Check if typed arrays are supported
  8951  	    if (typeof ArrayBuffer != 'function') {
  8952  	        return;
  8953  	    }
  8954  
  8955  	    // Shortcuts
  8956  	    var C = CryptoJS;
  8957  	    var C_lib = C.lib;
  8958  	    var WordArray = C_lib.WordArray;
  8959  
  8960  	    // Reference original init
  8961  	    var superInit = WordArray.init;
  8962  
  8963  	    // Augment WordArray.init to handle typed arrays
  8964  	    var subInit = WordArray.init = function (typedArray) {
  8965  	        // Convert buffers to uint8
  8966  	        if (typedArray instanceof ArrayBuffer) {
  8967  	            typedArray = new Uint8Array(typedArray);
  8968  	        }
  8969  
  8970  	        // Convert other array views to uint8
  8971  	        if (
  8972  	            typedArray instanceof Int8Array ||
  8973  	            (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
  8974  	            typedArray instanceof Int16Array ||
  8975  	            typedArray instanceof Uint16Array ||
  8976  	            typedArray instanceof Int32Array ||
  8977  	            typedArray instanceof Uint32Array ||
  8978  	            typedArray instanceof Float32Array ||
  8979  	            typedArray instanceof Float64Array
  8980  	        ) {
  8981  	            typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
  8982  	        }
  8983  
  8984  	        // Handle Uint8Array
  8985  	        if (typedArray instanceof Uint8Array) {
  8986  	            // Shortcut
  8987  	            var typedArrayByteLength = typedArray.byteLength;
  8988  
  8989  	            // Extract bytes
  8990  	            var words = [];
  8991  	            for (var i = 0; i < typedArrayByteLength; i++) {
  8992  	                words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
  8993  	            }
  8994  
  8995  	            // Initialize this word array
  8996  	            superInit.call(this, words, typedArrayByteLength);
  8997  	        } else {
  8998  	            // Else call normal init
  8999  	            superInit.apply(this, arguments);
  9000  	        }
  9001  	    };
  9002  
  9003  	    subInit.prototype = WordArray;
  9004  	}());
  9005  
  9006  
  9007  	return CryptoJS.lib.WordArray;
  9008  
  9009  }));
  9010  },{"./core":52}],60:[function(require,module,exports){
  9011  ;(function (root, factory) {
  9012  	if (typeof exports === "object") {
  9013  		// CommonJS
  9014  		module.exports = exports = factory(require("./core"));
  9015  	}
  9016  	else if (typeof define === "function" && define.amd) {
  9017  		// AMD
  9018  		define(["./core"], factory);
  9019  	}
  9020  	else {
  9021  		// Global (browser)
  9022  		factory(root.CryptoJS);
  9023  	}
  9024  }(this, function (CryptoJS) {
  9025  
  9026  	(function (Math) {
  9027  	    // Shortcuts
  9028  	    var C = CryptoJS;
  9029  	    var C_lib = C.lib;
  9030  	    var WordArray = C_lib.WordArray;
  9031  	    var Hasher = C_lib.Hasher;
  9032  	    var C_algo = C.algo;
  9033  
  9034  	    // Constants table
  9035  	    var T = [];
  9036  
  9037  	    // Compute constants
  9038  	    (function () {
  9039  	        for (var i = 0; i < 64; i++) {
  9040  	            T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  9041  	        }
  9042  	    }());
  9043  
  9044  	    /**
  9045  	     * MD5 hash algorithm.
  9046  	     */
  9047  	    var MD5 = C_algo.MD5 = Hasher.extend({
  9048  	        _doReset: function () {
  9049  	            this._hash = new WordArray.init([
  9050  	                0x67452301, 0xefcdab89,
  9051  	                0x98badcfe, 0x10325476
  9052  	            ]);
  9053  	        },
  9054  
  9055  	        _doProcessBlock: function (M, offset) {
  9056  	            // Swap endian
  9057  	            for (var i = 0; i < 16; i++) {
  9058  	                // Shortcuts
  9059  	                var offset_i = offset + i;
  9060  	                var M_offset_i = M[offset_i];
  9061  
  9062  	                M[offset_i] = (
  9063  	                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
  9064  	                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
  9065  	                );
  9066  	            }
  9067  
  9068  	            // Shortcuts
  9069  	            var H = this._hash.words;
  9070  
  9071  	            var M_offset_0  = M[offset + 0];
  9072  	            var M_offset_1  = M[offset + 1];
  9073  	            var M_offset_2  = M[offset + 2];
  9074  	            var M_offset_3  = M[offset + 3];
  9075  	            var M_offset_4  = M[offset + 4];
  9076  	            var M_offset_5  = M[offset + 5];
  9077  	            var M_offset_6  = M[offset + 6];
  9078  	            var M_offset_7  = M[offset + 7];
  9079  	            var M_offset_8  = M[offset + 8];
  9080  	            var M_offset_9  = M[offset + 9];
  9081  	            var M_offset_10 = M[offset + 10];
  9082  	            var M_offset_11 = M[offset + 11];
  9083  	            var M_offset_12 = M[offset + 12];
  9084  	            var M_offset_13 = M[offset + 13];
  9085  	            var M_offset_14 = M[offset + 14];
  9086  	            var M_offset_15 = M[offset + 15];
  9087  
  9088  	            // Working varialbes
  9089  	            var a = H[0];
  9090  	            var b = H[1];
  9091  	            var c = H[2];
  9092  	            var d = H[3];
  9093  
  9094  	            // Computation
  9095  	            a = FF(a, b, c, d, M_offset_0,  7,  T[0]);
  9096  	            d = FF(d, a, b, c, M_offset_1,  12, T[1]);
  9097  	            c = FF(c, d, a, b, M_offset_2,  17, T[2]);
  9098  	            b = FF(b, c, d, a, M_offset_3,  22, T[3]);
  9099  	            a = FF(a, b, c, d, M_offset_4,  7,  T[4]);
  9100  	            d = FF(d, a, b, c, M_offset_5,  12, T[5]);
  9101  	            c = FF(c, d, a, b, M_offset_6,  17, T[6]);
  9102  	            b = FF(b, c, d, a, M_offset_7,  22, T[7]);
  9103  	            a = FF(a, b, c, d, M_offset_8,  7,  T[8]);
  9104  	            d = FF(d, a, b, c, M_offset_9,  12, T[9]);
  9105  	            c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  9106  	            b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  9107  	            a = FF(a, b, c, d, M_offset_12, 7,  T[12]);
  9108  	            d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  9109  	            c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  9110  	            b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  9111  
  9112  	            a = GG(a, b, c, d, M_offset_1,  5,  T[16]);
  9113  	            d = GG(d, a, b, c, M_offset_6,  9,  T[17]);
  9114  	            c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  9115  	            b = GG(b, c, d, a, M_offset_0,  20, T[19]);
  9116  	            a = GG(a, b, c, d, M_offset_5,  5,  T[20]);
  9117  	            d = GG(d, a, b, c, M_offset_10, 9,  T[21]);
  9118  	            c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  9119  	            b = GG(b, c, d, a, M_offset_4,  20, T[23]);
  9120  	            a = GG(a, b, c, d, M_offset_9,  5,  T[24]);
  9121  	            d = GG(d, a, b, c, M_offset_14, 9,  T[25]);
  9122  	            c = GG(c, d, a, b, M_offset_3,  14, T[26]);
  9123  	            b = GG(b, c, d, a, M_offset_8,  20, T[27]);
  9124  	            a = GG(a, b, c, d, M_offset_13, 5,  T[28]);
  9125  	            d = GG(d, a, b, c, M_offset_2,  9,  T[29]);
  9126  	            c = GG(c, d, a, b, M_offset_7,  14, T[30]);
  9127  	            b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  9128  
  9129  	            a = HH(a, b, c, d, M_offset_5,  4,  T[32]);
  9130  	            d = HH(d, a, b, c, M_offset_8,  11, T[33]);
  9131  	            c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  9132  	            b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  9133  	            a = HH(a, b, c, d, M_offset_1,  4,  T[36]);
  9134  	            d = HH(d, a, b, c, M_offset_4,  11, T[37]);
  9135  	            c = HH(c, d, a, b, M_offset_7,  16, T[38]);
  9136  	            b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  9137  	            a = HH(a, b, c, d, M_offset_13, 4,  T[40]);
  9138  	            d = HH(d, a, b, c, M_offset_0,  11, T[41]);
  9139  	            c = HH(c, d, a, b, M_offset_3,  16, T[42]);
  9140  	            b = HH(b, c, d, a, M_offset_6,  23, T[43]);
  9141  	            a = HH(a, b, c, d, M_offset_9,  4,  T[44]);
  9142  	            d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  9143  	            c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  9144  	            b = HH(b, c, d, a, M_offset_2,  23, T[47]);
  9145  
  9146  	            a = II(a, b, c, d, M_offset_0,  6,  T[48]);
  9147  	            d = II(d, a, b, c, M_offset_7,  10, T[49]);
  9148  	            c = II(c, d, a, b, M_offset_14, 15, T[50]);
  9149  	            b = II(b, c, d, a, M_offset_5,  21, T[51]);
  9150  	            a = II(a, b, c, d, M_offset_12, 6,  T[52]);
  9151  	            d = II(d, a, b, c, M_offset_3,  10, T[53]);
  9152  	            c = II(c, d, a, b, M_offset_10, 15, T[54]);
  9153  	            b = II(b, c, d, a, M_offset_1,  21, T[55]);
  9154  	            a = II(a, b, c, d, M_offset_8,  6,  T[56]);
  9155  	            d = II(d, a, b, c, M_offset_15, 10, T[57]);
  9156  	            c = II(c, d, a, b, M_offset_6,  15, T[58]);
  9157  	            b = II(b, c, d, a, M_offset_13, 21, T[59]);
  9158  	            a = II(a, b, c, d, M_offset_4,  6,  T[60]);
  9159  	            d = II(d, a, b, c, M_offset_11, 10, T[61]);
  9160  	            c = II(c, d, a, b, M_offset_2,  15, T[62]);
  9161  	            b = II(b, c, d, a, M_offset_9,  21, T[63]);
  9162  
  9163  	            // Intermediate hash value
  9164  	            H[0] = (H[0] + a) | 0;
  9165  	            H[1] = (H[1] + b) | 0;
  9166  	            H[2] = (H[2] + c) | 0;
  9167  	            H[3] = (H[3] + d) | 0;
  9168  	        },
  9169  
  9170  	        _doFinalize: function () {
  9171  	            // Shortcuts
  9172  	            var data = this._data;
  9173  	            var dataWords = data.words;
  9174  
  9175  	            var nBitsTotal = this._nDataBytes * 8;
  9176  	            var nBitsLeft = data.sigBytes * 8;
  9177  
  9178  	            // Add padding
  9179  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  9180  
  9181  	            var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  9182  	            var nBitsTotalL = nBitsTotal;
  9183  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  9184  	                (((nBitsTotalH << 8)  | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  9185  	                (((nBitsTotalH << 24) | (nBitsTotalH >>> 8))  & 0xff00ff00)
  9186  	            );
  9187  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  9188  	                (((nBitsTotalL << 8)  | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  9189  	                (((nBitsTotalL << 24) | (nBitsTotalL >>> 8))  & 0xff00ff00)
  9190  	            );
  9191  
  9192  	            data.sigBytes = (dataWords.length + 1) * 4;
  9193  
  9194  	            // Hash final blocks
  9195  	            this._process();
  9196  
  9197  	            // Shortcuts
  9198  	            var hash = this._hash;
  9199  	            var H = hash.words;
  9200  
  9201  	            // Swap endian
  9202  	            for (var i = 0; i < 4; i++) {
  9203  	                // Shortcut
  9204  	                var H_i = H[i];
  9205  
  9206  	                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
  9207  	                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
  9208  	            }
  9209  
  9210  	            // Return final computed hash
  9211  	            return hash;
  9212  	        },
  9213  
  9214  	        clone: function () {
  9215  	            var clone = Hasher.clone.call(this);
  9216  	            clone._hash = this._hash.clone();
  9217  
  9218  	            return clone;
  9219  	        }
  9220  	    });
  9221  
  9222  	    function FF(a, b, c, d, x, s, t) {
  9223  	        var n = a + ((b & c) | (~b & d)) + x + t;
  9224  	        return ((n << s) | (n >>> (32 - s))) + b;
  9225  	    }
  9226  
  9227  	    function GG(a, b, c, d, x, s, t) {
  9228  	        var n = a + ((b & d) | (c & ~d)) + x + t;
  9229  	        return ((n << s) | (n >>> (32 - s))) + b;
  9230  	    }
  9231  
  9232  	    function HH(a, b, c, d, x, s, t) {
  9233  	        var n = a + (b ^ c ^ d) + x + t;
  9234  	        return ((n << s) | (n >>> (32 - s))) + b;
  9235  	    }
  9236  
  9237  	    function II(a, b, c, d, x, s, t) {
  9238  	        var n = a + (c ^ (b | ~d)) + x + t;
  9239  	        return ((n << s) | (n >>> (32 - s))) + b;
  9240  	    }
  9241  
  9242  	    /**
  9243  	     * Shortcut function to the hasher's object interface.
  9244  	     *
  9245  	     * @param {WordArray|string} message The message to hash.
  9246  	     *
  9247  	     * @return {WordArray} The hash.
  9248  	     *
  9249  	     * @static
  9250  	     *
  9251  	     * @example
  9252  	     *
  9253  	     *     var hash = CryptoJS.MD5('message');
  9254  	     *     var hash = CryptoJS.MD5(wordArray);
  9255  	     */
  9256  	    C.MD5 = Hasher._createHelper(MD5);
  9257  
  9258  	    /**
  9259  	     * Shortcut function to the HMAC's object interface.
  9260  	     *
  9261  	     * @param {WordArray|string} message The message to hash.
  9262  	     * @param {WordArray|string} key The secret key.
  9263  	     *
  9264  	     * @return {WordArray} The HMAC.
  9265  	     *
  9266  	     * @static
  9267  	     *
  9268  	     * @example
  9269  	     *
  9270  	     *     var hmac = CryptoJS.HmacMD5(message, key);
  9271  	     */
  9272  	    C.HmacMD5 = Hasher._createHmacHelper(MD5);
  9273  	}(Math));
  9274  
  9275  
  9276  	return CryptoJS.MD5;
  9277  
  9278  }));
  9279  },{"./core":52}],61:[function(require,module,exports){
  9280  ;(function (root, factory, undef) {
  9281  	if (typeof exports === "object") {
  9282  		// CommonJS
  9283  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9284  	}
  9285  	else if (typeof define === "function" && define.amd) {
  9286  		// AMD
  9287  		define(["./core", "./cipher-core"], factory);
  9288  	}
  9289  	else {
  9290  		// Global (browser)
  9291  		factory(root.CryptoJS);
  9292  	}
  9293  }(this, function (CryptoJS) {
  9294  
  9295  	/**
  9296  	 * Cipher Feedback block mode.
  9297  	 */
  9298  	CryptoJS.mode.CFB = (function () {
  9299  	    var CFB = CryptoJS.lib.BlockCipherMode.extend();
  9300  
  9301  	    CFB.Encryptor = CFB.extend({
  9302  	        processBlock: function (words, offset) {
  9303  	            // Shortcuts
  9304  	            var cipher = this._cipher;
  9305  	            var blockSize = cipher.blockSize;
  9306  
  9307  	            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9308  
  9309  	            // Remember this block to use with next block
  9310  	            this._prevBlock = words.slice(offset, offset + blockSize);
  9311  	        }
  9312  	    });
  9313  
  9314  	    CFB.Decryptor = CFB.extend({
  9315  	        processBlock: function (words, offset) {
  9316  	            // Shortcuts
  9317  	            var cipher = this._cipher;
  9318  	            var blockSize = cipher.blockSize;
  9319  
  9320  	            // Remember this block to use with next block
  9321  	            var thisBlock = words.slice(offset, offset + blockSize);
  9322  
  9323  	            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9324  
  9325  	            // This block becomes the previous block
  9326  	            this._prevBlock = thisBlock;
  9327  	        }
  9328  	    });
  9329  
  9330  	    function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
  9331  	        // Shortcut
  9332  	        var iv = this._iv;
  9333  
  9334  	        // Generate keystream
  9335  	        if (iv) {
  9336  	            var keystream = iv.slice(0);
  9337  
  9338  	            // Remove IV for subsequent blocks
  9339  	            this._iv = undefined;
  9340  	        } else {
  9341  	            var keystream = this._prevBlock;
  9342  	        }
  9343  	        cipher.encryptBlock(keystream, 0);
  9344  
  9345  	        // Encrypt
  9346  	        for (var i = 0; i < blockSize; i++) {
  9347  	            words[offset + i] ^= keystream[i];
  9348  	        }
  9349  	    }
  9350  
  9351  	    return CFB;
  9352  	}());
  9353  
  9354  
  9355  	return CryptoJS.mode.CFB;
  9356  
  9357  }));
  9358  },{"./cipher-core":51,"./core":52}],62:[function(require,module,exports){
  9359  ;(function (root, factory, undef) {
  9360  	if (typeof exports === "object") {
  9361  		// CommonJS
  9362  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9363  	}
  9364  	else if (typeof define === "function" && define.amd) {
  9365  		// AMD
  9366  		define(["./core", "./cipher-core"], factory);
  9367  	}
  9368  	else {
  9369  		// Global (browser)
  9370  		factory(root.CryptoJS);
  9371  	}
  9372  }(this, function (CryptoJS) {
  9373  
  9374  	/** @preserve
  9375  	 * Counter block mode compatible with  Dr Brian Gladman fileenc.c
  9376  	 * derived from CryptoJS.mode.CTR
  9377  	 * Jan Hruby jhruby.web@gmail.com
  9378  	 */
  9379  	CryptoJS.mode.CTRGladman = (function () {
  9380  	    var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
  9381  
  9382  		function incWord(word)
  9383  		{
  9384  			if (((word >> 24) & 0xff) === 0xff) { //overflow
  9385  			var b1 = (word >> 16)&0xff;
  9386  			var b2 = (word >> 8)&0xff;
  9387  			var b3 = word & 0xff;
  9388  
  9389  			if (b1 === 0xff) // overflow b1
  9390  			{
  9391  			b1 = 0;
  9392  			if (b2 === 0xff)
  9393  			{
  9394  				b2 = 0;
  9395  				if (b3 === 0xff)
  9396  				{
  9397  					b3 = 0;
  9398  				}
  9399  				else
  9400  				{
  9401  					++b3;
  9402  				}
  9403  			}
  9404  			else
  9405  			{
  9406  				++b2;
  9407  			}
  9408  			}
  9409  			else
  9410  			{
  9411  			++b1;
  9412  			}
  9413  
  9414  			word = 0;
  9415  			word += (b1 << 16);
  9416  			word += (b2 << 8);
  9417  			word += b3;
  9418  			}
  9419  			else
  9420  			{
  9421  			word += (0x01 << 24);
  9422  			}
  9423  			return word;
  9424  		}
  9425  
  9426  		function incCounter(counter)
  9427  		{
  9428  			if ((counter[0] = incWord(counter[0])) === 0)
  9429  			{
  9430  				// encr_data in fileenc.c from  Dr Brian Gladman's counts only with DWORD j < 8
  9431  				counter[1] = incWord(counter[1]);
  9432  			}
  9433  			return counter;
  9434  		}
  9435  
  9436  	    var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
  9437  	        processBlock: function (words, offset) {
  9438  	            // Shortcuts
  9439  	            var cipher = this._cipher
  9440  	            var blockSize = cipher.blockSize;
  9441  	            var iv = this._iv;
  9442  	            var counter = this._counter;
  9443  
  9444  	            // Generate keystream
  9445  	            if (iv) {
  9446  	                counter = this._counter = iv.slice(0);
  9447  
  9448  	                // Remove IV for subsequent blocks
  9449  	                this._iv = undefined;
  9450  	            }
  9451  
  9452  				incCounter(counter);
  9453  
  9454  				var keystream = counter.slice(0);
  9455  	            cipher.encryptBlock(keystream, 0);
  9456  
  9457  	            // Encrypt
  9458  	            for (var i = 0; i < blockSize; i++) {
  9459  	                words[offset + i] ^= keystream[i];
  9460  	            }
  9461  	        }
  9462  	    });
  9463  
  9464  	    CTRGladman.Decryptor = Encryptor;
  9465  
  9466  	    return CTRGladman;
  9467  	}());
  9468  
  9469  
  9470  
  9471  
  9472  	return CryptoJS.mode.CTRGladman;
  9473  
  9474  }));
  9475  },{"./cipher-core":51,"./core":52}],63:[function(require,module,exports){
  9476  ;(function (root, factory, undef) {
  9477  	if (typeof exports === "object") {
  9478  		// CommonJS
  9479  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9480  	}
  9481  	else if (typeof define === "function" && define.amd) {
  9482  		// AMD
  9483  		define(["./core", "./cipher-core"], factory);
  9484  	}
  9485  	else {
  9486  		// Global (browser)
  9487  		factory(root.CryptoJS);
  9488  	}
  9489  }(this, function (CryptoJS) {
  9490  
  9491  	/**
  9492  	 * Counter block mode.
  9493  	 */
  9494  	CryptoJS.mode.CTR = (function () {
  9495  	    var CTR = CryptoJS.lib.BlockCipherMode.extend();
  9496  
  9497  	    var Encryptor = CTR.Encryptor = CTR.extend({
  9498  	        processBlock: function (words, offset) {
  9499  	            // Shortcuts
  9500  	            var cipher = this._cipher
  9501  	            var blockSize = cipher.blockSize;
  9502  	            var iv = this._iv;
  9503  	            var counter = this._counter;
  9504  
  9505  	            // Generate keystream
  9506  	            if (iv) {
  9507  	                counter = this._counter = iv.slice(0);
  9508  
  9509  	                // Remove IV for subsequent blocks
  9510  	                this._iv = undefined;
  9511  	            }
  9512  	            var keystream = counter.slice(0);
  9513  	            cipher.encryptBlock(keystream, 0);
  9514  
  9515  	            // Increment counter
  9516  	            counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
  9517  
  9518  	            // Encrypt
  9519  	            for (var i = 0; i < blockSize; i++) {
  9520  	                words[offset + i] ^= keystream[i];
  9521  	            }
  9522  	        }
  9523  	    });
  9524  
  9525  	    CTR.Decryptor = Encryptor;
  9526  
  9527  	    return CTR;
  9528  	}());
  9529  
  9530  
  9531  	return CryptoJS.mode.CTR;
  9532  
  9533  }));
  9534  },{"./cipher-core":51,"./core":52}],64:[function(require,module,exports){
  9535  ;(function (root, factory, undef) {
  9536  	if (typeof exports === "object") {
  9537  		// CommonJS
  9538  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9539  	}
  9540  	else if (typeof define === "function" && define.amd) {
  9541  		// AMD
  9542  		define(["./core", "./cipher-core"], factory);
  9543  	}
  9544  	else {
  9545  		// Global (browser)
  9546  		factory(root.CryptoJS);
  9547  	}
  9548  }(this, function (CryptoJS) {
  9549  
  9550  	/**
  9551  	 * Electronic Codebook block mode.
  9552  	 */
  9553  	CryptoJS.mode.ECB = (function () {
  9554  	    var ECB = CryptoJS.lib.BlockCipherMode.extend();
  9555  
  9556  	    ECB.Encryptor = ECB.extend({
  9557  	        processBlock: function (words, offset) {
  9558  	            this._cipher.encryptBlock(words, offset);
  9559  	        }
  9560  	    });
  9561  
  9562  	    ECB.Decryptor = ECB.extend({
  9563  	        processBlock: function (words, offset) {
  9564  	            this._cipher.decryptBlock(words, offset);
  9565  	        }
  9566  	    });
  9567  
  9568  	    return ECB;
  9569  	}());
  9570  
  9571  
  9572  	return CryptoJS.mode.ECB;
  9573  
  9574  }));
  9575  },{"./cipher-core":51,"./core":52}],65:[function(require,module,exports){
  9576  ;(function (root, factory, undef) {
  9577  	if (typeof exports === "object") {
  9578  		// CommonJS
  9579  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9580  	}
  9581  	else if (typeof define === "function" && define.amd) {
  9582  		// AMD
  9583  		define(["./core", "./cipher-core"], factory);
  9584  	}
  9585  	else {
  9586  		// Global (browser)
  9587  		factory(root.CryptoJS);
  9588  	}
  9589  }(this, function (CryptoJS) {
  9590  
  9591  	/**
  9592  	 * Output Feedback block mode.
  9593  	 */
  9594  	CryptoJS.mode.OFB = (function () {
  9595  	    var OFB = CryptoJS.lib.BlockCipherMode.extend();
  9596  
  9597  	    var Encryptor = OFB.Encryptor = OFB.extend({
  9598  	        processBlock: function (words, offset) {
  9599  	            // Shortcuts
  9600  	            var cipher = this._cipher
  9601  	            var blockSize = cipher.blockSize;
  9602  	            var iv = this._iv;
  9603  	            var keystream = this._keystream;
  9604  
  9605  	            // Generate keystream
  9606  	            if (iv) {
  9607  	                keystream = this._keystream = iv.slice(0);
  9608  
  9609  	                // Remove IV for subsequent blocks
  9610  	                this._iv = undefined;
  9611  	            }
  9612  	            cipher.encryptBlock(keystream, 0);
  9613  
  9614  	            // Encrypt
  9615  	            for (var i = 0; i < blockSize; i++) {
  9616  	                words[offset + i] ^= keystream[i];
  9617  	            }
  9618  	        }
  9619  	    });
  9620  
  9621  	    OFB.Decryptor = Encryptor;
  9622  
  9623  	    return OFB;
  9624  	}());
  9625  
  9626  
  9627  	return CryptoJS.mode.OFB;
  9628  
  9629  }));
  9630  },{"./cipher-core":51,"./core":52}],66:[function(require,module,exports){
  9631  ;(function (root, factory, undef) {
  9632  	if (typeof exports === "object") {
  9633  		// CommonJS
  9634  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9635  	}
  9636  	else if (typeof define === "function" && define.amd) {
  9637  		// AMD
  9638  		define(["./core", "./cipher-core"], factory);
  9639  	}
  9640  	else {
  9641  		// Global (browser)
  9642  		factory(root.CryptoJS);
  9643  	}
  9644  }(this, function (CryptoJS) {
  9645  
  9646  	/**
  9647  	 * ANSI X.923 padding strategy.
  9648  	 */
  9649  	CryptoJS.pad.AnsiX923 = {
  9650  	    pad: function (data, blockSize) {
  9651  	        // Shortcuts
  9652  	        var dataSigBytes = data.sigBytes;
  9653  	        var blockSizeBytes = blockSize * 4;
  9654  
  9655  	        // Count padding bytes
  9656  	        var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
  9657  
  9658  	        // Compute last byte position
  9659  	        var lastBytePos = dataSigBytes + nPaddingBytes - 1;
  9660  
  9661  	        // Pad
  9662  	        data.clamp();
  9663  	        data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
  9664  	        data.sigBytes += nPaddingBytes;
  9665  	    },
  9666  
  9667  	    unpad: function (data) {
  9668  	        // Get number of padding bytes from last byte
  9669  	        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  9670  
  9671  	        // Remove padding
  9672  	        data.sigBytes -= nPaddingBytes;
  9673  	    }
  9674  	};
  9675  
  9676  
  9677  	return CryptoJS.pad.Ansix923;
  9678  
  9679  }));
  9680  },{"./cipher-core":51,"./core":52}],67:[function(require,module,exports){
  9681  ;(function (root, factory, undef) {
  9682  	if (typeof exports === "object") {
  9683  		// CommonJS
  9684  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9685  	}
  9686  	else if (typeof define === "function" && define.amd) {
  9687  		// AMD
  9688  		define(["./core", "./cipher-core"], factory);
  9689  	}
  9690  	else {
  9691  		// Global (browser)
  9692  		factory(root.CryptoJS);
  9693  	}
  9694  }(this, function (CryptoJS) {
  9695  
  9696  	/**
  9697  	 * ISO 10126 padding strategy.
  9698  	 */
  9699  	CryptoJS.pad.Iso10126 = {
  9700  	    pad: function (data, blockSize) {
  9701  	        // Shortcut
  9702  	        var blockSizeBytes = blockSize * 4;
  9703  
  9704  	        // Count padding bytes
  9705  	        var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  9706  
  9707  	        // Pad
  9708  	        data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
  9709  	             concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
  9710  	    },
  9711  
  9712  	    unpad: function (data) {
  9713  	        // Get number of padding bytes from last byte
  9714  	        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  9715  
  9716  	        // Remove padding
  9717  	        data.sigBytes -= nPaddingBytes;
  9718  	    }
  9719  	};
  9720  
  9721  
  9722  	return CryptoJS.pad.Iso10126;
  9723  
  9724  }));
  9725  },{"./cipher-core":51,"./core":52}],68:[function(require,module,exports){
  9726  ;(function (root, factory, undef) {
  9727  	if (typeof exports === "object") {
  9728  		// CommonJS
  9729  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9730  	}
  9731  	else if (typeof define === "function" && define.amd) {
  9732  		// AMD
  9733  		define(["./core", "./cipher-core"], factory);
  9734  	}
  9735  	else {
  9736  		// Global (browser)
  9737  		factory(root.CryptoJS);
  9738  	}
  9739  }(this, function (CryptoJS) {
  9740  
  9741  	/**
  9742  	 * ISO/IEC 9797-1 Padding Method 2.
  9743  	 */
  9744  	CryptoJS.pad.Iso97971 = {
  9745  	    pad: function (data, blockSize) {
  9746  	        // Add 0x80 byte
  9747  	        data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
  9748  
  9749  	        // Zero pad the rest
  9750  	        CryptoJS.pad.ZeroPadding.pad(data, blockSize);
  9751  	    },
  9752  
  9753  	    unpad: function (data) {
  9754  	        // Remove zero padding
  9755  	        CryptoJS.pad.ZeroPadding.unpad(data);
  9756  
  9757  	        // Remove one more byte -- the 0x80 byte
  9758  	        data.sigBytes--;
  9759  	    }
  9760  	};
  9761  
  9762  
  9763  	return CryptoJS.pad.Iso97971;
  9764  
  9765  }));
  9766  },{"./cipher-core":51,"./core":52}],69:[function(require,module,exports){
  9767  ;(function (root, factory, undef) {
  9768  	if (typeof exports === "object") {
  9769  		// CommonJS
  9770  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9771  	}
  9772  	else if (typeof define === "function" && define.amd) {
  9773  		// AMD
  9774  		define(["./core", "./cipher-core"], factory);
  9775  	}
  9776  	else {
  9777  		// Global (browser)
  9778  		factory(root.CryptoJS);
  9779  	}
  9780  }(this, function (CryptoJS) {
  9781  
  9782  	/**
  9783  	 * A noop padding strategy.
  9784  	 */
  9785  	CryptoJS.pad.NoPadding = {
  9786  	    pad: function () {
  9787  	    },
  9788  
  9789  	    unpad: function () {
  9790  	    }
  9791  	};
  9792  
  9793  
  9794  	return CryptoJS.pad.NoPadding;
  9795  
  9796  }));
  9797  },{"./cipher-core":51,"./core":52}],70:[function(require,module,exports){
  9798  ;(function (root, factory, undef) {
  9799  	if (typeof exports === "object") {
  9800  		// CommonJS
  9801  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9802  	}
  9803  	else if (typeof define === "function" && define.amd) {
  9804  		// AMD
  9805  		define(["./core", "./cipher-core"], factory);
  9806  	}
  9807  	else {
  9808  		// Global (browser)
  9809  		factory(root.CryptoJS);
  9810  	}
  9811  }(this, function (CryptoJS) {
  9812  
  9813  	/**
  9814  	 * Zero padding strategy.
  9815  	 */
  9816  	CryptoJS.pad.ZeroPadding = {
  9817  	    pad: function (data, blockSize) {
  9818  	        // Shortcut
  9819  	        var blockSizeBytes = blockSize * 4;
  9820  
  9821  	        // Pad
  9822  	        data.clamp();
  9823  	        data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
  9824  	    },
  9825  
  9826  	    unpad: function (data) {
  9827  	        // Shortcut
  9828  	        var dataWords = data.words;
  9829  
  9830  	        // Unpad
  9831  	        var i = data.sigBytes - 1;
  9832  	        while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
  9833  	            i--;
  9834  	        }
  9835  	        data.sigBytes = i + 1;
  9836  	    }
  9837  	};
  9838  
  9839  
  9840  	return CryptoJS.pad.ZeroPadding;
  9841  
  9842  }));
  9843  },{"./cipher-core":51,"./core":52}],71:[function(require,module,exports){
  9844  ;(function (root, factory, undef) {
  9845  	if (typeof exports === "object") {
  9846  		// CommonJS
  9847  		module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
  9848  	}
  9849  	else if (typeof define === "function" && define.amd) {
  9850  		// AMD
  9851  		define(["./core", "./sha1", "./hmac"], factory);
  9852  	}
  9853  	else {
  9854  		// Global (browser)
  9855  		factory(root.CryptoJS);
  9856  	}
  9857  }(this, function (CryptoJS) {
  9858  
  9859  	(function () {
  9860  	    // Shortcuts
  9861  	    var C = CryptoJS;
  9862  	    var C_lib = C.lib;
  9863  	    var Base = C_lib.Base;
  9864  	    var WordArray = C_lib.WordArray;
  9865  	    var C_algo = C.algo;
  9866  	    var SHA1 = C_algo.SHA1;
  9867  	    var HMAC = C_algo.HMAC;
  9868  
  9869  	    /**
  9870  	     * Password-Based Key Derivation Function 2 algorithm.
  9871  	     */
  9872  	    var PBKDF2 = C_algo.PBKDF2 = Base.extend({
  9873  	        /**
  9874  	         * Configuration options.
  9875  	         *
  9876  	         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  9877  	         * @property {Hasher} hasher The hasher to use. Default: SHA1
  9878  	         * @property {number} iterations The number of iterations to perform. Default: 1
  9879  	         */
  9880  	        cfg: Base.extend({
  9881  	            keySize: 128/32,
  9882  	            hasher: SHA1,
  9883  	            iterations: 1
  9884  	        }),
  9885  
  9886  	        /**
  9887  	         * Initializes a newly created key derivation function.
  9888  	         *
  9889  	         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  9890  	         *
  9891  	         * @example
  9892  	         *
  9893  	         *     var kdf = CryptoJS.algo.PBKDF2.create();
  9894  	         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
  9895  	         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
  9896  	         */
  9897  	        init: function (cfg) {
  9898  	            this.cfg = this.cfg.extend(cfg);
  9899  	        },
  9900  
  9901  	        /**
  9902  	         * Computes the Password-Based Key Derivation Function 2.
  9903  	         *
  9904  	         * @param {WordArray|string} password The password.
  9905  	         * @param {WordArray|string} salt A salt.
  9906  	         *
  9907  	         * @return {WordArray} The derived key.
  9908  	         *
  9909  	         * @example
  9910  	         *
  9911  	         *     var key = kdf.compute(password, salt);
  9912  	         */
  9913  	        compute: function (password, salt) {
  9914  	            // Shortcut
  9915  	            var cfg = this.cfg;
  9916  
  9917  	            // Init HMAC
  9918  	            var hmac = HMAC.create(cfg.hasher, password);
  9919  
  9920  	            // Initial values
  9921  	            var derivedKey = WordArray.create();
  9922  	            var blockIndex = WordArray.create([0x00000001]);
  9923  
  9924  	            // Shortcuts
  9925  	            var derivedKeyWords = derivedKey.words;
  9926  	            var blockIndexWords = blockIndex.words;
  9927  	            var keySize = cfg.keySize;
  9928  	            var iterations = cfg.iterations;
  9929  
  9930  	            // Generate key
  9931  	            while (derivedKeyWords.length < keySize) {
  9932  	                var block = hmac.update(salt).finalize(blockIndex);
  9933  	                hmac.reset();
  9934  
  9935  	                // Shortcuts
  9936  	                var blockWords = block.words;
  9937  	                var blockWordsLength = blockWords.length;
  9938  
  9939  	                // Iterations
  9940  	                var intermediate = block;
  9941  	                for (var i = 1; i < iterations; i++) {
  9942  	                    intermediate = hmac.finalize(intermediate);
  9943  	                    hmac.reset();
  9944  
  9945  	                    // Shortcut
  9946  	                    var intermediateWords = intermediate.words;
  9947  
  9948  	                    // XOR intermediate with block
  9949  	                    for (var j = 0; j < blockWordsLength; j++) {
  9950  	                        blockWords[j] ^= intermediateWords[j];
  9951  	                    }
  9952  	                }
  9953  
  9954  	                derivedKey.concat(block);
  9955  	                blockIndexWords[0]++;
  9956  	            }
  9957  	            derivedKey.sigBytes = keySize * 4;
  9958  
  9959  	            return derivedKey;
  9960  	        }
  9961  	    });
  9962  
  9963  	    /**
  9964  	     * Computes the Password-Based Key Derivation Function 2.
  9965  	     *
  9966  	     * @param {WordArray|string} password The password.
  9967  	     * @param {WordArray|string} salt A salt.
  9968  	     * @param {Object} cfg (Optional) The configuration options to use for this computation.
  9969  	     *
  9970  	     * @return {WordArray} The derived key.
  9971  	     *
  9972  	     * @static
  9973  	     *
  9974  	     * @example
  9975  	     *
  9976  	     *     var key = CryptoJS.PBKDF2(password, salt);
  9977  	     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
  9978  	     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
  9979  	     */
  9980  	    C.PBKDF2 = function (password, salt, cfg) {
  9981  	        return PBKDF2.create(cfg).compute(password, salt);
  9982  	    };
  9983  	}());
  9984  
  9985  
  9986  	return CryptoJS.PBKDF2;
  9987  
  9988  }));
  9989  },{"./core":52,"./hmac":57,"./sha1":76}],72:[function(require,module,exports){
  9990  ;(function (root, factory, undef) {
  9991  	if (typeof exports === "object") {
  9992  		// CommonJS
  9993  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  9994  	}
  9995  	else if (typeof define === "function" && define.amd) {
  9996  		// AMD
  9997  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  9998  	}
  9999  	else {
 10000  		// Global (browser)
 10001  		factory(root.CryptoJS);
 10002  	}
 10003  }(this, function (CryptoJS) {
 10004  
 10005  	(function () {
 10006  	    // Shortcuts
 10007  	    var C = CryptoJS;
 10008  	    var C_lib = C.lib;
 10009  	    var StreamCipher = C_lib.StreamCipher;
 10010  	    var C_algo = C.algo;
 10011  
 10012  	    // Reusable objects
 10013  	    var S  = [];
 10014  	    var C_ = [];
 10015  	    var G  = [];
 10016  
 10017  	    /**
 10018  	     * Rabbit stream cipher algorithm.
 10019  	     *
 10020  	     * This is a legacy version that neglected to convert the key to little-endian.
 10021  	     * This error doesn't affect the cipher's security,
 10022  	     * but it does affect its compatibility with other implementations.
 10023  	     */
 10024  	    var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
 10025  	        _doReset: function () {
 10026  	            // Shortcuts
 10027  	            var K = this._key.words;
 10028  	            var iv = this.cfg.iv;
 10029  
 10030  	            // Generate initial state values
 10031  	            var X = this._X = [
 10032  	                K[0], (K[3] << 16) | (K[2] >>> 16),
 10033  	                K[1], (K[0] << 16) | (K[3] >>> 16),
 10034  	                K[2], (K[1] << 16) | (K[0] >>> 16),
 10035  	                K[3], (K[2] << 16) | (K[1] >>> 16)
 10036  	            ];
 10037  
 10038  	            // Generate initial counter values
 10039  	            var C = this._C = [
 10040  	                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10041  	                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10042  	                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10043  	                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10044  	            ];
 10045  
 10046  	            // Carry bit
 10047  	            this._b = 0;
 10048  
 10049  	            // Iterate the system four times
 10050  	            for (var i = 0; i < 4; i++) {
 10051  	                nextState.call(this);
 10052  	            }
 10053  
 10054  	            // Modify the counters
 10055  	            for (var i = 0; i < 8; i++) {
 10056  	                C[i] ^= X[(i + 4) & 7];
 10057  	            }
 10058  
 10059  	            // IV setup
 10060  	            if (iv) {
 10061  	                // Shortcuts
 10062  	                var IV = iv.words;
 10063  	                var IV_0 = IV[0];
 10064  	                var IV_1 = IV[1];
 10065  
 10066  	                // Generate four subvectors
 10067  	                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10068  	                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10069  	                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10070  	                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10071  
 10072  	                // Modify counter values
 10073  	                C[0] ^= i0;
 10074  	                C[1] ^= i1;
 10075  	                C[2] ^= i2;
 10076  	                C[3] ^= i3;
 10077  	                C[4] ^= i0;
 10078  	                C[5] ^= i1;
 10079  	                C[6] ^= i2;
 10080  	                C[7] ^= i3;
 10081  
 10082  	                // Iterate the system four times
 10083  	                for (var i = 0; i < 4; i++) {
 10084  	                    nextState.call(this);
 10085  	                }
 10086  	            }
 10087  	        },
 10088  
 10089  	        _doProcessBlock: function (M, offset) {
 10090  	            // Shortcut
 10091  	            var X = this._X;
 10092  
 10093  	            // Iterate the system
 10094  	            nextState.call(this);
 10095  
 10096  	            // Generate four keystream words
 10097  	            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10098  	            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10099  	            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10100  	            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10101  
 10102  	            for (var i = 0; i < 4; i++) {
 10103  	                // Swap endian
 10104  	                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10105  	                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10106  
 10107  	                // Encrypt
 10108  	                M[offset + i] ^= S[i];
 10109  	            }
 10110  	        },
 10111  
 10112  	        blockSize: 128/32,
 10113  
 10114  	        ivSize: 64/32
 10115  	    });
 10116  
 10117  	    function nextState() {
 10118  	        // Shortcuts
 10119  	        var X = this._X;
 10120  	        var C = this._C;
 10121  
 10122  	        // Save old counter values
 10123  	        for (var i = 0; i < 8; i++) {
 10124  	            C_[i] = C[i];
 10125  	        }
 10126  
 10127  	        // Calculate new counter values
 10128  	        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10129  	        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10130  	        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10131  	        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10132  	        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10133  	        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10134  	        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10135  	        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10136  	        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10137  
 10138  	        // Calculate the g-values
 10139  	        for (var i = 0; i < 8; i++) {
 10140  	            var gx = X[i] + C[i];
 10141  
 10142  	            // Construct high and low argument for squaring
 10143  	            var ga = gx & 0xffff;
 10144  	            var gb = gx >>> 16;
 10145  
 10146  	            // Calculate high and low result of squaring
 10147  	            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10148  	            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10149  
 10150  	            // High XOR low
 10151  	            G[i] = gh ^ gl;
 10152  	        }
 10153  
 10154  	        // Calculate new state values
 10155  	        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10156  	        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10157  	        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10158  	        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10159  	        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10160  	        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10161  	        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10162  	        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10163  	    }
 10164  
 10165  	    /**
 10166  	     * Shortcut functions to the cipher's object interface.
 10167  	     *
 10168  	     * @example
 10169  	     *
 10170  	     *     var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
 10171  	     *     var plaintext  = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
 10172  	     */
 10173  	    C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
 10174  	}());
 10175  
 10176  
 10177  	return CryptoJS.RabbitLegacy;
 10178  
 10179  }));
 10180  },{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],73:[function(require,module,exports){
 10181  ;(function (root, factory, undef) {
 10182  	if (typeof exports === "object") {
 10183  		// CommonJS
 10184  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10185  	}
 10186  	else if (typeof define === "function" && define.amd) {
 10187  		// AMD
 10188  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10189  	}
 10190  	else {
 10191  		// Global (browser)
 10192  		factory(root.CryptoJS);
 10193  	}
 10194  }(this, function (CryptoJS) {
 10195  
 10196  	(function () {
 10197  	    // Shortcuts
 10198  	    var C = CryptoJS;
 10199  	    var C_lib = C.lib;
 10200  	    var StreamCipher = C_lib.StreamCipher;
 10201  	    var C_algo = C.algo;
 10202  
 10203  	    // Reusable objects
 10204  	    var S  = [];
 10205  	    var C_ = [];
 10206  	    var G  = [];
 10207  
 10208  	    /**
 10209  	     * Rabbit stream cipher algorithm
 10210  	     */
 10211  	    var Rabbit = C_algo.Rabbit = StreamCipher.extend({
 10212  	        _doReset: function () {
 10213  	            // Shortcuts
 10214  	            var K = this._key.words;
 10215  	            var iv = this.cfg.iv;
 10216  
 10217  	            // Swap endian
 10218  	            for (var i = 0; i < 4; i++) {
 10219  	                K[i] = (((K[i] << 8)  | (K[i] >>> 24)) & 0x00ff00ff) |
 10220  	                       (((K[i] << 24) | (K[i] >>> 8))  & 0xff00ff00);
 10221  	            }
 10222  
 10223  	            // Generate initial state values
 10224  	            var X = this._X = [
 10225  	                K[0], (K[3] << 16) | (K[2] >>> 16),
 10226  	                K[1], (K[0] << 16) | (K[3] >>> 16),
 10227  	                K[2], (K[1] << 16) | (K[0] >>> 16),
 10228  	                K[3], (K[2] << 16) | (K[1] >>> 16)
 10229  	            ];
 10230  
 10231  	            // Generate initial counter values
 10232  	            var C = this._C = [
 10233  	                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10234  	                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10235  	                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10236  	                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10237  	            ];
 10238  
 10239  	            // Carry bit
 10240  	            this._b = 0;
 10241  
 10242  	            // Iterate the system four times
 10243  	            for (var i = 0; i < 4; i++) {
 10244  	                nextState.call(this);
 10245  	            }
 10246  
 10247  	            // Modify the counters
 10248  	            for (var i = 0; i < 8; i++) {
 10249  	                C[i] ^= X[(i + 4) & 7];
 10250  	            }
 10251  
 10252  	            // IV setup
 10253  	            if (iv) {
 10254  	                // Shortcuts
 10255  	                var IV = iv.words;
 10256  	                var IV_0 = IV[0];
 10257  	                var IV_1 = IV[1];
 10258  
 10259  	                // Generate four subvectors
 10260  	                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10261  	                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10262  	                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10263  	                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10264  
 10265  	                // Modify counter values
 10266  	                C[0] ^= i0;
 10267  	                C[1] ^= i1;
 10268  	                C[2] ^= i2;
 10269  	                C[3] ^= i3;
 10270  	                C[4] ^= i0;
 10271  	                C[5] ^= i1;
 10272  	                C[6] ^= i2;
 10273  	                C[7] ^= i3;
 10274  
 10275  	                // Iterate the system four times
 10276  	                for (var i = 0; i < 4; i++) {
 10277  	                    nextState.call(this);
 10278  	                }
 10279  	            }
 10280  	        },
 10281  
 10282  	        _doProcessBlock: function (M, offset) {
 10283  	            // Shortcut
 10284  	            var X = this._X;
 10285  
 10286  	            // Iterate the system
 10287  	            nextState.call(this);
 10288  
 10289  	            // Generate four keystream words
 10290  	            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10291  	            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10292  	            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10293  	            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10294  
 10295  	            for (var i = 0; i < 4; i++) {
 10296  	                // Swap endian
 10297  	                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10298  	                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10299  
 10300  	                // Encrypt
 10301  	                M[offset + i] ^= S[i];
 10302  	            }
 10303  	        },
 10304  
 10305  	        blockSize: 128/32,
 10306  
 10307  	        ivSize: 64/32
 10308  	    });
 10309  
 10310  	    function nextState() {
 10311  	        // Shortcuts
 10312  	        var X = this._X;
 10313  	        var C = this._C;
 10314  
 10315  	        // Save old counter values
 10316  	        for (var i = 0; i < 8; i++) {
 10317  	            C_[i] = C[i];
 10318  	        }
 10319  
 10320  	        // Calculate new counter values
 10321  	        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10322  	        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10323  	        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10324  	        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10325  	        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10326  	        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10327  	        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10328  	        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10329  	        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10330  
 10331  	        // Calculate the g-values
 10332  	        for (var i = 0; i < 8; i++) {
 10333  	            var gx = X[i] + C[i];
 10334  
 10335  	            // Construct high and low argument for squaring
 10336  	            var ga = gx & 0xffff;
 10337  	            var gb = gx >>> 16;
 10338  
 10339  	            // Calculate high and low result of squaring
 10340  	            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10341  	            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10342  
 10343  	            // High XOR low
 10344  	            G[i] = gh ^ gl;
 10345  	        }
 10346  
 10347  	        // Calculate new state values
 10348  	        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10349  	        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10350  	        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10351  	        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10352  	        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10353  	        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10354  	        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10355  	        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10356  	    }
 10357  
 10358  	    /**
 10359  	     * Shortcut functions to the cipher's object interface.
 10360  	     *
 10361  	     * @example
 10362  	     *
 10363  	     *     var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
 10364  	     *     var plaintext  = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
 10365  	     */
 10366  	    C.Rabbit = StreamCipher._createHelper(Rabbit);
 10367  	}());
 10368  
 10369  
 10370  	return CryptoJS.Rabbit;
 10371  
 10372  }));
 10373  },{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],74:[function(require,module,exports){
 10374  ;(function (root, factory, undef) {
 10375  	if (typeof exports === "object") {
 10376  		// CommonJS
 10377  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10378  	}
 10379  	else if (typeof define === "function" && define.amd) {
 10380  		// AMD
 10381  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10382  	}
 10383  	else {
 10384  		// Global (browser)
 10385  		factory(root.CryptoJS);
 10386  	}
 10387  }(this, function (CryptoJS) {
 10388  
 10389  	(function () {
 10390  	    // Shortcuts
 10391  	    var C = CryptoJS;
 10392  	    var C_lib = C.lib;
 10393  	    var StreamCipher = C_lib.StreamCipher;
 10394  	    var C_algo = C.algo;
 10395  
 10396  	    /**
 10397  	     * RC4 stream cipher algorithm.
 10398  	     */
 10399  	    var RC4 = C_algo.RC4 = StreamCipher.extend({
 10400  	        _doReset: function () {
 10401  	            // Shortcuts
 10402  	            var key = this._key;
 10403  	            var keyWords = key.words;
 10404  	            var keySigBytes = key.sigBytes;
 10405  
 10406  	            // Init sbox
 10407  	            var S = this._S = [];
 10408  	            for (var i = 0; i < 256; i++) {
 10409  	                S[i] = i;
 10410  	            }
 10411  
 10412  	            // Key setup
 10413  	            for (var i = 0, j = 0; i < 256; i++) {
 10414  	                var keyByteIndex = i % keySigBytes;
 10415  	                var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
 10416  
 10417  	                j = (j + S[i] + keyByte) % 256;
 10418  
 10419  	                // Swap
 10420  	                var t = S[i];
 10421  	                S[i] = S[j];
 10422  	                S[j] = t;
 10423  	            }
 10424  
 10425  	            // Counters
 10426  	            this._i = this._j = 0;
 10427  	        },
 10428  
 10429  	        _doProcessBlock: function (M, offset) {
 10430  	            M[offset] ^= generateKeystreamWord.call(this);
 10431  	        },
 10432  
 10433  	        keySize: 256/32,
 10434  
 10435  	        ivSize: 0
 10436  	    });
 10437  
 10438  	    function generateKeystreamWord() {
 10439  	        // Shortcuts
 10440  	        var S = this._S;
 10441  	        var i = this._i;
 10442  	        var j = this._j;
 10443  
 10444  	        // Generate keystream word
 10445  	        var keystreamWord = 0;
 10446  	        for (var n = 0; n < 4; n++) {
 10447  	            i = (i + 1) % 256;
 10448  	            j = (j + S[i]) % 256;
 10449  
 10450  	            // Swap
 10451  	            var t = S[i];
 10452  	            S[i] = S[j];
 10453  	            S[j] = t;
 10454  
 10455  	            keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
 10456  	        }
 10457  
 10458  	        // Update counters
 10459  	        this._i = i;
 10460  	        this._j = j;
 10461  
 10462  	        return keystreamWord;
 10463  	    }
 10464  
 10465  	    /**
 10466  	     * Shortcut functions to the cipher's object interface.
 10467  	     *
 10468  	     * @example
 10469  	     *
 10470  	     *     var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
 10471  	     *     var plaintext  = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
 10472  	     */
 10473  	    C.RC4 = StreamCipher._createHelper(RC4);
 10474  
 10475  	    /**
 10476  	     * Modified RC4 stream cipher algorithm.
 10477  	     */
 10478  	    var RC4Drop = C_algo.RC4Drop = RC4.extend({
 10479  	        /**
 10480  	         * Configuration options.
 10481  	         *
 10482  	         * @property {number} drop The number of keystream words to drop. Default 192
 10483  	         */
 10484  	        cfg: RC4.cfg.extend({
 10485  	            drop: 192
 10486  	        }),
 10487  
 10488  	        _doReset: function () {
 10489  	            RC4._doReset.call(this);
 10490  
 10491  	            // Drop
 10492  	            for (var i = this.cfg.drop; i > 0; i--) {
 10493  	                generateKeystreamWord.call(this);
 10494  	            }
 10495  	        }
 10496  	    });
 10497  
 10498  	    /**
 10499  	     * Shortcut functions to the cipher's object interface.
 10500  	     *
 10501  	     * @example
 10502  	     *
 10503  	     *     var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
 10504  	     *     var plaintext  = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
 10505  	     */
 10506  	    C.RC4Drop = StreamCipher._createHelper(RC4Drop);
 10507  	}());
 10508  
 10509  
 10510  	return CryptoJS.RC4;
 10511  
 10512  }));
 10513  },{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],75:[function(require,module,exports){
 10514  ;(function (root, factory) {
 10515  	if (typeof exports === "object") {
 10516  		// CommonJS
 10517  		module.exports = exports = factory(require("./core"));
 10518  	}
 10519  	else if (typeof define === "function" && define.amd) {
 10520  		// AMD
 10521  		define(["./core"], factory);
 10522  	}
 10523  	else {
 10524  		// Global (browser)
 10525  		factory(root.CryptoJS);
 10526  	}
 10527  }(this, function (CryptoJS) {
 10528  
 10529  	/** @preserve
 10530  	(c) 2012 by Cédric Mesnil. All rights reserved.
 10531  
 10532  	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 10533  
 10534  	    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 10535  	    - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 10536  
 10537  	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 10538  	*/
 10539  
 10540  	(function (Math) {
 10541  	    // Shortcuts
 10542  	    var C = CryptoJS;
 10543  	    var C_lib = C.lib;
 10544  	    var WordArray = C_lib.WordArray;
 10545  	    var Hasher = C_lib.Hasher;
 10546  	    var C_algo = C.algo;
 10547  
 10548  	    // Constants table
 10549  	    var _zl = WordArray.create([
 10550  	        0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
 10551  	        7,  4, 13,  1, 10,  6, 15,  3, 12,  0,  9,  5,  2, 14, 11,  8,
 10552  	        3, 10, 14,  4,  9, 15,  8,  1,  2,  7,  0,  6, 13, 11,  5, 12,
 10553  	        1,  9, 11, 10,  0,  8, 12,  4, 13,  3,  7, 15, 14,  5,  6,  2,
 10554  	        4,  0,  5,  9,  7, 12,  2, 10, 14,  1,  3,  8, 11,  6, 15, 13]);
 10555  	    var _zr = WordArray.create([
 10556  	        5, 14,  7,  0,  9,  2, 11,  4, 13,  6, 15,  8,  1, 10,  3, 12,
 10557  	        6, 11,  3,  7,  0, 13,  5, 10, 14, 15,  8, 12,  4,  9,  1,  2,
 10558  	        15,  5,  1,  3,  7, 14,  6,  9, 11,  8, 12,  2, 10,  0,  4, 13,
 10559  	        8,  6,  4,  1,  3, 11, 15,  0,  5, 12,  2, 13,  9,  7, 10, 14,
 10560  	        12, 15, 10,  4,  1,  5,  8,  7,  6,  2, 13, 14,  0,  3,  9, 11]);
 10561  	    var _sl = WordArray.create([
 10562  	         11, 14, 15, 12,  5,  8,  7,  9, 11, 13, 14, 15,  6,  7,  9,  8,
 10563  	        7, 6,   8, 13, 11,  9,  7, 15,  7, 12, 15,  9, 11,  7, 13, 12,
 10564  	        11, 13,  6,  7, 14,  9, 13, 15, 14,  8, 13,  6,  5, 12,  7,  5,
 10565  	          11, 12, 14, 15, 14, 15,  9,  8,  9, 14,  5,  6,  8,  6,  5, 12,
 10566  	        9, 15,  5, 11,  6,  8, 13, 12,  5, 12, 13, 14, 11,  8,  5,  6 ]);
 10567  	    var _sr = WordArray.create([
 10568  	        8,  9,  9, 11, 13, 15, 15,  5,  7,  7,  8, 11, 14, 14, 12,  6,
 10569  	        9, 13, 15,  7, 12,  8,  9, 11,  7,  7, 12,  7,  6, 15, 13, 11,
 10570  	        9,  7, 15, 11,  8,  6,  6, 14, 12, 13,  5, 14, 13, 13,  7,  5,
 10571  	        15,  5,  8, 11, 14, 14,  6, 14,  6,  9, 12,  9, 12,  5, 15,  8,
 10572  	        8,  5, 12,  9, 12,  5, 14,  6,  8, 13,  6,  5, 15, 13, 11, 11 ]);
 10573  
 10574  	    var _hl =  WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
 10575  	    var _hr =  WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
 10576  
 10577  	    /**
 10578  	     * RIPEMD160 hash algorithm.
 10579  	     */
 10580  	    var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
 10581  	        _doReset: function () {
 10582  	            this._hash  = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
 10583  	        },
 10584  
 10585  	        _doProcessBlock: function (M, offset) {
 10586  
 10587  	            // Swap endian
 10588  	            for (var i = 0; i < 16; i++) {
 10589  	                // Shortcuts
 10590  	                var offset_i = offset + i;
 10591  	                var M_offset_i = M[offset_i];
 10592  
 10593  	                // Swap
 10594  	                M[offset_i] = (
 10595  	                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
 10596  	                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
 10597  	                );
 10598  	            }
 10599  	            // Shortcut
 10600  	            var H  = this._hash.words;
 10601  	            var hl = _hl.words;
 10602  	            var hr = _hr.words;
 10603  	            var zl = _zl.words;
 10604  	            var zr = _zr.words;
 10605  	            var sl = _sl.words;
 10606  	            var sr = _sr.words;
 10607  
 10608  	            // Working variables
 10609  	            var al, bl, cl, dl, el;
 10610  	            var ar, br, cr, dr, er;
 10611  
 10612  	            ar = al = H[0];
 10613  	            br = bl = H[1];
 10614  	            cr = cl = H[2];
 10615  	            dr = dl = H[3];
 10616  	            er = el = H[4];
 10617  	            // Computation
 10618  	            var t;
 10619  	            for (var i = 0; i < 80; i += 1) {
 10620  	                t = (al +  M[offset+zl[i]])|0;
 10621  	                if (i<16){
 10622  		            t +=  f1(bl,cl,dl) + hl[0];
 10623  	                } else if (i<32) {
 10624  		            t +=  f2(bl,cl,dl) + hl[1];
 10625  	                } else if (i<48) {
 10626  		            t +=  f3(bl,cl,dl) + hl[2];
 10627  	                } else if (i<64) {
 10628  		            t +=  f4(bl,cl,dl) + hl[3];
 10629  	                } else {// if (i<80) {
 10630  		            t +=  f5(bl,cl,dl) + hl[4];
 10631  	                }
 10632  	                t = t|0;
 10633  	                t =  rotl(t,sl[i]);
 10634  	                t = (t+el)|0;
 10635  	                al = el;
 10636  	                el = dl;
 10637  	                dl = rotl(cl, 10);
 10638  	                cl = bl;
 10639  	                bl = t;
 10640  
 10641  	                t = (ar + M[offset+zr[i]])|0;
 10642  	                if (i<16){
 10643  		            t +=  f5(br,cr,dr) + hr[0];
 10644  	                } else if (i<32) {
 10645  		            t +=  f4(br,cr,dr) + hr[1];
 10646  	                } else if (i<48) {
 10647  		            t +=  f3(br,cr,dr) + hr[2];
 10648  	                } else if (i<64) {
 10649  		            t +=  f2(br,cr,dr) + hr[3];
 10650  	                } else {// if (i<80) {
 10651  		            t +=  f1(br,cr,dr) + hr[4];
 10652  	                }
 10653  	                t = t|0;
 10654  	                t =  rotl(t,sr[i]) ;
 10655  	                t = (t+er)|0;
 10656  	                ar = er;
 10657  	                er = dr;
 10658  	                dr = rotl(cr, 10);
 10659  	                cr = br;
 10660  	                br = t;
 10661  	            }
 10662  	            // Intermediate hash value
 10663  	            t    = (H[1] + cl + dr)|0;
 10664  	            H[1] = (H[2] + dl + er)|0;
 10665  	            H[2] = (H[3] + el + ar)|0;
 10666  	            H[3] = (H[4] + al + br)|0;
 10667  	            H[4] = (H[0] + bl + cr)|0;
 10668  	            H[0] =  t;
 10669  	        },
 10670  
 10671  	        _doFinalize: function () {
 10672  	            // Shortcuts
 10673  	            var data = this._data;
 10674  	            var dataWords = data.words;
 10675  
 10676  	            var nBitsTotal = this._nDataBytes * 8;
 10677  	            var nBitsLeft = data.sigBytes * 8;
 10678  
 10679  	            // Add padding
 10680  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 10681  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
 10682  	                (((nBitsTotal << 8)  | (nBitsTotal >>> 24)) & 0x00ff00ff) |
 10683  	                (((nBitsTotal << 24) | (nBitsTotal >>> 8))  & 0xff00ff00)
 10684  	            );
 10685  	            data.sigBytes = (dataWords.length + 1) * 4;
 10686  
 10687  	            // Hash final blocks
 10688  	            this._process();
 10689  
 10690  	            // Shortcuts
 10691  	            var hash = this._hash;
 10692  	            var H = hash.words;
 10693  
 10694  	            // Swap endian
 10695  	            for (var i = 0; i < 5; i++) {
 10696  	                // Shortcut
 10697  	                var H_i = H[i];
 10698  
 10699  	                // Swap
 10700  	                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
 10701  	                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
 10702  	            }
 10703  
 10704  	            // Return final computed hash
 10705  	            return hash;
 10706  	        },
 10707  
 10708  	        clone: function () {
 10709  	            var clone = Hasher.clone.call(this);
 10710  	            clone._hash = this._hash.clone();
 10711  
 10712  	            return clone;
 10713  	        }
 10714  	    });
 10715  
 10716  
 10717  	    function f1(x, y, z) {
 10718  	        return ((x) ^ (y) ^ (z));
 10719  
 10720  	    }
 10721  
 10722  	    function f2(x, y, z) {
 10723  	        return (((x)&(y)) | ((~x)&(z)));
 10724  	    }
 10725  
 10726  	    function f3(x, y, z) {
 10727  	        return (((x) | (~(y))) ^ (z));
 10728  	    }
 10729  
 10730  	    function f4(x, y, z) {
 10731  	        return (((x) & (z)) | ((y)&(~(z))));
 10732  	    }
 10733  
 10734  	    function f5(x, y, z) {
 10735  	        return ((x) ^ ((y) |(~(z))));
 10736  
 10737  	    }
 10738  
 10739  	    function rotl(x,n) {
 10740  	        return (x<<n) | (x>>>(32-n));
 10741  	    }
 10742  
 10743  
 10744  	    /**
 10745  	     * Shortcut function to the hasher's object interface.
 10746  	     *
 10747  	     * @param {WordArray|string} message The message to hash.
 10748  	     *
 10749  	     * @return {WordArray} The hash.
 10750  	     *
 10751  	     * @static
 10752  	     *
 10753  	     * @example
 10754  	     *
 10755  	     *     var hash = CryptoJS.RIPEMD160('message');
 10756  	     *     var hash = CryptoJS.RIPEMD160(wordArray);
 10757  	     */
 10758  	    C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
 10759  
 10760  	    /**
 10761  	     * Shortcut function to the HMAC's object interface.
 10762  	     *
 10763  	     * @param {WordArray|string} message The message to hash.
 10764  	     * @param {WordArray|string} key The secret key.
 10765  	     *
 10766  	     * @return {WordArray} The HMAC.
 10767  	     *
 10768  	     * @static
 10769  	     *
 10770  	     * @example
 10771  	     *
 10772  	     *     var hmac = CryptoJS.HmacRIPEMD160(message, key);
 10773  	     */
 10774  	    C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
 10775  	}(Math));
 10776  
 10777  
 10778  	return CryptoJS.RIPEMD160;
 10779  
 10780  }));
 10781  },{"./core":52}],76:[function(require,module,exports){
 10782  ;(function (root, factory) {
 10783  	if (typeof exports === "object") {
 10784  		// CommonJS
 10785  		module.exports = exports = factory(require("./core"));
 10786  	}
 10787  	else if (typeof define === "function" && define.amd) {
 10788  		// AMD
 10789  		define(["./core"], factory);
 10790  	}
 10791  	else {
 10792  		// Global (browser)
 10793  		factory(root.CryptoJS);
 10794  	}
 10795  }(this, function (CryptoJS) {
 10796  
 10797  	(function () {
 10798  	    // Shortcuts
 10799  	    var C = CryptoJS;
 10800  	    var C_lib = C.lib;
 10801  	    var WordArray = C_lib.WordArray;
 10802  	    var Hasher = C_lib.Hasher;
 10803  	    var C_algo = C.algo;
 10804  
 10805  	    // Reusable object
 10806  	    var W = [];
 10807  
 10808  	    /**
 10809  	     * SHA-1 hash algorithm.
 10810  	     */
 10811  	    var SHA1 = C_algo.SHA1 = Hasher.extend({
 10812  	        _doReset: function () {
 10813  	            this._hash = new WordArray.init([
 10814  	                0x67452301, 0xefcdab89,
 10815  	                0x98badcfe, 0x10325476,
 10816  	                0xc3d2e1f0
 10817  	            ]);
 10818  	        },
 10819  
 10820  	        _doProcessBlock: function (M, offset) {
 10821  	            // Shortcut
 10822  	            var H = this._hash.words;
 10823  
 10824  	            // Working variables
 10825  	            var a = H[0];
 10826  	            var b = H[1];
 10827  	            var c = H[2];
 10828  	            var d = H[3];
 10829  	            var e = H[4];
 10830  
 10831  	            // Computation
 10832  	            for (var i = 0; i < 80; i++) {
 10833  	                if (i < 16) {
 10834  	                    W[i] = M[offset + i] | 0;
 10835  	                } else {
 10836  	                    var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
 10837  	                    W[i] = (n << 1) | (n >>> 31);
 10838  	                }
 10839  
 10840  	                var t = ((a << 5) | (a >>> 27)) + e + W[i];
 10841  	                if (i < 20) {
 10842  	                    t += ((b & c) | (~b & d)) + 0x5a827999;
 10843  	                } else if (i < 40) {
 10844  	                    t += (b ^ c ^ d) + 0x6ed9eba1;
 10845  	                } else if (i < 60) {
 10846  	                    t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
 10847  	                } else /* if (i < 80) */ {
 10848  	                    t += (b ^ c ^ d) - 0x359d3e2a;
 10849  	                }
 10850  
 10851  	                e = d;
 10852  	                d = c;
 10853  	                c = (b << 30) | (b >>> 2);
 10854  	                b = a;
 10855  	                a = t;
 10856  	            }
 10857  
 10858  	            // Intermediate hash value
 10859  	            H[0] = (H[0] + a) | 0;
 10860  	            H[1] = (H[1] + b) | 0;
 10861  	            H[2] = (H[2] + c) | 0;
 10862  	            H[3] = (H[3] + d) | 0;
 10863  	            H[4] = (H[4] + e) | 0;
 10864  	        },
 10865  
 10866  	        _doFinalize: function () {
 10867  	            // Shortcuts
 10868  	            var data = this._data;
 10869  	            var dataWords = data.words;
 10870  
 10871  	            var nBitsTotal = this._nDataBytes * 8;
 10872  	            var nBitsLeft = data.sigBytes * 8;
 10873  
 10874  	            // Add padding
 10875  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 10876  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 10877  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 10878  	            data.sigBytes = dataWords.length * 4;
 10879  
 10880  	            // Hash final blocks
 10881  	            this._process();
 10882  
 10883  	            // Return final computed hash
 10884  	            return this._hash;
 10885  	        },
 10886  
 10887  	        clone: function () {
 10888  	            var clone = Hasher.clone.call(this);
 10889  	            clone._hash = this._hash.clone();
 10890  
 10891  	            return clone;
 10892  	        }
 10893  	    });
 10894  
 10895  	    /**
 10896  	     * Shortcut function to the hasher's object interface.
 10897  	     *
 10898  	     * @param {WordArray|string} message The message to hash.
 10899  	     *
 10900  	     * @return {WordArray} The hash.
 10901  	     *
 10902  	     * @static
 10903  	     *
 10904  	     * @example
 10905  	     *
 10906  	     *     var hash = CryptoJS.SHA1('message');
 10907  	     *     var hash = CryptoJS.SHA1(wordArray);
 10908  	     */
 10909  	    C.SHA1 = Hasher._createHelper(SHA1);
 10910  
 10911  	    /**
 10912  	     * Shortcut function to the HMAC's object interface.
 10913  	     *
 10914  	     * @param {WordArray|string} message The message to hash.
 10915  	     * @param {WordArray|string} key The secret key.
 10916  	     *
 10917  	     * @return {WordArray} The HMAC.
 10918  	     *
 10919  	     * @static
 10920  	     *
 10921  	     * @example
 10922  	     *
 10923  	     *     var hmac = CryptoJS.HmacSHA1(message, key);
 10924  	     */
 10925  	    C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
 10926  	}());
 10927  
 10928  
 10929  	return CryptoJS.SHA1;
 10930  
 10931  }));
 10932  },{"./core":52}],77:[function(require,module,exports){
 10933  ;(function (root, factory, undef) {
 10934  	if (typeof exports === "object") {
 10935  		// CommonJS
 10936  		module.exports = exports = factory(require("./core"), require("./sha256"));
 10937  	}
 10938  	else if (typeof define === "function" && define.amd) {
 10939  		// AMD
 10940  		define(["./core", "./sha256"], factory);
 10941  	}
 10942  	else {
 10943  		// Global (browser)
 10944  		factory(root.CryptoJS);
 10945  	}
 10946  }(this, function (CryptoJS) {
 10947  
 10948  	(function () {
 10949  	    // Shortcuts
 10950  	    var C = CryptoJS;
 10951  	    var C_lib = C.lib;
 10952  	    var WordArray = C_lib.WordArray;
 10953  	    var C_algo = C.algo;
 10954  	    var SHA256 = C_algo.SHA256;
 10955  
 10956  	    /**
 10957  	     * SHA-224 hash algorithm.
 10958  	     */
 10959  	    var SHA224 = C_algo.SHA224 = SHA256.extend({
 10960  	        _doReset: function () {
 10961  	            this._hash = new WordArray.init([
 10962  	                0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
 10963  	                0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
 10964  	            ]);
 10965  	        },
 10966  
 10967  	        _doFinalize: function () {
 10968  	            var hash = SHA256._doFinalize.call(this);
 10969  
 10970  	            hash.sigBytes -= 4;
 10971  
 10972  	            return hash;
 10973  	        }
 10974  	    });
 10975  
 10976  	    /**
 10977  	     * Shortcut function to the hasher's object interface.
 10978  	     *
 10979  	     * @param {WordArray|string} message The message to hash.
 10980  	     *
 10981  	     * @return {WordArray} The hash.
 10982  	     *
 10983  	     * @static
 10984  	     *
 10985  	     * @example
 10986  	     *
 10987  	     *     var hash = CryptoJS.SHA224('message');
 10988  	     *     var hash = CryptoJS.SHA224(wordArray);
 10989  	     */
 10990  	    C.SHA224 = SHA256._createHelper(SHA224);
 10991  
 10992  	    /**
 10993  	     * Shortcut function to the HMAC's object interface.
 10994  	     *
 10995  	     * @param {WordArray|string} message The message to hash.
 10996  	     * @param {WordArray|string} key The secret key.
 10997  	     *
 10998  	     * @return {WordArray} The HMAC.
 10999  	     *
 11000  	     * @static
 11001  	     *
 11002  	     * @example
 11003  	     *
 11004  	     *     var hmac = CryptoJS.HmacSHA224(message, key);
 11005  	     */
 11006  	    C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
 11007  	}());
 11008  
 11009  
 11010  	return CryptoJS.SHA224;
 11011  
 11012  }));
 11013  },{"./core":52,"./sha256":78}],78:[function(require,module,exports){
 11014  ;(function (root, factory) {
 11015  	if (typeof exports === "object") {
 11016  		// CommonJS
 11017  		module.exports = exports = factory(require("./core"));
 11018  	}
 11019  	else if (typeof define === "function" && define.amd) {
 11020  		// AMD
 11021  		define(["./core"], factory);
 11022  	}
 11023  	else {
 11024  		// Global (browser)
 11025  		factory(root.CryptoJS);
 11026  	}
 11027  }(this, function (CryptoJS) {
 11028  
 11029  	(function (Math) {
 11030  	    // Shortcuts
 11031  	    var C = CryptoJS;
 11032  	    var C_lib = C.lib;
 11033  	    var WordArray = C_lib.WordArray;
 11034  	    var Hasher = C_lib.Hasher;
 11035  	    var C_algo = C.algo;
 11036  
 11037  	    // Initialization and round constants tables
 11038  	    var H = [];
 11039  	    var K = [];
 11040  
 11041  	    // Compute constants
 11042  	    (function () {
 11043  	        function isPrime(n) {
 11044  	            var sqrtN = Math.sqrt(n);
 11045  	            for (var factor = 2; factor <= sqrtN; factor++) {
 11046  	                if (!(n % factor)) {
 11047  	                    return false;
 11048  	                }
 11049  	            }
 11050  
 11051  	            return true;
 11052  	        }
 11053  
 11054  	        function getFractionalBits(n) {
 11055  	            return ((n - (n | 0)) * 0x100000000) | 0;
 11056  	        }
 11057  
 11058  	        var n = 2;
 11059  	        var nPrime = 0;
 11060  	        while (nPrime < 64) {
 11061  	            if (isPrime(n)) {
 11062  	                if (nPrime < 8) {
 11063  	                    H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
 11064  	                }
 11065  	                K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
 11066  
 11067  	                nPrime++;
 11068  	            }
 11069  
 11070  	            n++;
 11071  	        }
 11072  	    }());
 11073  
 11074  	    // Reusable object
 11075  	    var W = [];
 11076  
 11077  	    /**
 11078  	     * SHA-256 hash algorithm.
 11079  	     */
 11080  	    var SHA256 = C_algo.SHA256 = Hasher.extend({
 11081  	        _doReset: function () {
 11082  	            this._hash = new WordArray.init(H.slice(0));
 11083  	        },
 11084  
 11085  	        _doProcessBlock: function (M, offset) {
 11086  	            // Shortcut
 11087  	            var H = this._hash.words;
 11088  
 11089  	            // Working variables
 11090  	            var a = H[0];
 11091  	            var b = H[1];
 11092  	            var c = H[2];
 11093  	            var d = H[3];
 11094  	            var e = H[4];
 11095  	            var f = H[5];
 11096  	            var g = H[6];
 11097  	            var h = H[7];
 11098  
 11099  	            // Computation
 11100  	            for (var i = 0; i < 64; i++) {
 11101  	                if (i < 16) {
 11102  	                    W[i] = M[offset + i] | 0;
 11103  	                } else {
 11104  	                    var gamma0x = W[i - 15];
 11105  	                    var gamma0  = ((gamma0x << 25) | (gamma0x >>> 7))  ^
 11106  	                                  ((gamma0x << 14) | (gamma0x >>> 18)) ^
 11107  	                                   (gamma0x >>> 3);
 11108  
 11109  	                    var gamma1x = W[i - 2];
 11110  	                    var gamma1  = ((gamma1x << 15) | (gamma1x >>> 17)) ^
 11111  	                                  ((gamma1x << 13) | (gamma1x >>> 19)) ^
 11112  	                                   (gamma1x >>> 10);
 11113  
 11114  	                    W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
 11115  	                }
 11116  
 11117  	                var ch  = (e & f) ^ (~e & g);
 11118  	                var maj = (a & b) ^ (a & c) ^ (b & c);
 11119  
 11120  	                var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
 11121  	                var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7)  | (e >>> 25));
 11122  
 11123  	                var t1 = h + sigma1 + ch + K[i] + W[i];
 11124  	                var t2 = sigma0 + maj;
 11125  
 11126  	                h = g;
 11127  	                g = f;
 11128  	                f = e;
 11129  	                e = (d + t1) | 0;
 11130  	                d = c;
 11131  	                c = b;
 11132  	                b = a;
 11133  	                a = (t1 + t2) | 0;
 11134  	            }
 11135  
 11136  	            // Intermediate hash value
 11137  	            H[0] = (H[0] + a) | 0;
 11138  	            H[1] = (H[1] + b) | 0;
 11139  	            H[2] = (H[2] + c) | 0;
 11140  	            H[3] = (H[3] + d) | 0;
 11141  	            H[4] = (H[4] + e) | 0;
 11142  	            H[5] = (H[5] + f) | 0;
 11143  	            H[6] = (H[6] + g) | 0;
 11144  	            H[7] = (H[7] + h) | 0;
 11145  	        },
 11146  
 11147  	        _doFinalize: function () {
 11148  	            // Shortcuts
 11149  	            var data = this._data;
 11150  	            var dataWords = data.words;
 11151  
 11152  	            var nBitsTotal = this._nDataBytes * 8;
 11153  	            var nBitsLeft = data.sigBytes * 8;
 11154  
 11155  	            // Add padding
 11156  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11157  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11158  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11159  	            data.sigBytes = dataWords.length * 4;
 11160  
 11161  	            // Hash final blocks
 11162  	            this._process();
 11163  
 11164  	            // Return final computed hash
 11165  	            return this._hash;
 11166  	        },
 11167  
 11168  	        clone: function () {
 11169  	            var clone = Hasher.clone.call(this);
 11170  	            clone._hash = this._hash.clone();
 11171  
 11172  	            return clone;
 11173  	        }
 11174  	    });
 11175  
 11176  	    /**
 11177  	     * Shortcut function to the hasher's object interface.
 11178  	     *
 11179  	     * @param {WordArray|string} message The message to hash.
 11180  	     *
 11181  	     * @return {WordArray} The hash.
 11182  	     *
 11183  	     * @static
 11184  	     *
 11185  	     * @example
 11186  	     *
 11187  	     *     var hash = CryptoJS.SHA256('message');
 11188  	     *     var hash = CryptoJS.SHA256(wordArray);
 11189  	     */
 11190  	    C.SHA256 = Hasher._createHelper(SHA256);
 11191  
 11192  	    /**
 11193  	     * Shortcut function to the HMAC's object interface.
 11194  	     *
 11195  	     * @param {WordArray|string} message The message to hash.
 11196  	     * @param {WordArray|string} key The secret key.
 11197  	     *
 11198  	     * @return {WordArray} The HMAC.
 11199  	     *
 11200  	     * @static
 11201  	     *
 11202  	     * @example
 11203  	     *
 11204  	     *     var hmac = CryptoJS.HmacSHA256(message, key);
 11205  	     */
 11206  	    C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
 11207  	}(Math));
 11208  
 11209  
 11210  	return CryptoJS.SHA256;
 11211  
 11212  }));
 11213  },{"./core":52}],79:[function(require,module,exports){
 11214  ;(function (root, factory, undef) {
 11215  	if (typeof exports === "object") {
 11216  		// CommonJS
 11217  		module.exports = exports = factory(require("./core"), require("./x64-core"));
 11218  	}
 11219  	else if (typeof define === "function" && define.amd) {
 11220  		// AMD
 11221  		define(["./core", "./x64-core"], factory);
 11222  	}
 11223  	else {
 11224  		// Global (browser)
 11225  		factory(root.CryptoJS);
 11226  	}
 11227  }(this, function (CryptoJS) {
 11228  
 11229  	(function (Math) {
 11230  	    // Shortcuts
 11231  	    var C = CryptoJS;
 11232  	    var C_lib = C.lib;
 11233  	    var WordArray = C_lib.WordArray;
 11234  	    var Hasher = C_lib.Hasher;
 11235  	    var C_x64 = C.x64;
 11236  	    var X64Word = C_x64.Word;
 11237  	    var C_algo = C.algo;
 11238  
 11239  	    // Constants tables
 11240  	    var RHO_OFFSETS = [];
 11241  	    var PI_INDEXES  = [];
 11242  	    var ROUND_CONSTANTS = [];
 11243  
 11244  	    // Compute Constants
 11245  	    (function () {
 11246  	        // Compute rho offset constants
 11247  	        var x = 1, y = 0;
 11248  	        for (var t = 0; t < 24; t++) {
 11249  	            RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
 11250  
 11251  	            var newX = y % 5;
 11252  	            var newY = (2 * x + 3 * y) % 5;
 11253  	            x = newX;
 11254  	            y = newY;
 11255  	        }
 11256  
 11257  	        // Compute pi index constants
 11258  	        for (var x = 0; x < 5; x++) {
 11259  	            for (var y = 0; y < 5; y++) {
 11260  	                PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
 11261  	            }
 11262  	        }
 11263  
 11264  	        // Compute round constants
 11265  	        var LFSR = 0x01;
 11266  	        for (var i = 0; i < 24; i++) {
 11267  	            var roundConstantMsw = 0;
 11268  	            var roundConstantLsw = 0;
 11269  
 11270  	            for (var j = 0; j < 7; j++) {
 11271  	                if (LFSR & 0x01) {
 11272  	                    var bitPosition = (1 << j) - 1;
 11273  	                    if (bitPosition < 32) {
 11274  	                        roundConstantLsw ^= 1 << bitPosition;
 11275  	                    } else /* if (bitPosition >= 32) */ {
 11276  	                        roundConstantMsw ^= 1 << (bitPosition - 32);
 11277  	                    }
 11278  	                }
 11279  
 11280  	                // Compute next LFSR
 11281  	                if (LFSR & 0x80) {
 11282  	                    // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
 11283  	                    LFSR = (LFSR << 1) ^ 0x71;
 11284  	                } else {
 11285  	                    LFSR <<= 1;
 11286  	                }
 11287  	            }
 11288  
 11289  	            ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
 11290  	        }
 11291  	    }());
 11292  
 11293  	    // Reusable objects for temporary values
 11294  	    var T = [];
 11295  	    (function () {
 11296  	        for (var i = 0; i < 25; i++) {
 11297  	            T[i] = X64Word.create();
 11298  	        }
 11299  	    }());
 11300  
 11301  	    /**
 11302  	     * SHA-3 hash algorithm.
 11303  	     */
 11304  	    var SHA3 = C_algo.SHA3 = Hasher.extend({
 11305  	        /**
 11306  	         * Configuration options.
 11307  	         *
 11308  	         * @property {number} outputLength
 11309  	         *   The desired number of bits in the output hash.
 11310  	         *   Only values permitted are: 224, 256, 384, 512.
 11311  	         *   Default: 512
 11312  	         */
 11313  	        cfg: Hasher.cfg.extend({
 11314  	            outputLength: 512
 11315  	        }),
 11316  
 11317  	        _doReset: function () {
 11318  	            var state = this._state = []
 11319  	            for (var i = 0; i < 25; i++) {
 11320  	                state[i] = new X64Word.init();
 11321  	            }
 11322  
 11323  	            this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
 11324  	        },
 11325  
 11326  	        _doProcessBlock: function (M, offset) {
 11327  	            // Shortcuts
 11328  	            var state = this._state;
 11329  	            var nBlockSizeLanes = this.blockSize / 2;
 11330  
 11331  	            // Absorb
 11332  	            for (var i = 0; i < nBlockSizeLanes; i++) {
 11333  	                // Shortcuts
 11334  	                var M2i  = M[offset + 2 * i];
 11335  	                var M2i1 = M[offset + 2 * i + 1];
 11336  
 11337  	                // Swap endian
 11338  	                M2i = (
 11339  	                    (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |
 11340  	                    (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)
 11341  	                );
 11342  	                M2i1 = (
 11343  	                    (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |
 11344  	                    (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)
 11345  	                );
 11346  
 11347  	                // Absorb message into state
 11348  	                var lane = state[i];
 11349  	                lane.high ^= M2i1;
 11350  	                lane.low  ^= M2i;
 11351  	            }
 11352  
 11353  	            // Rounds
 11354  	            for (var round = 0; round < 24; round++) {
 11355  	                // Theta
 11356  	                for (var x = 0; x < 5; x++) {
 11357  	                    // Mix column lanes
 11358  	                    var tMsw = 0, tLsw = 0;
 11359  	                    for (var y = 0; y < 5; y++) {
 11360  	                        var lane = state[x + 5 * y];
 11361  	                        tMsw ^= lane.high;
 11362  	                        tLsw ^= lane.low;
 11363  	                    }
 11364  
 11365  	                    // Temporary values
 11366  	                    var Tx = T[x];
 11367  	                    Tx.high = tMsw;
 11368  	                    Tx.low  = tLsw;
 11369  	                }
 11370  	                for (var x = 0; x < 5; x++) {
 11371  	                    // Shortcuts
 11372  	                    var Tx4 = T[(x + 4) % 5];
 11373  	                    var Tx1 = T[(x + 1) % 5];
 11374  	                    var Tx1Msw = Tx1.high;
 11375  	                    var Tx1Lsw = Tx1.low;
 11376  
 11377  	                    // Mix surrounding columns
 11378  	                    var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
 11379  	                    var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
 11380  	                    for (var y = 0; y < 5; y++) {
 11381  	                        var lane = state[x + 5 * y];
 11382  	                        lane.high ^= tMsw;
 11383  	                        lane.low  ^= tLsw;
 11384  	                    }
 11385  	                }
 11386  
 11387  	                // Rho Pi
 11388  	                for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
 11389  	                    // Shortcuts
 11390  	                    var lane = state[laneIndex];
 11391  	                    var laneMsw = lane.high;
 11392  	                    var laneLsw = lane.low;
 11393  	                    var rhoOffset = RHO_OFFSETS[laneIndex];
 11394  
 11395  	                    // Rotate lanes
 11396  	                    if (rhoOffset < 32) {
 11397  	                        var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
 11398  	                        var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
 11399  	                    } else /* if (rhoOffset >= 32) */ {
 11400  	                        var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
 11401  	                        var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
 11402  	                    }
 11403  
 11404  	                    // Transpose lanes
 11405  	                    var TPiLane = T[PI_INDEXES[laneIndex]];
 11406  	                    TPiLane.high = tMsw;
 11407  	                    TPiLane.low  = tLsw;
 11408  	                }
 11409  
 11410  	                // Rho pi at x = y = 0
 11411  	                var T0 = T[0];
 11412  	                var state0 = state[0];
 11413  	                T0.high = state0.high;
 11414  	                T0.low  = state0.low;
 11415  
 11416  	                // Chi
 11417  	                for (var x = 0; x < 5; x++) {
 11418  	                    for (var y = 0; y < 5; y++) {
 11419  	                        // Shortcuts
 11420  	                        var laneIndex = x + 5 * y;
 11421  	                        var lane = state[laneIndex];
 11422  	                        var TLane = T[laneIndex];
 11423  	                        var Tx1Lane = T[((x + 1) % 5) + 5 * y];
 11424  	                        var Tx2Lane = T[((x + 2) % 5) + 5 * y];
 11425  
 11426  	                        // Mix rows
 11427  	                        lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
 11428  	                        lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);
 11429  	                    }
 11430  	                }
 11431  
 11432  	                // Iota
 11433  	                var lane = state[0];
 11434  	                var roundConstant = ROUND_CONSTANTS[round];
 11435  	                lane.high ^= roundConstant.high;
 11436  	                lane.low  ^= roundConstant.low;;
 11437  	            }
 11438  	        },
 11439  
 11440  	        _doFinalize: function () {
 11441  	            // Shortcuts
 11442  	            var data = this._data;
 11443  	            var dataWords = data.words;
 11444  	            var nBitsTotal = this._nDataBytes * 8;
 11445  	            var nBitsLeft = data.sigBytes * 8;
 11446  	            var blockSizeBits = this.blockSize * 32;
 11447  
 11448  	            // Add padding
 11449  	            dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
 11450  	            dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
 11451  	            data.sigBytes = dataWords.length * 4;
 11452  
 11453  	            // Hash final blocks
 11454  	            this._process();
 11455  
 11456  	            // Shortcuts
 11457  	            var state = this._state;
 11458  	            var outputLengthBytes = this.cfg.outputLength / 8;
 11459  	            var outputLengthLanes = outputLengthBytes / 8;
 11460  
 11461  	            // Squeeze
 11462  	            var hashWords = [];
 11463  	            for (var i = 0; i < outputLengthLanes; i++) {
 11464  	                // Shortcuts
 11465  	                var lane = state[i];
 11466  	                var laneMsw = lane.high;
 11467  	                var laneLsw = lane.low;
 11468  
 11469  	                // Swap endian
 11470  	                laneMsw = (
 11471  	                    (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |
 11472  	                    (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)
 11473  	                );
 11474  	                laneLsw = (
 11475  	                    (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |
 11476  	                    (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)
 11477  	                );
 11478  
 11479  	                // Squeeze state to retrieve hash
 11480  	                hashWords.push(laneLsw);
 11481  	                hashWords.push(laneMsw);
 11482  	            }
 11483  
 11484  	            // Return final computed hash
 11485  	            return new WordArray.init(hashWords, outputLengthBytes);
 11486  	        },
 11487  
 11488  	        clone: function () {
 11489  	            var clone = Hasher.clone.call(this);
 11490  
 11491  	            var state = clone._state = this._state.slice(0);
 11492  	            for (var i = 0; i < 25; i++) {
 11493  	                state[i] = state[i].clone();
 11494  	            }
 11495  
 11496  	            return clone;
 11497  	        }
 11498  	    });
 11499  
 11500  	    /**
 11501  	     * Shortcut function to the hasher's object interface.
 11502  	     *
 11503  	     * @param {WordArray|string} message The message to hash.
 11504  	     *
 11505  	     * @return {WordArray} The hash.
 11506  	     *
 11507  	     * @static
 11508  	     *
 11509  	     * @example
 11510  	     *
 11511  	     *     var hash = CryptoJS.SHA3('message');
 11512  	     *     var hash = CryptoJS.SHA3(wordArray);
 11513  	     */
 11514  	    C.SHA3 = Hasher._createHelper(SHA3);
 11515  
 11516  	    /**
 11517  	     * Shortcut function to the HMAC's object interface.
 11518  	     *
 11519  	     * @param {WordArray|string} message The message to hash.
 11520  	     * @param {WordArray|string} key The secret key.
 11521  	     *
 11522  	     * @return {WordArray} The HMAC.
 11523  	     *
 11524  	     * @static
 11525  	     *
 11526  	     * @example
 11527  	     *
 11528  	     *     var hmac = CryptoJS.HmacSHA3(message, key);
 11529  	     */
 11530  	    C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
 11531  	}(Math));
 11532  
 11533  
 11534  	return CryptoJS.SHA3;
 11535  
 11536  }));
 11537  },{"./core":52,"./x64-core":83}],80:[function(require,module,exports){
 11538  ;(function (root, factory, undef) {
 11539  	if (typeof exports === "object") {
 11540  		// CommonJS
 11541  		module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512"));
 11542  	}
 11543  	else if (typeof define === "function" && define.amd) {
 11544  		// AMD
 11545  		define(["./core", "./x64-core", "./sha512"], factory);
 11546  	}
 11547  	else {
 11548  		// Global (browser)
 11549  		factory(root.CryptoJS);
 11550  	}
 11551  }(this, function (CryptoJS) {
 11552  
 11553  	(function () {
 11554  	    // Shortcuts
 11555  	    var C = CryptoJS;
 11556  	    var C_x64 = C.x64;
 11557  	    var X64Word = C_x64.Word;
 11558  	    var X64WordArray = C_x64.WordArray;
 11559  	    var C_algo = C.algo;
 11560  	    var SHA512 = C_algo.SHA512;
 11561  
 11562  	    /**
 11563  	     * SHA-384 hash algorithm.
 11564  	     */
 11565  	    var SHA384 = C_algo.SHA384 = SHA512.extend({
 11566  	        _doReset: function () {
 11567  	            this._hash = new X64WordArray.init([
 11568  	                new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
 11569  	                new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
 11570  	                new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
 11571  	                new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
 11572  	            ]);
 11573  	        },
 11574  
 11575  	        _doFinalize: function () {
 11576  	            var hash = SHA512._doFinalize.call(this);
 11577  
 11578  	            hash.sigBytes -= 16;
 11579  
 11580  	            return hash;
 11581  	        }
 11582  	    });
 11583  
 11584  	    /**
 11585  	     * Shortcut function to the hasher's object interface.
 11586  	     *
 11587  	     * @param {WordArray|string} message The message to hash.
 11588  	     *
 11589  	     * @return {WordArray} The hash.
 11590  	     *
 11591  	     * @static
 11592  	     *
 11593  	     * @example
 11594  	     *
 11595  	     *     var hash = CryptoJS.SHA384('message');
 11596  	     *     var hash = CryptoJS.SHA384(wordArray);
 11597  	     */
 11598  	    C.SHA384 = SHA512._createHelper(SHA384);
 11599  
 11600  	    /**
 11601  	     * Shortcut function to the HMAC's object interface.
 11602  	     *
 11603  	     * @param {WordArray|string} message The message to hash.
 11604  	     * @param {WordArray|string} key The secret key.
 11605  	     *
 11606  	     * @return {WordArray} The HMAC.
 11607  	     *
 11608  	     * @static
 11609  	     *
 11610  	     * @example
 11611  	     *
 11612  	     *     var hmac = CryptoJS.HmacSHA384(message, key);
 11613  	     */
 11614  	    C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
 11615  	}());
 11616  
 11617  
 11618  	return CryptoJS.SHA384;
 11619  
 11620  }));
 11621  },{"./core":52,"./sha512":81,"./x64-core":83}],81:[function(require,module,exports){
 11622  ;(function (root, factory, undef) {
 11623  	if (typeof exports === "object") {
 11624  		// CommonJS
 11625  		module.exports = exports = factory(require("./core"), require("./x64-core"));
 11626  	}
 11627  	else if (typeof define === "function" && define.amd) {
 11628  		// AMD
 11629  		define(["./core", "./x64-core"], factory);
 11630  	}
 11631  	else {
 11632  		// Global (browser)
 11633  		factory(root.CryptoJS);
 11634  	}
 11635  }(this, function (CryptoJS) {
 11636  
 11637  	(function () {
 11638  	    // Shortcuts
 11639  	    var C = CryptoJS;
 11640  	    var C_lib = C.lib;
 11641  	    var Hasher = C_lib.Hasher;
 11642  	    var C_x64 = C.x64;
 11643  	    var X64Word = C_x64.Word;
 11644  	    var X64WordArray = C_x64.WordArray;
 11645  	    var C_algo = C.algo;
 11646  
 11647  	    function X64Word_create() {
 11648  	        return X64Word.create.apply(X64Word, arguments);
 11649  	    }
 11650  
 11651  	    // Constants
 11652  	    var K = [
 11653  	        X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
 11654  	        X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
 11655  	        X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
 11656  	        X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
 11657  	        X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
 11658  	        X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
 11659  	        X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
 11660  	        X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
 11661  	        X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
 11662  	        X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
 11663  	        X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
 11664  	        X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
 11665  	        X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
 11666  	        X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
 11667  	        X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
 11668  	        X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
 11669  	        X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
 11670  	        X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
 11671  	        X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
 11672  	        X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
 11673  	        X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
 11674  	        X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
 11675  	        X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
 11676  	        X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
 11677  	        X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
 11678  	        X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
 11679  	        X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
 11680  	        X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
 11681  	        X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
 11682  	        X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
 11683  	        X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
 11684  	        X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
 11685  	        X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
 11686  	        X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
 11687  	        X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
 11688  	        X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
 11689  	        X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
 11690  	        X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
 11691  	        X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
 11692  	        X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
 11693  	    ];
 11694  
 11695  	    // Reusable objects
 11696  	    var W = [];
 11697  	    (function () {
 11698  	        for (var i = 0; i < 80; i++) {
 11699  	            W[i] = X64Word_create();
 11700  	        }
 11701  	    }());
 11702  
 11703  	    /**
 11704  	     * SHA-512 hash algorithm.
 11705  	     */
 11706  	    var SHA512 = C_algo.SHA512 = Hasher.extend({
 11707  	        _doReset: function () {
 11708  	            this._hash = new X64WordArray.init([
 11709  	                new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
 11710  	                new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
 11711  	                new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
 11712  	                new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
 11713  	            ]);
 11714  	        },
 11715  
 11716  	        _doProcessBlock: function (M, offset) {
 11717  	            // Shortcuts
 11718  	            var H = this._hash.words;
 11719  
 11720  	            var H0 = H[0];
 11721  	            var H1 = H[1];
 11722  	            var H2 = H[2];
 11723  	            var H3 = H[3];
 11724  	            var H4 = H[4];
 11725  	            var H5 = H[5];
 11726  	            var H6 = H[6];
 11727  	            var H7 = H[7];
 11728  
 11729  	            var H0h = H0.high;
 11730  	            var H0l = H0.low;
 11731  	            var H1h = H1.high;
 11732  	            var H1l = H1.low;
 11733  	            var H2h = H2.high;
 11734  	            var H2l = H2.low;
 11735  	            var H3h = H3.high;
 11736  	            var H3l = H3.low;
 11737  	            var H4h = H4.high;
 11738  	            var H4l = H4.low;
 11739  	            var H5h = H5.high;
 11740  	            var H5l = H5.low;
 11741  	            var H6h = H6.high;
 11742  	            var H6l = H6.low;
 11743  	            var H7h = H7.high;
 11744  	            var H7l = H7.low;
 11745  
 11746  	            // Working variables
 11747  	            var ah = H0h;
 11748  	            var al = H0l;
 11749  	            var bh = H1h;
 11750  	            var bl = H1l;
 11751  	            var ch = H2h;
 11752  	            var cl = H2l;
 11753  	            var dh = H3h;
 11754  	            var dl = H3l;
 11755  	            var eh = H4h;
 11756  	            var el = H4l;
 11757  	            var fh = H5h;
 11758  	            var fl = H5l;
 11759  	            var gh = H6h;
 11760  	            var gl = H6l;
 11761  	            var hh = H7h;
 11762  	            var hl = H7l;
 11763  
 11764  	            // Rounds
 11765  	            for (var i = 0; i < 80; i++) {
 11766  	                // Shortcut
 11767  	                var Wi = W[i];
 11768  
 11769  	                // Extend message
 11770  	                if (i < 16) {
 11771  	                    var Wih = Wi.high = M[offset + i * 2]     | 0;
 11772  	                    var Wil = Wi.low  = M[offset + i * 2 + 1] | 0;
 11773  	                } else {
 11774  	                    // Gamma0
 11775  	                    var gamma0x  = W[i - 15];
 11776  	                    var gamma0xh = gamma0x.high;
 11777  	                    var gamma0xl = gamma0x.low;
 11778  	                    var gamma0h  = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
 11779  	                    var gamma0l  = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
 11780  
 11781  	                    // Gamma1
 11782  	                    var gamma1x  = W[i - 2];
 11783  	                    var gamma1xh = gamma1x.high;
 11784  	                    var gamma1xl = gamma1x.low;
 11785  	                    var gamma1h  = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
 11786  	                    var gamma1l  = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
 11787  
 11788  	                    // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
 11789  	                    var Wi7  = W[i - 7];
 11790  	                    var Wi7h = Wi7.high;
 11791  	                    var Wi7l = Wi7.low;
 11792  
 11793  	                    var Wi16  = W[i - 16];
 11794  	                    var Wi16h = Wi16.high;
 11795  	                    var Wi16l = Wi16.low;
 11796  
 11797  	                    var Wil = gamma0l + Wi7l;
 11798  	                    var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
 11799  	                    var Wil = Wil + gamma1l;
 11800  	                    var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
 11801  	                    var Wil = Wil + Wi16l;
 11802  	                    var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
 11803  
 11804  	                    Wi.high = Wih;
 11805  	                    Wi.low  = Wil;
 11806  	                }
 11807  
 11808  	                var chh  = (eh & fh) ^ (~eh & gh);
 11809  	                var chl  = (el & fl) ^ (~el & gl);
 11810  	                var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
 11811  	                var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
 11812  
 11813  	                var sigma0h = ((ah >>> 28) | (al << 4))  ^ ((ah << 30)  | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
 11814  	                var sigma0l = ((al >>> 28) | (ah << 4))  ^ ((al << 30)  | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
 11815  	                var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
 11816  	                var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
 11817  
 11818  	                // t1 = h + sigma1 + ch + K[i] + W[i]
 11819  	                var Ki  = K[i];
 11820  	                var Kih = Ki.high;
 11821  	                var Kil = Ki.low;
 11822  
 11823  	                var t1l = hl + sigma1l;
 11824  	                var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
 11825  	                var t1l = t1l + chl;
 11826  	                var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
 11827  	                var t1l = t1l + Kil;
 11828  	                var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
 11829  	                var t1l = t1l + Wil;
 11830  	                var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
 11831  
 11832  	                // t2 = sigma0 + maj
 11833  	                var t2l = sigma0l + majl;
 11834  	                var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
 11835  
 11836  	                // Update working variables
 11837  	                hh = gh;
 11838  	                hl = gl;
 11839  	                gh = fh;
 11840  	                gl = fl;
 11841  	                fh = eh;
 11842  	                fl = el;
 11843  	                el = (dl + t1l) | 0;
 11844  	                eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
 11845  	                dh = ch;
 11846  	                dl = cl;
 11847  	                ch = bh;
 11848  	                cl = bl;
 11849  	                bh = ah;
 11850  	                bl = al;
 11851  	                al = (t1l + t2l) | 0;
 11852  	                ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
 11853  	            }
 11854  
 11855  	            // Intermediate hash value
 11856  	            H0l = H0.low  = (H0l + al);
 11857  	            H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
 11858  	            H1l = H1.low  = (H1l + bl);
 11859  	            H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
 11860  	            H2l = H2.low  = (H2l + cl);
 11861  	            H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
 11862  	            H3l = H3.low  = (H3l + dl);
 11863  	            H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
 11864  	            H4l = H4.low  = (H4l + el);
 11865  	            H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
 11866  	            H5l = H5.low  = (H5l + fl);
 11867  	            H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
 11868  	            H6l = H6.low  = (H6l + gl);
 11869  	            H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
 11870  	            H7l = H7.low  = (H7l + hl);
 11871  	            H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
 11872  	        },
 11873  
 11874  	        _doFinalize: function () {
 11875  	            // Shortcuts
 11876  	            var data = this._data;
 11877  	            var dataWords = data.words;
 11878  
 11879  	            var nBitsTotal = this._nDataBytes * 8;
 11880  	            var nBitsLeft = data.sigBytes * 8;
 11881  
 11882  	            // Add padding
 11883  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11884  	            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
 11885  	            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
 11886  	            data.sigBytes = dataWords.length * 4;
 11887  
 11888  	            // Hash final blocks
 11889  	            this._process();
 11890  
 11891  	            // Convert hash to 32-bit word array before returning
 11892  	            var hash = this._hash.toX32();
 11893  
 11894  	            // Return final computed hash
 11895  	            return hash;
 11896  	        },
 11897  
 11898  	        clone: function () {
 11899  	            var clone = Hasher.clone.call(this);
 11900  	            clone._hash = this._hash.clone();
 11901  
 11902  	            return clone;
 11903  	        },
 11904  
 11905  	        blockSize: 1024/32
 11906  	    });
 11907  
 11908  	    /**
 11909  	     * Shortcut function to the hasher's object interface.
 11910  	     *
 11911  	     * @param {WordArray|string} message The message to hash.
 11912  	     *
 11913  	     * @return {WordArray} The hash.
 11914  	     *
 11915  	     * @static
 11916  	     *
 11917  	     * @example
 11918  	     *
 11919  	     *     var hash = CryptoJS.SHA512('message');
 11920  	     *     var hash = CryptoJS.SHA512(wordArray);
 11921  	     */
 11922  	    C.SHA512 = Hasher._createHelper(SHA512);
 11923  
 11924  	    /**
 11925  	     * Shortcut function to the HMAC's object interface.
 11926  	     *
 11927  	     * @param {WordArray|string} message The message to hash.
 11928  	     * @param {WordArray|string} key The secret key.
 11929  	     *
 11930  	     * @return {WordArray} The HMAC.
 11931  	     *
 11932  	     * @static
 11933  	     *
 11934  	     * @example
 11935  	     *
 11936  	     *     var hmac = CryptoJS.HmacSHA512(message, key);
 11937  	     */
 11938  	    C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
 11939  	}());
 11940  
 11941  
 11942  	return CryptoJS.SHA512;
 11943  
 11944  }));
 11945  },{"./core":52,"./x64-core":83}],82:[function(require,module,exports){
 11946  ;(function (root, factory, undef) {
 11947  	if (typeof exports === "object") {
 11948  		// CommonJS
 11949  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 11950  	}
 11951  	else if (typeof define === "function" && define.amd) {
 11952  		// AMD
 11953  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 11954  	}
 11955  	else {
 11956  		// Global (browser)
 11957  		factory(root.CryptoJS);
 11958  	}
 11959  }(this, function (CryptoJS) {
 11960  
 11961  	(function () {
 11962  	    // Shortcuts
 11963  	    var C = CryptoJS;
 11964  	    var C_lib = C.lib;
 11965  	    var WordArray = C_lib.WordArray;
 11966  	    var BlockCipher = C_lib.BlockCipher;
 11967  	    var C_algo = C.algo;
 11968  
 11969  	    // Permuted Choice 1 constants
 11970  	    var PC1 = [
 11971  	        57, 49, 41, 33, 25, 17, 9,  1,
 11972  	        58, 50, 42, 34, 26, 18, 10, 2,
 11973  	        59, 51, 43, 35, 27, 19, 11, 3,
 11974  	        60, 52, 44, 36, 63, 55, 47, 39,
 11975  	        31, 23, 15, 7,  62, 54, 46, 38,
 11976  	        30, 22, 14, 6,  61, 53, 45, 37,
 11977  	        29, 21, 13, 5,  28, 20, 12, 4
 11978  	    ];
 11979  
 11980  	    // Permuted Choice 2 constants
 11981  	    var PC2 = [
 11982  	        14, 17, 11, 24, 1,  5,
 11983  	        3,  28, 15, 6,  21, 10,
 11984  	        23, 19, 12, 4,  26, 8,
 11985  	        16, 7,  27, 20, 13, 2,
 11986  	        41, 52, 31, 37, 47, 55,
 11987  	        30, 40, 51, 45, 33, 48,
 11988  	        44, 49, 39, 56, 34, 53,
 11989  	        46, 42, 50, 36, 29, 32
 11990  	    ];
 11991  
 11992  	    // Cumulative bit shift constants
 11993  	    var BIT_SHIFTS = [1,  2,  4,  6,  8,  10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
 11994  
 11995  	    // SBOXes and round permutation constants
 11996  	    var SBOX_P = [
 11997  	        {
 11998  	            0x0: 0x808200,
 11999  	            0x10000000: 0x8000,
 12000  	            0x20000000: 0x808002,
 12001  	            0x30000000: 0x2,
 12002  	            0x40000000: 0x200,
 12003  	            0x50000000: 0x808202,
 12004  	            0x60000000: 0x800202,
 12005  	            0x70000000: 0x800000,
 12006  	            0x80000000: 0x202,
 12007  	            0x90000000: 0x800200,
 12008  	            0xa0000000: 0x8200,
 12009  	            0xb0000000: 0x808000,
 12010  	            0xc0000000: 0x8002,
 12011  	            0xd0000000: 0x800002,
 12012  	            0xe0000000: 0x0,
 12013  	            0xf0000000: 0x8202,
 12014  	            0x8000000: 0x0,
 12015  	            0x18000000: 0x808202,
 12016  	            0x28000000: 0x8202,
 12017  	            0x38000000: 0x8000,
 12018  	            0x48000000: 0x808200,
 12019  	            0x58000000: 0x200,
 12020  	            0x68000000: 0x808002,
 12021  	            0x78000000: 0x2,
 12022  	            0x88000000: 0x800200,
 12023  	            0x98000000: 0x8200,
 12024  	            0xa8000000: 0x808000,
 12025  	            0xb8000000: 0x800202,
 12026  	            0xc8000000: 0x800002,
 12027  	            0xd8000000: 0x8002,
 12028  	            0xe8000000: 0x202,
 12029  	            0xf8000000: 0x800000,
 12030  	            0x1: 0x8000,
 12031  	            0x10000001: 0x2,
 12032  	            0x20000001: 0x808200,
 12033  	            0x30000001: 0x800000,
 12034  	            0x40000001: 0x808002,
 12035  	            0x50000001: 0x8200,
 12036  	            0x60000001: 0x200,
 12037  	            0x70000001: 0x800202,
 12038  	            0x80000001: 0x808202,
 12039  	            0x90000001: 0x808000,
 12040  	            0xa0000001: 0x800002,
 12041  	            0xb0000001: 0x8202,
 12042  	            0xc0000001: 0x202,
 12043  	            0xd0000001: 0x800200,
 12044  	            0xe0000001: 0x8002,
 12045  	            0xf0000001: 0x0,
 12046  	            0x8000001: 0x808202,
 12047  	            0x18000001: 0x808000,
 12048  	            0x28000001: 0x800000,
 12049  	            0x38000001: 0x200,
 12050  	            0x48000001: 0x8000,
 12051  	            0x58000001: 0x800002,
 12052  	            0x68000001: 0x2,
 12053  	            0x78000001: 0x8202,
 12054  	            0x88000001: 0x8002,
 12055  	            0x98000001: 0x800202,
 12056  	            0xa8000001: 0x202,
 12057  	            0xb8000001: 0x808200,
 12058  	            0xc8000001: 0x800200,
 12059  	            0xd8000001: 0x0,
 12060  	            0xe8000001: 0x8200,
 12061  	            0xf8000001: 0x808002
 12062  	        },
 12063  	        {
 12064  	            0x0: 0x40084010,
 12065  	            0x1000000: 0x4000,
 12066  	            0x2000000: 0x80000,
 12067  	            0x3000000: 0x40080010,
 12068  	            0x4000000: 0x40000010,
 12069  	            0x5000000: 0x40084000,
 12070  	            0x6000000: 0x40004000,
 12071  	            0x7000000: 0x10,
 12072  	            0x8000000: 0x84000,
 12073  	            0x9000000: 0x40004010,
 12074  	            0xa000000: 0x40000000,
 12075  	            0xb000000: 0x84010,
 12076  	            0xc000000: 0x80010,
 12077  	            0xd000000: 0x0,
 12078  	            0xe000000: 0x4010,
 12079  	            0xf000000: 0x40080000,
 12080  	            0x800000: 0x40004000,
 12081  	            0x1800000: 0x84010,
 12082  	            0x2800000: 0x10,
 12083  	            0x3800000: 0x40004010,
 12084  	            0x4800000: 0x40084010,
 12085  	            0x5800000: 0x40000000,
 12086  	            0x6800000: 0x80000,
 12087  	            0x7800000: 0x40080010,
 12088  	            0x8800000: 0x80010,
 12089  	            0x9800000: 0x0,
 12090  	            0xa800000: 0x4000,
 12091  	            0xb800000: 0x40080000,
 12092  	            0xc800000: 0x40000010,
 12093  	            0xd800000: 0x84000,
 12094  	            0xe800000: 0x40084000,
 12095  	            0xf800000: 0x4010,
 12096  	            0x10000000: 0x0,
 12097  	            0x11000000: 0x40080010,
 12098  	            0x12000000: 0x40004010,
 12099  	            0x13000000: 0x40084000,
 12100  	            0x14000000: 0x40080000,
 12101  	            0x15000000: 0x10,
 12102  	            0x16000000: 0x84010,
 12103  	            0x17000000: 0x4000,
 12104  	            0x18000000: 0x4010,
 12105  	            0x19000000: 0x80000,
 12106  	            0x1a000000: 0x80010,
 12107  	            0x1b000000: 0x40000010,
 12108  	            0x1c000000: 0x84000,
 12109  	            0x1d000000: 0x40004000,
 12110  	            0x1e000000: 0x40000000,
 12111  	            0x1f000000: 0x40084010,
 12112  	            0x10800000: 0x84010,
 12113  	            0x11800000: 0x80000,
 12114  	            0x12800000: 0x40080000,
 12115  	            0x13800000: 0x4000,
 12116  	            0x14800000: 0x40004000,
 12117  	            0x15800000: 0x40084010,
 12118  	            0x16800000: 0x10,
 12119  	            0x17800000: 0x40000000,
 12120  	            0x18800000: 0x40084000,
 12121  	            0x19800000: 0x40000010,
 12122  	            0x1a800000: 0x40004010,
 12123  	            0x1b800000: 0x80010,
 12124  	            0x1c800000: 0x0,
 12125  	            0x1d800000: 0x4010,
 12126  	            0x1e800000: 0x40080010,
 12127  	            0x1f800000: 0x84000
 12128  	        },
 12129  	        {
 12130  	            0x0: 0x104,
 12131  	            0x100000: 0x0,
 12132  	            0x200000: 0x4000100,
 12133  	            0x300000: 0x10104,
 12134  	            0x400000: 0x10004,
 12135  	            0x500000: 0x4000004,
 12136  	            0x600000: 0x4010104,
 12137  	            0x700000: 0x4010000,
 12138  	            0x800000: 0x4000000,
 12139  	            0x900000: 0x4010100,
 12140  	            0xa00000: 0x10100,
 12141  	            0xb00000: 0x4010004,
 12142  	            0xc00000: 0x4000104,
 12143  	            0xd00000: 0x10000,
 12144  	            0xe00000: 0x4,
 12145  	            0xf00000: 0x100,
 12146  	            0x80000: 0x4010100,
 12147  	            0x180000: 0x4010004,
 12148  	            0x280000: 0x0,
 12149  	            0x380000: 0x4000100,
 12150  	            0x480000: 0x4000004,
 12151  	            0x580000: 0x10000,
 12152  	            0x680000: 0x10004,
 12153  	            0x780000: 0x104,
 12154  	            0x880000: 0x4,
 12155  	            0x980000: 0x100,
 12156  	            0xa80000: 0x4010000,
 12157  	            0xb80000: 0x10104,
 12158  	            0xc80000: 0x10100,
 12159  	            0xd80000: 0x4000104,
 12160  	            0xe80000: 0x4010104,
 12161  	            0xf80000: 0x4000000,
 12162  	            0x1000000: 0x4010100,
 12163  	            0x1100000: 0x10004,
 12164  	            0x1200000: 0x10000,
 12165  	            0x1300000: 0x4000100,
 12166  	            0x1400000: 0x100,
 12167  	            0x1500000: 0x4010104,
 12168  	            0x1600000: 0x4000004,
 12169  	            0x1700000: 0x0,
 12170  	            0x1800000: 0x4000104,
 12171  	            0x1900000: 0x4000000,
 12172  	            0x1a00000: 0x4,
 12173  	            0x1b00000: 0x10100,
 12174  	            0x1c00000: 0x4010000,
 12175  	            0x1d00000: 0x104,
 12176  	            0x1e00000: 0x10104,
 12177  	            0x1f00000: 0x4010004,
 12178  	            0x1080000: 0x4000000,
 12179  	            0x1180000: 0x104,
 12180  	            0x1280000: 0x4010100,
 12181  	            0x1380000: 0x0,
 12182  	            0x1480000: 0x10004,
 12183  	            0x1580000: 0x4000100,
 12184  	            0x1680000: 0x100,
 12185  	            0x1780000: 0x4010004,
 12186  	            0x1880000: 0x10000,
 12187  	            0x1980000: 0x4010104,
 12188  	            0x1a80000: 0x10104,
 12189  	            0x1b80000: 0x4000004,
 12190  	            0x1c80000: 0x4000104,
 12191  	            0x1d80000: 0x4010000,
 12192  	            0x1e80000: 0x4,
 12193  	            0x1f80000: 0x10100
 12194  	        },
 12195  	        {
 12196  	            0x0: 0x80401000,
 12197  	            0x10000: 0x80001040,
 12198  	            0x20000: 0x401040,
 12199  	            0x30000: 0x80400000,
 12200  	            0x40000: 0x0,
 12201  	            0x50000: 0x401000,
 12202  	            0x60000: 0x80000040,
 12203  	            0x70000: 0x400040,
 12204  	            0x80000: 0x80000000,
 12205  	            0x90000: 0x400000,
 12206  	            0xa0000: 0x40,
 12207  	            0xb0000: 0x80001000,
 12208  	            0xc0000: 0x80400040,
 12209  	            0xd0000: 0x1040,
 12210  	            0xe0000: 0x1000,
 12211  	            0xf0000: 0x80401040,
 12212  	            0x8000: 0x80001040,
 12213  	            0x18000: 0x40,
 12214  	            0x28000: 0x80400040,
 12215  	            0x38000: 0x80001000,
 12216  	            0x48000: 0x401000,
 12217  	            0x58000: 0x80401040,
 12218  	            0x68000: 0x0,
 12219  	            0x78000: 0x80400000,
 12220  	            0x88000: 0x1000,
 12221  	            0x98000: 0x80401000,
 12222  	            0xa8000: 0x400000,
 12223  	            0xb8000: 0x1040,
 12224  	            0xc8000: 0x80000000,
 12225  	            0xd8000: 0x400040,
 12226  	            0xe8000: 0x401040,
 12227  	            0xf8000: 0x80000040,
 12228  	            0x100000: 0x400040,
 12229  	            0x110000: 0x401000,
 12230  	            0x120000: 0x80000040,
 12231  	            0x130000: 0x0,
 12232  	            0x140000: 0x1040,
 12233  	            0x150000: 0x80400040,
 12234  	            0x160000: 0x80401000,
 12235  	            0x170000: 0x80001040,
 12236  	            0x180000: 0x80401040,
 12237  	            0x190000: 0x80000000,
 12238  	            0x1a0000: 0x80400000,
 12239  	            0x1b0000: 0x401040,
 12240  	            0x1c0000: 0x80001000,
 12241  	            0x1d0000: 0x400000,
 12242  	            0x1e0000: 0x40,
 12243  	            0x1f0000: 0x1000,
 12244  	            0x108000: 0x80400000,
 12245  	            0x118000: 0x80401040,
 12246  	            0x128000: 0x0,
 12247  	            0x138000: 0x401000,
 12248  	            0x148000: 0x400040,
 12249  	            0x158000: 0x80000000,
 12250  	            0x168000: 0x80001040,
 12251  	            0x178000: 0x40,
 12252  	            0x188000: 0x80000040,
 12253  	            0x198000: 0x1000,
 12254  	            0x1a8000: 0x80001000,
 12255  	            0x1b8000: 0x80400040,
 12256  	            0x1c8000: 0x1040,
 12257  	            0x1d8000: 0x80401000,
 12258  	            0x1e8000: 0x400000,
 12259  	            0x1f8000: 0x401040
 12260  	        },
 12261  	        {
 12262  	            0x0: 0x80,
 12263  	            0x1000: 0x1040000,
 12264  	            0x2000: 0x40000,
 12265  	            0x3000: 0x20000000,
 12266  	            0x4000: 0x20040080,
 12267  	            0x5000: 0x1000080,
 12268  	            0x6000: 0x21000080,
 12269  	            0x7000: 0x40080,
 12270  	            0x8000: 0x1000000,
 12271  	            0x9000: 0x20040000,
 12272  	            0xa000: 0x20000080,
 12273  	            0xb000: 0x21040080,
 12274  	            0xc000: 0x21040000,
 12275  	            0xd000: 0x0,
 12276  	            0xe000: 0x1040080,
 12277  	            0xf000: 0x21000000,
 12278  	            0x800: 0x1040080,
 12279  	            0x1800: 0x21000080,
 12280  	            0x2800: 0x80,
 12281  	            0x3800: 0x1040000,
 12282  	            0x4800: 0x40000,
 12283  	            0x5800: 0x20040080,
 12284  	            0x6800: 0x21040000,
 12285  	            0x7800: 0x20000000,
 12286  	            0x8800: 0x20040000,
 12287  	            0x9800: 0x0,
 12288  	            0xa800: 0x21040080,
 12289  	            0xb800: 0x1000080,
 12290  	            0xc800: 0x20000080,
 12291  	            0xd800: 0x21000000,
 12292  	            0xe800: 0x1000000,
 12293  	            0xf800: 0x40080,
 12294  	            0x10000: 0x40000,
 12295  	            0x11000: 0x80,
 12296  	            0x12000: 0x20000000,
 12297  	            0x13000: 0x21000080,
 12298  	            0x14000: 0x1000080,
 12299  	            0x15000: 0x21040000,
 12300  	            0x16000: 0x20040080,
 12301  	            0x17000: 0x1000000,
 12302  	            0x18000: 0x21040080,
 12303  	            0x19000: 0x21000000,
 12304  	            0x1a000: 0x1040000,
 12305  	            0x1b000: 0x20040000,
 12306  	            0x1c000: 0x40080,
 12307  	            0x1d000: 0x20000080,
 12308  	            0x1e000: 0x0,
 12309  	            0x1f000: 0x1040080,
 12310  	            0x10800: 0x21000080,
 12311  	            0x11800: 0x1000000,
 12312  	            0x12800: 0x1040000,
 12313  	            0x13800: 0x20040080,
 12314  	            0x14800: 0x20000000,
 12315  	            0x15800: 0x1040080,
 12316  	            0x16800: 0x80,
 12317  	            0x17800: 0x21040000,
 12318  	            0x18800: 0x40080,
 12319  	            0x19800: 0x21040080,
 12320  	            0x1a800: 0x0,
 12321  	            0x1b800: 0x21000000,
 12322  	            0x1c800: 0x1000080,
 12323  	            0x1d800: 0x40000,
 12324  	            0x1e800: 0x20040000,
 12325  	            0x1f800: 0x20000080
 12326  	        },
 12327  	        {
 12328  	            0x0: 0x10000008,
 12329  	            0x100: 0x2000,
 12330  	            0x200: 0x10200000,
 12331  	            0x300: 0x10202008,
 12332  	            0x400: 0x10002000,
 12333  	            0x500: 0x200000,
 12334  	            0x600: 0x200008,
 12335  	            0x700: 0x10000000,
 12336  	            0x800: 0x0,
 12337  	            0x900: 0x10002008,
 12338  	            0xa00: 0x202000,
 12339  	            0xb00: 0x8,
 12340  	            0xc00: 0x10200008,
 12341  	            0xd00: 0x202008,
 12342  	            0xe00: 0x2008,
 12343  	            0xf00: 0x10202000,
 12344  	            0x80: 0x10200000,
 12345  	            0x180: 0x10202008,
 12346  	            0x280: 0x8,
 12347  	            0x380: 0x200000,
 12348  	            0x480: 0x202008,
 12349  	            0x580: 0x10000008,
 12350  	            0x680: 0x10002000,
 12351  	            0x780: 0x2008,
 12352  	            0x880: 0x200008,
 12353  	            0x980: 0x2000,
 12354  	            0xa80: 0x10002008,
 12355  	            0xb80: 0x10200008,
 12356  	            0xc80: 0x0,
 12357  	            0xd80: 0x10202000,
 12358  	            0xe80: 0x202000,
 12359  	            0xf80: 0x10000000,
 12360  	            0x1000: 0x10002000,
 12361  	            0x1100: 0x10200008,
 12362  	            0x1200: 0x10202008,
 12363  	            0x1300: 0x2008,
 12364  	            0x1400: 0x200000,
 12365  	            0x1500: 0x10000000,
 12366  	            0x1600: 0x10000008,
 12367  	            0x1700: 0x202000,
 12368  	            0x1800: 0x202008,
 12369  	            0x1900: 0x0,
 12370  	            0x1a00: 0x8,
 12371  	            0x1b00: 0x10200000,
 12372  	            0x1c00: 0x2000,
 12373  	            0x1d00: 0x10002008,
 12374  	            0x1e00: 0x10202000,
 12375  	            0x1f00: 0x200008,
 12376  	            0x1080: 0x8,
 12377  	            0x1180: 0x202000,
 12378  	            0x1280: 0x200000,
 12379  	            0x1380: 0x10000008,
 12380  	            0x1480: 0x10002000,
 12381  	            0x1580: 0x2008,
 12382  	            0x1680: 0x10202008,
 12383  	            0x1780: 0x10200000,
 12384  	            0x1880: 0x10202000,
 12385  	            0x1980: 0x10200008,
 12386  	            0x1a80: 0x2000,
 12387  	            0x1b80: 0x202008,
 12388  	            0x1c80: 0x200008,
 12389  	            0x1d80: 0x0,
 12390  	            0x1e80: 0x10000000,
 12391  	            0x1f80: 0x10002008
 12392  	        },
 12393  	        {
 12394  	            0x0: 0x100000,
 12395  	            0x10: 0x2000401,
 12396  	            0x20: 0x400,
 12397  	            0x30: 0x100401,
 12398  	            0x40: 0x2100401,
 12399  	            0x50: 0x0,
 12400  	            0x60: 0x1,
 12401  	            0x70: 0x2100001,
 12402  	            0x80: 0x2000400,
 12403  	            0x90: 0x100001,
 12404  	            0xa0: 0x2000001,
 12405  	            0xb0: 0x2100400,
 12406  	            0xc0: 0x2100000,
 12407  	            0xd0: 0x401,
 12408  	            0xe0: 0x100400,
 12409  	            0xf0: 0x2000000,
 12410  	            0x8: 0x2100001,
 12411  	            0x18: 0x0,
 12412  	            0x28: 0x2000401,
 12413  	            0x38: 0x2100400,
 12414  	            0x48: 0x100000,
 12415  	            0x58: 0x2000001,
 12416  	            0x68: 0x2000000,
 12417  	            0x78: 0x401,
 12418  	            0x88: 0x100401,
 12419  	            0x98: 0x2000400,
 12420  	            0xa8: 0x2100000,
 12421  	            0xb8: 0x100001,
 12422  	            0xc8: 0x400,
 12423  	            0xd8: 0x2100401,
 12424  	            0xe8: 0x1,
 12425  	            0xf8: 0x100400,
 12426  	            0x100: 0x2000000,
 12427  	            0x110: 0x100000,
 12428  	            0x120: 0x2000401,
 12429  	            0x130: 0x2100001,
 12430  	            0x140: 0x100001,
 12431  	            0x150: 0x2000400,
 12432  	            0x160: 0x2100400,
 12433  	            0x170: 0x100401,
 12434  	            0x180: 0x401,
 12435  	            0x190: 0x2100401,
 12436  	            0x1a0: 0x100400,
 12437  	            0x1b0: 0x1,
 12438  	            0x1c0: 0x0,
 12439  	            0x1d0: 0x2100000,
 12440  	            0x1e0: 0x2000001,
 12441  	            0x1f0: 0x400,
 12442  	            0x108: 0x100400,
 12443  	            0x118: 0x2000401,
 12444  	            0x128: 0x2100001,
 12445  	            0x138: 0x1,
 12446  	            0x148: 0x2000000,
 12447  	            0x158: 0x100000,
 12448  	            0x168: 0x401,
 12449  	            0x178: 0x2100400,
 12450  	            0x188: 0x2000001,
 12451  	            0x198: 0x2100000,
 12452  	            0x1a8: 0x0,
 12453  	            0x1b8: 0x2100401,
 12454  	            0x1c8: 0x100401,
 12455  	            0x1d8: 0x400,
 12456  	            0x1e8: 0x2000400,
 12457  	            0x1f8: 0x100001
 12458  	        },
 12459  	        {
 12460  	            0x0: 0x8000820,
 12461  	            0x1: 0x20000,
 12462  	            0x2: 0x8000000,
 12463  	            0x3: 0x20,
 12464  	            0x4: 0x20020,
 12465  	            0x5: 0x8020820,
 12466  	            0x6: 0x8020800,
 12467  	            0x7: 0x800,
 12468  	            0x8: 0x8020000,
 12469  	            0x9: 0x8000800,
 12470  	            0xa: 0x20800,
 12471  	            0xb: 0x8020020,
 12472  	            0xc: 0x820,
 12473  	            0xd: 0x0,
 12474  	            0xe: 0x8000020,
 12475  	            0xf: 0x20820,
 12476  	            0x80000000: 0x800,
 12477  	            0x80000001: 0x8020820,
 12478  	            0x80000002: 0x8000820,
 12479  	            0x80000003: 0x8000000,
 12480  	            0x80000004: 0x8020000,
 12481  	            0x80000005: 0x20800,
 12482  	            0x80000006: 0x20820,
 12483  	            0x80000007: 0x20,
 12484  	            0x80000008: 0x8000020,
 12485  	            0x80000009: 0x820,
 12486  	            0x8000000a: 0x20020,
 12487  	            0x8000000b: 0x8020800,
 12488  	            0x8000000c: 0x0,
 12489  	            0x8000000d: 0x8020020,
 12490  	            0x8000000e: 0x8000800,
 12491  	            0x8000000f: 0x20000,
 12492  	            0x10: 0x20820,
 12493  	            0x11: 0x8020800,
 12494  	            0x12: 0x20,
 12495  	            0x13: 0x800,
 12496  	            0x14: 0x8000800,
 12497  	            0x15: 0x8000020,
 12498  	            0x16: 0x8020020,
 12499  	            0x17: 0x20000,
 12500  	            0x18: 0x0,
 12501  	            0x19: 0x20020,
 12502  	            0x1a: 0x8020000,
 12503  	            0x1b: 0x8000820,
 12504  	            0x1c: 0x8020820,
 12505  	            0x1d: 0x20800,
 12506  	            0x1e: 0x820,
 12507  	            0x1f: 0x8000000,
 12508  	            0x80000010: 0x20000,
 12509  	            0x80000011: 0x800,
 12510  	            0x80000012: 0x8020020,
 12511  	            0x80000013: 0x20820,
 12512  	            0x80000014: 0x20,
 12513  	            0x80000015: 0x8020000,
 12514  	            0x80000016: 0x8000000,
 12515  	            0x80000017: 0x8000820,
 12516  	            0x80000018: 0x8020820,
 12517  	            0x80000019: 0x8000020,
 12518  	            0x8000001a: 0x8000800,
 12519  	            0x8000001b: 0x0,
 12520  	            0x8000001c: 0x20800,
 12521  	            0x8000001d: 0x820,
 12522  	            0x8000001e: 0x20020,
 12523  	            0x8000001f: 0x8020800
 12524  	        }
 12525  	    ];
 12526  
 12527  	    // Masks that select the SBOX input
 12528  	    var SBOX_MASK = [
 12529  	        0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
 12530  	        0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
 12531  	    ];
 12532  
 12533  	    /**
 12534  	     * DES block cipher algorithm.
 12535  	     */
 12536  	    var DES = C_algo.DES = BlockCipher.extend({
 12537  	        _doReset: function () {
 12538  	            // Shortcuts
 12539  	            var key = this._key;
 12540  	            var keyWords = key.words;
 12541  
 12542  	            // Select 56 bits according to PC1
 12543  	            var keyBits = [];
 12544  	            for (var i = 0; i < 56; i++) {
 12545  	                var keyBitPos = PC1[i] - 1;
 12546  	                keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
 12547  	            }
 12548  
 12549  	            // Assemble 16 subkeys
 12550  	            var subKeys = this._subKeys = [];
 12551  	            for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
 12552  	                // Create subkey
 12553  	                var subKey = subKeys[nSubKey] = [];
 12554  
 12555  	                // Shortcut
 12556  	                var bitShift = BIT_SHIFTS[nSubKey];
 12557  
 12558  	                // Select 48 bits according to PC2
 12559  	                for (var i = 0; i < 24; i++) {
 12560  	                    // Select from the left 28 key bits
 12561  	                    subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
 12562  
 12563  	                    // Select from the right 28 key bits
 12564  	                    subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
 12565  	                }
 12566  
 12567  	                // Since each subkey is applied to an expanded 32-bit input,
 12568  	                // the subkey can be broken into 8 values scaled to 32-bits,
 12569  	                // which allows the key to be used without expansion
 12570  	                subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
 12571  	                for (var i = 1; i < 7; i++) {
 12572  	                    subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
 12573  	                }
 12574  	                subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
 12575  	            }
 12576  
 12577  	            // Compute inverse subkeys
 12578  	            var invSubKeys = this._invSubKeys = [];
 12579  	            for (var i = 0; i < 16; i++) {
 12580  	                invSubKeys[i] = subKeys[15 - i];
 12581  	            }
 12582  	        },
 12583  
 12584  	        encryptBlock: function (M, offset) {
 12585  	            this._doCryptBlock(M, offset, this._subKeys);
 12586  	        },
 12587  
 12588  	        decryptBlock: function (M, offset) {
 12589  	            this._doCryptBlock(M, offset, this._invSubKeys);
 12590  	        },
 12591  
 12592  	        _doCryptBlock: function (M, offset, subKeys) {
 12593  	            // Get input
 12594  	            this._lBlock = M[offset];
 12595  	            this._rBlock = M[offset + 1];
 12596  
 12597  	            // Initial permutation
 12598  	            exchangeLR.call(this, 4,  0x0f0f0f0f);
 12599  	            exchangeLR.call(this, 16, 0x0000ffff);
 12600  	            exchangeRL.call(this, 2,  0x33333333);
 12601  	            exchangeRL.call(this, 8,  0x00ff00ff);
 12602  	            exchangeLR.call(this, 1,  0x55555555);
 12603  
 12604  	            // Rounds
 12605  	            for (var round = 0; round < 16; round++) {
 12606  	                // Shortcuts
 12607  	                var subKey = subKeys[round];
 12608  	                var lBlock = this._lBlock;
 12609  	                var rBlock = this._rBlock;
 12610  
 12611  	                // Feistel function
 12612  	                var f = 0;
 12613  	                for (var i = 0; i < 8; i++) {
 12614  	                    f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
 12615  	                }
 12616  	                this._lBlock = rBlock;
 12617  	                this._rBlock = lBlock ^ f;
 12618  	            }
 12619  
 12620  	            // Undo swap from last round
 12621  	            var t = this._lBlock;
 12622  	            this._lBlock = this._rBlock;
 12623  	            this._rBlock = t;
 12624  
 12625  	            // Final permutation
 12626  	            exchangeLR.call(this, 1,  0x55555555);
 12627  	            exchangeRL.call(this, 8,  0x00ff00ff);
 12628  	            exchangeRL.call(this, 2,  0x33333333);
 12629  	            exchangeLR.call(this, 16, 0x0000ffff);
 12630  	            exchangeLR.call(this, 4,  0x0f0f0f0f);
 12631  
 12632  	            // Set output
 12633  	            M[offset] = this._lBlock;
 12634  	            M[offset + 1] = this._rBlock;
 12635  	        },
 12636  
 12637  	        keySize: 64/32,
 12638  
 12639  	        ivSize: 64/32,
 12640  
 12641  	        blockSize: 64/32
 12642  	    });
 12643  
 12644  	    // Swap bits across the left and right words
 12645  	    function exchangeLR(offset, mask) {
 12646  	        var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
 12647  	        this._rBlock ^= t;
 12648  	        this._lBlock ^= t << offset;
 12649  	    }
 12650  
 12651  	    function exchangeRL(offset, mask) {
 12652  	        var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
 12653  	        this._lBlock ^= t;
 12654  	        this._rBlock ^= t << offset;
 12655  	    }
 12656  
 12657  	    /**
 12658  	     * Shortcut functions to the cipher's object interface.
 12659  	     *
 12660  	     * @example
 12661  	     *
 12662  	     *     var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
 12663  	     *     var plaintext  = CryptoJS.DES.decrypt(ciphertext, key, cfg);
 12664  	     */
 12665  	    C.DES = BlockCipher._createHelper(DES);
 12666  
 12667  	    /**
 12668  	     * Triple-DES block cipher algorithm.
 12669  	     */
 12670  	    var TripleDES = C_algo.TripleDES = BlockCipher.extend({
 12671  	        _doReset: function () {
 12672  	            // Shortcuts
 12673  	            var key = this._key;
 12674  	            var keyWords = key.words;
 12675  
 12676  	            // Create DES instances
 12677  	            this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
 12678  	            this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
 12679  	            this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
 12680  	        },
 12681  
 12682  	        encryptBlock: function (M, offset) {
 12683  	            this._des1.encryptBlock(M, offset);
 12684  	            this._des2.decryptBlock(M, offset);
 12685  	            this._des3.encryptBlock(M, offset);
 12686  	        },
 12687  
 12688  	        decryptBlock: function (M, offset) {
 12689  	            this._des3.decryptBlock(M, offset);
 12690  	            this._des2.encryptBlock(M, offset);
 12691  	            this._des1.decryptBlock(M, offset);
 12692  	        },
 12693  
 12694  	        keySize: 192/32,
 12695  
 12696  	        ivSize: 64/32,
 12697  
 12698  	        blockSize: 64/32
 12699  	    });
 12700  
 12701  	    /**
 12702  	     * Shortcut functions to the cipher's object interface.
 12703  	     *
 12704  	     * @example
 12705  	     *
 12706  	     *     var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
 12707  	     *     var plaintext  = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
 12708  	     */
 12709  	    C.TripleDES = BlockCipher._createHelper(TripleDES);
 12710  	}());
 12711  
 12712  
 12713  	return CryptoJS.TripleDES;
 12714  
 12715  }));
 12716  },{"./cipher-core":51,"./core":52,"./enc-base64":53,"./evpkdf":55,"./md5":60}],83:[function(require,module,exports){
 12717  ;(function (root, factory) {
 12718  	if (typeof exports === "object") {
 12719  		// CommonJS
 12720  		module.exports = exports = factory(require("./core"));
 12721  	}
 12722  	else if (typeof define === "function" && define.amd) {
 12723  		// AMD
 12724  		define(["./core"], factory);
 12725  	}
 12726  	else {
 12727  		// Global (browser)
 12728  		factory(root.CryptoJS);
 12729  	}
 12730  }(this, function (CryptoJS) {
 12731  
 12732  	(function (undefined) {
 12733  	    // Shortcuts
 12734  	    var C = CryptoJS;
 12735  	    var C_lib = C.lib;
 12736  	    var Base = C_lib.Base;
 12737  	    var X32WordArray = C_lib.WordArray;
 12738  
 12739  	    /**
 12740  	     * x64 namespace.
 12741  	     */
 12742  	    var C_x64 = C.x64 = {};
 12743  
 12744  	    /**
 12745  	     * A 64-bit word.
 12746  	     */
 12747  	    var X64Word = C_x64.Word = Base.extend({
 12748  	        /**
 12749  	         * Initializes a newly created 64-bit word.
 12750  	         *
 12751  	         * @param {number} high The high 32 bits.
 12752  	         * @param {number} low The low 32 bits.
 12753  	         *
 12754  	         * @example
 12755  	         *
 12756  	         *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
 12757  	         */
 12758  	        init: function (high, low) {
 12759  	            this.high = high;
 12760  	            this.low = low;
 12761  	        }
 12762  
 12763  	        /**
 12764  	         * Bitwise NOTs this word.
 12765  	         *
 12766  	         * @return {X64Word} A new x64-Word object after negating.
 12767  	         *
 12768  	         * @example
 12769  	         *
 12770  	         *     var negated = x64Word.not();
 12771  	         */
 12772  	        // not: function () {
 12773  	            // var high = ~this.high;
 12774  	            // var low = ~this.low;
 12775  
 12776  	            // return X64Word.create(high, low);
 12777  	        // },
 12778  
 12779  	        /**
 12780  	         * Bitwise ANDs this word with the passed word.
 12781  	         *
 12782  	         * @param {X64Word} word The x64-Word to AND with this word.
 12783  	         *
 12784  	         * @return {X64Word} A new x64-Word object after ANDing.
 12785  	         *
 12786  	         * @example
 12787  	         *
 12788  	         *     var anded = x64Word.and(anotherX64Word);
 12789  	         */
 12790  	        // and: function (word) {
 12791  	            // var high = this.high & word.high;
 12792  	            // var low = this.low & word.low;
 12793  
 12794  	            // return X64Word.create(high, low);
 12795  	        // },
 12796  
 12797  	        /**
 12798  	         * Bitwise ORs this word with the passed word.
 12799  	         *
 12800  	         * @param {X64Word} word The x64-Word to OR with this word.
 12801  	         *
 12802  	         * @return {X64Word} A new x64-Word object after ORing.
 12803  	         *
 12804  	         * @example
 12805  	         *
 12806  	         *     var ored = x64Word.or(anotherX64Word);
 12807  	         */
 12808  	        // or: function (word) {
 12809  	            // var high = this.high | word.high;
 12810  	            // var low = this.low | word.low;
 12811  
 12812  	            // return X64Word.create(high, low);
 12813  	        // },
 12814  
 12815  	        /**
 12816  	         * Bitwise XORs this word with the passed word.
 12817  	         *
 12818  	         * @param {X64Word} word The x64-Word to XOR with this word.
 12819  	         *
 12820  	         * @return {X64Word} A new x64-Word object after XORing.
 12821  	         *
 12822  	         * @example
 12823  	         *
 12824  	         *     var xored = x64Word.xor(anotherX64Word);
 12825  	         */
 12826  	        // xor: function (word) {
 12827  	            // var high = this.high ^ word.high;
 12828  	            // var low = this.low ^ word.low;
 12829  
 12830  	            // return X64Word.create(high, low);
 12831  	        // },
 12832  
 12833  	        /**
 12834  	         * Shifts this word n bits to the left.
 12835  	         *
 12836  	         * @param {number} n The number of bits to shift.
 12837  	         *
 12838  	         * @return {X64Word} A new x64-Word object after shifting.
 12839  	         *
 12840  	         * @example
 12841  	         *
 12842  	         *     var shifted = x64Word.shiftL(25);
 12843  	         */
 12844  	        // shiftL: function (n) {
 12845  	            // if (n < 32) {
 12846  	                // var high = (this.high << n) | (this.low >>> (32 - n));
 12847  	                // var low = this.low << n;
 12848  	            // } else {
 12849  	                // var high = this.low << (n - 32);
 12850  	                // var low = 0;
 12851  	            // }
 12852  
 12853  	            // return X64Word.create(high, low);
 12854  	        // },
 12855  
 12856  	        /**
 12857  	         * Shifts this word n bits to the right.
 12858  	         *
 12859  	         * @param {number} n The number of bits to shift.
 12860  	         *
 12861  	         * @return {X64Word} A new x64-Word object after shifting.
 12862  	         *
 12863  	         * @example
 12864  	         *
 12865  	         *     var shifted = x64Word.shiftR(7);
 12866  	         */
 12867  	        // shiftR: function (n) {
 12868  	            // if (n < 32) {
 12869  	                // var low = (this.low >>> n) | (this.high << (32 - n));
 12870  	                // var high = this.high >>> n;
 12871  	            // } else {
 12872  	                // var low = this.high >>> (n - 32);
 12873  	                // var high = 0;
 12874  	            // }
 12875  
 12876  	            // return X64Word.create(high, low);
 12877  	        // },
 12878  
 12879  	        /**
 12880  	         * Rotates this word n bits to the left.
 12881  	         *
 12882  	         * @param {number} n The number of bits to rotate.
 12883  	         *
 12884  	         * @return {X64Word} A new x64-Word object after rotating.
 12885  	         *
 12886  	         * @example
 12887  	         *
 12888  	         *     var rotated = x64Word.rotL(25);
 12889  	         */
 12890  	        // rotL: function (n) {
 12891  	            // return this.shiftL(n).or(this.shiftR(64 - n));
 12892  	        // },
 12893  
 12894  	        /**
 12895  	         * Rotates this word n bits to the right.
 12896  	         *
 12897  	         * @param {number} n The number of bits to rotate.
 12898  	         *
 12899  	         * @return {X64Word} A new x64-Word object after rotating.
 12900  	         *
 12901  	         * @example
 12902  	         *
 12903  	         *     var rotated = x64Word.rotR(7);
 12904  	         */
 12905  	        // rotR: function (n) {
 12906  	            // return this.shiftR(n).or(this.shiftL(64 - n));
 12907  	        // },
 12908  
 12909  	        /**
 12910  	         * Adds this word with the passed word.
 12911  	         *
 12912  	         * @param {X64Word} word The x64-Word to add with this word.
 12913  	         *
 12914  	         * @return {X64Word} A new x64-Word object after adding.
 12915  	         *
 12916  	         * @example
 12917  	         *
 12918  	         *     var added = x64Word.add(anotherX64Word);
 12919  	         */
 12920  	        // add: function (word) {
 12921  	            // var low = (this.low + word.low) | 0;
 12922  	            // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
 12923  	            // var high = (this.high + word.high + carry) | 0;
 12924  
 12925  	            // return X64Word.create(high, low);
 12926  	        // }
 12927  	    });
 12928  
 12929  	    /**
 12930  	     * An array of 64-bit words.
 12931  	     *
 12932  	     * @property {Array} words The array of CryptoJS.x64.Word objects.
 12933  	     * @property {number} sigBytes The number of significant bytes in this word array.
 12934  	     */
 12935  	    var X64WordArray = C_x64.WordArray = Base.extend({
 12936  	        /**
 12937  	         * Initializes a newly created word array.
 12938  	         *
 12939  	         * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
 12940  	         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
 12941  	         *
 12942  	         * @example
 12943  	         *
 12944  	         *     var wordArray = CryptoJS.x64.WordArray.create();
 12945  	         *
 12946  	         *     var wordArray = CryptoJS.x64.WordArray.create([
 12947  	         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 12948  	         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 12949  	         *     ]);
 12950  	         *
 12951  	         *     var wordArray = CryptoJS.x64.WordArray.create([
 12952  	         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 12953  	         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 12954  	         *     ], 10);
 12955  	         */
 12956  	        init: function (words, sigBytes) {
 12957  	            words = this.words = words || [];
 12958  
 12959  	            if (sigBytes != undefined) {
 12960  	                this.sigBytes = sigBytes;
 12961  	            } else {
 12962  	                this.sigBytes = words.length * 8;
 12963  	            }
 12964  	        },
 12965  
 12966  	        /**
 12967  	         * Converts this 64-bit word array to a 32-bit word array.
 12968  	         *
 12969  	         * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
 12970  	         *
 12971  	         * @example
 12972  	         *
 12973  	         *     var x32WordArray = x64WordArray.toX32();
 12974  	         */
 12975  	        toX32: function () {
 12976  	            // Shortcuts
 12977  	            var x64Words = this.words;
 12978  	            var x64WordsLength = x64Words.length;
 12979  
 12980  	            // Convert
 12981  	            var x32Words = [];
 12982  	            for (var i = 0; i < x64WordsLength; i++) {
 12983  	                var x64Word = x64Words[i];
 12984  	                x32Words.push(x64Word.high);
 12985  	                x32Words.push(x64Word.low);
 12986  	            }
 12987  
 12988  	            return X32WordArray.create(x32Words, this.sigBytes);
 12989  	        },
 12990  
 12991  	        /**
 12992  	         * Creates a copy of this word array.
 12993  	         *
 12994  	         * @return {X64WordArray} The clone.
 12995  	         *
 12996  	         * @example
 12997  	         *
 12998  	         *     var clone = x64WordArray.clone();
 12999  	         */
 13000  	        clone: function () {
 13001  	            var clone = Base.clone.call(this);
 13002  
 13003  	            // Clone "words" array
 13004  	            var words = clone.words = this.words.slice(0);
 13005  
 13006  	            // Clone each X64Word object
 13007  	            var wordsLength = words.length;
 13008  	            for (var i = 0; i < wordsLength; i++) {
 13009  	                words[i] = words[i].clone();
 13010  	            }
 13011  
 13012  	            return clone;
 13013  	        }
 13014  	    });
 13015  	}());
 13016  
 13017  
 13018  	return CryptoJS;
 13019  
 13020  }));
 13021  },{"./core":52}],84:[function(require,module,exports){
 13022  /*! https://mths.be/utf8js v2.0.0 by @mathias */
 13023  ;(function(root) {
 13024  
 13025  	// Detect free variables exports
 13026  	var freeExports = typeof exports == 'object' && exports;
 13027  
 13028  	// Detect free variable module
 13029  	var freeModule = typeof module == 'object' && module &&
 13030  		module.exports == freeExports && module;
 13031  
 13032  	// Detect free variable global, from Node.js or Browserified code,
 13033  	// and use it as root
 13034  	var freeGlobal = typeof global == 'object' && global;
 13035  	if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
 13036  		root = freeGlobal;
 13037  	}
 13038  
 13039  	/*--------------------------------------------------------------------------*/
 13040  
 13041  	var stringFromCharCode = String.fromCharCode;
 13042  
 13043  	// Taken from https://mths.be/punycode
 13044  	function ucs2decode(string) {
 13045  		var output = [];
 13046  		var counter = 0;
 13047  		var length = string.length;
 13048  		var value;
 13049  		var extra;
 13050  		while (counter < length) {
 13051  			value = string.charCodeAt(counter++);
 13052  			if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
 13053  				// high surrogate, and there is a next character
 13054  				extra = string.charCodeAt(counter++);
 13055  				if ((extra & 0xFC00) == 0xDC00) { // low surrogate
 13056  					output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
 13057  				} else {
 13058  					// unmatched surrogate; only append this code unit, in case the next
 13059  					// code unit is the high surrogate of a surrogate pair
 13060  					output.push(value);
 13061  					counter--;
 13062  				}
 13063  			} else {
 13064  				output.push(value);
 13065  			}
 13066  		}
 13067  		return output;
 13068  	}
 13069  
 13070  	// Taken from https://mths.be/punycode
 13071  	function ucs2encode(array) {
 13072  		var length = array.length;
 13073  		var index = -1;
 13074  		var value;
 13075  		var output = '';
 13076  		while (++index < length) {
 13077  			value = array[index];
 13078  			if (value > 0xFFFF) {
 13079  				value -= 0x10000;
 13080  				output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
 13081  				value = 0xDC00 | value & 0x3FF;
 13082  			}
 13083  			output += stringFromCharCode(value);
 13084  		}
 13085  		return output;
 13086  	}
 13087  
 13088  	function checkScalarValue(codePoint) {
 13089  		if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
 13090  			throw Error(
 13091  				'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
 13092  				' is not a scalar value'
 13093  			);
 13094  		}
 13095  	}
 13096  	/*--------------------------------------------------------------------------*/
 13097  
 13098  	function createByte(codePoint, shift) {
 13099  		return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
 13100  	}
 13101  
 13102  	function encodeCodePoint(codePoint) {
 13103  		if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
 13104  			return stringFromCharCode(codePoint);
 13105  		}
 13106  		var symbol = '';
 13107  		if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
 13108  			symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
 13109  		}
 13110  		else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
 13111  			checkScalarValue(codePoint);
 13112  			symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
 13113  			symbol += createByte(codePoint, 6);
 13114  		}
 13115  		else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
 13116  			symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
 13117  			symbol += createByte(codePoint, 12);
 13118  			symbol += createByte(codePoint, 6);
 13119  		}
 13120  		symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
 13121  		return symbol;
 13122  	}
 13123  
 13124  	function utf8encode(string) {
 13125  		var codePoints = ucs2decode(string);
 13126  		var length = codePoints.length;
 13127  		var index = -1;
 13128  		var codePoint;
 13129  		var byteString = '';
 13130  		while (++index < length) {
 13131  			codePoint = codePoints[index];
 13132  			byteString += encodeCodePoint(codePoint);
 13133  		}
 13134  		return byteString;
 13135  	}
 13136  
 13137  	/*--------------------------------------------------------------------------*/
 13138  
 13139  	function readContinuationByte() {
 13140  		if (byteIndex >= byteCount) {
 13141  			throw Error('Invalid byte index');
 13142  		}
 13143  
 13144  		var continuationByte = byteArray[byteIndex] & 0xFF;
 13145  		byteIndex++;
 13146  
 13147  		if ((continuationByte & 0xC0) == 0x80) {
 13148  			return continuationByte & 0x3F;
 13149  		}
 13150  
 13151  		// If we end up here, it’s not a continuation byte
 13152  		throw Error('Invalid continuation byte');
 13153  	}
 13154  
 13155  	function decodeSymbol() {
 13156  		var byte1;
 13157  		var byte2;
 13158  		var byte3;
 13159  		var byte4;
 13160  		var codePoint;
 13161  
 13162  		if (byteIndex > byteCount) {
 13163  			throw Error('Invalid byte index');
 13164  		}
 13165  
 13166  		if (byteIndex == byteCount) {
 13167  			return false;
 13168  		}
 13169  
 13170  		// Read first byte
 13171  		byte1 = byteArray[byteIndex] & 0xFF;
 13172  		byteIndex++;
 13173  
 13174  		// 1-byte sequence (no continuation bytes)
 13175  		if ((byte1 & 0x80) == 0) {
 13176  			return byte1;
 13177  		}
 13178  
 13179  		// 2-byte sequence
 13180  		if ((byte1 & 0xE0) == 0xC0) {
 13181  			var byte2 = readContinuationByte();
 13182  			codePoint = ((byte1 & 0x1F) << 6) | byte2;
 13183  			if (codePoint >= 0x80) {
 13184  				return codePoint;
 13185  			} else {
 13186  				throw Error('Invalid continuation byte');
 13187  			}
 13188  		}
 13189  
 13190  		// 3-byte sequence (may include unpaired surrogates)
 13191  		if ((byte1 & 0xF0) == 0xE0) {
 13192  			byte2 = readContinuationByte();
 13193  			byte3 = readContinuationByte();
 13194  			codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
 13195  			if (codePoint >= 0x0800) {
 13196  				checkScalarValue(codePoint);
 13197  				return codePoint;
 13198  			} else {
 13199  				throw Error('Invalid continuation byte');
 13200  			}
 13201  		}
 13202  
 13203  		// 4-byte sequence
 13204  		if ((byte1 & 0xF8) == 0xF0) {
 13205  			byte2 = readContinuationByte();
 13206  			byte3 = readContinuationByte();
 13207  			byte4 = readContinuationByte();
 13208  			codePoint = ((byte1 & 0x0F) << 0x12) | (byte2 << 0x0C) |
 13209  				(byte3 << 0x06) | byte4;
 13210  			if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
 13211  				return codePoint;
 13212  			}
 13213  		}
 13214  
 13215  		throw Error('Invalid UTF-8 detected');
 13216  	}
 13217  
 13218  	var byteArray;
 13219  	var byteCount;
 13220  	var byteIndex;
 13221  	function utf8decode(byteString) {
 13222  		byteArray = ucs2decode(byteString);
 13223  		byteCount = byteArray.length;
 13224  		byteIndex = 0;
 13225  		var codePoints = [];
 13226  		var tmp;
 13227  		while ((tmp = decodeSymbol()) !== false) {
 13228  			codePoints.push(tmp);
 13229  		}
 13230  		return ucs2encode(codePoints);
 13231  	}
 13232  
 13233  	/*--------------------------------------------------------------------------*/
 13234  
 13235  	var utf8 = {
 13236  		'version': '2.0.0',
 13237  		'encode': utf8encode,
 13238  		'decode': utf8decode
 13239  	};
 13240  
 13241  	// Some AMD build optimizers, like r.js, check for specific condition patterns
 13242  	// like the following:
 13243  	if (
 13244  		typeof define == 'function' &&
 13245  		typeof define.amd == 'object' &&
 13246  		define.amd
 13247  	) {
 13248  		define(function() {
 13249  			return utf8;
 13250  		});
 13251  	}	else if (freeExports && !freeExports.nodeType) {
 13252  		if (freeModule) { // in Node.js or RingoJS v0.8.0+
 13253  			freeModule.exports = utf8;
 13254  		} else { // in Narwhal or RingoJS v0.7.0-
 13255  			var object = {};
 13256  			var hasOwnProperty = object.hasOwnProperty;
 13257  			for (var key in utf8) {
 13258  				hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
 13259  			}
 13260  		}
 13261  	} else { // in Rhino or a web browser
 13262  		root.utf8 = utf8;
 13263  	}
 13264  
 13265  }(this));
 13266  
 13267  },{}],"bignumber.js":[function(require,module,exports){
 13268  /*! bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */
 13269  
 13270  ;(function (global) {
 13271      'use strict';
 13272  
 13273      /*
 13274        bignumber.js v2.0.7
 13275        A JavaScript library for arbitrary-precision arithmetic.
 13276        https://github.com/MikeMcl/bignumber.js
 13277        Copyright (c) 2015 Michael Mclaughlin <M8ch88l@gmail.com>
 13278        MIT Expat Licence
 13279      */
 13280  
 13281  
 13282      var BigNumber, crypto, parseNumeric,
 13283          isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
 13284          mathceil = Math.ceil,
 13285          mathfloor = Math.floor,
 13286          notBool = ' not a boolean or binary digit',
 13287          roundingMode = 'rounding mode',
 13288          tooManyDigits = 'number type has more than 15 significant digits',
 13289          ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
 13290          BASE = 1e14,
 13291          LOG_BASE = 14,
 13292          MAX_SAFE_INTEGER = 0x1fffffffffffff,         // 2^53 - 1
 13293          // MAX_INT32 = 0x7fffffff,                   // 2^31 - 1
 13294          POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
 13295          SQRT_BASE = 1e7,
 13296  
 13297          /*
 13298           * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
 13299           * the arguments to toExponential, toFixed, toFormat, and toPrecision, beyond which an
 13300           * exception is thrown (if ERRORS is true).
 13301           */
 13302          MAX = 1E9;                                   // 0 to MAX_INT32
 13303  
 13304  
 13305      /*
 13306       * Create and return a BigNumber constructor.
 13307       */
 13308      function another(configObj) {
 13309          var div,
 13310  
 13311              // id tracks the caller function, so its name can be included in error messages.
 13312              id = 0,
 13313              P = BigNumber.prototype,
 13314              ONE = new BigNumber(1),
 13315  
 13316  
 13317              /********************************* EDITABLE DEFAULTS **********************************/
 13318  
 13319  
 13320              /*
 13321               * The default values below must be integers within the inclusive ranges stated.
 13322               * The values can also be changed at run-time using BigNumber.config.
 13323               */
 13324  
 13325              // The maximum number of decimal places for operations involving division.
 13326              DECIMAL_PLACES = 20,                     // 0 to MAX
 13327  
 13328              /*
 13329               * The rounding mode used when rounding to the above decimal places, and when using
 13330               * toExponential, toFixed, toFormat and toPrecision, and round (default value).
 13331               * UP         0 Away from zero.
 13332               * DOWN       1 Towards zero.
 13333               * CEIL       2 Towards +Infinity.
 13334               * FLOOR      3 Towards -Infinity.
 13335               * HALF_UP    4 Towards nearest neighbour. If equidistant, up.
 13336               * HALF_DOWN  5 Towards nearest neighbour. If equidistant, down.
 13337               * HALF_EVEN  6 Towards nearest neighbour. If equidistant, towards even neighbour.
 13338               * HALF_CEIL  7 Towards nearest neighbour. If equidistant, towards +Infinity.
 13339               * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
 13340               */
 13341              ROUNDING_MODE = 4,                       // 0 to 8
 13342  
 13343              // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
 13344  
 13345              // The exponent value at and beneath which toString returns exponential notation.
 13346              // Number type: -7
 13347              TO_EXP_NEG = -7,                         // 0 to -MAX
 13348  
 13349              // The exponent value at and above which toString returns exponential notation.
 13350              // Number type: 21
 13351              TO_EXP_POS = 21,                         // 0 to MAX
 13352  
 13353              // RANGE : [MIN_EXP, MAX_EXP]
 13354  
 13355              // The minimum exponent value, beneath which underflow to zero occurs.
 13356              // Number type: -324  (5e-324)
 13357              MIN_EXP = -1e7,                          // -1 to -MAX
 13358  
 13359              // The maximum exponent value, above which overflow to Infinity occurs.
 13360              // Number type:  308  (1.7976931348623157e+308)
 13361              // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
 13362              MAX_EXP = 1e7,                           // 1 to MAX
 13363  
 13364              // Whether BigNumber Errors are ever thrown.
 13365              ERRORS = true,                           // true or false
 13366  
 13367              // Change to intValidatorNoErrors if ERRORS is false.
 13368              isValidInt = intValidatorWithErrors,     // intValidatorWithErrors/intValidatorNoErrors
 13369  
 13370              // Whether to use cryptographically-secure random number generation, if available.
 13371              CRYPTO = false,                          // true or false
 13372  
 13373              /*
 13374               * The modulo mode used when calculating the modulus: a mod n.
 13375               * The quotient (q = a / n) is calculated according to the corresponding rounding mode.
 13376               * The remainder (r) is calculated as: r = a - n * q.
 13377               *
 13378               * UP        0 The remainder is positive if the dividend is negative, else is negative.
 13379               * DOWN      1 The remainder has the same sign as the dividend.
 13380               *             This modulo mode is commonly known as 'truncated division' and is
 13381               *             equivalent to (a % n) in JavaScript.
 13382               * FLOOR     3 The remainder has the same sign as the divisor (Python %).
 13383               * HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
 13384               * EUCLID    9 Euclidian division. q = sign(n) * floor(a / abs(n)).
 13385               *             The remainder is always positive.
 13386               *
 13387               * The truncated division, floored division, Euclidian division and IEEE 754 remainder
 13388               * modes are commonly used for the modulus operation.
 13389               * Although the other rounding modes can also be used, they may not give useful results.
 13390               */
 13391              MODULO_MODE = 1,                         // 0 to 9
 13392  
 13393              // The maximum number of significant digits of the result of the toPower operation.
 13394              // If POW_PRECISION is 0, there will be unlimited significant digits.
 13395              POW_PRECISION = 100,                     // 0 to MAX
 13396  
 13397              // The format specification used by the BigNumber.prototype.toFormat method.
 13398              FORMAT = {
 13399                  decimalSeparator: '.',
 13400                  groupSeparator: ',',
 13401                  groupSize: 3,
 13402                  secondaryGroupSize: 0,
 13403                  fractionGroupSeparator: '\xA0',      // non-breaking space
 13404                  fractionGroupSize: 0
 13405              };
 13406  
 13407  
 13408          /******************************************************************************************/
 13409  
 13410  
 13411          // CONSTRUCTOR
 13412  
 13413  
 13414          /*
 13415           * The BigNumber constructor and exported function.
 13416           * Create and return a new instance of a BigNumber object.
 13417           *
 13418           * n {number|string|BigNumber} A numeric value.
 13419           * [b] {number} The base of n. Integer, 2 to 64 inclusive.
 13420           */
 13421          function BigNumber( n, b ) {
 13422              var c, e, i, num, len, str,
 13423                  x = this;
 13424  
 13425              // Enable constructor usage without new.
 13426              if ( !( x instanceof BigNumber ) ) {
 13427  
 13428                  // 'BigNumber() constructor call without new: {n}'
 13429                  if (ERRORS) raise( 26, 'constructor call without new', n );
 13430                  return new BigNumber( n, b );
 13431              }
 13432  
 13433              // 'new BigNumber() base not an integer: {b}'
 13434              // 'new BigNumber() base out of range: {b}'
 13435              if ( b == null || !isValidInt( b, 2, 64, id, 'base' ) ) {
 13436  
 13437                  // Duplicate.
 13438                  if ( n instanceof BigNumber ) {
 13439                      x.s = n.s;
 13440                      x.e = n.e;
 13441                      x.c = ( n = n.c ) ? n.slice() : n;
 13442                      id = 0;
 13443                      return;
 13444                  }
 13445  
 13446                  if ( ( num = typeof n == 'number' ) && n * 0 == 0 ) {
 13447                      x.s = 1 / n < 0 ? ( n = -n, -1 ) : 1;
 13448  
 13449                      // Fast path for integers.
 13450                      if ( n === ~~n ) {
 13451                          for ( e = 0, i = n; i >= 10; i /= 10, e++ );
 13452                          x.e = e;
 13453                          x.c = [n];
 13454                          id = 0;
 13455                          return;
 13456                      }
 13457  
 13458                      str = n + '';
 13459                  } else {
 13460                      if ( !isNumeric.test( str = n + '' ) ) return parseNumeric( x, str, num );
 13461                      x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
 13462                  }
 13463              } else {
 13464                  b = b | 0;
 13465                  str = n + '';
 13466  
 13467                  // Ensure return value is rounded to DECIMAL_PLACES as with other bases.
 13468                  // Allow exponential notation to be used with base 10 argument.
 13469                  if ( b == 10 ) {
 13470                      x = new BigNumber( n instanceof BigNumber ? n : str );
 13471                      return round( x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE );
 13472                  }
 13473  
 13474                  // Avoid potential interpretation of Infinity and NaN as base 44+ values.
 13475                  // Any number in exponential form will fail due to the [Ee][+-].
 13476                  if ( ( num = typeof n == 'number' ) && n * 0 != 0 ||
 13477                    !( new RegExp( '^-?' + ( c = '[' + ALPHABET.slice( 0, b ) + ']+' ) +
 13478                      '(?:\\.' + c + ')?$',b < 37 ? 'i' : '' ) ).test(str) ) {
 13479                      return parseNumeric( x, str, num, b );
 13480                  }
 13481  
 13482                  if (num) {
 13483                      x.s = 1 / n < 0 ? ( str = str.slice(1), -1 ) : 1;
 13484  
 13485                      if ( ERRORS && str.replace( /^0\.0*|\./, '' ).length > 15 ) {
 13486  
 13487                          // 'new BigNumber() number type has more than 15 significant digits: {n}'
 13488                          raise( id, tooManyDigits, n );
 13489                      }
 13490  
 13491                      // Prevent later check for length on converted number.
 13492                      num = false;
 13493                  } else {
 13494                      x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
 13495                  }
 13496  
 13497                  str = convertBase( str, 10, b, x.s );
 13498              }
 13499  
 13500              // Decimal point?
 13501              if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );
 13502  
 13503              // Exponential form?
 13504              if ( ( i = str.search( /e/i ) ) > 0 ) {
 13505  
 13506                  // Determine exponent.
 13507                  if ( e < 0 ) e = i;
 13508                  e += +str.slice( i + 1 );
 13509                  str = str.substring( 0, i );
 13510              } else if ( e < 0 ) {
 13511  
 13512                  // Integer.
 13513                  e = str.length;
 13514              }
 13515  
 13516              // Determine leading zeros.
 13517              for ( i = 0; str.charCodeAt(i) === 48; i++ );
 13518  
 13519              // Determine trailing zeros.
 13520              for ( len = str.length; str.charCodeAt(--len) === 48; );
 13521              str = str.slice( i, len + 1 );
 13522  
 13523              if (str) {
 13524                  len = str.length;
 13525  
 13526                  // Disallow numbers with over 15 significant digits if number type.
 13527                  // 'new BigNumber() number type has more than 15 significant digits: {n}'
 13528                  if ( num && ERRORS && len > 15 ) raise( id, tooManyDigits, x.s * n );
 13529  
 13530                  e = e - i - 1;
 13531  
 13532                   // Overflow?
 13533                  if ( e > MAX_EXP ) {
 13534  
 13535                      // Infinity.
 13536                      x.c = x.e = null;
 13537  
 13538                  // Underflow?
 13539                  } else if ( e < MIN_EXP ) {
 13540  
 13541                      // Zero.
 13542                      x.c = [ x.e = 0 ];
 13543                  } else {
 13544                      x.e = e;
 13545                      x.c = [];
 13546  
 13547                      // Transform base
 13548  
 13549                      // e is the base 10 exponent.
 13550                      // i is where to slice str to get the first element of the coefficient array.
 13551                      i = ( e + 1 ) % LOG_BASE;
 13552                      if ( e < 0 ) i += LOG_BASE;
 13553  
 13554                      if ( i < len ) {
 13555                          if (i) x.c.push( +str.slice( 0, i ) );
 13556  
 13557                          for ( len -= LOG_BASE; i < len; ) {
 13558                              x.c.push( +str.slice( i, i += LOG_BASE ) );
 13559                          }
 13560  
 13561                          str = str.slice(i);
 13562                          i = LOG_BASE - str.length;
 13563                      } else {
 13564                          i -= len;
 13565                      }
 13566  
 13567                      for ( ; i--; str += '0' );
 13568                      x.c.push( +str );
 13569                  }
 13570              } else {
 13571  
 13572                  // Zero.
 13573                  x.c = [ x.e = 0 ];
 13574              }
 13575  
 13576              id = 0;
 13577          }
 13578  
 13579  
 13580          // CONSTRUCTOR PROPERTIES
 13581  
 13582  
 13583          BigNumber.another = another;
 13584  
 13585          BigNumber.ROUND_UP = 0;
 13586          BigNumber.ROUND_DOWN = 1;
 13587          BigNumber.ROUND_CEIL = 2;
 13588          BigNumber.ROUND_FLOOR = 3;
 13589          BigNumber.ROUND_HALF_UP = 4;
 13590          BigNumber.ROUND_HALF_DOWN = 5;
 13591          BigNumber.ROUND_HALF_EVEN = 6;
 13592          BigNumber.ROUND_HALF_CEIL = 7;
 13593          BigNumber.ROUND_HALF_FLOOR = 8;
 13594          BigNumber.EUCLID = 9;
 13595  
 13596  
 13597          /*
 13598           * Configure infrequently-changing library-wide settings.
 13599           *
 13600           * Accept an object or an argument list, with one or many of the following properties or
 13601           * parameters respectively:
 13602           *
 13603           *   DECIMAL_PLACES  {number}  Integer, 0 to MAX inclusive
 13604           *   ROUNDING_MODE   {number}  Integer, 0 to 8 inclusive
 13605           *   EXPONENTIAL_AT  {number|number[]}  Integer, -MAX to MAX inclusive or
 13606           *                                      [integer -MAX to 0 incl., 0 to MAX incl.]
 13607           *   RANGE           {number|number[]}  Non-zero integer, -MAX to MAX inclusive or
 13608           *                                      [integer -MAX to -1 incl., integer 1 to MAX incl.]
 13609           *   ERRORS          {boolean|number}   true, false, 1 or 0
 13610           *   CRYPTO          {boolean|number}   true, false, 1 or 0
 13611           *   MODULO_MODE     {number}           0 to 9 inclusive
 13612           *   POW_PRECISION   {number}           0 to MAX inclusive
 13613           *   FORMAT          {object}           See BigNumber.prototype.toFormat
 13614           *      decimalSeparator       {string}
 13615           *      groupSeparator         {string}
 13616           *      groupSize              {number}
 13617           *      secondaryGroupSize     {number}
 13618           *      fractionGroupSeparator {string}
 13619           *      fractionGroupSize      {number}
 13620           *
 13621           * (The values assigned to the above FORMAT object properties are not checked for validity.)
 13622           *
 13623           * E.g.
 13624           * BigNumber.config(20, 4) is equivalent to
 13625           * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
 13626           *
 13627           * Ignore properties/parameters set to null or undefined.
 13628           * Return an object with the properties current values.
 13629           */
 13630          BigNumber.config = function () {
 13631              var v, p,
 13632                  i = 0,
 13633                  r = {},
 13634                  a = arguments,
 13635                  o = a[0],
 13636                  has = o && typeof o == 'object'
 13637                    ? function () { if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null; }
 13638                    : function () { if ( a.length > i ) return ( v = a[i++] ) != null; };
 13639  
 13640              // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
 13641              // 'config() DECIMAL_PLACES not an integer: {v}'
 13642              // 'config() DECIMAL_PLACES out of range: {v}'
 13643              if ( has( p = 'DECIMAL_PLACES' ) && isValidInt( v, 0, MAX, 2, p ) ) {
 13644                  DECIMAL_PLACES = v | 0;
 13645              }
 13646              r[p] = DECIMAL_PLACES;
 13647  
 13648              // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
 13649              // 'config() ROUNDING_MODE not an integer: {v}'
 13650              // 'config() ROUNDING_MODE out of range: {v}'
 13651              if ( has( p = 'ROUNDING_MODE' ) && isValidInt( v, 0, 8, 2, p ) ) {
 13652                  ROUNDING_MODE = v | 0;
 13653              }
 13654              r[p] = ROUNDING_MODE;
 13655  
 13656              // EXPONENTIAL_AT {number|number[]}
 13657              // Integer, -MAX to MAX inclusive or [integer -MAX to 0 inclusive, 0 to MAX inclusive].
 13658              // 'config() EXPONENTIAL_AT not an integer: {v}'
 13659              // 'config() EXPONENTIAL_AT out of range: {v}'
 13660              if ( has( p = 'EXPONENTIAL_AT' ) ) {
 13661  
 13662                  if ( isArray(v) ) {
 13663                      if ( isValidInt( v[0], -MAX, 0, 2, p ) && isValidInt( v[1], 0, MAX, 2, p ) ) {
 13664                          TO_EXP_NEG = v[0] | 0;
 13665                          TO_EXP_POS = v[1] | 0;
 13666                      }
 13667                  } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
 13668                      TO_EXP_NEG = -( TO_EXP_POS = ( v < 0 ? -v : v ) | 0 );
 13669                  }
 13670              }
 13671              r[p] = [ TO_EXP_NEG, TO_EXP_POS ];
 13672  
 13673              // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
 13674              // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
 13675              // 'config() RANGE not an integer: {v}'
 13676              // 'config() RANGE cannot be zero: {v}'
 13677              // 'config() RANGE out of range: {v}'
 13678              if ( has( p = 'RANGE' ) ) {
 13679  
 13680                  if ( isArray(v) ) {
 13681                      if ( isValidInt( v[0], -MAX, -1, 2, p ) && isValidInt( v[1], 1, MAX, 2, p ) ) {
 13682                          MIN_EXP = v[0] | 0;
 13683                          MAX_EXP = v[1] | 0;
 13684                      }
 13685                  } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
 13686                      if ( v | 0 ) MIN_EXP = -( MAX_EXP = ( v < 0 ? -v : v ) | 0 );
 13687                      else if (ERRORS) raise( 2, p + ' cannot be zero', v );
 13688                  }
 13689              }
 13690              r[p] = [ MIN_EXP, MAX_EXP ];
 13691  
 13692              // ERRORS {boolean|number} true, false, 1 or 0.
 13693              // 'config() ERRORS not a boolean or binary digit: {v}'
 13694              if ( has( p = 'ERRORS' ) ) {
 13695  
 13696                  if ( v === !!v || v === 1 || v === 0 ) {
 13697                      id = 0;
 13698                      isValidInt = ( ERRORS = !!v ) ? intValidatorWithErrors : intValidatorNoErrors;
 13699                  } else if (ERRORS) {
 13700                      raise( 2, p + notBool, v );
 13701                  }
 13702              }
 13703              r[p] = ERRORS;
 13704  
 13705              // CRYPTO {boolean|number} true, false, 1 or 0.
 13706              // 'config() CRYPTO not a boolean or binary digit: {v}'
 13707              // 'config() crypto unavailable: {crypto}'
 13708              if ( has( p = 'CRYPTO' ) ) {
 13709  
 13710                  if ( v === !!v || v === 1 || v === 0 ) {
 13711                      CRYPTO = !!( v && crypto && typeof crypto == 'object' );
 13712                      if ( v && !CRYPTO && ERRORS ) raise( 2, 'crypto unavailable', crypto );
 13713                  } else if (ERRORS) {
 13714                      raise( 2, p + notBool, v );
 13715                  }
 13716              }
 13717              r[p] = CRYPTO;
 13718  
 13719              // MODULO_MODE {number} Integer, 0 to 9 inclusive.
 13720              // 'config() MODULO_MODE not an integer: {v}'
 13721              // 'config() MODULO_MODE out of range: {v}'
 13722              if ( has( p = 'MODULO_MODE' ) && isValidInt( v, 0, 9, 2, p ) ) {
 13723                  MODULO_MODE = v | 0;
 13724              }
 13725              r[p] = MODULO_MODE;
 13726  
 13727              // POW_PRECISION {number} Integer, 0 to MAX inclusive.
 13728              // 'config() POW_PRECISION not an integer: {v}'
 13729              // 'config() POW_PRECISION out of range: {v}'
 13730              if ( has( p = 'POW_PRECISION' ) && isValidInt( v, 0, MAX, 2, p ) ) {
 13731                  POW_PRECISION = v | 0;
 13732              }
 13733              r[p] = POW_PRECISION;
 13734  
 13735              // FORMAT {object}
 13736              // 'config() FORMAT not an object: {v}'
 13737              if ( has( p = 'FORMAT' ) ) {
 13738  
 13739                  if ( typeof v == 'object' ) {
 13740                      FORMAT = v;
 13741                  } else if (ERRORS) {
 13742                      raise( 2, p + ' not an object', v );
 13743                  }
 13744              }
 13745              r[p] = FORMAT;
 13746  
 13747              return r;
 13748          };
 13749  
 13750  
 13751          /*
 13752           * Return a new BigNumber whose value is the maximum of the arguments.
 13753           *
 13754           * arguments {number|string|BigNumber}
 13755           */
 13756          BigNumber.max = function () { return maxOrMin( arguments, P.lt ); };
 13757  
 13758  
 13759          /*
 13760           * Return a new BigNumber whose value is the minimum of the arguments.
 13761           *
 13762           * arguments {number|string|BigNumber}
 13763           */
 13764          BigNumber.min = function () { return maxOrMin( arguments, P.gt ); };
 13765  
 13766  
 13767          /*
 13768           * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
 13769           * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
 13770           * zeros are produced).
 13771           *
 13772           * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
 13773           *
 13774           * 'random() decimal places not an integer: {dp}'
 13775           * 'random() decimal places out of range: {dp}'
 13776           * 'random() crypto unavailable: {crypto}'
 13777           */
 13778          BigNumber.random = (function () {
 13779              var pow2_53 = 0x20000000000000;
 13780  
 13781              // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
 13782              // Check if Math.random() produces more than 32 bits of randomness.
 13783              // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
 13784              // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
 13785              var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
 13786                ? function () { return mathfloor( Math.random() * pow2_53 ); }
 13787                : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
 13788                    (Math.random() * 0x800000 | 0); };
 13789  
 13790              return function (dp) {
 13791                  var a, b, e, k, v,
 13792                      i = 0,
 13793                      c = [],
 13794                      rand = new BigNumber(ONE);
 13795  
 13796                  dp = dp == null || !isValidInt( dp, 0, MAX, 14 ) ? DECIMAL_PLACES : dp | 0;
 13797                  k = mathceil( dp / LOG_BASE );
 13798  
 13799                  if (CRYPTO) {
 13800  
 13801                      // Browsers supporting crypto.getRandomValues.
 13802                      if ( crypto && crypto.getRandomValues ) {
 13803  
 13804                          a = crypto.getRandomValues( new Uint32Array( k *= 2 ) );
 13805  
 13806                          for ( ; i < k; ) {
 13807  
 13808                              // 53 bits:
 13809                              // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
 13810                              // 11111 11111111 11111111 11111111 11100000 00000000 00000000
 13811                              // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
 13812                              //                                     11111 11111111 11111111
 13813                              // 0x20000 is 2^21.
 13814                              v = a[i] * 0x20000 + (a[i + 1] >>> 11);
 13815  
 13816                              // Rejection sampling:
 13817                              // 0 <= v < 9007199254740992
 13818                              // Probability that v >= 9e15, is
 13819                              // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
 13820                              if ( v >= 9e15 ) {
 13821                                  b = crypto.getRandomValues( new Uint32Array(2) );
 13822                                  a[i] = b[0];
 13823                                  a[i + 1] = b[1];
 13824                              } else {
 13825  
 13826                                  // 0 <= v <= 8999999999999999
 13827                                  // 0 <= (v % 1e14) <= 99999999999999
 13828                                  c.push( v % 1e14 );
 13829                                  i += 2;
 13830                              }
 13831                          }
 13832                          i = k / 2;
 13833  
 13834                      // Node.js supporting crypto.randomBytes.
 13835                      } else if ( crypto && crypto.randomBytes ) {
 13836  
 13837                          // buffer
 13838                          a = crypto.randomBytes( k *= 7 );
 13839  
 13840                          for ( ; i < k; ) {
 13841  
 13842                              // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
 13843                              // 0x100000000 is 2^32, 0x1000000 is 2^24
 13844                              // 11111 11111111 11111111 11111111 11111111 11111111 11111111
 13845                              // 0 <= v < 9007199254740992
 13846                              v = ( ( a[i] & 31 ) * 0x1000000000000 ) + ( a[i + 1] * 0x10000000000 ) +
 13847                                    ( a[i + 2] * 0x100000000 ) + ( a[i + 3] * 0x1000000 ) +
 13848                                    ( a[i + 4] << 16 ) + ( a[i + 5] << 8 ) + a[i + 6];
 13849  
 13850                              if ( v >= 9e15 ) {
 13851                                  crypto.randomBytes(7).copy( a, i );
 13852                              } else {
 13853  
 13854                                  // 0 <= (v % 1e14) <= 99999999999999
 13855                                  c.push( v % 1e14 );
 13856                                  i += 7;
 13857                              }
 13858                          }
 13859                          i = k / 7;
 13860                      } else if (ERRORS) {
 13861                          raise( 14, 'crypto unavailable', crypto );
 13862                      }
 13863                  }
 13864  
 13865                  // Use Math.random: CRYPTO is false or crypto is unavailable and ERRORS is false.
 13866                  if (!i) {
 13867  
 13868                      for ( ; i < k; ) {
 13869                          v = random53bitInt();
 13870                          if ( v < 9e15 ) c[i++] = v % 1e14;
 13871                      }
 13872                  }
 13873  
 13874                  k = c[--i];
 13875                  dp %= LOG_BASE;
 13876  
 13877                  // Convert trailing digits to zeros according to dp.
 13878                  if ( k && dp ) {
 13879                      v = POWS_TEN[LOG_BASE - dp];
 13880                      c[i] = mathfloor( k / v ) * v;
 13881                  }
 13882  
 13883                  // Remove trailing elements which are zero.
 13884                  for ( ; c[i] === 0; c.pop(), i-- );
 13885  
 13886                  // Zero?
 13887                  if ( i < 0 ) {
 13888                      c = [ e = 0 ];
 13889                  } else {
 13890  
 13891                      // Remove leading elements which are zero and adjust exponent accordingly.
 13892                      for ( e = -1 ; c[0] === 0; c.shift(), e -= LOG_BASE);
 13893  
 13894                      // Count the digits of the first element of c to determine leading zeros, and...
 13895                      for ( i = 1, v = c[0]; v >= 10; v /= 10, i++);
 13896  
 13897                      // adjust the exponent accordingly.
 13898                      if ( i < LOG_BASE ) e -= LOG_BASE - i;
 13899                  }
 13900  
 13901                  rand.e = e;
 13902                  rand.c = c;
 13903                  return rand;
 13904              };
 13905          })();
 13906  
 13907  
 13908          // PRIVATE FUNCTIONS
 13909  
 13910  
 13911          // Convert a numeric string of baseIn to a numeric string of baseOut.
 13912          function convertBase( str, baseOut, baseIn, sign ) {
 13913              var d, e, k, r, x, xc, y,
 13914                  i = str.indexOf( '.' ),
 13915                  dp = DECIMAL_PLACES,
 13916                  rm = ROUNDING_MODE;
 13917  
 13918              if ( baseIn < 37 ) str = str.toLowerCase();
 13919  
 13920              // Non-integer.
 13921              if ( i >= 0 ) {
 13922                  k = POW_PRECISION;
 13923  
 13924                  // Unlimited precision.
 13925                  POW_PRECISION = 0;
 13926                  str = str.replace( '.', '' );
 13927                  y = new BigNumber(baseIn);
 13928                  x = y.pow( str.length - i );
 13929                  POW_PRECISION = k;
 13930  
 13931                  // Convert str as if an integer, then restore the fraction part by dividing the
 13932                  // result by its base raised to a power.
 13933                  y.c = toBaseOut( toFixedPoint( coeffToString( x.c ), x.e ), 10, baseOut );
 13934                  y.e = y.c.length;
 13935              }
 13936  
 13937              // Convert the number as integer.
 13938              xc = toBaseOut( str, baseIn, baseOut );
 13939              e = k = xc.length;
 13940  
 13941              // Remove trailing zeros.
 13942              for ( ; xc[--k] == 0; xc.pop() );
 13943              if ( !xc[0] ) return '0';
 13944  
 13945              if ( i < 0 ) {
 13946                  --e;
 13947              } else {
 13948                  x.c = xc;
 13949                  x.e = e;
 13950  
 13951                  // sign is needed for correct rounding.
 13952                  x.s = sign;
 13953                  x = div( x, y, dp, rm, baseOut );
 13954                  xc = x.c;
 13955                  r = x.r;
 13956                  e = x.e;
 13957              }
 13958  
 13959              d = e + dp + 1;
 13960  
 13961              // The rounding digit, i.e. the digit to the right of the digit that may be rounded up.
 13962              i = xc[d];
 13963              k = baseOut / 2;
 13964              r = r || d < 0 || xc[d + 1] != null;
 13965  
 13966              r = rm < 4 ? ( i != null || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
 13967                         : i > k || i == k &&( rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
 13968                           rm == ( x.s < 0 ? 8 : 7 ) );
 13969  
 13970              if ( d < 1 || !xc[0] ) {
 13971  
 13972                  // 1^-dp or 0.
 13973                  str = r ? toFixedPoint( '1', -dp ) : '0';
 13974              } else {
 13975                  xc.length = d;
 13976  
 13977                  if (r) {
 13978  
 13979                      // Rounding up may mean the previous digit has to be rounded up and so on.
 13980                      for ( --baseOut; ++xc[--d] > baseOut; ) {
 13981                          xc[d] = 0;
 13982  
 13983                          if ( !d ) {
 13984                              ++e;
 13985                              xc.unshift(1);
 13986                          }
 13987                      }
 13988                  }
 13989  
 13990                  // Determine trailing zeros.
 13991                  for ( k = xc.length; !xc[--k]; );
 13992  
 13993                  // E.g. [4, 11, 15] becomes 4bf.
 13994                  for ( i = 0, str = ''; i <= k; str += ALPHABET.charAt( xc[i++] ) );
 13995                  str = toFixedPoint( str, e );
 13996              }
 13997  
 13998              // The caller will add the sign.
 13999              return str;
 14000          }
 14001  
 14002  
 14003          // Perform division in the specified base. Called by div and convertBase.
 14004          div = (function () {
 14005  
 14006              // Assume non-zero x and k.
 14007              function multiply( x, k, base ) {
 14008                  var m, temp, xlo, xhi,
 14009                      carry = 0,
 14010                      i = x.length,
 14011                      klo = k % SQRT_BASE,
 14012                      khi = k / SQRT_BASE | 0;
 14013  
 14014                  for ( x = x.slice(); i--; ) {
 14015                      xlo = x[i] % SQRT_BASE;
 14016                      xhi = x[i] / SQRT_BASE | 0;
 14017                      m = khi * xlo + xhi * klo;
 14018                      temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry;
 14019                      carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi;
 14020                      x[i] = temp % base;
 14021                  }
 14022  
 14023                  if (carry) x.unshift(carry);
 14024  
 14025                  return x;
 14026              }
 14027  
 14028              function compare( a, b, aL, bL ) {
 14029                  var i, cmp;
 14030  
 14031                  if ( aL != bL ) {
 14032                      cmp = aL > bL ? 1 : -1;
 14033                  } else {
 14034  
 14035                      for ( i = cmp = 0; i < aL; i++ ) {
 14036  
 14037                          if ( a[i] != b[i] ) {
 14038                              cmp = a[i] > b[i] ? 1 : -1;
 14039                              break;
 14040                          }
 14041                      }
 14042                  }
 14043                  return cmp;
 14044              }
 14045  
 14046              function subtract( a, b, aL, base ) {
 14047                  var i = 0;
 14048  
 14049                  // Subtract b from a.
 14050                  for ( ; aL--; ) {
 14051                      a[aL] -= i;
 14052                      i = a[aL] < b[aL] ? 1 : 0;
 14053                      a[aL] = i * base + a[aL] - b[aL];
 14054                  }
 14055  
 14056                  // Remove leading zeros.
 14057                  for ( ; !a[0] && a.length > 1; a.shift() );
 14058              }
 14059  
 14060              // x: dividend, y: divisor.
 14061              return function ( x, y, dp, rm, base ) {
 14062                  var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
 14063                      yL, yz,
 14064                      s = x.s == y.s ? 1 : -1,
 14065                      xc = x.c,
 14066                      yc = y.c;
 14067  
 14068                  // Either NaN, Infinity or 0?
 14069                  if ( !xc || !xc[0] || !yc || !yc[0] ) {
 14070  
 14071                      return new BigNumber(
 14072  
 14073                        // Return NaN if either NaN, or both Infinity or 0.
 14074                        !x.s || !y.s || ( xc ? yc && xc[0] == yc[0] : !yc ) ? NaN :
 14075  
 14076                          // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
 14077                          xc && xc[0] == 0 || !yc ? s * 0 : s / 0
 14078                      );
 14079                  }
 14080  
 14081                  q = new BigNumber(s);
 14082                  qc = q.c = [];
 14083                  e = x.e - y.e;
 14084                  s = dp + e + 1;
 14085  
 14086                  if ( !base ) {
 14087                      base = BASE;
 14088                      e = bitFloor( x.e / LOG_BASE ) - bitFloor( y.e / LOG_BASE );
 14089                      s = s / LOG_BASE | 0;
 14090                  }
 14091  
 14092                  // Result exponent may be one less then the current value of e.
 14093                  // The coefficients of the BigNumbers from convertBase may have trailing zeros.
 14094                  for ( i = 0; yc[i] == ( xc[i] || 0 ); i++ );
 14095                  if ( yc[i] > ( xc[i] || 0 ) ) e--;
 14096  
 14097                  if ( s < 0 ) {
 14098                      qc.push(1);
 14099                      more = true;
 14100                  } else {
 14101                      xL = xc.length;
 14102                      yL = yc.length;
 14103                      i = 0;
 14104                      s += 2;
 14105  
 14106                      // Normalise xc and yc so highest order digit of yc is >= base / 2.
 14107  
 14108                      n = mathfloor( base / ( yc[0] + 1 ) );
 14109  
 14110                      // Not necessary, but to handle odd bases where yc[0] == ( base / 2 ) - 1.
 14111                      // if ( n > 1 || n++ == 1 && yc[0] < base / 2 ) {
 14112                      if ( n > 1 ) {
 14113                          yc = multiply( yc, n, base );
 14114                          xc = multiply( xc, n, base );
 14115                          yL = yc.length;
 14116                          xL = xc.length;
 14117                      }
 14118  
 14119                      xi = yL;
 14120                      rem = xc.slice( 0, yL );
 14121                      remL = rem.length;
 14122  
 14123                      // Add zeros to make remainder as long as divisor.
 14124                      for ( ; remL < yL; rem[remL++] = 0 );
 14125                      yz = yc.slice();
 14126                      yz.unshift(0);
 14127                      yc0 = yc[0];
 14128                      if ( yc[1] >= base / 2 ) yc0++;
 14129                      // Not necessary, but to prevent trial digit n > base, when using base 3.
 14130                      // else if ( base == 3 && yc0 == 1 ) yc0 = 1 + 1e-15;
 14131  
 14132                      do {
 14133                          n = 0;
 14134  
 14135                          // Compare divisor and remainder.
 14136                          cmp = compare( yc, rem, yL, remL );
 14137  
 14138                          // If divisor < remainder.
 14139                          if ( cmp < 0 ) {
 14140  
 14141                              // Calculate trial digit, n.
 14142  
 14143                              rem0 = rem[0];
 14144                              if ( yL != remL ) rem0 = rem0 * base + ( rem[1] || 0 );
 14145  
 14146                              // n is how many times the divisor goes into the current remainder.
 14147                              n = mathfloor( rem0 / yc0 );
 14148  
 14149                              //  Algorithm:
 14150                              //  1. product = divisor * trial digit (n)
 14151                              //  2. if product > remainder: product -= divisor, n--
 14152                              //  3. remainder -= product
 14153                              //  4. if product was < remainder at 2:
 14154                              //    5. compare new remainder and divisor
 14155                              //    6. If remainder > divisor: remainder -= divisor, n++
 14156  
 14157                              if ( n > 1 ) {
 14158  
 14159                                  // n may be > base only when base is 3.
 14160                                  if (n >= base) n = base - 1;
 14161  
 14162                                  // product = divisor * trial digit.
 14163                                  prod = multiply( yc, n, base );
 14164                                  prodL = prod.length;
 14165                                  remL = rem.length;
 14166  
 14167                                  // Compare product and remainder.
 14168                                  // If product > remainder.
 14169                                  // Trial digit n too high.
 14170                                  // n is 1 too high about 5% of the time, and is not known to have
 14171                                  // ever been more than 1 too high.
 14172                                  while ( compare( prod, rem, prodL, remL ) == 1 ) {
 14173                                      n--;
 14174  
 14175                                      // Subtract divisor from product.
 14176                                      subtract( prod, yL < prodL ? yz : yc, prodL, base );
 14177                                      prodL = prod.length;
 14178                                      cmp = 1;
 14179                                  }
 14180                              } else {
 14181  
 14182                                  // n is 0 or 1, cmp is -1.
 14183                                  // If n is 0, there is no need to compare yc and rem again below,
 14184                                  // so change cmp to 1 to avoid it.
 14185                                  // If n is 1, leave cmp as -1, so yc and rem are compared again.
 14186                                  if ( n == 0 ) {
 14187  
 14188                                      // divisor < remainder, so n must be at least 1.
 14189                                      cmp = n = 1;
 14190                                  }
 14191  
 14192                                  // product = divisor
 14193                                  prod = yc.slice();
 14194                                  prodL = prod.length;
 14195                              }
 14196  
 14197                              if ( prodL < remL ) prod.unshift(0);
 14198  
 14199                              // Subtract product from remainder.
 14200                              subtract( rem, prod, remL, base );
 14201                              remL = rem.length;
 14202  
 14203                               // If product was < remainder.
 14204                              if ( cmp == -1 ) {
 14205  
 14206                                  // Compare divisor and new remainder.
 14207                                  // If divisor < new remainder, subtract divisor from remainder.
 14208                                  // Trial digit n too low.
 14209                                  // n is 1 too low about 5% of the time, and very rarely 2 too low.
 14210                                  while ( compare( yc, rem, yL, remL ) < 1 ) {
 14211                                      n++;
 14212  
 14213                                      // Subtract divisor from remainder.
 14214                                      subtract( rem, yL < remL ? yz : yc, remL, base );
 14215                                      remL = rem.length;
 14216                                  }
 14217                              }
 14218                          } else if ( cmp === 0 ) {
 14219                              n++;
 14220                              rem = [0];
 14221                          } // else cmp === 1 and n will be 0
 14222  
 14223                          // Add the next digit, n, to the result array.
 14224                          qc[i++] = n;
 14225  
 14226                          // Update the remainder.
 14227                          if ( rem[0] ) {
 14228                              rem[remL++] = xc[xi] || 0;
 14229                          } else {
 14230                              rem = [ xc[xi] ];
 14231                              remL = 1;
 14232                          }
 14233                      } while ( ( xi++ < xL || rem[0] != null ) && s-- );
 14234  
 14235                      more = rem[0] != null;
 14236  
 14237                      // Leading zero?
 14238                      if ( !qc[0] ) qc.shift();
 14239                  }
 14240  
 14241                  if ( base == BASE ) {
 14242  
 14243                      // To calculate q.e, first get the number of digits of qc[0].
 14244                      for ( i = 1, s = qc[0]; s >= 10; s /= 10, i++ );
 14245                      round( q, dp + ( q.e = i + e * LOG_BASE - 1 ) + 1, rm, more );
 14246  
 14247                  // Caller is convertBase.
 14248                  } else {
 14249                      q.e = e;
 14250                      q.r = +more;
 14251                  }
 14252  
 14253                  return q;
 14254              };
 14255          })();
 14256  
 14257  
 14258          /*
 14259           * Return a string representing the value of BigNumber n in fixed-point or exponential
 14260           * notation rounded to the specified decimal places or significant digits.
 14261           *
 14262           * n is a BigNumber.
 14263           * i is the index of the last digit required (i.e. the digit that may be rounded up).
 14264           * rm is the rounding mode.
 14265           * caller is caller id: toExponential 19, toFixed 20, toFormat 21, toPrecision 24.
 14266           */
 14267          function format( n, i, rm, caller ) {
 14268              var c0, e, ne, len, str;
 14269  
 14270              rm = rm != null && isValidInt( rm, 0, 8, caller, roundingMode )
 14271                ? rm | 0 : ROUNDING_MODE;
 14272  
 14273              if ( !n.c ) return n.toString();
 14274              c0 = n.c[0];
 14275              ne = n.e;
 14276  
 14277              if ( i == null ) {
 14278                  str = coeffToString( n.c );
 14279                  str = caller == 19 || caller == 24 && ne <= TO_EXP_NEG
 14280                    ? toExponential( str, ne )
 14281                    : toFixedPoint( str, ne );
 14282              } else {
 14283                  n = round( new BigNumber(n), i, rm );
 14284  
 14285                  // n.e may have changed if the value was rounded up.
 14286                  e = n.e;
 14287  
 14288                  str = coeffToString( n.c );
 14289                  len = str.length;
 14290  
 14291                  // toPrecision returns exponential notation if the number of significant digits
 14292                  // specified is less than the number of digits necessary to represent the integer
 14293                  // part of the value in fixed-point notation.
 14294  
 14295                  // Exponential notation.
 14296                  if ( caller == 19 || caller == 24 && ( i <= e || e <= TO_EXP_NEG ) ) {
 14297  
 14298                      // Append zeros?
 14299                      for ( ; len < i; str += '0', len++ );
 14300                      str = toExponential( str, e );
 14301  
 14302                  // Fixed-point notation.
 14303                  } else {
 14304                      i -= ne;
 14305                      str = toFixedPoint( str, e );
 14306  
 14307                      // Append zeros?
 14308                      if ( e + 1 > len ) {
 14309                          if ( --i > 0 ) for ( str += '.'; i--; str += '0' );
 14310                      } else {
 14311                          i += e - len;
 14312                          if ( i > 0 ) {
 14313                              if ( e + 1 == len ) str += '.';
 14314                              for ( ; i--; str += '0' );
 14315                          }
 14316                      }
 14317                  }
 14318              }
 14319  
 14320              return n.s < 0 && c0 ? '-' + str : str;
 14321          }
 14322  
 14323  
 14324          // Handle BigNumber.max and BigNumber.min.
 14325          function maxOrMin( args, method ) {
 14326              var m, n,
 14327                  i = 0;
 14328  
 14329              if ( isArray( args[0] ) ) args = args[0];
 14330              m = new BigNumber( args[0] );
 14331  
 14332              for ( ; ++i < args.length; ) {
 14333                  n = new BigNumber( args[i] );
 14334  
 14335                  // If any number is NaN, return NaN.
 14336                  if ( !n.s ) {
 14337                      m = n;
 14338                      break;
 14339                  } else if ( method.call( m, n ) ) {
 14340                      m = n;
 14341                  }
 14342              }
 14343  
 14344              return m;
 14345          }
 14346  
 14347  
 14348          /*
 14349           * Return true if n is an integer in range, otherwise throw.
 14350           * Use for argument validation when ERRORS is true.
 14351           */
 14352          function intValidatorWithErrors( n, min, max, caller, name ) {
 14353              if ( n < min || n > max || n != truncate(n) ) {
 14354                  raise( caller, ( name || 'decimal places' ) +
 14355                    ( n < min || n > max ? ' out of range' : ' not an integer' ), n );
 14356              }
 14357  
 14358              return true;
 14359          }
 14360  
 14361  
 14362          /*
 14363           * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
 14364           * Called by minus, plus and times.
 14365           */
 14366          function normalise( n, c, e ) {
 14367              var i = 1,
 14368                  j = c.length;
 14369  
 14370               // Remove trailing zeros.
 14371              for ( ; !c[--j]; c.pop() );
 14372  
 14373              // Calculate the base 10 exponent. First get the number of digits of c[0].
 14374              for ( j = c[0]; j >= 10; j /= 10, i++ );
 14375  
 14376              // Overflow?
 14377              if ( ( e = i + e * LOG_BASE - 1 ) > MAX_EXP ) {
 14378  
 14379                  // Infinity.
 14380                  n.c = n.e = null;
 14381  
 14382              // Underflow?
 14383              } else if ( e < MIN_EXP ) {
 14384  
 14385                  // Zero.
 14386                  n.c = [ n.e = 0 ];
 14387              } else {
 14388                  n.e = e;
 14389                  n.c = c;
 14390              }
 14391  
 14392              return n;
 14393          }
 14394  
 14395  
 14396          // Handle values that fail the validity test in BigNumber.
 14397          parseNumeric = (function () {
 14398              var basePrefix = /^(-?)0([xbo])/i,
 14399                  dotAfter = /^([^.]+)\.$/,
 14400                  dotBefore = /^\.([^.]+)$/,
 14401                  isInfinityOrNaN = /^-?(Infinity|NaN)$/,
 14402                  whitespaceOrPlus = /^\s*\+|^\s+|\s+$/g;
 14403  
 14404              return function ( x, str, num, b ) {
 14405                  var base,
 14406                      s = num ? str : str.replace( whitespaceOrPlus, '' );
 14407  
 14408                  // No exception on ±Infinity or NaN.
 14409                  if ( isInfinityOrNaN.test(s) ) {
 14410                      x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
 14411                  } else {
 14412                      if ( !num ) {
 14413  
 14414                          // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
 14415                          s = s.replace( basePrefix, function ( m, p1, p2 ) {
 14416                              base = ( p2 = p2.toLowerCase() ) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
 14417                              return !b || b == base ? p1 : m;
 14418                          });
 14419  
 14420                          if (b) {
 14421                              base = b;
 14422  
 14423                              // E.g. '1.' to '1', '.1' to '0.1'
 14424                              s = s.replace( dotAfter, '$1' ).replace( dotBefore, '0.$1' );
 14425                          }
 14426  
 14427                          if ( str != s ) return new BigNumber( s, base );
 14428                      }
 14429  
 14430                      // 'new BigNumber() not a number: {n}'
 14431                      // 'new BigNumber() not a base {b} number: {n}'
 14432                      if (ERRORS) raise( id, 'not a' + ( b ? ' base ' + b : '' ) + ' number', str );
 14433                      x.s = null;
 14434                  }
 14435  
 14436                  x.c = x.e = null;
 14437                  id = 0;
 14438              }
 14439          })();
 14440  
 14441  
 14442          // Throw a BigNumber Error.
 14443          function raise( caller, msg, val ) {
 14444              var error = new Error( [
 14445                  'new BigNumber',     // 0
 14446                  'cmp',               // 1
 14447                  'config',            // 2
 14448                  'div',               // 3
 14449                  'divToInt',          // 4
 14450                  'eq',                // 5
 14451                  'gt',                // 6
 14452                  'gte',               // 7
 14453                  'lt',                // 8
 14454                  'lte',               // 9
 14455                  'minus',             // 10
 14456                  'mod',               // 11
 14457                  'plus',              // 12
 14458                  'precision',         // 13
 14459                  'random',            // 14
 14460                  'round',             // 15
 14461                  'shift',             // 16
 14462                  'times',             // 17
 14463                  'toDigits',          // 18
 14464                  'toExponential',     // 19
 14465                  'toFixed',           // 20
 14466                  'toFormat',          // 21
 14467                  'toFraction',        // 22
 14468                  'pow',               // 23
 14469                  'toPrecision',       // 24
 14470                  'toString',          // 25
 14471                  'BigNumber'          // 26
 14472              ][caller] + '() ' + msg + ': ' + val );
 14473  
 14474              error.name = 'BigNumber Error';
 14475              id = 0;
 14476              throw error;
 14477          }
 14478  
 14479  
 14480          /*
 14481           * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
 14482           * If r is truthy, it is known that there are more digits after the rounding digit.
 14483           */
 14484          function round( x, sd, rm, r ) {
 14485              var d, i, j, k, n, ni, rd,
 14486                  xc = x.c,
 14487                  pows10 = POWS_TEN;
 14488  
 14489              // if x is not Infinity or NaN...
 14490              if (xc) {
 14491  
 14492                  // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
 14493                  // n is a base 1e14 number, the value of the element of array x.c containing rd.
 14494                  // ni is the index of n within x.c.
 14495                  // d is the number of digits of n.
 14496                  // i is the index of rd within n including leading zeros.
 14497                  // j is the actual index of rd within n (if < 0, rd is a leading zero).
 14498                  out: {
 14499  
 14500                      // Get the number of digits of the first element of xc.
 14501                      for ( d = 1, k = xc[0]; k >= 10; k /= 10, d++ );
 14502                      i = sd - d;
 14503  
 14504                      // If the rounding digit is in the first element of xc...
 14505                      if ( i < 0 ) {
 14506                          i += LOG_BASE;
 14507                          j = sd;
 14508                          n = xc[ ni = 0 ];
 14509  
 14510                          // Get the rounding digit at index j of n.
 14511                          rd = n / pows10[ d - j - 1 ] % 10 | 0;
 14512                      } else {
 14513                          ni = mathceil( ( i + 1 ) / LOG_BASE );
 14514  
 14515                          if ( ni >= xc.length ) {
 14516  
 14517                              if (r) {
 14518  
 14519                                  // Needed by sqrt.
 14520                                  for ( ; xc.length <= ni; xc.push(0) );
 14521                                  n = rd = 0;
 14522                                  d = 1;
 14523                                  i %= LOG_BASE;
 14524                                  j = i - LOG_BASE + 1;
 14525                              } else {
 14526                                  break out;
 14527                              }
 14528                          } else {
 14529                              n = k = xc[ni];
 14530  
 14531                              // Get the number of digits of n.
 14532                              for ( d = 1; k >= 10; k /= 10, d++ );
 14533  
 14534                              // Get the index of rd within n.
 14535                              i %= LOG_BASE;
 14536  
 14537                              // Get the index of rd within n, adjusted for leading zeros.
 14538                              // The number of leading zeros of n is given by LOG_BASE - d.
 14539                              j = i - LOG_BASE + d;
 14540  
 14541                              // Get the rounding digit at index j of n.
 14542                              rd = j < 0 ? 0 : n / pows10[ d - j - 1 ] % 10 | 0;
 14543                          }
 14544                      }
 14545  
 14546                      r = r || sd < 0 ||
 14547  
 14548                      // Are there any non-zero digits after the rounding digit?
 14549                      // The expression  n % pows10[ d - j - 1 ]  returns all digits of n to the right
 14550                      // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
 14551                        xc[ni + 1] != null || ( j < 0 ? n : n % pows10[ d - j - 1 ] );
 14552  
 14553                      r = rm < 4
 14554                        ? ( rd || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
 14555                        : rd > 5 || rd == 5 && ( rm == 4 || r || rm == 6 &&
 14556  
 14557                          // Check whether the digit to the left of the rounding digit is odd.
 14558                          ( ( i > 0 ? j > 0 ? n / pows10[ d - j ] : 0 : xc[ni - 1] ) % 10 ) & 1 ||
 14559                            rm == ( x.s < 0 ? 8 : 7 ) );
 14560  
 14561                      if ( sd < 1 || !xc[0] ) {
 14562                          xc.length = 0;
 14563  
 14564                          if (r) {
 14565  
 14566                              // Convert sd to decimal places.
 14567                              sd -= x.e + 1;
 14568  
 14569                              // 1, 0.1, 0.01, 0.001, 0.0001 etc.
 14570                              xc[0] = pows10[ sd % LOG_BASE ];
 14571                              x.e = -sd || 0;
 14572                          } else {
 14573  
 14574                              // Zero.
 14575                              xc[0] = x.e = 0;
 14576                          }
 14577  
 14578                          return x;
 14579                      }
 14580  
 14581                      // Remove excess digits.
 14582                      if ( i == 0 ) {
 14583                          xc.length = ni;
 14584                          k = 1;
 14585                          ni--;
 14586                      } else {
 14587                          xc.length = ni + 1;
 14588                          k = pows10[ LOG_BASE - i ];
 14589  
 14590                          // E.g. 56700 becomes 56000 if 7 is the rounding digit.
 14591                          // j > 0 means i > number of leading zeros of n.
 14592                          xc[ni] = j > 0 ? mathfloor( n / pows10[ d - j ] % pows10[j] ) * k : 0;
 14593                      }
 14594  
 14595                      // Round up?
 14596                      if (r) {
 14597  
 14598                          for ( ; ; ) {
 14599  
 14600                              // If the digit to be rounded up is in the first element of xc...
 14601                              if ( ni == 0 ) {
 14602  
 14603                                  // i will be the length of xc[0] before k is added.
 14604                                  for ( i = 1, j = xc[0]; j >= 10; j /= 10, i++ );
 14605                                  j = xc[0] += k;
 14606                                  for ( k = 1; j >= 10; j /= 10, k++ );
 14607  
 14608                                  // if i != k the length has increased.
 14609                                  if ( i != k ) {
 14610                                      x.e++;
 14611                                      if ( xc[0] == BASE ) xc[0] = 1;
 14612                                  }
 14613  
 14614                                  break;
 14615                              } else {
 14616                                  xc[ni] += k;
 14617                                  if ( xc[ni] != BASE ) break;
 14618                                  xc[ni--] = 0;
 14619                                  k = 1;
 14620                              }
 14621                          }
 14622                      }
 14623  
 14624                      // Remove trailing zeros.
 14625                      for ( i = xc.length; xc[--i] === 0; xc.pop() );
 14626                  }
 14627  
 14628                  // Overflow? Infinity.
 14629                  if ( x.e > MAX_EXP ) {
 14630                      x.c = x.e = null;
 14631  
 14632                  // Underflow? Zero.
 14633                  } else if ( x.e < MIN_EXP ) {
 14634                      x.c = [ x.e = 0 ];
 14635                  }
 14636              }
 14637  
 14638              return x;
 14639          }
 14640  
 14641  
 14642          // PROTOTYPE/INSTANCE METHODS
 14643  
 14644  
 14645          /*
 14646           * Return a new BigNumber whose value is the absolute value of this BigNumber.
 14647           */
 14648          P.absoluteValue = P.abs = function () {
 14649              var x = new BigNumber(this);
 14650              if ( x.s < 0 ) x.s = 1;
 14651              return x;
 14652          };
 14653  
 14654  
 14655          /*
 14656           * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
 14657           * number in the direction of Infinity.
 14658           */
 14659          P.ceil = function () {
 14660              return round( new BigNumber(this), this.e + 1, 2 );
 14661          };
 14662  
 14663  
 14664          /*
 14665           * Return
 14666           * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
 14667           * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
 14668           * 0 if they have the same value,
 14669           * or null if the value of either is NaN.
 14670           */
 14671          P.comparedTo = P.cmp = function ( y, b ) {
 14672              id = 1;
 14673              return compare( this, new BigNumber( y, b ) );
 14674          };
 14675  
 14676  
 14677          /*
 14678           * Return the number of decimal places of the value of this BigNumber, or null if the value
 14679           * of this BigNumber is ±Infinity or NaN.
 14680           */
 14681          P.decimalPlaces = P.dp = function () {
 14682              var n, v,
 14683                  c = this.c;
 14684  
 14685              if ( !c ) return null;
 14686              n = ( ( v = c.length - 1 ) - bitFloor( this.e / LOG_BASE ) ) * LOG_BASE;
 14687  
 14688              // Subtract the number of trailing zeros of the last number.
 14689              if ( v = c[v] ) for ( ; v % 10 == 0; v /= 10, n-- );
 14690              if ( n < 0 ) n = 0;
 14691  
 14692              return n;
 14693          };
 14694  
 14695  
 14696          /*
 14697           *  n / 0 = I
 14698           *  n / N = N
 14699           *  n / I = 0
 14700           *  0 / n = 0
 14701           *  0 / 0 = N
 14702           *  0 / N = N
 14703           *  0 / I = 0
 14704           *  N / n = N
 14705           *  N / 0 = N
 14706           *  N / N = N
 14707           *  N / I = N
 14708           *  I / n = I
 14709           *  I / 0 = I
 14710           *  I / N = N
 14711           *  I / I = N
 14712           *
 14713           * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
 14714           * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
 14715           */
 14716          P.dividedBy = P.div = function ( y, b ) {
 14717              id = 3;
 14718              return div( this, new BigNumber( y, b ), DECIMAL_PLACES, ROUNDING_MODE );
 14719          };
 14720  
 14721  
 14722          /*
 14723           * Return a new BigNumber whose value is the integer part of dividing the value of this
 14724           * BigNumber by the value of BigNumber(y, b).
 14725           */
 14726          P.dividedToIntegerBy = P.divToInt = function ( y, b ) {
 14727              id = 4;
 14728              return div( this, new BigNumber( y, b ), 0, 1 );
 14729          };
 14730  
 14731  
 14732          /*
 14733           * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
 14734           * otherwise returns false.
 14735           */
 14736          P.equals = P.eq = function ( y, b ) {
 14737              id = 5;
 14738              return compare( this, new BigNumber( y, b ) ) === 0;
 14739          };
 14740  
 14741  
 14742          /*
 14743           * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
 14744           * number in the direction of -Infinity.
 14745           */
 14746          P.floor = function () {
 14747              return round( new BigNumber(this), this.e + 1, 3 );
 14748          };
 14749  
 14750  
 14751          /*
 14752           * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
 14753           * otherwise returns false.
 14754           */
 14755          P.greaterThan = P.gt = function ( y, b ) {
 14756              id = 6;
 14757              return compare( this, new BigNumber( y, b ) ) > 0;
 14758          };
 14759  
 14760  
 14761          /*
 14762           * Return true if the value of this BigNumber is greater than or equal to the value of
 14763           * BigNumber(y, b), otherwise returns false.
 14764           */
 14765          P.greaterThanOrEqualTo = P.gte = function ( y, b ) {
 14766              id = 7;
 14767              return ( b = compare( this, new BigNumber( y, b ) ) ) === 1 || b === 0;
 14768  
 14769          };
 14770  
 14771  
 14772          /*
 14773           * Return true if the value of this BigNumber is a finite number, otherwise returns false.
 14774           */
 14775          P.isFinite = function () {
 14776              return !!this.c;
 14777          };
 14778  
 14779  
 14780          /*
 14781           * Return true if the value of this BigNumber is an integer, otherwise return false.
 14782           */
 14783          P.isInteger = P.isInt = function () {
 14784              return !!this.c && bitFloor( this.e / LOG_BASE ) > this.c.length - 2;
 14785          };
 14786  
 14787  
 14788          /*
 14789           * Return true if the value of this BigNumber is NaN, otherwise returns false.
 14790           */
 14791          P.isNaN = function () {
 14792              return !this.s;
 14793          };
 14794  
 14795  
 14796          /*
 14797           * Return true if the value of this BigNumber is negative, otherwise returns false.
 14798           */
 14799          P.isNegative = P.isNeg = function () {
 14800              return this.s < 0;
 14801          };
 14802  
 14803  
 14804          /*
 14805           * Return true if the value of this BigNumber is 0 or -0, otherwise returns false.
 14806           */
 14807          P.isZero = function () {
 14808              return !!this.c && this.c[0] == 0;
 14809          };
 14810  
 14811  
 14812          /*
 14813           * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
 14814           * otherwise returns false.
 14815           */
 14816          P.lessThan = P.lt = function ( y, b ) {
 14817              id = 8;
 14818              return compare( this, new BigNumber( y, b ) ) < 0;
 14819          };
 14820  
 14821  
 14822          /*
 14823           * Return true if the value of this BigNumber is less than or equal to the value of
 14824           * BigNumber(y, b), otherwise returns false.
 14825           */
 14826          P.lessThanOrEqualTo = P.lte = function ( y, b ) {
 14827              id = 9;
 14828              return ( b = compare( this, new BigNumber( y, b ) ) ) === -1 || b === 0;
 14829          };
 14830  
 14831  
 14832          /*
 14833           *  n - 0 = n
 14834           *  n - N = N
 14835           *  n - I = -I
 14836           *  0 - n = -n
 14837           *  0 - 0 = 0
 14838           *  0 - N = N
 14839           *  0 - I = -I
 14840           *  N - n = N
 14841           *  N - 0 = N
 14842           *  N - N = N
 14843           *  N - I = N
 14844           *  I - n = I
 14845           *  I - 0 = I
 14846           *  I - N = N
 14847           *  I - I = N
 14848           *
 14849           * Return a new BigNumber whose value is the value of this BigNumber minus the value of
 14850           * BigNumber(y, b).
 14851           */
 14852          P.minus = P.sub = function ( y, b ) {
 14853              var i, j, t, xLTy,
 14854                  x = this,
 14855                  a = x.s;
 14856  
 14857              id = 10;
 14858              y = new BigNumber( y, b );
 14859              b = y.s;
 14860  
 14861              // Either NaN?
 14862              if ( !a || !b ) return new BigNumber(NaN);
 14863  
 14864              // Signs differ?
 14865              if ( a != b ) {
 14866                  y.s = -b;
 14867                  return x.plus(y);
 14868              }
 14869  
 14870              var xe = x.e / LOG_BASE,
 14871                  ye = y.e / LOG_BASE,
 14872                  xc = x.c,
 14873                  yc = y.c;
 14874  
 14875              if ( !xe || !ye ) {
 14876  
 14877                  // Either Infinity?
 14878                  if ( !xc || !yc ) return xc ? ( y.s = -b, y ) : new BigNumber( yc ? x : NaN );
 14879  
 14880                  // Either zero?
 14881                  if ( !xc[0] || !yc[0] ) {
 14882  
 14883                      // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
 14884                      return yc[0] ? ( y.s = -b, y ) : new BigNumber( xc[0] ? x :
 14885  
 14886                        // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
 14887                        ROUNDING_MODE == 3 ? -0 : 0 );
 14888                  }
 14889              }
 14890  
 14891              xe = bitFloor(xe);
 14892              ye = bitFloor(ye);
 14893              xc = xc.slice();
 14894  
 14895              // Determine which is the bigger number.
 14896              if ( a = xe - ye ) {
 14897  
 14898                  if ( xLTy = a < 0 ) {
 14899                      a = -a;
 14900                      t = xc;
 14901                  } else {
 14902                      ye = xe;
 14903                      t = yc;
 14904                  }
 14905  
 14906                  t.reverse();
 14907  
 14908                  // Prepend zeros to equalise exponents.
 14909                  for ( b = a; b--; t.push(0) );
 14910                  t.reverse();
 14911              } else {
 14912  
 14913                  // Exponents equal. Check digit by digit.
 14914                  j = ( xLTy = ( a = xc.length ) < ( b = yc.length ) ) ? a : b;
 14915  
 14916                  for ( a = b = 0; b < j; b++ ) {
 14917  
 14918                      if ( xc[b] != yc[b] ) {
 14919                          xLTy = xc[b] < yc[b];
 14920                          break;
 14921                      }
 14922                  }
 14923              }
 14924  
 14925              // x < y? Point xc to the array of the bigger number.
 14926              if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
 14927  
 14928              b = ( j = yc.length ) - ( i = xc.length );
 14929  
 14930              // Append zeros to xc if shorter.
 14931              // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
 14932              if ( b > 0 ) for ( ; b--; xc[i++] = 0 );
 14933              b = BASE - 1;
 14934  
 14935              // Subtract yc from xc.
 14936              for ( ; j > a; ) {
 14937  
 14938                  if ( xc[--j] < yc[j] ) {
 14939                      for ( i = j; i && !xc[--i]; xc[i] = b );
 14940                      --xc[i];
 14941                      xc[j] += BASE;
 14942                  }
 14943  
 14944                  xc[j] -= yc[j];
 14945              }
 14946  
 14947              // Remove leading zeros and adjust exponent accordingly.
 14948              for ( ; xc[0] == 0; xc.shift(), --ye );
 14949  
 14950              // Zero?
 14951              if ( !xc[0] ) {
 14952  
 14953                  // Following IEEE 754 (2008) 6.3,
 14954                  // n - n = +0  but  n - n = -0  when rounding towards -Infinity.
 14955                  y.s = ROUNDING_MODE == 3 ? -1 : 1;
 14956                  y.c = [ y.e = 0 ];
 14957                  return y;
 14958              }
 14959  
 14960              // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
 14961              // for finite x and y.
 14962              return normalise( y, xc, ye );
 14963          };
 14964  
 14965  
 14966          /*
 14967           *   n % 0 =  N
 14968           *   n % N =  N
 14969           *   n % I =  n
 14970           *   0 % n =  0
 14971           *  -0 % n = -0
 14972           *   0 % 0 =  N
 14973           *   0 % N =  N
 14974           *   0 % I =  0
 14975           *   N % n =  N
 14976           *   N % 0 =  N
 14977           *   N % N =  N
 14978           *   N % I =  N
 14979           *   I % n =  N
 14980           *   I % 0 =  N
 14981           *   I % N =  N
 14982           *   I % I =  N
 14983           *
 14984           * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
 14985           * BigNumber(y, b). The result depends on the value of MODULO_MODE.
 14986           */
 14987          P.modulo = P.mod = function ( y, b ) {
 14988              var q, s,
 14989                  x = this;
 14990  
 14991              id = 11;
 14992              y = new BigNumber( y, b );
 14993  
 14994              // Return NaN if x is Infinity or NaN, or y is NaN or zero.
 14995              if ( !x.c || !y.s || y.c && !y.c[0] ) {
 14996                  return new BigNumber(NaN);
 14997  
 14998              // Return x if y is Infinity or x is zero.
 14999              } else if ( !y.c || x.c && !x.c[0] ) {
 15000                  return new BigNumber(x);
 15001              }
 15002  
 15003              if ( MODULO_MODE == 9 ) {
 15004  
 15005                  // Euclidian division: q = sign(y) * floor(x / abs(y))
 15006                  // r = x - qy    where  0 <= r < abs(y)
 15007                  s = y.s;
 15008                  y.s = 1;
 15009                  q = div( x, y, 0, 3 );
 15010                  y.s = s;
 15011                  q.s *= s;
 15012              } else {
 15013                  q = div( x, y, 0, MODULO_MODE );
 15014              }
 15015  
 15016              return x.minus( q.times(y) );
 15017          };
 15018  
 15019  
 15020          /*
 15021           * Return a new BigNumber whose value is the value of this BigNumber negated,
 15022           * i.e. multiplied by -1.
 15023           */
 15024          P.negated = P.neg = function () {
 15025              var x = new BigNumber(this);
 15026              x.s = -x.s || null;
 15027              return x;
 15028          };
 15029  
 15030  
 15031          /*
 15032           *  n + 0 = n
 15033           *  n + N = N
 15034           *  n + I = I
 15035           *  0 + n = n
 15036           *  0 + 0 = 0
 15037           *  0 + N = N
 15038           *  0 + I = I
 15039           *  N + n = N
 15040           *  N + 0 = N
 15041           *  N + N = N
 15042           *  N + I = N
 15043           *  I + n = I
 15044           *  I + 0 = I
 15045           *  I + N = N
 15046           *  I + I = I
 15047           *
 15048           * Return a new BigNumber whose value is the value of this BigNumber plus the value of
 15049           * BigNumber(y, b).
 15050           */
 15051          P.plus = P.add = function ( y, b ) {
 15052              var t,
 15053                  x = this,
 15054                  a = x.s;
 15055  
 15056              id = 12;
 15057              y = new BigNumber( y, b );
 15058              b = y.s;
 15059  
 15060              // Either NaN?
 15061              if ( !a || !b ) return new BigNumber(NaN);
 15062  
 15063              // Signs differ?
 15064               if ( a != b ) {
 15065                  y.s = -b;
 15066                  return x.minus(y);
 15067              }
 15068  
 15069              var xe = x.e / LOG_BASE,
 15070                  ye = y.e / LOG_BASE,
 15071                  xc = x.c,
 15072                  yc = y.c;
 15073  
 15074              if ( !xe || !ye ) {
 15075  
 15076                  // Return ±Infinity if either ±Infinity.
 15077                  if ( !xc || !yc ) return new BigNumber( a / 0 );
 15078  
 15079                  // Either zero?
 15080                  // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
 15081                  if ( !xc[0] || !yc[0] ) return yc[0] ? y : new BigNumber( xc[0] ? x : a * 0 );
 15082              }
 15083  
 15084              xe = bitFloor(xe);
 15085              ye = bitFloor(ye);
 15086              xc = xc.slice();
 15087  
 15088              // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
 15089              if ( a = xe - ye ) {
 15090                  if ( a > 0 ) {
 15091                      ye = xe;
 15092                      t = yc;
 15093                  } else {
 15094                      a = -a;
 15095                      t = xc;
 15096                  }
 15097  
 15098                  t.reverse();
 15099                  for ( ; a--; t.push(0) );
 15100                  t.reverse();
 15101              }
 15102  
 15103              a = xc.length;
 15104              b = yc.length;
 15105  
 15106              // Point xc to the longer array, and b to the shorter length.
 15107              if ( a - b < 0 ) t = yc, yc = xc, xc = t, b = a;
 15108  
 15109              // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
 15110              for ( a = 0; b; ) {
 15111                  a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;
 15112                  xc[b] %= BASE;
 15113              }
 15114  
 15115              if (a) {
 15116                  xc.unshift(a);
 15117                  ++ye;
 15118              }
 15119  
 15120              // No need to check for zero, as +x + +y != 0 && -x + -y != 0
 15121              // ye = MAX_EXP + 1 possible
 15122              return normalise( y, xc, ye );
 15123          };
 15124  
 15125  
 15126          /*
 15127           * Return the number of significant digits of the value of this BigNumber.
 15128           *
 15129           * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
 15130           */
 15131          P.precision = P.sd = function (z) {
 15132              var n, v,
 15133                  x = this,
 15134                  c = x.c;
 15135  
 15136              // 'precision() argument not a boolean or binary digit: {z}'
 15137              if ( z != null && z !== !!z && z !== 1 && z !== 0 ) {
 15138                  if (ERRORS) raise( 13, 'argument' + notBool, z );
 15139                  if ( z != !!z ) z = null;
 15140              }
 15141  
 15142              if ( !c ) return null;
 15143              v = c.length - 1;
 15144              n = v * LOG_BASE + 1;
 15145  
 15146              if ( v = c[v] ) {
 15147  
 15148                  // Subtract the number of trailing zeros of the last element.
 15149                  for ( ; v % 10 == 0; v /= 10, n-- );
 15150  
 15151                  // Add the number of digits of the first element.
 15152                  for ( v = c[0]; v >= 10; v /= 10, n++ );
 15153              }
 15154  
 15155              if ( z && x.e + 1 > n ) n = x.e + 1;
 15156  
 15157              return n;
 15158          };
 15159  
 15160  
 15161          /*
 15162           * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
 15163           * dp decimal places using rounding mode rm, or to 0 and ROUNDING_MODE respectively if
 15164           * omitted.
 15165           *
 15166           * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
 15167           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15168           *
 15169           * 'round() decimal places out of range: {dp}'
 15170           * 'round() decimal places not an integer: {dp}'
 15171           * 'round() rounding mode not an integer: {rm}'
 15172           * 'round() rounding mode out of range: {rm}'
 15173           */
 15174          P.round = function ( dp, rm ) {
 15175              var n = new BigNumber(this);
 15176  
 15177              if ( dp == null || isValidInt( dp, 0, MAX, 15 ) ) {
 15178                  round( n, ~~dp + this.e + 1, rm == null ||
 15179                    !isValidInt( rm, 0, 8, 15, roundingMode ) ? ROUNDING_MODE : rm | 0 );
 15180              }
 15181  
 15182              return n;
 15183          };
 15184  
 15185  
 15186          /*
 15187           * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
 15188           * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
 15189           *
 15190           * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
 15191           *
 15192           * If k is out of range and ERRORS is false, the result will be ±0 if k < 0, or ±Infinity
 15193           * otherwise.
 15194           *
 15195           * 'shift() argument not an integer: {k}'
 15196           * 'shift() argument out of range: {k}'
 15197           */
 15198          P.shift = function (k) {
 15199              var n = this;
 15200              return isValidInt( k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 16, 'argument' )
 15201  
 15202                // k < 1e+21, or truncate(k) will produce exponential notation.
 15203                ? n.times( '1e' + truncate(k) )
 15204                : new BigNumber( n.c && n.c[0] && ( k < -MAX_SAFE_INTEGER || k > MAX_SAFE_INTEGER )
 15205                  ? n.s * ( k < 0 ? 0 : 1 / 0 )
 15206                  : n );
 15207          };
 15208  
 15209  
 15210          /*
 15211           *  sqrt(-n) =  N
 15212           *  sqrt( N) =  N
 15213           *  sqrt(-I) =  N
 15214           *  sqrt( I) =  I
 15215           *  sqrt( 0) =  0
 15216           *  sqrt(-0) = -0
 15217           *
 15218           * Return a new BigNumber whose value is the square root of the value of this BigNumber,
 15219           * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
 15220           */
 15221          P.squareRoot = P.sqrt = function () {
 15222              var m, n, r, rep, t,
 15223                  x = this,
 15224                  c = x.c,
 15225                  s = x.s,
 15226                  e = x.e,
 15227                  dp = DECIMAL_PLACES + 4,
 15228                  half = new BigNumber('0.5');
 15229  
 15230              // Negative/NaN/Infinity/zero?
 15231              if ( s !== 1 || !c || !c[0] ) {
 15232                  return new BigNumber( !s || s < 0 && ( !c || c[0] ) ? NaN : c ? x : 1 / 0 );
 15233              }
 15234  
 15235              // Initial estimate.
 15236              s = Math.sqrt( +x );
 15237  
 15238              // Math.sqrt underflow/overflow?
 15239              // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
 15240              if ( s == 0 || s == 1 / 0 ) {
 15241                  n = coeffToString(c);
 15242                  if ( ( n.length + e ) % 2 == 0 ) n += '0';
 15243                  s = Math.sqrt(n);
 15244                  e = bitFloor( ( e + 1 ) / 2 ) - ( e < 0 || e % 2 );
 15245  
 15246                  if ( s == 1 / 0 ) {
 15247                      n = '1e' + e;
 15248                  } else {
 15249                      n = s.toExponential();
 15250                      n = n.slice( 0, n.indexOf('e') + 1 ) + e;
 15251                  }
 15252  
 15253                  r = new BigNumber(n);
 15254              } else {
 15255                  r = new BigNumber( s + '' );
 15256              }
 15257  
 15258              // Check for zero.
 15259              // r could be zero if MIN_EXP is changed after the this value was created.
 15260              // This would cause a division by zero (x/t) and hence Infinity below, which would cause
 15261              // coeffToString to throw.
 15262              if ( r.c[0] ) {
 15263                  e = r.e;
 15264                  s = e + dp;
 15265                  if ( s < 3 ) s = 0;
 15266  
 15267                  // Newton-Raphson iteration.
 15268                  for ( ; ; ) {
 15269                      t = r;
 15270                      r = half.times( t.plus( div( x, t, dp, 1 ) ) );
 15271  
 15272                      if ( coeffToString( t.c   ).slice( 0, s ) === ( n =
 15273                           coeffToString( r.c ) ).slice( 0, s ) ) {
 15274  
 15275                          // The exponent of r may here be one less than the final result exponent,
 15276                          // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
 15277                          // are indexed correctly.
 15278                          if ( r.e < e ) --s;
 15279                          n = n.slice( s - 3, s + 1 );
 15280  
 15281                          // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
 15282                          // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
 15283                          // iteration.
 15284                          if ( n == '9999' || !rep && n == '4999' ) {
 15285  
 15286                              // On the first iteration only, check to see if rounding up gives the
 15287                              // exact result as the nines may infinitely repeat.
 15288                              if ( !rep ) {
 15289                                  round( t, t.e + DECIMAL_PLACES + 2, 0 );
 15290  
 15291                                  if ( t.times(t).eq(x) ) {
 15292                                      r = t;
 15293                                      break;
 15294                                  }
 15295                              }
 15296  
 15297                              dp += 4;
 15298                              s += 4;
 15299                              rep = 1;
 15300                          } else {
 15301  
 15302                              // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
 15303                              // result. If not, then there are further digits and m will be truthy.
 15304                              if ( !+n || !+n.slice(1) && n.charAt(0) == '5' ) {
 15305  
 15306                                  // Truncate to the first rounding digit.
 15307                                  round( r, r.e + DECIMAL_PLACES + 2, 1 );
 15308                                  m = !r.times(r).eq(x);
 15309                              }
 15310  
 15311                              break;
 15312                          }
 15313                      }
 15314                  }
 15315              }
 15316  
 15317              return round( r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m );
 15318          };
 15319  
 15320  
 15321          /*
 15322           *  n * 0 = 0
 15323           *  n * N = N
 15324           *  n * I = I
 15325           *  0 * n = 0
 15326           *  0 * 0 = 0
 15327           *  0 * N = N
 15328           *  0 * I = N
 15329           *  N * n = N
 15330           *  N * 0 = N
 15331           *  N * N = N
 15332           *  N * I = N
 15333           *  I * n = I
 15334           *  I * 0 = N
 15335           *  I * N = N
 15336           *  I * I = I
 15337           *
 15338           * Return a new BigNumber whose value is the value of this BigNumber times the value of
 15339           * BigNumber(y, b).
 15340           */
 15341          P.times = P.mul = function ( y, b ) {
 15342              var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
 15343                  base, sqrtBase,
 15344                  x = this,
 15345                  xc = x.c,
 15346                  yc = ( id = 17, y = new BigNumber( y, b ) ).c;
 15347  
 15348              // Either NaN, ±Infinity or ±0?
 15349              if ( !xc || !yc || !xc[0] || !yc[0] ) {
 15350  
 15351                  // Return NaN if either is NaN, or one is 0 and the other is Infinity.
 15352                  if ( !x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc ) {
 15353                      y.c = y.e = y.s = null;
 15354                  } else {
 15355                      y.s *= x.s;
 15356  
 15357                      // Return ±Infinity if either is ±Infinity.
 15358                      if ( !xc || !yc ) {
 15359                          y.c = y.e = null;
 15360  
 15361                      // Return ±0 if either is ±0.
 15362                      } else {
 15363                          y.c = [0];
 15364                          y.e = 0;
 15365                      }
 15366                  }
 15367  
 15368                  return y;
 15369              }
 15370  
 15371              e = bitFloor( x.e / LOG_BASE ) + bitFloor( y.e / LOG_BASE );
 15372              y.s *= x.s;
 15373              xcL = xc.length;
 15374              ycL = yc.length;
 15375  
 15376              // Ensure xc points to longer array and xcL to its length.
 15377              if ( xcL < ycL ) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
 15378  
 15379              // Initialise the result array with zeros.
 15380              for ( i = xcL + ycL, zc = []; i--; zc.push(0) );
 15381  
 15382              base = BASE;
 15383              sqrtBase = SQRT_BASE;
 15384  
 15385              for ( i = ycL; --i >= 0; ) {
 15386                  c = 0;
 15387                  ylo = yc[i] % sqrtBase;
 15388                  yhi = yc[i] / sqrtBase | 0;
 15389  
 15390                  for ( k = xcL, j = i + k; j > i; ) {
 15391                      xlo = xc[--k] % sqrtBase;
 15392                      xhi = xc[k] / sqrtBase | 0;
 15393                      m = yhi * xlo + xhi * ylo;
 15394                      xlo = ylo * xlo + ( ( m % sqrtBase ) * sqrtBase ) + zc[j] + c;
 15395                      c = ( xlo / base | 0 ) + ( m / sqrtBase | 0 ) + yhi * xhi;
 15396                      zc[j--] = xlo % base;
 15397                  }
 15398  
 15399                  zc[j] = c;
 15400              }
 15401  
 15402              if (c) {
 15403                  ++e;
 15404              } else {
 15405                  zc.shift();
 15406              }
 15407  
 15408              return normalise( y, zc, e );
 15409          };
 15410  
 15411  
 15412          /*
 15413           * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
 15414           * sd significant digits using rounding mode rm, or ROUNDING_MODE if rm is omitted.
 15415           *
 15416           * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
 15417           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15418           *
 15419           * 'toDigits() precision out of range: {sd}'
 15420           * 'toDigits() precision not an integer: {sd}'
 15421           * 'toDigits() rounding mode not an integer: {rm}'
 15422           * 'toDigits() rounding mode out of range: {rm}'
 15423           */
 15424          P.toDigits = function ( sd, rm ) {
 15425              var n = new BigNumber(this);
 15426              sd = sd == null || !isValidInt( sd, 1, MAX, 18, 'precision' ) ? null : sd | 0;
 15427              rm = rm == null || !isValidInt( rm, 0, 8, 18, roundingMode ) ? ROUNDING_MODE : rm | 0;
 15428              return sd ? round( n, sd, rm ) : n;
 15429          };
 15430  
 15431  
 15432          /*
 15433           * Return a string representing the value of this BigNumber in exponential notation and
 15434           * rounded using ROUNDING_MODE to dp fixed decimal places.
 15435           *
 15436           * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
 15437           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15438           *
 15439           * 'toExponential() decimal places not an integer: {dp}'
 15440           * 'toExponential() decimal places out of range: {dp}'
 15441           * 'toExponential() rounding mode not an integer: {rm}'
 15442           * 'toExponential() rounding mode out of range: {rm}'
 15443           */
 15444          P.toExponential = function ( dp, rm ) {
 15445              return format( this,
 15446                dp != null && isValidInt( dp, 0, MAX, 19 ) ? ~~dp + 1 : null, rm, 19 );
 15447          };
 15448  
 15449  
 15450          /*
 15451           * Return a string representing the value of this BigNumber in fixed-point notation rounding
 15452           * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
 15453           *
 15454           * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
 15455           * but e.g. (-0.00001).toFixed(0) is '-0'.
 15456           *
 15457           * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
 15458           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15459           *
 15460           * 'toFixed() decimal places not an integer: {dp}'
 15461           * 'toFixed() decimal places out of range: {dp}'
 15462           * 'toFixed() rounding mode not an integer: {rm}'
 15463           * 'toFixed() rounding mode out of range: {rm}'
 15464           */
 15465          P.toFixed = function ( dp, rm ) {
 15466              return format( this, dp != null && isValidInt( dp, 0, MAX, 20 )
 15467                ? ~~dp + this.e + 1 : null, rm, 20 );
 15468          };
 15469  
 15470  
 15471          /*
 15472           * Return a string representing the value of this BigNumber in fixed-point notation rounded
 15473           * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
 15474           * of the FORMAT object (see BigNumber.config).
 15475           *
 15476           * FORMAT = {
 15477           *      decimalSeparator : '.',
 15478           *      groupSeparator : ',',
 15479           *      groupSize : 3,
 15480           *      secondaryGroupSize : 0,
 15481           *      fractionGroupSeparator : '\xA0',    // non-breaking space
 15482           *      fractionGroupSize : 0
 15483           * };
 15484           *
 15485           * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
 15486           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15487           *
 15488           * 'toFormat() decimal places not an integer: {dp}'
 15489           * 'toFormat() decimal places out of range: {dp}'
 15490           * 'toFormat() rounding mode not an integer: {rm}'
 15491           * 'toFormat() rounding mode out of range: {rm}'
 15492           */
 15493          P.toFormat = function ( dp, rm ) {
 15494              var str = format( this, dp != null && isValidInt( dp, 0, MAX, 21 )
 15495                ? ~~dp + this.e + 1 : null, rm, 21 );
 15496  
 15497              if ( this.c ) {
 15498                  var i,
 15499                      arr = str.split('.'),
 15500                      g1 = +FORMAT.groupSize,
 15501                      g2 = +FORMAT.secondaryGroupSize,
 15502                      groupSeparator = FORMAT.groupSeparator,
 15503                      intPart = arr[0],
 15504                      fractionPart = arr[1],
 15505                      isNeg = this.s < 0,
 15506                      intDigits = isNeg ? intPart.slice(1) : intPart,
 15507                      len = intDigits.length;
 15508  
 15509                  if (g2) i = g1, g1 = g2, g2 = i, len -= i;
 15510  
 15511                  if ( g1 > 0 && len > 0 ) {
 15512                      i = len % g1 || g1;
 15513                      intPart = intDigits.substr( 0, i );
 15514  
 15515                      for ( ; i < len; i += g1 ) {
 15516                          intPart += groupSeparator + intDigits.substr( i, g1 );
 15517                      }
 15518  
 15519                      if ( g2 > 0 ) intPart += groupSeparator + intDigits.slice(i);
 15520                      if (isNeg) intPart = '-' + intPart;
 15521                  }
 15522  
 15523                  str = fractionPart
 15524                    ? intPart + FORMAT.decimalSeparator + ( ( g2 = +FORMAT.fractionGroupSize )
 15525                      ? fractionPart.replace( new RegExp( '\\d{' + g2 + '}\\B', 'g' ),
 15526                        '$&' + FORMAT.fractionGroupSeparator )
 15527                      : fractionPart )
 15528                    : intPart;
 15529              }
 15530  
 15531              return str;
 15532          };
 15533  
 15534  
 15535          /*
 15536           * Return a string array representing the value of this BigNumber as a simple fraction with
 15537           * an integer numerator and an integer denominator. The denominator will be a positive
 15538           * non-zero value less than or equal to the specified maximum denominator. If a maximum
 15539           * denominator is not specified, the denominator will be the lowest value necessary to
 15540           * represent the number exactly.
 15541           *
 15542           * [md] {number|string|BigNumber} Integer >= 1 and < Infinity. The maximum denominator.
 15543           *
 15544           * 'toFraction() max denominator not an integer: {md}'
 15545           * 'toFraction() max denominator out of range: {md}'
 15546           */
 15547          P.toFraction = function (md) {
 15548              var arr, d0, d2, e, exp, n, n0, q, s,
 15549                  k = ERRORS,
 15550                  x = this,
 15551                  xc = x.c,
 15552                  d = new BigNumber(ONE),
 15553                  n1 = d0 = new BigNumber(ONE),
 15554                  d1 = n0 = new BigNumber(ONE);
 15555  
 15556              if ( md != null ) {
 15557                  ERRORS = false;
 15558                  n = new BigNumber(md);
 15559                  ERRORS = k;
 15560  
 15561                  if ( !( k = n.isInt() ) || n.lt(ONE) ) {
 15562  
 15563                      if (ERRORS) {
 15564                          raise( 22,
 15565                            'max denominator ' + ( k ? 'out of range' : 'not an integer' ), md );
 15566                      }
 15567  
 15568                      // ERRORS is false:
 15569                      // If md is a finite non-integer >= 1, round it to an integer and use it.
 15570                      md = !k && n.c && round( n, n.e + 1, 1 ).gte(ONE) ? n : null;
 15571                  }
 15572              }
 15573  
 15574              if ( !xc ) return x.toString();
 15575              s = coeffToString(xc);
 15576  
 15577              // Determine initial denominator.
 15578              // d is a power of 10 and the minimum max denominator that specifies the value exactly.
 15579              e = d.e = s.length - x.e - 1;
 15580              d.c[0] = POWS_TEN[ ( exp = e % LOG_BASE ) < 0 ? LOG_BASE + exp : exp ];
 15581              md = !md || n.cmp(d) > 0 ? ( e > 0 ? d : n1 ) : n;
 15582  
 15583              exp = MAX_EXP;
 15584              MAX_EXP = 1 / 0;
 15585              n = new BigNumber(s);
 15586  
 15587              // n0 = d1 = 0
 15588              n0.c[0] = 0;
 15589  
 15590              for ( ; ; )  {
 15591                  q = div( n, d, 0, 1 );
 15592                  d2 = d0.plus( q.times(d1) );
 15593                  if ( d2.cmp(md) == 1 ) break;
 15594                  d0 = d1;
 15595                  d1 = d2;
 15596                  n1 = n0.plus( q.times( d2 = n1 ) );
 15597                  n0 = d2;
 15598                  d = n.minus( q.times( d2 = d ) );
 15599                  n = d2;
 15600              }
 15601  
 15602              d2 = div( md.minus(d0), d1, 0, 1 );
 15603              n0 = n0.plus( d2.times(n1) );
 15604              d0 = d0.plus( d2.times(d1) );
 15605              n0.s = n1.s = x.s;
 15606              e *= 2;
 15607  
 15608              // Determine which fraction is closer to x, n0/d0 or n1/d1
 15609              arr = div( n1, d1, e, ROUNDING_MODE ).minus(x).abs().cmp(
 15610                    div( n0, d0, e, ROUNDING_MODE ).minus(x).abs() ) < 1
 15611                      ? [ n1.toString(), d1.toString() ]
 15612                      : [ n0.toString(), d0.toString() ];
 15613  
 15614              MAX_EXP = exp;
 15615              return arr;
 15616          };
 15617  
 15618  
 15619          /*
 15620           * Return the value of this BigNumber converted to a number primitive.
 15621           */
 15622          P.toNumber = function () {
 15623              var x = this;
 15624  
 15625              // Ensure zero has correct sign.
 15626              return +x || ( x.s ? x.s * 0 : NaN );
 15627          };
 15628  
 15629  
 15630          /*
 15631           * Return a BigNumber whose value is the value of this BigNumber raised to the power n.
 15632           * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
 15633           * If POW_PRECISION is not 0, round to POW_PRECISION using ROUNDING_MODE.
 15634           *
 15635           * n {number} Integer, -9007199254740992 to 9007199254740992 inclusive.
 15636           * (Performs 54 loop iterations for n of 9007199254740992.)
 15637           *
 15638           * 'pow() exponent not an integer: {n}'
 15639           * 'pow() exponent out of range: {n}'
 15640           */
 15641          P.toPower = P.pow = function (n) {
 15642              var k, y,
 15643                  i = mathfloor( n < 0 ? -n : +n ),
 15644                  x = this;
 15645  
 15646              // Pass ±Infinity to Math.pow if exponent is out of range.
 15647              if ( !isValidInt( n, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 23, 'exponent' ) &&
 15648                ( !isFinite(n) || i > MAX_SAFE_INTEGER && ( n /= 0 ) ||
 15649                  parseFloat(n) != n && !( n = NaN ) ) ) {
 15650                  return new BigNumber( Math.pow( +x, n ) );
 15651              }
 15652  
 15653              // Truncating each coefficient array to a length of k after each multiplication equates
 15654              // to truncating significant digits to POW_PRECISION + [28, 41], i.e. there will be a
 15655              // minimum of 28 guard digits retained. (Using + 1.5 would give [9, 21] guard digits.)
 15656              k = POW_PRECISION ? mathceil( POW_PRECISION / LOG_BASE + 2 ) : 0;
 15657              y = new BigNumber(ONE);
 15658  
 15659              for ( ; ; ) {
 15660  
 15661                  if ( i % 2 ) {
 15662                      y = y.times(x);
 15663                      if ( !y.c ) break;
 15664                      if ( k && y.c.length > k ) y.c.length = k;
 15665                  }
 15666  
 15667                  i = mathfloor( i / 2 );
 15668                  if ( !i ) break;
 15669  
 15670                  x = x.times(x);
 15671                  if ( k && x.c && x.c.length > k ) x.c.length = k;
 15672              }
 15673  
 15674              if ( n < 0 ) y = ONE.div(y);
 15675              return k ? round( y, POW_PRECISION, ROUNDING_MODE ) : y;
 15676          };
 15677  
 15678  
 15679          /*
 15680           * Return a string representing the value of this BigNumber rounded to sd significant digits
 15681           * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
 15682           * necessary to represent the integer part of the value in fixed-point notation, then use
 15683           * exponential notation.
 15684           *
 15685           * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
 15686           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15687           *
 15688           * 'toPrecision() precision not an integer: {sd}'
 15689           * 'toPrecision() precision out of range: {sd}'
 15690           * 'toPrecision() rounding mode not an integer: {rm}'
 15691           * 'toPrecision() rounding mode out of range: {rm}'
 15692           */
 15693          P.toPrecision = function ( sd, rm ) {
 15694              return format( this, sd != null && isValidInt( sd, 1, MAX, 24, 'precision' )
 15695                ? sd | 0 : null, rm, 24 );
 15696          };
 15697  
 15698  
 15699          /*
 15700           * Return a string representing the value of this BigNumber in base b, or base 10 if b is
 15701           * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
 15702           * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
 15703           * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
 15704           * TO_EXP_NEG, return exponential notation.
 15705           *
 15706           * [b] {number} Integer, 2 to 64 inclusive.
 15707           *
 15708           * 'toString() base not an integer: {b}'
 15709           * 'toString() base out of range: {b}'
 15710           */
 15711          P.toString = function (b) {
 15712              var str,
 15713                  n = this,
 15714                  s = n.s,
 15715                  e = n.e;
 15716  
 15717              // Infinity or NaN?
 15718              if ( e === null ) {
 15719  
 15720                  if (s) {
 15721                      str = 'Infinity';
 15722                      if ( s < 0 ) str = '-' + str;
 15723                  } else {
 15724                      str = 'NaN';
 15725                  }
 15726              } else {
 15727                  str = coeffToString( n.c );
 15728  
 15729                  if ( b == null || !isValidInt( b, 2, 64, 25, 'base' ) ) {
 15730                      str = e <= TO_EXP_NEG || e >= TO_EXP_POS
 15731                        ? toExponential( str, e )
 15732                        : toFixedPoint( str, e );
 15733                  } else {
 15734                      str = convertBase( toFixedPoint( str, e ), b | 0, 10, s );
 15735                  }
 15736  
 15737                  if ( s < 0 && n.c[0] ) str = '-' + str;
 15738              }
 15739  
 15740              return str;
 15741          };
 15742  
 15743  
 15744          /*
 15745           * Return a new BigNumber whose value is the value of this BigNumber truncated to a whole
 15746           * number.
 15747           */
 15748          P.truncated = P.trunc = function () {
 15749              return round( new BigNumber(this), this.e + 1, 1 );
 15750          };
 15751  
 15752  
 15753  
 15754          /*
 15755           * Return as toString, but do not accept a base argument.
 15756           */
 15757          P.valueOf = P.toJSON = function () {
 15758              return this.toString();
 15759          };
 15760  
 15761  
 15762          // Aliases for BigDecimal methods.
 15763          //P.add = P.plus;         // P.add included above
 15764          //P.subtract = P.minus;   // P.sub included above
 15765          //P.multiply = P.times;   // P.mul included above
 15766          //P.divide = P.div;
 15767          //P.remainder = P.mod;
 15768          //P.compareTo = P.cmp;
 15769          //P.negate = P.neg;
 15770  
 15771  
 15772          if ( configObj != null ) BigNumber.config(configObj);
 15773  
 15774          return BigNumber;
 15775      }
 15776  
 15777  
 15778      // PRIVATE HELPER FUNCTIONS
 15779  
 15780  
 15781      function bitFloor(n) {
 15782          var i = n | 0;
 15783          return n > 0 || n === i ? i : i - 1;
 15784      }
 15785  
 15786  
 15787      // Return a coefficient array as a string of base 10 digits.
 15788      function coeffToString(a) {
 15789          var s, z,
 15790              i = 1,
 15791              j = a.length,
 15792              r = a[0] + '';
 15793  
 15794          for ( ; i < j; ) {
 15795              s = a[i++] + '';
 15796              z = LOG_BASE - s.length;
 15797              for ( ; z--; s = '0' + s );
 15798              r += s;
 15799          }
 15800  
 15801          // Determine trailing zeros.
 15802          for ( j = r.length; r.charCodeAt(--j) === 48; );
 15803          return r.slice( 0, j + 1 || 1 );
 15804      }
 15805  
 15806  
 15807      // Compare the value of BigNumbers x and y.
 15808      function compare( x, y ) {
 15809          var a, b,
 15810              xc = x.c,
 15811              yc = y.c,
 15812              i = x.s,
 15813              j = y.s,
 15814              k = x.e,
 15815              l = y.e;
 15816  
 15817          // Either NaN?
 15818          if ( !i || !j ) return null;
 15819  
 15820          a = xc && !xc[0];
 15821          b = yc && !yc[0];
 15822  
 15823          // Either zero?
 15824          if ( a || b ) return a ? b ? 0 : -j : i;
 15825  
 15826          // Signs differ?
 15827          if ( i != j ) return i;
 15828  
 15829          a = i < 0;
 15830          b = k == l;
 15831  
 15832          // Either Infinity?
 15833          if ( !xc || !yc ) return b ? 0 : !xc ^ a ? 1 : -1;
 15834  
 15835          // Compare exponents.
 15836          if ( !b ) return k > l ^ a ? 1 : -1;
 15837  
 15838          j = ( k = xc.length ) < ( l = yc.length ) ? k : l;
 15839  
 15840          // Compare digit by digit.
 15841          for ( i = 0; i < j; i++ ) if ( xc[i] != yc[i] ) return xc[i] > yc[i] ^ a ? 1 : -1;
 15842  
 15843          // Compare lengths.
 15844          return k == l ? 0 : k > l ^ a ? 1 : -1;
 15845      }
 15846  
 15847  
 15848      /*
 15849       * Return true if n is a valid number in range, otherwise false.
 15850       * Use for argument validation when ERRORS is false.
 15851       * Note: parseInt('1e+1') == 1 but parseFloat('1e+1') == 10.
 15852       */
 15853      function intValidatorNoErrors( n, min, max ) {
 15854          return ( n = truncate(n) ) >= min && n <= max;
 15855      }
 15856  
 15857  
 15858      function isArray(obj) {
 15859          return Object.prototype.toString.call(obj) == '[object Array]';
 15860      }
 15861  
 15862  
 15863      /*
 15864       * Convert string of baseIn to an array of numbers of baseOut.
 15865       * Eg. convertBase('255', 10, 16) returns [15, 15].
 15866       * Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
 15867       */
 15868      function toBaseOut( str, baseIn, baseOut ) {
 15869          var j,
 15870              arr = [0],
 15871              arrL,
 15872              i = 0,
 15873              len = str.length;
 15874  
 15875          for ( ; i < len; ) {
 15876              for ( arrL = arr.length; arrL--; arr[arrL] *= baseIn );
 15877              arr[ j = 0 ] += ALPHABET.indexOf( str.charAt( i++ ) );
 15878  
 15879              for ( ; j < arr.length; j++ ) {
 15880  
 15881                  if ( arr[j] > baseOut - 1 ) {
 15882                      if ( arr[j + 1] == null ) arr[j + 1] = 0;
 15883                      arr[j + 1] += arr[j] / baseOut | 0;
 15884                      arr[j] %= baseOut;
 15885                  }
 15886              }
 15887          }
 15888  
 15889          return arr.reverse();
 15890      }
 15891  
 15892  
 15893      function toExponential( str, e ) {
 15894          return ( str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str ) +
 15895            ( e < 0 ? 'e' : 'e+' ) + e;
 15896      }
 15897  
 15898  
 15899      function toFixedPoint( str, e ) {
 15900          var len, z;
 15901  
 15902          // Negative exponent?
 15903          if ( e < 0 ) {
 15904  
 15905              // Prepend zeros.
 15906              for ( z = '0.'; ++e; z += '0' );
 15907              str = z + str;
 15908  
 15909          // Positive exponent
 15910          } else {
 15911              len = str.length;
 15912  
 15913              // Append zeros.
 15914              if ( ++e > len ) {
 15915                  for ( z = '0', e -= len; --e; z += '0' );
 15916                  str += z;
 15917              } else if ( e < len ) {
 15918                  str = str.slice( 0, e ) + '.' + str.slice(e);
 15919              }
 15920          }
 15921  
 15922          return str;
 15923      }
 15924  
 15925  
 15926      function truncate(n) {
 15927          n = parseFloat(n);
 15928          return n < 0 ? mathceil(n) : mathfloor(n);
 15929      }
 15930  
 15931  
 15932      // EXPORT
 15933  
 15934  
 15935      BigNumber = another();
 15936  
 15937      // AMD.
 15938      if ( typeof define == 'function' && define.amd ) {
 15939          define( function () { return BigNumber; } );
 15940  
 15941      // Node and other environments that support module.exports.
 15942      } else if ( typeof module != 'undefined' && module.exports ) {
 15943          module.exports = BigNumber;
 15944          if ( !crypto ) try { crypto = require('crypto'); } catch (e) {}
 15945  
 15946      // Browser.
 15947      } else {
 15948          global.BigNumber = BigNumber;
 15949      }
 15950  })(this);
 15951  
 15952  },{"crypto":49}],"web3":[function(require,module,exports){
 15953  var Web3 = require('./lib/web3');
 15954  
 15955  // dont override global variable
 15956  if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
 15957      window.Web3 = Web3;
 15958  }
 15959  
 15960  module.exports = Web3;
 15961  
 15962  },{"./lib/web3":22}]},{},["web3"])
 15963  //# sourceMappingURL=web3.js.map
 15964  `