github.com/neatio-net/neatio@v1.7.3-0.20231114194659-f4d7a2226baa/internal/jsre/deps/web3.js (about)

     1  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){
     2      module.exports=[
     3        {
     4          "constant": true,
     5          "inputs": [
     6            {
     7              "name": "_owner",
     8              "type": "address"
     9            }
    10          ],
    11          "name": "name",
    12          "outputs": [
    13            {
    14              "name": "o_name",
    15              "type": "bytes32"
    16            }
    17          ],
    18          "type": "function"
    19        },
    20        {
    21          "constant": true,
    22          "inputs": [
    23            {
    24              "name": "_name",
    25              "type": "bytes32"
    26            }
    27          ],
    28          "name": "owner",
    29          "outputs": [
    30            {
    31              "name": "",
    32              "type": "address"
    33            }
    34          ],
    35          "type": "function"
    36        },
    37        {
    38          "constant": true,
    39          "inputs": [
    40            {
    41              "name": "_name",
    42              "type": "bytes32"
    43            }
    44          ],
    45          "name": "content",
    46          "outputs": [
    47            {
    48              "name": "",
    49              "type": "bytes32"
    50            }
    51          ],
    52          "type": "function"
    53        },
    54        {
    55          "constant": true,
    56          "inputs": [
    57            {
    58              "name": "_name",
    59              "type": "bytes32"
    60            }
    61          ],
    62          "name": "addr",
    63          "outputs": [
    64            {
    65              "name": "",
    66              "type": "address"
    67            }
    68          ],
    69          "type": "function"
    70        },
    71        {
    72          "constant": false,
    73          "inputs": [
    74            {
    75              "name": "_name",
    76              "type": "bytes32"
    77            }
    78          ],
    79          "name": "reserve",
    80          "outputs": [],
    81          "type": "function"
    82        },
    83        {
    84          "constant": true,
    85          "inputs": [
    86            {
    87              "name": "_name",
    88              "type": "bytes32"
    89            }
    90          ],
    91          "name": "subRegistrar",
    92          "outputs": [
    93            {
    94              "name": "",
    95              "type": "address"
    96            }
    97          ],
    98          "type": "function"
    99        },
   100        {
   101          "constant": false,
   102          "inputs": [
   103            {
   104              "name": "_name",
   105              "type": "bytes32"
   106            },
   107            {
   108              "name": "_newOwner",
   109              "type": "address"
   110            }
   111          ],
   112          "name": "transfer",
   113          "outputs": [],
   114          "type": "function"
   115        },
   116        {
   117          "constant": false,
   118          "inputs": [
   119            {
   120              "name": "_name",
   121              "type": "bytes32"
   122            },
   123            {
   124              "name": "_registrar",
   125              "type": "address"
   126            }
   127          ],
   128          "name": "setSubRegistrar",
   129          "outputs": [],
   130          "type": "function"
   131        },
   132        {
   133          "constant": false,
   134          "inputs": [],
   135          "name": "Registrar",
   136          "outputs": [],
   137          "type": "function"
   138        },
   139        {
   140          "constant": false,
   141          "inputs": [
   142            {
   143              "name": "_name",
   144              "type": "bytes32"
   145            },
   146            {
   147              "name": "_a",
   148              "type": "address"
   149            },
   150            {
   151              "name": "_primary",
   152              "type": "bool"
   153            }
   154          ],
   155          "name": "setAddress",
   156          "outputs": [],
   157          "type": "function"
   158        },
   159        {
   160          "constant": false,
   161          "inputs": [
   162            {
   163              "name": "_name",
   164              "type": "bytes32"
   165            },
   166            {
   167              "name": "_content",
   168              "type": "bytes32"
   169            }
   170          ],
   171          "name": "setContent",
   172          "outputs": [],
   173          "type": "function"
   174        },
   175        {
   176          "constant": false,
   177          "inputs": [
   178            {
   179              "name": "_name",
   180              "type": "bytes32"
   181            }
   182          ],
   183          "name": "disown",
   184          "outputs": [],
   185          "type": "function"
   186        },
   187        {
   188          "anonymous": false,
   189          "inputs": [
   190            {
   191              "indexed": true,
   192              "name": "_name",
   193              "type": "bytes32"
   194            },
   195            {
   196              "indexed": false,
   197              "name": "_winner",
   198              "type": "address"
   199            }
   200          ],
   201          "name": "AuctionEnded",
   202          "type": "event"
   203        },
   204        {
   205          "anonymous": false,
   206          "inputs": [
   207            {
   208              "indexed": true,
   209              "name": "_name",
   210              "type": "bytes32"
   211            },
   212            {
   213              "indexed": false,
   214              "name": "_bidder",
   215              "type": "address"
   216            },
   217            {
   218              "indexed": false,
   219              "name": "_value",
   220              "type": "uint256"
   221            }
   222          ],
   223          "name": "NewBid",
   224          "type": "event"
   225        },
   226        {
   227          "anonymous": false,
   228          "inputs": [
   229            {
   230              "indexed": true,
   231              "name": "name",
   232              "type": "bytes32"
   233            }
   234          ],
   235          "name": "Changed",
   236          "type": "event"
   237        },
   238        {
   239          "anonymous": false,
   240          "inputs": [
   241            {
   242              "indexed": true,
   243              "name": "name",
   244              "type": "bytes32"
   245            },
   246            {
   247              "indexed": true,
   248              "name": "addr",
   249              "type": "address"
   250            }
   251          ],
   252          "name": "PrimaryChanged",
   253          "type": "event"
   254        }
   255      ]
   256      
   257      },{}],2:[function(require,module,exports){
   258      module.exports=[
   259        {
   260          "constant": true,
   261          "inputs": [
   262            {
   263              "name": "_name",
   264              "type": "bytes32"
   265            }
   266          ],
   267          "name": "owner",
   268          "outputs": [
   269            {
   270              "name": "",
   271              "type": "address"
   272            }
   273          ],
   274          "type": "function"
   275        },
   276        {
   277          "constant": false,
   278          "inputs": [
   279            {
   280              "name": "_name",
   281              "type": "bytes32"
   282            },
   283            {
   284              "name": "_refund",
   285              "type": "address"
   286            }
   287          ],
   288          "name": "disown",
   289          "outputs": [],
   290          "type": "function"
   291        },
   292        {
   293          "constant": true,
   294          "inputs": [
   295            {
   296              "name": "_name",
   297              "type": "bytes32"
   298            }
   299          ],
   300          "name": "addr",
   301          "outputs": [
   302            {
   303              "name": "",
   304              "type": "address"
   305            }
   306          ],
   307          "type": "function"
   308        },
   309        {
   310          "constant": false,
   311          "inputs": [
   312            {
   313              "name": "_name",
   314              "type": "bytes32"
   315            }
   316          ],
   317          "name": "reserve",
   318          "outputs": [],
   319          "type": "function"
   320        },
   321        {
   322          "constant": false,
   323          "inputs": [
   324            {
   325              "name": "_name",
   326              "type": "bytes32"
   327            },
   328            {
   329              "name": "_newOwner",
   330              "type": "address"
   331            }
   332          ],
   333          "name": "transfer",
   334          "outputs": [],
   335          "type": "function"
   336        },
   337        {
   338          "constant": false,
   339          "inputs": [
   340            {
   341              "name": "_name",
   342              "type": "bytes32"
   343            },
   344            {
   345              "name": "_a",
   346              "type": "address"
   347            }
   348          ],
   349          "name": "setAddr",
   350          "outputs": [],
   351          "type": "function"
   352        },
   353        {
   354          "anonymous": false,
   355          "inputs": [
   356            {
   357              "indexed": true,
   358              "name": "name",
   359              "type": "bytes32"
   360            }
   361          ],
   362          "name": "Changed",
   363          "type": "event"
   364        }
   365      ]
   366      
   367      },{}],3:[function(require,module,exports){
   368      module.exports=[
   369        {
   370          "constant": false,
   371          "inputs": [
   372            {
   373              "name": "from",
   374              "type": "bytes32"
   375            },
   376            {
   377              "name": "to",
   378              "type": "address"
   379            },
   380            {
   381              "name": "value",
   382              "type": "uint256"
   383            }
   384          ],
   385          "name": "transfer",
   386          "outputs": [],
   387          "type": "function"
   388        },
   389        {
   390          "constant": false,
   391          "inputs": [
   392            {
   393              "name": "from",
   394              "type": "bytes32"
   395            },
   396            {
   397              "name": "to",
   398              "type": "address"
   399            },
   400            {
   401              "name": "indirectId",
   402              "type": "bytes32"
   403            },
   404            {
   405              "name": "value",
   406              "type": "uint256"
   407            }
   408          ],
   409          "name": "icapTransfer",
   410          "outputs": [],
   411          "type": "function"
   412        },
   413        {
   414          "constant": false,
   415          "inputs": [
   416            {
   417              "name": "to",
   418              "type": "bytes32"
   419            }
   420          ],
   421          "name": "deposit",
   422          "outputs": [],
   423          "payable": true,
   424          "type": "function"
   425        },
   426        {
   427          "anonymous": false,
   428          "inputs": [
   429            {
   430              "indexed": true,
   431              "name": "from",
   432              "type": "address"
   433            },
   434            {
   435              "indexed": false,
   436              "name": "value",
   437              "type": "uint256"
   438            }
   439          ],
   440          "name": "AnonymousDeposit",
   441          "type": "event"
   442        },
   443        {
   444          "anonymous": false,
   445          "inputs": [
   446            {
   447              "indexed": true,
   448              "name": "from",
   449              "type": "address"
   450            },
   451            {
   452              "indexed": true,
   453              "name": "to",
   454              "type": "bytes32"
   455            },
   456            {
   457              "indexed": false,
   458              "name": "value",
   459              "type": "uint256"
   460            }
   461          ],
   462          "name": "Deposit",
   463          "type": "event"
   464        },
   465        {
   466          "anonymous": false,
   467          "inputs": [
   468            {
   469              "indexed": true,
   470              "name": "from",
   471              "type": "bytes32"
   472            },
   473            {
   474              "indexed": true,
   475              "name": "to",
   476              "type": "address"
   477            },
   478            {
   479              "indexed": false,
   480              "name": "value",
   481              "type": "uint256"
   482            }
   483          ],
   484          "name": "Transfer",
   485          "type": "event"
   486        },
   487        {
   488          "anonymous": false,
   489          "inputs": [
   490            {
   491              "indexed": true,
   492              "name": "from",
   493              "type": "bytes32"
   494            },
   495            {
   496              "indexed": true,
   497              "name": "to",
   498              "type": "address"
   499            },
   500            {
   501              "indexed": false,
   502              "name": "indirectId",
   503              "type": "bytes32"
   504            },
   505            {
   506              "indexed": false,
   507              "name": "value",
   508              "type": "uint256"
   509            }
   510          ],
   511          "name": "IcapTransfer",
   512          "type": "event"
   513        }
   514      ]
   515      
   516      },{}],4:[function(require,module,exports){
   517      var f = require('./formatters');
   518      var SolidityType = require('./type');
   519      
   520      /**
   521       * SolidityTypeAddress is a prootype that represents address type
   522       * It matches:
   523       * address
   524       * address[]
   525       * address[4]
   526       * address[][]
   527       * address[3][]
   528       * address[][6][], ...
   529       */
   530      var SolidityTypeAddress = function () {
   531          this._inputFormatter = f.formatInputInt;
   532          this._outputFormatter = f.formatOutputAddress;
   533      };
   534      
   535      SolidityTypeAddress.prototype = new SolidityType({});
   536      SolidityTypeAddress.prototype.constructor = SolidityTypeAddress;
   537      
   538      SolidityTypeAddress.prototype.isType = function (name) {
   539          return !!name.match(/address(\[([0-9]*)\])?/);
   540      };
   541      
   542      module.exports = SolidityTypeAddress;
   543      
   544      },{"./formatters":9,"./type":14}],5:[function(require,module,exports){
   545      var f = require('./formatters');
   546      var SolidityType = require('./type');
   547      
   548      /**
   549       * SolidityTypeBool is a prootype that represents bool type
   550       * It matches:
   551       * bool
   552       * bool[]
   553       * bool[4]
   554       * bool[][]
   555       * bool[3][]
   556       * bool[][6][], ...
   557       */
   558      var SolidityTypeBool = function () {
   559          this._inputFormatter = f.formatInputBool;
   560          this._outputFormatter = f.formatOutputBool;
   561      };
   562      
   563      SolidityTypeBool.prototype = new SolidityType({});
   564      SolidityTypeBool.prototype.constructor = SolidityTypeBool;
   565      
   566      SolidityTypeBool.prototype.isType = function (name) {
   567          return !!name.match(/^bool(\[([0-9]*)\])*$/);
   568      };
   569      
   570      module.exports = SolidityTypeBool;
   571      
   572      },{"./formatters":9,"./type":14}],6:[function(require,module,exports){
   573      var f = require('./formatters');
   574      var SolidityType = require('./type');
   575      
   576      /**
   577       * SolidityTypeBytes is a prototype that represents the bytes type.
   578       * It matches:
   579       * bytes
   580       * bytes[]
   581       * bytes[4]
   582       * bytes[][]
   583       * bytes[3][]
   584       * bytes[][6][], ...
   585       * bytes32
   586       * bytes8[4]
   587       * bytes[3][]
   588       */
   589      var SolidityTypeBytes = function () {
   590          this._inputFormatter = f.formatInputBytes;
   591          this._outputFormatter = f.formatOutputBytes;
   592      };
   593      
   594      SolidityTypeBytes.prototype = new SolidityType({});
   595      SolidityTypeBytes.prototype.constructor = SolidityTypeBytes;
   596      
   597      SolidityTypeBytes.prototype.isType = function (name) {
   598          return !!name.match(/^bytes([0-9]{1,})(\[([0-9]*)\])*$/);
   599      };
   600      
   601      module.exports = SolidityTypeBytes;
   602      
   603      },{"./formatters":9,"./type":14}],7:[function(require,module,exports){
   604      /*
   605          This file is part of web3.js.
   606      
   607          web3.js is free software: you can redistribute it and/or modify
   608          it under the terms of the GNU Lesser General Public License as published by
   609          the Free Software Foundation, either version 3 of the License, or
   610          (at your option) any later version.
   611      
   612          web3.js is distributed in the hope that it will be useful,
   613          but WITHOUT ANY WARRANTY; without even the implied warranty of
   614          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   615          GNU Lesser General Public License for more details.
   616      
   617          You should have received a copy of the GNU Lesser General Public License
   618          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
   619      */
   620      /**
   621       * @file coder.js
   622       * @author Marek Kotewicz <marek@ethdev.com>
   623       * @date 2015
   624       */
   625      
   626      var f = require('./formatters');
   627      
   628      var SolidityTypeAddress = require('./address');
   629      var SolidityTypeBool = require('./bool');
   630      var SolidityTypeInt = require('./int');
   631      var SolidityTypeUInt = require('./uint');
   632      var SolidityTypeDynamicBytes = require('./dynamicbytes');
   633      var SolidityTypeString = require('./string');
   634      var SolidityTypeReal = require('./real');
   635      var SolidityTypeUReal = require('./ureal');
   636      var SolidityTypeBytes = require('./bytes');
   637      
   638      var isDynamic = function (solidityType, type) {
   639         return solidityType.isDynamicType(type) ||
   640                solidityType.isDynamicArray(type);
   641      };
   642      
   643      /**
   644       * SolidityCoder prototype should be used to encode/decode solidity params of any type
   645       */
   646      var SolidityCoder = function (types) {
   647          this._types = types;
   648      };
   649      
   650      /**
   651       * This method should be used to transform type to SolidityType
   652       *
   653       * @method _requireType
   654       * @param {String} type
   655       * @returns {SolidityType}
   656       * @throws {Error} throws if no matching type is found
   657       */
   658      SolidityCoder.prototype._requireType = function (type) {
   659          var solidityType = this._types.filter(function (t) {
   660              return t.isType(type);
   661          })[0];
   662      
   663          if (!solidityType) {
   664              throw Error('invalid solidity type!: ' + type);
   665          }
   666      
   667          return solidityType;
   668      };
   669      
   670      /**
   671       * Should be used to encode plain param
   672       *
   673       * @method encodeParam
   674       * @param {String} type
   675       * @param {Object} plain param
   676       * @return {String} encoded plain param
   677       */
   678      SolidityCoder.prototype.encodeParam = function (type, param) {
   679          return this.encodeParams([type], [param]);
   680      };
   681      
   682      /**
   683       * Should be used to encode list of params
   684       *
   685       * @method encodeParams
   686       * @param {Array} types
   687       * @param {Array} params
   688       * @return {String} encoded list of params
   689       */
   690      SolidityCoder.prototype.encodeParams = function (types, params) {
   691          var solidityTypes = this.getSolidityTypes(types);
   692      
   693          var encodeds = solidityTypes.map(function (solidityType, index) {
   694              return solidityType.encode(params[index], types[index]);
   695          });
   696      
   697          var dynamicOffset = solidityTypes.reduce(function (acc, solidityType, index) {
   698              var staticPartLength = solidityType.staticPartLength(types[index]);
   699              var roundedStaticPartLength = Math.floor((staticPartLength + 31) / 32) * 32;
   700      
   701              return acc + (isDynamic(solidityTypes[index], types[index]) ?
   702                  32 :
   703                  roundedStaticPartLength);
   704          }, 0);
   705      
   706          var result = this.encodeMultiWithOffset(types, solidityTypes, encodeds, dynamicOffset);
   707      
   708          return result;
   709      };
   710      
   711      SolidityCoder.prototype.encodeMultiWithOffset = function (types, solidityTypes, encodeds, dynamicOffset) {
   712          var result = "";
   713          var self = this;
   714      
   715          types.forEach(function (type, i) {
   716              if (isDynamic(solidityTypes[i], types[i])) {
   717                  result += f.formatInputInt(dynamicOffset).encode();
   718                  var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   719                  dynamicOffset += e.length / 2;
   720              } else {
   721                  // don't add length to dynamicOffset. it's already counted
   722                  result += self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   723              }
   724      
   725              // TODO: figure out nested arrays
   726          });
   727      
   728          types.forEach(function (type, i) {
   729              if (isDynamic(solidityTypes[i], types[i])) {
   730                  var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   731                  dynamicOffset += e.length / 2;
   732                  result += e;
   733              }
   734          });
   735          return result;
   736      };
   737      
   738      // TODO: refactor whole encoding!
   739      SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded, offset) {
   740          var self = this;
   741          if (solidityType.isDynamicArray(type)) {
   742              return (function () {
   743                  // offset was already set
   744                  var nestedName = solidityType.nestedName(type);
   745                  var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
   746                  var result = encoded[0];
   747      
   748                  (function () {
   749                      var previousLength = 2; // in int
   750                      if (solidityType.isDynamicArray(nestedName)) {
   751                          for (var i = 1; i < encoded.length; i++) {
   752                              previousLength += +(encoded[i - 1])[0] || 0;
   753                              result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
   754                          }
   755                      }
   756                  })();
   757      
   758                  // first element is length, skip it
   759                  (function () {
   760                      for (var i = 0; i < encoded.length - 1; i++) {
   761                          var additionalOffset = result / 2;
   762                          result += self.encodeWithOffset(nestedName, solidityType, encoded[i + 1], offset +  additionalOffset);
   763                      }
   764                  })();
   765      
   766                  return result;
   767              })();
   768      
   769          } else if (solidityType.isStaticArray(type)) {
   770              return (function () {
   771                  var nestedName = solidityType.nestedName(type);
   772                  var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
   773                  var result = "";
   774      
   775      
   776                  if (solidityType.isDynamicArray(nestedName)) {
   777                      (function () {
   778                          var previousLength = 0; // in int
   779                          for (var i = 0; i < encoded.length; i++) {
   780                              // calculate length of previous item
   781                              previousLength += +(encoded[i - 1] || [])[0] || 0;
   782                              result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
   783                          }
   784                      })();
   785                  }
   786      
   787                  (function () {
   788                      for (var i = 0; i < encoded.length; i++) {
   789                          var additionalOffset = result / 2;
   790                          result += self.encodeWithOffset(nestedName, solidityType, encoded[i], offset + additionalOffset);
   791                      }
   792                  })();
   793      
   794                  return result;
   795              })();
   796          }
   797      
   798          return encoded;
   799      };
   800      
   801      /**
   802       * Should be used to decode bytes to plain param
   803       *
   804       * @method decodeParam
   805       * @param {String} type
   806       * @param {String} bytes
   807       * @return {Object} plain param
   808       */
   809      SolidityCoder.prototype.decodeParam = function (type, bytes) {
   810          return this.decodeParams([type], bytes)[0];
   811      };
   812      
   813      /**
   814       * Should be used to decode list of params
   815       *
   816       * @method decodeParam
   817       * @param {Array} types
   818       * @param {String} bytes
   819       * @return {Array} array of plain params
   820       */
   821      SolidityCoder.prototype.decodeParams = function (types, bytes) {
   822          var solidityTypes = this.getSolidityTypes(types);
   823          var offsets = this.getOffsets(types, solidityTypes);
   824      
   825          return solidityTypes.map(function (solidityType, index) {
   826              return solidityType.decode(bytes, offsets[index],  types[index], index);
   827          });
   828      };
   829      
   830      SolidityCoder.prototype.getOffsets = function (types, solidityTypes) {
   831          var lengths =  solidityTypes.map(function (solidityType, index) {
   832              return solidityType.staticPartLength(types[index]);
   833          });
   834      
   835          for (var i = 1; i < lengths.length; i++) {
   836               // sum with length of previous element
   837              lengths[i] += lengths[i - 1];
   838          }
   839      
   840          return lengths.map(function (length, index) {
   841              // remove the current length, so the length is sum of previous elements
   842              var staticPartLength = solidityTypes[index].staticPartLength(types[index]);
   843              return length - staticPartLength;
   844          });
   845      };
   846      
   847      SolidityCoder.prototype.getSolidityTypes = function (types) {
   848          var self = this;
   849          return types.map(function (type) {
   850              return self._requireType(type);
   851          });
   852      };
   853      
   854      var coder = new SolidityCoder([
   855          new SolidityTypeAddress(),
   856          new SolidityTypeBool(),
   857          new SolidityTypeInt(),
   858          new SolidityTypeUInt(),
   859          new SolidityTypeDynamicBytes(),
   860          new SolidityTypeBytes(),
   861          new SolidityTypeString(),
   862          new SolidityTypeReal(),
   863          new SolidityTypeUReal()
   864      ]);
   865      
   866      module.exports = coder;
   867      
   868      },{"./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){
   869      var f = require('./formatters');
   870      var SolidityType = require('./type');
   871      
   872      var SolidityTypeDynamicBytes = function () {
   873          this._inputFormatter = f.formatInputDynamicBytes;
   874          this._outputFormatter = f.formatOutputDynamicBytes;
   875      };
   876      
   877      SolidityTypeDynamicBytes.prototype = new SolidityType({});
   878      SolidityTypeDynamicBytes.prototype.constructor = SolidityTypeDynamicBytes;
   879      
   880      SolidityTypeDynamicBytes.prototype.isType = function (name) {
   881          return !!name.match(/^bytes(\[([0-9]*)\])*$/);
   882      };
   883      
   884      SolidityTypeDynamicBytes.prototype.isDynamicType = function () {
   885          return true;
   886      };
   887      
   888      module.exports = SolidityTypeDynamicBytes;
   889      
   890      },{"./formatters":9,"./type":14}],9:[function(require,module,exports){
   891      /*
   892          This file is part of web3.js.
   893      
   894          web3.js is free software: you can redistribute it and/or modify
   895          it under the terms of the GNU Lesser General Public License as published by
   896          the Free Software Foundation, either version 3 of the License, or
   897          (at your option) any later version.
   898      
   899          web3.js is distributed in the hope that it will be useful,
   900          but WITHOUT ANY WARRANTY; without even the implied warranty of
   901          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   902          GNU Lesser General Public License for more details.
   903      
   904          You should have received a copy of the GNU Lesser General Public License
   905          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
   906      */
   907      /**
   908       * @file formatters.js
   909       * @author Marek Kotewicz <marek@ethdev.com>
   910       * @date 2015
   911       */
   912      
   913      var BigNumber = require('bignumber.js');
   914      var utils = require('../utils/utils');
   915      var c = require('../utils/config');
   916      var SolidityParam = require('./param');
   917      
   918      
   919      /**
   920       * Formats input value to byte representation of int
   921       * If value is negative, return it's two's complement
   922       * If the value is floating point, round it down
   923       *
   924       * @method formatInputInt
   925       * @param {String|Number|BigNumber} value that needs to be formatted
   926       * @returns {SolidityParam}
   927       */
   928      var formatInputInt = function (value) {
   929          BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
   930          var result = utils.padLeft(utils.toTwosComplement(value).toString(16), 64);
   931          return new SolidityParam(result);
   932      };
   933      
   934      /**
   935       * Formats input bytes
   936       *
   937       * @method formatInputBytes
   938       * @param {String}
   939       * @returns {SolidityParam}
   940       */
   941      var formatInputBytes = function (value) {
   942          var result = utils.toHex(value).substr(2);
   943          var l = Math.floor((result.length + 63) / 64);
   944          result = utils.padRight(result, l * 64);
   945          return new SolidityParam(result);
   946      };
   947      
   948      /**
   949       * Formats input bytes
   950       *
   951       * @method formatDynamicInputBytes
   952       * @param {String}
   953       * @returns {SolidityParam}
   954       */
   955      var formatInputDynamicBytes = function (value) {
   956          var result = utils.toHex(value).substr(2);
   957          var length = result.length / 2;
   958          var l = Math.floor((result.length + 63) / 64);
   959          result = utils.padRight(result, l * 64);
   960          return new SolidityParam(formatInputInt(length).value + result);
   961      };
   962      
   963      /**
   964       * Formats input value to byte representation of string
   965       *
   966       * @method formatInputString
   967       * @param {String}
   968       * @returns {SolidityParam}
   969       */
   970      var formatInputString = function (value) {
   971          var result = utils.fromUtf8(value).substr(2);
   972          var length = result.length / 2;
   973          var l = Math.floor((result.length + 63) / 64);
   974          result = utils.padRight(result, l * 64);
   975          return new SolidityParam(formatInputInt(length).value + result);
   976      };
   977      
   978      /**
   979       * Formats input value to byte representation of bool
   980       *
   981       * @method formatInputBool
   982       * @param {Boolean}
   983       * @returns {SolidityParam}
   984       */
   985      var formatInputBool = function (value) {
   986          var result = '000000000000000000000000000000000000000000000000000000000000000' + (value ?  '1' : '0');
   987          return new SolidityParam(result);
   988      };
   989      
   990      /**
   991       * Formats input value to byte representation of real
   992       * Values are multiplied by 2^m and encoded as integers
   993       *
   994       * @method formatInputReal
   995       * @param {String|Number|BigNumber}
   996       * @returns {SolidityParam}
   997       */
   998      var formatInputReal = function (value) {
   999          return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
  1000      };
  1001      
  1002      /**
  1003       * Check if input value is negative
  1004       *
  1005       * @method signedIsNegative
  1006       * @param {String} value is hex format
  1007       * @returns {Boolean} true if it is negative, otherwise false
  1008       */
  1009      var signedIsNegative = function (value) {
  1010          return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
  1011      };
  1012      
  1013      /**
  1014       * Formats right-aligned output bytes to int
  1015       *
  1016       * @method formatOutputInt
  1017       * @param {SolidityParam} param
  1018       * @returns {BigNumber} right-aligned output bytes formatted to big number
  1019       */
  1020      var formatOutputInt = function (param) {
  1021          var value = param.staticPart() || "0";
  1022      
  1023          // check if it's negative number
  1024          // it is, return two's complement
  1025          if (signedIsNegative(value)) {
  1026              return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
  1027          }
  1028          return new BigNumber(value, 16);
  1029      };
  1030      
  1031      /**
  1032       * Formats right-aligned output bytes to uint
  1033       *
  1034       * @method formatOutputUInt
  1035       * @param {SolidityParam}
  1036       * @returns {BigNumeber} right-aligned output bytes formatted to uint
  1037       */
  1038      var formatOutputUInt = function (param) {
  1039          var value = param.staticPart() || "0";
  1040          return new BigNumber(value, 16);
  1041      };
  1042      
  1043      /**
  1044       * Formats right-aligned output bytes to real
  1045       *
  1046       * @method formatOutputReal
  1047       * @param {SolidityParam}
  1048       * @returns {BigNumber} input bytes formatted to real
  1049       */
  1050      var formatOutputReal = function (param) {
  1051          return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
  1052      };
  1053      
  1054      /**
  1055       * Formats right-aligned output bytes to ureal
  1056       *
  1057       * @method formatOutputUReal
  1058       * @param {SolidityParam}
  1059       * @returns {BigNumber} input bytes formatted to ureal
  1060       */
  1061      var formatOutputUReal = function (param) {
  1062          return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
  1063      };
  1064      
  1065      /**
  1066       * Should be used to format output bool
  1067       *
  1068       * @method formatOutputBool
  1069       * @param {SolidityParam}
  1070       * @returns {Boolean} right-aligned input bytes formatted to bool
  1071       */
  1072      var formatOutputBool = function (param) {
  1073          return param.staticPart() === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
  1074      };
  1075      
  1076      /**
  1077       * Should be used to format output bytes
  1078       *
  1079       * @method formatOutputBytes
  1080       * @param {SolidityParam} left-aligned hex representation of string
  1081       * @param {String} name type name
  1082       * @returns {String} hex string
  1083       */
  1084      var formatOutputBytes = function (param, name) {
  1085          var matches = name.match(/^bytes([0-9]*)/);
  1086          var size = parseInt(matches[1]);
  1087          return '0x' + param.staticPart().slice(0, 2 * size);
  1088      };
  1089      
  1090      /**
  1091       * Should be used to format output bytes
  1092       *
  1093       * @method formatOutputDynamicBytes
  1094       * @param {SolidityParam} left-aligned hex representation of string
  1095       * @returns {String} hex string
  1096       */
  1097      var formatOutputDynamicBytes = function (param) {
  1098          var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1099          return '0x' + param.dynamicPart().substr(64, length);
  1100      };
  1101      
  1102      /**
  1103       * Should be used to format output string
  1104       *
  1105       * @method formatOutputString
  1106       * @param {SolidityParam} left-aligned hex representation of string
  1107       * @returns {String} ascii string
  1108       */
  1109      var formatOutputString = function (param) {
  1110          var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1111          return utils.toUtf8(param.dynamicPart().substr(64, length));
  1112      };
  1113      
  1114      /**
  1115       * Should be used to format output address
  1116       *
  1117       * @method formatOutputAddress
  1118       * @param {SolidityParam} right-aligned input bytes
  1119       * @returns {String} address
  1120       */
  1121      var formatOutputAddress = function (param) {
  1122          var value = param.staticPart();
  1123          return "0x" + value.slice(value.length - 40, value.length);
  1124      };
  1125      
  1126      module.exports = {
  1127          formatInputInt: formatInputInt,
  1128          formatInputBytes: formatInputBytes,
  1129          formatInputDynamicBytes: formatInputDynamicBytes,
  1130          formatInputString: formatInputString,
  1131          formatInputBool: formatInputBool,
  1132          formatInputReal: formatInputReal,
  1133          formatOutputInt: formatOutputInt,
  1134          formatOutputUInt: formatOutputUInt,
  1135          formatOutputReal: formatOutputReal,
  1136          formatOutputUReal: formatOutputUReal,
  1137          formatOutputBool: formatOutputBool,
  1138          formatOutputBytes: formatOutputBytes,
  1139          formatOutputDynamicBytes: formatOutputDynamicBytes,
  1140          formatOutputString: formatOutputString,
  1141          formatOutputAddress: formatOutputAddress
  1142      };
  1143      
  1144      },{"../utils/config":18,"../utils/utils":20,"./param":11,"bignumber.js":"bignumber.js"}],10:[function(require,module,exports){
  1145      var f = require('./formatters');
  1146      var SolidityType = require('./type');
  1147      
  1148      /**
  1149       * SolidityTypeInt is a prootype that represents int type
  1150       * It matches:
  1151       * int
  1152       * int[]
  1153       * int[4]
  1154       * int[][]
  1155       * int[3][]
  1156       * int[][6][], ...
  1157       * int32
  1158       * int64[]
  1159       * int8[4]
  1160       * int256[][]
  1161       * int[3][]
  1162       * int64[][6][], ...
  1163       */
  1164      var SolidityTypeInt = function () {
  1165          this._inputFormatter = f.formatInputInt;
  1166          this._outputFormatter = f.formatOutputInt;
  1167      };
  1168      
  1169      SolidityTypeInt.prototype = new SolidityType({});
  1170      SolidityTypeInt.prototype.constructor = SolidityTypeInt;
  1171      
  1172      SolidityTypeInt.prototype.isType = function (name) {
  1173          return !!name.match(/^int([0-9]*)?(\[([0-9]*)\])*$/);
  1174      };
  1175      
  1176      module.exports = SolidityTypeInt;
  1177      
  1178      },{"./formatters":9,"./type":14}],11:[function(require,module,exports){
  1179      /*
  1180          This file is part of web3.js.
  1181      
  1182          web3.js is free software: you can redistribute it and/or modify
  1183          it under the terms of the GNU Lesser General Public License as published by
  1184          the Free Software Foundation, either version 3 of the License, or
  1185          (at your option) any later version.
  1186      
  1187          web3.js is distributed in the hope that it will be useful,
  1188          but WITHOUT ANY WARRANTY; without even the implied warranty of
  1189          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1190          GNU Lesser General Public License for more details.
  1191      
  1192          You should have received a copy of the GNU Lesser General Public License
  1193          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1194      */
  1195      /** 
  1196       * @file param.js
  1197       * @author Marek Kotewicz <marek@ethdev.com>
  1198       * @date 2015
  1199       */
  1200      
  1201      var utils = require('../utils/utils');
  1202      
  1203      /**
  1204       * SolidityParam object prototype.
  1205       * Should be used when encoding, decoding solidity bytes
  1206       */
  1207      var SolidityParam = function (value, offset) {
  1208          this.value = value || '';
  1209          this.offset = offset; // offset in bytes
  1210      };
  1211      
  1212      /**
  1213       * This method should be used to get length of params's dynamic part
  1214       * 
  1215       * @method dynamicPartLength
  1216       * @returns {Number} length of dynamic part (in bytes)
  1217       */
  1218      SolidityParam.prototype.dynamicPartLength = function () {
  1219          return this.dynamicPart().length / 2;
  1220      };
  1221      
  1222      /**
  1223       * This method should be used to create copy of solidity param with different offset
  1224       *
  1225       * @method withOffset
  1226       * @param {Number} offset length in bytes
  1227       * @returns {SolidityParam} new solidity param with applied offset
  1228       */
  1229      SolidityParam.prototype.withOffset = function (offset) {
  1230          return new SolidityParam(this.value, offset);
  1231      };
  1232      
  1233      /**
  1234       * This method should be used to combine solidity params together
  1235       * eg. when appending an array
  1236       *
  1237       * @method combine
  1238       * @param {SolidityParam} param with which we should combine
  1239       * @param {SolidityParam} result of combination
  1240       */
  1241      SolidityParam.prototype.combine = function (param) {
  1242          return new SolidityParam(this.value + param.value); 
  1243      };
  1244      
  1245      /**
  1246       * This method should be called to check if param has dynamic size.
  1247       * If it has, it returns true, otherwise false
  1248       *
  1249       * @method isDynamic
  1250       * @returns {Boolean}
  1251       */
  1252      SolidityParam.prototype.isDynamic = function () {
  1253          return this.offset !== undefined;
  1254      };
  1255      
  1256      /**
  1257       * This method should be called to transform offset to bytes
  1258       *
  1259       * @method offsetAsBytes
  1260       * @returns {String} bytes representation of offset
  1261       */
  1262      SolidityParam.prototype.offsetAsBytes = function () {
  1263          return !this.isDynamic() ? '' : utils.padLeft(utils.toTwosComplement(this.offset).toString(16), 64);
  1264      };
  1265      
  1266      /**
  1267       * This method should be called to get static part of param
  1268       *
  1269       * @method staticPart
  1270       * @returns {String} offset if it is a dynamic param, otherwise value
  1271       */
  1272      SolidityParam.prototype.staticPart = function () {
  1273          if (!this.isDynamic()) {
  1274              return this.value; 
  1275          } 
  1276          return this.offsetAsBytes();
  1277      };
  1278      
  1279      /**
  1280       * This method should be called to get dynamic part of param
  1281       *
  1282       * @method dynamicPart
  1283       * @returns {String} returns a value if it is a dynamic param, otherwise empty string
  1284       */
  1285      SolidityParam.prototype.dynamicPart = function () {
  1286          return this.isDynamic() ? this.value : '';
  1287      };
  1288      
  1289      /**
  1290       * This method should be called to encode param
  1291       *
  1292       * @method encode
  1293       * @returns {String}
  1294       */
  1295      SolidityParam.prototype.encode = function () {
  1296          return this.staticPart() + this.dynamicPart();
  1297      };
  1298      
  1299      /**
  1300       * This method should be called to encode array of params
  1301       *
  1302       * @method encodeList
  1303       * @param {Array[SolidityParam]} params
  1304       * @returns {String}
  1305       */
  1306      SolidityParam.encodeList = function (params) {
  1307          
  1308          // updating offsets
  1309          var totalOffset = params.length * 32;
  1310          var offsetParams = params.map(function (param) {
  1311              if (!param.isDynamic()) {
  1312                  return param;
  1313              }
  1314              var offset = totalOffset;
  1315              totalOffset += param.dynamicPartLength();
  1316              return param.withOffset(offset);
  1317          });
  1318      
  1319          // encode everything!
  1320          return offsetParams.reduce(function (result, param) {
  1321              return result + param.dynamicPart();
  1322          }, offsetParams.reduce(function (result, param) {
  1323              return result + param.staticPart();
  1324          }, ''));
  1325      };
  1326      
  1327      
  1328      
  1329      module.exports = SolidityParam;
  1330      
  1331      
  1332      },{"../utils/utils":20}],12:[function(require,module,exports){
  1333      var f = require('./formatters');
  1334      var SolidityType = require('./type');
  1335      
  1336      /**
  1337       * SolidityTypeReal is a prootype that represents real type
  1338       * It matches:
  1339       * real
  1340       * real[]
  1341       * real[4]
  1342       * real[][]
  1343       * real[3][]
  1344       * real[][6][], ...
  1345       * real32
  1346       * real64[]
  1347       * real8[4]
  1348       * real256[][]
  1349       * real[3][]
  1350       * real64[][6][], ...
  1351       */
  1352      var SolidityTypeReal = function () {
  1353          this._inputFormatter = f.formatInputReal;
  1354          this._outputFormatter = f.formatOutputReal;
  1355      };
  1356      
  1357      SolidityTypeReal.prototype = new SolidityType({});
  1358      SolidityTypeReal.prototype.constructor = SolidityTypeReal;
  1359      
  1360      SolidityTypeReal.prototype.isType = function (name) {
  1361          return !!name.match(/real([0-9]*)?(\[([0-9]*)\])?/);
  1362      };
  1363      
  1364      module.exports = SolidityTypeReal;
  1365      
  1366      },{"./formatters":9,"./type":14}],13:[function(require,module,exports){
  1367      var f = require('./formatters');
  1368      var SolidityType = require('./type');
  1369      
  1370      var SolidityTypeString = function () {
  1371          this._inputFormatter = f.formatInputString;
  1372          this._outputFormatter = f.formatOutputString;
  1373      };
  1374      
  1375      SolidityTypeString.prototype = new SolidityType({});
  1376      SolidityTypeString.prototype.constructor = SolidityTypeString;
  1377      
  1378      SolidityTypeString.prototype.isType = function (name) {
  1379          return !!name.match(/^string(\[([0-9]*)\])*$/);
  1380      };
  1381      
  1382      SolidityTypeString.prototype.isDynamicType = function () {
  1383          return true;
  1384      };
  1385      
  1386      module.exports = SolidityTypeString;
  1387      
  1388      },{"./formatters":9,"./type":14}],14:[function(require,module,exports){
  1389      var f = require('./formatters');
  1390      var SolidityParam = require('./param');
  1391      
  1392      /**
  1393       * SolidityType prototype is used to encode/decode solidity params of certain type
  1394       */
  1395      var SolidityType = function (config) {
  1396          this._inputFormatter = config.inputFormatter;
  1397          this._outputFormatter = config.outputFormatter;
  1398      };
  1399      
  1400      /**
  1401       * Should be used to determine if this SolidityType do match given name
  1402       *
  1403       * @method isType
  1404       * @param {String} name
  1405       * @return {Bool} true if type match this SolidityType, otherwise false
  1406       */
  1407      SolidityType.prototype.isType = function (name) {
  1408          throw "this method should be overrwritten for type " + name;
  1409      };
  1410      
  1411      /**
  1412       * Should be used to determine what is the length of static part in given type
  1413       *
  1414       * @method staticPartLength
  1415       * @param {String} name
  1416       * @return {Number} length of static part in bytes
  1417       */
  1418      SolidityType.prototype.staticPartLength = function (name) {
  1419          // If name isn't an array then treat it like a single element array.
  1420          return (this.nestedTypes(name) || ['[1]'])
  1421              .map(function (type) {
  1422                  // the length of the nested array
  1423                  return parseInt(type.slice(1, -1), 10) || 1;
  1424              })
  1425              .reduce(function (previous, current) {
  1426                  return previous * current;
  1427              // all basic types are 32 bytes long
  1428              }, 32);
  1429      };
  1430      
  1431      /**
  1432       * Should be used to determine if type is dynamic array
  1433       * eg:
  1434       * "type[]" => true
  1435       * "type[4]" => false
  1436       *
  1437       * @method isDynamicArray
  1438       * @param {String} name
  1439       * @return {Bool} true if the type is dynamic array
  1440       */
  1441      SolidityType.prototype.isDynamicArray = function (name) {
  1442          var nestedTypes = this.nestedTypes(name);
  1443          return !!nestedTypes && !nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1444      };
  1445      
  1446      /**
  1447       * Should be used to determine if type is static array
  1448       * eg:
  1449       * "type[]" => false
  1450       * "type[4]" => true
  1451       *
  1452       * @method isStaticArray
  1453       * @param {String} name
  1454       * @return {Bool} true if the type is static array
  1455       */
  1456      SolidityType.prototype.isStaticArray = function (name) {
  1457          var nestedTypes = this.nestedTypes(name);
  1458          return !!nestedTypes && !!nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1459      };
  1460      
  1461      /**
  1462       * Should return length of static array
  1463       * eg.
  1464       * "int[32]" => 32
  1465       * "int256[14]" => 14
  1466       * "int[2][3]" => 3
  1467       * "int" => 1
  1468       * "int[1]" => 1
  1469       * "int[]" => 1
  1470       *
  1471       * @method staticArrayLength
  1472       * @param {String} name
  1473       * @return {Number} static array length
  1474       */
  1475      SolidityType.prototype.staticArrayLength = function (name) {
  1476          var nestedTypes = this.nestedTypes(name);
  1477          if (nestedTypes) {
  1478             return parseInt(nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g) || 1);
  1479          }
  1480          return 1;
  1481      };
  1482      
  1483      /**
  1484       * Should return nested type
  1485       * eg.
  1486       * "int[32]" => "int"
  1487       * "int256[14]" => "int256"
  1488       * "int[2][3]" => "int[2]"
  1489       * "int" => "int"
  1490       * "int[]" => "int"
  1491       *
  1492       * @method nestedName
  1493       * @param {String} name
  1494       * @return {String} nested name
  1495       */
  1496      SolidityType.prototype.nestedName = function (name) {
  1497          // remove last [] in name
  1498          var nestedTypes = this.nestedTypes(name);
  1499          if (!nestedTypes) {
  1500              return name;
  1501          }
  1502      
  1503          return name.substr(0, name.length - nestedTypes[nestedTypes.length - 1].length);
  1504      };
  1505      
  1506      /**
  1507       * Should return true if type has dynamic size by default
  1508       * such types are "string", "bytes"
  1509       *
  1510       * @method isDynamicType
  1511       * @param {String} name
  1512       * @return {Bool} true if is dynamic, otherwise false
  1513       */
  1514      SolidityType.prototype.isDynamicType = function () {
  1515          return false;
  1516      };
  1517      
  1518      /**
  1519       * Should return array of nested types
  1520       * eg.
  1521       * "int[2][3][]" => ["[2]", "[3]", "[]"]
  1522       * "int[] => ["[]"]
  1523       * "int" => null
  1524       *
  1525       * @method nestedTypes
  1526       * @param {String} name
  1527       * @return {Array} array of nested types
  1528       */
  1529      SolidityType.prototype.nestedTypes = function (name) {
  1530          // return list of strings eg. "[]", "[3]", "[]", "[2]"
  1531          return name.match(/(\[[0-9]*\])/g);
  1532      };
  1533      
  1534      /**
  1535       * Should be used to encode the value
  1536       *
  1537       * @method encode
  1538       * @param {Object} value
  1539       * @param {String} name
  1540       * @return {String} encoded value
  1541       */
  1542      SolidityType.prototype.encode = function (value, name) {
  1543          var self = this;
  1544          if (this.isDynamicArray(name)) {
  1545      
  1546              return (function () {
  1547                  var length = value.length;                          // in int
  1548                  var nestedName = self.nestedName(name);
  1549      
  1550                  var result = [];
  1551                  result.push(f.formatInputInt(length).encode());
  1552      
  1553                  value.forEach(function (v) {
  1554                      result.push(self.encode(v, nestedName));
  1555                  });
  1556      
  1557                  return result;
  1558              })();
  1559      
  1560          } else if (this.isStaticArray(name)) {
  1561      
  1562              return (function () {
  1563                  var length = self.staticArrayLength(name);          // in int
  1564                  var nestedName = self.nestedName(name);
  1565      
  1566                  var result = [];
  1567                  for (var i = 0; i < length; i++) {
  1568                      result.push(self.encode(value[i], nestedName));
  1569                  }
  1570      
  1571                  return result;
  1572              })();
  1573      
  1574          }
  1575      
  1576          return this._inputFormatter(value, name).encode();
  1577      };
  1578      
  1579      /**
  1580       * Should be used to decode value from bytes
  1581       *
  1582       * @method decode
  1583       * @param {String} bytes
  1584       * @param {Number} offset in bytes
  1585       * @param {String} name type name
  1586       * @returns {Object} decoded value
  1587       */
  1588      SolidityType.prototype.decode = function (bytes, offset, name) {
  1589          var self = this;
  1590      
  1591          if (this.isDynamicArray(name)) {
  1592      
  1593              return (function () {
  1594                  var arrayOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
  1595                  var length = parseInt('0x' + bytes.substr(arrayOffset * 2, 64)); // in int
  1596                  var arrayStart = arrayOffset + 32; // array starts after length; // in bytes
  1597      
  1598                  var nestedName = self.nestedName(name);
  1599                  var nestedStaticPartLength = self.staticPartLength(nestedName);  // in bytes
  1600                  var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1601                  var result = [];
  1602      
  1603                  for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1604                      result.push(self.decode(bytes, arrayStart + i, nestedName));
  1605                  }
  1606      
  1607                  return result;
  1608              })();
  1609      
  1610          } else if (this.isStaticArray(name)) {
  1611      
  1612              return (function () {
  1613                  var length = self.staticArrayLength(name);                      // in int
  1614                  var arrayStart = offset;                                        // in bytes
  1615      
  1616                  var nestedName = self.nestedName(name);
  1617                  var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
  1618                  var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1619                  var result = [];
  1620      
  1621                  for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1622                      result.push(self.decode(bytes, arrayStart + i, nestedName));
  1623                  }
  1624      
  1625                  return result;
  1626              })();
  1627          } else if (this.isDynamicType(name)) {
  1628      
  1629              return (function () {
  1630                  var dynamicOffset = parseInt('0x' + bytes.substr(offset * 2, 64));      // in bytes
  1631                  var length = parseInt('0x' + bytes.substr(dynamicOffset * 2, 64));      // in bytes
  1632                  var roundedLength = Math.floor((length + 31) / 32);                     // in int
  1633                  var param = new SolidityParam(bytes.substr(dynamicOffset * 2, ( 1 + roundedLength) * 64), 0);
  1634                  return self._outputFormatter(param, name);
  1635              })();
  1636          }
  1637      
  1638          var length = this.staticPartLength(name);
  1639          var param = new SolidityParam(bytes.substr(offset * 2, length * 2));
  1640          return this._outputFormatter(param, name);
  1641      };
  1642      
  1643      module.exports = SolidityType;
  1644      
  1645      },{"./formatters":9,"./param":11}],15:[function(require,module,exports){
  1646      var f = require('./formatters');
  1647      var SolidityType = require('./type');
  1648      
  1649      /**
  1650       * SolidityTypeUInt is a prootype that represents uint type
  1651       * It matches:
  1652       * uint
  1653       * uint[]
  1654       * uint[4]
  1655       * uint[][]
  1656       * uint[3][]
  1657       * uint[][6][], ...
  1658       * uint32
  1659       * uint64[]
  1660       * uint8[4]
  1661       * uint256[][]
  1662       * uint[3][]
  1663       * uint64[][6][], ...
  1664       */
  1665      var SolidityTypeUInt = function () {
  1666          this._inputFormatter = f.formatInputInt;
  1667          this._outputFormatter = f.formatOutputUInt;
  1668      };
  1669      
  1670      SolidityTypeUInt.prototype = new SolidityType({});
  1671      SolidityTypeUInt.prototype.constructor = SolidityTypeUInt;
  1672      
  1673      SolidityTypeUInt.prototype.isType = function (name) {
  1674          return !!name.match(/^uint([0-9]*)?(\[([0-9]*)\])*$/);
  1675      };
  1676      
  1677      module.exports = SolidityTypeUInt;
  1678      
  1679      },{"./formatters":9,"./type":14}],16:[function(require,module,exports){
  1680      var f = require('./formatters');
  1681      var SolidityType = require('./type');
  1682      
  1683      /**
  1684       * SolidityTypeUReal is a prootype that represents ureal type
  1685       * It matches:
  1686       * ureal
  1687       * ureal[]
  1688       * ureal[4]
  1689       * ureal[][]
  1690       * ureal[3][]
  1691       * ureal[][6][], ...
  1692       * ureal32
  1693       * ureal64[]
  1694       * ureal8[4]
  1695       * ureal256[][]
  1696       * ureal[3][]
  1697       * ureal64[][6][], ...
  1698       */
  1699      var SolidityTypeUReal = function () {
  1700          this._inputFormatter = f.formatInputReal;
  1701          this._outputFormatter = f.formatOutputUReal;
  1702      };
  1703      
  1704      SolidityTypeUReal.prototype = new SolidityType({});
  1705      SolidityTypeUReal.prototype.constructor = SolidityTypeUReal;
  1706      
  1707      SolidityTypeUReal.prototype.isType = function (name) {
  1708          return !!name.match(/^ureal([0-9]*)?(\[([0-9]*)\])*$/);
  1709      };
  1710      
  1711      module.exports = SolidityTypeUReal;
  1712      
  1713      },{"./formatters":9,"./type":14}],17:[function(require,module,exports){
  1714      'use strict';
  1715      
  1716      // go env doesn't have and need XMLHttpRequest
  1717      if (typeof XMLHttpRequest === 'undefined') {
  1718          exports.XMLHttpRequest = {};
  1719      } else {
  1720          exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line
  1721      }
  1722      
  1723      
  1724      },{}],18:[function(require,module,exports){
  1725      /*
  1726          This file is part of web3.js.
  1727      
  1728          web3.js is free software: you can redistribute it and/or modify
  1729          it under the terms of the GNU Lesser General Public License as published by
  1730          the Free Software Foundation, either version 3 of the License, or
  1731          (at your option) any later version.
  1732      
  1733          web3.js is distributed in the hope that it will be useful,
  1734          but WITHOUT ANY WARRANTY; without even the implied warranty of
  1735          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1736          GNU Lesser General Public License for more details.
  1737      
  1738          You should have received a copy of the GNU Lesser General Public License
  1739          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1740      */
  1741      /** @file config.js
  1742       * @authors:
  1743       *   Marek Kotewicz <marek@ethdev.com>
  1744       * @date 2015
  1745       */
  1746      
  1747      /**
  1748       * Utils
  1749       * 
  1750       * @module utils
  1751       */
  1752      
  1753      /**
  1754       * Utility functions
  1755       * 
  1756       * @class [utils] config
  1757       * @constructor
  1758       */
  1759      
  1760      
  1761      /// required to define ETH_BIGNUMBER_ROUNDING_MODE
  1762      var BigNumber = require('bignumber.js');
  1763      
  1764      var ETH_UNITS = [
  1765          'wei',
  1766          'kwei',
  1767          'Mwei',
  1768          'Gwei',
  1769          'szabo',
  1770          'finney',
  1771          'femtoether',
  1772          'picoether',
  1773          'nanoether',
  1774          'microether',
  1775          'milliether',
  1776          'nano',
  1777          'micro',
  1778          'milli',
  1779          'ether',
  1780          'grand',
  1781          'Mether',
  1782          'Gether',
  1783          'Tether',
  1784          'Pether',
  1785          'Eether',
  1786          'Zether',
  1787          'Yether',
  1788          'Nether',
  1789          'Dether',
  1790          'Vether',
  1791          'Uether'
  1792      ];
  1793      
  1794      module.exports = {
  1795          ETH_PADDING: 32,
  1796          ETH_SIGNATURE_LENGTH: 4,
  1797          ETH_UNITS: ETH_UNITS,
  1798          ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
  1799          ETH_POLLING_TIMEOUT: 1000/2,
  1800          defaultBlock: 'latest',
  1801          defaultAccount: undefined
  1802      };
  1803      
  1804      
  1805      },{"bignumber.js":"bignumber.js"}],19:[function(require,module,exports){
  1806      /*
  1807          This file is part of web3.js.
  1808      
  1809          web3.js is free software: you can redistribute it and/or modify
  1810          it under the terms of the GNU Lesser General Public License as published by
  1811          the Free Software Foundation, either version 3 of the License, or
  1812          (at your option) any later version.
  1813      
  1814          web3.js is distributed in the hope that it will be useful,
  1815          but WITHOUT ANY WARRANTY; without even the implied warranty of
  1816          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1817          GNU Lesser General Public License for more details.
  1818      
  1819          You should have received a copy of the GNU Lesser General Public License
  1820          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1821      */
  1822      /** 
  1823       * @file sha3.js
  1824       * @author Marek Kotewicz <marek@ethdev.com>
  1825       * @date 2015
  1826       */
  1827      
  1828      var CryptoJS = require('crypto-js');
  1829      var sha3 = require('crypto-js/sha3');
  1830      
  1831      module.exports = function (value, options) {
  1832          if (options && options.encoding === 'hex') {
  1833              if (value.length > 2 && value.substr(0, 2) === '0x') {
  1834                  value = value.substr(2);
  1835              }
  1836              value = CryptoJS.enc.Hex.parse(value);
  1837          }
  1838      
  1839          return sha3(value, {
  1840              outputLength: 256
  1841          }).toString();
  1842      };
  1843      
  1844      
  1845      },{"crypto-js":59,"crypto-js/sha3":80}],20:[function(require,module,exports){
  1846      /*
  1847          This file is part of web3.js.
  1848      
  1849          web3.js is free software: you can redistribute it and/or modify
  1850          it under the terms of the GNU Lesser General Public License as published by
  1851          the Free Software Foundation, either version 3 of the License, or
  1852          (at your option) any later version.
  1853      
  1854          web3.js is distributed in the hope that it will be useful,
  1855          but WITHOUT ANY WARRANTY; without even the implied warranty of
  1856          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1857          GNU Lesser General Public License for more details.
  1858      
  1859          You should have received a copy of the GNU Lesser General Public License
  1860          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1861      */
  1862      /**
  1863       * @file utils.js
  1864       * @author Marek Kotewicz <marek@ethdev.com>
  1865       * @date 2015
  1866       */
  1867      
  1868      /**
  1869       * Utils
  1870       *
  1871       * @module utils
  1872       */
  1873      
  1874      /**
  1875       * Utility functions
  1876       *
  1877       * @class [utils] utils
  1878       * @constructor
  1879       */
  1880      
  1881      
  1882      var BigNumber = require('bignumber.js');
  1883      var sha3 = require('./sha3.js');
  1884      var utf8 = require('utf8');
  1885      
  1886      var unitMap = {
  1887          'noether':      '0',
  1888          'wei':          '1',
  1889          'kwei':         '1000',
  1890          'Kwei':         '1000',
  1891          'babbage':      '1000',
  1892          'femtoether':   '1000',
  1893          'mwei':         '1000000',
  1894          'Mwei':         '1000000',
  1895          'lovelace':     '1000000',
  1896          'picoether':    '1000000',
  1897          'gwei':         '1000000000',
  1898          'Gwei':         '1000000000',
  1899          'shannon':      '1000000000',
  1900          'nanoether':    '1000000000',
  1901          'nano':         '1000000000',
  1902          'szabo':        '1000000000000',
  1903          'microether':   '1000000000000',
  1904          'micro':        '1000000000000',
  1905          'finney':       '1000000000000000',
  1906          'milliether':   '1000000000000000',
  1907          'milli':        '1000000000000000',
  1908          'ether':        '1000000000000000000',
  1909          'neat':         '1000000000000000000',
  1910          'kether':       '1000000000000000000000',
  1911          'kneat':        '1000000000000000000000',
  1912          'grand':        '1000000000000000000000',
  1913          'mether':       '1000000000000000000000000',
  1914          'mneat':        '1000000000000000000000000',
  1915          'gether':       '1000000000000000000000000000',
  1916          'gneat':        '1000000000000000000000000000',
  1917          'tneat':        '1000000000000000000000000000000',
  1918          'tether':       '1000000000000000000000000000000'
  1919      };
  1920      
  1921      /**
  1922       * Should be called to pad string to expected length
  1923       *
  1924       * @method padLeft
  1925       * @param {String} string to be padded
  1926       * @param {Number} characters that result string should have
  1927       * @param {String} sign, by default 0
  1928       * @returns {String} right aligned string
  1929       */
  1930      var padLeft = function (string, chars, sign) {
  1931          return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
  1932      };
  1933      
  1934      /**
  1935       * Should be called to pad string to expected length
  1936       *
  1937       * @method padRight
  1938       * @param {String} string to be padded
  1939       * @param {Number} characters that result string should have
  1940       * @param {String} sign, by default 0
  1941       * @returns {String} right aligned string
  1942       */
  1943      var padRight = function (string, chars, sign) {
  1944          return string + (new Array(chars - string.length + 1).join(sign ? sign : "0"));
  1945      };
  1946      
  1947      /**
  1948       * Should be called to get utf8 from it's hex representation
  1949       *
  1950       * @method toUtf8
  1951       * @param {String} string in hex
  1952       * @returns {String} ascii string representation of hex value
  1953       */
  1954      var toUtf8 = function(hex) {
  1955      // Find termination
  1956          var str = "";
  1957          var i = 0, l = hex.length;
  1958          if (hex.substring(0, 2) === '0x') {
  1959              i = 2;
  1960          }
  1961          for (; i < l; i+=2) {
  1962              var code = parseInt(hex.substr(i, 2), 16);
  1963              if (code === 0)
  1964                  break;
  1965              str += String.fromCharCode(code);
  1966          }
  1967      
  1968          return utf8.decode(str);
  1969      };
  1970      
  1971      /**
  1972       * Should be called to get ascii from it's hex representation
  1973       *
  1974       * @method toAscii
  1975       * @param {String} string in hex
  1976       * @returns {String} ascii string representation of hex value
  1977       */
  1978      var toAscii = function(hex) {
  1979      // Find termination
  1980          var str = "";
  1981          var i = 0, l = hex.length;
  1982          if (hex.substring(0, 2) === '0x') {
  1983              i = 2;
  1984          }
  1985          for (; i < l; i+=2) {
  1986              var code = parseInt(hex.substr(i, 2), 16);
  1987              str += String.fromCharCode(code);
  1988          }
  1989      
  1990          return str;
  1991      };
  1992      
  1993      /**
  1994       * Should be called to get hex representation (prefixed by 0x) of utf8 string
  1995       *
  1996       * @method fromUtf8
  1997       * @param {String} string
  1998       * @param {Number} optional padding
  1999       * @returns {String} hex representation of input string
  2000       */
  2001      var fromUtf8 = function(str) {
  2002          str = utf8.encode(str);
  2003          var hex = "";
  2004          for(var i = 0; i < str.length; i++) {
  2005              var code = str.charCodeAt(i);
  2006              if (code === 0)
  2007                  break;
  2008              var n = code.toString(16);
  2009              hex += n.length < 2 ? '0' + n : n;
  2010          }
  2011      
  2012          return "0x" + hex;
  2013      };
  2014      
  2015      /**
  2016       * Should be called to get hex representation (prefixed by 0x) of ascii string
  2017       *
  2018       * @method fromAscii
  2019       * @param {String} string
  2020       * @param {Number} optional padding
  2021       * @returns {String} hex representation of input string
  2022       */
  2023      var fromAscii = function(str) {
  2024          var hex = "";
  2025          for(var i = 0; i < str.length; i++) {
  2026              var code = str.charCodeAt(i);
  2027              var n = code.toString(16);
  2028              hex += n.length < 2 ? '0' + n : n;
  2029          }
  2030      
  2031          return "0x" + hex;
  2032      };
  2033      
  2034      /**
  2035       * Should be used to create full function/event name from json abi
  2036       *
  2037       * @method transformToFullName
  2038       * @param {Object} json-abi
  2039       * @return {String} full fnction/event name
  2040       */
  2041      var transformToFullName = function (json) {
  2042          if (json.name.indexOf('(') !== -1) {
  2043              return json.name;
  2044          }
  2045      
  2046          var typeName = json.inputs.map(function(i){return i.type; }).join();
  2047          return json.name + '(' + typeName + ')';
  2048      };
  2049      
  2050      /**
  2051       * Should be called to get display name of contract function
  2052       *
  2053       * @method extractDisplayName
  2054       * @param {String} name of function/event
  2055       * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
  2056       */
  2057      var extractDisplayName = function (name) {
  2058          var length = name.indexOf('(');
  2059          return length !== -1 ? name.substr(0, length) : name;
  2060      };
  2061      
  2062      /// @returns overloaded part of function/event name
  2063      var extractTypeName = function (name) {
  2064          /// TODO: make it invulnerable
  2065          var length = name.indexOf('(');
  2066          return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
  2067      };
  2068      
  2069      /**
  2070       * Converts value to it's decimal representation in string
  2071       *
  2072       * @method toDecimal
  2073       * @param {String|Number|BigNumber}
  2074       * @return {String}
  2075       */
  2076      var toDecimal = function (value) {
  2077          return toBigNumber(value).toNumber();
  2078      };
  2079      
  2080      /**
  2081       * Converts value to it's hex representation
  2082       *
  2083       * @method fromDecimal
  2084       * @param {String|Number|BigNumber}
  2085       * @return {String}
  2086       */
  2087      var fromDecimal = function (value) {
  2088          var number = toBigNumber(value);
  2089          var result = number.toString(16);
  2090      
  2091          return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
  2092      };
  2093      
  2094      /**
  2095       * Auto converts any given value into it's hex representation.
  2096       *
  2097       * And even stringifys objects before.
  2098       *
  2099       * @method toHex
  2100       * @param {String|Number|BigNumber|Object}
  2101       * @return {String}
  2102       */
  2103      var toHex = function (val) {
  2104          /*jshint maxcomplexity: 8 */
  2105      
  2106          if (isBoolean(val))
  2107              return fromDecimal(+val);
  2108      
  2109          if (isBigNumber(val))
  2110              return fromDecimal(val);
  2111      
  2112          if (typeof val === 'object')
  2113              return fromUtf8(JSON.stringify(val));
  2114      
  2115          // if its a negative number, pass it through fromDecimal
  2116          if (isString(val)) {
  2117              if (val.indexOf('-0x') === 0)
  2118                  return fromDecimal(val);
  2119              else if(val.indexOf('0x') === 0)
  2120                  return val;
  2121              else if (!isFinite(val))
  2122                  return fromAscii(val);
  2123          }
  2124      
  2125          return fromDecimal(val);
  2126      };
  2127      
  2128      /**
  2129       * Returns value of unit in Wei
  2130       *
  2131       * @method getValueOfUnit
  2132       * @param {String} unit the unit to convert to, default ether
  2133       * @returns {BigNumber} value of the unit (in Wei)
  2134       * @throws error if the unit is not correct:w
  2135       */
  2136      var getValueOfUnit = function (unit) {
  2137          unit = unit ? unit.toLowerCase() : 'ether';
  2138          var unitValue = unitMap[unit];
  2139          if (unitValue === undefined) {
  2140              throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
  2141          }
  2142          return new BigNumber(unitValue, 10);
  2143      };
  2144      
  2145      /**
  2146       * Takes a number of wei and converts it to any other ether unit.
  2147       *
  2148       * Possible units are:
  2149       *   SI Short   SI Full        Effigy       Other
  2150       * - kwei       femtoether     babbage
  2151       * - mwei       picoether      lovelace
  2152       * - gwei       nanoether      shannon      nano
  2153       * - --         microether     szabo        micro
  2154       * - --         milliether     finney       milli
  2155       * - ether      --             --
  2156       * - kether                    --           grand
  2157       * - mether
  2158       * - gether
  2159       * - tether
  2160       *
  2161       * @method fromWei
  2162       * @param {Number|String} number can be a number, number string or a HEX of a decimal
  2163       * @param {String} unit the unit to convert to, default ether
  2164       * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2165      */
  2166      var fromWei = function(number, unit) {
  2167          var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
  2168      
  2169          return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2170      };
  2171      
  2172      /**
  2173       * Takes a number of a unit and converts it to wei.
  2174       *
  2175       * Possible units are:
  2176       *   SI Short   SI Full        Effigy       Other
  2177       * - kwei       femtoether     babbage
  2178       * - mwei       picoether      lovelace
  2179       * - gwei       nanoether      shannon      nano
  2180       * - --         microether     szabo        micro
  2181       * - --         microether     szabo        micro
  2182       * - --         milliether     finney       milli
  2183       * - ether      --             --
  2184       * - kether                    --           grand
  2185       * - mether
  2186       * - gether
  2187       * - tether
  2188       *
  2189       * @method toWei
  2190       * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
  2191       * @param {String} unit the unit to convert from, default ether
  2192       * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2193      */
  2194      var toWei = function(number, unit) {
  2195          var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
  2196      
  2197          return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2198      };
  2199      
  2200      /**
  2201       * Takes an input and transforms it into a bignumber
  2202       *
  2203       * @method toBigNumber
  2204       * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
  2205       * @return {BigNumber} BigNumber
  2206      */
  2207      var toBigNumber = function(number) {
  2208          /*jshint maxcomplexity:5 */
  2209          number = number || 0;
  2210          if (isBigNumber(number))
  2211              return number;
  2212      
  2213          if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
  2214              return new BigNumber(number.replace('0x',''), 16);
  2215          }
  2216      
  2217          return new BigNumber(number.toString(10), 10);
  2218      };
  2219      
  2220      /**
  2221       * Takes and input transforms it into bignumber and if it is negative value, into two's complement
  2222       *
  2223       * @method toTwosComplement
  2224       * @param {Number|String|BigNumber}
  2225       * @return {BigNumber}
  2226       */
  2227      var toTwosComplement = function (number) {
  2228          var bigNumber = toBigNumber(number).round();
  2229          if (bigNumber.lessThan(0)) {
  2230              return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
  2231          }
  2232          return bigNumber;
  2233      };
  2234      
  2235      /**
  2236       * Checks if the given string is strictly an address
  2237       *
  2238       * @method isStrictAddress
  2239       * @param {String} address the given HEX address
  2240       * @return {Boolean}
  2241      */
  2242      var isStrictAddress = function (address) {
  2243          return /^0x[0-9a-f]{40}$/i.test(address);
  2244      };
  2245      
  2246      /**
  2247       * Checks if the given string is an address
  2248       *
  2249       * @method isAddress
  2250       * @param {String} address the given HEX address
  2251       * @return {Boolean}
  2252      */
  2253      var isAddress = function (address) {
  2254          if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
  2255              // check if it has the basic requirements of an address
  2256              return false;
  2257          } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
  2258              // If it's all small caps or all caps, return true
  2259              return true;
  2260          } else {
  2261              // Otherwise check each case
  2262              return isChecksumAddress(address);
  2263          }
  2264      };
  2265      
  2266      /**
  2267       * Checks if the given string is a checksummed address
  2268       *
  2269       * @method isChecksumAddress
  2270       * @param {String} address the given HEX address
  2271       * @return {Boolean}
  2272      */
  2273      var isChecksumAddress = function (address) {
  2274          // Check each case
  2275          address = address.replace('0x','');
  2276          var addressHash = sha3(address.toLowerCase());
  2277      
  2278          for (var i = 0; i < 40; i++ ) {
  2279              // the nth letter should be uppercase if the nth digit of casemap is 1
  2280              if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
  2281                  return false;
  2282              }
  2283          }
  2284          return true;
  2285      };
  2286      
  2287      
  2288      
  2289      /**
  2290       * Makes a checksum address
  2291       *
  2292       * @method toChecksumAddress
  2293       * @param {String} address the given HEX address
  2294       * @return {String}
  2295      */
  2296      var toChecksumAddress = function (address) {
  2297          if (typeof address === 'undefined') return '';
  2298      
  2299          address = address.toLowerCase().replace('0x','');
  2300          var addressHash = sha3(address);
  2301          var checksumAddress = '0x';
  2302      
  2303          for (var i = 0; i < address.length; i++ ) {
  2304              // If ith character is 9 to f then make it uppercase
  2305              if (parseInt(addressHash[i], 16) > 7) {
  2306                checksumAddress += address[i].toUpperCase();
  2307              } else {
  2308                  checksumAddress += address[i];
  2309              }
  2310          }
  2311          return checksumAddress;
  2312      };
  2313      
  2314      /**
  2315       * Transforms given string to valid 20 bytes-length addres with 0x prefix
  2316       *
  2317       * @method toAddress
  2318       * @param {String} address
  2319       * @return {String} formatted address
  2320       */
  2321      var toAddress = function (address) {
  2322          if (isStrictAddress(address)) {
  2323              return address;
  2324          }
  2325      
  2326          if (/^[0-9a-f]{40}$/.test(address)) {
  2327              return '0x' + address;
  2328          }
  2329      
  2330          return '0x' + padLeft(toHex(address).substr(2), 40);
  2331      };
  2332      
  2333      /**
  2334       * Returns true if object is BigNumber, otherwise false
  2335       *
  2336       * @method isBigNumber
  2337       * @param {Object}
  2338       * @return {Boolean}
  2339       */
  2340      var isBigNumber = function (object) {
  2341          return object instanceof BigNumber ||
  2342              (object && object.constructor && object.constructor.name === 'BigNumber');
  2343      };
  2344      
  2345      /**
  2346       * Returns true if object is string, otherwise false
  2347       *
  2348       * @method isString
  2349       * @param {Object}
  2350       * @return {Boolean}
  2351       */
  2352      var isString = function (object) {
  2353          return typeof object === 'string' ||
  2354              (object && object.constructor && object.constructor.name === 'String');
  2355      };
  2356      
  2357      /**
  2358       * Returns true if object is function, otherwise false
  2359       *
  2360       * @method isFunction
  2361       * @param {Object}
  2362       * @return {Boolean}
  2363       */
  2364      var isFunction = function (object) {
  2365          return typeof object === 'function';
  2366      };
  2367      
  2368      /**
  2369       * Returns true if object is Objet, otherwise false
  2370       *
  2371       * @method isObject
  2372       * @param {Object}
  2373       * @return {Boolean}
  2374       */
  2375      var isObject = function (object) {
  2376          return object !== null && !(object instanceof Array) && typeof object === 'object';
  2377      };
  2378      
  2379      /**
  2380       * Returns true if object is boolean, otherwise false
  2381       *
  2382       * @method isBoolean
  2383       * @param {Object}
  2384       * @return {Boolean}
  2385       */
  2386      var isBoolean = function (object) {
  2387          return typeof object === 'boolean';
  2388      };
  2389      
  2390      /**
  2391       * Returns true if object is array, otherwise false
  2392       *
  2393       * @method isArray
  2394       * @param {Object}
  2395       * @return {Boolean}
  2396       */
  2397      var isArray = function (object) {
  2398          return object instanceof Array;
  2399      };
  2400      
  2401      /**
  2402       * Returns true if given string is valid json object
  2403       *
  2404       * @method isJson
  2405       * @param {String}
  2406       * @return {Boolean}
  2407       */
  2408      var isJson = function (str) {
  2409          try {
  2410              return !!JSON.parse(str);
  2411          } catch (e) {
  2412              return false;
  2413          }
  2414      };
  2415      
  2416      /**
  2417       * Returns true if given string is a valid Ethereum block header bloom.
  2418       *
  2419       * @method isBloom
  2420       * @param {String} hex encoded bloom filter
  2421       * @return {Boolean}
  2422       */
  2423      var isBloom = function (bloom) {
  2424          if (!/^(0x)?[0-9a-f]{512}$/i.test(bloom)) {
  2425              return false;
  2426          } else if (/^(0x)?[0-9a-f]{512}$/.test(bloom) || /^(0x)?[0-9A-F]{512}$/.test(bloom)) {
  2427              return true;
  2428          }
  2429          return false;
  2430      };
  2431      
  2432      /**
  2433       * Returns true if given string is a valid log topic.
  2434       *
  2435       * @method isTopic
  2436       * @param {String} hex encoded topic
  2437       * @return {Boolean}
  2438       */
  2439      var isTopic = function (topic) {
  2440          if (!/^(0x)?[0-9a-f]{64}$/i.test(topic)) {
  2441              return false;
  2442          } else if (/^(0x)?[0-9a-f]{64}$/.test(topic) || /^(0x)?[0-9A-F]{64}$/.test(topic)) {
  2443              return true;
  2444          }
  2445          return false;
  2446      };
  2447      
  2448      module.exports = {
  2449          padLeft: padLeft,
  2450          padRight: padRight,
  2451          toHex: toHex,
  2452          toDecimal: toDecimal,
  2453          fromDecimal: fromDecimal,
  2454          toUtf8: toUtf8,
  2455          toAscii: toAscii,
  2456          fromUtf8: fromUtf8,
  2457          fromAscii: fromAscii,
  2458          transformToFullName: transformToFullName,
  2459          extractDisplayName: extractDisplayName,
  2460          extractTypeName: extractTypeName,
  2461          toWei: toWei,
  2462          fromWei: fromWei,
  2463          toBigNumber: toBigNumber,
  2464          toTwosComplement: toTwosComplement,
  2465          toAddress: toAddress,
  2466          isBigNumber: isBigNumber,
  2467          isStrictAddress: isStrictAddress,
  2468          isAddress: isAddress,
  2469          isChecksumAddress: isChecksumAddress,
  2470          toChecksumAddress: toChecksumAddress,
  2471          isFunction: isFunction,
  2472          isString: isString,
  2473          isObject: isObject,
  2474          isBoolean: isBoolean,
  2475          isArray: isArray,
  2476          isJson: isJson,
  2477          isBloom: isBloom,
  2478          isTopic: isTopic,
  2479      };
  2480      
  2481      },{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":85}],21:[function(require,module,exports){
  2482      module.exports={
  2483          "version": "0.20.1"
  2484      }
  2485      
  2486      },{}],22:[function(require,module,exports){
  2487      /*
  2488          This file is part of web3.js.
  2489      
  2490          web3.js is free software: you can redistribute it and/or modify
  2491          it under the terms of the GNU Lesser General Public License as published by
  2492          the Free Software Foundation, either version 3 of the License, or
  2493          (at your option) any later version.
  2494      
  2495          web3.js is distributed in the hope that it will be useful,
  2496          but WITHOUT ANY WARRANTY; without even the implied warranty of
  2497          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2498          GNU Lesser General Public License for more details.
  2499      
  2500          You should have received a copy of the GNU Lesser General Public License
  2501          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2502      */
  2503      /**
  2504       * @file web3.js
  2505       * @authors:
  2506       *   Jeffrey Wilcke <jeff@ethdev.com>
  2507       *   Marek Kotewicz <marek@ethdev.com>
  2508       *   Marian Oancea <marian@ethdev.com>
  2509       *   Fabian Vogelsteller <fabian@ethdev.com>
  2510       *   Gav Wood <g@ethdev.com>
  2511       * @date 2014
  2512       */
  2513      
  2514      var RequestManager = require('./web3/requestmanager');
  2515      var Iban = require('./web3/iban');
  2516      var Eth = require('./web3/methods/eth');
  2517      var DB = require('./web3/methods/db');
  2518      var Shh = require('./web3/methods/shh');
  2519      var Net = require('./web3/methods/net');
  2520      var Personal = require('./web3/methods/personal');
  2521      var Swarm = require('./web3/methods/swarm');
  2522      var Settings = require('./web3/settings');
  2523      var version = require('./version.json');
  2524      var utils = require('./utils/utils');
  2525      var sha3 = require('./utils/sha3');
  2526      var extend = require('./web3/extend');
  2527      var Batch = require('./web3/batch');
  2528      var Property = require('./web3/property');
  2529      var HttpProvider = require('./web3/httpprovider');
  2530      var IpcProvider = require('./web3/ipcprovider');
  2531      var BigNumber = require('bignumber.js');
  2532      
  2533      
  2534      
  2535      function Web3 (provider) {
  2536          this._requestManager = new RequestManager(provider);
  2537          this.currentProvider = provider;
  2538          this.eth = new Eth(this);
  2539          this.neat = new Eth(this);
  2540          this.db = new DB(this);
  2541          this.shh = new Shh(this);
  2542          this.net = new Net(this);
  2543          this.personal = new Personal(this);
  2544          this.bzz = new Swarm(this);
  2545          this.settings = new Settings();
  2546          this.version = {
  2547              api: version.version
  2548          };
  2549          this.providers = {
  2550              HttpProvider: HttpProvider,
  2551              IpcProvider: IpcProvider
  2552          };
  2553          this._extend = extend(this);
  2554          this._extend({
  2555              properties: properties()
  2556          });
  2557      }
  2558      
  2559      // expose providers on the class
  2560      Web3.providers = {
  2561          HttpProvider: HttpProvider,
  2562          IpcProvider: IpcProvider
  2563      };
  2564      
  2565      Web3.prototype.setProvider = function (provider) {
  2566          this._requestManager.setProvider(provider);
  2567          this.currentProvider = provider;
  2568      };
  2569      
  2570      Web3.prototype.reset = function (keepIsSyncing) {
  2571          this._requestManager.reset(keepIsSyncing);
  2572          this.settings = new Settings();
  2573      };
  2574      
  2575      Web3.prototype.BigNumber = BigNumber;
  2576      Web3.prototype.toHex = utils.toHex;
  2577      Web3.prototype.toAscii = utils.toAscii;
  2578      Web3.prototype.toUtf8 = utils.toUtf8;
  2579      Web3.prototype.fromAscii = utils.fromAscii;
  2580      Web3.prototype.fromUtf8 = utils.fromUtf8;
  2581      Web3.prototype.toDecimal = utils.toDecimal;
  2582      Web3.prototype.fromDecimal = utils.fromDecimal;
  2583      Web3.prototype.toBigNumber = utils.toBigNumber;
  2584      Web3.prototype.toWei = utils.toWei;
  2585      Web3.prototype.fromWei = utils.fromWei;
  2586      Web3.prototype.isAddress = utils.isAddress;
  2587      Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
  2588      Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
  2589      Web3.prototype.isIBAN = utils.isIBAN;
  2590      Web3.prototype.padLeft = utils.padLeft;
  2591      Web3.prototype.padRight = utils.padRight;
  2592      
  2593      
  2594      Web3.prototype.sha3 = function(string, options) {
  2595          return '0x' + sha3(string, options);
  2596      };
  2597      
  2598      Web3.prototype.getVoteHash =  function(from,pubKey,amount,salt){
  2599          if(pubKey.substr(0, 2) === '0x') pubKey = pubKey.substr(2);
  2600      
  2601          if( (typeof amount) == "string" && amount.substr(0, 2) === '0x'){
  2602              amount = amount.substr(2);
  2603          }else{
  2604              amount = amount.toString("16");
  2605          }
  2606          // like add on 2019,10,21
  2607          var fromCode = "";
  2608          for(var i =0; i < from.length; i++){
  2609              fromCode += from[i].charCodeAt().toString('16');
  2610          }
  2611          amount = (amount.length%2 == 0)?amount:("0"+amount);
  2612          var saltCode = "";
  2613          for(var i=0;i<salt.length;i++){
  2614               saltCode += salt[i].charCodeAt().toString("16");
  2615          }
  2616      
  2617          var  concatString = fromCode+pubKey+amount+saltCode;
  2618          return "0x" + sha3(concatString.toLowerCase(),{encoding: 'hex'});
  2619      };
  2620      
  2621      
  2622      
  2623      
  2624      
  2625      /**
  2626       * Transforms direct icap to address
  2627       */
  2628      Web3.prototype.fromICAP = function (icap) {
  2629          var iban = new Iban(icap);
  2630          return iban.address();
  2631      };
  2632      
  2633      var properties = function () {
  2634          return [
  2635              new Property({
  2636                  name: 'version.node',
  2637                  getter: 'web3_clientVersion'
  2638              }),
  2639              new Property({
  2640                  name: 'version.network',
  2641                  getter: 'net_version',
  2642                  inputFormatter: utils.toDecimal
  2643              }),
  2644              new Property({
  2645                  name: 'version.ethereum',
  2646                  getter: 'eth_protocolVersion',
  2647                  inputFormatter: utils.toDecimal
  2648              }),
  2649              new Property({
  2650                  name: 'version.whisper',
  2651                  getter: 'shh_version',
  2652                  inputFormatter: utils.toDecimal
  2653              })
  2654          ];
  2655      };
  2656      
  2657      Web3.prototype.isConnected = function(){
  2658          return (this.currentProvider && this.currentProvider.isConnected());
  2659      };
  2660      
  2661      Web3.prototype.createBatch = function () {
  2662          return new Batch(this);
  2663      };
  2664      
  2665      module.exports = Web3;
  2666      
  2667      
  2668      },{"./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/methods/swarm":42,"./web3/property":45,"./web3/requestmanager":46,"./web3/settings":47,"bignumber.js":"bignumber.js"}],23:[function(require,module,exports){
  2669      /*
  2670          This file is part of web3.js.
  2671      
  2672          web3.js is free software: you can redistribute it and/or modify
  2673          it under the terms of the GNU Lesser General Public License as published by
  2674          the Free Software Foundation, either version 3 of the License, or
  2675          (at your option) any later version.
  2676      
  2677          web3.js is distributed in the hope that it will be useful,
  2678          but WITHOUT ANY WARRANTY; without even the implied warranty of
  2679          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2680          GNU Lesser General Public License for more details.
  2681      
  2682          You should have received a copy of the GNU Lesser General Public License
  2683          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2684      */
  2685      /**
  2686       * @file allevents.js
  2687       * @author Marek Kotewicz <marek@ethdev.com>
  2688       * @date 2014
  2689       */
  2690      
  2691      var sha3 = require('../utils/sha3');
  2692      var SolidityEvent = require('./event');
  2693      var formatters = require('./formatters');
  2694      var utils = require('../utils/utils');
  2695      var Filter = require('./filter');
  2696      var watches = require('./methods/watches');
  2697      
  2698      var AllSolidityEvents = function (requestManager, json, address) {
  2699          this._requestManager = requestManager;
  2700          this._json = json;
  2701          this._address = address;
  2702      };
  2703      
  2704      AllSolidityEvents.prototype.encode = function (options) {
  2705          options = options || {};
  2706          var result = {};
  2707      
  2708          ['fromBlock', 'toBlock'].filter(function (f) {
  2709              return options[f] !== undefined;
  2710          }).forEach(function (f) {
  2711              result[f] = formatters.inputBlockNumberFormatter(options[f]);
  2712          });
  2713      
  2714          result.address = this._address;
  2715      
  2716          return result;
  2717      };
  2718      
  2719      AllSolidityEvents.prototype.decode = function (data) {
  2720          data.data = data.data || '';
  2721          data.topics = data.topics || [];
  2722      
  2723          var eventTopic = data.topics[0].slice(2);
  2724          var match = this._json.filter(function (j) {
  2725              return eventTopic === sha3(utils.transformToFullName(j));
  2726          })[0];
  2727      
  2728          if (!match) { // cannot find matching event?
  2729              console.warn('cannot find event for log');
  2730              return data;
  2731          }
  2732      
  2733          var event = new SolidityEvent(this._requestManager, match, this._address);
  2734          return event.decode(data);
  2735      };
  2736      
  2737      AllSolidityEvents.prototype.execute = function (options, callback) {
  2738      
  2739          if (utils.isFunction(arguments[arguments.length - 1])) {
  2740              callback = arguments[arguments.length - 1];
  2741              if(arguments.length === 1)
  2742                  options = null;
  2743          }
  2744      
  2745          var o = this.encode(options);
  2746          var formatter = this.decode.bind(this);
  2747          return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
  2748      };
  2749      
  2750      AllSolidityEvents.prototype.attachToContract = function (contract) {
  2751          var execute = this.execute.bind(this);
  2752          contract.allEvents = execute;
  2753      };
  2754      
  2755      module.exports = AllSolidityEvents;
  2756      
  2757      
  2758      },{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":43}],24:[function(require,module,exports){
  2759      /*
  2760          This file is part of web3.js.
  2761      
  2762          web3.js is free software: you can redistribute it and/or modify
  2763          it under the terms of the GNU Lesser General Public License as published by
  2764          the Free Software Foundation, either version 3 of the License, or
  2765          (at your option) any later version.
  2766      
  2767          web3.js is distributed in the hope that it will be useful,
  2768          but WITHOUT ANY WARRANTY; without even the implied warranty of
  2769          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2770          GNU Lesser General Public License for more details.
  2771      
  2772          You should have received a copy of the GNU Lesser General Public License
  2773          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2774      */
  2775      /** 
  2776       * @file batch.js
  2777       * @author Marek Kotewicz <marek@ethdev.com>
  2778       * @date 2015
  2779       */
  2780      
  2781      var Jsonrpc = require('./jsonrpc');
  2782      var errors = require('./errors');
  2783      
  2784      var Batch = function (web3) {
  2785          this.requestManager = web3._requestManager;
  2786          this.requests = [];
  2787      };
  2788      
  2789      /**
  2790       * Should be called to add create new request to batch request
  2791       *
  2792       * @method add
  2793       * @param {Object} jsonrpc requet object
  2794       */
  2795      Batch.prototype.add = function (request) {
  2796          this.requests.push(request);
  2797      };
  2798      
  2799      /**
  2800       * Should be called to execute batch request
  2801       *
  2802       * @method execute
  2803       */
  2804      Batch.prototype.execute = function () {
  2805          var requests = this.requests;
  2806          this.requestManager.sendBatch(requests, function (err, results) {
  2807              results = results || [];
  2808              requests.map(function (request, index) {
  2809                  return results[index] || {};
  2810              }).forEach(function (result, index) {
  2811                  if (requests[index].callback) {
  2812      
  2813                      if (!Jsonrpc.isValidResponse(result)) {
  2814                          return requests[index].callback(errors.InvalidResponse(result));
  2815                      }
  2816      
  2817                      requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));
  2818                  }
  2819              });
  2820          }); 
  2821      };
  2822      
  2823      module.exports = Batch;
  2824      
  2825      
  2826      },{"./errors":26,"./jsonrpc":35}],25:[function(require,module,exports){
  2827      /*
  2828          This file is part of web3.js.
  2829      
  2830          web3.js is free software: you can redistribute it and/or modify
  2831          it under the terms of the GNU Lesser General Public License as published by
  2832          the Free Software Foundation, either version 3 of the License, or
  2833          (at your option) any later version.
  2834      
  2835          web3.js is distributed in the hope that it will be useful,
  2836          but WITHOUT ANY WARRANTY; without even the implied warranty of
  2837          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2838          GNU Lesser General Public License for more details.
  2839      
  2840          You should have received a copy of the GNU Lesser General Public License
  2841          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2842      */
  2843      /**
  2844       * @file contract.js
  2845       * @author Marek Kotewicz <marek@ethdev.com>
  2846       * @date 2014
  2847       */
  2848      
  2849      var utils = require('../utils/utils');
  2850      var coder = require('../solidity/coder');
  2851      var SolidityEvent = require('./event');
  2852      var SolidityFunction = require('./function');
  2853      var AllEvents = require('./allevents');
  2854      
  2855      /**
  2856       * Should be called to encode constructor params
  2857       *
  2858       * @method encodeConstructorParams
  2859       * @param {Array} abi
  2860       * @param {Array} constructor params
  2861       */
  2862      var encodeConstructorParams = function (abi, params) {
  2863          return abi.filter(function (json) {
  2864              return json.type === 'constructor' && json.inputs.length === params.length;
  2865          }).map(function (json) {
  2866              return json.inputs.map(function (input) {
  2867                  return input.type;
  2868              });
  2869          }).map(function (types) {
  2870              return coder.encodeParams(types, params);
  2871          })[0] || '';
  2872      };
  2873      
  2874      /**
  2875       * Should be called to add functions to contract object
  2876       *
  2877       * @method addFunctionsToContract
  2878       * @param {Contract} contract
  2879       * @param {Array} abi
  2880       */
  2881      var addFunctionsToContract = function (contract) {
  2882          contract.abi.filter(function (json) {
  2883              return json.type === 'function';
  2884          }).map(function (json) {
  2885              return new SolidityFunction(contract._eth, json, contract.address);
  2886          }).forEach(function (f) {
  2887              f.attachToContract(contract);
  2888          });
  2889      };
  2890      
  2891      /**
  2892       * Should be called to add events to contract object
  2893       *
  2894       * @method addEventsToContract
  2895       * @param {Contract} contract
  2896       * @param {Array} abi
  2897       */
  2898      var addEventsToContract = function (contract) {
  2899          var events = contract.abi.filter(function (json) {
  2900              return json.type === 'event';
  2901          });
  2902      
  2903          var All = new AllEvents(contract._eth._requestManager, events, contract.address);
  2904          All.attachToContract(contract);
  2905      
  2906          events.map(function (json) {
  2907              return new SolidityEvent(contract._eth._requestManager, json, contract.address);
  2908          }).forEach(function (e) {
  2909              e.attachToContract(contract);
  2910          });
  2911      };
  2912      
  2913      
  2914      /**
  2915       * Should be called to check if the contract gets properly deployed on the blockchain.
  2916       *
  2917       * @method checkForContractAddress
  2918       * @param {Object} contract
  2919       * @param {Function} callback
  2920       * @returns {Undefined}
  2921       */
  2922      var checkForContractAddress = function(contract, callback){
  2923          var count = 0,
  2924              callbackFired = false;
  2925      
  2926          // wait for receipt
  2927          var filter = contract._eth.filter('latest', function(e){
  2928              if (!e && !callbackFired) {
  2929                  count++;
  2930      
  2931                  // stop watching after 50 blocks (timeout)
  2932                  if (count > 50) {
  2933      
  2934                      filter.stopWatching(function() {});
  2935                      callbackFired = true;
  2936      
  2937                      if (callback)
  2938                          callback(new Error('Contract transaction couldn\'t be found after 50 blocks'));
  2939                      else
  2940                          throw new Error('Contract transaction couldn\'t be found after 50 blocks');
  2941      
  2942      
  2943                  } else {
  2944      
  2945                      contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
  2946                          if(receipt && !callbackFired) {
  2947      
  2948                              contract._eth.getCode(receipt.contractAddress, function(e, code){
  2949                                  /*jshint maxcomplexity: 6 */
  2950      
  2951                                  if(callbackFired || !code)
  2952                                      return;
  2953      
  2954                                  filter.stopWatching(function() {});
  2955                                  callbackFired = true;
  2956      
  2957                                  if(code.length > 3) {
  2958      
  2959                                      // console.log('Contract code deployed!');
  2960      
  2961                                      contract.address = receipt.contractAddress;
  2962      
  2963                                      // attach events and methods again after we have
  2964                                      addFunctionsToContract(contract);
  2965                                      addEventsToContract(contract);
  2966      
  2967                                      // call callback for the second time
  2968                                      if(callback)
  2969                                          callback(null, contract);
  2970      
  2971                                  } else {
  2972                                      if(callback)
  2973                                          callback(new Error('The contract code couldn\'t be stored, please check your gas amount.'));
  2974                                      else
  2975                                          throw new Error('The contract code couldn\'t be stored, please check your gas amount.');
  2976                                  }
  2977                              });
  2978                          }
  2979                      });
  2980                  }
  2981              }
  2982          });
  2983      };
  2984      
  2985      /**
  2986       * Should be called to create new ContractFactory instance
  2987       *
  2988       * @method ContractFactory
  2989       * @param {Array} abi
  2990       */
  2991      var ContractFactory = function (eth, abi) {
  2992          this.eth = eth;
  2993          this.abi = abi;
  2994      
  2995          /**
  2996           * Should be called to create new contract on a blockchain
  2997           *
  2998           * @method new
  2999           * @param {Any} contract constructor param1 (optional)
  3000           * @param {Any} contract constructor param2 (optional)
  3001           * @param {Object} contract transaction object (required)
  3002           * @param {Function} callback
  3003           * @returns {Contract} returns contract instance
  3004           */
  3005          this.new = function () {
  3006              /*jshint maxcomplexity: 7 */
  3007              
  3008              var contract = new Contract(this.eth, this.abi);
  3009      
  3010              // parse arguments
  3011              var options = {}; // required!
  3012              var callback;
  3013      
  3014              var args = Array.prototype.slice.call(arguments);
  3015              if (utils.isFunction(args[args.length - 1])) {
  3016                  callback = args.pop();
  3017              }
  3018      
  3019              var last = args[args.length - 1];
  3020              if (utils.isObject(last) && !utils.isArray(last)) {
  3021                  options = args.pop();
  3022              }
  3023      
  3024              if (options.value > 0) {
  3025                  var constructorAbi = abi.filter(function (json) {
  3026                      return json.type === 'constructor' && json.inputs.length === args.length;
  3027                  })[0] || {};
  3028      
  3029                  if (!constructorAbi.payable) {
  3030                      throw new Error('Cannot send value to non-payable constructor');
  3031                  }
  3032              }
  3033      
  3034              var bytes = encodeConstructorParams(this.abi, args);
  3035              options.data += bytes;
  3036      
  3037              if (callback) {
  3038      
  3039                  // wait for the contract address and check if the code was deployed
  3040                  this.eth.sendTransaction(options, function (err, hash) {
  3041                      if (err) {
  3042                          callback(err);
  3043                      } else {
  3044                          // add the transaction hash
  3045                          contract.transactionHash = hash;
  3046      
  3047                          // call callback for the first time
  3048                          callback(null, contract);
  3049      
  3050                          checkForContractAddress(contract, callback);
  3051                      }
  3052                  });
  3053              } else {
  3054                  var hash = this.eth.sendTransaction(options);
  3055                  // add the transaction hash
  3056                  contract.transactionHash = hash;
  3057                  checkForContractAddress(contract);
  3058              }
  3059      
  3060              return contract;
  3061          };
  3062      
  3063          this.new.getData = this.getData.bind(this);
  3064      };
  3065      
  3066      /**
  3067       * Should be called to create new ContractFactory
  3068       *
  3069       * @method contract
  3070       * @param {Array} abi
  3071       * @returns {ContractFactory} new contract factory
  3072       */
  3073      //var contract = function (abi) {
  3074          //return new ContractFactory(abi);
  3075      //};
  3076      
  3077      
  3078      
  3079      /**
  3080       * Should be called to get access to existing contract on a blockchain
  3081       *
  3082       * @method at
  3083       * @param {Address} contract address (required)
  3084       * @param {Function} callback {optional)
  3085       * @returns {Contract} returns contract if no callback was passed,
  3086       * otherwise calls callback function (err, contract)
  3087       */
  3088      ContractFactory.prototype.at = function (address, callback) {
  3089          var contract = new Contract(this.eth, this.abi, address);
  3090      
  3091          // this functions are not part of prototype,
  3092          // because we don't want to spoil the interface
  3093          addFunctionsToContract(contract);
  3094          addEventsToContract(contract);
  3095      
  3096          if (callback) {
  3097              callback(null, contract);
  3098          }
  3099          return contract;
  3100      };
  3101      
  3102      /**
  3103       * Gets the data, which is data to deploy plus constructor params
  3104       *
  3105       * @method getData
  3106       */
  3107      ContractFactory.prototype.getData = function () {
  3108          var options = {}; // required!
  3109          var args = Array.prototype.slice.call(arguments);
  3110      
  3111          var last = args[args.length - 1];
  3112          if (utils.isObject(last) && !utils.isArray(last)) {
  3113              options = args.pop();
  3114          }
  3115      
  3116          var bytes = encodeConstructorParams(this.abi, args);
  3117          options.data += bytes;
  3118      
  3119          return options.data;
  3120      };
  3121      
  3122      /**
  3123       * Should be called to create new contract instance
  3124       *
  3125       * @method Contract
  3126       * @param {Array} abi
  3127       * @param {Address} contract address
  3128       */
  3129      var Contract = function (eth, abi, address) {
  3130          this._eth = eth;
  3131          this.transactionHash = null;
  3132          this.address = address;
  3133          this.abi = abi;
  3134      };
  3135      
  3136      module.exports = ContractFactory;
  3137      
  3138      },{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(require,module,exports){
  3139      /*
  3140          This file is part of web3.js.
  3141      
  3142          web3.js is free software: you can redistribute it and/or modify
  3143          it under the terms of the GNU Lesser General Public License as published by
  3144          the Free Software Foundation, either version 3 of the License, or
  3145          (at your option) any later version.
  3146      
  3147          web3.js is distributed in the hope that it will be useful,
  3148          but WITHOUT ANY WARRANTY; without even the implied warranty of
  3149          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3150          GNU Lesser General Public License for more details.
  3151      
  3152          You should have received a copy of the GNU Lesser General Public License
  3153          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3154      */
  3155      /** 
  3156       * @file errors.js
  3157       * @author Marek Kotewicz <marek@ethdev.com>
  3158       * @date 2015
  3159       */
  3160      
  3161      module.exports = {
  3162          InvalidNumberOfSolidityArgs: function () {
  3163              return new Error('Invalid number of arguments to Solidity function');
  3164          },
  3165          InvalidNumberOfRPCParams: function () {
  3166              return new Error('Invalid number of input parameters to RPC method');
  3167          },
  3168          InvalidConnection: function (host){
  3169              return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
  3170          },
  3171          InvalidProvider: function () {
  3172              return new Error('Provider not set or invalid');
  3173          },
  3174          InvalidResponse: function (result){
  3175              var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);
  3176              return new Error(message);
  3177          },
  3178          ConnectionTimeout: function (ms){
  3179              return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived');
  3180          }
  3181      };
  3182      
  3183      },{}],27:[function(require,module,exports){
  3184      /*
  3185          This file is part of web3.js.
  3186      
  3187          web3.js is free software: you can redistribute it and/or modify
  3188          it under the terms of the GNU Lesser General Public License as published by
  3189          the Free Software Foundation, either version 3 of the License, or
  3190          (at your option) any later version.
  3191      
  3192          web3.js is distributed in the hope that it will be useful,
  3193          but WITHOUT ANY WARRANTY; without even the implied warranty of
  3194          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3195          GNU Lesser General Public License for more details.
  3196      
  3197          You should have received a copy of the GNU Lesser General Public License
  3198          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3199      */
  3200      /**
  3201       * @file event.js
  3202       * @author Marek Kotewicz <marek@ethdev.com>
  3203       * @date 2014
  3204       */
  3205      
  3206      var utils = require('../utils/utils');
  3207      var coder = require('../solidity/coder');
  3208      var formatters = require('./formatters');
  3209      var sha3 = require('../utils/sha3');
  3210      var Filter = require('./filter');
  3211      var watches = require('./methods/watches');
  3212      
  3213      /**
  3214       * This prototype should be used to create event filters
  3215       */
  3216      var SolidityEvent = function (requestManager, json, address) {
  3217          this._requestManager = requestManager;
  3218          this._params = json.inputs;
  3219          this._name = utils.transformToFullName(json);
  3220          this._address = address;
  3221          this._anonymous = json.anonymous;
  3222      };
  3223      
  3224      /**
  3225       * Should be used to get filtered param types
  3226       *
  3227       * @method types
  3228       * @param {Bool} decide if returned typed should be indexed
  3229       * @return {Array} array of types
  3230       */
  3231      SolidityEvent.prototype.types = function (indexed) {
  3232          return this._params.filter(function (i) {
  3233              return i.indexed === indexed;
  3234          }).map(function (i) {
  3235              return i.type;
  3236          });
  3237      };
  3238      
  3239      /**
  3240       * Should be used to get event display name
  3241       *
  3242       * @method displayName
  3243       * @return {String} event display name
  3244       */
  3245      SolidityEvent.prototype.displayName = function () {
  3246          return utils.extractDisplayName(this._name);
  3247      };
  3248      
  3249      /**
  3250       * Should be used to get event type name
  3251       *
  3252       * @method typeName
  3253       * @return {String} event type name
  3254       */
  3255      SolidityEvent.prototype.typeName = function () {
  3256          return utils.extractTypeName(this._name);
  3257      };
  3258      
  3259      /**
  3260       * Should be used to get event signature
  3261       *
  3262       * @method signature
  3263       * @return {String} event signature
  3264       */
  3265      SolidityEvent.prototype.signature = function () {
  3266          return sha3(this._name);
  3267      };
  3268      
  3269      /**
  3270       * Should be used to encode indexed params and options to one final object
  3271       *
  3272       * @method encode
  3273       * @param {Object} indexed
  3274       * @param {Object} options
  3275       * @return {Object} everything combined together and encoded
  3276       */
  3277      SolidityEvent.prototype.encode = function (indexed, options) {
  3278          indexed = indexed || {};
  3279          options = options || {};
  3280          var result = {};
  3281      
  3282          ['fromBlock', 'toBlock'].filter(function (f) {
  3283              return options[f] !== undefined;
  3284          }).forEach(function (f) {
  3285              result[f] = formatters.inputBlockNumberFormatter(options[f]);
  3286          });
  3287      
  3288          result.topics = [];
  3289      
  3290          result.address = this._address;
  3291          if (!this._anonymous) {
  3292              result.topics.push('0x' + this.signature());
  3293          }
  3294      
  3295          var indexedTopics = this._params.filter(function (i) {
  3296              return i.indexed === true;
  3297          }).map(function (i) {
  3298              var value = indexed[i.name];
  3299              if (value === undefined || value === null) {
  3300                  return null;
  3301              }
  3302      
  3303              if (utils.isArray(value)) {
  3304                  return value.map(function (v) {
  3305                      return '0x' + coder.encodeParam(i.type, v);
  3306                  });
  3307              }
  3308              return '0x' + coder.encodeParam(i.type, value);
  3309          });
  3310      
  3311          result.topics = result.topics.concat(indexedTopics);
  3312      
  3313          return result;
  3314      };
  3315      
  3316      /**
  3317       * Should be used to decode indexed params and options
  3318       *
  3319       * @method decode
  3320       * @param {Object} data
  3321       * @return {Object} result object with decoded indexed && not indexed params
  3322       */
  3323      SolidityEvent.prototype.decode = function (data) {
  3324      
  3325          data.data = data.data || '';
  3326          data.topics = data.topics || [];
  3327      
  3328          var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
  3329          var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
  3330          var indexedParams = coder.decodeParams(this.types(true), indexedData);
  3331      
  3332          var notIndexedData = data.data.slice(2);
  3333          var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
  3334      
  3335          var result = formatters.outputLogFormatter(data);
  3336          result.event = this.displayName();
  3337          result.address = data.address;
  3338      
  3339          result.args = this._params.reduce(function (acc, current) {
  3340              acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();
  3341              return acc;
  3342          }, {});
  3343      
  3344          delete result.data;
  3345          delete result.topics;
  3346      
  3347          return result;
  3348      };
  3349      
  3350      /**
  3351       * Should be used to create new filter object from event
  3352       *
  3353       * @method execute
  3354       * @param {Object} indexed
  3355       * @param {Object} options
  3356       * @return {Object} filter object
  3357       */
  3358      SolidityEvent.prototype.execute = function (indexed, options, callback) {
  3359      
  3360          if (utils.isFunction(arguments[arguments.length - 1])) {
  3361              callback = arguments[arguments.length - 1];
  3362              if(arguments.length === 2)
  3363                  options = null;
  3364              if(arguments.length === 1) {
  3365                  options = null;
  3366                  indexed = {};
  3367              }
  3368          }
  3369      
  3370          var o = this.encode(indexed, options);
  3371          var formatter = this.decode.bind(this);
  3372          return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
  3373      };
  3374      
  3375      /**
  3376       * Should be used to attach event to contract object
  3377       *
  3378       * @method attachToContract
  3379       * @param {Contract}
  3380       */
  3381      SolidityEvent.prototype.attachToContract = function (contract) {
  3382          var execute = this.execute.bind(this);
  3383          var displayName = this.displayName();
  3384          if (!contract[displayName]) {
  3385              contract[displayName] = execute;
  3386          }
  3387          contract[displayName][this.typeName()] = this.execute.bind(this, contract);
  3388      };
  3389      
  3390      module.exports = SolidityEvent;
  3391      
  3392      
  3393      },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":43}],28:[function(require,module,exports){
  3394      var formatters = require('./formatters');
  3395      var utils = require('./../utils/utils');
  3396      var Method = require('./method');
  3397      var Property = require('./property');
  3398      
  3399      // TODO: refactor, so the input params are not altered.
  3400      // it's necessary to make same 'extension' work with multiple providers
  3401      var extend = function (web3) {
  3402          /* jshint maxcomplexity:5 */
  3403          var ex = function (extension) {
  3404      
  3405              var extendedObject;
  3406              if (extension.property) {
  3407                  if (!web3[extension.property]) {
  3408                      web3[extension.property] = {};
  3409                  }
  3410                  extendedObject = web3[extension.property];
  3411              } else {
  3412                  extendedObject = web3;
  3413              }
  3414      
  3415              if (extension.methods) {
  3416                  extension.methods.forEach(function (method) {
  3417                      method.attachToObject(extendedObject);
  3418                      method.setRequestManager(web3._requestManager);
  3419                  });
  3420              }
  3421      
  3422              if (extension.properties) {
  3423                  extension.properties.forEach(function (property) {
  3424                      property.attachToObject(extendedObject);
  3425                      property.setRequestManager(web3._requestManager);
  3426                  });
  3427              }
  3428          };
  3429      
  3430          ex.formatters = formatters; 
  3431          ex.utils = utils;
  3432          ex.Method = Method;
  3433          ex.Property = Property;
  3434      
  3435          return ex;
  3436      };
  3437      
  3438      
  3439      
  3440      module.exports = extend;
  3441      
  3442      
  3443      },{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":45}],29:[function(require,module,exports){
  3444      /*
  3445          This file is part of web3.js.
  3446      
  3447          web3.js is free software: you can redistribute it and/or modify
  3448          it under the terms of the GNU Lesser General Public License as published by
  3449          the Free Software Foundation, either version 3 of the License, or
  3450          (at your option) any later version.
  3451      
  3452          web3.js is distributed in the hope that it will be useful,
  3453          but WITHOUT ANY WARRANTY; without even the implied warranty of
  3454          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3455          GNU Lesser General Public License for more details.
  3456      
  3457          You should have received a copy of the GNU Lesser General Public License
  3458          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3459      */
  3460      /** @file filter.js
  3461       * @authors:
  3462       *   Jeffrey Wilcke <jeff@ethdev.com>
  3463       *   Marek Kotewicz <marek@ethdev.com>
  3464       *   Marian Oancea <marian@ethdev.com>
  3465       *   Fabian Vogelsteller <fabian@ethdev.com>
  3466       *   Gav Wood <g@ethdev.com>
  3467       * @date 2014
  3468       */
  3469      
  3470      var formatters = require('./formatters');
  3471      var utils = require('../utils/utils');
  3472      
  3473      /**
  3474      * Converts a given topic to a hex string, but also allows null values.
  3475      *
  3476      * @param {Mixed} value
  3477      * @return {String}
  3478      */
  3479      var toTopic = function(value){
  3480      
  3481          if(value === null || typeof value === 'undefined')
  3482              return null;
  3483      
  3484          value = String(value);
  3485      
  3486          if(value.indexOf('0x') === 0)
  3487              return value;
  3488          else
  3489              return utils.fromUtf8(value);
  3490      };
  3491      
  3492      /// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
  3493      /// @param should be string or object
  3494      /// @returns options string or object
  3495      var getOptions = function (options, type) {
  3496          /*jshint maxcomplexity: 6 */
  3497      
  3498          if (utils.isString(options)) {
  3499              return options;
  3500          }
  3501      
  3502          options = options || {};
  3503      
  3504      
  3505          switch(type) {
  3506              case 'eth':
  3507      
  3508                  // make sure topics, get converted to hex
  3509                  options.topics = options.topics || [];
  3510                  options.topics = options.topics.map(function(topic){
  3511                      return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
  3512                  });
  3513      
  3514                  return {
  3515                      topics: options.topics,
  3516                      from: options.from,
  3517                      to: options.to,
  3518                      address: options.address,
  3519                      fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
  3520                      toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
  3521                  };
  3522              case 'shh':
  3523                  return options;
  3524          }
  3525      };
  3526      
  3527      /**
  3528      Adds the callback and sets up the methods, to iterate over the results.
  3529      
  3530      @method getLogsAtStart
  3531      @param {Object} self
  3532      @param {function} callback
  3533      */
  3534      var getLogsAtStart = function(self, callback){
  3535          // call getFilterLogs for the first watch callback start
  3536          if (!utils.isString(self.options)) {
  3537              self.get(function (err, messages) {
  3538                  // don't send all the responses to all the watches again... just to self one
  3539                  if (err) {
  3540                      callback(err);
  3541                  }
  3542      
  3543                  if(utils.isArray(messages)) {
  3544                      messages.forEach(function (message) {
  3545                          callback(null, message);
  3546                      });
  3547                  }
  3548              });
  3549          }
  3550      };
  3551      
  3552      /**
  3553      Adds the callback and sets up the methods, to iterate over the results.
  3554      
  3555      @method pollFilter
  3556      @param {Object} self
  3557      */
  3558      var pollFilter = function(self) {
  3559      
  3560          var onMessage = function (error, messages) {
  3561              if (error) {
  3562                  return self.callbacks.forEach(function (callback) {
  3563                      callback(error);
  3564                  });
  3565              }
  3566      
  3567              if(utils.isArray(messages)) {
  3568                  messages.forEach(function (message) {
  3569                      message = self.formatter ? self.formatter(message) : message;
  3570                      self.callbacks.forEach(function (callback) {
  3571                          callback(null, message);
  3572                      });
  3573                  });
  3574              }
  3575          };
  3576      
  3577          self.requestManager.startPolling({
  3578              method: self.implementation.poll.call,
  3579              params: [self.filterId],
  3580          }, self.filterId, onMessage, self.stopWatching.bind(self));
  3581      
  3582      };
  3583      
  3584      var Filter = function (options, type, requestManager, methods, formatter, callback, filterCreationErrorCallback) {
  3585          var self = this;
  3586          var implementation = {};
  3587          methods.forEach(function (method) {
  3588              method.setRequestManager(requestManager);
  3589              method.attachToObject(implementation);
  3590          });
  3591          this.requestManager = requestManager;
  3592          this.options = getOptions(options, type);
  3593          this.implementation = implementation;
  3594          this.filterId = null;
  3595          this.callbacks = [];
  3596          this.getLogsCallbacks = [];
  3597          this.pollFilters = [];
  3598          this.formatter = formatter;
  3599          this.implementation.newFilter(this.options, function(error, id){
  3600              if(error) {
  3601                  self.callbacks.forEach(function(cb){
  3602                      cb(error);
  3603                  });
  3604                  if (typeof filterCreationErrorCallback === 'function') {
  3605                    filterCreationErrorCallback(error);
  3606                  }
  3607              } else {
  3608                  self.filterId = id;
  3609      
  3610                  // check if there are get pending callbacks as a consequence
  3611                  // of calling get() with filterId unassigned.
  3612                  self.getLogsCallbacks.forEach(function (cb){
  3613                      self.get(cb);
  3614                  });
  3615                  self.getLogsCallbacks = [];
  3616      
  3617                  // get filter logs for the already existing watch calls
  3618                  self.callbacks.forEach(function(cb){
  3619                      getLogsAtStart(self, cb);
  3620                  });
  3621                  if(self.callbacks.length > 0)
  3622                      pollFilter(self);
  3623      
  3624                  // start to watch immediately
  3625                  if(typeof callback === 'function') {
  3626                      return self.watch(callback);
  3627                  }
  3628              }
  3629          });
  3630      
  3631          return this;
  3632      };
  3633      
  3634      Filter.prototype.watch = function (callback) {
  3635          this.callbacks.push(callback);
  3636      
  3637          if(this.filterId) {
  3638              getLogsAtStart(this, callback);
  3639              pollFilter(this);
  3640          }
  3641      
  3642          return this;
  3643      };
  3644      
  3645      Filter.prototype.stopWatching = function (callback) {
  3646          this.requestManager.stopPolling(this.filterId);
  3647          this.callbacks = [];
  3648          // remove filter async
  3649          if (callback) {
  3650              this.implementation.uninstallFilter(this.filterId, callback);
  3651          } else {
  3652              return this.implementation.uninstallFilter(this.filterId);
  3653          }
  3654      };
  3655      
  3656      Filter.prototype.get = function (callback) {
  3657          var self = this;
  3658          if (utils.isFunction(callback)) {
  3659              if (this.filterId === null) {
  3660                  // If filterId is not set yet, call it back
  3661                  // when newFilter() assigns it.
  3662                  this.getLogsCallbacks.push(callback);
  3663              } else {
  3664                  this.implementation.getLogs(this.filterId, function(err, res){
  3665                      if (err) {
  3666                          callback(err);
  3667                      } else {
  3668                          callback(null, res.map(function (log) {
  3669                              return self.formatter ? self.formatter(log) : log;
  3670                          }));
  3671                      }
  3672                  });
  3673              }
  3674          } else {
  3675              if (this.filterId === null) {
  3676                  throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.');
  3677              }
  3678              var logs = this.implementation.getLogs(this.filterId);
  3679              return logs.map(function (log) {
  3680                  return self.formatter ? self.formatter(log) : log;
  3681              });
  3682          }
  3683      
  3684          return this;
  3685      };
  3686      
  3687      module.exports = Filter;
  3688      
  3689      
  3690      },{"../utils/utils":20,"./formatters":30}],30:[function(require,module,exports){
  3691      'use strict'
  3692      
  3693      /*
  3694          This file is part of web3.js.
  3695      
  3696          web3.js is free software: you can redistribute it and/or modify
  3697          it under the terms of the GNU Lesser General Public License as published by
  3698          the Free Software Foundation, either version 3 of the License, or
  3699          (at your option) any later version.
  3700      
  3701          web3.js is distributed in the hope that it will be useful,
  3702          but WITHOUT ANY WARRANTY; without even the implied warranty of
  3703          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3704          GNU Lesser General Public License for more details.
  3705      
  3706          You should have received a copy of the GNU Lesser General Public License
  3707          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3708      */
  3709      /**
  3710       * @file formatters.js
  3711       * @author Marek Kotewicz <marek@ethdev.com>
  3712       * @author Fabian Vogelsteller <fabian@ethdev.com>
  3713       * @date 2015
  3714       */
  3715      
  3716      var utils = require('../utils/utils');
  3717      var config = require('../utils/config');
  3718      var Iban = require('./iban');
  3719      
  3720      /**
  3721       * Should the format output to a big number
  3722       *
  3723       * @method outputBigNumberFormatter
  3724       * @param {String|Number|BigNumber}
  3725       * @returns {BigNumber} object
  3726       */
  3727      var outputBigNumberFormatter = function (number) {
  3728          return utils.toBigNumber(number);
  3729      };
  3730      
  3731      var isPredefinedBlockNumber = function (blockNumber) {
  3732          return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
  3733      };
  3734      
  3735      var inputDefaultBlockNumberFormatter = function (blockNumber) {
  3736          if (blockNumber === undefined) {
  3737              return config.defaultBlock;
  3738          }
  3739          return inputBlockNumberFormatter(blockNumber);
  3740      };
  3741      
  3742      var inputBlockNumberFormatter = function (blockNumber) {
  3743          if (blockNumber === undefined) {
  3744              return undefined;
  3745          } else if (isPredefinedBlockNumber(blockNumber)) {
  3746              return blockNumber;
  3747          }
  3748          return utils.toHex(blockNumber);
  3749      };
  3750      
  3751      /**
  3752       * Formats the input of a transaction and converts all values to HEX
  3753       *
  3754       * @method inputCallFormatter
  3755       * @param {Object} transaction options
  3756       * @returns object
  3757      */
  3758      var inputCallFormatter = function (options){
  3759      
  3760          options.from = options.from || config.defaultAccount;
  3761      
  3762          if (options.from) {
  3763              options.from = inputAddressFormatter(options.from);
  3764          }
  3765      
  3766          if (options.to) { // it might be contract creation
  3767              options.to = inputAddressFormatter(options.to);
  3768          }
  3769      
  3770          ['maxFeePerGas', 'maxPriorityFeePerGas', 'gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3771              return options[key] !== undefined;
  3772          }).forEach(function(key){
  3773              options[key] = utils.fromDecimal(options[key]);
  3774          });
  3775      
  3776          return options;
  3777      };
  3778      
  3779      /**
  3780       * Formats the input of a transaction and converts all values to HEX
  3781       *
  3782       * @method inputTransactionFormatter
  3783       * @param {Object} transaction options
  3784       * @returns object
  3785      */
  3786      var inputTransactionFormatter = function (options){
  3787      
  3788          options.from = options.from || config.defaultAccount;
  3789          options.from = inputAddressFormatter(options.from);
  3790      
  3791          if (options.to) { // it might be contract creation
  3792              options.to = inputAddressFormatter(options.to);
  3793          }
  3794      
  3795          ['maxFeePerGas', 'maxPriorityFeePerGas', 'gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3796              return options[key] !== undefined;
  3797          }).forEach(function(key){
  3798              options[key] = utils.fromDecimal(options[key]);
  3799          });
  3800      
  3801          return options;
  3802      };
  3803      
  3804      /**
  3805       * Formats the output of a transaction to its proper values
  3806       *
  3807       * @method outputTransactionFormatter
  3808       * @param {Object} tx
  3809       * @returns {Object}
  3810      */
  3811      var outputTransactionFormatter = function (tx){
  3812          if(tx.blockNumber !== null)
  3813              tx.blockNumber = utils.toDecimal(tx.blockNumber);
  3814          if(tx.transactionIndex !== null)
  3815              tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
  3816          tx.nonce = utils.toDecimal(tx.nonce);
  3817          tx.gas = utils.toDecimal(tx.gas);
  3818          tx.gasPrice = utils.toBigNumber(tx.gasPrice);
  3819          if(tx.maxFeePerGas !== undefined) {
  3820            tx.maxFeePerGas = utils.toBigNumber(tx.maxFeePerGas);
  3821          }
  3822          if(tx.maxPriorityFeePerGas !== undefined) {
  3823            tx.maxPriorityFeePerGas = utils.toBigNumber(tx.maxPriorityFeePerGas);
  3824          }
  3825          tx.value = utils.toBigNumber(tx.value);
  3826          return tx;
  3827      };
  3828      
  3829      /**
  3830       * Formats the output of a transaction receipt to its proper values
  3831       *
  3832       * @method outputTransactionReceiptFormatter
  3833       * @param {Object} receipt
  3834       * @returns {Object}
  3835      */
  3836      var outputTransactionReceiptFormatter = function (receipt){
  3837          if(receipt.blockNumber !== null)
  3838              receipt.blockNumber = utils.toDecimal(receipt.blockNumber);
  3839          if(receipt.transactionIndex !== null)
  3840              receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
  3841          receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
  3842          receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
  3843          if(receipt.effectiveGasPrice !== undefined) {
  3844            receipt.effectiveGasPrice = utils.toBigNumber(receipt.effectiveGasPrice);
  3845          }
  3846          if(utils.isArray(receipt.logs)) {
  3847              receipt.logs = receipt.logs.map(function(log){
  3848                  return outputLogFormatter(log);
  3849              });
  3850          }
  3851      
  3852          return receipt;
  3853      };
  3854      
  3855      /**
  3856       * Formats the output of a block to its proper values
  3857       *
  3858       * @method outputBlockFormatter
  3859       * @param {Object} block
  3860       * @returns {Object}
  3861      */
  3862      var outputBlockFormatter = function(block) {
  3863          // transform to number
  3864          if (block.baseFeePerGas !== undefined) {
  3865            block.baseFeePerGas = utils.toBigNumber(block.baseFeePerGas);
  3866          }
  3867          block.gasLimit = utils.toDecimal(block.gasLimit);
  3868          block.gasUsed = utils.toDecimal(block.gasUsed);
  3869          block.size = utils.toDecimal(block.size);
  3870          block.timestamp = utils.toDecimal(block.timestamp);
  3871          if(block.number !== null)
  3872              block.number = utils.toDecimal(block.number);
  3873      
  3874          block.difficulty = utils.toBigNumber(block.difficulty);
  3875          block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
  3876      
  3877          if (utils.isArray(block.transactions)) {
  3878              block.transactions.forEach(function(item){
  3879                  if(!utils.isString(item))
  3880                      return outputTransactionFormatter(item);
  3881              });
  3882          }
  3883      
  3884          return block;
  3885      };
  3886      
  3887      /**
  3888       * Formats the output of a log
  3889       *
  3890       * @method outputLogFormatter
  3891       * @param {Object} log object
  3892       * @returns {Object} log
  3893      */
  3894      var outputLogFormatter = function(log) {
  3895          if(log.blockNumber)
  3896              log.blockNumber = utils.toDecimal(log.blockNumber);
  3897          if(log.transactionIndex)
  3898              log.transactionIndex = utils.toDecimal(log.transactionIndex);
  3899          if(log.logIndex)
  3900              log.logIndex = utils.toDecimal(log.logIndex);
  3901      
  3902          return log;
  3903      };
  3904      
  3905      /**
  3906       * Formats the input of a whisper post and converts all values to HEX
  3907       *
  3908       * @method inputPostFormatter
  3909       * @param {Object} transaction object
  3910       * @returns {Object}
  3911      */
  3912      var inputPostFormatter = function(post) {
  3913      
  3914          // post.payload = utils.toHex(post.payload);
  3915          post.ttl = utils.fromDecimal(post.ttl);
  3916          post.workToProve = utils.fromDecimal(post.workToProve);
  3917          post.priority = utils.fromDecimal(post.priority);
  3918      
  3919          // fallback
  3920          if (!utils.isArray(post.topics)) {
  3921              post.topics = post.topics ? [post.topics] : [];
  3922          }
  3923      
  3924          // format the following options
  3925          post.topics = post.topics.map(function(topic){
  3926              // convert only if not hex
  3927              return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);
  3928          });
  3929      
  3930          return post;
  3931      };
  3932      
  3933      /**
  3934       * Formats the output of a received post message
  3935       *
  3936       * @method outputPostFormatter
  3937       * @param {Object}
  3938       * @returns {Object}
  3939       */
  3940      var outputPostFormatter = function(post){
  3941      
  3942          post.expiry = utils.toDecimal(post.expiry);
  3943          post.sent = utils.toDecimal(post.sent);
  3944          post.ttl = utils.toDecimal(post.ttl);
  3945          post.workProved = utils.toDecimal(post.workProved);
  3946          // post.payloadRaw = post.payload;
  3947          // post.payload = utils.toAscii(post.payload);
  3948      
  3949          // if (utils.isJson(post.payload)) {
  3950          //     post.payload = JSON.parse(post.payload);
  3951          // }
  3952      
  3953          // format the following options
  3954          if (!post.topics) {
  3955              post.topics = [];
  3956          }
  3957          post.topics = post.topics.map(function(topic){
  3958              return utils.toAscii(topic);
  3959          });
  3960      
  3961          return post;
  3962      };
  3963      
  3964      var inputAddressFormatter = function (address) {
  3965          var iban = new Iban(address);
  3966          if (iban.isValid() && iban.isDirect()) {
  3967              return '0x' + iban.address();
  3968          } else if (utils.isStrictAddress(address)) {
  3969              return address;
  3970          } else if (utils.isAddress(address)) {
  3971              return '0x' + address;
  3972          }
  3973          throw new Error('invalid address');
  3974      };
  3975      
  3976      
  3977      var outputSyncingFormatter = function(result) {
  3978          if (!result) {
  3979              return result;
  3980          }
  3981      
  3982          result.startingBlock = utils.toDecimal(result.startingBlock);
  3983          result.currentBlock = utils.toDecimal(result.currentBlock);
  3984          result.highestBlock = utils.toDecimal(result.highestBlock);
  3985          if (result.knownStates) {
  3986              result.knownStates = utils.toDecimal(result.knownStates);
  3987              result.pulledStates = utils.toDecimal(result.pulledStates);
  3988          }
  3989      
  3990          return result;
  3991      };
  3992      
  3993      module.exports = {
  3994          inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
  3995          inputBlockNumberFormatter: inputBlockNumberFormatter,
  3996          inputCallFormatter: inputCallFormatter,
  3997          inputTransactionFormatter: inputTransactionFormatter,
  3998          inputAddressFormatter: inputAddressFormatter,
  3999          inputPostFormatter: inputPostFormatter,
  4000          outputBigNumberFormatter: outputBigNumberFormatter,
  4001          outputTransactionFormatter: outputTransactionFormatter,
  4002          outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
  4003          outputBlockFormatter: outputBlockFormatter,
  4004          outputLogFormatter: outputLogFormatter,
  4005          outputPostFormatter: outputPostFormatter,
  4006          outputSyncingFormatter: outputSyncingFormatter
  4007      };
  4008      
  4009      
  4010      },{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(require,module,exports){
  4011      /*
  4012          This file is part of web3.js.
  4013      
  4014          web3.js is free software: you can redistribute it and/or modify
  4015          it under the terms of the GNU Lesser General Public License as published by
  4016          the Free Software Foundation, either version 3 of the License, or
  4017          (at your option) any later version.
  4018      
  4019          web3.js is distributed in the hope that it will be useful,
  4020          but WITHOUT ANY WARRANTY; without even the implied warranty of
  4021          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4022          GNU Lesser General Public License for more details.
  4023      
  4024          You should have received a copy of the GNU Lesser General Public License
  4025          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4026      */
  4027      /**
  4028       * @file function.js
  4029       * @author Marek Kotewicz <marek@ethdev.com>
  4030       * @date 2015
  4031       */
  4032      
  4033      var coder = require('../solidity/coder');
  4034      var utils = require('../utils/utils');
  4035      var errors = require('./errors');
  4036      var formatters = require('./formatters');
  4037      var sha3 = require('../utils/sha3');
  4038      
  4039      /**
  4040       * This prototype should be used to call/sendTransaction to solidity functions
  4041       */
  4042      var SolidityFunction = function (eth, json, address) {
  4043          this._eth = eth;
  4044          this._inputTypes = json.inputs.map(function (i) {
  4045              return i.type;
  4046          });
  4047          this._outputTypes = json.outputs.map(function (i) {
  4048              return i.type;
  4049          });
  4050          this._constant = json.constant;
  4051          this._payable = json.payable;
  4052          this._name = utils.transformToFullName(json);
  4053          this._address = address;
  4054      };
  4055      
  4056      SolidityFunction.prototype.extractCallback = function (args) {
  4057          if (utils.isFunction(args[args.length - 1])) {
  4058              return args.pop(); // modify the args array!
  4059          }
  4060      };
  4061      
  4062      SolidityFunction.prototype.extractDefaultBlock = function (args) {
  4063          if (args.length > this._inputTypes.length && !utils.isObject(args[args.length -1])) {
  4064              return formatters.inputDefaultBlockNumberFormatter(args.pop()); // modify the args array!
  4065          }
  4066      };
  4067      
  4068      /**
  4069       * Should be called to check if the number of arguments is correct
  4070       *
  4071       * @method validateArgs
  4072       * @param {Array} arguments
  4073       * @throws {Error} if it is not
  4074       */
  4075      SolidityFunction.prototype.validateArgs = function (args) {
  4076          var inputArgs = args.filter(function (a) {
  4077            // filter the options object but not arguments that are arrays
  4078            return !( (utils.isObject(a) === true) &&
  4079                      (utils.isArray(a) === false) &&
  4080                      (utils.isBigNumber(a) === false)
  4081                    );
  4082          });
  4083          if (inputArgs.length !== this._inputTypes.length) {
  4084              throw errors.InvalidNumberOfSolidityArgs();
  4085          }
  4086      };
  4087      
  4088      /**
  4089       * Should be used to create payload from arguments
  4090       *
  4091       * @method toPayload
  4092       * @param {Array} solidity function params
  4093       * @param {Object} optional payload options
  4094       */
  4095      SolidityFunction.prototype.toPayload = function (args) {
  4096          var options = {};
  4097          if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
  4098              options = args[args.length - 1];
  4099          }
  4100          this.validateArgs(args);
  4101          options.to = this._address;
  4102          options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
  4103          return options;
  4104      };
  4105      
  4106      /**
  4107       * Should be used to get function signature
  4108       *
  4109       * @method signature
  4110       * @return {String} function signature
  4111       */
  4112      SolidityFunction.prototype.signature = function () {
  4113          return sha3(this._name).slice(0, 8);
  4114      };
  4115      
  4116      
  4117      SolidityFunction.prototype.unpackOutput = function (output) {
  4118          if (!output) {
  4119              return;
  4120          }
  4121      
  4122          output = output.length >= 2 ? output.slice(2) : output;
  4123          var result = coder.decodeParams(this._outputTypes, output);
  4124          return result.length === 1 ? result[0] : result;
  4125      };
  4126      
  4127      /**
  4128       * Calls a contract function.
  4129       *
  4130       * @method call
  4131       * @param {...Object} Contract function arguments
  4132       * @param {function} If the last argument is a function, the contract function
  4133       *   call will be asynchronous, and the callback will be passed the
  4134       *   error and result.
  4135       * @return {String} output bytes
  4136       */
  4137      SolidityFunction.prototype.call = function () {
  4138          var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4139          var callback = this.extractCallback(args);
  4140          var defaultBlock = this.extractDefaultBlock(args);
  4141          var payload = this.toPayload(args);
  4142      
  4143      
  4144          if (!callback) {
  4145              var output = this._eth.call(payload, defaultBlock);
  4146              return this.unpackOutput(output);
  4147          }
  4148      
  4149          var self = this;
  4150          this._eth.call(payload, defaultBlock, function (error, output) {
  4151              if (error) return callback(error, null);
  4152      
  4153              var unpacked = null;
  4154              try {
  4155                  unpacked = self.unpackOutput(output);
  4156              }
  4157              catch (e) {
  4158                  error = e;
  4159              }
  4160      
  4161              callback(error, unpacked);
  4162          });
  4163      };
  4164      
  4165      /**
  4166       * Should be used to sendTransaction to solidity function
  4167       *
  4168       * @method sendTransaction
  4169       */
  4170      SolidityFunction.prototype.sendTransaction = function () {
  4171          var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4172          var callback = this.extractCallback(args);
  4173          var payload = this.toPayload(args);
  4174      
  4175          if (payload.value > 0 && !this._payable) {
  4176              throw new Error('Cannot send value to non-payable function');
  4177          }
  4178      
  4179          if (!callback) {
  4180              return this._eth.sendTransaction(payload);
  4181          }
  4182      
  4183          this._eth.sendTransaction(payload, callback);
  4184      };
  4185      
  4186      /**
  4187       * Should be used to estimateGas of solidity function
  4188       *
  4189       * @method estimateGas
  4190       */
  4191      SolidityFunction.prototype.estimateGas = function () {
  4192          var args = Array.prototype.slice.call(arguments);
  4193          var callback = this.extractCallback(args);
  4194          var payload = this.toPayload(args);
  4195      
  4196          if (!callback) {
  4197              return this._eth.estimateGas(payload);
  4198          }
  4199      
  4200          this._eth.estimateGas(payload, callback);
  4201      };
  4202      
  4203      /**
  4204       * Return the encoded data of the call
  4205       *
  4206       * @method getData
  4207       * @return {String} the encoded data
  4208       */
  4209      SolidityFunction.prototype.getData = function () {
  4210          var args = Array.prototype.slice.call(arguments);
  4211          var payload = this.toPayload(args);
  4212      
  4213          return payload.data;
  4214      };
  4215      
  4216      /**
  4217       * Should be used to get function display name
  4218       *
  4219       * @method displayName
  4220       * @return {String} display name of the function
  4221       */
  4222      SolidityFunction.prototype.displayName = function () {
  4223          return utils.extractDisplayName(this._name);
  4224      };
  4225      
  4226      /**
  4227       * Should be used to get function type name
  4228       *
  4229       * @method typeName
  4230       * @return {String} type name of the function
  4231       */
  4232      SolidityFunction.prototype.typeName = function () {
  4233          return utils.extractTypeName(this._name);
  4234      };
  4235      
  4236      /**
  4237       * Should be called to get rpc requests from solidity function
  4238       *
  4239       * @method request
  4240       * @returns {Object}
  4241       */
  4242      SolidityFunction.prototype.request = function () {
  4243          var args = Array.prototype.slice.call(arguments);
  4244          var callback = this.extractCallback(args);
  4245          var payload = this.toPayload(args);
  4246          var format = this.unpackOutput.bind(this);
  4247      
  4248          return {
  4249              method: this._constant ? 'eth_call' : 'eth_sendTransaction',
  4250              callback: callback,
  4251              params: [payload],
  4252              format: format
  4253          };
  4254      };
  4255      
  4256      /**
  4257       * Should be called to execute function
  4258       *
  4259       * @method execute
  4260       */
  4261      SolidityFunction.prototype.execute = function () {
  4262          var transaction = !this._constant;
  4263      
  4264          // send transaction
  4265          if (transaction) {
  4266              return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
  4267          }
  4268      
  4269          // call
  4270          return this.call.apply(this, Array.prototype.slice.call(arguments));
  4271      };
  4272      
  4273      /**
  4274       * Should be called to attach function to contract
  4275       *
  4276       * @method attachToContract
  4277       * @param {Contract}
  4278       */
  4279      SolidityFunction.prototype.attachToContract = function (contract) {
  4280          var execute = this.execute.bind(this);
  4281          execute.request = this.request.bind(this);
  4282          execute.call = this.call.bind(this);
  4283          execute.sendTransaction = this.sendTransaction.bind(this);
  4284          execute.estimateGas = this.estimateGas.bind(this);
  4285          execute.getData = this.getData.bind(this);
  4286          var displayName = this.displayName();
  4287          if (!contract[displayName]) {
  4288              contract[displayName] = execute;
  4289          }
  4290          contract[displayName][this.typeName()] = execute; // circular!!!!
  4291      };
  4292      
  4293      module.exports = SolidityFunction;
  4294      
  4295      },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./errors":26,"./formatters":30}],32:[function(require,module,exports){
  4296      /*
  4297          This file is part of web3.js.
  4298      
  4299          web3.js is free software: you can redistribute it and/or modify
  4300          it under the terms of the GNU Lesser General Public License as published by
  4301          the Free Software Foundation, either version 3 of the License, or
  4302          (at your option) any later version.
  4303      
  4304          web3.js is distributed in the hope that it will be useful,
  4305          but WITHOUT ANY WARRANTY; without even the implied warranty of
  4306          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4307          GNU Lesser General Public License for more details.
  4308      
  4309          You should have received a copy of the GNU Lesser General Public License
  4310          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4311      */
  4312      /** @file httpprovider.js
  4313       * @authors:
  4314       *   Marek Kotewicz <marek@ethdev.com>
  4315       *   Marian Oancea <marian@ethdev.com>
  4316       *   Fabian Vogelsteller <fabian@ethdev.com>
  4317       * @date 2015
  4318       */
  4319      
  4320      var errors = require('./errors');
  4321      
  4322      // workaround to use httpprovider in different envs
  4323      
  4324      // browser
  4325      if (typeof window !== 'undefined' && window.XMLHttpRequest) {
  4326        XMLHttpRequest = window.XMLHttpRequest; // jshint ignore: line
  4327      // node
  4328      } else {
  4329        XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore: line
  4330      }
  4331      
  4332      var XHR2 = require('xhr2'); // jshint ignore: line
  4333      
  4334      /**
  4335       * HttpProvider should be used to send rpc calls over http
  4336       */
  4337      var HttpProvider = function (host, timeout, user, password) {
  4338        this.host = host || 'http://localhost:8545';
  4339        this.timeout = timeout || 0;
  4340        this.user = user;
  4341        this.password = password;
  4342      };
  4343      
  4344      /**
  4345       * Should be called to prepare new XMLHttpRequest
  4346       *
  4347       * @method prepareRequest
  4348       * @param {Boolean} true if request should be async
  4349       * @return {XMLHttpRequest} object
  4350       */
  4351      HttpProvider.prototype.prepareRequest = function (async) {
  4352        var request;
  4353      
  4354        if (async) {
  4355          request = new XHR2();
  4356          request.timeout = this.timeout;
  4357        } else {
  4358          request = new XMLHttpRequest();
  4359        }
  4360      
  4361        request.open('POST', this.host, async);
  4362        if (this.user && this.password) {
  4363          var auth = 'Basic ' + new Buffer(this.user + ':' + this.password).toString('base64');
  4364          request.setRequestHeader('Authorization', auth);
  4365        } request.setRequestHeader('Content-Type', 'application/json');
  4366        return request;
  4367      };
  4368      
  4369      /**
  4370       * Should be called to make sync request
  4371       *
  4372       * @method send
  4373       * @param {Object} payload
  4374       * @return {Object} result
  4375       */
  4376      HttpProvider.prototype.send = function (payload) {
  4377        var request = this.prepareRequest(false);
  4378      
  4379        try {
  4380          request.send(JSON.stringify(payload));
  4381        } catch (error) {
  4382          throw errors.InvalidConnection(this.host);
  4383        }
  4384      
  4385        var result = request.responseText;
  4386      
  4387        try {
  4388          result = JSON.parse(result);
  4389        } catch (e) {
  4390          throw errors.InvalidResponse(request.responseText);
  4391        }
  4392      
  4393        return result;
  4394      };
  4395      
  4396      /**
  4397       * Should be used to make async request
  4398       *
  4399       * @method sendAsync
  4400       * @param {Object} payload
  4401       * @param {Function} callback triggered on end with (err, result)
  4402       */
  4403      HttpProvider.prototype.sendAsync = function (payload, callback) {
  4404        var request = this.prepareRequest(true);
  4405      
  4406        request.onreadystatechange = function () {
  4407          if (request.readyState === 4 && request.timeout !== 1) {
  4408            var result = request.responseText;
  4409            var error = null;
  4410      
  4411            try {
  4412              result = JSON.parse(result);
  4413            } catch (e) {
  4414              error = errors.InvalidResponse(request.responseText);
  4415            }
  4416      
  4417            callback(error, result);
  4418          }
  4419        };
  4420      
  4421        request.ontimeout = function () {
  4422          callback(errors.ConnectionTimeout(this.timeout));
  4423        };
  4424      
  4425        try {
  4426          request.send(JSON.stringify(payload));
  4427        } catch (error) {
  4428          callback(errors.InvalidConnection(this.host));
  4429        }
  4430      };
  4431      
  4432      /**
  4433       * Synchronously tries to make Http request
  4434       *
  4435       * @method isConnected
  4436       * @return {Boolean} returns true if request haven't failed. Otherwise false
  4437       */
  4438      HttpProvider.prototype.isConnected = function () {
  4439        try {
  4440          this.send({
  4441            id: 9999999999,
  4442            jsonrpc: '2.0',
  4443            method: 'net_listening',
  4444            params: []
  4445          });
  4446          return true;
  4447        } catch (e) {
  4448          return false;
  4449        }
  4450      };
  4451      
  4452      module.exports = HttpProvider;
  4453      
  4454      },{"./errors":26,"xhr2":86,"xmlhttprequest":17}],33:[function(require,module,exports){
  4455      /*
  4456          This file is part of web3.js.
  4457      
  4458          web3.js is free software: you can redistribute it and/or modify
  4459          it under the terms of the GNU Lesser General Public License as published by
  4460          the Free Software Foundation, either version 3 of the License, or
  4461          (at your option) any later version.
  4462      
  4463          web3.js is distributed in the hope that it will be useful,
  4464          but WITHOUT ANY WARRANTY; without even the implied warranty of
  4465          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4466          GNU Lesser General Public License for more details.
  4467      
  4468          You should have received a copy of the GNU Lesser General Public License
  4469          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4470      */
  4471      /** 
  4472       * @file iban.js
  4473       * @author Marek Kotewicz <marek@ethdev.com>
  4474       * @date 2015
  4475       */
  4476      
  4477      var BigNumber = require('bignumber.js');
  4478      
  4479      var padLeft = function (string, bytes) {
  4480          var result = string;
  4481          while (result.length < bytes * 2) {
  4482              result = '0' + result;
  4483          }
  4484          return result;
  4485      };
  4486      
  4487      /**
  4488       * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to
  4489       * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.
  4490       *
  4491       * @method iso13616Prepare
  4492       * @param {String} iban the IBAN
  4493       * @returns {String} the prepared IBAN
  4494       */
  4495      var iso13616Prepare = function (iban) {
  4496          var A = 'A'.charCodeAt(0);
  4497          var Z = 'Z'.charCodeAt(0);
  4498      
  4499          iban = iban.toUpperCase();
  4500          iban = iban.substr(4) + iban.substr(0,4);
  4501      
  4502          return iban.split('').map(function(n){
  4503              var code = n.charCodeAt(0);
  4504              if (code >= A && code <= Z){
  4505                  // A = 10, B = 11, ... Z = 35
  4506                  return code - A + 10;
  4507              } else {
  4508                  return n;
  4509              }
  4510          }).join('');
  4511      };
  4512      
  4513      /**
  4514       * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064.
  4515       *
  4516       * @method mod9710
  4517       * @param {String} iban
  4518       * @returns {Number}
  4519       */
  4520      var mod9710 = function (iban) {
  4521          var remainder = iban,
  4522              block;
  4523      
  4524          while (remainder.length > 2){
  4525              block = remainder.slice(0, 9);
  4526              remainder = parseInt(block, 10) % 97 + remainder.slice(block.length);
  4527          }
  4528      
  4529          return parseInt(remainder, 10) % 97;
  4530      };
  4531      
  4532      /**
  4533       * This prototype should be used to create iban object from iban correct string
  4534       *
  4535       * @param {String} iban
  4536       */
  4537      var Iban = function (iban) {
  4538          this._iban = iban;
  4539      };
  4540      
  4541      /**
  4542       * This method should be used to create iban object from ethereum address
  4543       *
  4544       * @method fromAddress
  4545       * @param {String} address
  4546       * @return {Iban} the IBAN object
  4547       */
  4548      Iban.fromAddress = function (address) {
  4549          var asBn = new BigNumber(address, 16);
  4550          var base36 = asBn.toString(36);
  4551          var padded = padLeft(base36, 15);
  4552          return Iban.fromBban(padded.toUpperCase());
  4553      };
  4554      
  4555      /**
  4556       * Convert the passed BBAN to an IBAN for this country specification.
  4557       * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>.
  4558       * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
  4559       *
  4560       * @method fromBban
  4561       * @param {String} bban the BBAN to convert to IBAN
  4562       * @returns {Iban} the IBAN object
  4563       */
  4564      Iban.fromBban = function (bban) {
  4565          var countryCode = 'XE';
  4566      
  4567          var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban));
  4568          var checkDigit = ('0' + (98 - remainder)).slice(-2);
  4569      
  4570          return new Iban(countryCode + checkDigit + bban);
  4571      };
  4572      
  4573      /**
  4574       * Should be used to create IBAN object for given institution and identifier
  4575       *
  4576       * @method createIndirect
  4577       * @param {Object} options, required options are "institution" and "identifier"
  4578       * @return {Iban} the IBAN object
  4579       */
  4580      Iban.createIndirect = function (options) {
  4581          return Iban.fromBban('ETH' + options.institution + options.identifier);
  4582      };
  4583      
  4584      /**
  4585       * Thos method should be used to check if given string is valid iban object
  4586       *
  4587       * @method isValid
  4588       * @param {String} iban string
  4589       * @return {Boolean} true if it is valid IBAN
  4590       */
  4591      Iban.isValid = function (iban) {
  4592          var i = new Iban(iban);
  4593          return i.isValid();
  4594      };
  4595      
  4596      /**
  4597       * Should be called to check if iban is correct
  4598       *
  4599       * @method isValid
  4600       * @returns {Boolean} true if it is, otherwise false
  4601       */
  4602      Iban.prototype.isValid = function () {
  4603          return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) &&
  4604              mod9710(iso13616Prepare(this._iban)) === 1;
  4605      };
  4606      
  4607      /**
  4608       * Should be called to check if iban number is direct
  4609       *
  4610       * @method isDirect
  4611       * @returns {Boolean} true if it is, otherwise false
  4612       */
  4613      Iban.prototype.isDirect = function () {
  4614          return this._iban.length === 34 || this._iban.length === 35;
  4615      };
  4616      
  4617      /**
  4618       * Should be called to check if iban number if indirect
  4619       *
  4620       * @method isIndirect
  4621       * @returns {Boolean} true if it is, otherwise false
  4622       */
  4623      Iban.prototype.isIndirect = function () {
  4624          return this._iban.length === 20;
  4625      };
  4626      
  4627      /**
  4628       * Should be called to get iban checksum
  4629       * Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
  4630       *
  4631       * @method checksum
  4632       * @returns {String} checksum
  4633       */
  4634      Iban.prototype.checksum = function () {
  4635          return this._iban.substr(2, 2);
  4636      };
  4637      
  4638      /**
  4639       * Should be called to get institution identifier
  4640       * eg. XREG
  4641       *
  4642       * @method institution
  4643       * @returns {String} institution identifier
  4644       */
  4645      Iban.prototype.institution = function () {
  4646          return this.isIndirect() ? this._iban.substr(7, 4) : '';
  4647      };
  4648      
  4649      /**
  4650       * Should be called to get client identifier within institution
  4651       * eg. GAVOFYORK
  4652       *
  4653       * @method client
  4654       * @returns {String} client identifier
  4655       */
  4656      Iban.prototype.client = function () {
  4657          return this.isIndirect() ? this._iban.substr(11) : '';
  4658      };
  4659      
  4660      /**
  4661       * Should be called to get client direct address
  4662       *
  4663       * @method address
  4664       * @returns {String} client direct address
  4665       */
  4666      Iban.prototype.address = function () {
  4667          if (this.isDirect()) {
  4668              var base36 = this._iban.substr(4);
  4669              var asBn = new BigNumber(base36, 36);
  4670              return padLeft(asBn.toString(16), 20);
  4671          } 
  4672      
  4673          return '';
  4674      };
  4675      
  4676      Iban.prototype.toString = function () {
  4677          return this._iban;
  4678      };
  4679      
  4680      module.exports = Iban;
  4681      
  4682      
  4683      },{"bignumber.js":"bignumber.js"}],34:[function(require,module,exports){
  4684      /*
  4685          This file is part of web3.js.
  4686      
  4687          web3.js is free software: you can redistribute it and/or modify
  4688          it under the terms of the GNU Lesser General Public License as published by
  4689          the Free Software Foundation, either version 3 of the License, or
  4690          (at your option) any later version.
  4691      
  4692          web3.js is distributed in the hope that it will be useful,
  4693          but WITHOUT ANY WARRANTY; without even the implied warranty of
  4694          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4695          GNU Lesser General Public License for more details.
  4696      
  4697          You should have received a copy of the GNU Lesser General Public License
  4698          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4699      */
  4700      /** @file ipcprovider.js
  4701       * @authors:
  4702       *   Fabian Vogelsteller <fabian@ethdev.com>
  4703       * @date 2015
  4704       */
  4705      
  4706      "use strict";
  4707      
  4708      var utils = require('../utils/utils');
  4709      var errors = require('./errors');
  4710      
  4711      
  4712      var IpcProvider = function (path, net) {
  4713          var _this = this;
  4714          this.responseCallbacks = {};
  4715          this.path = path;
  4716          
  4717          this.connection = net.connect({path: this.path});
  4718      
  4719          this.connection.on('error', function(e){
  4720              console.error('IPC Connection Error', e);
  4721              _this._timeout();
  4722          });
  4723      
  4724          this.connection.on('end', function(){
  4725              _this._timeout();
  4726          }); 
  4727      
  4728      
  4729          // LISTEN FOR CONNECTION RESPONSES
  4730          this.connection.on('data', function(data) {
  4731              /*jshint maxcomplexity: 6 */
  4732      
  4733              _this._parseResponse(data.toString()).forEach(function(result){
  4734      
  4735                  var id = null;
  4736      
  4737                  // get the id which matches the returned id
  4738                  if(utils.isArray(result)) {
  4739                      result.forEach(function(load){
  4740                          if(_this.responseCallbacks[load.id])
  4741                              id = load.id;
  4742                      });
  4743                  } else {
  4744                      id = result.id;
  4745                  }
  4746      
  4747                  // fire the callback
  4748                  if(_this.responseCallbacks[id]) {
  4749                      _this.responseCallbacks[id](null, result);
  4750                      delete _this.responseCallbacks[id];
  4751                  }
  4752              });
  4753          });
  4754      };
  4755      
  4756      /**
  4757      Will parse the response and make an array out of it.
  4758      
  4759      @method _parseResponse
  4760      @param {String} data
  4761      */
  4762      IpcProvider.prototype._parseResponse = function(data) {
  4763          var _this = this,
  4764              returnValues = [];
  4765          
  4766          // DE-CHUNKER
  4767          var dechunkedData = data
  4768              .replace(/\}[\n\r]?\{/g,'}|--|{') // }{
  4769              .replace(/\}\][\n\r]?\[\{/g,'}]|--|[{') // }][{
  4770              .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{
  4771              .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{
  4772              .split('|--|');
  4773      
  4774          dechunkedData.forEach(function(data){
  4775      
  4776              // prepend the last chunk
  4777              if(_this.lastChunk)
  4778                  data = _this.lastChunk + data;
  4779      
  4780              var result = null;
  4781      
  4782              try {
  4783                  result = JSON.parse(data);
  4784      
  4785              } catch(e) {
  4786      
  4787                  _this.lastChunk = data;
  4788      
  4789                  // start timeout to cancel all requests
  4790                  clearTimeout(_this.lastChunkTimeout);
  4791                  _this.lastChunkTimeout = setTimeout(function(){
  4792                      _this._timeout();
  4793                      throw errors.InvalidResponse(data);
  4794                  }, 1000 * 15);
  4795      
  4796                  return;
  4797              }
  4798      
  4799              // cancel timeout and set chunk to null
  4800              clearTimeout(_this.lastChunkTimeout);
  4801              _this.lastChunk = null;
  4802      
  4803              if(result)
  4804                  returnValues.push(result);
  4805          });
  4806      
  4807          return returnValues;
  4808      };
  4809      
  4810      
  4811      /**
  4812      Get the adds a callback to the responseCallbacks object,
  4813      which will be called if a response matching the response Id will arrive.
  4814      
  4815      @method _addResponseCallback
  4816      */
  4817      IpcProvider.prototype._addResponseCallback = function(payload, callback) {
  4818          var id = payload.id || payload[0].id;
  4819          var method = payload.method || payload[0].method;
  4820      
  4821          this.responseCallbacks[id] = callback;
  4822          this.responseCallbacks[id].method = method;
  4823      };
  4824      
  4825      /**
  4826      Timeout all requests when the end/error event is fired
  4827      
  4828      @method _timeout
  4829      */
  4830      IpcProvider.prototype._timeout = function() {
  4831          for(var key in this.responseCallbacks) {
  4832              if(this.responseCallbacks.hasOwnProperty(key)){
  4833                  this.responseCallbacks[key](errors.InvalidConnection('on IPC'));
  4834                  delete this.responseCallbacks[key];
  4835              }
  4836          }
  4837      };
  4838      
  4839      
  4840      /**
  4841      Check if the current connection is still valid.
  4842      
  4843      @method isConnected
  4844      */
  4845      IpcProvider.prototype.isConnected = function() {
  4846          var _this = this;
  4847      
  4848          // try reconnect, when connection is gone
  4849          if(!_this.connection.writable)
  4850              _this.connection.connect({path: _this.path});
  4851      
  4852          return !!this.connection.writable;
  4853      };
  4854      
  4855      IpcProvider.prototype.send = function (payload) {
  4856      
  4857          if(this.connection.writeSync) {
  4858              var result;
  4859      
  4860              // try reconnect, when connection is gone
  4861              if(!this.connection.writable)
  4862                  this.connection.connect({path: this.path});
  4863      
  4864              var data = this.connection.writeSync(JSON.stringify(payload));
  4865      
  4866              try {
  4867                  result = JSON.parse(data);
  4868              } catch(e) {
  4869                  throw errors.InvalidResponse(data);                
  4870              }
  4871      
  4872              return result;
  4873      
  4874          } else {
  4875              throw new Error('You tried to send "'+ payload.method +'" synchronously. Synchronous requests are not supported by the IPC provider.');
  4876          }
  4877      };
  4878      
  4879      IpcProvider.prototype.sendAsync = function (payload, callback) {
  4880          // try reconnect, when connection is gone
  4881          if(!this.connection.writable)
  4882              this.connection.connect({path: this.path});
  4883      
  4884      
  4885          this.connection.write(JSON.stringify(payload));
  4886          this._addResponseCallback(payload, callback);
  4887      };
  4888      
  4889      module.exports = IpcProvider;
  4890      
  4891      
  4892      },{"../utils/utils":20,"./errors":26}],35:[function(require,module,exports){
  4893      /*
  4894          This file is part of web3.js.
  4895      
  4896          web3.js is free software: you can redistribute it and/or modify
  4897          it under the terms of the GNU Lesser General Public License as published by
  4898          the Free Software Foundation, either version 3 of the License, or
  4899          (at your option) any later version.
  4900      
  4901          web3.js is distributed in the hope that it will be useful,
  4902          but WITHOUT ANY WARRANTY; without even the implied warranty of
  4903          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4904          GNU Lesser General Public License for more details.
  4905      
  4906          You should have received a copy of the GNU Lesser General Public License
  4907          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4908      */
  4909      /** @file jsonrpc.js
  4910       * @authors:
  4911       *   Marek Kotewicz <marek@ethdev.com>
  4912       *   Aaron Kumavis <aaron@kumavis.me>
  4913       * @date 2015
  4914       */
  4915      
  4916      // Initialize Jsonrpc as a simple object with utility functions.
  4917      var Jsonrpc = {
  4918          messageId: 0
  4919      };
  4920      
  4921      /**
  4922       * Should be called to valid json create payload object
  4923       *
  4924       * @method toPayload
  4925       * @param {Function} method of jsonrpc call, required
  4926       * @param {Array} params, an array of method params, optional
  4927       * @returns {Object} valid jsonrpc payload object
  4928       */
  4929      Jsonrpc.toPayload = function (method, params) {
  4930          if (!method)
  4931              console.error('jsonrpc method should be specified!');
  4932      
  4933          // advance message ID
  4934          Jsonrpc.messageId++;
  4935      
  4936          return {
  4937              jsonrpc: '2.0',
  4938              id: Jsonrpc.messageId,
  4939              method: method,
  4940              params: params || []
  4941          };
  4942      };
  4943      
  4944      /**
  4945       * Should be called to check if jsonrpc response is valid
  4946       *
  4947       * @method isValidResponse
  4948       * @param {Object}
  4949       * @returns {Boolean} true if response is valid, otherwise false
  4950       */
  4951      Jsonrpc.isValidResponse = function (response) {
  4952          return Array.isArray(response) ? response.every(validateSingleMessage) : validateSingleMessage(response);
  4953      
  4954          function validateSingleMessage(message){
  4955            return !!message &&
  4956              !message.error &&
  4957              message.jsonrpc === '2.0' &&
  4958              typeof message.id === 'number' &&
  4959              message.result !== undefined; // only undefined is not valid json object
  4960          }
  4961      };
  4962      
  4963      /**
  4964       * Should be called to create batch payload object
  4965       *
  4966       * @method toBatchPayload
  4967       * @param {Array} messages, an array of objects with method (required) and params (optional) fields
  4968       * @returns {Array} batch payload
  4969       */
  4970      Jsonrpc.toBatchPayload = function (messages) {
  4971          return messages.map(function (message) {
  4972              return Jsonrpc.toPayload(message.method, message.params);
  4973          });
  4974      };
  4975      
  4976      module.exports = Jsonrpc;
  4977      
  4978      
  4979      },{}],36:[function(require,module,exports){
  4980      /*
  4981          This file is part of web3.js.
  4982      
  4983          web3.js is free software: you can redistribute it and/or modify
  4984          it under the terms of the GNU Lesser General Public License as published by
  4985          the Free Software Foundation, either version 3 of the License, or
  4986          (at your option) any later version.
  4987      
  4988          web3.js is distributed in the hope that it will be useful,
  4989          but WITHOUT ANY WARRANTY; without even the implied warranty of
  4990          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4991          GNU Lesser General Public License for more details.
  4992      
  4993          You should have received a copy of the GNU Lesser General Public License
  4994          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4995      */
  4996      /**
  4997       * @file method.js
  4998       * @author Marek Kotewicz <marek@ethdev.com>
  4999       * @date 2015
  5000       */
  5001      
  5002      var utils = require('../utils/utils');
  5003      var errors = require('./errors');
  5004      
  5005      var Method = function (options) {
  5006          this.name = options.name;
  5007          this.call = options.call;
  5008          this.params = options.params || 0;
  5009          this.inputFormatter = options.inputFormatter;
  5010          this.outputFormatter = options.outputFormatter;
  5011          this.requestManager = null;
  5012      };
  5013      
  5014      Method.prototype.setRequestManager = function (rm) {
  5015          this.requestManager = rm;
  5016      };
  5017      
  5018      /**
  5019       * Should be used to determine name of the jsonrpc method based on arguments
  5020       *
  5021       * @method getCall
  5022       * @param {Array} arguments
  5023       * @return {String} name of jsonrpc method
  5024       */
  5025      Method.prototype.getCall = function (args) {
  5026          return utils.isFunction(this.call) ? this.call(args) : this.call;
  5027      };
  5028      
  5029      /**
  5030       * Should be used to extract callback from array of arguments. Modifies input param
  5031       *
  5032       * @method extractCallback
  5033       * @param {Array} arguments
  5034       * @return {Function|Null} callback, if exists
  5035       */
  5036      Method.prototype.extractCallback = function (args) {
  5037          if (utils.isFunction(args[args.length - 1])) {
  5038              return args.pop(); // modify the args array!
  5039          }
  5040      };
  5041      
  5042      /**
  5043       * Should be called to check if the number of arguments is correct
  5044       * 
  5045       * @method validateArgs
  5046       * @param {Array} arguments
  5047       * @throws {Error} if it is not
  5048       */
  5049      Method.prototype.validateArgs = function (args) {
  5050          if (args.length !== this.params) {
  5051              throw errors.InvalidNumberOfRPCParams();
  5052          }
  5053      };
  5054      
  5055      /**
  5056       * Should be called to format input args of method
  5057       * 
  5058       * @method formatInput
  5059       * @param {Array}
  5060       * @return {Array}
  5061       */
  5062      Method.prototype.formatInput = function (args) {
  5063          if (!this.inputFormatter) {
  5064              return args;
  5065          }
  5066      
  5067          return this.inputFormatter.map(function (formatter, index) {
  5068              return formatter ? formatter(args[index]) : args[index];
  5069          });
  5070      };
  5071      
  5072      /**
  5073       * Should be called to format output(result) of method
  5074       *
  5075       * @method formatOutput
  5076       * @param {Object}
  5077       * @return {Object}
  5078       */
  5079      Method.prototype.formatOutput = function (result) {
  5080          return this.outputFormatter && result ? this.outputFormatter(result) : result;
  5081      };
  5082      
  5083      /**
  5084       * Should create payload from given input args
  5085       *
  5086       * @method toPayload
  5087       * @param {Array} args
  5088       * @return {Object}
  5089       */
  5090      Method.prototype.toPayload = function (args) {
  5091          var call = this.getCall(args);
  5092          var callback = this.extractCallback(args);
  5093          var params = this.formatInput(args);
  5094          this.validateArgs(params);
  5095      
  5096          return {
  5097              method: call,
  5098              params: params,
  5099              callback: callback
  5100          };
  5101      };
  5102      
  5103      Method.prototype.attachToObject = function (obj) {
  5104          var func = this.buildCall();
  5105          func.call = this.call; // TODO!!! that's ugly. filter.js uses it
  5106          var name = this.name.split('.');
  5107          if (name.length > 1) {
  5108              obj[name[0]] = obj[name[0]] || {};
  5109              obj[name[0]][name[1]] = func;
  5110          } else {
  5111              obj[name[0]] = func; 
  5112          }
  5113      };
  5114      
  5115      Method.prototype.buildCall = function() {
  5116          var method = this;
  5117          var send = function () {
  5118              var payload = method.toPayload(Array.prototype.slice.call(arguments));
  5119              if (payload.callback) {
  5120                  return method.requestManager.sendAsync(payload, function (err, result) {
  5121                      payload.callback(err, method.formatOutput(result));
  5122                  });
  5123              }
  5124              return method.formatOutput(method.requestManager.send(payload));
  5125          };
  5126          send.request = this.request.bind(this);
  5127          return send;
  5128      };
  5129      
  5130      /**
  5131       * Should be called to create pure JSONRPC request which can be used in batch request
  5132       *
  5133       * @method request
  5134       * @param {...} params
  5135       * @return {Object} jsonrpc request
  5136       */
  5137      Method.prototype.request = function () {
  5138          var payload = this.toPayload(Array.prototype.slice.call(arguments));
  5139          payload.format = this.formatOutput.bind(this);
  5140          return payload;
  5141      };
  5142      
  5143      module.exports = Method;
  5144      
  5145      },{"../utils/utils":20,"./errors":26}],37:[function(require,module,exports){
  5146      /*
  5147          This file is part of web3.js.
  5148      
  5149          web3.js is free software: you can redistribute it and/or modify
  5150          it under the terms of the GNU Lesser General Public License as published by
  5151          the Free Software Foundation, either version 3 of the License, or
  5152          (at your option) any later version.
  5153      
  5154          web3.js is distributed in the hope that it will be useful,
  5155          but WITHOUT ANY WARRANTY; without even the implied warranty of
  5156          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5157          GNU Lesser General Public License for more details.
  5158      
  5159          You should have received a copy of the GNU Lesser General Public License
  5160          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5161      */
  5162      /** @file db.js
  5163       * @authors:
  5164       *   Marek Kotewicz <marek@ethdev.com>
  5165       * @date 2015
  5166       */
  5167      
  5168      var Method = require('../method');
  5169      
  5170      var DB = function (web3) {
  5171          this._requestManager = web3._requestManager;
  5172      
  5173          var self = this;
  5174          
  5175          methods().forEach(function(method) { 
  5176              method.attachToObject(self);
  5177              method.setRequestManager(web3._requestManager);
  5178          });
  5179      };
  5180      
  5181      var methods = function () {
  5182          var putString = new Method({
  5183              name: 'putString',
  5184              call: 'db_putString',
  5185              params: 3
  5186          });
  5187      
  5188          var getString = new Method({
  5189              name: 'getString',
  5190              call: 'db_getString',
  5191              params: 2
  5192          });
  5193      
  5194          var putHex = new Method({
  5195              name: 'putHex',
  5196              call: 'db_putHex',
  5197              params: 3
  5198          });
  5199      
  5200          var getHex = new Method({
  5201              name: 'getHex',
  5202              call: 'db_getHex',
  5203              params: 2
  5204          });
  5205      
  5206          return [
  5207              putString, getString, putHex, getHex
  5208          ];
  5209      };
  5210      
  5211      module.exports = DB;
  5212      
  5213      },{"../method":36}],38:[function(require,module,exports){
  5214      /*
  5215          This file is part of web3.js.
  5216      
  5217          web3.js is free software: you can redistribute it and/or modify
  5218          it under the terms of the GNU Lesser General Public License as published by
  5219          the Free Software Foundation, either version 3 of the License, or
  5220          (at your option) any later version.
  5221      
  5222          web3.js is distributed in the hope that it will be useful,
  5223          but WITHOUT ANY WARRANTY; without even the implied warranty of
  5224          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5225          GNU Lesser General Public License for more details.
  5226      
  5227          You should have received a copy of the GNU Lesser General Public License
  5228          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5229      */
  5230      /**
  5231       * @file eth.js
  5232       * @author Marek Kotewicz <marek@ethdev.com>
  5233       * @author Fabian Vogelsteller <fabian@ethdev.com>
  5234       * @date 2015
  5235       */
  5236      
  5237      "use strict";
  5238      
  5239      var formatters = require('../formatters');
  5240      var utils = require('../../utils/utils');
  5241      var Method = require('../method');
  5242      var Property = require('../property');
  5243      var c = require('../../utils/config');
  5244      var Contract = require('../contract');
  5245      var watches = require('./watches');
  5246      var Filter = require('../filter');
  5247      var IsSyncing = require('../syncing');
  5248      var namereg = require('../namereg');
  5249      var Iban = require('../iban');
  5250      var transfer = require('../transfer');
  5251      
  5252      var blockCall = function (args) {
  5253          return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
  5254      };
  5255      
  5256      var transactionFromBlockCall = function (args) {
  5257          return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
  5258      };
  5259      
  5260      var uncleCall = function (args) {
  5261          return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
  5262      };
  5263      
  5264      var getBlockTransactionCountCall = function (args) {
  5265          return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
  5266      };
  5267      
  5268      var uncleCountCall = function (args) {
  5269          return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
  5270      };
  5271      
  5272      function Eth(web3) {
  5273          this._requestManager = web3._requestManager;
  5274      
  5275          var self = this;
  5276      
  5277          methods().forEach(function(method) {
  5278              method.attachToObject(self);
  5279              method.setRequestManager(self._requestManager);
  5280          });
  5281      
  5282          properties().forEach(function(p) {
  5283              p.attachToObject(self);
  5284              p.setRequestManager(self._requestManager);
  5285          });
  5286      
  5287      
  5288          this.iban = Iban;
  5289          this.sendIBANTransaction = transfer.bind(null, this);
  5290      }
  5291      
  5292      Object.defineProperty(Eth.prototype, 'defaultBlock', {
  5293          get: function () {
  5294              return c.defaultBlock;
  5295          },
  5296          set: function (val) {
  5297              c.defaultBlock = val;
  5298              return val;
  5299          }
  5300      });
  5301      
  5302      Object.defineProperty(Eth.prototype, 'defaultAccount', {
  5303          get: function () {
  5304              return c.defaultAccount;
  5305          },
  5306          set: function (val) {
  5307              c.defaultAccount = val;
  5308              return val;
  5309          }
  5310      });
  5311      
  5312      var methods = function () {
  5313          var getBalance = new Method({
  5314              name: 'getBalance',
  5315              call: 'eth_getBalance',
  5316              params: 2,
  5317              inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
  5318              outputFormatter: formatters.outputBigNumberFormatter
  5319          });
  5320      
  5321          var getStorageAt = new Method({
  5322              name: 'getStorageAt',
  5323              call: 'eth_getStorageAt',
  5324              params: 3,
  5325              inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
  5326          });
  5327      
  5328          var getCode = new Method({
  5329              name: 'getCode',
  5330              call: 'eth_getCode',
  5331              params: 2,
  5332              inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
  5333          });
  5334      
  5335          var getBlock = new Method({
  5336              name: 'getBlock',
  5337              call: blockCall,
  5338              params: 2,
  5339              inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
  5340              outputFormatter: formatters.outputBlockFormatter
  5341          });
  5342      
  5343          var getUncle = new Method({
  5344              name: 'getUncle',
  5345              call: uncleCall,
  5346              params: 2,
  5347              inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5348              outputFormatter: formatters.outputBlockFormatter,
  5349      
  5350          });
  5351      
  5352          var getCompilers = new Method({
  5353              name: 'getCompilers',
  5354              call: 'eth_getCompilers',
  5355              params: 0
  5356          });
  5357      
  5358          var getBlockTransactionCount = new Method({
  5359              name: 'getBlockTransactionCount',
  5360              call: getBlockTransactionCountCall,
  5361              params: 1,
  5362              inputFormatter: [formatters.inputBlockNumberFormatter],
  5363              outputFormatter: utils.toDecimal
  5364          });
  5365      
  5366          var getBlockUncleCount = new Method({
  5367              name: 'getBlockUncleCount',
  5368              call: uncleCountCall,
  5369              params: 1,
  5370              inputFormatter: [formatters.inputBlockNumberFormatter],
  5371              outputFormatter: utils.toDecimal
  5372          });
  5373      
  5374          var getTransaction = new Method({
  5375              name: 'getTransaction',
  5376              call: 'eth_getTransactionByHash',
  5377              params: 1,
  5378              outputFormatter: formatters.outputTransactionFormatter
  5379          });
  5380      
  5381          var getTransactionFromBlock = new Method({
  5382              name: 'getTransactionFromBlock',
  5383              call: transactionFromBlockCall,
  5384              params: 2,
  5385              inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5386              outputFormatter: formatters.outputTransactionFormatter
  5387          });
  5388      
  5389          var getTransactionReceipt = new Method({
  5390              name: 'getTransactionReceipt',
  5391              call: 'eth_getTransactionReceipt',
  5392              params: 1,
  5393              outputFormatter: formatters.outputTransactionReceiptFormatter
  5394          });
  5395      
  5396          var getTransactionCount = new Method({
  5397              name: 'getTransactionCount',
  5398              call: 'eth_getTransactionCount',
  5399              params: 2,
  5400              inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
  5401              outputFormatter: utils.toDecimal
  5402          });
  5403      
  5404          var sendRawTransaction = new Method({
  5405              name: 'sendRawTransaction',
  5406              call: 'eth_sendRawTransaction',
  5407              params: 1,
  5408              inputFormatter: [null]
  5409          });
  5410      
  5411          var sendTransaction = new Method({
  5412              name: 'sendTransaction',
  5413              call: 'eth_sendTransaction',
  5414              params: 1,
  5415              inputFormatter: [formatters.inputTransactionFormatter]
  5416          });
  5417      
  5418          var signTransaction = new Method({
  5419              name: 'signTransaction',
  5420              call: 'eth_signTransaction',
  5421              params: 1,
  5422              inputFormatter: [formatters.inputTransactionFormatter]
  5423          });
  5424      
  5425          var sign = new Method({
  5426              name: 'sign',
  5427              call: 'eth_sign',
  5428              params: 2,
  5429              inputFormatter: [formatters.inputAddressFormatter, null]
  5430          });
  5431      
  5432          var call = new Method({
  5433              name: 'call',
  5434              call: 'eth_call',
  5435              params: 2,
  5436              inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
  5437          });
  5438      
  5439          var estimateGas = new Method({
  5440              name: 'estimateGas',
  5441              call: 'eth_estimateGas',
  5442              params: 1,
  5443              inputFormatter: [formatters.inputCallFormatter],
  5444              outputFormatter: utils.toDecimal
  5445          });
  5446      
  5447          var compileSolidity = new Method({
  5448              name: 'compile.solidity',
  5449              call: 'eth_compileSolidity',
  5450              params: 1
  5451          });
  5452      
  5453          var compileLLL = new Method({
  5454              name: 'compile.lll',
  5455              call: 'eth_compileLLL',
  5456              params: 1
  5457          });
  5458      
  5459          var compileSerpent = new Method({
  5460              name: 'compile.serpent',
  5461              call: 'eth_compileSerpent',
  5462              params: 1
  5463          });
  5464      
  5465          var submitWork = new Method({
  5466              name: 'submitWork',
  5467              call: 'eth_submitWork',
  5468              params: 3
  5469          });
  5470      
  5471          var getWork = new Method({
  5472              name: 'getWork',
  5473              call: 'eth_getWork',
  5474              params: 0
  5475          });
  5476      
  5477          return [
  5478              getBalance,
  5479              getStorageAt,
  5480              getCode,
  5481              getBlock,
  5482              getUncle,
  5483              getCompilers,
  5484              getBlockTransactionCount,
  5485              getBlockUncleCount,
  5486              getTransaction,
  5487              getTransactionFromBlock,
  5488              getTransactionReceipt,
  5489              getTransactionCount,
  5490              call,
  5491              estimateGas,
  5492              sendRawTransaction,
  5493              signTransaction,
  5494              sendTransaction,
  5495              sign,
  5496              compileSolidity,
  5497              compileLLL,
  5498              compileSerpent,
  5499              submitWork,
  5500              getWork
  5501          ];
  5502      };
  5503      
  5504      
  5505      var properties = function () {
  5506          return [
  5507              new Property({
  5508                  name: 'coinbase',
  5509                  getter: 'eth_coinbase'
  5510              }),
  5511              new Property({
  5512                  name: 'mining',
  5513                  getter: 'eth_mining'
  5514              }),
  5515              new Property({
  5516                  name: 'hashrate',
  5517                  getter: 'eth_hashrate',
  5518                  outputFormatter: utils.toDecimal
  5519              }),
  5520              new Property({
  5521                  name: 'syncing',
  5522                  getter: 'eth_syncing',
  5523                  outputFormatter: formatters.outputSyncingFormatter
  5524              }),
  5525              new Property({
  5526                  name: 'gasPrice',
  5527                  getter: 'eth_gasPrice',
  5528                  outputFormatter: formatters.outputBigNumberFormatter
  5529              }),
  5530              new Property({
  5531                  name: 'accounts',
  5532                  getter: 'eth_accounts'
  5533              }),
  5534              new Property({
  5535                  name: 'blockNumber',
  5536                  getter: 'eth_blockNumber',
  5537                  outputFormatter: utils.toDecimal
  5538              }),
  5539              new Property({
  5540                  name: 'protocolVersion',
  5541                  getter: 'eth_protocolVersion'
  5542              })
  5543          ];
  5544      };
  5545      
  5546      Eth.prototype.contract = function (abi) {
  5547          var factory = new Contract(this, abi);
  5548          return factory;
  5549      };
  5550      
  5551      Eth.prototype.filter = function (options, callback, filterCreationErrorCallback) {
  5552          return new Filter(options, 'eth', this._requestManager, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
  5553      };
  5554      
  5555      Eth.prototype.namereg = function () {
  5556          return this.contract(namereg.global.abi).at(namereg.global.address);
  5557      };
  5558      
  5559      Eth.prototype.icapNamereg = function () {
  5560          return this.contract(namereg.icap.abi).at(namereg.icap.address);
  5561      };
  5562      
  5563      Eth.prototype.isSyncing = function (callback) {
  5564          return new IsSyncing(this._requestManager, callback);
  5565      };
  5566      
  5567      module.exports = Eth;
  5568      
  5569      },{"../../utils/config":18,"../../utils/utils":20,"../contract":25,"../filter":29,"../formatters":30,"../iban":33,"../method":36,"../namereg":44,"../property":45,"../syncing":48,"../transfer":49,"./watches":43}],39:[function(require,module,exports){
  5570      /*
  5571          This file is part of web3.js.
  5572      
  5573          web3.js is free software: you can redistribute it and/or modify
  5574          it under the terms of the GNU Lesser General Public License as published by
  5575          the Free Software Foundation, either version 3 of the License, or
  5576          (at your option) any later version.
  5577      
  5578          web3.js is distributed in the hope that it will be useful,
  5579          but WITHOUT ANY WARRANTY; without even the implied warranty of
  5580          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5581          GNU Lesser General Public License for more details.
  5582      
  5583          You should have received a copy of the GNU Lesser General Public License
  5584          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5585      */
  5586      /** @file eth.js
  5587       * @authors:
  5588       *   Marek Kotewicz <marek@ethdev.com>
  5589       * @date 2015
  5590       */
  5591      
  5592      var utils = require('../../utils/utils');
  5593      var Property = require('../property');
  5594      
  5595      var Net = function (web3) {
  5596          this._requestManager = web3._requestManager;
  5597      
  5598          var self = this;
  5599      
  5600          properties().forEach(function(p) { 
  5601              p.attachToObject(self);
  5602              p.setRequestManager(web3._requestManager);
  5603          });
  5604      };
  5605      
  5606      /// @returns an array of objects describing web3.eth api properties
  5607      var properties = function () {
  5608          return [
  5609              new Property({
  5610                  name: 'listening',
  5611                  getter: 'net_listening'
  5612              }),
  5613              new Property({
  5614                  name: 'peerCount',
  5615                  getter: 'net_peerCount',
  5616                  outputFormatter: utils.toDecimal
  5617              })
  5618          ];
  5619      };
  5620      
  5621      module.exports = Net;
  5622      
  5623      },{"../../utils/utils":20,"../property":45}],40:[function(require,module,exports){
  5624      /*
  5625          This file is part of web3.js.
  5626      
  5627          web3.js is free software: you can redistribute it and/or modify
  5628          it under the terms of the GNU Lesser General Public License as published by
  5629          the Free Software Foundation, either version 3 of the License, or
  5630          (at your option) any later version.
  5631      
  5632          web3.js is distributed in the hope that it will be useful,
  5633          but WITHOUT ANY WARRANTY; without even the implied warranty of
  5634          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5635          GNU Lesser General Public License for more details.
  5636      
  5637          You should have received a copy of the GNU Lesser General Public License
  5638          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5639      */
  5640      /**
  5641       * @file eth.js
  5642       * @author Marek Kotewicz <marek@ethdev.com>
  5643       * @author Fabian Vogelsteller <fabian@ethdev.com>
  5644       * @date 2015
  5645       */
  5646      
  5647      "use strict";
  5648      
  5649      var Method = require('../method');
  5650      var Property = require('../property');
  5651      var formatters = require('../formatters');
  5652      
  5653      function Personal(web3) {
  5654          this._requestManager = web3._requestManager;
  5655      
  5656          var self = this;
  5657      
  5658          methods().forEach(function(method) {
  5659              method.attachToObject(self);
  5660              method.setRequestManager(self._requestManager);
  5661          });
  5662      
  5663          properties().forEach(function(p) {
  5664              p.attachToObject(self);
  5665              p.setRequestManager(self._requestManager);
  5666          });
  5667      }
  5668      
  5669      var methods = function () {
  5670          var newAccount = new Method({
  5671              name: 'newAccount',
  5672              call: 'personal_newAccount',
  5673              params: 1,
  5674              inputFormatter: [null]
  5675          });
  5676      
  5677          var importRawKey = new Method({
  5678              name: 'importRawKey',
  5679              call: 'personal_importRawKey',
  5680              params: 2
  5681          });
  5682      
  5683          var sign = new Method({
  5684              name: 'sign',
  5685              call: 'personal_sign',
  5686              params: 3,
  5687              inputFormatter: [null, formatters.inputAddressFormatter, null]
  5688          });
  5689      
  5690          var ecRecover = new Method({
  5691              name: 'ecRecover',
  5692              call: 'personal_ecRecover',
  5693              params: 2
  5694          });
  5695      
  5696          var unlockAccount = new Method({
  5697              name: 'unlockAccount',
  5698              call: 'personal_unlockAccount',
  5699              params: 3,
  5700              inputFormatter: [formatters.inputAddressFormatter, null, null]
  5701          });
  5702      
  5703          var sendTransaction = new Method({
  5704              name: 'sendTransaction',
  5705              call: 'personal_sendTransaction',
  5706              params: 2,
  5707              inputFormatter: [formatters.inputTransactionFormatter, null]
  5708          });
  5709      
  5710          var lockAccount = new Method({
  5711              name: 'lockAccount',
  5712              call: 'personal_lockAccount',
  5713              params: 1,
  5714              inputFormatter: [formatters.inputAddressFormatter]
  5715          });
  5716      
  5717          return [
  5718              newAccount,
  5719              importRawKey,
  5720              unlockAccount,
  5721              ecRecover,
  5722              sign,
  5723              sendTransaction,
  5724              lockAccount
  5725          ];
  5726      };
  5727      
  5728      var properties = function () {
  5729          return [
  5730              new Property({
  5731                  name: 'listAccounts',
  5732                  getter: 'personal_listAccounts'
  5733              })
  5734          ];
  5735      };
  5736      
  5737      
  5738      module.exports = Personal;
  5739      
  5740      },{"../formatters":30,"../method":36,"../property":45}],41:[function(require,module,exports){
  5741      /*
  5742          This file is part of web3.js.
  5743      
  5744          web3.js is free software: you can redistribute it and/or modify
  5745          it under the terms of the GNU Lesser General Public License as published by
  5746          the Free Software Foundation, either version 3 of the License, or
  5747          (at your option) any later version.
  5748      
  5749          web3.js is distributed in the hope that it will be useful,
  5750          but WITHOUT ANY WARRANTY; without even the implied warranty of
  5751          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5752          GNU Lesser General Public License for more details.
  5753      
  5754          You should have received a copy of the GNU Lesser General Public License
  5755          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5756      */
  5757      /** @file shh.js
  5758       * @authors:
  5759       *   Fabian Vogelsteller <fabian@ethereum.org>
  5760       *   Marek Kotewicz <marek@ethcore.io>
  5761       * @date 2017
  5762       */
  5763      
  5764      var Method = require('../method');
  5765      var Filter = require('../filter');
  5766      var watches = require('./watches');
  5767      
  5768      var Shh = function (web3) {
  5769          this._requestManager = web3._requestManager;
  5770      
  5771          var self = this;
  5772      
  5773          methods().forEach(function(method) {
  5774              method.attachToObject(self);
  5775              method.setRequestManager(self._requestManager);
  5776          });
  5777      };
  5778      
  5779      Shh.prototype.newMessageFilter = function (options, callback, filterCreationErrorCallback) {
  5780          return new Filter(options, 'shh', this._requestManager, watches.shh(), null, callback, filterCreationErrorCallback);
  5781      };
  5782      
  5783      var methods = function () {
  5784      
  5785          return [
  5786              new Method({
  5787                  name: 'version',
  5788                  call: 'shh_version',
  5789                  params: 0
  5790              }),
  5791              new Method({
  5792                  name: 'info',
  5793                  call: 'shh_info',
  5794                  params: 0
  5795              }),
  5796              new Method({
  5797                  name: 'setMaxMessageSize',
  5798                  call: 'shh_setMaxMessageSize',
  5799                  params: 1
  5800              }),
  5801              new Method({
  5802                  name: 'setMinPoW',
  5803                  call: 'shh_setMinPoW',
  5804                  params: 1
  5805              }),
  5806              new Method({
  5807                  name: 'markTrustedPeer',
  5808                  call: 'shh_markTrustedPeer',
  5809                  params: 1
  5810              }),
  5811              new Method({
  5812                  name: 'newKeyPair',
  5813                  call: 'shh_newKeyPair',
  5814                  params: 0
  5815              }),
  5816              new Method({
  5817                  name: 'addPrivateKey',
  5818                  call: 'shh_addPrivateKey',
  5819                  params: 1
  5820              }),
  5821              new Method({
  5822                  name: 'deleteKeyPair',
  5823                  call: 'shh_deleteKeyPair',
  5824                  params: 1
  5825              }),
  5826              new Method({
  5827                  name: 'hasKeyPair',
  5828                  call: 'shh_hasKeyPair',
  5829                  params: 1
  5830              }),
  5831              new Method({
  5832                  name: 'getPublicKey',
  5833                  call: 'shh_getPublicKey',
  5834                  params: 1
  5835              }),
  5836              new Method({
  5837                  name: 'getPrivateKey',
  5838                  call: 'shh_getPrivateKey',
  5839                  params: 1
  5840              }),
  5841              new Method({
  5842                  name: 'newSymKey',
  5843                  call: 'shh_newSymKey',
  5844                  params: 0
  5845              }),
  5846              new Method({
  5847                  name: 'addSymKey',
  5848                  call: 'shh_addSymKey',
  5849                  params: 1
  5850              }),
  5851              new Method({
  5852                  name: 'generateSymKeyFromPassword',
  5853                  call: 'shh_generateSymKeyFromPassword',
  5854                  params: 1
  5855              }),
  5856              new Method({
  5857                  name: 'hasSymKey',
  5858                  call: 'shh_hasSymKey',
  5859                  params: 1
  5860              }),
  5861              new Method({
  5862                  name: 'getSymKey',
  5863                  call: 'shh_getSymKey',
  5864                  params: 1
  5865              }),
  5866              new Method({
  5867                  name: 'deleteSymKey',
  5868                  call: 'shh_deleteSymKey',
  5869                  params: 1
  5870              }),
  5871      
  5872              // subscribe and unsubscribe missing
  5873      
  5874              new Method({
  5875                  name: 'post',
  5876                  call: 'shh_post',
  5877                  params: 1,
  5878                  inputFormatter: [null]
  5879              })
  5880          ];
  5881      };
  5882      
  5883      module.exports = Shh;
  5884      
  5885      
  5886      },{"../filter":29,"../method":36,"./watches":43}],42:[function(require,module,exports){
  5887      /*
  5888          This file is part of web3.js.
  5889      
  5890          web3.js is free software: you can redistribute it and/or modify
  5891          it under the terms of the GNU Lesser General Public License as published by
  5892          the Free Software Foundation, either version 3 of the License, or
  5893          (at your option) any later version.
  5894      
  5895          web3.js is distributed in the hope that it will be useful,
  5896          but WITHOUT ANY WARRANTY; without even the implied warranty of
  5897          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5898          GNU Lesser General Public License for more details.
  5899      
  5900          You should have received a copy of the GNU Lesser General Public License
  5901          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5902      */
  5903      /**
  5904       * @file bzz.js
  5905       * @author Alex Beregszaszi <alex@rtfs.hu>
  5906       * @date 2016
  5907       *
  5908       * Reference: https://github.com/ethereum/go-ethereum/blob/swarm/internal/web3ext/web3ext.go#L33
  5909       */
  5910      
  5911      "use strict";
  5912      
  5913      var Method = require('../method');
  5914      var Property = require('../property');
  5915      
  5916      function Swarm(web3) {
  5917          this._requestManager = web3._requestManager;
  5918      
  5919          var self = this;
  5920      
  5921          methods().forEach(function(method) {
  5922              method.attachToObject(self);
  5923              method.setRequestManager(self._requestManager);
  5924          });
  5925      
  5926          properties().forEach(function(p) {
  5927              p.attachToObject(self);
  5928              p.setRequestManager(self._requestManager);
  5929          });
  5930      }
  5931      
  5932      var methods = function () {
  5933          var blockNetworkRead = new Method({
  5934              name: 'blockNetworkRead',
  5935              call: 'bzz_blockNetworkRead',
  5936              params: 1,
  5937              inputFormatter: [null]
  5938          });
  5939      
  5940          var syncEnabled = new Method({
  5941              name: 'syncEnabled',
  5942              call: 'bzz_syncEnabled',
  5943              params: 1,
  5944              inputFormatter: [null]
  5945          });
  5946      
  5947          var swapEnabled = new Method({
  5948              name: 'swapEnabled',
  5949              call: 'bzz_swapEnabled',
  5950              params: 1,
  5951              inputFormatter: [null]
  5952          });
  5953      
  5954          var download = new Method({
  5955              name: 'download',
  5956              call: 'bzz_download',
  5957              params: 2,
  5958              inputFormatter: [null, null]
  5959          });
  5960      
  5961          var upload = new Method({
  5962              name: 'upload',
  5963              call: 'bzz_upload',
  5964              params: 2,
  5965              inputFormatter: [null, null]
  5966          });
  5967      
  5968          var retrieve = new Method({
  5969              name: 'retrieve',
  5970              call: 'bzz_retrieve',
  5971              params: 1,
  5972              inputFormatter: [null]
  5973          });
  5974      
  5975          var store = new Method({
  5976              name: 'store',
  5977              call: 'bzz_store',
  5978              params: 2,
  5979              inputFormatter: [null, null]
  5980          });
  5981      
  5982          var get = new Method({
  5983              name: 'get',
  5984              call: 'bzz_get',
  5985              params: 1,
  5986              inputFormatter: [null]
  5987          });
  5988      
  5989          var put = new Method({
  5990              name: 'put',
  5991              call: 'bzz_put',
  5992              params: 2,
  5993              inputFormatter: [null, null]
  5994          });
  5995      
  5996          var modify = new Method({
  5997              name: 'modify',
  5998              call: 'bzz_modify',
  5999              params: 4,
  6000              inputFormatter: [null, null, null, null]
  6001          });
  6002      
  6003          return [
  6004              blockNetworkRead,
  6005              syncEnabled,
  6006              swapEnabled,
  6007              download,
  6008              upload,
  6009              retrieve,
  6010              store,
  6011              get,
  6012              put,
  6013              modify
  6014          ];
  6015      };
  6016      
  6017      var properties = function () {
  6018          return [
  6019              new Property({
  6020                  name: 'hive',
  6021                  getter: 'bzz_hive'
  6022              }),
  6023              new Property({
  6024                  name: 'info',
  6025                  getter: 'bzz_info'
  6026              })
  6027          ];
  6028      };
  6029      
  6030      
  6031      module.exports = Swarm;
  6032      
  6033      },{"../method":36,"../property":45}],43:[function(require,module,exports){
  6034      /*
  6035          This file is part of web3.js.
  6036      
  6037          web3.js is free software: you can redistribute it and/or modify
  6038          it under the terms of the GNU Lesser General Public License as published by
  6039          the Free Software Foundation, either version 3 of the License, or
  6040          (at your option) any later version.
  6041      
  6042          web3.js is distributed in the hope that it will be useful,
  6043          but WITHOUT ANY WARRANTY; without even the implied warranty of
  6044          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6045          GNU Lesser General Public License for more details.
  6046      
  6047          You should have received a copy of the GNU Lesser General Public License
  6048          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6049      */
  6050      /** @file watches.js
  6051       * @authors:
  6052       *   Marek Kotewicz <marek@ethdev.com>
  6053       * @date 2015
  6054       */
  6055      
  6056      var Method = require('../method');
  6057      
  6058      /// @returns an array of objects describing web3.eth.filter api methods
  6059      var eth = function () {
  6060          var newFilterCall = function (args) {
  6061              var type = args[0];
  6062      
  6063              switch(type) {
  6064                  case 'latest':
  6065                      args.shift();
  6066                      this.params = 0;
  6067                      return 'eth_newBlockFilter';
  6068                  case 'pending':
  6069                      args.shift();
  6070                      this.params = 0;
  6071                      return 'eth_newPendingTransactionFilter';
  6072                  default:
  6073                      return 'eth_newFilter';
  6074              }
  6075          };
  6076      
  6077          var newFilter = new Method({
  6078              name: 'newFilter',
  6079              call: newFilterCall,
  6080              params: 1
  6081          });
  6082      
  6083          var uninstallFilter = new Method({
  6084              name: 'uninstallFilter',
  6085              call: 'eth_uninstallFilter',
  6086              params: 1
  6087          });
  6088      
  6089          var getLogs = new Method({
  6090              name: 'getLogs',
  6091              call: 'eth_getFilterLogs',
  6092              params: 1
  6093          });
  6094      
  6095          var poll = new Method({
  6096              name: 'poll',
  6097              call: 'eth_getFilterChanges',
  6098              params: 1
  6099          });
  6100      
  6101          return [
  6102              newFilter,
  6103              uninstallFilter,
  6104              getLogs,
  6105              poll
  6106          ];
  6107      };
  6108      
  6109      /// @returns an array of objects describing web3.shh.watch api methods
  6110      var shh = function () {
  6111      
  6112          return [
  6113              new Method({
  6114                  name: 'newFilter',
  6115                  call: 'shh_newMessageFilter',
  6116                  params: 1
  6117              }),
  6118              new Method({
  6119                  name: 'uninstallFilter',
  6120                  call: 'shh_deleteMessageFilter',
  6121                  params: 1
  6122              }),
  6123              new Method({
  6124                  name: 'getLogs',
  6125                  call: 'shh_getFilterMessages',
  6126                  params: 1
  6127              }),
  6128              new Method({
  6129                  name: 'poll',
  6130                  call: 'shh_getFilterMessages',
  6131                  params: 1
  6132              })
  6133          ];
  6134      };
  6135      
  6136      module.exports = {
  6137          eth: eth,
  6138          shh: shh
  6139      };
  6140      
  6141      
  6142      },{"../method":36}],44:[function(require,module,exports){
  6143      /*
  6144          This file is part of web3.js.
  6145      
  6146          web3.js is free software: you can redistribute it and/or modify
  6147          it under the terms of the GNU Lesser General Public License as published by
  6148          the Free Software Foundation, either version 3 of the License, or
  6149          (at your option) any later version.
  6150      
  6151          web3.js is distributed in the hope that it will be useful,
  6152          but WITHOUT ANY WARRANTY; without even the implied warranty of
  6153          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6154          GNU Lesser General Public License for more details.
  6155      
  6156          You should have received a copy of the GNU Lesser General Public License
  6157          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6158      */
  6159      /** 
  6160       * @file namereg.js
  6161       * @author Marek Kotewicz <marek@ethdev.com>
  6162       * @date 2015
  6163       */
  6164      
  6165      var globalRegistrarAbi = require('../contracts/GlobalRegistrar.json');
  6166      var icapRegistrarAbi= require('../contracts/ICAPRegistrar.json');
  6167      
  6168      var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
  6169      var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
  6170      
  6171      module.exports = {
  6172          global: {
  6173              abi: globalRegistrarAbi,
  6174              address: globalNameregAddress
  6175          },
  6176          icap: {
  6177              abi: icapRegistrarAbi,
  6178              address: icapNameregAddress
  6179          }
  6180      };
  6181      
  6182      
  6183      },{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],45:[function(require,module,exports){
  6184      /*
  6185          This file is part of web3.js.
  6186      
  6187          web3.js is free software: you can redistribute it and/or modify
  6188          it under the terms of the GNU Lesser General Public License as published by
  6189          the Free Software Foundation, either version 3 of the License, or
  6190          (at your option) any later version.
  6191      
  6192          web3.js is distributed in the hope that it will be useful,
  6193          but WITHOUT ANY WARRANTY; without even the implied warranty of
  6194          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6195          GNU Lesser General Public License for more details.
  6196      
  6197          You should have received a copy of the GNU Lesser General Public License
  6198          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6199      */
  6200      /**
  6201       * @file property.js
  6202       * @author Fabian Vogelsteller <fabian@frozeman.de>
  6203       * @author Marek Kotewicz <marek@ethdev.com>
  6204       * @date 2015
  6205       */
  6206      
  6207      var utils = require('../utils/utils');
  6208      
  6209      var Property = function (options) {
  6210          this.name = options.name;
  6211          this.getter = options.getter;
  6212          this.setter = options.setter;
  6213          this.outputFormatter = options.outputFormatter;
  6214          this.inputFormatter = options.inputFormatter;
  6215          this.requestManager = null;
  6216      };
  6217      
  6218      Property.prototype.setRequestManager = function (rm) {
  6219          this.requestManager = rm;
  6220      };
  6221      
  6222      /**
  6223       * Should be called to format input args of method
  6224       *
  6225       * @method formatInput
  6226       * @param {Array}
  6227       * @return {Array}
  6228       */
  6229      Property.prototype.formatInput = function (arg) {
  6230          return this.inputFormatter ? this.inputFormatter(arg) : arg;
  6231      };
  6232      
  6233      /**
  6234       * Should be called to format output(result) of method
  6235       *
  6236       * @method formatOutput
  6237       * @param {Object}
  6238       * @return {Object}
  6239       */
  6240      Property.prototype.formatOutput = function (result) {
  6241          return this.outputFormatter && result !== null && result !== undefined ? this.outputFormatter(result) : result;
  6242      };
  6243      
  6244      /**
  6245       * Should be used to extract callback from array of arguments. Modifies input param
  6246       *
  6247       * @method extractCallback
  6248       * @param {Array} arguments
  6249       * @return {Function|Null} callback, if exists
  6250       */
  6251      Property.prototype.extractCallback = function (args) {
  6252          if (utils.isFunction(args[args.length - 1])) {
  6253              return args.pop(); // modify the args array!
  6254          }
  6255      };
  6256      
  6257      
  6258      /**
  6259       * Should attach function to method
  6260       *
  6261       * @method attachToObject
  6262       * @param {Object}
  6263       * @param {Function}
  6264       */
  6265      Property.prototype.attachToObject = function (obj) {
  6266          var proto = {
  6267              get: this.buildGet(),
  6268              enumerable: true
  6269          };
  6270      
  6271          var names = this.name.split('.');
  6272          var name = names[0];
  6273          if (names.length > 1) {
  6274              obj[names[0]] = obj[names[0]] || {};
  6275              obj = obj[names[0]];
  6276              name = names[1];
  6277          }
  6278      
  6279          Object.defineProperty(obj, name, proto);
  6280          obj[asyncGetterName(name)] = this.buildAsyncGet();
  6281      };
  6282      
  6283      var asyncGetterName = function (name) {
  6284          return 'get' + name.charAt(0).toUpperCase() + name.slice(1);
  6285      };
  6286      
  6287      Property.prototype.buildGet = function () {
  6288          var property = this;
  6289          return function get() {
  6290              return property.formatOutput(property.requestManager.send({
  6291                  method: property.getter
  6292              }));
  6293          };
  6294      };
  6295      
  6296      Property.prototype.buildAsyncGet = function () {
  6297          var property = this;
  6298          var get = function (callback) {
  6299              property.requestManager.sendAsync({
  6300                  method: property.getter
  6301              }, function (err, result) {
  6302                  callback(err, property.formatOutput(result));
  6303              });
  6304          };
  6305          get.request = this.request.bind(this);
  6306          return get;
  6307      };
  6308      
  6309      /**
  6310       * Should be called to create pure JSONRPC request which can be used in batch request
  6311       *
  6312       * @method request
  6313       * @param {...} params
  6314       * @return {Object} jsonrpc request
  6315       */
  6316      Property.prototype.request = function () {
  6317          var payload = {
  6318              method: this.getter,
  6319              params: [],
  6320              callback: this.extractCallback(Array.prototype.slice.call(arguments))
  6321          };
  6322          payload.format = this.formatOutput.bind(this);
  6323          return payload;
  6324      };
  6325      
  6326      module.exports = Property;
  6327      
  6328      
  6329      },{"../utils/utils":20}],46:[function(require,module,exports){
  6330      /*
  6331          This file is part of web3.js.
  6332      
  6333          web3.js is free software: you can redistribute it and/or modify
  6334          it under the terms of the GNU Lesser General Public License as published by
  6335          the Free Software Foundation, either version 3 of the License, or
  6336          (at your option) any later version.
  6337      
  6338          web3.js is distributed in the hope that it will be useful,
  6339          but WITHOUT ANY WARRANTY; without even the implied warranty of
  6340          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6341          GNU Lesser General Public License for more details.
  6342      
  6343          You should have received a copy of the GNU Lesser General Public License
  6344          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6345      */
  6346      /** 
  6347       * @file requestmanager.js
  6348       * @author Jeffrey Wilcke <jeff@ethdev.com>
  6349       * @author Marek Kotewicz <marek@ethdev.com>
  6350       * @author Marian Oancea <marian@ethdev.com>
  6351       * @author Fabian Vogelsteller <fabian@ethdev.com>
  6352       * @author Gav Wood <g@ethdev.com>
  6353       * @date 2014
  6354       */
  6355      
  6356      var Jsonrpc = require('./jsonrpc');
  6357      var utils = require('../utils/utils');
  6358      var c = require('../utils/config');
  6359      var errors = require('./errors');
  6360      
  6361      /**
  6362       * It's responsible for passing messages to providers
  6363       * It's also responsible for polling the ethereum node for incoming messages
  6364       * Default poll timeout is 1 second
  6365       * Singleton
  6366       */
  6367      var RequestManager = function (provider) {
  6368          this.provider = provider;
  6369          this.polls = {};
  6370          this.timeout = null;
  6371      };
  6372      
  6373      /**
  6374       * Should be used to synchronously send request
  6375       *
  6376       * @method send
  6377       * @param {Object} data
  6378       * @return {Object}
  6379       */
  6380      RequestManager.prototype.send = function (data) {
  6381          if (!this.provider) {
  6382              console.error(errors.InvalidProvider());
  6383              return null;
  6384          }
  6385      
  6386          var payload = Jsonrpc.toPayload(data.method, data.params);
  6387          var result = this.provider.send(payload);
  6388      
  6389          if (!Jsonrpc.isValidResponse(result)) {
  6390              throw errors.InvalidResponse(result);
  6391          }
  6392      
  6393          return result.result;
  6394      };
  6395      
  6396      /**
  6397       * Should be used to asynchronously send request
  6398       *
  6399       * @method sendAsync
  6400       * @param {Object} data
  6401       * @param {Function} callback
  6402       */
  6403      RequestManager.prototype.sendAsync = function (data, callback) {
  6404          if (!this.provider) {
  6405              return callback(errors.InvalidProvider());
  6406          }
  6407      
  6408          var payload = Jsonrpc.toPayload(data.method, data.params);
  6409          this.provider.sendAsync(payload, function (err, result) {
  6410              if (err) {
  6411                  return callback(err);
  6412              }
  6413              
  6414              if (!Jsonrpc.isValidResponse(result)) {
  6415                  return callback(errors.InvalidResponse(result));
  6416              }
  6417      
  6418              callback(null, result.result);
  6419          });
  6420      };
  6421      
  6422      /**
  6423       * Should be called to asynchronously send batch request
  6424       *
  6425       * @method sendBatch
  6426       * @param {Array} batch data
  6427       * @param {Function} callback
  6428       */
  6429      RequestManager.prototype.sendBatch = function (data, callback) {
  6430          if (!this.provider) {
  6431              return callback(errors.InvalidProvider());
  6432          }
  6433      
  6434          var payload = Jsonrpc.toBatchPayload(data);
  6435      
  6436          this.provider.sendAsync(payload, function (err, results) {
  6437              if (err) {
  6438                  return callback(err);
  6439              }
  6440      
  6441              if (!utils.isArray(results)) {
  6442                  return callback(errors.InvalidResponse(results));
  6443              }
  6444      
  6445              callback(err, results);
  6446          }); 
  6447      };
  6448      
  6449      /**
  6450       * Should be used to set provider of request manager
  6451       *
  6452       * @method setProvider
  6453       * @param {Object}
  6454       */
  6455      RequestManager.prototype.setProvider = function (p) {
  6456          this.provider = p;
  6457      };
  6458      
  6459      /**
  6460       * Should be used to start polling
  6461       *
  6462       * @method startPolling
  6463       * @param {Object} data
  6464       * @param {Number} pollId
  6465       * @param {Function} callback
  6466       * @param {Function} uninstall
  6467       *
  6468       * @todo cleanup number of params
  6469       */
  6470      RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
  6471          this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
  6472      
  6473      
  6474          // start polling
  6475          if (!this.timeout) {
  6476              this.poll();
  6477          }
  6478      };
  6479      
  6480      /**
  6481       * Should be used to stop polling for filter with given id
  6482       *
  6483       * @method stopPolling
  6484       * @param {Number} pollId
  6485       */
  6486      RequestManager.prototype.stopPolling = function (pollId) {
  6487          delete this.polls[pollId];
  6488      
  6489          // stop polling
  6490          if(Object.keys(this.polls).length === 0 && this.timeout) {
  6491              clearTimeout(this.timeout);
  6492              this.timeout = null;
  6493          }
  6494      };
  6495      
  6496      /**
  6497       * Should be called to reset the polling mechanism of the request manager
  6498       *
  6499       * @method reset
  6500       */
  6501      RequestManager.prototype.reset = function (keepIsSyncing) {
  6502          /*jshint maxcomplexity:5 */
  6503      
  6504          for (var key in this.polls) {
  6505              // remove all polls, except sync polls,
  6506              // they need to be removed manually by calling syncing.stopWatching()
  6507              if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) {
  6508                  this.polls[key].uninstall();
  6509                  delete this.polls[key];
  6510              }
  6511          }
  6512      
  6513          // stop polling
  6514          if(Object.keys(this.polls).length === 0 && this.timeout) {
  6515              clearTimeout(this.timeout);
  6516              this.timeout = null;
  6517          }
  6518      };
  6519      
  6520      /**
  6521       * Should be called to poll for changes on filter with given id
  6522       *
  6523       * @method poll
  6524       */
  6525      RequestManager.prototype.poll = function () {
  6526          /*jshint maxcomplexity: 6 */
  6527          this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
  6528      
  6529          if (Object.keys(this.polls).length === 0) {
  6530              return;
  6531          }
  6532      
  6533          if (!this.provider) {
  6534              console.error(errors.InvalidProvider());
  6535              return;
  6536          }
  6537      
  6538          var pollsData = [];
  6539          var pollsIds = [];
  6540          for (var key in this.polls) {
  6541              pollsData.push(this.polls[key].data);
  6542              pollsIds.push(key);
  6543          }
  6544      
  6545          if (pollsData.length === 0) {
  6546              return;
  6547          }
  6548      
  6549          var payload = Jsonrpc.toBatchPayload(pollsData);
  6550          
  6551          // map the request id to they poll id
  6552          var pollsIdMap = {};
  6553          payload.forEach(function(load, index){
  6554              pollsIdMap[load.id] = pollsIds[index];
  6555          });
  6556      
  6557      
  6558          var self = this;
  6559          this.provider.sendAsync(payload, function (error, results) {
  6560      
  6561      
  6562              // TODO: console log?
  6563              if (error) {
  6564                  return;
  6565              }
  6566      
  6567              if (!utils.isArray(results)) {
  6568                  throw errors.InvalidResponse(results);
  6569              }
  6570              results.map(function (result) {
  6571                  var id = pollsIdMap[result.id];
  6572      
  6573                  // make sure the filter is still installed after arrival of the request
  6574                  if (self.polls[id]) {
  6575                      result.callback = self.polls[id].callback;
  6576                      return result;
  6577                  } else
  6578                      return false;
  6579              }).filter(function (result) {
  6580                  return !!result; 
  6581              }).filter(function (result) {
  6582                  var valid = Jsonrpc.isValidResponse(result);
  6583                  if (!valid) {
  6584                      result.callback(errors.InvalidResponse(result));
  6585                  }
  6586                  return valid;
  6587              }).forEach(function (result) {
  6588                  result.callback(null, result.result);
  6589              });
  6590          });
  6591      };
  6592      
  6593      module.exports = RequestManager;
  6594      
  6595      
  6596      },{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],47:[function(require,module,exports){
  6597      
  6598      
  6599      var Settings = function () {
  6600          this.defaultBlock = 'latest';
  6601          this.defaultAccount = undefined;
  6602      };
  6603      
  6604      module.exports = Settings;
  6605      
  6606      
  6607      },{}],48:[function(require,module,exports){
  6608      /*
  6609          This file is part of web3.js.
  6610      
  6611          web3.js is free software: you can redistribute it and/or modify
  6612          it under the terms of the GNU Lesser General Public License as published by
  6613          the Free Software Foundation, either version 3 of the License, or
  6614          (at your option) any later version.
  6615      
  6616          web3.js is distributed in the hope that it will be useful,
  6617          but WITHOUT ANY WARRANTY; without even the implied warranty of
  6618          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6619          GNU Lesser General Public License for more details.
  6620      
  6621          You should have received a copy of the GNU Lesser General Public License
  6622          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6623      */
  6624      /** @file syncing.js
  6625       * @authors:
  6626       *   Fabian Vogelsteller <fabian@ethdev.com>
  6627       * @date 2015
  6628       */
  6629      
  6630      var formatters = require('./formatters');
  6631      var utils = require('../utils/utils');
  6632      
  6633      var count = 1;
  6634      
  6635      /**
  6636      Adds the callback and sets up the methods, to iterate over the results.
  6637      
  6638      @method pollSyncing
  6639      @param {Object} self
  6640      */
  6641      var pollSyncing = function(self) {
  6642      
  6643          var onMessage = function (error, sync) {
  6644              if (error) {
  6645                  return self.callbacks.forEach(function (callback) {
  6646                      callback(error);
  6647                  });
  6648              }
  6649      
  6650              if(utils.isObject(sync) && sync.startingBlock)
  6651                  sync = formatters.outputSyncingFormatter(sync);
  6652      
  6653              self.callbacks.forEach(function (callback) {
  6654                  if (self.lastSyncState !== sync) {
  6655                      
  6656                      // call the callback with true first so the app can stop anything, before receiving the sync data
  6657                      if(!self.lastSyncState && utils.isObject(sync))
  6658                          callback(null, true);
  6659                      
  6660                      // call on the next CPU cycle, so the actions of the sync stop can be processes first
  6661                      setTimeout(function() {
  6662                          callback(null, sync);
  6663                      }, 0);
  6664                      
  6665                      self.lastSyncState = sync;
  6666                  }
  6667              });
  6668          };
  6669      
  6670          self.requestManager.startPolling({
  6671              method: 'eth_syncing',
  6672              params: [],
  6673          }, self.pollId, onMessage, self.stopWatching.bind(self));
  6674      
  6675      };
  6676      
  6677      var IsSyncing = function (requestManager, callback) {
  6678          this.requestManager = requestManager;
  6679          this.pollId = 'syncPoll_'+ count++;
  6680          this.callbacks = [];
  6681          this.addCallback(callback);
  6682          this.lastSyncState = false;
  6683          pollSyncing(this);
  6684      
  6685          return this;
  6686      };
  6687      
  6688      IsSyncing.prototype.addCallback = function (callback) {
  6689          if(callback)
  6690              this.callbacks.push(callback);
  6691          return this;
  6692      };
  6693      
  6694      IsSyncing.prototype.stopWatching = function () {
  6695          this.requestManager.stopPolling(this.pollId);
  6696          this.callbacks = [];
  6697      };
  6698      
  6699      module.exports = IsSyncing;
  6700      
  6701      
  6702      },{"../utils/utils":20,"./formatters":30}],49:[function(require,module,exports){
  6703      /*
  6704          This file is part of web3.js.
  6705      
  6706          web3.js is free software: you can redistribute it and/or modify
  6707          it under the terms of the GNU Lesser General Public License as published by
  6708          the Free Software Foundation, either version 3 of the License, or
  6709          (at your option) any later version.
  6710      
  6711          web3.js is distributed in the hope that it will be useful,
  6712          but WITHOUT ANY WARRANTY; without even the implied warranty of
  6713          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6714          GNU Lesser General Public License for more details.
  6715      
  6716          You should have received a copy of the GNU Lesser General Public License
  6717          along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6718      */
  6719      /** 
  6720       * @file transfer.js
  6721       * @author Marek Kotewicz <marek@ethdev.com>
  6722       * @date 2015
  6723       */
  6724      
  6725      var Iban = require('./iban');
  6726      var exchangeAbi = require('../contracts/SmartExchange.json');
  6727      
  6728      /**
  6729       * Should be used to make Iban transfer
  6730       *
  6731       * @method transfer
  6732       * @param {String} from
  6733       * @param {String} to iban
  6734       * @param {Value} value to be tranfered
  6735       * @param {Function} callback, callback
  6736       */
  6737      var transfer = function (eth, from, to, value, callback) {
  6738          var iban = new Iban(to); 
  6739          if (!iban.isValid()) {
  6740              throw new Error('invalid iban address');
  6741          }
  6742      
  6743          if (iban.isDirect()) {
  6744              return transferToAddress(eth, from, iban.address(), value, callback);
  6745          }
  6746          
  6747          if (!callback) {
  6748              var address = eth.icapNamereg().addr(iban.institution());
  6749              return deposit(eth, from, address, value, iban.client());
  6750          }
  6751      
  6752          eth.icapNamereg().addr(iban.institution(), function (err, address) {
  6753              return deposit(eth, from, address, value, iban.client(), callback);
  6754          });
  6755          
  6756      };
  6757      
  6758      /**
  6759       * Should be used to transfer funds to certain address
  6760       *
  6761       * @method transferToAddress
  6762       * @param {String} from
  6763       * @param {String} to
  6764       * @param {Value} value to be tranfered
  6765       * @param {Function} callback, callback
  6766       */
  6767      var transferToAddress = function (eth, from, to, value, callback) {
  6768          return eth.sendTransaction({
  6769              address: to,
  6770              from: from,
  6771              value: value
  6772          }, callback);
  6773      };
  6774      
  6775      /**
  6776       * Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
  6777       *
  6778       * @method deposit
  6779       * @param {String} from
  6780       * @param {String} to
  6781       * @param {Value} value to be transferred
  6782       * @param {String} client unique identifier
  6783       * @param {Function} callback, callback
  6784       */
  6785      var deposit = function (eth, from, to, value, client, callback) {
  6786          var abi = exchangeAbi;
  6787          return eth.contract(abi).at(to).deposit(client, {
  6788              from: from,
  6789              value: value
  6790          }, callback);
  6791      };
  6792      
  6793      module.exports = transfer;
  6794      
  6795      
  6796      },{"../contracts/SmartExchange.json":3,"./iban":33}],50:[function(require,module,exports){
  6797      
  6798      },{}],51:[function(require,module,exports){
  6799      ;(function (root, factory, undef) {
  6800          if (typeof exports === "object") {
  6801              // CommonJS
  6802              module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  6803          }
  6804          else if (typeof define === "function" && define.amd) {
  6805              // AMD
  6806              define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  6807          }
  6808          else {
  6809              // Global (browser)
  6810              factory(root.CryptoJS);
  6811          }
  6812      }(this, function (CryptoJS) {
  6813      
  6814          (function () {
  6815              // Shortcuts
  6816              var C = CryptoJS;
  6817              var C_lib = C.lib;
  6818              var BlockCipher = C_lib.BlockCipher;
  6819              var C_algo = C.algo;
  6820      
  6821              // Lookup tables
  6822              var SBOX = [];
  6823              var INV_SBOX = [];
  6824              var SUB_MIX_0 = [];
  6825              var SUB_MIX_1 = [];
  6826              var SUB_MIX_2 = [];
  6827              var SUB_MIX_3 = [];
  6828              var INV_SUB_MIX_0 = [];
  6829              var INV_SUB_MIX_1 = [];
  6830              var INV_SUB_MIX_2 = [];
  6831              var INV_SUB_MIX_3 = [];
  6832      
  6833              // Compute lookup tables
  6834              (function () {
  6835                  // Compute double table
  6836                  var d = [];
  6837                  for (var i = 0; i < 256; i++) {
  6838                      if (i < 128) {
  6839                          d[i] = i << 1;
  6840                      } else {
  6841                          d[i] = (i << 1) ^ 0x11b;
  6842                      }
  6843                  }
  6844      
  6845                  // Walk GF(2^8)
  6846                  var x = 0;
  6847                  var xi = 0;
  6848                  for (var i = 0; i < 256; i++) {
  6849                      // Compute sbox
  6850                      var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  6851                      sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  6852                      SBOX[x] = sx;
  6853                      INV_SBOX[sx] = x;
  6854      
  6855                      // Compute multiplication
  6856                      var x2 = d[x];
  6857                      var x4 = d[x2];
  6858                      var x8 = d[x4];
  6859      
  6860                      // Compute sub bytes, mix columns tables
  6861                      var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  6862                      SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  6863                      SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  6864                      SUB_MIX_2[x] = (t << 8)  | (t >>> 24);
  6865                      SUB_MIX_3[x] = t;
  6866      
  6867                      // Compute inv sub bytes, inv mix columns tables
  6868                      var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  6869                      INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  6870                      INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  6871                      INV_SUB_MIX_2[sx] = (t << 8)  | (t >>> 24);
  6872                      INV_SUB_MIX_3[sx] = t;
  6873      
  6874                      // Compute next counter
  6875                      if (!x) {
  6876                          x = xi = 1;
  6877                      } else {
  6878                          x = x2 ^ d[d[d[x8 ^ x2]]];
  6879                          xi ^= d[d[xi]];
  6880                      }
  6881                  }
  6882              }());
  6883      
  6884              // Precomputed Rcon lookup
  6885              var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  6886      
  6887              /**
  6888               * AES block cipher algorithm.
  6889               */
  6890              var AES = C_algo.AES = BlockCipher.extend({
  6891                  _doReset: function () {
  6892                      // Skip reset of nRounds has been set before and key did not change
  6893                      if (this._nRounds && this._keyPriorReset === this._key) {
  6894                          return;
  6895                      }
  6896      
  6897                      // Shortcuts
  6898                      var key = this._keyPriorReset = this._key;
  6899                      var keyWords = key.words;
  6900                      var keySize = key.sigBytes / 4;
  6901      
  6902                      // Compute number of rounds
  6903                      var nRounds = this._nRounds = keySize + 6;
  6904      
  6905                      // Compute number of key schedule rows
  6906                      var ksRows = (nRounds + 1) * 4;
  6907      
  6908                      // Compute key schedule
  6909                      var keySchedule = this._keySchedule = [];
  6910                      for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  6911                          if (ksRow < keySize) {
  6912                              keySchedule[ksRow] = keyWords[ksRow];
  6913                          } else {
  6914                              var t = keySchedule[ksRow - 1];
  6915      
  6916                              if (!(ksRow % keySize)) {
  6917                                  // Rot word
  6918                                  t = (t << 8) | (t >>> 24);
  6919      
  6920                                  // Sub word
  6921                                  t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6922      
  6923                                  // Mix Rcon
  6924                                  t ^= RCON[(ksRow / keySize) | 0] << 24;
  6925                              } else if (keySize > 6 && ksRow % keySize == 4) {
  6926                                  // Sub word
  6927                                  t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6928                              }
  6929      
  6930                              keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  6931                          }
  6932                      }
  6933      
  6934                      // Compute inv key schedule
  6935                      var invKeySchedule = this._invKeySchedule = [];
  6936                      for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  6937                          var ksRow = ksRows - invKsRow;
  6938      
  6939                          if (invKsRow % 4) {
  6940                              var t = keySchedule[ksRow];
  6941                          } else {
  6942                              var t = keySchedule[ksRow - 4];
  6943                          }
  6944      
  6945                          if (invKsRow < 4 || ksRow <= 4) {
  6946                              invKeySchedule[invKsRow] = t;
  6947                          } else {
  6948                              invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  6949                                                         INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  6950                          }
  6951                      }
  6952                  },
  6953      
  6954                  encryptBlock: function (M, offset) {
  6955                      this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  6956                  },
  6957      
  6958                  decryptBlock: function (M, offset) {
  6959                      // Swap 2nd and 4th rows
  6960                      var t = M[offset + 1];
  6961                      M[offset + 1] = M[offset + 3];
  6962                      M[offset + 3] = t;
  6963      
  6964                      this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  6965      
  6966                      // Inv swap 2nd and 4th rows
  6967                      var t = M[offset + 1];
  6968                      M[offset + 1] = M[offset + 3];
  6969                      M[offset + 3] = t;
  6970                  },
  6971      
  6972                  _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  6973                      // Shortcut
  6974                      var nRounds = this._nRounds;
  6975      
  6976                      // Get input, add round key
  6977                      var s0 = M[offset]     ^ keySchedule[0];
  6978                      var s1 = M[offset + 1] ^ keySchedule[1];
  6979                      var s2 = M[offset + 2] ^ keySchedule[2];
  6980                      var s3 = M[offset + 3] ^ keySchedule[3];
  6981      
  6982                      // Key schedule row counter
  6983                      var ksRow = 4;
  6984      
  6985                      // Rounds
  6986                      for (var round = 1; round < nRounds; round++) {
  6987                          // Shift rows, sub bytes, mix columns, add round key
  6988                          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++];
  6989                          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++];
  6990                          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++];
  6991                          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++];
  6992      
  6993                          // Update state
  6994                          s0 = t0;
  6995                          s1 = t1;
  6996                          s2 = t2;
  6997                          s3 = t3;
  6998                      }
  6999      
  7000                      // Shift rows, sub bytes, add round key
  7001                      var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  7002                      var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  7003                      var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  7004                      var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  7005      
  7006                      // Set output
  7007                      M[offset]     = t0;
  7008                      M[offset + 1] = t1;
  7009                      M[offset + 2] = t2;
  7010                      M[offset + 3] = t3;
  7011                  },
  7012      
  7013                  keySize: 256/32
  7014              });
  7015      
  7016              /**
  7017               * Shortcut functions to the cipher's object interface.
  7018               *
  7019               * @example
  7020               *
  7021               *     var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  7022               *     var plaintext  = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  7023               */
  7024              C.AES = BlockCipher._createHelper(AES);
  7025          }());
  7026      
  7027      
  7028          return CryptoJS.AES;
  7029      
  7030      }));
  7031      },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],52:[function(require,module,exports){
  7032      ;(function (root, factory) {
  7033          if (typeof exports === "object") {
  7034              // CommonJS
  7035              module.exports = exports = factory(require("./core"));
  7036          }
  7037          else if (typeof define === "function" && define.amd) {
  7038              // AMD
  7039              define(["./core"], factory);
  7040          }
  7041          else {
  7042              // Global (browser)
  7043              factory(root.CryptoJS);
  7044          }
  7045      }(this, function (CryptoJS) {
  7046      
  7047          /**
  7048           * Cipher core components.
  7049           */
  7050          CryptoJS.lib.Cipher || (function (undefined) {
  7051              // Shortcuts
  7052              var C = CryptoJS;
  7053              var C_lib = C.lib;
  7054              var Base = C_lib.Base;
  7055              var WordArray = C_lib.WordArray;
  7056              var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  7057              var C_enc = C.enc;
  7058              var Utf8 = C_enc.Utf8;
  7059              var Base64 = C_enc.Base64;
  7060              var C_algo = C.algo;
  7061              var EvpKDF = C_algo.EvpKDF;
  7062      
  7063              /**
  7064               * Abstract base cipher template.
  7065               *
  7066               * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  7067               * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  7068               * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  7069               * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  7070               */
  7071              var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  7072                  /**
  7073                   * Configuration options.
  7074                   *
  7075                   * @property {WordArray} iv The IV to use for this operation.
  7076                   */
  7077                  cfg: Base.extend(),
  7078      
  7079                  /**
  7080                   * Creates this cipher in encryption mode.
  7081                   *
  7082                   * @param {WordArray} key The key.
  7083                   * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7084                   *
  7085                   * @return {Cipher} A cipher instance.
  7086                   *
  7087                   * @static
  7088                   *
  7089                   * @example
  7090                   *
  7091                   *     var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  7092                   */
  7093                  createEncryptor: function (key, cfg) {
  7094                      return this.create(this._ENC_XFORM_MODE, key, cfg);
  7095                  },
  7096      
  7097                  /**
  7098                   * Creates this cipher in decryption mode.
  7099                   *
  7100                   * @param {WordArray} key The key.
  7101                   * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7102                   *
  7103                   * @return {Cipher} A cipher instance.
  7104                   *
  7105                   * @static
  7106                   *
  7107                   * @example
  7108                   *
  7109                   *     var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  7110                   */
  7111                  createDecryptor: function (key, cfg) {
  7112                      return this.create(this._DEC_XFORM_MODE, key, cfg);
  7113                  },
  7114      
  7115                  /**
  7116                   * Initializes a newly created cipher.
  7117                   *
  7118                   * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  7119                   * @param {WordArray} key The key.
  7120                   * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7121                   *
  7122                   * @example
  7123                   *
  7124                   *     var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  7125                   */
  7126                  init: function (xformMode, key, cfg) {
  7127                      // Apply config defaults
  7128                      this.cfg = this.cfg.extend(cfg);
  7129      
  7130                      // Store transform mode and key
  7131                      this._xformMode = xformMode;
  7132                      this._key = key;
  7133      
  7134                      // Set initial values
  7135                      this.reset();
  7136                  },
  7137      
  7138                  /**
  7139                   * Resets this cipher to its initial state.
  7140                   *
  7141                   * @example
  7142                   *
  7143                   *     cipher.reset();
  7144                   */
  7145                  reset: function () {
  7146                      // Reset data buffer
  7147                      BufferedBlockAlgorithm.reset.call(this);
  7148      
  7149                      // Perform concrete-cipher logic
  7150                      this._doReset();
  7151                  },
  7152      
  7153                  /**
  7154                   * Adds data to be encrypted or decrypted.
  7155                   *
  7156                   * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  7157                   *
  7158                   * @return {WordArray} The data after processing.
  7159                   *
  7160                   * @example
  7161                   *
  7162                   *     var encrypted = cipher.process('data');
  7163                   *     var encrypted = cipher.process(wordArray);
  7164                   */
  7165                  process: function (dataUpdate) {
  7166                      // Append
  7167                      this._append(dataUpdate);
  7168      
  7169                      // Process available blocks
  7170                      return this._process();
  7171                  },
  7172      
  7173                  /**
  7174                   * Finalizes the encryption or decryption process.
  7175                   * Note that the finalize operation is effectively a destructive, read-once operation.
  7176                   *
  7177                   * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  7178                   *
  7179                   * @return {WordArray} The data after final processing.
  7180                   *
  7181                   * @example
  7182                   *
  7183                   *     var encrypted = cipher.finalize();
  7184                   *     var encrypted = cipher.finalize('data');
  7185                   *     var encrypted = cipher.finalize(wordArray);
  7186                   */
  7187                  finalize: function (dataUpdate) {
  7188                      // Final data update
  7189                      if (dataUpdate) {
  7190                          this._append(dataUpdate);
  7191                      }
  7192      
  7193                      // Perform concrete-cipher logic
  7194                      var finalProcessedData = this._doFinalize();
  7195      
  7196                      return finalProcessedData;
  7197                  },
  7198      
  7199                  keySize: 128/32,
  7200      
  7201                  ivSize: 128/32,
  7202      
  7203                  _ENC_XFORM_MODE: 1,
  7204      
  7205                  _DEC_XFORM_MODE: 2,
  7206      
  7207                  /**
  7208                   * Creates shortcut functions to a cipher's object interface.
  7209                   *
  7210                   * @param {Cipher} cipher The cipher to create a helper for.
  7211                   *
  7212                   * @return {Object} An object with encrypt and decrypt shortcut functions.
  7213                   *
  7214                   * @static
  7215                   *
  7216                   * @example
  7217                   *
  7218                   *     var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  7219                   */
  7220                  _createHelper: (function () {
  7221                      function selectCipherStrategy(key) {
  7222                          if (typeof key == 'string') {
  7223                              return PasswordBasedCipher;
  7224                          } else {
  7225                              return SerializableCipher;
  7226                          }
  7227                      }
  7228      
  7229                      return function (cipher) {
  7230                          return {
  7231                              encrypt: function (message, key, cfg) {
  7232                                  return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  7233                              },
  7234      
  7235                              decrypt: function (ciphertext, key, cfg) {
  7236                                  return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  7237                              }
  7238                          };
  7239                      };
  7240                  }())
  7241              });
  7242      
  7243              /**
  7244               * Abstract base stream cipher template.
  7245               *
  7246               * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  7247               */
  7248              var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  7249                  _doFinalize: function () {
  7250                      // Process partial blocks
  7251                      var finalProcessedBlocks = this._process(!!'flush');
  7252      
  7253                      return finalProcessedBlocks;
  7254                  },
  7255      
  7256                  blockSize: 1
  7257              });
  7258      
  7259              /**
  7260               * Mode namespace.
  7261               */
  7262              var C_mode = C.mode = {};
  7263      
  7264              /**
  7265               * Abstract base block cipher mode template.
  7266               */
  7267              var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  7268                  /**
  7269                   * Creates this mode for encryption.
  7270                   *
  7271                   * @param {Cipher} cipher A block cipher instance.
  7272                   * @param {Array} iv The IV words.
  7273                   *
  7274                   * @static
  7275                   *
  7276                   * @example
  7277                   *
  7278                   *     var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  7279                   */
  7280                  createEncryptor: function (cipher, iv) {
  7281                      return this.Encryptor.create(cipher, iv);
  7282                  },
  7283      
  7284                  /**
  7285                   * Creates this mode for decryption.
  7286                   *
  7287                   * @param {Cipher} cipher A block cipher instance.
  7288                   * @param {Array} iv The IV words.
  7289                   *
  7290                   * @static
  7291                   *
  7292                   * @example
  7293                   *
  7294                   *     var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  7295                   */
  7296                  createDecryptor: function (cipher, iv) {
  7297                      return this.Decryptor.create(cipher, iv);
  7298                  },
  7299      
  7300                  /**
  7301                   * Initializes a newly created mode.
  7302                   *
  7303                   * @param {Cipher} cipher A block cipher instance.
  7304                   * @param {Array} iv The IV words.
  7305                   *
  7306                   * @example
  7307                   *
  7308                   *     var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  7309                   */
  7310                  init: function (cipher, iv) {
  7311                      this._cipher = cipher;
  7312                      this._iv = iv;
  7313                  }
  7314              });
  7315      
  7316              /**
  7317               * Cipher Block Chaining mode.
  7318               */
  7319              var CBC = C_mode.CBC = (function () {
  7320                  /**
  7321                   * Abstract base CBC mode.
  7322                   */
  7323                  var CBC = BlockCipherMode.extend();
  7324      
  7325                  /**
  7326                   * CBC encryptor.
  7327                   */
  7328                  CBC.Encryptor = CBC.extend({
  7329                      /**
  7330                       * Processes the data block at offset.
  7331                       *
  7332                       * @param {Array} words The data words to operate on.
  7333                       * @param {number} offset The offset where the block starts.
  7334                       *
  7335                       * @example
  7336                       *
  7337                       *     mode.processBlock(data.words, offset);
  7338                       */
  7339                      processBlock: function (words, offset) {
  7340                          // Shortcuts
  7341                          var cipher = this._cipher;
  7342                          var blockSize = cipher.blockSize;
  7343      
  7344                          // XOR and encrypt
  7345                          xorBlock.call(this, words, offset, blockSize);
  7346                          cipher.encryptBlock(words, offset);
  7347      
  7348                          // Remember this block to use with next block
  7349                          this._prevBlock = words.slice(offset, offset + blockSize);
  7350                      }
  7351                  });
  7352      
  7353                  /**
  7354                   * CBC decryptor.
  7355                   */
  7356                  CBC.Decryptor = CBC.extend({
  7357                      /**
  7358                       * Processes the data block at offset.
  7359                       *
  7360                       * @param {Array} words The data words to operate on.
  7361                       * @param {number} offset The offset where the block starts.
  7362                       *
  7363                       * @example
  7364                       *
  7365                       *     mode.processBlock(data.words, offset);
  7366                       */
  7367                      processBlock: function (words, offset) {
  7368                          // Shortcuts
  7369                          var cipher = this._cipher;
  7370                          var blockSize = cipher.blockSize;
  7371      
  7372                          // Remember this block to use with next block
  7373                          var thisBlock = words.slice(offset, offset + blockSize);
  7374      
  7375                          // Decrypt and XOR
  7376                          cipher.decryptBlock(words, offset);
  7377                          xorBlock.call(this, words, offset, blockSize);
  7378      
  7379                          // This block becomes the previous block
  7380                          this._prevBlock = thisBlock;
  7381                      }
  7382                  });
  7383      
  7384                  function xorBlock(words, offset, blockSize) {
  7385                      // Shortcut
  7386                      var iv = this._iv;
  7387      
  7388                      // Choose mixing block
  7389                      if (iv) {
  7390                          var block = iv;
  7391      
  7392                          // Remove IV for subsequent blocks
  7393                          this._iv = undefined;
  7394                      } else {
  7395                          var block = this._prevBlock;
  7396                      }
  7397      
  7398                      // XOR blocks
  7399                      for (var i = 0; i < blockSize; i++) {
  7400                          words[offset + i] ^= block[i];
  7401                      }
  7402                  }
  7403      
  7404                  return CBC;
  7405              }());
  7406      
  7407              /**
  7408               * Padding namespace.
  7409               */
  7410              var C_pad = C.pad = {};
  7411      
  7412              /**
  7413               * PKCS #5/7 padding strategy.
  7414               */
  7415              var Pkcs7 = C_pad.Pkcs7 = {
  7416                  /**
  7417                   * Pads data using the algorithm defined in PKCS #5/7.
  7418                   *
  7419                   * @param {WordArray} data The data to pad.
  7420                   * @param {number} blockSize The multiple that the data should be padded to.
  7421                   *
  7422                   * @static
  7423                   *
  7424                   * @example
  7425                   *
  7426                   *     CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  7427                   */
  7428                  pad: function (data, blockSize) {
  7429                      // Shortcut
  7430                      var blockSizeBytes = blockSize * 4;
  7431      
  7432                      // Count padding bytes
  7433                      var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  7434      
  7435                      // Create padding word
  7436                      var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  7437      
  7438                      // Create padding
  7439                      var paddingWords = [];
  7440                      for (var i = 0; i < nPaddingBytes; i += 4) {
  7441                          paddingWords.push(paddingWord);
  7442                      }
  7443                      var padding = WordArray.create(paddingWords, nPaddingBytes);
  7444      
  7445                      // Add padding
  7446                      data.concat(padding);
  7447                  },
  7448      
  7449                  /**
  7450                   * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  7451                   *
  7452                   * @param {WordArray} data The data to unpad.
  7453                   *
  7454                   * @static
  7455                   *
  7456                   * @example
  7457                   *
  7458                   *     CryptoJS.pad.Pkcs7.unpad(wordArray);
  7459                   */
  7460                  unpad: function (data) {
  7461                      // Get number of padding bytes from last byte
  7462                      var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  7463      
  7464                      // Remove padding
  7465                      data.sigBytes -= nPaddingBytes;
  7466                  }
  7467              };
  7468      
  7469              /**
  7470               * Abstract base block cipher template.
  7471               *
  7472               * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  7473               */
  7474              var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  7475                  /**
  7476                   * Configuration options.
  7477                   *
  7478                   * @property {Mode} mode The block mode to use. Default: CBC
  7479                   * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  7480                   */
  7481                  cfg: Cipher.cfg.extend({
  7482                      mode: CBC,
  7483                      padding: Pkcs7
  7484                  }),
  7485      
  7486                  reset: function () {
  7487                      // Reset cipher
  7488                      Cipher.reset.call(this);
  7489      
  7490                      // Shortcuts
  7491                      var cfg = this.cfg;
  7492                      var iv = cfg.iv;
  7493                      var mode = cfg.mode;
  7494      
  7495                      // Reset block mode
  7496                      if (this._xformMode == this._ENC_XFORM_MODE) {
  7497                          var modeCreator = mode.createEncryptor;
  7498                      } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7499                          var modeCreator = mode.createDecryptor;
  7500      
  7501                          // Keep at least one block in the buffer for unpadding
  7502                          this._minBufferSize = 1;
  7503                      }
  7504                      this._mode = modeCreator.call(mode, this, iv && iv.words);
  7505                  },
  7506      
  7507                  _doProcessBlock: function (words, offset) {
  7508                      this._mode.processBlock(words, offset);
  7509                  },
  7510      
  7511                  _doFinalize: function () {
  7512                      // Shortcut
  7513                      var padding = this.cfg.padding;
  7514      
  7515                      // Finalize
  7516                      if (this._xformMode == this._ENC_XFORM_MODE) {
  7517                          // Pad data
  7518                          padding.pad(this._data, this.blockSize);
  7519      
  7520                          // Process final blocks
  7521                          var finalProcessedBlocks = this._process(!!'flush');
  7522                      } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7523                          // Process final blocks
  7524                          var finalProcessedBlocks = this._process(!!'flush');
  7525      
  7526                          // Unpad data
  7527                          padding.unpad(finalProcessedBlocks);
  7528                      }
  7529      
  7530                      return finalProcessedBlocks;
  7531                  },
  7532      
  7533                  blockSize: 128/32
  7534              });
  7535      
  7536              /**
  7537               * A collection of cipher parameters.
  7538               *
  7539               * @property {WordArray} ciphertext The raw ciphertext.
  7540               * @property {WordArray} key The key to this ciphertext.
  7541               * @property {WordArray} iv The IV used in the ciphering operation.
  7542               * @property {WordArray} salt The salt used with a key derivation function.
  7543               * @property {Cipher} algorithm The cipher algorithm.
  7544               * @property {Mode} mode The block mode used in the ciphering operation.
  7545               * @property {Padding} padding The padding scheme used in the ciphering operation.
  7546               * @property {number} blockSize The block size of the cipher.
  7547               * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  7548               */
  7549              var CipherParams = C_lib.CipherParams = Base.extend({
  7550                  /**
  7551                   * Initializes a newly created cipher params object.
  7552                   *
  7553                   * @param {Object} cipherParams An object with any of the possible cipher parameters.
  7554                   *
  7555                   * @example
  7556                   *
  7557                   *     var cipherParams = CryptoJS.lib.CipherParams.create({
  7558                   *         ciphertext: ciphertextWordArray,
  7559                   *         key: keyWordArray,
  7560                   *         iv: ivWordArray,
  7561                   *         salt: saltWordArray,
  7562                   *         algorithm: CryptoJS.algo.AES,
  7563                   *         mode: CryptoJS.mode.CBC,
  7564                   *         padding: CryptoJS.pad.PKCS7,
  7565                   *         blockSize: 4,
  7566                   *         formatter: CryptoJS.format.OpenSSL
  7567                   *     });
  7568                   */
  7569                  init: function (cipherParams) {
  7570                      this.mixIn(cipherParams);
  7571                  },
  7572      
  7573                  /**
  7574                   * Converts this cipher params object to a string.
  7575                   *
  7576                   * @param {Format} formatter (Optional) The formatting strategy to use.
  7577                   *
  7578                   * @return {string} The stringified cipher params.
  7579                   *
  7580                   * @throws Error If neither the formatter nor the default formatter is set.
  7581                   *
  7582                   * @example
  7583                   *
  7584                   *     var string = cipherParams + '';
  7585                   *     var string = cipherParams.toString();
  7586                   *     var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  7587                   */
  7588                  toString: function (formatter) {
  7589                      return (formatter || this.formatter).stringify(this);
  7590                  }
  7591              });
  7592      
  7593              /**
  7594               * Format namespace.
  7595               */
  7596              var C_format = C.format = {};
  7597      
  7598              /**
  7599               * OpenSSL formatting strategy.
  7600               */
  7601              var OpenSSLFormatter = C_format.OpenSSL = {
  7602                  /**
  7603                   * Converts a cipher params object to an OpenSSL-compatible string.
  7604                   *
  7605                   * @param {CipherParams} cipherParams The cipher params object.
  7606                   *
  7607                   * @return {string} The OpenSSL-compatible string.
  7608                   *
  7609                   * @static
  7610                   *
  7611                   * @example
  7612                   *
  7613                   *     var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  7614                   */
  7615                  stringify: function (cipherParams) {
  7616                      // Shortcuts
  7617                      var ciphertext = cipherParams.ciphertext;
  7618                      var salt = cipherParams.salt;
  7619      
  7620                      // Format
  7621                      if (salt) {
  7622                          var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  7623                      } else {
  7624                          var wordArray = ciphertext;
  7625                      }
  7626      
  7627                      return wordArray.toString(Base64);
  7628                  },
  7629      
  7630                  /**
  7631                   * Converts an OpenSSL-compatible string to a cipher params object.
  7632                   *
  7633                   * @param {string} openSSLStr The OpenSSL-compatible string.
  7634                   *
  7635                   * @return {CipherParams} The cipher params object.
  7636                   *
  7637                   * @static
  7638                   *
  7639                   * @example
  7640                   *
  7641                   *     var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  7642                   */
  7643                  parse: function (openSSLStr) {
  7644                      // Parse base64
  7645                      var ciphertext = Base64.parse(openSSLStr);
  7646      
  7647                      // Shortcut
  7648                      var ciphertextWords = ciphertext.words;
  7649      
  7650                      // Test for salt
  7651                      if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  7652                          // Extract salt
  7653                          var salt = WordArray.create(ciphertextWords.slice(2, 4));
  7654      
  7655                          // Remove salt from ciphertext
  7656                          ciphertextWords.splice(0, 4);
  7657                          ciphertext.sigBytes -= 16;
  7658                      }
  7659      
  7660                      return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  7661                  }
  7662              };
  7663      
  7664              /**
  7665               * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  7666               */
  7667              var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  7668                  /**
  7669                   * Configuration options.
  7670                   *
  7671                   * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  7672                   */
  7673                  cfg: Base.extend({
  7674                      format: OpenSSLFormatter
  7675                  }),
  7676      
  7677                  /**
  7678                   * Encrypts a message.
  7679                   *
  7680                   * @param {Cipher} cipher The cipher algorithm to use.
  7681                   * @param {WordArray|string} message The message to encrypt.
  7682                   * @param {WordArray} key The key.
  7683                   * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7684                   *
  7685                   * @return {CipherParams} A cipher params object.
  7686                   *
  7687                   * @static
  7688                   *
  7689                   * @example
  7690                   *
  7691                   *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  7692                   *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  7693                   *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7694                   */
  7695                  encrypt: function (cipher, message, key, cfg) {
  7696                      // Apply config defaults
  7697                      cfg = this.cfg.extend(cfg);
  7698      
  7699                      // Encrypt
  7700                      var encryptor = cipher.createEncryptor(key, cfg);
  7701                      var ciphertext = encryptor.finalize(message);
  7702      
  7703                      // Shortcut
  7704                      var cipherCfg = encryptor.cfg;
  7705      
  7706                      // Create and return serializable cipher params
  7707                      return CipherParams.create({
  7708                          ciphertext: ciphertext,
  7709                          key: key,
  7710                          iv: cipherCfg.iv,
  7711                          algorithm: cipher,
  7712                          mode: cipherCfg.mode,
  7713                          padding: cipherCfg.padding,
  7714                          blockSize: cipher.blockSize,
  7715                          formatter: cfg.format
  7716                      });
  7717                  },
  7718      
  7719                  /**
  7720                   * Decrypts serialized ciphertext.
  7721                   *
  7722                   * @param {Cipher} cipher The cipher algorithm to use.
  7723                   * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7724                   * @param {WordArray} key The key.
  7725                   * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7726                   *
  7727                   * @return {WordArray} The plaintext.
  7728                   *
  7729                   * @static
  7730                   *
  7731                   * @example
  7732                   *
  7733                   *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7734                   *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7735                   */
  7736                  decrypt: function (cipher, ciphertext, key, cfg) {
  7737                      // Apply config defaults
  7738                      cfg = this.cfg.extend(cfg);
  7739      
  7740                      // Convert string to CipherParams
  7741                      ciphertext = this._parse(ciphertext, cfg.format);
  7742      
  7743                      // Decrypt
  7744                      var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  7745      
  7746                      return plaintext;
  7747                  },
  7748      
  7749                  /**
  7750                   * Converts serialized ciphertext to CipherParams,
  7751                   * else assumed CipherParams already and returns ciphertext unchanged.
  7752                   *
  7753                   * @param {CipherParams|string} ciphertext The ciphertext.
  7754                   * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  7755                   *
  7756                   * @return {CipherParams} The unserialized ciphertext.
  7757                   *
  7758                   * @static
  7759                   *
  7760                   * @example
  7761                   *
  7762                   *     var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  7763                   */
  7764                  _parse: function (ciphertext, format) {
  7765                      if (typeof ciphertext == 'string') {
  7766                          return format.parse(ciphertext, this);
  7767                      } else {
  7768                          return ciphertext;
  7769                      }
  7770                  }
  7771              });
  7772      
  7773              /**
  7774               * Key derivation function namespace.
  7775               */
  7776              var C_kdf = C.kdf = {};
  7777      
  7778              /**
  7779               * OpenSSL key derivation function.
  7780               */
  7781              var OpenSSLKdf = C_kdf.OpenSSL = {
  7782                  /**
  7783                   * Derives a key and IV from a password.
  7784                   *
  7785                   * @param {string} password The password to derive from.
  7786                   * @param {number} keySize The size in words of the key to generate.
  7787                   * @param {number} ivSize The size in words of the IV to generate.
  7788                   * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  7789                   *
  7790                   * @return {CipherParams} A cipher params object with the key, IV, and salt.
  7791                   *
  7792                   * @static
  7793                   *
  7794                   * @example
  7795                   *
  7796                   *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  7797                   *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  7798                   */
  7799                  execute: function (password, keySize, ivSize, salt) {
  7800                      // Generate random salt
  7801                      if (!salt) {
  7802                          salt = WordArray.random(64/8);
  7803                      }
  7804      
  7805                      // Derive key and IV
  7806                      var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  7807      
  7808                      // Separate key and IV
  7809                      var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  7810                      key.sigBytes = keySize * 4;
  7811      
  7812                      // Return params
  7813                      return CipherParams.create({ key: key, iv: iv, salt: salt });
  7814                  }
  7815              };
  7816      
  7817              /**
  7818               * A serializable cipher wrapper that derives the key from a password,
  7819               * and returns ciphertext as a serializable cipher params object.
  7820               */
  7821              var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  7822                  /**
  7823                   * Configuration options.
  7824                   *
  7825                   * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  7826                   */
  7827                  cfg: SerializableCipher.cfg.extend({
  7828                      kdf: OpenSSLKdf
  7829                  }),
  7830      
  7831                  /**
  7832                   * Encrypts a message using a password.
  7833                   *
  7834                   * @param {Cipher} cipher The cipher algorithm to use.
  7835                   * @param {WordArray|string} message The message to encrypt.
  7836                   * @param {string} password The password.
  7837                   * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7838                   *
  7839                   * @return {CipherParams} A cipher params object.
  7840                   *
  7841                   * @static
  7842                   *
  7843                   * @example
  7844                   *
  7845                   *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  7846                   *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  7847                   */
  7848                  encrypt: function (cipher, message, password, cfg) {
  7849                      // Apply config defaults
  7850                      cfg = this.cfg.extend(cfg);
  7851      
  7852                      // Derive key and other params
  7853                      var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  7854      
  7855                      // Add IV to config
  7856                      cfg.iv = derivedParams.iv;
  7857      
  7858                      // Encrypt
  7859                      var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  7860      
  7861                      // Mix in derived params
  7862                      ciphertext.mixIn(derivedParams);
  7863      
  7864                      return ciphertext;
  7865                  },
  7866      
  7867                  /**
  7868                   * Decrypts serialized ciphertext using a password.
  7869                   *
  7870                   * @param {Cipher} cipher The cipher algorithm to use.
  7871                   * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7872                   * @param {string} password The password.
  7873                   * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7874                   *
  7875                   * @return {WordArray} The plaintext.
  7876                   *
  7877                   * @static
  7878                   *
  7879                   * @example
  7880                   *
  7881                   *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  7882                   *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  7883                   */
  7884                  decrypt: function (cipher, ciphertext, password, cfg) {
  7885                      // Apply config defaults
  7886                      cfg = this.cfg.extend(cfg);
  7887      
  7888                      // Convert string to CipherParams
  7889                      ciphertext = this._parse(ciphertext, cfg.format);
  7890      
  7891                      // Derive key and other params
  7892                      var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  7893      
  7894                      // Add IV to config
  7895                      cfg.iv = derivedParams.iv;
  7896      
  7897                      // Decrypt
  7898                      var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  7899      
  7900                      return plaintext;
  7901                  }
  7902              });
  7903          }());
  7904      
  7905      
  7906      }));
  7907      },{"./core":53}],53:[function(require,module,exports){
  7908      ;(function (root, factory) {
  7909          if (typeof exports === "object") {
  7910              // CommonJS
  7911              module.exports = exports = factory();
  7912          }
  7913          else if (typeof define === "function" && define.amd) {
  7914              // AMD
  7915              define([], factory);
  7916          }
  7917          else {
  7918              // Global (browser)
  7919              root.CryptoJS = factory();
  7920          }
  7921      }(this, function () {
  7922      
  7923          /**
  7924           * CryptoJS core components.
  7925           */
  7926          var CryptoJS = CryptoJS || (function (Math, undefined) {
  7927              /*
  7928               * Local polyfil of Object.create
  7929               */
  7930              var create = Object.create || (function () {
  7931                  function F() {};
  7932      
  7933                  return function (obj) {
  7934                      var subtype;
  7935      
  7936                      F.prototype = obj;
  7937      
  7938                      subtype = new F();
  7939      
  7940                      F.prototype = null;
  7941      
  7942                      return subtype;
  7943                  };
  7944              }())
  7945      
  7946              /**
  7947               * CryptoJS namespace.
  7948               */
  7949              var C = {};
  7950      
  7951              /**
  7952               * Library namespace.
  7953               */
  7954              var C_lib = C.lib = {};
  7955      
  7956              /**
  7957               * Base object for prototypal inheritance.
  7958               */
  7959              var Base = C_lib.Base = (function () {
  7960      
  7961      
  7962                  return {
  7963                      /**
  7964                       * Creates a new object that inherits from this object.
  7965                       *
  7966                       * @param {Object} overrides Properties to copy into the new object.
  7967                       *
  7968                       * @return {Object} The new object.
  7969                       *
  7970                       * @static
  7971                       *
  7972                       * @example
  7973                       *
  7974                       *     var MyType = CryptoJS.lib.Base.extend({
  7975                       *         field: 'value',
  7976                       *
  7977                       *         method: function () {
  7978                       *         }
  7979                       *     });
  7980                       */
  7981                      extend: function (overrides) {
  7982                          // Spawn
  7983                          var subtype = create(this);
  7984      
  7985                          // Augment
  7986                          if (overrides) {
  7987                              subtype.mixIn(overrides);
  7988                          }
  7989      
  7990                          // Create default initializer
  7991                          if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  7992                              subtype.init = function () {
  7993                                  subtype.$super.init.apply(this, arguments);
  7994                              };
  7995                          }
  7996      
  7997                          // Initializer's prototype is the subtype object
  7998                          subtype.init.prototype = subtype;
  7999      
  8000                          // Reference supertype
  8001                          subtype.$super = this;
  8002      
  8003                          return subtype;
  8004                      },
  8005      
  8006                      /**
  8007                       * Extends this object and runs the init method.
  8008                       * Arguments to create() will be passed to init().
  8009                       *
  8010                       * @return {Object} The new object.
  8011                       *
  8012                       * @static
  8013                       *
  8014                       * @example
  8015                       *
  8016                       *     var instance = MyType.create();
  8017                       */
  8018                      create: function () {
  8019                          var instance = this.extend();
  8020                          instance.init.apply(instance, arguments);
  8021      
  8022                          return instance;
  8023                      },
  8024      
  8025                      /**
  8026                       * Initializes a newly created object.
  8027                       * Override this method to add some logic when your objects are created.
  8028                       *
  8029                       * @example
  8030                       *
  8031                       *     var MyType = CryptoJS.lib.Base.extend({
  8032                       *         init: function () {
  8033                       *             // ...
  8034                       *         }
  8035                       *     });
  8036                       */
  8037                      init: function () {
  8038                      },
  8039      
  8040                      /**
  8041                       * Copies properties into this object.
  8042                       *
  8043                       * @param {Object} properties The properties to mix in.
  8044                       *
  8045                       * @example
  8046                       *
  8047                       *     MyType.mixIn({
  8048                       *         field: 'value'
  8049                       *     });
  8050                       */
  8051                      mixIn: function (properties) {
  8052                          for (var propertyName in properties) {
  8053                              if (properties.hasOwnProperty(propertyName)) {
  8054                                  this[propertyName] = properties[propertyName];
  8055                              }
  8056                          }
  8057      
  8058                          // IE won't copy toString using the loop above
  8059                          if (properties.hasOwnProperty('toString')) {
  8060                              this.toString = properties.toString;
  8061                          }
  8062                      },
  8063      
  8064                      /**
  8065                       * Creates a copy of this object.
  8066                       *
  8067                       * @return {Object} The clone.
  8068                       *
  8069                       * @example
  8070                       *
  8071                       *     var clone = instance.clone();
  8072                       */
  8073                      clone: function () {
  8074                          return this.init.prototype.extend(this);
  8075                      }
  8076                  };
  8077              }());
  8078      
  8079              /**
  8080               * An array of 32-bit words.
  8081               *
  8082               * @property {Array} words The array of 32-bit words.
  8083               * @property {number} sigBytes The number of significant bytes in this word array.
  8084               */
  8085              var WordArray = C_lib.WordArray = Base.extend({
  8086                  /**
  8087                   * Initializes a newly created word array.
  8088                   *
  8089                   * @param {Array} words (Optional) An array of 32-bit words.
  8090                   * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  8091                   *
  8092                   * @example
  8093                   *
  8094                   *     var wordArray = CryptoJS.lib.WordArray.create();
  8095                   *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  8096                   *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  8097                   */
  8098                  init: function (words, sigBytes) {
  8099                      words = this.words = words || [];
  8100      
  8101                      if (sigBytes != undefined) {
  8102                          this.sigBytes = sigBytes;
  8103                      } else {
  8104                          this.sigBytes = words.length * 4;
  8105                      }
  8106                  },
  8107      
  8108                  /**
  8109                   * Converts this word array to a string.
  8110                   *
  8111                   * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  8112                   *
  8113                   * @return {string} The stringified word array.
  8114                   *
  8115                   * @example
  8116                   *
  8117                   *     var string = wordArray + '';
  8118                   *     var string = wordArray.toString();
  8119                   *     var string = wordArray.toString(CryptoJS.enc.Utf8);
  8120                   */
  8121                  toString: function (encoder) {
  8122                      return (encoder || Hex).stringify(this);
  8123                  },
  8124      
  8125                  /**
  8126                   * Concatenates a word array to this word array.
  8127                   *
  8128                   * @param {WordArray} wordArray The word array to append.
  8129                   *
  8130                   * @return {WordArray} This word array.
  8131                   *
  8132                   * @example
  8133                   *
  8134                   *     wordArray1.concat(wordArray2);
  8135                   */
  8136                  concat: function (wordArray) {
  8137                      // Shortcuts
  8138                      var thisWords = this.words;
  8139                      var thatWords = wordArray.words;
  8140                      var thisSigBytes = this.sigBytes;
  8141                      var thatSigBytes = wordArray.sigBytes;
  8142      
  8143                      // Clamp excess bits
  8144                      this.clamp();
  8145      
  8146                      // Concat
  8147                      if (thisSigBytes % 4) {
  8148                          // Copy one byte at a time
  8149                          for (var i = 0; i < thatSigBytes; i++) {
  8150                              var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8151                              thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  8152                          }
  8153                      } else {
  8154                          // Copy one word at a time
  8155                          for (var i = 0; i < thatSigBytes; i += 4) {
  8156                              thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
  8157                          }
  8158                      }
  8159                      this.sigBytes += thatSigBytes;
  8160      
  8161                      // Chainable
  8162                      return this;
  8163                  },
  8164      
  8165                  /**
  8166                   * Removes insignificant bits.
  8167                   *
  8168                   * @example
  8169                   *
  8170                   *     wordArray.clamp();
  8171                   */
  8172                  clamp: function () {
  8173                      // Shortcuts
  8174                      var words = this.words;
  8175                      var sigBytes = this.sigBytes;
  8176      
  8177                      // Clamp
  8178                      words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  8179                      words.length = Math.ceil(sigBytes / 4);
  8180                  },
  8181      
  8182                  /**
  8183                   * Creates a copy of this word array.
  8184                   *
  8185                   * @return {WordArray} The clone.
  8186                   *
  8187                   * @example
  8188                   *
  8189                   *     var clone = wordArray.clone();
  8190                   */
  8191                  clone: function () {
  8192                      var clone = Base.clone.call(this);
  8193                      clone.words = this.words.slice(0);
  8194      
  8195                      return clone;
  8196                  },
  8197      
  8198                  /**
  8199                   * Creates a word array filled with random bytes.
  8200                   *
  8201                   * @param {number} nBytes The number of random bytes to generate.
  8202                   *
  8203                   * @return {WordArray} The random word array.
  8204                   *
  8205                   * @static
  8206                   *
  8207                   * @example
  8208                   *
  8209                   *     var wordArray = CryptoJS.lib.WordArray.random(16);
  8210                   */
  8211                  random: function (nBytes) {
  8212                      var words = [];
  8213      
  8214                      var r = (function (m_w) {
  8215                          var m_w = m_w;
  8216                          var m_z = 0x3ade68b1;
  8217                          var mask = 0xffffffff;
  8218      
  8219                          return function () {
  8220                              m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
  8221                              m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
  8222                              var result = ((m_z << 0x10) + m_w) & mask;
  8223                              result /= 0x100000000;
  8224                              result += 0.5;
  8225                              return result * (Math.random() > .5 ? 1 : -1);
  8226                          }
  8227                      });
  8228      
  8229                      for (var i = 0, rcache; i < nBytes; i += 4) {
  8230                          var _r = r((rcache || Math.random()) * 0x100000000);
  8231      
  8232                          rcache = _r() * 0x3ade67b7;
  8233                          words.push((_r() * 0x100000000) | 0);
  8234                      }
  8235      
  8236                      return new WordArray.init(words, nBytes);
  8237                  }
  8238              });
  8239      
  8240              /**
  8241               * Encoder namespace.
  8242               */
  8243              var C_enc = C.enc = {};
  8244      
  8245              /**
  8246               * Hex encoding strategy.
  8247               */
  8248              var Hex = C_enc.Hex = {
  8249                  /**
  8250                   * Converts a word array to a hex string.
  8251                   *
  8252                   * @param {WordArray} wordArray The word array.
  8253                   *
  8254                   * @return {string} The hex string.
  8255                   *
  8256                   * @static
  8257                   *
  8258                   * @example
  8259                   *
  8260                   *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  8261                   */
  8262                  stringify: function (wordArray) {
  8263                      // Shortcuts
  8264                      var words = wordArray.words;
  8265                      var sigBytes = wordArray.sigBytes;
  8266      
  8267                      // Convert
  8268                      var hexChars = [];
  8269                      for (var i = 0; i < sigBytes; i++) {
  8270                          var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8271                          hexChars.push((bite >>> 4).toString(16));
  8272                          hexChars.push((bite & 0x0f).toString(16));
  8273                      }
  8274      
  8275                      return hexChars.join('');
  8276                  },
  8277      
  8278                  /**
  8279                   * Converts a hex string to a word array.
  8280                   *
  8281                   * @param {string} hexStr The hex string.
  8282                   *
  8283                   * @return {WordArray} The word array.
  8284                   *
  8285                   * @static
  8286                   *
  8287                   * @example
  8288                   *
  8289                   *     var wordArray = CryptoJS.enc.Hex.parse(hexString);
  8290                   */
  8291                  parse: function (hexStr) {
  8292                      // Shortcut
  8293                      var hexStrLength = hexStr.length;
  8294      
  8295                      // Convert
  8296                      var words = [];
  8297                      for (var i = 0; i < hexStrLength; i += 2) {
  8298                          words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  8299                      }
  8300      
  8301                      return new WordArray.init(words, hexStrLength / 2);
  8302                  }
  8303              };
  8304      
  8305              /**
  8306               * Latin1 encoding strategy.
  8307               */
  8308              var Latin1 = C_enc.Latin1 = {
  8309                  /**
  8310                   * Converts a word array to a Latin1 string.
  8311                   *
  8312                   * @param {WordArray} wordArray The word array.
  8313                   *
  8314                   * @return {string} The Latin1 string.
  8315                   *
  8316                   * @static
  8317                   *
  8318                   * @example
  8319                   *
  8320                   *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  8321                   */
  8322                  stringify: function (wordArray) {
  8323                      // Shortcuts
  8324                      var words = wordArray.words;
  8325                      var sigBytes = wordArray.sigBytes;
  8326      
  8327                      // Convert
  8328                      var latin1Chars = [];
  8329                      for (var i = 0; i < sigBytes; i++) {
  8330                          var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8331                          latin1Chars.push(String.fromCharCode(bite));
  8332                      }
  8333      
  8334                      return latin1Chars.join('');
  8335                  },
  8336      
  8337                  /**
  8338                   * Converts a Latin1 string to a word array.
  8339                   *
  8340                   * @param {string} latin1Str The Latin1 string.
  8341                   *
  8342                   * @return {WordArray} The word array.
  8343                   *
  8344                   * @static
  8345                   *
  8346                   * @example
  8347                   *
  8348                   *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  8349                   */
  8350                  parse: function (latin1Str) {
  8351                      // Shortcut
  8352                      var latin1StrLength = latin1Str.length;
  8353      
  8354                      // Convert
  8355                      var words = [];
  8356                      for (var i = 0; i < latin1StrLength; i++) {
  8357                          words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  8358                      }
  8359      
  8360                      return new WordArray.init(words, latin1StrLength);
  8361                  }
  8362              };
  8363      
  8364              /**
  8365               * UTF-8 encoding strategy.
  8366               */
  8367              var Utf8 = C_enc.Utf8 = {
  8368                  /**
  8369                   * Converts a word array to a UTF-8 string.
  8370                   *
  8371                   * @param {WordArray} wordArray The word array.
  8372                   *
  8373                   * @return {string} The UTF-8 string.
  8374                   *
  8375                   * @static
  8376                   *
  8377                   * @example
  8378                   *
  8379                   *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  8380                   */
  8381                  stringify: function (wordArray) {
  8382                      try {
  8383                          return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  8384                      } catch (e) {
  8385                          throw new Error('Malformed UTF-8 data');
  8386                      }
  8387                  },
  8388      
  8389                  /**
  8390                   * Converts a UTF-8 string to a word array.
  8391                   *
  8392                   * @param {string} utf8Str The UTF-8 string.
  8393                   *
  8394                   * @return {WordArray} The word array.
  8395                   *
  8396                   * @static
  8397                   *
  8398                   * @example
  8399                   *
  8400                   *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  8401                   */
  8402                  parse: function (utf8Str) {
  8403                      return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  8404                  }
  8405              };
  8406      
  8407              /**
  8408               * Abstract buffered block algorithm template.
  8409               *
  8410               * The property blockSize must be implemented in a concrete subtype.
  8411               *
  8412               * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  8413               */
  8414              var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  8415                  /**
  8416                   * Resets this block algorithm's data buffer to its initial state.
  8417                   *
  8418                   * @example
  8419                   *
  8420                   *     bufferedBlockAlgorithm.reset();
  8421                   */
  8422                  reset: function () {
  8423                      // Initial values
  8424                      this._data = new WordArray.init();
  8425                      this._nDataBytes = 0;
  8426                  },
  8427      
  8428                  /**
  8429                   * Adds new data to this block algorithm's buffer.
  8430                   *
  8431                   * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  8432                   *
  8433                   * @example
  8434                   *
  8435                   *     bufferedBlockAlgorithm._append('data');
  8436                   *     bufferedBlockAlgorithm._append(wordArray);
  8437                   */
  8438                  _append: function (data) {
  8439                      // Convert string to WordArray, else assume WordArray already
  8440                      if (typeof data == 'string') {
  8441                          data = Utf8.parse(data);
  8442                      }
  8443      
  8444                      // Append
  8445                      this._data.concat(data);
  8446                      this._nDataBytes += data.sigBytes;
  8447                  },
  8448      
  8449                  /**
  8450                   * Processes available data blocks.
  8451                   *
  8452                   * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  8453                   *
  8454                   * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  8455                   *
  8456                   * @return {WordArray} The processed data.
  8457                   *
  8458                   * @example
  8459                   *
  8460                   *     var processedData = bufferedBlockAlgorithm._process();
  8461                   *     var processedData = bufferedBlockAlgorithm._process(!!'flush');
  8462                   */
  8463                  _process: function (doFlush) {
  8464                      // Shortcuts
  8465                      var data = this._data;
  8466                      var dataWords = data.words;
  8467                      var dataSigBytes = data.sigBytes;
  8468                      var blockSize = this.blockSize;
  8469                      var blockSizeBytes = blockSize * 4;
  8470      
  8471                      // Count blocks ready
  8472                      var nBlocksReady = dataSigBytes / blockSizeBytes;
  8473                      if (doFlush) {
  8474                          // Round up to include partial blocks
  8475                          nBlocksReady = Math.ceil(nBlocksReady);
  8476                      } else {
  8477                          // Round down to include only full blocks,
  8478                          // less the number of blocks that must remain in the buffer
  8479                          nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  8480                      }
  8481      
  8482                      // Count words ready
  8483                      var nWordsReady = nBlocksReady * blockSize;
  8484      
  8485                      // Count bytes ready
  8486                      var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  8487      
  8488                      // Process blocks
  8489                      if (nWordsReady) {
  8490                          for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  8491                              // Perform concrete-algorithm logic
  8492                              this._doProcessBlock(dataWords, offset);
  8493                          }
  8494      
  8495                          // Remove processed words
  8496                          var processedWords = dataWords.splice(0, nWordsReady);
  8497                          data.sigBytes -= nBytesReady;
  8498                      }
  8499      
  8500                      // Return processed words
  8501                      return new WordArray.init(processedWords, nBytesReady);
  8502                  },
  8503      
  8504                  /**
  8505                   * Creates a copy of this object.
  8506                   *
  8507                   * @return {Object} The clone.
  8508                   *
  8509                   * @example
  8510                   *
  8511                   *     var clone = bufferedBlockAlgorithm.clone();
  8512                   */
  8513                  clone: function () {
  8514                      var clone = Base.clone.call(this);
  8515                      clone._data = this._data.clone();
  8516      
  8517                      return clone;
  8518                  },
  8519      
  8520                  _minBufferSize: 0
  8521              });
  8522      
  8523              /**
  8524               * Abstract hasher template.
  8525               *
  8526               * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  8527               */
  8528              var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  8529                  /**
  8530                   * Configuration options.
  8531                   */
  8532                  cfg: Base.extend(),
  8533      
  8534                  /**
  8535                   * Initializes a newly created hasher.
  8536                   *
  8537                   * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  8538                   *
  8539                   * @example
  8540                   *
  8541                   *     var hasher = CryptoJS.algo.SHA256.create();
  8542                   */
  8543                  init: function (cfg) {
  8544                      // Apply config defaults
  8545                      this.cfg = this.cfg.extend(cfg);
  8546      
  8547                      // Set initial values
  8548                      this.reset();
  8549                  },
  8550      
  8551                  /**
  8552                   * Resets this hasher to its initial state.
  8553                   *
  8554                   * @example
  8555                   *
  8556                   *     hasher.reset();
  8557                   */
  8558                  reset: function () {
  8559                      // Reset data buffer
  8560                      BufferedBlockAlgorithm.reset.call(this);
  8561      
  8562                      // Perform concrete-hasher logic
  8563                      this._doReset();
  8564                  },
  8565      
  8566                  /**
  8567                   * Updates this hasher with a message.
  8568                   *
  8569                   * @param {WordArray|string} messageUpdate The message to append.
  8570                   *
  8571                   * @return {Hasher} This hasher.
  8572                   *
  8573                   * @example
  8574                   *
  8575                   *     hasher.update('message');
  8576                   *     hasher.update(wordArray);
  8577                   */
  8578                  update: function (messageUpdate) {
  8579                      // Append
  8580                      this._append(messageUpdate);
  8581      
  8582                      // Update the hash
  8583                      this._process();
  8584      
  8585                      // Chainable
  8586                      return this;
  8587                  },
  8588      
  8589                  /**
  8590                   * Finalizes the hash computation.
  8591                   * Note that the finalize operation is effectively a destructive, read-once operation.
  8592                   *
  8593                   * @param {WordArray|string} messageUpdate (Optional) A final message update.
  8594                   *
  8595                   * @return {WordArray} The hash.
  8596                   *
  8597                   * @example
  8598                   *
  8599                   *     var hash = hasher.finalize();
  8600                   *     var hash = hasher.finalize('message');
  8601                   *     var hash = hasher.finalize(wordArray);
  8602                   */
  8603                  finalize: function (messageUpdate) {
  8604                      // Final message update
  8605                      if (messageUpdate) {
  8606                          this._append(messageUpdate);
  8607                      }
  8608      
  8609                      // Perform concrete-hasher logic
  8610                      var hash = this._doFinalize();
  8611      
  8612                      return hash;
  8613                  },
  8614      
  8615                  blockSize: 512/32,
  8616      
  8617                  /**
  8618                   * Creates a shortcut function to a hasher's object interface.
  8619                   *
  8620                   * @param {Hasher} hasher The hasher to create a helper for.
  8621                   *
  8622                   * @return {Function} The shortcut function.
  8623                   *
  8624                   * @static
  8625                   *
  8626                   * @example
  8627                   *
  8628                   *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  8629                   */
  8630                  _createHelper: function (hasher) {
  8631                      return function (message, cfg) {
  8632                          return new hasher.init(cfg).finalize(message);
  8633                      };
  8634                  },
  8635      
  8636                  /**
  8637                   * Creates a shortcut function to the HMAC's object interface.
  8638                   *
  8639                   * @param {Hasher} hasher The hasher to use in this HMAC helper.
  8640                   *
  8641                   * @return {Function} The shortcut function.
  8642                   *
  8643                   * @static
  8644                   *
  8645                   * @example
  8646                   *
  8647                   *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  8648                   */
  8649                  _createHmacHelper: function (hasher) {
  8650                      return function (message, key) {
  8651                          return new C_algo.HMAC.init(hasher, key).finalize(message);
  8652                      };
  8653                  }
  8654              });
  8655      
  8656              /**
  8657               * Algorithm namespace.
  8658               */
  8659              var C_algo = C.algo = {};
  8660      
  8661              return C;
  8662          }(Math));
  8663      
  8664      
  8665          return CryptoJS;
  8666      
  8667      }));
  8668      },{}],54:[function(require,module,exports){
  8669      ;(function (root, factory) {
  8670          if (typeof exports === "object") {
  8671              // CommonJS
  8672              module.exports = exports = factory(require("./core"));
  8673          }
  8674          else if (typeof define === "function" && define.amd) {
  8675              // AMD
  8676              define(["./core"], factory);
  8677          }
  8678          else {
  8679              // Global (browser)
  8680              factory(root.CryptoJS);
  8681          }
  8682      }(this, function (CryptoJS) {
  8683      
  8684          (function () {
  8685              // Shortcuts
  8686              var C = CryptoJS;
  8687              var C_lib = C.lib;
  8688              var WordArray = C_lib.WordArray;
  8689              var C_enc = C.enc;
  8690      
  8691              /**
  8692               * Base64 encoding strategy.
  8693               */
  8694              var Base64 = C_enc.Base64 = {
  8695                  /**
  8696                   * Converts a word array to a Base64 string.
  8697                   *
  8698                   * @param {WordArray} wordArray The word array.
  8699                   *
  8700                   * @return {string} The Base64 string.
  8701                   *
  8702                   * @static
  8703                   *
  8704                   * @example
  8705                   *
  8706                   *     var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  8707                   */
  8708                  stringify: function (wordArray) {
  8709                      // Shortcuts
  8710                      var words = wordArray.words;
  8711                      var sigBytes = wordArray.sigBytes;
  8712                      var map = this._map;
  8713      
  8714                      // Clamp excess bits
  8715                      wordArray.clamp();
  8716      
  8717                      // Convert
  8718                      var base64Chars = [];
  8719                      for (var i = 0; i < sigBytes; i += 3) {
  8720                          var byte1 = (words[i >>> 2]       >>> (24 - (i % 4) * 8))       & 0xff;
  8721                          var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  8722                          var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  8723      
  8724                          var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  8725      
  8726                          for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  8727                              base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  8728                          }
  8729                      }
  8730      
  8731                      // Add padding
  8732                      var paddingChar = map.charAt(64);
  8733                      if (paddingChar) {
  8734                          while (base64Chars.length % 4) {
  8735                              base64Chars.push(paddingChar);
  8736                          }
  8737                      }
  8738      
  8739                      return base64Chars.join('');
  8740                  },
  8741      
  8742                  /**
  8743                   * Converts a Base64 string to a word array.
  8744                   *
  8745                   * @param {string} base64Str The Base64 string.
  8746                   *
  8747                   * @return {WordArray} The word array.
  8748                   *
  8749                   * @static
  8750                   *
  8751                   * @example
  8752                   *
  8753                   *     var wordArray = CryptoJS.enc.Base64.parse(base64String);
  8754                   */
  8755                  parse: function (base64Str) {
  8756                      // Shortcuts
  8757                      var base64StrLength = base64Str.length;
  8758                      var map = this._map;
  8759                      var reverseMap = this._reverseMap;
  8760      
  8761                      if (!reverseMap) {
  8762                              reverseMap = this._reverseMap = [];
  8763                              for (var j = 0; j < map.length; j++) {
  8764                                  reverseMap[map.charCodeAt(j)] = j;
  8765                              }
  8766                      }
  8767      
  8768                      // Ignore padding
  8769                      var paddingChar = map.charAt(64);
  8770                      if (paddingChar) {
  8771                          var paddingIndex = base64Str.indexOf(paddingChar);
  8772                          if (paddingIndex !== -1) {
  8773                              base64StrLength = paddingIndex;
  8774                          }
  8775                      }
  8776      
  8777                      // Convert
  8778                      return parseLoop(base64Str, base64StrLength, reverseMap);
  8779      
  8780                  },
  8781      
  8782                  _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  8783              };
  8784      
  8785              function parseLoop(base64Str, base64StrLength, reverseMap) {
  8786                var words = [];
  8787                var nBytes = 0;
  8788                for (var i = 0; i < base64StrLength; i++) {
  8789                    if (i % 4) {
  8790                        var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  8791                        var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  8792                        words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
  8793                        nBytes++;
  8794                    }
  8795                }
  8796                return WordArray.create(words, nBytes);
  8797              }
  8798          }());
  8799      
  8800      
  8801          return CryptoJS.enc.Base64;
  8802      
  8803      }));
  8804      },{"./core":53}],55:[function(require,module,exports){
  8805      ;(function (root, factory) {
  8806          if (typeof exports === "object") {
  8807              // CommonJS
  8808              module.exports = exports = factory(require("./core"));
  8809          }
  8810          else if (typeof define === "function" && define.amd) {
  8811              // AMD
  8812              define(["./core"], factory);
  8813          }
  8814          else {
  8815              // Global (browser)
  8816              factory(root.CryptoJS);
  8817          }
  8818      }(this, function (CryptoJS) {
  8819      
  8820          (function () {
  8821              // Shortcuts
  8822              var C = CryptoJS;
  8823              var C_lib = C.lib;
  8824              var WordArray = C_lib.WordArray;
  8825              var C_enc = C.enc;
  8826      
  8827              /**
  8828               * UTF-16 BE encoding strategy.
  8829               */
  8830              var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
  8831                  /**
  8832                   * Converts a word array to a UTF-16 BE string.
  8833                   *
  8834                   * @param {WordArray} wordArray The word array.
  8835                   *
  8836                   * @return {string} The UTF-16 BE string.
  8837                   *
  8838                   * @static
  8839                   *
  8840                   * @example
  8841                   *
  8842                   *     var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
  8843                   */
  8844                  stringify: function (wordArray) {
  8845                      // Shortcuts
  8846                      var words = wordArray.words;
  8847                      var sigBytes = wordArray.sigBytes;
  8848      
  8849                      // Convert
  8850                      var utf16Chars = [];
  8851                      for (var i = 0; i < sigBytes; i += 2) {
  8852                          var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
  8853                          utf16Chars.push(String.fromCharCode(codePoint));
  8854                      }
  8855      
  8856                      return utf16Chars.join('');
  8857                  },
  8858      
  8859                  /**
  8860                   * Converts a UTF-16 BE string to a word array.
  8861                   *
  8862                   * @param {string} utf16Str The UTF-16 BE string.
  8863                   *
  8864                   * @return {WordArray} The word array.
  8865                   *
  8866                   * @static
  8867                   *
  8868                   * @example
  8869                   *
  8870                   *     var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
  8871                   */
  8872                  parse: function (utf16Str) {
  8873                      // Shortcut
  8874                      var utf16StrLength = utf16Str.length;
  8875      
  8876                      // Convert
  8877                      var words = [];
  8878                      for (var i = 0; i < utf16StrLength; i++) {
  8879                          words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
  8880                      }
  8881      
  8882                      return WordArray.create(words, utf16StrLength * 2);
  8883                  }
  8884              };
  8885      
  8886              /**
  8887               * UTF-16 LE encoding strategy.
  8888               */
  8889              C_enc.Utf16LE = {
  8890                  /**
  8891                   * Converts a word array to a UTF-16 LE string.
  8892                   *
  8893                   * @param {WordArray} wordArray The word array.
  8894                   *
  8895                   * @return {string} The UTF-16 LE string.
  8896                   *
  8897                   * @static
  8898                   *
  8899                   * @example
  8900                   *
  8901                   *     var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
  8902                   */
  8903                  stringify: function (wordArray) {
  8904                      // Shortcuts
  8905                      var words = wordArray.words;
  8906                      var sigBytes = wordArray.sigBytes;
  8907      
  8908                      // Convert
  8909                      var utf16Chars = [];
  8910                      for (var i = 0; i < sigBytes; i += 2) {
  8911                          var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
  8912                          utf16Chars.push(String.fromCharCode(codePoint));
  8913                      }
  8914      
  8915                      return utf16Chars.join('');
  8916                  },
  8917      
  8918                  /**
  8919                   * Converts a UTF-16 LE string to a word array.
  8920                   *
  8921                   * @param {string} utf16Str The UTF-16 LE string.
  8922                   *
  8923                   * @return {WordArray} The word array.
  8924                   *
  8925                   * @static
  8926                   *
  8927                   * @example
  8928                   *
  8929                   *     var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
  8930                   */
  8931                  parse: function (utf16Str) {
  8932                      // Shortcut
  8933                      var utf16StrLength = utf16Str.length;
  8934      
  8935                      // Convert
  8936                      var words = [];
  8937                      for (var i = 0; i < utf16StrLength; i++) {
  8938                          words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
  8939                      }
  8940      
  8941                      return WordArray.create(words, utf16StrLength * 2);
  8942                  }
  8943              };
  8944      
  8945              function swapEndian(word) {
  8946                  return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
  8947              }
  8948          }());
  8949      
  8950      
  8951          return CryptoJS.enc.Utf16;
  8952      
  8953      }));
  8954      },{"./core":53}],56:[function(require,module,exports){
  8955      ;(function (root, factory, undef) {
  8956          if (typeof exports === "object") {
  8957              // CommonJS
  8958              module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
  8959          }
  8960          else if (typeof define === "function" && define.amd) {
  8961              // AMD
  8962              define(["./core", "./sha1", "./hmac"], factory);
  8963          }
  8964          else {
  8965              // Global (browser)
  8966              factory(root.CryptoJS);
  8967          }
  8968      }(this, function (CryptoJS) {
  8969      
  8970          (function () {
  8971              // Shortcuts
  8972              var C = CryptoJS;
  8973              var C_lib = C.lib;
  8974              var Base = C_lib.Base;
  8975              var WordArray = C_lib.WordArray;
  8976              var C_algo = C.algo;
  8977              var MD5 = C_algo.MD5;
  8978      
  8979              /**
  8980               * This key derivation function is meant to conform with EVP_BytesToKey.
  8981               * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  8982               */
  8983              var EvpKDF = C_algo.EvpKDF = Base.extend({
  8984                  /**
  8985                   * Configuration options.
  8986                   *
  8987                   * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  8988                   * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  8989                   * @property {number} iterations The number of iterations to perform. Default: 1
  8990                   */
  8991                  cfg: Base.extend({
  8992                      keySize: 128/32,
  8993                      hasher: MD5,
  8994                      iterations: 1
  8995                  }),
  8996      
  8997                  /**
  8998                   * Initializes a newly created key derivation function.
  8999                   *
  9000                   * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  9001                   *
  9002                   * @example
  9003                   *
  9004                   *     var kdf = CryptoJS.algo.EvpKDF.create();
  9005                   *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  9006                   *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  9007                   */
  9008                  init: function (cfg) {
  9009                      this.cfg = this.cfg.extend(cfg);
  9010                  },
  9011      
  9012                  /**
  9013                   * Derives a key from a password.
  9014                   *
  9015                   * @param {WordArray|string} password The password.
  9016                   * @param {WordArray|string} salt A salt.
  9017                   *
  9018                   * @return {WordArray} The derived key.
  9019                   *
  9020                   * @example
  9021                   *
  9022                   *     var key = kdf.compute(password, salt);
  9023                   */
  9024                  compute: function (password, salt) {
  9025                      // Shortcut
  9026                      var cfg = this.cfg;
  9027      
  9028                      // Init hasher
  9029                      var hasher = cfg.hasher.create();
  9030      
  9031                      // Initial values
  9032                      var derivedKey = WordArray.create();
  9033      
  9034                      // Shortcuts
  9035                      var derivedKeyWords = derivedKey.words;
  9036                      var keySize = cfg.keySize;
  9037                      var iterations = cfg.iterations;
  9038      
  9039                      // Generate key
  9040                      while (derivedKeyWords.length < keySize) {
  9041                          if (block) {
  9042                              hasher.update(block);
  9043                          }
  9044                          var block = hasher.update(password).finalize(salt);
  9045                          hasher.reset();
  9046      
  9047                          // Iterations
  9048                          for (var i = 1; i < iterations; i++) {
  9049                              block = hasher.finalize(block);
  9050                              hasher.reset();
  9051                          }
  9052      
  9053                          derivedKey.concat(block);
  9054                      }
  9055                      derivedKey.sigBytes = keySize * 4;
  9056      
  9057                      return derivedKey;
  9058                  }
  9059              });
  9060      
  9061              /**
  9062               * Derives a key from a password.
  9063               *
  9064               * @param {WordArray|string} password The password.
  9065               * @param {WordArray|string} salt A salt.
  9066               * @param {Object} cfg (Optional) The configuration options to use for this computation.
  9067               *
  9068               * @return {WordArray} The derived key.
  9069               *
  9070               * @static
  9071               *
  9072               * @example
  9073               *
  9074               *     var key = CryptoJS.EvpKDF(password, salt);
  9075               *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  9076               *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  9077               */
  9078              C.EvpKDF = function (password, salt, cfg) {
  9079                  return EvpKDF.create(cfg).compute(password, salt);
  9080              };
  9081          }());
  9082      
  9083      
  9084          return CryptoJS.EvpKDF;
  9085      
  9086      }));
  9087      },{"./core":53,"./hmac":58,"./sha1":77}],57:[function(require,module,exports){
  9088      ;(function (root, factory, undef) {
  9089          if (typeof exports === "object") {
  9090              // CommonJS
  9091              module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9092          }
  9093          else if (typeof define === "function" && define.amd) {
  9094              // AMD
  9095              define(["./core", "./cipher-core"], factory);
  9096          }
  9097          else {
  9098              // Global (browser)
  9099              factory(root.CryptoJS);
  9100          }
  9101      }(this, function (CryptoJS) {
  9102      
  9103          (function (undefined) {
  9104              // Shortcuts
  9105              var C = CryptoJS;
  9106              var C_lib = C.lib;
  9107              var CipherParams = C_lib.CipherParams;
  9108              var C_enc = C.enc;
  9109              var Hex = C_enc.Hex;
  9110              var C_format = C.format;
  9111      
  9112              var HexFormatter = C_format.Hex = {
  9113                  /**
  9114                   * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  9115                   *
  9116                   * @param {CipherParams} cipherParams The cipher params object.
  9117                   *
  9118                   * @return {string} The hexadecimally encoded string.
  9119                   *
  9120                   * @static
  9121                   *
  9122                   * @example
  9123                   *
  9124                   *     var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  9125                   */
  9126                  stringify: function (cipherParams) {
  9127                      return cipherParams.ciphertext.toString(Hex);
  9128                  },
  9129      
  9130                  /**
  9131                   * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  9132                   *
  9133                   * @param {string} input The hexadecimally encoded string.
  9134                   *
  9135                   * @return {CipherParams} The cipher params object.
  9136                   *
  9137                   * @static
  9138                   *
  9139                   * @example
  9140                   *
  9141                   *     var cipherParams = CryptoJS.format.Hex.parse(hexString);
  9142                   */
  9143                  parse: function (input) {
  9144                      var ciphertext = Hex.parse(input);
  9145                      return CipherParams.create({ ciphertext: ciphertext });
  9146                  }
  9147              };
  9148          }());
  9149      
  9150      
  9151          return CryptoJS.format.Hex;
  9152      
  9153      }));
  9154      },{"./cipher-core":52,"./core":53}],58:[function(require,module,exports){
  9155      ;(function (root, factory) {
  9156          if (typeof exports === "object") {
  9157              // CommonJS
  9158              module.exports = exports = factory(require("./core"));
  9159          }
  9160          else if (typeof define === "function" && define.amd) {
  9161              // AMD
  9162              define(["./core"], factory);
  9163          }
  9164          else {
  9165              // Global (browser)
  9166              factory(root.CryptoJS);
  9167          }
  9168      }(this, function (CryptoJS) {
  9169      
  9170          (function () {
  9171              // Shortcuts
  9172              var C = CryptoJS;
  9173              var C_lib = C.lib;
  9174              var Base = C_lib.Base;
  9175              var C_enc = C.enc;
  9176              var Utf8 = C_enc.Utf8;
  9177              var C_algo = C.algo;
  9178      
  9179              /**
  9180               * HMAC algorithm.
  9181               */
  9182              var HMAC = C_algo.HMAC = Base.extend({
  9183                  /**
  9184                   * Initializes a newly created HMAC.
  9185                   *
  9186                   * @param {Hasher} hasher The hash algorithm to use.
  9187                   * @param {WordArray|string} key The secret key.
  9188                   *
  9189                   * @example
  9190                   *
  9191                   *     var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  9192                   */
  9193                  init: function (hasher, key) {
  9194                      // Init hasher
  9195                      hasher = this._hasher = new hasher.init();
  9196      
  9197                      // Convert string to WordArray, else assume WordArray already
  9198                      if (typeof key == 'string') {
  9199                          key = Utf8.parse(key);
  9200                      }
  9201      
  9202                      // Shortcuts
  9203                      var hasherBlockSize = hasher.blockSize;
  9204                      var hasherBlockSizeBytes = hasherBlockSize * 4;
  9205      
  9206                      // Allow arbitrary length keys
  9207                      if (key.sigBytes > hasherBlockSizeBytes) {
  9208                          key = hasher.finalize(key);
  9209                      }
  9210      
  9211                      // Clamp excess bits
  9212                      key.clamp();
  9213      
  9214                      // Clone key for inner and outer pads
  9215                      var oKey = this._oKey = key.clone();
  9216                      var iKey = this._iKey = key.clone();
  9217      
  9218                      // Shortcuts
  9219                      var oKeyWords = oKey.words;
  9220                      var iKeyWords = iKey.words;
  9221      
  9222                      // XOR keys with pad constants
  9223                      for (var i = 0; i < hasherBlockSize; i++) {
  9224                          oKeyWords[i] ^= 0x5c5c5c5c;
  9225                          iKeyWords[i] ^= 0x36363636;
  9226                      }
  9227                      oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  9228      
  9229                      // Set initial values
  9230                      this.reset();
  9231                  },
  9232      
  9233                  /**
  9234                   * Resets this HMAC to its initial state.
  9235                   *
  9236                   * @example
  9237                   *
  9238                   *     hmacHasher.reset();
  9239                   */
  9240                  reset: function () {
  9241                      // Shortcut
  9242                      var hasher = this._hasher;
  9243      
  9244                      // Reset
  9245                      hasher.reset();
  9246                      hasher.update(this._iKey);
  9247                  },
  9248      
  9249                  /**
  9250                   * Updates this HMAC with a message.
  9251                   *
  9252                   * @param {WordArray|string} messageUpdate The message to append.
  9253                   *
  9254                   * @return {HMAC} This HMAC instance.
  9255                   *
  9256                   * @example
  9257                   *
  9258                   *     hmacHasher.update('message');
  9259                   *     hmacHasher.update(wordArray);
  9260                   */
  9261                  update: function (messageUpdate) {
  9262                      this._hasher.update(messageUpdate);
  9263      
  9264                      // Chainable
  9265                      return this;
  9266                  },
  9267      
  9268                  /**
  9269                   * Finalizes the HMAC computation.
  9270                   * Note that the finalize operation is effectively a destructive, read-once operation.
  9271                   *
  9272                   * @param {WordArray|string} messageUpdate (Optional) A final message update.
  9273                   *
  9274                   * @return {WordArray} The HMAC.
  9275                   *
  9276                   * @example
  9277                   *
  9278                   *     var hmac = hmacHasher.finalize();
  9279                   *     var hmac = hmacHasher.finalize('message');
  9280                   *     var hmac = hmacHasher.finalize(wordArray);
  9281                   */
  9282                  finalize: function (messageUpdate) {
  9283                      // Shortcut
  9284                      var hasher = this._hasher;
  9285      
  9286                      // Compute HMAC
  9287                      var innerHash = hasher.finalize(messageUpdate);
  9288                      hasher.reset();
  9289                      var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  9290      
  9291                      return hmac;
  9292                  }
  9293              });
  9294          }());
  9295      
  9296      
  9297      }));
  9298      },{"./core":53}],59:[function(require,module,exports){
  9299      ;(function (root, factory, undef) {
  9300          if (typeof exports === "object") {
  9301              // CommonJS
  9302              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"));
  9303          }
  9304          else if (typeof define === "function" && define.amd) {
  9305              // AMD
  9306              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);
  9307          }
  9308          else {
  9309              // Global (browser)
  9310              root.CryptoJS = factory(root.CryptoJS);
  9311          }
  9312      }(this, function (CryptoJS) {
  9313      
  9314          return CryptoJS;
  9315      
  9316      }));
  9317      },{"./aes":51,"./cipher-core":52,"./core":53,"./enc-base64":54,"./enc-utf16":55,"./evpkdf":56,"./format-hex":57,"./hmac":58,"./lib-typedarrays":60,"./md5":61,"./mode-cfb":62,"./mode-ctr":64,"./mode-ctr-gladman":63,"./mode-ecb":65,"./mode-ofb":66,"./pad-ansix923":67,"./pad-iso10126":68,"./pad-iso97971":69,"./pad-nopadding":70,"./pad-zeropadding":71,"./pbkdf2":72,"./rabbit":74,"./rabbit-legacy":73,"./rc4":75,"./ripemd160":76,"./sha1":77,"./sha224":78,"./sha256":79,"./sha3":80,"./sha384":81,"./sha512":82,"./tripledes":83,"./x64-core":84}],60:[function(require,module,exports){
  9318      ;(function (root, factory) {
  9319          if (typeof exports === "object") {
  9320              // CommonJS
  9321              module.exports = exports = factory(require("./core"));
  9322          }
  9323          else if (typeof define === "function" && define.amd) {
  9324              // AMD
  9325              define(["./core"], factory);
  9326          }
  9327          else {
  9328              // Global (browser)
  9329              factory(root.CryptoJS);
  9330          }
  9331      }(this, function (CryptoJS) {
  9332      
  9333          (function () {
  9334              // Check if typed arrays are supported
  9335              if (typeof ArrayBuffer != 'function') {
  9336                  return;
  9337              }
  9338      
  9339              // Shortcuts
  9340              var C = CryptoJS;
  9341              var C_lib = C.lib;
  9342              var WordArray = C_lib.WordArray;
  9343      
  9344              // Reference original init
  9345              var superInit = WordArray.init;
  9346      
  9347              // Augment WordArray.init to handle typed arrays
  9348              var subInit = WordArray.init = function (typedArray) {
  9349                  // Convert buffers to uint8
  9350                  if (typedArray instanceof ArrayBuffer) {
  9351                      typedArray = new Uint8Array(typedArray);
  9352                  }
  9353      
  9354                  // Convert other array views to uint8
  9355                  if (
  9356                      typedArray instanceof Int8Array ||
  9357                      (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
  9358                      typedArray instanceof Int16Array ||
  9359                      typedArray instanceof Uint16Array ||
  9360                      typedArray instanceof Int32Array ||
  9361                      typedArray instanceof Uint32Array ||
  9362                      typedArray instanceof Float32Array ||
  9363                      typedArray instanceof Float64Array
  9364                  ) {
  9365                      typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
  9366                  }
  9367      
  9368                  // Handle Uint8Array
  9369                  if (typedArray instanceof Uint8Array) {
  9370                      // Shortcut
  9371                      var typedArrayByteLength = typedArray.byteLength;
  9372      
  9373                      // Extract bytes
  9374                      var words = [];
  9375                      for (var i = 0; i < typedArrayByteLength; i++) {
  9376                          words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
  9377                      }
  9378      
  9379                      // Initialize this word array
  9380                      superInit.call(this, words, typedArrayByteLength);
  9381                  } else {
  9382                      // Else call normal init
  9383                      superInit.apply(this, arguments);
  9384                  }
  9385              };
  9386      
  9387              subInit.prototype = WordArray;
  9388          }());
  9389      
  9390      
  9391          return CryptoJS.lib.WordArray;
  9392      
  9393      }));
  9394      },{"./core":53}],61:[function(require,module,exports){
  9395      ;(function (root, factory) {
  9396          if (typeof exports === "object") {
  9397              // CommonJS
  9398              module.exports = exports = factory(require("./core"));
  9399          }
  9400          else if (typeof define === "function" && define.amd) {
  9401              // AMD
  9402              define(["./core"], factory);
  9403          }
  9404          else {
  9405              // Global (browser)
  9406              factory(root.CryptoJS);
  9407          }
  9408      }(this, function (CryptoJS) {
  9409      
  9410          (function (Math) {
  9411              // Shortcuts
  9412              var C = CryptoJS;
  9413              var C_lib = C.lib;
  9414              var WordArray = C_lib.WordArray;
  9415              var Hasher = C_lib.Hasher;
  9416              var C_algo = C.algo;
  9417      
  9418              // Constants table
  9419              var T = [];
  9420      
  9421              // Compute constants
  9422              (function () {
  9423                  for (var i = 0; i < 64; i++) {
  9424                      T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  9425                  }
  9426              }());
  9427      
  9428              /**
  9429               * MD5 hash algorithm.
  9430               */
  9431              var MD5 = C_algo.MD5 = Hasher.extend({
  9432                  _doReset: function () {
  9433                      this._hash = new WordArray.init([
  9434                          0x67452301, 0xefcdab89,
  9435                          0x98badcfe, 0x10325476
  9436                      ]);
  9437                  },
  9438      
  9439                  _doProcessBlock: function (M, offset) {
  9440                      // Swap endian
  9441                      for (var i = 0; i < 16; i++) {
  9442                          // Shortcuts
  9443                          var offset_i = offset + i;
  9444                          var M_offset_i = M[offset_i];
  9445      
  9446                          M[offset_i] = (
  9447                              (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
  9448                              (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
  9449                          );
  9450                      }
  9451      
  9452                      // Shortcuts
  9453                      var H = this._hash.words;
  9454      
  9455                      var M_offset_0  = M[offset + 0];
  9456                      var M_offset_1  = M[offset + 1];
  9457                      var M_offset_2  = M[offset + 2];
  9458                      var M_offset_3  = M[offset + 3];
  9459                      var M_offset_4  = M[offset + 4];
  9460                      var M_offset_5  = M[offset + 5];
  9461                      var M_offset_6  = M[offset + 6];
  9462                      var M_offset_7  = M[offset + 7];
  9463                      var M_offset_8  = M[offset + 8];
  9464                      var M_offset_9  = M[offset + 9];
  9465                      var M_offset_10 = M[offset + 10];
  9466                      var M_offset_11 = M[offset + 11];
  9467                      var M_offset_12 = M[offset + 12];
  9468                      var M_offset_13 = M[offset + 13];
  9469                      var M_offset_14 = M[offset + 14];
  9470                      var M_offset_15 = M[offset + 15];
  9471      
  9472                      // Working varialbes
  9473                      var a = H[0];
  9474                      var b = H[1];
  9475                      var c = H[2];
  9476                      var d = H[3];
  9477      
  9478                      // Computation
  9479                      a = FF(a, b, c, d, M_offset_0,  7,  T[0]);
  9480                      d = FF(d, a, b, c, M_offset_1,  12, T[1]);
  9481                      c = FF(c, d, a, b, M_offset_2,  17, T[2]);
  9482                      b = FF(b, c, d, a, M_offset_3,  22, T[3]);
  9483                      a = FF(a, b, c, d, M_offset_4,  7,  T[4]);
  9484                      d = FF(d, a, b, c, M_offset_5,  12, T[5]);
  9485                      c = FF(c, d, a, b, M_offset_6,  17, T[6]);
  9486                      b = FF(b, c, d, a, M_offset_7,  22, T[7]);
  9487                      a = FF(a, b, c, d, M_offset_8,  7,  T[8]);
  9488                      d = FF(d, a, b, c, M_offset_9,  12, T[9]);
  9489                      c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  9490                      b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  9491                      a = FF(a, b, c, d, M_offset_12, 7,  T[12]);
  9492                      d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  9493                      c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  9494                      b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  9495      
  9496                      a = GG(a, b, c, d, M_offset_1,  5,  T[16]);
  9497                      d = GG(d, a, b, c, M_offset_6,  9,  T[17]);
  9498                      c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  9499                      b = GG(b, c, d, a, M_offset_0,  20, T[19]);
  9500                      a = GG(a, b, c, d, M_offset_5,  5,  T[20]);
  9501                      d = GG(d, a, b, c, M_offset_10, 9,  T[21]);
  9502                      c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  9503                      b = GG(b, c, d, a, M_offset_4,  20, T[23]);
  9504                      a = GG(a, b, c, d, M_offset_9,  5,  T[24]);
  9505                      d = GG(d, a, b, c, M_offset_14, 9,  T[25]);
  9506                      c = GG(c, d, a, b, M_offset_3,  14, T[26]);
  9507                      b = GG(b, c, d, a, M_offset_8,  20, T[27]);
  9508                      a = GG(a, b, c, d, M_offset_13, 5,  T[28]);
  9509                      d = GG(d, a, b, c, M_offset_2,  9,  T[29]);
  9510                      c = GG(c, d, a, b, M_offset_7,  14, T[30]);
  9511                      b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  9512      
  9513                      a = HH(a, b, c, d, M_offset_5,  4,  T[32]);
  9514                      d = HH(d, a, b, c, M_offset_8,  11, T[33]);
  9515                      c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  9516                      b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  9517                      a = HH(a, b, c, d, M_offset_1,  4,  T[36]);
  9518                      d = HH(d, a, b, c, M_offset_4,  11, T[37]);
  9519                      c = HH(c, d, a, b, M_offset_7,  16, T[38]);
  9520                      b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  9521                      a = HH(a, b, c, d, M_offset_13, 4,  T[40]);
  9522                      d = HH(d, a, b, c, M_offset_0,  11, T[41]);
  9523                      c = HH(c, d, a, b, M_offset_3,  16, T[42]);
  9524                      b = HH(b, c, d, a, M_offset_6,  23, T[43]);
  9525                      a = HH(a, b, c, d, M_offset_9,  4,  T[44]);
  9526                      d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  9527                      c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  9528                      b = HH(b, c, d, a, M_offset_2,  23, T[47]);
  9529      
  9530                      a = II(a, b, c, d, M_offset_0,  6,  T[48]);
  9531                      d = II(d, a, b, c, M_offset_7,  10, T[49]);
  9532                      c = II(c, d, a, b, M_offset_14, 15, T[50]);
  9533                      b = II(b, c, d, a, M_offset_5,  21, T[51]);
  9534                      a = II(a, b, c, d, M_offset_12, 6,  T[52]);
  9535                      d = II(d, a, b, c, M_offset_3,  10, T[53]);
  9536                      c = II(c, d, a, b, M_offset_10, 15, T[54]);
  9537                      b = II(b, c, d, a, M_offset_1,  21, T[55]);
  9538                      a = II(a, b, c, d, M_offset_8,  6,  T[56]);
  9539                      d = II(d, a, b, c, M_offset_15, 10, T[57]);
  9540                      c = II(c, d, a, b, M_offset_6,  15, T[58]);
  9541                      b = II(b, c, d, a, M_offset_13, 21, T[59]);
  9542                      a = II(a, b, c, d, M_offset_4,  6,  T[60]);
  9543                      d = II(d, a, b, c, M_offset_11, 10, T[61]);
  9544                      c = II(c, d, a, b, M_offset_2,  15, T[62]);
  9545                      b = II(b, c, d, a, M_offset_9,  21, T[63]);
  9546      
  9547                      // Intermediate hash value
  9548                      H[0] = (H[0] + a) | 0;
  9549                      H[1] = (H[1] + b) | 0;
  9550                      H[2] = (H[2] + c) | 0;
  9551                      H[3] = (H[3] + d) | 0;
  9552                  },
  9553      
  9554                  _doFinalize: function () {
  9555                      // Shortcuts
  9556                      var data = this._data;
  9557                      var dataWords = data.words;
  9558      
  9559                      var nBitsTotal = this._nDataBytes * 8;
  9560                      var nBitsLeft = data.sigBytes * 8;
  9561      
  9562                      // Add padding
  9563                      dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  9564      
  9565                      var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  9566                      var nBitsTotalL = nBitsTotal;
  9567                      dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  9568                          (((nBitsTotalH << 8)  | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  9569                          (((nBitsTotalH << 24) | (nBitsTotalH >>> 8))  & 0xff00ff00)
  9570                      );
  9571                      dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  9572                          (((nBitsTotalL << 8)  | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  9573                          (((nBitsTotalL << 24) | (nBitsTotalL >>> 8))  & 0xff00ff00)
  9574                      );
  9575      
  9576                      data.sigBytes = (dataWords.length + 1) * 4;
  9577      
  9578                      // Hash final blocks
  9579                      this._process();
  9580      
  9581                      // Shortcuts
  9582                      var hash = this._hash;
  9583                      var H = hash.words;
  9584      
  9585                      // Swap endian
  9586                      for (var i = 0; i < 4; i++) {
  9587                          // Shortcut
  9588                          var H_i = H[i];
  9589      
  9590                          H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
  9591                                 (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
  9592                      }
  9593      
  9594                      // Return final computed hash
  9595                      return hash;
  9596                  },
  9597      
  9598                  clone: function () {
  9599                      var clone = Hasher.clone.call(this);
  9600                      clone._hash = this._hash.clone();
  9601      
  9602                      return clone;
  9603                  }
  9604              });
  9605      
  9606              function FF(a, b, c, d, x, s, t) {
  9607                  var n = a + ((b & c) | (~b & d)) + x + t;
  9608                  return ((n << s) | (n >>> (32 - s))) + b;
  9609              }
  9610      
  9611              function GG(a, b, c, d, x, s, t) {
  9612                  var n = a + ((b & d) | (c & ~d)) + x + t;
  9613                  return ((n << s) | (n >>> (32 - s))) + b;
  9614              }
  9615      
  9616              function HH(a, b, c, d, x, s, t) {
  9617                  var n = a + (b ^ c ^ d) + x + t;
  9618                  return ((n << s) | (n >>> (32 - s))) + b;
  9619              }
  9620      
  9621              function II(a, b, c, d, x, s, t) {
  9622                  var n = a + (c ^ (b | ~d)) + x + t;
  9623                  return ((n << s) | (n >>> (32 - s))) + b;
  9624              }
  9625      
  9626              /**
  9627               * Shortcut function to the hasher's object interface.
  9628               *
  9629               * @param {WordArray|string} message The message to hash.
  9630               *
  9631               * @return {WordArray} The hash.
  9632               *
  9633               * @static
  9634               *
  9635               * @example
  9636               *
  9637               *     var hash = CryptoJS.MD5('message');
  9638               *     var hash = CryptoJS.MD5(wordArray);
  9639               */
  9640              C.MD5 = Hasher._createHelper(MD5);
  9641      
  9642              /**
  9643               * Shortcut function to the HMAC's object interface.
  9644               *
  9645               * @param {WordArray|string} message The message to hash.
  9646               * @param {WordArray|string} key The secret key.
  9647               *
  9648               * @return {WordArray} The HMAC.
  9649               *
  9650               * @static
  9651               *
  9652               * @example
  9653               *
  9654               *     var hmac = CryptoJS.HmacMD5(message, key);
  9655               */
  9656              C.HmacMD5 = Hasher._createHmacHelper(MD5);
  9657          }(Math));
  9658      
  9659      
  9660          return CryptoJS.MD5;
  9661      
  9662      }));
  9663      },{"./core":53}],62:[function(require,module,exports){
  9664      ;(function (root, factory, undef) {
  9665          if (typeof exports === "object") {
  9666              // CommonJS
  9667              module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9668          }
  9669          else if (typeof define === "function" && define.amd) {
  9670              // AMD
  9671              define(["./core", "./cipher-core"], factory);
  9672          }
  9673          else {
  9674              // Global (browser)
  9675              factory(root.CryptoJS);
  9676          }
  9677      }(this, function (CryptoJS) {
  9678      
  9679          /**
  9680           * Cipher Feedback block mode.
  9681           */
  9682          CryptoJS.mode.CFB = (function () {
  9683              var CFB = CryptoJS.lib.BlockCipherMode.extend();
  9684      
  9685              CFB.Encryptor = CFB.extend({
  9686                  processBlock: function (words, offset) {
  9687                      // Shortcuts
  9688                      var cipher = this._cipher;
  9689                      var blockSize = cipher.blockSize;
  9690      
  9691                      generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9692      
  9693                      // Remember this block to use with next block
  9694                      this._prevBlock = words.slice(offset, offset + blockSize);
  9695                  }
  9696              });
  9697      
  9698              CFB.Decryptor = CFB.extend({
  9699                  processBlock: function (words, offset) {
  9700                      // Shortcuts
  9701                      var cipher = this._cipher;
  9702                      var blockSize = cipher.blockSize;
  9703      
  9704                      // Remember this block to use with next block
  9705                      var thisBlock = words.slice(offset, offset + blockSize);
  9706      
  9707                      generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9708      
  9709                      // This block becomes the previous block
  9710                      this._prevBlock = thisBlock;
  9711                  }
  9712              });
  9713      
  9714              function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
  9715                  // Shortcut
  9716                  var iv = this._iv;
  9717      
  9718                  // Generate keystream
  9719                  if (iv) {
  9720                      var keystream = iv.slice(0);
  9721      
  9722                      // Remove IV for subsequent blocks
  9723                      this._iv = undefined;
  9724                  } else {
  9725                      var keystream = this._prevBlock;
  9726                  }
  9727                  cipher.encryptBlock(keystream, 0);
  9728      
  9729                  // Encrypt
  9730                  for (var i = 0; i < blockSize; i++) {
  9731                      words[offset + i] ^= keystream[i];
  9732                  }
  9733              }
  9734      
  9735              return CFB;
  9736          }());
  9737      
  9738      
  9739          return CryptoJS.mode.CFB;
  9740      
  9741      }));
  9742      },{"./cipher-core":52,"./core":53}],63:[function(require,module,exports){
  9743      ;(function (root, factory, undef) {
  9744          if (typeof exports === "object") {
  9745              // CommonJS
  9746              module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9747          }
  9748          else if (typeof define === "function" && define.amd) {
  9749              // AMD
  9750              define(["./core", "./cipher-core"], factory);
  9751          }
  9752          else {
  9753              // Global (browser)
  9754              factory(root.CryptoJS);
  9755          }
  9756      }(this, function (CryptoJS) {
  9757      
  9758          /** @preserve
  9759           * Counter block mode compatible with  Dr Brian Gladman fileenc.c
  9760           * derived from CryptoJS.mode.CTR
  9761           * Jan Hruby jhruby.web@gmail.com
  9762           */
  9763          CryptoJS.mode.CTRGladman = (function () {
  9764              var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
  9765      
  9766              function incWord(word)
  9767              {
  9768                  if (((word >> 24) & 0xff) === 0xff) { //overflow
  9769                  var b1 = (word >> 16)&0xff;
  9770                  var b2 = (word >> 8)&0xff;
  9771                  var b3 = word & 0xff;
  9772      
  9773                  if (b1 === 0xff) // overflow b1
  9774                  {
  9775                  b1 = 0;
  9776                  if (b2 === 0xff)
  9777                  {
  9778                      b2 = 0;
  9779                      if (b3 === 0xff)
  9780                      {
  9781                          b3 = 0;
  9782                      }
  9783                      else
  9784                      {
  9785                          ++b3;
  9786                      }
  9787                  }
  9788                  else
  9789                  {
  9790                      ++b2;
  9791                  }
  9792                  }
  9793                  else
  9794                  {
  9795                  ++b1;
  9796                  }
  9797      
  9798                  word = 0;
  9799                  word += (b1 << 16);
  9800                  word += (b2 << 8);
  9801                  word += b3;
  9802                  }
  9803                  else
  9804                  {
  9805                  word += (0x01 << 24);
  9806                  }
  9807                  return word;
  9808              }
  9809      
  9810              function incCounter(counter)
  9811              {
  9812                  if ((counter[0] = incWord(counter[0])) === 0)
  9813                  {
  9814                      // encr_data in fileenc.c from  Dr Brian Gladman's counts only with DWORD j < 8
  9815                      counter[1] = incWord(counter[1]);
  9816                  }
  9817                  return counter;
  9818              }
  9819      
  9820              var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
  9821                  processBlock: function (words, offset) {
  9822                      // Shortcuts
  9823                      var cipher = this._cipher
  9824                      var blockSize = cipher.blockSize;
  9825                      var iv = this._iv;
  9826                      var counter = this._counter;
  9827      
  9828                      // Generate keystream
  9829                      if (iv) {
  9830                          counter = this._counter = iv.slice(0);
  9831      
  9832                          // Remove IV for subsequent blocks
  9833                          this._iv = undefined;
  9834                      }
  9835      
  9836                      incCounter(counter);
  9837      
  9838                      var keystream = counter.slice(0);
  9839                      cipher.encryptBlock(keystream, 0);
  9840      
  9841                      // Encrypt
  9842                      for (var i = 0; i < blockSize; i++) {
  9843                          words[offset + i] ^= keystream[i];
  9844                      }
  9845                  }
  9846              });
  9847      
  9848              CTRGladman.Decryptor = Encryptor;
  9849      
  9850              return CTRGladman;
  9851          }());
  9852      
  9853      
  9854      
  9855      
  9856          return CryptoJS.mode.CTRGladman;
  9857      
  9858      }));
  9859      },{"./cipher-core":52,"./core":53}],64:[function(require,module,exports){
  9860      ;(function (root, factory, undef) {
  9861          if (typeof exports === "object") {
  9862              // CommonJS
  9863              module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9864          }
  9865          else if (typeof define === "function" && define.amd) {
  9866              // AMD
  9867              define(["./core", "./cipher-core"], factory);
  9868          }
  9869          else {
  9870              // Global (browser)
  9871              factory(root.CryptoJS);
  9872          }
  9873      }(this, function (CryptoJS) {
  9874      
  9875          /**
  9876           * Counter block mode.
  9877           */
  9878          CryptoJS.mode.CTR = (function () {
  9879              var CTR = CryptoJS.lib.BlockCipherMode.extend();
  9880      
  9881              var Encryptor = CTR.Encryptor = CTR.extend({
  9882                  processBlock: function (words, offset) {
  9883                      // Shortcuts
  9884                      var cipher = this._cipher
  9885                      var blockSize = cipher.blockSize;
  9886                      var iv = this._iv;
  9887                      var counter = this._counter;
  9888      
  9889                      // Generate keystream
  9890                      if (iv) {
  9891                          counter = this._counter = iv.slice(0);
  9892      
  9893                          // Remove IV for subsequent blocks
  9894                          this._iv = undefined;
  9895                      }
  9896                      var keystream = counter.slice(0);
  9897                      cipher.encryptBlock(keystream, 0);
  9898      
  9899                      // Increment counter
  9900                      counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
  9901      
  9902                      // Encrypt
  9903                      for (var i = 0; i < blockSize; i++) {
  9904                          words[offset + i] ^= keystream[i];
  9905                      }
  9906                  }
  9907              });
  9908      
  9909              CTR.Decryptor = Encryptor;
  9910      
  9911              return CTR;
  9912          }());
  9913      
  9914      
  9915          return CryptoJS.mode.CTR;
  9916      
  9917      }));
  9918      },{"./cipher-core":52,"./core":53}],65:[function(require,module,exports){
  9919      ;(function (root, factory, undef) {
  9920          if (typeof exports === "object") {
  9921              // CommonJS
  9922              module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9923          }
  9924          else if (typeof define === "function" && define.amd) {
  9925              // AMD
  9926              define(["./core", "./cipher-core"], factory);
  9927          }
  9928          else {
  9929              // Global (browser)
  9930              factory(root.CryptoJS);
  9931          }
  9932      }(this, function (CryptoJS) {
  9933      
  9934          /**
  9935           * Electronic Codebook block mode.
  9936           */
  9937          CryptoJS.mode.ECB = (function () {
  9938              var ECB = CryptoJS.lib.BlockCipherMode.extend();
  9939      
  9940              ECB.Encryptor = ECB.extend({
  9941                  processBlock: function (words, offset) {
  9942                      this._cipher.encryptBlock(words, offset);
  9943                  }
  9944              });
  9945      
  9946              ECB.Decryptor = ECB.extend({
  9947                  processBlock: function (words, offset) {
  9948                      this._cipher.decryptBlock(words, offset);
  9949                  }
  9950              });
  9951      
  9952              return ECB;
  9953          }());
  9954      
  9955      
  9956          return CryptoJS.mode.ECB;
  9957      
  9958      }));
  9959      },{"./cipher-core":52,"./core":53}],66:[function(require,module,exports){
  9960      ;(function (root, factory, undef) {
  9961          if (typeof exports === "object") {
  9962              // CommonJS
  9963              module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9964          }
  9965          else if (typeof define === "function" && define.amd) {
  9966              // AMD
  9967              define(["./core", "./cipher-core"], factory);
  9968          }
  9969          else {
  9970              // Global (browser)
  9971              factory(root.CryptoJS);
  9972          }
  9973      }(this, function (CryptoJS) {
  9974      
  9975          /**
  9976           * Output Feedback block mode.
  9977           */
  9978          CryptoJS.mode.OFB = (function () {
  9979              var OFB = CryptoJS.lib.BlockCipherMode.extend();
  9980      
  9981              var Encryptor = OFB.Encryptor = OFB.extend({
  9982                  processBlock: function (words, offset) {
  9983                      // Shortcuts
  9984                      var cipher = this._cipher
  9985                      var blockSize = cipher.blockSize;
  9986                      var iv = this._iv;
  9987                      var keystream = this._keystream;
  9988      
  9989                      // Generate keystream
  9990                      if (iv) {
  9991                          keystream = this._keystream = iv.slice(0);
  9992      
  9993                          // Remove IV for subsequent blocks
  9994                          this._iv = undefined;
  9995                      }
  9996                      cipher.encryptBlock(keystream, 0);
  9997      
  9998                      // Encrypt
  9999                      for (var i = 0; i < blockSize; i++) {
 10000                          words[offset + i] ^= keystream[i];
 10001                      }
 10002                  }
 10003              });
 10004      
 10005              OFB.Decryptor = Encryptor;
 10006      
 10007              return OFB;
 10008          }());
 10009      
 10010      
 10011          return CryptoJS.mode.OFB;
 10012      
 10013      }));
 10014      },{"./cipher-core":52,"./core":53}],67:[function(require,module,exports){
 10015      ;(function (root, factory, undef) {
 10016          if (typeof exports === "object") {
 10017              // CommonJS
 10018              module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10019          }
 10020          else if (typeof define === "function" && define.amd) {
 10021              // AMD
 10022              define(["./core", "./cipher-core"], factory);
 10023          }
 10024          else {
 10025              // Global (browser)
 10026              factory(root.CryptoJS);
 10027          }
 10028      }(this, function (CryptoJS) {
 10029      
 10030          /**
 10031           * ANSI X.923 padding strategy.
 10032           */
 10033          CryptoJS.pad.AnsiX923 = {
 10034              pad: function (data, blockSize) {
 10035                  // Shortcuts
 10036                  var dataSigBytes = data.sigBytes;
 10037                  var blockSizeBytes = blockSize * 4;
 10038      
 10039                  // Count padding bytes
 10040                  var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
 10041      
 10042                  // Compute last byte position
 10043                  var lastBytePos = dataSigBytes + nPaddingBytes - 1;
 10044      
 10045                  // Pad
 10046                  data.clamp();
 10047                  data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
 10048                  data.sigBytes += nPaddingBytes;
 10049              },
 10050      
 10051              unpad: function (data) {
 10052                  // Get number of padding bytes from last byte
 10053                  var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
 10054      
 10055                  // Remove padding
 10056                  data.sigBytes -= nPaddingBytes;
 10057              }
 10058          };
 10059      
 10060      
 10061          return CryptoJS.pad.Ansix923;
 10062      
 10063      }));
 10064      },{"./cipher-core":52,"./core":53}],68:[function(require,module,exports){
 10065      ;(function (root, factory, undef) {
 10066          if (typeof exports === "object") {
 10067              // CommonJS
 10068              module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10069          }
 10070          else if (typeof define === "function" && define.amd) {
 10071              // AMD
 10072              define(["./core", "./cipher-core"], factory);
 10073          }
 10074          else {
 10075              // Global (browser)
 10076              factory(root.CryptoJS);
 10077          }
 10078      }(this, function (CryptoJS) {
 10079      
 10080          /**
 10081           * ISO 10126 padding strategy.
 10082           */
 10083          CryptoJS.pad.Iso10126 = {
 10084              pad: function (data, blockSize) {
 10085                  // Shortcut
 10086                  var blockSizeBytes = blockSize * 4;
 10087      
 10088                  // Count padding bytes
 10089                  var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
 10090      
 10091                  // Pad
 10092                  data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
 10093                       concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
 10094              },
 10095      
 10096              unpad: function (data) {
 10097                  // Get number of padding bytes from last byte
 10098                  var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
 10099      
 10100                  // Remove padding
 10101                  data.sigBytes -= nPaddingBytes;
 10102              }
 10103          };
 10104      
 10105      
 10106          return CryptoJS.pad.Iso10126;
 10107      
 10108      }));
 10109      },{"./cipher-core":52,"./core":53}],69:[function(require,module,exports){
 10110      ;(function (root, factory, undef) {
 10111          if (typeof exports === "object") {
 10112              // CommonJS
 10113              module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10114          }
 10115          else if (typeof define === "function" && define.amd) {
 10116              // AMD
 10117              define(["./core", "./cipher-core"], factory);
 10118          }
 10119          else {
 10120              // Global (browser)
 10121              factory(root.CryptoJS);
 10122          }
 10123      }(this, function (CryptoJS) {
 10124      
 10125          /**
 10126           * ISO/IEC 9797-1 Padding Method 2.
 10127           */
 10128          CryptoJS.pad.Iso97971 = {
 10129              pad: function (data, blockSize) {
 10130                  // Add 0x80 byte
 10131                  data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
 10132      
 10133                  // Zero pad the rest
 10134                  CryptoJS.pad.ZeroPadding.pad(data, blockSize);
 10135              },
 10136      
 10137              unpad: function (data) {
 10138                  // Remove zero padding
 10139                  CryptoJS.pad.ZeroPadding.unpad(data);
 10140      
 10141                  // Remove one more byte -- the 0x80 byte
 10142                  data.sigBytes--;
 10143              }
 10144          };
 10145      
 10146      
 10147          return CryptoJS.pad.Iso97971;
 10148      
 10149      }));
 10150      },{"./cipher-core":52,"./core":53}],70:[function(require,module,exports){
 10151      ;(function (root, factory, undef) {
 10152          if (typeof exports === "object") {
 10153              // CommonJS
 10154              module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10155          }
 10156          else if (typeof define === "function" && define.amd) {
 10157              // AMD
 10158              define(["./core", "./cipher-core"], factory);
 10159          }
 10160          else {
 10161              // Global (browser)
 10162              factory(root.CryptoJS);
 10163          }
 10164      }(this, function (CryptoJS) {
 10165      
 10166          /**
 10167           * A noop padding strategy.
 10168           */
 10169          CryptoJS.pad.NoPadding = {
 10170              pad: function () {
 10171              },
 10172      
 10173              unpad: function () {
 10174              }
 10175          };
 10176      
 10177      
 10178          return CryptoJS.pad.NoPadding;
 10179      
 10180      }));
 10181      },{"./cipher-core":52,"./core":53}],71:[function(require,module,exports){
 10182      ;(function (root, factory, undef) {
 10183          if (typeof exports === "object") {
 10184              // CommonJS
 10185              module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10186          }
 10187          else if (typeof define === "function" && define.amd) {
 10188              // AMD
 10189              define(["./core", "./cipher-core"], factory);
 10190          }
 10191          else {
 10192              // Global (browser)
 10193              factory(root.CryptoJS);
 10194          }
 10195      }(this, function (CryptoJS) {
 10196      
 10197          /**
 10198           * Zero padding strategy.
 10199           */
 10200          CryptoJS.pad.ZeroPadding = {
 10201              pad: function (data, blockSize) {
 10202                  // Shortcut
 10203                  var blockSizeBytes = blockSize * 4;
 10204      
 10205                  // Pad
 10206                  data.clamp();
 10207                  data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
 10208              },
 10209      
 10210              unpad: function (data) {
 10211                  // Shortcut
 10212                  var dataWords = data.words;
 10213      
 10214                  // Unpad
 10215                  var i = data.sigBytes - 1;
 10216                  while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
 10217                      i--;
 10218                  }
 10219                  data.sigBytes = i + 1;
 10220              }
 10221          };
 10222      
 10223      
 10224          return CryptoJS.pad.ZeroPadding;
 10225      
 10226      }));
 10227      },{"./cipher-core":52,"./core":53}],72:[function(require,module,exports){
 10228      ;(function (root, factory, undef) {
 10229          if (typeof exports === "object") {
 10230              // CommonJS
 10231              module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
 10232          }
 10233          else if (typeof define === "function" && define.amd) {
 10234              // AMD
 10235              define(["./core", "./sha1", "./hmac"], factory);
 10236          }
 10237          else {
 10238              // Global (browser)
 10239              factory(root.CryptoJS);
 10240          }
 10241      }(this, function (CryptoJS) {
 10242      
 10243          (function () {
 10244              // Shortcuts
 10245              var C = CryptoJS;
 10246              var C_lib = C.lib;
 10247              var Base = C_lib.Base;
 10248              var WordArray = C_lib.WordArray;
 10249              var C_algo = C.algo;
 10250              var SHA1 = C_algo.SHA1;
 10251              var HMAC = C_algo.HMAC;
 10252      
 10253              /**
 10254               * Password-Based Key Derivation Function 2 algorithm.
 10255               */
 10256              var PBKDF2 = C_algo.PBKDF2 = Base.extend({
 10257                  /**
 10258                   * Configuration options.
 10259                   *
 10260                   * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
 10261                   * @property {Hasher} hasher The hasher to use. Default: SHA1
 10262                   * @property {number} iterations The number of iterations to perform. Default: 1
 10263                   */
 10264                  cfg: Base.extend({
 10265                      keySize: 128/32,
 10266                      hasher: SHA1,
 10267                      iterations: 1
 10268                  }),
 10269      
 10270                  /**
 10271                   * Initializes a newly created key derivation function.
 10272                   *
 10273                   * @param {Object} cfg (Optional) The configuration options to use for the derivation.
 10274                   *
 10275                   * @example
 10276                   *
 10277                   *     var kdf = CryptoJS.algo.PBKDF2.create();
 10278                   *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
 10279                   *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
 10280                   */
 10281                  init: function (cfg) {
 10282                      this.cfg = this.cfg.extend(cfg);
 10283                  },
 10284      
 10285                  /**
 10286                   * Computes the Password-Based Key Derivation Function 2.
 10287                   *
 10288                   * @param {WordArray|string} password The password.
 10289                   * @param {WordArray|string} salt A salt.
 10290                   *
 10291                   * @return {WordArray} The derived key.
 10292                   *
 10293                   * @example
 10294                   *
 10295                   *     var key = kdf.compute(password, salt);
 10296                   */
 10297                  compute: function (password, salt) {
 10298                      // Shortcut
 10299                      var cfg = this.cfg;
 10300      
 10301                      // Init HMAC
 10302                      var hmac = HMAC.create(cfg.hasher, password);
 10303      
 10304                      // Initial values
 10305                      var derivedKey = WordArray.create();
 10306                      var blockIndex = WordArray.create([0x00000001]);
 10307      
 10308                      // Shortcuts
 10309                      var derivedKeyWords = derivedKey.words;
 10310                      var blockIndexWords = blockIndex.words;
 10311                      var keySize = cfg.keySize;
 10312                      var iterations = cfg.iterations;
 10313      
 10314                      // Generate key
 10315                      while (derivedKeyWords.length < keySize) {
 10316                          var block = hmac.update(salt).finalize(blockIndex);
 10317                          hmac.reset();
 10318      
 10319                          // Shortcuts
 10320                          var blockWords = block.words;
 10321                          var blockWordsLength = blockWords.length;
 10322      
 10323                          // Iterations
 10324                          var intermediate = block;
 10325                          for (var i = 1; i < iterations; i++) {
 10326                              intermediate = hmac.finalize(intermediate);
 10327                              hmac.reset();
 10328      
 10329                              // Shortcut
 10330                              var intermediateWords = intermediate.words;
 10331      
 10332                              // XOR intermediate with block
 10333                              for (var j = 0; j < blockWordsLength; j++) {
 10334                                  blockWords[j] ^= intermediateWords[j];
 10335                              }
 10336                          }
 10337      
 10338                          derivedKey.concat(block);
 10339                          blockIndexWords[0]++;
 10340                      }
 10341                      derivedKey.sigBytes = keySize * 4;
 10342      
 10343                      return derivedKey;
 10344                  }
 10345              });
 10346      
 10347              /**
 10348               * Computes the Password-Based Key Derivation Function 2.
 10349               *
 10350               * @param {WordArray|string} password The password.
 10351               * @param {WordArray|string} salt A salt.
 10352               * @param {Object} cfg (Optional) The configuration options to use for this computation.
 10353               *
 10354               * @return {WordArray} The derived key.
 10355               *
 10356               * @static
 10357               *
 10358               * @example
 10359               *
 10360               *     var key = CryptoJS.PBKDF2(password, salt);
 10361               *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
 10362               *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
 10363               */
 10364              C.PBKDF2 = function (password, salt, cfg) {
 10365                  return PBKDF2.create(cfg).compute(password, salt);
 10366              };
 10367          }());
 10368      
 10369      
 10370          return CryptoJS.PBKDF2;
 10371      
 10372      }));
 10373      },{"./core":53,"./hmac":58,"./sha1":77}],73:[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              // Reusable objects
 10397              var S  = [];
 10398              var C_ = [];
 10399              var G  = [];
 10400      
 10401              /**
 10402               * Rabbit stream cipher algorithm.
 10403               *
 10404               * This is a legacy version that neglected to convert the key to little-endian.
 10405               * This error doesn't affect the cipher's security,
 10406               * but it does affect its compatibility with other implementations.
 10407               */
 10408              var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
 10409                  _doReset: function () {
 10410                      // Shortcuts
 10411                      var K = this._key.words;
 10412                      var iv = this.cfg.iv;
 10413      
 10414                      // Generate initial state values
 10415                      var X = this._X = [
 10416                          K[0], (K[3] << 16) | (K[2] >>> 16),
 10417                          K[1], (K[0] << 16) | (K[3] >>> 16),
 10418                          K[2], (K[1] << 16) | (K[0] >>> 16),
 10419                          K[3], (K[2] << 16) | (K[1] >>> 16)
 10420                      ];
 10421      
 10422                      // Generate initial counter values
 10423                      var C = this._C = [
 10424                          (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10425                          (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10426                          (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10427                          (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10428                      ];
 10429      
 10430                      // Carry bit
 10431                      this._b = 0;
 10432      
 10433                      // Iterate the system four times
 10434                      for (var i = 0; i < 4; i++) {
 10435                          nextState.call(this);
 10436                      }
 10437      
 10438                      // Modify the counters
 10439                      for (var i = 0; i < 8; i++) {
 10440                          C[i] ^= X[(i + 4) & 7];
 10441                      }
 10442      
 10443                      // IV setup
 10444                      if (iv) {
 10445                          // Shortcuts
 10446                          var IV = iv.words;
 10447                          var IV_0 = IV[0];
 10448                          var IV_1 = IV[1];
 10449      
 10450                          // Generate four subvectors
 10451                          var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10452                          var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10453                          var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10454                          var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10455      
 10456                          // Modify counter values
 10457                          C[0] ^= i0;
 10458                          C[1] ^= i1;
 10459                          C[2] ^= i2;
 10460                          C[3] ^= i3;
 10461                          C[4] ^= i0;
 10462                          C[5] ^= i1;
 10463                          C[6] ^= i2;
 10464                          C[7] ^= i3;
 10465      
 10466                          // Iterate the system four times
 10467                          for (var i = 0; i < 4; i++) {
 10468                              nextState.call(this);
 10469                          }
 10470                      }
 10471                  },
 10472      
 10473                  _doProcessBlock: function (M, offset) {
 10474                      // Shortcut
 10475                      var X = this._X;
 10476      
 10477                      // Iterate the system
 10478                      nextState.call(this);
 10479      
 10480                      // Generate four keystream words
 10481                      S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10482                      S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10483                      S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10484                      S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10485      
 10486                      for (var i = 0; i < 4; i++) {
 10487                          // Swap endian
 10488                          S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10489                                 (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10490      
 10491                          // Encrypt
 10492                          M[offset + i] ^= S[i];
 10493                      }
 10494                  },
 10495      
 10496                  blockSize: 128/32,
 10497      
 10498                  ivSize: 64/32
 10499              });
 10500      
 10501              function nextState() {
 10502                  // Shortcuts
 10503                  var X = this._X;
 10504                  var C = this._C;
 10505      
 10506                  // Save old counter values
 10507                  for (var i = 0; i < 8; i++) {
 10508                      C_[i] = C[i];
 10509                  }
 10510      
 10511                  // Calculate new counter values
 10512                  C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10513                  C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10514                  C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10515                  C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10516                  C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10517                  C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10518                  C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10519                  C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10520                  this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10521      
 10522                  // Calculate the g-values
 10523                  for (var i = 0; i < 8; i++) {
 10524                      var gx = X[i] + C[i];
 10525      
 10526                      // Construct high and low argument for squaring
 10527                      var ga = gx & 0xffff;
 10528                      var gb = gx >>> 16;
 10529      
 10530                      // Calculate high and low result of squaring
 10531                      var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10532                      var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10533      
 10534                      // High XOR low
 10535                      G[i] = gh ^ gl;
 10536                  }
 10537      
 10538                  // Calculate new state values
 10539                  X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10540                  X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10541                  X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10542                  X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10543                  X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10544                  X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10545                  X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10546                  X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10547              }
 10548      
 10549              /**
 10550               * Shortcut functions to the cipher's object interface.
 10551               *
 10552               * @example
 10553               *
 10554               *     var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
 10555               *     var plaintext  = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
 10556               */
 10557              C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
 10558          }());
 10559      
 10560      
 10561          return CryptoJS.RabbitLegacy;
 10562      
 10563      }));
 10564      },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],74:[function(require,module,exports){
 10565      ;(function (root, factory, undef) {
 10566          if (typeof exports === "object") {
 10567              // CommonJS
 10568              module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10569          }
 10570          else if (typeof define === "function" && define.amd) {
 10571              // AMD
 10572              define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10573          }
 10574          else {
 10575              // Global (browser)
 10576              factory(root.CryptoJS);
 10577          }
 10578      }(this, function (CryptoJS) {
 10579      
 10580          (function () {
 10581              // Shortcuts
 10582              var C = CryptoJS;
 10583              var C_lib = C.lib;
 10584              var StreamCipher = C_lib.StreamCipher;
 10585              var C_algo = C.algo;
 10586      
 10587              // Reusable objects
 10588              var S  = [];
 10589              var C_ = [];
 10590              var G  = [];
 10591      
 10592              /**
 10593               * Rabbit stream cipher algorithm
 10594               */
 10595              var Rabbit = C_algo.Rabbit = StreamCipher.extend({
 10596                  _doReset: function () {
 10597                      // Shortcuts
 10598                      var K = this._key.words;
 10599                      var iv = this.cfg.iv;
 10600      
 10601                      // Swap endian
 10602                      for (var i = 0; i < 4; i++) {
 10603                          K[i] = (((K[i] << 8)  | (K[i] >>> 24)) & 0x00ff00ff) |
 10604                                 (((K[i] << 24) | (K[i] >>> 8))  & 0xff00ff00);
 10605                      }
 10606      
 10607                      // Generate initial state values
 10608                      var X = this._X = [
 10609                          K[0], (K[3] << 16) | (K[2] >>> 16),
 10610                          K[1], (K[0] << 16) | (K[3] >>> 16),
 10611                          K[2], (K[1] << 16) | (K[0] >>> 16),
 10612                          K[3], (K[2] << 16) | (K[1] >>> 16)
 10613                      ];
 10614      
 10615                      // Generate initial counter values
 10616                      var C = this._C = [
 10617                          (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10618                          (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10619                          (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10620                          (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10621                      ];
 10622      
 10623                      // Carry bit
 10624                      this._b = 0;
 10625      
 10626                      // Iterate the system four times
 10627                      for (var i = 0; i < 4; i++) {
 10628                          nextState.call(this);
 10629                      }
 10630      
 10631                      // Modify the counters
 10632                      for (var i = 0; i < 8; i++) {
 10633                          C[i] ^= X[(i + 4) & 7];
 10634                      }
 10635      
 10636                      // IV setup
 10637                      if (iv) {
 10638                          // Shortcuts
 10639                          var IV = iv.words;
 10640                          var IV_0 = IV[0];
 10641                          var IV_1 = IV[1];
 10642      
 10643                          // Generate four subvectors
 10644                          var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10645                          var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10646                          var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10647                          var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10648      
 10649                          // Modify counter values
 10650                          C[0] ^= i0;
 10651                          C[1] ^= i1;
 10652                          C[2] ^= i2;
 10653                          C[3] ^= i3;
 10654                          C[4] ^= i0;
 10655                          C[5] ^= i1;
 10656                          C[6] ^= i2;
 10657                          C[7] ^= i3;
 10658      
 10659                          // Iterate the system four times
 10660                          for (var i = 0; i < 4; i++) {
 10661                              nextState.call(this);
 10662                          }
 10663                      }
 10664                  },
 10665      
 10666                  _doProcessBlock: function (M, offset) {
 10667                      // Shortcut
 10668                      var X = this._X;
 10669      
 10670                      // Iterate the system
 10671                      nextState.call(this);
 10672      
 10673                      // Generate four keystream words
 10674                      S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10675                      S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10676                      S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10677                      S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10678      
 10679                      for (var i = 0; i < 4; i++) {
 10680                          // Swap endian
 10681                          S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10682                                 (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10683      
 10684                          // Encrypt
 10685                          M[offset + i] ^= S[i];
 10686                      }
 10687                  },
 10688      
 10689                  blockSize: 128/32,
 10690      
 10691                  ivSize: 64/32
 10692              });
 10693      
 10694              function nextState() {
 10695                  // Shortcuts
 10696                  var X = this._X;
 10697                  var C = this._C;
 10698      
 10699                  // Save old counter values
 10700                  for (var i = 0; i < 8; i++) {
 10701                      C_[i] = C[i];
 10702                  }
 10703      
 10704                  // Calculate new counter values
 10705                  C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10706                  C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10707                  C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10708                  C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10709                  C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10710                  C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10711                  C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10712                  C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10713                  this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10714      
 10715                  // Calculate the g-values
 10716                  for (var i = 0; i < 8; i++) {
 10717                      var gx = X[i] + C[i];
 10718      
 10719                      // Construct high and low argument for squaring
 10720                      var ga = gx & 0xffff;
 10721                      var gb = gx >>> 16;
 10722      
 10723                      // Calculate high and low result of squaring
 10724                      var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10725                      var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10726      
 10727                      // High XOR low
 10728                      G[i] = gh ^ gl;
 10729                  }
 10730      
 10731                  // Calculate new state values
 10732                  X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10733                  X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10734                  X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10735                  X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10736                  X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10737                  X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10738                  X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10739                  X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10740              }
 10741      
 10742              /**
 10743               * Shortcut functions to the cipher's object interface.
 10744               *
 10745               * @example
 10746               *
 10747               *     var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
 10748               *     var plaintext  = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
 10749               */
 10750              C.Rabbit = StreamCipher._createHelper(Rabbit);
 10751          }());
 10752      
 10753      
 10754          return CryptoJS.Rabbit;
 10755      
 10756      }));
 10757      },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],75:[function(require,module,exports){
 10758      ;(function (root, factory, undef) {
 10759          if (typeof exports === "object") {
 10760              // CommonJS
 10761              module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10762          }
 10763          else if (typeof define === "function" && define.amd) {
 10764              // AMD
 10765              define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10766          }
 10767          else {
 10768              // Global (browser)
 10769              factory(root.CryptoJS);
 10770          }
 10771      }(this, function (CryptoJS) {
 10772      
 10773          (function () {
 10774              // Shortcuts
 10775              var C = CryptoJS;
 10776              var C_lib = C.lib;
 10777              var StreamCipher = C_lib.StreamCipher;
 10778              var C_algo = C.algo;
 10779      
 10780              /**
 10781               * RC4 stream cipher algorithm.
 10782               */
 10783              var RC4 = C_algo.RC4 = StreamCipher.extend({
 10784                  _doReset: function () {
 10785                      // Shortcuts
 10786                      var key = this._key;
 10787                      var keyWords = key.words;
 10788                      var keySigBytes = key.sigBytes;
 10789      
 10790                      // Init sbox
 10791                      var S = this._S = [];
 10792                      for (var i = 0; i < 256; i++) {
 10793                          S[i] = i;
 10794                      }
 10795      
 10796                      // Key setup
 10797                      for (var i = 0, j = 0; i < 256; i++) {
 10798                          var keyByteIndex = i % keySigBytes;
 10799                          var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
 10800      
 10801                          j = (j + S[i] + keyByte) % 256;
 10802      
 10803                          // Swap
 10804                          var t = S[i];
 10805                          S[i] = S[j];
 10806                          S[j] = t;
 10807                      }
 10808      
 10809                      // Counters
 10810                      this._i = this._j = 0;
 10811                  },
 10812      
 10813                  _doProcessBlock: function (M, offset) {
 10814                      M[offset] ^= generateKeystreamWord.call(this);
 10815                  },
 10816      
 10817                  keySize: 256/32,
 10818      
 10819                  ivSize: 0
 10820              });
 10821      
 10822              function generateKeystreamWord() {
 10823                  // Shortcuts
 10824                  var S = this._S;
 10825                  var i = this._i;
 10826                  var j = this._j;
 10827      
 10828                  // Generate keystream word
 10829                  var keystreamWord = 0;
 10830                  for (var n = 0; n < 4; n++) {
 10831                      i = (i + 1) % 256;
 10832                      j = (j + S[i]) % 256;
 10833      
 10834                      // Swap
 10835                      var t = S[i];
 10836                      S[i] = S[j];
 10837                      S[j] = t;
 10838      
 10839                      keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
 10840                  }
 10841      
 10842                  // Update counters
 10843                  this._i = i;
 10844                  this._j = j;
 10845      
 10846                  return keystreamWord;
 10847              }
 10848      
 10849              /**
 10850               * Shortcut functions to the cipher's object interface.
 10851               *
 10852               * @example
 10853               *
 10854               *     var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
 10855               *     var plaintext  = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
 10856               */
 10857              C.RC4 = StreamCipher._createHelper(RC4);
 10858      
 10859              /**
 10860               * Modified RC4 stream cipher algorithm.
 10861               */
 10862              var RC4Drop = C_algo.RC4Drop = RC4.extend({
 10863                  /**
 10864                   * Configuration options.
 10865                   *
 10866                   * @property {number} drop The number of keystream words to drop. Default 192
 10867                   */
 10868                  cfg: RC4.cfg.extend({
 10869                      drop: 192
 10870                  }),
 10871      
 10872                  _doReset: function () {
 10873                      RC4._doReset.call(this);
 10874      
 10875                      // Drop
 10876                      for (var i = this.cfg.drop; i > 0; i--) {
 10877                          generateKeystreamWord.call(this);
 10878                      }
 10879                  }
 10880              });
 10881      
 10882              /**
 10883               * Shortcut functions to the cipher's object interface.
 10884               *
 10885               * @example
 10886               *
 10887               *     var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
 10888               *     var plaintext  = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
 10889               */
 10890              C.RC4Drop = StreamCipher._createHelper(RC4Drop);
 10891          }());
 10892      
 10893      
 10894          return CryptoJS.RC4;
 10895      
 10896      }));
 10897      },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],76:[function(require,module,exports){
 10898      ;(function (root, factory) {
 10899          if (typeof exports === "object") {
 10900              // CommonJS
 10901              module.exports = exports = factory(require("./core"));
 10902          }
 10903          else if (typeof define === "function" && define.amd) {
 10904              // AMD
 10905              define(["./core"], factory);
 10906          }
 10907          else {
 10908              // Global (browser)
 10909              factory(root.CryptoJS);
 10910          }
 10911      }(this, function (CryptoJS) {
 10912      
 10913          /** @preserve
 10914          (c) 2012 by Cédric Mesnil. All rights reserved.
 10915      
 10916          Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 10917      
 10918              - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 10919              - 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.
 10920      
 10921          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.
 10922          */
 10923      
 10924          (function (Math) {
 10925              // Shortcuts
 10926              var C = CryptoJS;
 10927              var C_lib = C.lib;
 10928              var WordArray = C_lib.WordArray;
 10929              var Hasher = C_lib.Hasher;
 10930              var C_algo = C.algo;
 10931      
 10932              // Constants table
 10933              var _zl = WordArray.create([
 10934                  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
 10935                  7,  4, 13,  1, 10,  6, 15,  3, 12,  0,  9,  5,  2, 14, 11,  8,
 10936                  3, 10, 14,  4,  9, 15,  8,  1,  2,  7,  0,  6, 13, 11,  5, 12,
 10937                  1,  9, 11, 10,  0,  8, 12,  4, 13,  3,  7, 15, 14,  5,  6,  2,
 10938                  4,  0,  5,  9,  7, 12,  2, 10, 14,  1,  3,  8, 11,  6, 15, 13]);
 10939              var _zr = WordArray.create([
 10940                  5, 14,  7,  0,  9,  2, 11,  4, 13,  6, 15,  8,  1, 10,  3, 12,
 10941                  6, 11,  3,  7,  0, 13,  5, 10, 14, 15,  8, 12,  4,  9,  1,  2,
 10942                  15,  5,  1,  3,  7, 14,  6,  9, 11,  8, 12,  2, 10,  0,  4, 13,
 10943                  8,  6,  4,  1,  3, 11, 15,  0,  5, 12,  2, 13,  9,  7, 10, 14,
 10944                  12, 15, 10,  4,  1,  5,  8,  7,  6,  2, 13, 14,  0,  3,  9, 11]);
 10945              var _sl = WordArray.create([
 10946                   11, 14, 15, 12,  5,  8,  7,  9, 11, 13, 14, 15,  6,  7,  9,  8,
 10947                  7, 6,   8, 13, 11,  9,  7, 15,  7, 12, 15,  9, 11,  7, 13, 12,
 10948                  11, 13,  6,  7, 14,  9, 13, 15, 14,  8, 13,  6,  5, 12,  7,  5,
 10949                    11, 12, 14, 15, 14, 15,  9,  8,  9, 14,  5,  6,  8,  6,  5, 12,
 10950                  9, 15,  5, 11,  6,  8, 13, 12,  5, 12, 13, 14, 11,  8,  5,  6 ]);
 10951              var _sr = WordArray.create([
 10952                  8,  9,  9, 11, 13, 15, 15,  5,  7,  7,  8, 11, 14, 14, 12,  6,
 10953                  9, 13, 15,  7, 12,  8,  9, 11,  7,  7, 12,  7,  6, 15, 13, 11,
 10954                  9,  7, 15, 11,  8,  6,  6, 14, 12, 13,  5, 14, 13, 13,  7,  5,
 10955                  15,  5,  8, 11, 14, 14,  6, 14,  6,  9, 12,  9, 12,  5, 15,  8,
 10956                  8,  5, 12,  9, 12,  5, 14,  6,  8, 13,  6,  5, 15, 13, 11, 11 ]);
 10957      
 10958              var _hl =  WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
 10959              var _hr =  WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
 10960      
 10961              /**
 10962               * RIPEMD160 hash algorithm.
 10963               */
 10964              var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
 10965                  _doReset: function () {
 10966                      this._hash  = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
 10967                  },
 10968      
 10969                  _doProcessBlock: function (M, offset) {
 10970      
 10971                      // Swap endian
 10972                      for (var i = 0; i < 16; i++) {
 10973                          // Shortcuts
 10974                          var offset_i = offset + i;
 10975                          var M_offset_i = M[offset_i];
 10976      
 10977                          // Swap
 10978                          M[offset_i] = (
 10979                              (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
 10980                              (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
 10981                          );
 10982                      }
 10983                      // Shortcut
 10984                      var H  = this._hash.words;
 10985                      var hl = _hl.words;
 10986                      var hr = _hr.words;
 10987                      var zl = _zl.words;
 10988                      var zr = _zr.words;
 10989                      var sl = _sl.words;
 10990                      var sr = _sr.words;
 10991      
 10992                      // Working variables
 10993                      var al, bl, cl, dl, el;
 10994                      var ar, br, cr, dr, er;
 10995      
 10996                      ar = al = H[0];
 10997                      br = bl = H[1];
 10998                      cr = cl = H[2];
 10999                      dr = dl = H[3];
 11000                      er = el = H[4];
 11001                      // Computation
 11002                      var t;
 11003                      for (var i = 0; i < 80; i += 1) {
 11004                          t = (al +  M[offset+zl[i]])|0;
 11005                          if (i<16){
 11006                          t +=  f1(bl,cl,dl) + hl[0];
 11007                          } else if (i<32) {
 11008                          t +=  f2(bl,cl,dl) + hl[1];
 11009                          } else if (i<48) {
 11010                          t +=  f3(bl,cl,dl) + hl[2];
 11011                          } else if (i<64) {
 11012                          t +=  f4(bl,cl,dl) + hl[3];
 11013                          } else {// if (i<80) {
 11014                          t +=  f5(bl,cl,dl) + hl[4];
 11015                          }
 11016                          t = t|0;
 11017                          t =  rotl(t,sl[i]);
 11018                          t = (t+el)|0;
 11019                          al = el;
 11020                          el = dl;
 11021                          dl = rotl(cl, 10);
 11022                          cl = bl;
 11023                          bl = t;
 11024      
 11025                          t = (ar + M[offset+zr[i]])|0;
 11026                          if (i<16){
 11027                          t +=  f5(br,cr,dr) + hr[0];
 11028                          } else if (i<32) {
 11029                          t +=  f4(br,cr,dr) + hr[1];
 11030                          } else if (i<48) {
 11031                          t +=  f3(br,cr,dr) + hr[2];
 11032                          } else if (i<64) {
 11033                          t +=  f2(br,cr,dr) + hr[3];
 11034                          } else {// if (i<80) {
 11035                          t +=  f1(br,cr,dr) + hr[4];
 11036                          }
 11037                          t = t|0;
 11038                          t =  rotl(t,sr[i]) ;
 11039                          t = (t+er)|0;
 11040                          ar = er;
 11041                          er = dr;
 11042                          dr = rotl(cr, 10);
 11043                          cr = br;
 11044                          br = t;
 11045                      }
 11046                      // Intermediate hash value
 11047                      t    = (H[1] + cl + dr)|0;
 11048                      H[1] = (H[2] + dl + er)|0;
 11049                      H[2] = (H[3] + el + ar)|0;
 11050                      H[3] = (H[4] + al + br)|0;
 11051                      H[4] = (H[0] + bl + cr)|0;
 11052                      H[0] =  t;
 11053                  },
 11054      
 11055                  _doFinalize: function () {
 11056                      // Shortcuts
 11057                      var data = this._data;
 11058                      var dataWords = data.words;
 11059      
 11060                      var nBitsTotal = this._nDataBytes * 8;
 11061                      var nBitsLeft = data.sigBytes * 8;
 11062      
 11063                      // Add padding
 11064                      dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11065                      dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
 11066                          (((nBitsTotal << 8)  | (nBitsTotal >>> 24)) & 0x00ff00ff) |
 11067                          (((nBitsTotal << 24) | (nBitsTotal >>> 8))  & 0xff00ff00)
 11068                      );
 11069                      data.sigBytes = (dataWords.length + 1) * 4;
 11070      
 11071                      // Hash final blocks
 11072                      this._process();
 11073      
 11074                      // Shortcuts
 11075                      var hash = this._hash;
 11076                      var H = hash.words;
 11077      
 11078                      // Swap endian
 11079                      for (var i = 0; i < 5; i++) {
 11080                          // Shortcut
 11081                          var H_i = H[i];
 11082      
 11083                          // Swap
 11084                          H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
 11085                                 (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
 11086                      }
 11087      
 11088                      // Return final computed hash
 11089                      return hash;
 11090                  },
 11091      
 11092                  clone: function () {
 11093                      var clone = Hasher.clone.call(this);
 11094                      clone._hash = this._hash.clone();
 11095      
 11096                      return clone;
 11097                  }
 11098              });
 11099      
 11100      
 11101              function f1(x, y, z) {
 11102                  return ((x) ^ (y) ^ (z));
 11103      
 11104              }
 11105      
 11106              function f2(x, y, z) {
 11107                  return (((x)&(y)) | ((~x)&(z)));
 11108              }
 11109      
 11110              function f3(x, y, z) {
 11111                  return (((x) | (~(y))) ^ (z));
 11112              }
 11113      
 11114              function f4(x, y, z) {
 11115                  return (((x) & (z)) | ((y)&(~(z))));
 11116              }
 11117      
 11118              function f5(x, y, z) {
 11119                  return ((x) ^ ((y) |(~(z))));
 11120      
 11121              }
 11122      
 11123              function rotl(x,n) {
 11124                  return (x<<n) | (x>>>(32-n));
 11125              }
 11126      
 11127      
 11128              /**
 11129               * Shortcut function to the hasher's object interface.
 11130               *
 11131               * @param {WordArray|string} message The message to hash.
 11132               *
 11133               * @return {WordArray} The hash.
 11134               *
 11135               * @static
 11136               *
 11137               * @example
 11138               *
 11139               *     var hash = CryptoJS.RIPEMD160('message');
 11140               *     var hash = CryptoJS.RIPEMD160(wordArray);
 11141               */
 11142              C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
 11143      
 11144              /**
 11145               * Shortcut function to the HMAC's object interface.
 11146               *
 11147               * @param {WordArray|string} message The message to hash.
 11148               * @param {WordArray|string} key The secret key.
 11149               *
 11150               * @return {WordArray} The HMAC.
 11151               *
 11152               * @static
 11153               *
 11154               * @example
 11155               *
 11156               *     var hmac = CryptoJS.HmacRIPEMD160(message, key);
 11157               */
 11158              C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
 11159          }(Math));
 11160      
 11161      
 11162          return CryptoJS.RIPEMD160;
 11163      
 11164      }));
 11165      },{"./core":53}],77:[function(require,module,exports){
 11166      ;(function (root, factory) {
 11167          if (typeof exports === "object") {
 11168              // CommonJS
 11169              module.exports = exports = factory(require("./core"));
 11170          }
 11171          else if (typeof define === "function" && define.amd) {
 11172              // AMD
 11173              define(["./core"], factory);
 11174          }
 11175          else {
 11176              // Global (browser)
 11177              factory(root.CryptoJS);
 11178          }
 11179      }(this, function (CryptoJS) {
 11180      
 11181          (function () {
 11182              // Shortcuts
 11183              var C = CryptoJS;
 11184              var C_lib = C.lib;
 11185              var WordArray = C_lib.WordArray;
 11186              var Hasher = C_lib.Hasher;
 11187              var C_algo = C.algo;
 11188      
 11189              // Reusable object
 11190              var W = [];
 11191      
 11192              /**
 11193               * SHA-1 hash algorithm.
 11194               */
 11195              var SHA1 = C_algo.SHA1 = Hasher.extend({
 11196                  _doReset: function () {
 11197                      this._hash = new WordArray.init([
 11198                          0x67452301, 0xefcdab89,
 11199                          0x98badcfe, 0x10325476,
 11200                          0xc3d2e1f0
 11201                      ]);
 11202                  },
 11203      
 11204                  _doProcessBlock: function (M, offset) {
 11205                      // Shortcut
 11206                      var H = this._hash.words;
 11207      
 11208                      // Working variables
 11209                      var a = H[0];
 11210                      var b = H[1];
 11211                      var c = H[2];
 11212                      var d = H[3];
 11213                      var e = H[4];
 11214      
 11215                      // Computation
 11216                      for (var i = 0; i < 80; i++) {
 11217                          if (i < 16) {
 11218                              W[i] = M[offset + i] | 0;
 11219                          } else {
 11220                              var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
 11221                              W[i] = (n << 1) | (n >>> 31);
 11222                          }
 11223      
 11224                          var t = ((a << 5) | (a >>> 27)) + e + W[i];
 11225                          if (i < 20) {
 11226                              t += ((b & c) | (~b & d)) + 0x5a827999;
 11227                          } else if (i < 40) {
 11228                              t += (b ^ c ^ d) + 0x6ed9eba1;
 11229                          } else if (i < 60) {
 11230                              t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
 11231                          } else /* if (i < 80) */ {
 11232                              t += (b ^ c ^ d) - 0x359d3e2a;
 11233                          }
 11234      
 11235                          e = d;
 11236                          d = c;
 11237                          c = (b << 30) | (b >>> 2);
 11238                          b = a;
 11239                          a = t;
 11240                      }
 11241      
 11242                      // Intermediate hash value
 11243                      H[0] = (H[0] + a) | 0;
 11244                      H[1] = (H[1] + b) | 0;
 11245                      H[2] = (H[2] + c) | 0;
 11246                      H[3] = (H[3] + d) | 0;
 11247                      H[4] = (H[4] + e) | 0;
 11248                  },
 11249      
 11250                  _doFinalize: function () {
 11251                      // Shortcuts
 11252                      var data = this._data;
 11253                      var dataWords = data.words;
 11254      
 11255                      var nBitsTotal = this._nDataBytes * 8;
 11256                      var nBitsLeft = data.sigBytes * 8;
 11257      
 11258                      // Add padding
 11259                      dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11260                      dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11261                      dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11262                      data.sigBytes = dataWords.length * 4;
 11263      
 11264                      // Hash final blocks
 11265                      this._process();
 11266      
 11267                      // Return final computed hash
 11268                      return this._hash;
 11269                  },
 11270      
 11271                  clone: function () {
 11272                      var clone = Hasher.clone.call(this);
 11273                      clone._hash = this._hash.clone();
 11274      
 11275                      return clone;
 11276                  }
 11277              });
 11278      
 11279              /**
 11280               * Shortcut function to the hasher's object interface.
 11281               *
 11282               * @param {WordArray|string} message The message to hash.
 11283               *
 11284               * @return {WordArray} The hash.
 11285               *
 11286               * @static
 11287               *
 11288               * @example
 11289               *
 11290               *     var hash = CryptoJS.SHA1('message');
 11291               *     var hash = CryptoJS.SHA1(wordArray);
 11292               */
 11293              C.SHA1 = Hasher._createHelper(SHA1);
 11294      
 11295              /**
 11296               * Shortcut function to the HMAC's object interface.
 11297               *
 11298               * @param {WordArray|string} message The message to hash.
 11299               * @param {WordArray|string} key The secret key.
 11300               *
 11301               * @return {WordArray} The HMAC.
 11302               *
 11303               * @static
 11304               *
 11305               * @example
 11306               *
 11307               *     var hmac = CryptoJS.HmacSHA1(message, key);
 11308               */
 11309              C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
 11310          }());
 11311      
 11312      
 11313          return CryptoJS.SHA1;
 11314      
 11315      }));
 11316      },{"./core":53}],78:[function(require,module,exports){
 11317      ;(function (root, factory, undef) {
 11318          if (typeof exports === "object") {
 11319              // CommonJS
 11320              module.exports = exports = factory(require("./core"), require("./sha256"));
 11321          }
 11322          else if (typeof define === "function" && define.amd) {
 11323              // AMD
 11324              define(["./core", "./sha256"], factory);
 11325          }
 11326          else {
 11327              // Global (browser)
 11328              factory(root.CryptoJS);
 11329          }
 11330      }(this, function (CryptoJS) {
 11331      
 11332          (function () {
 11333              // Shortcuts
 11334              var C = CryptoJS;
 11335              var C_lib = C.lib;
 11336              var WordArray = C_lib.WordArray;
 11337              var C_algo = C.algo;
 11338              var SHA256 = C_algo.SHA256;
 11339      
 11340              /**
 11341               * SHA-224 hash algorithm.
 11342               */
 11343              var SHA224 = C_algo.SHA224 = SHA256.extend({
 11344                  _doReset: function () {
 11345                      this._hash = new WordArray.init([
 11346                          0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
 11347                          0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
 11348                      ]);
 11349                  },
 11350      
 11351                  _doFinalize: function () {
 11352                      var hash = SHA256._doFinalize.call(this);
 11353      
 11354                      hash.sigBytes -= 4;
 11355      
 11356                      return hash;
 11357                  }
 11358              });
 11359      
 11360              /**
 11361               * Shortcut function to the hasher's object interface.
 11362               *
 11363               * @param {WordArray|string} message The message to hash.
 11364               *
 11365               * @return {WordArray} The hash.
 11366               *
 11367               * @static
 11368               *
 11369               * @example
 11370               *
 11371               *     var hash = CryptoJS.SHA224('message');
 11372               *     var hash = CryptoJS.SHA224(wordArray);
 11373               */
 11374              C.SHA224 = SHA256._createHelper(SHA224);
 11375      
 11376              /**
 11377               * Shortcut function to the HMAC's object interface.
 11378               *
 11379               * @param {WordArray|string} message The message to hash.
 11380               * @param {WordArray|string} key The secret key.
 11381               *
 11382               * @return {WordArray} The HMAC.
 11383               *
 11384               * @static
 11385               *
 11386               * @example
 11387               *
 11388               *     var hmac = CryptoJS.HmacSHA224(message, key);
 11389               */
 11390              C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
 11391          }());
 11392      
 11393      
 11394          return CryptoJS.SHA224;
 11395      
 11396      }));
 11397      },{"./core":53,"./sha256":79}],79:[function(require,module,exports){
 11398      ;(function (root, factory) {
 11399          if (typeof exports === "object") {
 11400              // CommonJS
 11401              module.exports = exports = factory(require("./core"));
 11402          }
 11403          else if (typeof define === "function" && define.amd) {
 11404              // AMD
 11405              define(["./core"], factory);
 11406          }
 11407          else {
 11408              // Global (browser)
 11409              factory(root.CryptoJS);
 11410          }
 11411      }(this, function (CryptoJS) {
 11412      
 11413          (function (Math) {
 11414              // Shortcuts
 11415              var C = CryptoJS;
 11416              var C_lib = C.lib;
 11417              var WordArray = C_lib.WordArray;
 11418              var Hasher = C_lib.Hasher;
 11419              var C_algo = C.algo;
 11420      
 11421              // Initialization and round constants tables
 11422              var H = [];
 11423              var K = [];
 11424      
 11425              // Compute constants
 11426              (function () {
 11427                  function isPrime(n) {
 11428                      var sqrtN = Math.sqrt(n);
 11429                      for (var factor = 2; factor <= sqrtN; factor++) {
 11430                          if (!(n % factor)) {
 11431                              return false;
 11432                          }
 11433                      }
 11434      
 11435                      return true;
 11436                  }
 11437      
 11438                  function getFractionalBits(n) {
 11439                      return ((n - (n | 0)) * 0x100000000) | 0;
 11440                  }
 11441      
 11442                  var n = 2;
 11443                  var nPrime = 0;
 11444                  while (nPrime < 64) {
 11445                      if (isPrime(n)) {
 11446                          if (nPrime < 8) {
 11447                              H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
 11448                          }
 11449                          K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
 11450      
 11451                          nPrime++;
 11452                      }
 11453      
 11454                      n++;
 11455                  }
 11456              }());
 11457      
 11458              // Reusable object
 11459              var W = [];
 11460      
 11461              /**
 11462               * SHA-256 hash algorithm.
 11463               */
 11464              var SHA256 = C_algo.SHA256 = Hasher.extend({
 11465                  _doReset: function () {
 11466                      this._hash = new WordArray.init(H.slice(0));
 11467                  },
 11468      
 11469                  _doProcessBlock: function (M, offset) {
 11470                      // Shortcut
 11471                      var H = this._hash.words;
 11472      
 11473                      // Working variables
 11474                      var a = H[0];
 11475                      var b = H[1];
 11476                      var c = H[2];
 11477                      var d = H[3];
 11478                      var e = H[4];
 11479                      var f = H[5];
 11480                      var g = H[6];
 11481                      var h = H[7];
 11482      
 11483                      // Computation
 11484                      for (var i = 0; i < 64; i++) {
 11485                          if (i < 16) {
 11486                              W[i] = M[offset + i] | 0;
 11487                          } else {
 11488                              var gamma0x = W[i - 15];
 11489                              var gamma0  = ((gamma0x << 25) | (gamma0x >>> 7))  ^
 11490                                            ((gamma0x << 14) | (gamma0x >>> 18)) ^
 11491                                             (gamma0x >>> 3);
 11492      
 11493                              var gamma1x = W[i - 2];
 11494                              var gamma1  = ((gamma1x << 15) | (gamma1x >>> 17)) ^
 11495                                            ((gamma1x << 13) | (gamma1x >>> 19)) ^
 11496                                             (gamma1x >>> 10);
 11497      
 11498                              W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
 11499                          }
 11500      
 11501                          var ch  = (e & f) ^ (~e & g);
 11502                          var maj = (a & b) ^ (a & c) ^ (b & c);
 11503      
 11504                          var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
 11505                          var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7)  | (e >>> 25));
 11506      
 11507                          var t1 = h + sigma1 + ch + K[i] + W[i];
 11508                          var t2 = sigma0 + maj;
 11509      
 11510                          h = g;
 11511                          g = f;
 11512                          f = e;
 11513                          e = (d + t1) | 0;
 11514                          d = c;
 11515                          c = b;
 11516                          b = a;
 11517                          a = (t1 + t2) | 0;
 11518                      }
 11519      
 11520                      // Intermediate hash value
 11521                      H[0] = (H[0] + a) | 0;
 11522                      H[1] = (H[1] + b) | 0;
 11523                      H[2] = (H[2] + c) | 0;
 11524                      H[3] = (H[3] + d) | 0;
 11525                      H[4] = (H[4] + e) | 0;
 11526                      H[5] = (H[5] + f) | 0;
 11527                      H[6] = (H[6] + g) | 0;
 11528                      H[7] = (H[7] + h) | 0;
 11529                  },
 11530      
 11531                  _doFinalize: function () {
 11532                      // Shortcuts
 11533                      var data = this._data;
 11534                      var dataWords = data.words;
 11535      
 11536                      var nBitsTotal = this._nDataBytes * 8;
 11537                      var nBitsLeft = data.sigBytes * 8;
 11538      
 11539                      // Add padding
 11540                      dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11541                      dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11542                      dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11543                      data.sigBytes = dataWords.length * 4;
 11544      
 11545                      // Hash final blocks
 11546                      this._process();
 11547      
 11548                      // Return final computed hash
 11549                      return this._hash;
 11550                  },
 11551      
 11552                  clone: function () {
 11553                      var clone = Hasher.clone.call(this);
 11554                      clone._hash = this._hash.clone();
 11555      
 11556                      return clone;
 11557                  }
 11558              });
 11559      
 11560              /**
 11561               * Shortcut function to the hasher's object interface.
 11562               *
 11563               * @param {WordArray|string} message The message to hash.
 11564               *
 11565               * @return {WordArray} The hash.
 11566               *
 11567               * @static
 11568               *
 11569               * @example
 11570               *
 11571               *     var hash = CryptoJS.SHA256('message');
 11572               *     var hash = CryptoJS.SHA256(wordArray);
 11573               */
 11574              C.SHA256 = Hasher._createHelper(SHA256);
 11575      
 11576              /**
 11577               * Shortcut function to the HMAC's object interface.
 11578               *
 11579               * @param {WordArray|string} message The message to hash.
 11580               * @param {WordArray|string} key The secret key.
 11581               *
 11582               * @return {WordArray} The HMAC.
 11583               *
 11584               * @static
 11585               *
 11586               * @example
 11587               *
 11588               *     var hmac = CryptoJS.HmacSHA256(message, key);
 11589               */
 11590              C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
 11591          }(Math));
 11592      
 11593      
 11594          return CryptoJS.SHA256;
 11595      
 11596      }));
 11597      },{"./core":53}],80:[function(require,module,exports){
 11598      ;(function (root, factory, undef) {
 11599          if (typeof exports === "object") {
 11600              // CommonJS
 11601              module.exports = exports = factory(require("./core"), require("./x64-core"));
 11602          }
 11603          else if (typeof define === "function" && define.amd) {
 11604              // AMD
 11605              define(["./core", "./x64-core"], factory);
 11606          }
 11607          else {
 11608              // Global (browser)
 11609              factory(root.CryptoJS);
 11610          }
 11611      }(this, function (CryptoJS) {
 11612      
 11613          (function (Math) {
 11614              // Shortcuts
 11615              var C = CryptoJS;
 11616              var C_lib = C.lib;
 11617              var WordArray = C_lib.WordArray;
 11618              var Hasher = C_lib.Hasher;
 11619              var C_x64 = C.x64;
 11620              var X64Word = C_x64.Word;
 11621              var C_algo = C.algo;
 11622      
 11623              // Constants tables
 11624              var RHO_OFFSETS = [];
 11625              var PI_INDEXES  = [];
 11626              var ROUND_CONSTANTS = [];
 11627      
 11628              // Compute Constants
 11629              (function () {
 11630                  // Compute rho offset constants
 11631                  var x = 1, y = 0;
 11632                  for (var t = 0; t < 24; t++) {
 11633                      RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
 11634      
 11635                      var newX = y % 5;
 11636                      var newY = (2 * x + 3 * y) % 5;
 11637                      x = newX;
 11638                      y = newY;
 11639                  }
 11640      
 11641                  // Compute pi index constants
 11642                  for (var x = 0; x < 5; x++) {
 11643                      for (var y = 0; y < 5; y++) {
 11644                          PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
 11645                      }
 11646                  }
 11647      
 11648                  // Compute round constants
 11649                  var LFSR = 0x01;
 11650                  for (var i = 0; i < 24; i++) {
 11651                      var roundConstantMsw = 0;
 11652                      var roundConstantLsw = 0;
 11653      
 11654                      for (var j = 0; j < 7; j++) {
 11655                          if (LFSR & 0x01) {
 11656                              var bitPosition = (1 << j) - 1;
 11657                              if (bitPosition < 32) {
 11658                                  roundConstantLsw ^= 1 << bitPosition;
 11659                              } else /* if (bitPosition >= 32) */ {
 11660                                  roundConstantMsw ^= 1 << (bitPosition - 32);
 11661                              }
 11662                          }
 11663      
 11664                          // Compute next LFSR
 11665                          if (LFSR & 0x80) {
 11666                              // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
 11667                              LFSR = (LFSR << 1) ^ 0x71;
 11668                          } else {
 11669                              LFSR <<= 1;
 11670                          }
 11671                      }
 11672      
 11673                      ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
 11674                  }
 11675              }());
 11676      
 11677              // Reusable objects for temporary values
 11678              var T = [];
 11679              (function () {
 11680                  for (var i = 0; i < 25; i++) {
 11681                      T[i] = X64Word.create();
 11682                  }
 11683              }());
 11684      
 11685              /**
 11686               * SHA-3 hash algorithm.
 11687               */
 11688              var SHA3 = C_algo.SHA3 = Hasher.extend({
 11689                  /**
 11690                   * Configuration options.
 11691                   *
 11692                   * @property {number} outputLength
 11693                   *   The desired number of bits in the output hash.
 11694                   *   Only values permitted are: 224, 256, 384, 512.
 11695                   *   Default: 512
 11696                   */
 11697                  cfg: Hasher.cfg.extend({
 11698                      outputLength: 512
 11699                  }),
 11700      
 11701                  _doReset: function () {
 11702                      var state = this._state = []
 11703                      for (var i = 0; i < 25; i++) {
 11704                          state[i] = new X64Word.init();
 11705                      }
 11706      
 11707                      this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
 11708                  },
 11709      
 11710                  _doProcessBlock: function (M, offset) {
 11711                      // Shortcuts
 11712                      var state = this._state;
 11713                      var nBlockSizeLanes = this.blockSize / 2;
 11714      
 11715                      // Absorb
 11716                      for (var i = 0; i < nBlockSizeLanes; i++) {
 11717                          // Shortcuts
 11718                          var M2i  = M[offset + 2 * i];
 11719                          var M2i1 = M[offset + 2 * i + 1];
 11720      
 11721                          // Swap endian
 11722                          M2i = (
 11723                              (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |
 11724                              (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)
 11725                          );
 11726                          M2i1 = (
 11727                              (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |
 11728                              (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)
 11729                          );
 11730      
 11731                          // Absorb message into state
 11732                          var lane = state[i];
 11733                          lane.high ^= M2i1;
 11734                          lane.low  ^= M2i;
 11735                      }
 11736      
 11737                      // Rounds
 11738                      for (var round = 0; round < 24; round++) {
 11739                          // Theta
 11740                          for (var x = 0; x < 5; x++) {
 11741                              // Mix column lanes
 11742                              var tMsw = 0, tLsw = 0;
 11743                              for (var y = 0; y < 5; y++) {
 11744                                  var lane = state[x + 5 * y];
 11745                                  tMsw ^= lane.high;
 11746                                  tLsw ^= lane.low;
 11747                              }
 11748      
 11749                              // Temporary values
 11750                              var Tx = T[x];
 11751                              Tx.high = tMsw;
 11752                              Tx.low  = tLsw;
 11753                          }
 11754                          for (var x = 0; x < 5; x++) {
 11755                              // Shortcuts
 11756                              var Tx4 = T[(x + 4) % 5];
 11757                              var Tx1 = T[(x + 1) % 5];
 11758                              var Tx1Msw = Tx1.high;
 11759                              var Tx1Lsw = Tx1.low;
 11760      
 11761                              // Mix surrounding columns
 11762                              var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
 11763                              var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
 11764                              for (var y = 0; y < 5; y++) {
 11765                                  var lane = state[x + 5 * y];
 11766                                  lane.high ^= tMsw;
 11767                                  lane.low  ^= tLsw;
 11768                              }
 11769                          }
 11770      
 11771                          // Rho Pi
 11772                          for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
 11773                              // Shortcuts
 11774                              var lane = state[laneIndex];
 11775                              var laneMsw = lane.high;
 11776                              var laneLsw = lane.low;
 11777                              var rhoOffset = RHO_OFFSETS[laneIndex];
 11778      
 11779                              // Rotate lanes
 11780                              if (rhoOffset < 32) {
 11781                                  var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
 11782                                  var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
 11783                              } else /* if (rhoOffset >= 32) */ {
 11784                                  var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
 11785                                  var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
 11786                              }
 11787      
 11788                              // Transpose lanes
 11789                              var TPiLane = T[PI_INDEXES[laneIndex]];
 11790                              TPiLane.high = tMsw;
 11791                              TPiLane.low  = tLsw;
 11792                          }
 11793      
 11794                          // Rho pi at x = y = 0
 11795                          var T0 = T[0];
 11796                          var state0 = state[0];
 11797                          T0.high = state0.high;
 11798                          T0.low  = state0.low;
 11799      
 11800                          // Chi
 11801                          for (var x = 0; x < 5; x++) {
 11802                              for (var y = 0; y < 5; y++) {
 11803                                  // Shortcuts
 11804                                  var laneIndex = x + 5 * y;
 11805                                  var lane = state[laneIndex];
 11806                                  var TLane = T[laneIndex];
 11807                                  var Tx1Lane = T[((x + 1) % 5) + 5 * y];
 11808                                  var Tx2Lane = T[((x + 2) % 5) + 5 * y];
 11809      
 11810                                  // Mix rows
 11811                                  lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
 11812                                  lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);
 11813                              }
 11814                          }
 11815      
 11816                          // Iota
 11817                          var lane = state[0];
 11818                          var roundConstant = ROUND_CONSTANTS[round];
 11819                          lane.high ^= roundConstant.high;
 11820                          lane.low  ^= roundConstant.low;;
 11821                      }
 11822                  },
 11823      
 11824                  _doFinalize: function () {
 11825                      // Shortcuts
 11826                      var data = this._data;
 11827                      var dataWords = data.words;
 11828                      var nBitsTotal = this._nDataBytes * 8;
 11829                      var nBitsLeft = data.sigBytes * 8;
 11830                      var blockSizeBits = this.blockSize * 32;
 11831      
 11832                      // Add padding
 11833                      dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
 11834                      dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
 11835                      data.sigBytes = dataWords.length * 4;
 11836      
 11837                      // Hash final blocks
 11838                      this._process();
 11839      
 11840                      // Shortcuts
 11841                      var state = this._state;
 11842                      var outputLengthBytes = this.cfg.outputLength / 8;
 11843                      var outputLengthLanes = outputLengthBytes / 8;
 11844      
 11845                      // Squeeze
 11846                      var hashWords = [];
 11847                      for (var i = 0; i < outputLengthLanes; i++) {
 11848                          // Shortcuts
 11849                          var lane = state[i];
 11850                          var laneMsw = lane.high;
 11851                          var laneLsw = lane.low;
 11852      
 11853                          // Swap endian
 11854                          laneMsw = (
 11855                              (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |
 11856                              (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)
 11857                          );
 11858                          laneLsw = (
 11859                              (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |
 11860                              (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)
 11861                          );
 11862      
 11863                          // Squeeze state to retrieve hash
 11864                          hashWords.push(laneLsw);
 11865                          hashWords.push(laneMsw);
 11866                      }
 11867      
 11868                      // Return final computed hash
 11869                      return new WordArray.init(hashWords, outputLengthBytes);
 11870                  },
 11871      
 11872                  clone: function () {
 11873                      var clone = Hasher.clone.call(this);
 11874      
 11875                      var state = clone._state = this._state.slice(0);
 11876                      for (var i = 0; i < 25; i++) {
 11877                          state[i] = state[i].clone();
 11878                      }
 11879      
 11880                      return clone;
 11881                  }
 11882              });
 11883      
 11884              /**
 11885               * Shortcut function to the hasher's object interface.
 11886               *
 11887               * @param {WordArray|string} message The message to hash.
 11888               *
 11889               * @return {WordArray} The hash.
 11890               *
 11891               * @static
 11892               *
 11893               * @example
 11894               *
 11895               *     var hash = CryptoJS.SHA3('message');
 11896               *     var hash = CryptoJS.SHA3(wordArray);
 11897               */
 11898              C.SHA3 = Hasher._createHelper(SHA3);
 11899      
 11900              /**
 11901               * Shortcut function to the HMAC's object interface.
 11902               *
 11903               * @param {WordArray|string} message The message to hash.
 11904               * @param {WordArray|string} key The secret key.
 11905               *
 11906               * @return {WordArray} The HMAC.
 11907               *
 11908               * @static
 11909               *
 11910               * @example
 11911               *
 11912               *     var hmac = CryptoJS.HmacSHA3(message, key);
 11913               */
 11914              C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
 11915          }(Math));
 11916      
 11917      
 11918          return CryptoJS.SHA3;
 11919      
 11920      }));
 11921      },{"./core":53,"./x64-core":84}],81:[function(require,module,exports){
 11922      ;(function (root, factory, undef) {
 11923          if (typeof exports === "object") {
 11924              // CommonJS
 11925              module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512"));
 11926          }
 11927          else if (typeof define === "function" && define.amd) {
 11928              // AMD
 11929              define(["./core", "./x64-core", "./sha512"], factory);
 11930          }
 11931          else {
 11932              // Global (browser)
 11933              factory(root.CryptoJS);
 11934          }
 11935      }(this, function (CryptoJS) {
 11936      
 11937          (function () {
 11938              // Shortcuts
 11939              var C = CryptoJS;
 11940              var C_x64 = C.x64;
 11941              var X64Word = C_x64.Word;
 11942              var X64WordArray = C_x64.WordArray;
 11943              var C_algo = C.algo;
 11944              var SHA512 = C_algo.SHA512;
 11945      
 11946              /**
 11947               * SHA-384 hash algorithm.
 11948               */
 11949              var SHA384 = C_algo.SHA384 = SHA512.extend({
 11950                  _doReset: function () {
 11951                      this._hash = new X64WordArray.init([
 11952                          new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
 11953                          new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
 11954                          new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
 11955                          new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
 11956                      ]);
 11957                  },
 11958      
 11959                  _doFinalize: function () {
 11960                      var hash = SHA512._doFinalize.call(this);
 11961      
 11962                      hash.sigBytes -= 16;
 11963      
 11964                      return hash;
 11965                  }
 11966              });
 11967      
 11968              /**
 11969               * Shortcut function to the hasher's object interface.
 11970               *
 11971               * @param {WordArray|string} message The message to hash.
 11972               *
 11973               * @return {WordArray} The hash.
 11974               *
 11975               * @static
 11976               *
 11977               * @example
 11978               *
 11979               *     var hash = CryptoJS.SHA384('message');
 11980               *     var hash = CryptoJS.SHA384(wordArray);
 11981               */
 11982              C.SHA384 = SHA512._createHelper(SHA384);
 11983      
 11984              /**
 11985               * Shortcut function to the HMAC's object interface.
 11986               *
 11987               * @param {WordArray|string} message The message to hash.
 11988               * @param {WordArray|string} key The secret key.
 11989               *
 11990               * @return {WordArray} The HMAC.
 11991               *
 11992               * @static
 11993               *
 11994               * @example
 11995               *
 11996               *     var hmac = CryptoJS.HmacSHA384(message, key);
 11997               */
 11998              C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
 11999          }());
 12000      
 12001      
 12002          return CryptoJS.SHA384;
 12003      
 12004      }));
 12005      },{"./core":53,"./sha512":82,"./x64-core":84}],82:[function(require,module,exports){
 12006      ;(function (root, factory, undef) {
 12007          if (typeof exports === "object") {
 12008              // CommonJS
 12009              module.exports = exports = factory(require("./core"), require("./x64-core"));
 12010          }
 12011          else if (typeof define === "function" && define.amd) {
 12012              // AMD
 12013              define(["./core", "./x64-core"], factory);
 12014          }
 12015          else {
 12016              // Global (browser)
 12017              factory(root.CryptoJS);
 12018          }
 12019      }(this, function (CryptoJS) {
 12020      
 12021          (function () {
 12022              // Shortcuts
 12023              var C = CryptoJS;
 12024              var C_lib = C.lib;
 12025              var Hasher = C_lib.Hasher;
 12026              var C_x64 = C.x64;
 12027              var X64Word = C_x64.Word;
 12028              var X64WordArray = C_x64.WordArray;
 12029              var C_algo = C.algo;
 12030      
 12031              function X64Word_create() {
 12032                  return X64Word.create.apply(X64Word, arguments);
 12033              }
 12034      
 12035              // Constants
 12036              var K = [
 12037                  X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
 12038                  X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
 12039                  X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
 12040                  X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
 12041                  X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
 12042                  X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
 12043                  X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
 12044                  X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
 12045                  X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
 12046                  X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
 12047                  X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
 12048                  X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
 12049                  X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
 12050                  X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
 12051                  X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
 12052                  X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
 12053                  X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
 12054                  X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
 12055                  X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
 12056                  X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
 12057                  X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
 12058                  X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
 12059                  X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
 12060                  X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
 12061                  X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
 12062                  X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
 12063                  X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
 12064                  X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
 12065                  X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
 12066                  X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
 12067                  X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
 12068                  X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
 12069                  X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
 12070                  X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
 12071                  X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
 12072                  X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
 12073                  X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
 12074                  X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
 12075                  X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
 12076                  X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
 12077              ];
 12078      
 12079              // Reusable objects
 12080              var W = [];
 12081              (function () {
 12082                  for (var i = 0; i < 80; i++) {
 12083                      W[i] = X64Word_create();
 12084                  }
 12085              }());
 12086      
 12087              /**
 12088               * SHA-512 hash algorithm.
 12089               */
 12090              var SHA512 = C_algo.SHA512 = Hasher.extend({
 12091                  _doReset: function () {
 12092                      this._hash = new X64WordArray.init([
 12093                          new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
 12094                          new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
 12095                          new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
 12096                          new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
 12097                      ]);
 12098                  },
 12099      
 12100                  _doProcessBlock: function (M, offset) {
 12101                      // Shortcuts
 12102                      var H = this._hash.words;
 12103      
 12104                      var H0 = H[0];
 12105                      var H1 = H[1];
 12106                      var H2 = H[2];
 12107                      var H3 = H[3];
 12108                      var H4 = H[4];
 12109                      var H5 = H[5];
 12110                      var H6 = H[6];
 12111                      var H7 = H[7];
 12112      
 12113                      var H0h = H0.high;
 12114                      var H0l = H0.low;
 12115                      var H1h = H1.high;
 12116                      var H1l = H1.low;
 12117                      var H2h = H2.high;
 12118                      var H2l = H2.low;
 12119                      var H3h = H3.high;
 12120                      var H3l = H3.low;
 12121                      var H4h = H4.high;
 12122                      var H4l = H4.low;
 12123                      var H5h = H5.high;
 12124                      var H5l = H5.low;
 12125                      var H6h = H6.high;
 12126                      var H6l = H6.low;
 12127                      var H7h = H7.high;
 12128                      var H7l = H7.low;
 12129      
 12130                      // Working variables
 12131                      var ah = H0h;
 12132                      var al = H0l;
 12133                      var bh = H1h;
 12134                      var bl = H1l;
 12135                      var ch = H2h;
 12136                      var cl = H2l;
 12137                      var dh = H3h;
 12138                      var dl = H3l;
 12139                      var eh = H4h;
 12140                      var el = H4l;
 12141                      var fh = H5h;
 12142                      var fl = H5l;
 12143                      var gh = H6h;
 12144                      var gl = H6l;
 12145                      var hh = H7h;
 12146                      var hl = H7l;
 12147      
 12148                      // Rounds
 12149                      for (var i = 0; i < 80; i++) {
 12150                          // Shortcut
 12151                          var Wi = W[i];
 12152      
 12153                          // Extend message
 12154                          if (i < 16) {
 12155                              var Wih = Wi.high = M[offset + i * 2]     | 0;
 12156                              var Wil = Wi.low  = M[offset + i * 2 + 1] | 0;
 12157                          } else {
 12158                              // Gamma0
 12159                              var gamma0x  = W[i - 15];
 12160                              var gamma0xh = gamma0x.high;
 12161                              var gamma0xl = gamma0x.low;
 12162                              var gamma0h  = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
 12163                              var gamma0l  = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
 12164      
 12165                              // Gamma1
 12166                              var gamma1x  = W[i - 2];
 12167                              var gamma1xh = gamma1x.high;
 12168                              var gamma1xl = gamma1x.low;
 12169                              var gamma1h  = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
 12170                              var gamma1l  = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
 12171      
 12172                              // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
 12173                              var Wi7  = W[i - 7];
 12174                              var Wi7h = Wi7.high;
 12175                              var Wi7l = Wi7.low;
 12176      
 12177                              var Wi16  = W[i - 16];
 12178                              var Wi16h = Wi16.high;
 12179                              var Wi16l = Wi16.low;
 12180      
 12181                              var Wil = gamma0l + Wi7l;
 12182                              var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
 12183                              var Wil = Wil + gamma1l;
 12184                              var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
 12185                              var Wil = Wil + Wi16l;
 12186                              var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
 12187      
 12188                              Wi.high = Wih;
 12189                              Wi.low  = Wil;
 12190                          }
 12191      
 12192                          var chh  = (eh & fh) ^ (~eh & gh);
 12193                          var chl  = (el & fl) ^ (~el & gl);
 12194                          var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
 12195                          var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
 12196      
 12197                          var sigma0h = ((ah >>> 28) | (al << 4))  ^ ((ah << 30)  | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
 12198                          var sigma0l = ((al >>> 28) | (ah << 4))  ^ ((al << 30)  | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
 12199                          var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
 12200                          var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
 12201      
 12202                          // t1 = h + sigma1 + ch + K[i] + W[i]
 12203                          var Ki  = K[i];
 12204                          var Kih = Ki.high;
 12205                          var Kil = Ki.low;
 12206      
 12207                          var t1l = hl + sigma1l;
 12208                          var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
 12209                          var t1l = t1l + chl;
 12210                          var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
 12211                          var t1l = t1l + Kil;
 12212                          var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
 12213                          var t1l = t1l + Wil;
 12214                          var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
 12215      
 12216                          // t2 = sigma0 + maj
 12217                          var t2l = sigma0l + majl;
 12218                          var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
 12219      
 12220                          // Update working variables
 12221                          hh = gh;
 12222                          hl = gl;
 12223                          gh = fh;
 12224                          gl = fl;
 12225                          fh = eh;
 12226                          fl = el;
 12227                          el = (dl + t1l) | 0;
 12228                          eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
 12229                          dh = ch;
 12230                          dl = cl;
 12231                          ch = bh;
 12232                          cl = bl;
 12233                          bh = ah;
 12234                          bl = al;
 12235                          al = (t1l + t2l) | 0;
 12236                          ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
 12237                      }
 12238      
 12239                      // Intermediate hash value
 12240                      H0l = H0.low  = (H0l + al);
 12241                      H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
 12242                      H1l = H1.low  = (H1l + bl);
 12243                      H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
 12244                      H2l = H2.low  = (H2l + cl);
 12245                      H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
 12246                      H3l = H3.low  = (H3l + dl);
 12247                      H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
 12248                      H4l = H4.low  = (H4l + el);
 12249                      H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
 12250                      H5l = H5.low  = (H5l + fl);
 12251                      H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
 12252                      H6l = H6.low  = (H6l + gl);
 12253                      H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
 12254                      H7l = H7.low  = (H7l + hl);
 12255                      H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
 12256                  },
 12257      
 12258                  _doFinalize: function () {
 12259                      // Shortcuts
 12260                      var data = this._data;
 12261                      var dataWords = data.words;
 12262      
 12263                      var nBitsTotal = this._nDataBytes * 8;
 12264                      var nBitsLeft = data.sigBytes * 8;
 12265      
 12266                      // Add padding
 12267                      dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 12268                      dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
 12269                      dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
 12270                      data.sigBytes = dataWords.length * 4;
 12271      
 12272                      // Hash final blocks
 12273                      this._process();
 12274      
 12275                      // Convert hash to 32-bit word array before returning
 12276                      var hash = this._hash.toX32();
 12277      
 12278                      // Return final computed hash
 12279                      return hash;
 12280                  },
 12281      
 12282                  clone: function () {
 12283                      var clone = Hasher.clone.call(this);
 12284                      clone._hash = this._hash.clone();
 12285      
 12286                      return clone;
 12287                  },
 12288      
 12289                  blockSize: 1024/32
 12290              });
 12291      
 12292              /**
 12293               * Shortcut function to the hasher's object interface.
 12294               *
 12295               * @param {WordArray|string} message The message to hash.
 12296               *
 12297               * @return {WordArray} The hash.
 12298               *
 12299               * @static
 12300               *
 12301               * @example
 12302               *
 12303               *     var hash = CryptoJS.SHA512('message');
 12304               *     var hash = CryptoJS.SHA512(wordArray);
 12305               */
 12306              C.SHA512 = Hasher._createHelper(SHA512);
 12307      
 12308              /**
 12309               * Shortcut function to the HMAC's object interface.
 12310               *
 12311               * @param {WordArray|string} message The message to hash.
 12312               * @param {WordArray|string} key The secret key.
 12313               *
 12314               * @return {WordArray} The HMAC.
 12315               *
 12316               * @static
 12317               *
 12318               * @example
 12319               *
 12320               *     var hmac = CryptoJS.HmacSHA512(message, key);
 12321               */
 12322              C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
 12323          }());
 12324      
 12325      
 12326          return CryptoJS.SHA512;
 12327      
 12328      }));
 12329      },{"./core":53,"./x64-core":84}],83:[function(require,module,exports){
 12330      ;(function (root, factory, undef) {
 12331          if (typeof exports === "object") {
 12332              // CommonJS
 12333              module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 12334          }
 12335          else if (typeof define === "function" && define.amd) {
 12336              // AMD
 12337              define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 12338          }
 12339          else {
 12340              // Global (browser)
 12341              factory(root.CryptoJS);
 12342          }
 12343      }(this, function (CryptoJS) {
 12344      
 12345          (function () {
 12346              // Shortcuts
 12347              var C = CryptoJS;
 12348              var C_lib = C.lib;
 12349              var WordArray = C_lib.WordArray;
 12350              var BlockCipher = C_lib.BlockCipher;
 12351              var C_algo = C.algo;
 12352      
 12353              // Permuted Choice 1 constants
 12354              var PC1 = [
 12355                  57, 49, 41, 33, 25, 17, 9,  1,
 12356                  58, 50, 42, 34, 26, 18, 10, 2,
 12357                  59, 51, 43, 35, 27, 19, 11, 3,
 12358                  60, 52, 44, 36, 63, 55, 47, 39,
 12359                  31, 23, 15, 7,  62, 54, 46, 38,
 12360                  30, 22, 14, 6,  61, 53, 45, 37,
 12361                  29, 21, 13, 5,  28, 20, 12, 4
 12362              ];
 12363      
 12364              // Permuted Choice 2 constants
 12365              var PC2 = [
 12366                  14, 17, 11, 24, 1,  5,
 12367                  3,  28, 15, 6,  21, 10,
 12368                  23, 19, 12, 4,  26, 8,
 12369                  16, 7,  27, 20, 13, 2,
 12370                  41, 52, 31, 37, 47, 55,
 12371                  30, 40, 51, 45, 33, 48,
 12372                  44, 49, 39, 56, 34, 53,
 12373                  46, 42, 50, 36, 29, 32
 12374              ];
 12375      
 12376              // Cumulative bit shift constants
 12377              var BIT_SHIFTS = [1,  2,  4,  6,  8,  10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
 12378      
 12379              // SBOXes and round permutation constants
 12380              var SBOX_P = [
 12381                  {
 12382                      0x0: 0x808200,
 12383                      0x10000000: 0x8000,
 12384                      0x20000000: 0x808002,
 12385                      0x30000000: 0x2,
 12386                      0x40000000: 0x200,
 12387                      0x50000000: 0x808202,
 12388                      0x60000000: 0x800202,
 12389                      0x70000000: 0x800000,
 12390                      0x80000000: 0x202,
 12391                      0x90000000: 0x800200,
 12392                      0xa0000000: 0x8200,
 12393                      0xb0000000: 0x808000,
 12394                      0xc0000000: 0x8002,
 12395                      0xd0000000: 0x800002,
 12396                      0xe0000000: 0x0,
 12397                      0xf0000000: 0x8202,
 12398                      0x8000000: 0x0,
 12399                      0x18000000: 0x808202,
 12400                      0x28000000: 0x8202,
 12401                      0x38000000: 0x8000,
 12402                      0x48000000: 0x808200,
 12403                      0x58000000: 0x200,
 12404                      0x68000000: 0x808002,
 12405                      0x78000000: 0x2,
 12406                      0x88000000: 0x800200,
 12407                      0x98000000: 0x8200,
 12408                      0xa8000000: 0x808000,
 12409                      0xb8000000: 0x800202,
 12410                      0xc8000000: 0x800002,
 12411                      0xd8000000: 0x8002,
 12412                      0xe8000000: 0x202,
 12413                      0xf8000000: 0x800000,
 12414                      0x1: 0x8000,
 12415                      0x10000001: 0x2,
 12416                      0x20000001: 0x808200,
 12417                      0x30000001: 0x800000,
 12418                      0x40000001: 0x808002,
 12419                      0x50000001: 0x8200,
 12420                      0x60000001: 0x200,
 12421                      0x70000001: 0x800202,
 12422                      0x80000001: 0x808202,
 12423                      0x90000001: 0x808000,
 12424                      0xa0000001: 0x800002,
 12425                      0xb0000001: 0x8202,
 12426                      0xc0000001: 0x202,
 12427                      0xd0000001: 0x800200,
 12428                      0xe0000001: 0x8002,
 12429                      0xf0000001: 0x0,
 12430                      0x8000001: 0x808202,
 12431                      0x18000001: 0x808000,
 12432                      0x28000001: 0x800000,
 12433                      0x38000001: 0x200,
 12434                      0x48000001: 0x8000,
 12435                      0x58000001: 0x800002,
 12436                      0x68000001: 0x2,
 12437                      0x78000001: 0x8202,
 12438                      0x88000001: 0x8002,
 12439                      0x98000001: 0x800202,
 12440                      0xa8000001: 0x202,
 12441                      0xb8000001: 0x808200,
 12442                      0xc8000001: 0x800200,
 12443                      0xd8000001: 0x0,
 12444                      0xe8000001: 0x8200,
 12445                      0xf8000001: 0x808002
 12446                  },
 12447                  {
 12448                      0x0: 0x40084010,
 12449                      0x1000000: 0x4000,
 12450                      0x2000000: 0x80000,
 12451                      0x3000000: 0x40080010,
 12452                      0x4000000: 0x40000010,
 12453                      0x5000000: 0x40084000,
 12454                      0x6000000: 0x40004000,
 12455                      0x7000000: 0x10,
 12456                      0x8000000: 0x84000,
 12457                      0x9000000: 0x40004010,
 12458                      0xa000000: 0x40000000,
 12459                      0xb000000: 0x84010,
 12460                      0xc000000: 0x80010,
 12461                      0xd000000: 0x0,
 12462                      0xe000000: 0x4010,
 12463                      0xf000000: 0x40080000,
 12464                      0x800000: 0x40004000,
 12465                      0x1800000: 0x84010,
 12466                      0x2800000: 0x10,
 12467                      0x3800000: 0x40004010,
 12468                      0x4800000: 0x40084010,
 12469                      0x5800000: 0x40000000,
 12470                      0x6800000: 0x80000,
 12471                      0x7800000: 0x40080010,
 12472                      0x8800000: 0x80010,
 12473                      0x9800000: 0x0,
 12474                      0xa800000: 0x4000,
 12475                      0xb800000: 0x40080000,
 12476                      0xc800000: 0x40000010,
 12477                      0xd800000: 0x84000,
 12478                      0xe800000: 0x40084000,
 12479                      0xf800000: 0x4010,
 12480                      0x10000000: 0x0,
 12481                      0x11000000: 0x40080010,
 12482                      0x12000000: 0x40004010,
 12483                      0x13000000: 0x40084000,
 12484                      0x14000000: 0x40080000,
 12485                      0x15000000: 0x10,
 12486                      0x16000000: 0x84010,
 12487                      0x17000000: 0x4000,
 12488                      0x18000000: 0x4010,
 12489                      0x19000000: 0x80000,
 12490                      0x1a000000: 0x80010,
 12491                      0x1b000000: 0x40000010,
 12492                      0x1c000000: 0x84000,
 12493                      0x1d000000: 0x40004000,
 12494                      0x1e000000: 0x40000000,
 12495                      0x1f000000: 0x40084010,
 12496                      0x10800000: 0x84010,
 12497                      0x11800000: 0x80000,
 12498                      0x12800000: 0x40080000,
 12499                      0x13800000: 0x4000,
 12500                      0x14800000: 0x40004000,
 12501                      0x15800000: 0x40084010,
 12502                      0x16800000: 0x10,
 12503                      0x17800000: 0x40000000,
 12504                      0x18800000: 0x40084000,
 12505                      0x19800000: 0x40000010,
 12506                      0x1a800000: 0x40004010,
 12507                      0x1b800000: 0x80010,
 12508                      0x1c800000: 0x0,
 12509                      0x1d800000: 0x4010,
 12510                      0x1e800000: 0x40080010,
 12511                      0x1f800000: 0x84000
 12512                  },
 12513                  {
 12514                      0x0: 0x104,
 12515                      0x100000: 0x0,
 12516                      0x200000: 0x4000100,
 12517                      0x300000: 0x10104,
 12518                      0x400000: 0x10004,
 12519                      0x500000: 0x4000004,
 12520                      0x600000: 0x4010104,
 12521                      0x700000: 0x4010000,
 12522                      0x800000: 0x4000000,
 12523                      0x900000: 0x4010100,
 12524                      0xa00000: 0x10100,
 12525                      0xb00000: 0x4010004,
 12526                      0xc00000: 0x4000104,
 12527                      0xd00000: 0x10000,
 12528                      0xe00000: 0x4,
 12529                      0xf00000: 0x100,
 12530                      0x80000: 0x4010100,
 12531                      0x180000: 0x4010004,
 12532                      0x280000: 0x0,
 12533                      0x380000: 0x4000100,
 12534                      0x480000: 0x4000004,
 12535                      0x580000: 0x10000,
 12536                      0x680000: 0x10004,
 12537                      0x780000: 0x104,
 12538                      0x880000: 0x4,
 12539                      0x980000: 0x100,
 12540                      0xa80000: 0x4010000,
 12541                      0xb80000: 0x10104,
 12542                      0xc80000: 0x10100,
 12543                      0xd80000: 0x4000104,
 12544                      0xe80000: 0x4010104,
 12545                      0xf80000: 0x4000000,
 12546                      0x1000000: 0x4010100,
 12547                      0x1100000: 0x10004,
 12548                      0x1200000: 0x10000,
 12549                      0x1300000: 0x4000100,
 12550                      0x1400000: 0x100,
 12551                      0x1500000: 0x4010104,
 12552                      0x1600000: 0x4000004,
 12553                      0x1700000: 0x0,
 12554                      0x1800000: 0x4000104,
 12555                      0x1900000: 0x4000000,
 12556                      0x1a00000: 0x4,
 12557                      0x1b00000: 0x10100,
 12558                      0x1c00000: 0x4010000,
 12559                      0x1d00000: 0x104,
 12560                      0x1e00000: 0x10104,
 12561                      0x1f00000: 0x4010004,
 12562                      0x1080000: 0x4000000,
 12563                      0x1180000: 0x104,
 12564                      0x1280000: 0x4010100,
 12565                      0x1380000: 0x0,
 12566                      0x1480000: 0x10004,
 12567                      0x1580000: 0x4000100,
 12568                      0x1680000: 0x100,
 12569                      0x1780000: 0x4010004,
 12570                      0x1880000: 0x10000,
 12571                      0x1980000: 0x4010104,
 12572                      0x1a80000: 0x10104,
 12573                      0x1b80000: 0x4000004,
 12574                      0x1c80000: 0x4000104,
 12575                      0x1d80000: 0x4010000,
 12576                      0x1e80000: 0x4,
 12577                      0x1f80000: 0x10100
 12578                  },
 12579                  {
 12580                      0x0: 0x80401000,
 12581                      0x10000: 0x80001040,
 12582                      0x20000: 0x401040,
 12583                      0x30000: 0x80400000,
 12584                      0x40000: 0x0,
 12585                      0x50000: 0x401000,
 12586                      0x60000: 0x80000040,
 12587                      0x70000: 0x400040,
 12588                      0x80000: 0x80000000,
 12589                      0x90000: 0x400000,
 12590                      0xa0000: 0x40,
 12591                      0xb0000: 0x80001000,
 12592                      0xc0000: 0x80400040,
 12593                      0xd0000: 0x1040,
 12594                      0xe0000: 0x1000,
 12595                      0xf0000: 0x80401040,
 12596                      0x8000: 0x80001040,
 12597                      0x18000: 0x40,
 12598                      0x28000: 0x80400040,
 12599                      0x38000: 0x80001000,
 12600                      0x48000: 0x401000,
 12601                      0x58000: 0x80401040,
 12602                      0x68000: 0x0,
 12603                      0x78000: 0x80400000,
 12604                      0x88000: 0x1000,
 12605                      0x98000: 0x80401000,
 12606                      0xa8000: 0x400000,
 12607                      0xb8000: 0x1040,
 12608                      0xc8000: 0x80000000,
 12609                      0xd8000: 0x400040,
 12610                      0xe8000: 0x401040,
 12611                      0xf8000: 0x80000040,
 12612                      0x100000: 0x400040,
 12613                      0x110000: 0x401000,
 12614                      0x120000: 0x80000040,
 12615                      0x130000: 0x0,
 12616                      0x140000: 0x1040,
 12617                      0x150000: 0x80400040,
 12618                      0x160000: 0x80401000,
 12619                      0x170000: 0x80001040,
 12620                      0x180000: 0x80401040,
 12621                      0x190000: 0x80000000,
 12622                      0x1a0000: 0x80400000,
 12623                      0x1b0000: 0x401040,
 12624                      0x1c0000: 0x80001000,
 12625                      0x1d0000: 0x400000,
 12626                      0x1e0000: 0x40,
 12627                      0x1f0000: 0x1000,
 12628                      0x108000: 0x80400000,
 12629                      0x118000: 0x80401040,
 12630                      0x128000: 0x0,
 12631                      0x138000: 0x401000,
 12632                      0x148000: 0x400040,
 12633                      0x158000: 0x80000000,
 12634                      0x168000: 0x80001040,
 12635                      0x178000: 0x40,
 12636                      0x188000: 0x80000040,
 12637                      0x198000: 0x1000,
 12638                      0x1a8000: 0x80001000,
 12639                      0x1b8000: 0x80400040,
 12640                      0x1c8000: 0x1040,
 12641                      0x1d8000: 0x80401000,
 12642                      0x1e8000: 0x400000,
 12643                      0x1f8000: 0x401040
 12644                  },
 12645                  {
 12646                      0x0: 0x80,
 12647                      0x1000: 0x1040000,
 12648                      0x2000: 0x40000,
 12649                      0x3000: 0x20000000,
 12650                      0x4000: 0x20040080,
 12651                      0x5000: 0x1000080,
 12652                      0x6000: 0x21000080,
 12653                      0x7000: 0x40080,
 12654                      0x8000: 0x1000000,
 12655                      0x9000: 0x20040000,
 12656                      0xa000: 0x20000080,
 12657                      0xb000: 0x21040080,
 12658                      0xc000: 0x21040000,
 12659                      0xd000: 0x0,
 12660                      0xe000: 0x1040080,
 12661                      0xf000: 0x21000000,
 12662                      0x800: 0x1040080,
 12663                      0x1800: 0x21000080,
 12664                      0x2800: 0x80,
 12665                      0x3800: 0x1040000,
 12666                      0x4800: 0x40000,
 12667                      0x5800: 0x20040080,
 12668                      0x6800: 0x21040000,
 12669                      0x7800: 0x20000000,
 12670                      0x8800: 0x20040000,
 12671                      0x9800: 0x0,
 12672                      0xa800: 0x21040080,
 12673                      0xb800: 0x1000080,
 12674                      0xc800: 0x20000080,
 12675                      0xd800: 0x21000000,
 12676                      0xe800: 0x1000000,
 12677                      0xf800: 0x40080,
 12678                      0x10000: 0x40000,
 12679                      0x11000: 0x80,
 12680                      0x12000: 0x20000000,
 12681                      0x13000: 0x21000080,
 12682                      0x14000: 0x1000080,
 12683                      0x15000: 0x21040000,
 12684                      0x16000: 0x20040080,
 12685                      0x17000: 0x1000000,
 12686                      0x18000: 0x21040080,
 12687                      0x19000: 0x21000000,
 12688                      0x1a000: 0x1040000,
 12689                      0x1b000: 0x20040000,
 12690                      0x1c000: 0x40080,
 12691                      0x1d000: 0x20000080,
 12692                      0x1e000: 0x0,
 12693                      0x1f000: 0x1040080,
 12694                      0x10800: 0x21000080,
 12695                      0x11800: 0x1000000,
 12696                      0x12800: 0x1040000,
 12697                      0x13800: 0x20040080,
 12698                      0x14800: 0x20000000,
 12699                      0x15800: 0x1040080,
 12700                      0x16800: 0x80,
 12701                      0x17800: 0x21040000,
 12702                      0x18800: 0x40080,
 12703                      0x19800: 0x21040080,
 12704                      0x1a800: 0x0,
 12705                      0x1b800: 0x21000000,
 12706                      0x1c800: 0x1000080,
 12707                      0x1d800: 0x40000,
 12708                      0x1e800: 0x20040000,
 12709                      0x1f800: 0x20000080
 12710                  },
 12711                  {
 12712                      0x0: 0x10000008,
 12713                      0x100: 0x2000,
 12714                      0x200: 0x10200000,
 12715                      0x300: 0x10202008,
 12716                      0x400: 0x10002000,
 12717                      0x500: 0x200000,
 12718                      0x600: 0x200008,
 12719                      0x700: 0x10000000,
 12720                      0x800: 0x0,
 12721                      0x900: 0x10002008,
 12722                      0xa00: 0x202000,
 12723                      0xb00: 0x8,
 12724                      0xc00: 0x10200008,
 12725                      0xd00: 0x202008,
 12726                      0xe00: 0x2008,
 12727                      0xf00: 0x10202000,
 12728                      0x80: 0x10200000,
 12729                      0x180: 0x10202008,
 12730                      0x280: 0x8,
 12731                      0x380: 0x200000,
 12732                      0x480: 0x202008,
 12733                      0x580: 0x10000008,
 12734                      0x680: 0x10002000,
 12735                      0x780: 0x2008,
 12736                      0x880: 0x200008,
 12737                      0x980: 0x2000,
 12738                      0xa80: 0x10002008,
 12739                      0xb80: 0x10200008,
 12740                      0xc80: 0x0,
 12741                      0xd80: 0x10202000,
 12742                      0xe80: 0x202000,
 12743                      0xf80: 0x10000000,
 12744                      0x1000: 0x10002000,
 12745                      0x1100: 0x10200008,
 12746                      0x1200: 0x10202008,
 12747                      0x1300: 0x2008,
 12748                      0x1400: 0x200000,
 12749                      0x1500: 0x10000000,
 12750                      0x1600: 0x10000008,
 12751                      0x1700: 0x202000,
 12752                      0x1800: 0x202008,
 12753                      0x1900: 0x0,
 12754                      0x1a00: 0x8,
 12755                      0x1b00: 0x10200000,
 12756                      0x1c00: 0x2000,
 12757                      0x1d00: 0x10002008,
 12758                      0x1e00: 0x10202000,
 12759                      0x1f00: 0x200008,
 12760                      0x1080: 0x8,
 12761                      0x1180: 0x202000,
 12762                      0x1280: 0x200000,
 12763                      0x1380: 0x10000008,
 12764                      0x1480: 0x10002000,
 12765                      0x1580: 0x2008,
 12766                      0x1680: 0x10202008,
 12767                      0x1780: 0x10200000,
 12768                      0x1880: 0x10202000,
 12769                      0x1980: 0x10200008,
 12770                      0x1a80: 0x2000,
 12771                      0x1b80: 0x202008,
 12772                      0x1c80: 0x200008,
 12773                      0x1d80: 0x0,
 12774                      0x1e80: 0x10000000,
 12775                      0x1f80: 0x10002008
 12776                  },
 12777                  {
 12778                      0x0: 0x100000,
 12779                      0x10: 0x2000401,
 12780                      0x20: 0x400,
 12781                      0x30: 0x100401,
 12782                      0x40: 0x2100401,
 12783                      0x50: 0x0,
 12784                      0x60: 0x1,
 12785                      0x70: 0x2100001,
 12786                      0x80: 0x2000400,
 12787                      0x90: 0x100001,
 12788                      0xa0: 0x2000001,
 12789                      0xb0: 0x2100400,
 12790                      0xc0: 0x2100000,
 12791                      0xd0: 0x401,
 12792                      0xe0: 0x100400,
 12793                      0xf0: 0x2000000,
 12794                      0x8: 0x2100001,
 12795                      0x18: 0x0,
 12796                      0x28: 0x2000401,
 12797                      0x38: 0x2100400,
 12798                      0x48: 0x100000,
 12799                      0x58: 0x2000001,
 12800                      0x68: 0x2000000,
 12801                      0x78: 0x401,
 12802                      0x88: 0x100401,
 12803                      0x98: 0x2000400,
 12804                      0xa8: 0x2100000,
 12805                      0xb8: 0x100001,
 12806                      0xc8: 0x400,
 12807                      0xd8: 0x2100401,
 12808                      0xe8: 0x1,
 12809                      0xf8: 0x100400,
 12810                      0x100: 0x2000000,
 12811                      0x110: 0x100000,
 12812                      0x120: 0x2000401,
 12813                      0x130: 0x2100001,
 12814                      0x140: 0x100001,
 12815                      0x150: 0x2000400,
 12816                      0x160: 0x2100400,
 12817                      0x170: 0x100401,
 12818                      0x180: 0x401,
 12819                      0x190: 0x2100401,
 12820                      0x1a0: 0x100400,
 12821                      0x1b0: 0x1,
 12822                      0x1c0: 0x0,
 12823                      0x1d0: 0x2100000,
 12824                      0x1e0: 0x2000001,
 12825                      0x1f0: 0x400,
 12826                      0x108: 0x100400,
 12827                      0x118: 0x2000401,
 12828                      0x128: 0x2100001,
 12829                      0x138: 0x1,
 12830                      0x148: 0x2000000,
 12831                      0x158: 0x100000,
 12832                      0x168: 0x401,
 12833                      0x178: 0x2100400,
 12834                      0x188: 0x2000001,
 12835                      0x198: 0x2100000,
 12836                      0x1a8: 0x0,
 12837                      0x1b8: 0x2100401,
 12838                      0x1c8: 0x100401,
 12839                      0x1d8: 0x400,
 12840                      0x1e8: 0x2000400,
 12841                      0x1f8: 0x100001
 12842                  },
 12843                  {
 12844                      0x0: 0x8000820,
 12845                      0x1: 0x20000,
 12846                      0x2: 0x8000000,
 12847                      0x3: 0x20,
 12848                      0x4: 0x20020,
 12849                      0x5: 0x8020820,
 12850                      0x6: 0x8020800,
 12851                      0x7: 0x800,
 12852                      0x8: 0x8020000,
 12853                      0x9: 0x8000800,
 12854                      0xa: 0x20800,
 12855                      0xb: 0x8020020,
 12856                      0xc: 0x820,
 12857                      0xd: 0x0,
 12858                      0xe: 0x8000020,
 12859                      0xf: 0x20820,
 12860                      0x80000000: 0x800,
 12861                      0x80000001: 0x8020820,
 12862                      0x80000002: 0x8000820,
 12863                      0x80000003: 0x8000000,
 12864                      0x80000004: 0x8020000,
 12865                      0x80000005: 0x20800,
 12866                      0x80000006: 0x20820,
 12867                      0x80000007: 0x20,
 12868                      0x80000008: 0x8000020,
 12869                      0x80000009: 0x820,
 12870                      0x8000000a: 0x20020,
 12871                      0x8000000b: 0x8020800,
 12872                      0x8000000c: 0x0,
 12873                      0x8000000d: 0x8020020,
 12874                      0x8000000e: 0x8000800,
 12875                      0x8000000f: 0x20000,
 12876                      0x10: 0x20820,
 12877                      0x11: 0x8020800,
 12878                      0x12: 0x20,
 12879                      0x13: 0x800,
 12880                      0x14: 0x8000800,
 12881                      0x15: 0x8000020,
 12882                      0x16: 0x8020020,
 12883                      0x17: 0x20000,
 12884                      0x18: 0x0,
 12885                      0x19: 0x20020,
 12886                      0x1a: 0x8020000,
 12887                      0x1b: 0x8000820,
 12888                      0x1c: 0x8020820,
 12889                      0x1d: 0x20800,
 12890                      0x1e: 0x820,
 12891                      0x1f: 0x8000000,
 12892                      0x80000010: 0x20000,
 12893                      0x80000011: 0x800,
 12894                      0x80000012: 0x8020020,
 12895                      0x80000013: 0x20820,
 12896                      0x80000014: 0x20,
 12897                      0x80000015: 0x8020000,
 12898                      0x80000016: 0x8000000,
 12899                      0x80000017: 0x8000820,
 12900                      0x80000018: 0x8020820,
 12901                      0x80000019: 0x8000020,
 12902                      0x8000001a: 0x8000800,
 12903                      0x8000001b: 0x0,
 12904                      0x8000001c: 0x20800,
 12905                      0x8000001d: 0x820,
 12906                      0x8000001e: 0x20020,
 12907                      0x8000001f: 0x8020800
 12908                  }
 12909              ];
 12910      
 12911              // Masks that select the SBOX input
 12912              var SBOX_MASK = [
 12913                  0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
 12914                  0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
 12915              ];
 12916      
 12917              /**
 12918               * DES block cipher algorithm.
 12919               */
 12920              var DES = C_algo.DES = BlockCipher.extend({
 12921                  _doReset: function () {
 12922                      // Shortcuts
 12923                      var key = this._key;
 12924                      var keyWords = key.words;
 12925      
 12926                      // Select 56 bits according to PC1
 12927                      var keyBits = [];
 12928                      for (var i = 0; i < 56; i++) {
 12929                          var keyBitPos = PC1[i] - 1;
 12930                          keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
 12931                      }
 12932      
 12933                      // Assemble 16 subkeys
 12934                      var subKeys = this._subKeys = [];
 12935                      for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
 12936                          // Create subkey
 12937                          var subKey = subKeys[nSubKey] = [];
 12938      
 12939                          // Shortcut
 12940                          var bitShift = BIT_SHIFTS[nSubKey];
 12941      
 12942                          // Select 48 bits according to PC2
 12943                          for (var i = 0; i < 24; i++) {
 12944                              // Select from the left 28 key bits
 12945                              subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
 12946      
 12947                              // Select from the right 28 key bits
 12948                              subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
 12949                          }
 12950      
 12951                          // Since each subkey is applied to an expanded 32-bit input,
 12952                          // the subkey can be broken into 8 values scaled to 32-bits,
 12953                          // which allows the key to be used without expansion
 12954                          subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
 12955                          for (var i = 1; i < 7; i++) {
 12956                              subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
 12957                          }
 12958                          subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
 12959                      }
 12960      
 12961                      // Compute inverse subkeys
 12962                      var invSubKeys = this._invSubKeys = [];
 12963                      for (var i = 0; i < 16; i++) {
 12964                          invSubKeys[i] = subKeys[15 - i];
 12965                      }
 12966                  },
 12967      
 12968                  encryptBlock: function (M, offset) {
 12969                      this._doCryptBlock(M, offset, this._subKeys);
 12970                  },
 12971      
 12972                  decryptBlock: function (M, offset) {
 12973                      this._doCryptBlock(M, offset, this._invSubKeys);
 12974                  },
 12975      
 12976                  _doCryptBlock: function (M, offset, subKeys) {
 12977                      // Get input
 12978                      this._lBlock = M[offset];
 12979                      this._rBlock = M[offset + 1];
 12980      
 12981                      // Initial permutation
 12982                      exchangeLR.call(this, 4,  0x0f0f0f0f);
 12983                      exchangeLR.call(this, 16, 0x0000ffff);
 12984                      exchangeRL.call(this, 2,  0x33333333);
 12985                      exchangeRL.call(this, 8,  0x00ff00ff);
 12986                      exchangeLR.call(this, 1,  0x55555555);
 12987      
 12988                      // Rounds
 12989                      for (var round = 0; round < 16; round++) {
 12990                          // Shortcuts
 12991                          var subKey = subKeys[round];
 12992                          var lBlock = this._lBlock;
 12993                          var rBlock = this._rBlock;
 12994      
 12995                          // Feistel function
 12996                          var f = 0;
 12997                          for (var i = 0; i < 8; i++) {
 12998                              f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
 12999                          }
 13000                          this._lBlock = rBlock;
 13001                          this._rBlock = lBlock ^ f;
 13002                      }
 13003      
 13004                      // Undo swap from last round
 13005                      var t = this._lBlock;
 13006                      this._lBlock = this._rBlock;
 13007                      this._rBlock = t;
 13008      
 13009                      // Final permutation
 13010                      exchangeLR.call(this, 1,  0x55555555);
 13011                      exchangeRL.call(this, 8,  0x00ff00ff);
 13012                      exchangeRL.call(this, 2,  0x33333333);
 13013                      exchangeLR.call(this, 16, 0x0000ffff);
 13014                      exchangeLR.call(this, 4,  0x0f0f0f0f);
 13015      
 13016                      // Set output
 13017                      M[offset] = this._lBlock;
 13018                      M[offset + 1] = this._rBlock;
 13019                  },
 13020      
 13021                  keySize: 64/32,
 13022      
 13023                  ivSize: 64/32,
 13024      
 13025                  blockSize: 64/32
 13026              });
 13027      
 13028              // Swap bits across the left and right words
 13029              function exchangeLR(offset, mask) {
 13030                  var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
 13031                  this._rBlock ^= t;
 13032                  this._lBlock ^= t << offset;
 13033              }
 13034      
 13035              function exchangeRL(offset, mask) {
 13036                  var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
 13037                  this._lBlock ^= t;
 13038                  this._rBlock ^= t << offset;
 13039              }
 13040      
 13041              /**
 13042               * Shortcut functions to the cipher's object interface.
 13043               *
 13044               * @example
 13045               *
 13046               *     var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
 13047               *     var plaintext  = CryptoJS.DES.decrypt(ciphertext, key, cfg);
 13048               */
 13049              C.DES = BlockCipher._createHelper(DES);
 13050      
 13051              /**
 13052               * Triple-DES block cipher algorithm.
 13053               */
 13054              var TripleDES = C_algo.TripleDES = BlockCipher.extend({
 13055                  _doReset: function () {
 13056                      // Shortcuts
 13057                      var key = this._key;
 13058                      var keyWords = key.words;
 13059      
 13060                      // Create DES instances
 13061                      this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
 13062                      this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
 13063                      this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
 13064                  },
 13065      
 13066                  encryptBlock: function (M, offset) {
 13067                      this._des1.encryptBlock(M, offset);
 13068                      this._des2.decryptBlock(M, offset);
 13069                      this._des3.encryptBlock(M, offset);
 13070                  },
 13071      
 13072                  decryptBlock: function (M, offset) {
 13073                      this._des3.decryptBlock(M, offset);
 13074                      this._des2.encryptBlock(M, offset);
 13075                      this._des1.decryptBlock(M, offset);
 13076                  },
 13077      
 13078                  keySize: 192/32,
 13079      
 13080                  ivSize: 64/32,
 13081      
 13082                  blockSize: 64/32
 13083              });
 13084      
 13085              /**
 13086               * Shortcut functions to the cipher's object interface.
 13087               *
 13088               * @example
 13089               *
 13090               *     var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
 13091               *     var plaintext  = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
 13092               */
 13093              C.TripleDES = BlockCipher._createHelper(TripleDES);
 13094          }());
 13095      
 13096      
 13097          return CryptoJS.TripleDES;
 13098      
 13099      }));
 13100      },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],84:[function(require,module,exports){
 13101      ;(function (root, factory) {
 13102          if (typeof exports === "object") {
 13103              // CommonJS
 13104              module.exports = exports = factory(require("./core"));
 13105          }
 13106          else if (typeof define === "function" && define.amd) {
 13107              // AMD
 13108              define(["./core"], factory);
 13109          }
 13110          else {
 13111              // Global (browser)
 13112              factory(root.CryptoJS);
 13113          }
 13114      }(this, function (CryptoJS) {
 13115      
 13116          (function (undefined) {
 13117              // Shortcuts
 13118              var C = CryptoJS;
 13119              var C_lib = C.lib;
 13120              var Base = C_lib.Base;
 13121              var X32WordArray = C_lib.WordArray;
 13122      
 13123              /**
 13124               * x64 namespace.
 13125               */
 13126              var C_x64 = C.x64 = {};
 13127      
 13128              /**
 13129               * A 64-bit word.
 13130               */
 13131              var X64Word = C_x64.Word = Base.extend({
 13132                  /**
 13133                   * Initializes a newly created 64-bit word.
 13134                   *
 13135                   * @param {number} high The high 32 bits.
 13136                   * @param {number} low The low 32 bits.
 13137                   *
 13138                   * @example
 13139                   *
 13140                   *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
 13141                   */
 13142                  init: function (high, low) {
 13143                      this.high = high;
 13144                      this.low = low;
 13145                  }
 13146      
 13147                  /**
 13148                   * Bitwise NOTs this word.
 13149                   *
 13150                   * @return {X64Word} A new x64-Word object after negating.
 13151                   *
 13152                   * @example
 13153                   *
 13154                   *     var negated = x64Word.not();
 13155                   */
 13156                  // not: function () {
 13157                      // var high = ~this.high;
 13158                      // var low = ~this.low;
 13159      
 13160                      // return X64Word.create(high, low);
 13161                  // },
 13162      
 13163                  /**
 13164                   * Bitwise ANDs this word with the passed word.
 13165                   *
 13166                   * @param {X64Word} word The x64-Word to AND with this word.
 13167                   *
 13168                   * @return {X64Word} A new x64-Word object after ANDing.
 13169                   *
 13170                   * @example
 13171                   *
 13172                   *     var anded = x64Word.and(anotherX64Word);
 13173                   */
 13174                  // and: function (word) {
 13175                      // var high = this.high & word.high;
 13176                      // var low = this.low & word.low;
 13177      
 13178                      // return X64Word.create(high, low);
 13179                  // },
 13180      
 13181                  /**
 13182                   * Bitwise ORs this word with the passed word.
 13183                   *
 13184                   * @param {X64Word} word The x64-Word to OR with this word.
 13185                   *
 13186                   * @return {X64Word} A new x64-Word object after ORing.
 13187                   *
 13188                   * @example
 13189                   *
 13190                   *     var ored = x64Word.or(anotherX64Word);
 13191                   */
 13192                  // or: function (word) {
 13193                      // var high = this.high | word.high;
 13194                      // var low = this.low | word.low;
 13195      
 13196                      // return X64Word.create(high, low);
 13197                  // },
 13198      
 13199                  /**
 13200                   * Bitwise XORs this word with the passed word.
 13201                   *
 13202                   * @param {X64Word} word The x64-Word to XOR with this word.
 13203                   *
 13204                   * @return {X64Word} A new x64-Word object after XORing.
 13205                   *
 13206                   * @example
 13207                   *
 13208                   *     var xored = x64Word.xor(anotherX64Word);
 13209                   */
 13210                  // xor: function (word) {
 13211                      // var high = this.high ^ word.high;
 13212                      // var low = this.low ^ word.low;
 13213      
 13214                      // return X64Word.create(high, low);
 13215                  // },
 13216      
 13217                  /**
 13218                   * Shifts this word n bits to the left.
 13219                   *
 13220                   * @param {number} n The number of bits to shift.
 13221                   *
 13222                   * @return {X64Word} A new x64-Word object after shifting.
 13223                   *
 13224                   * @example
 13225                   *
 13226                   *     var shifted = x64Word.shiftL(25);
 13227                   */
 13228                  // shiftL: function (n) {
 13229                      // if (n < 32) {
 13230                          // var high = (this.high << n) | (this.low >>> (32 - n));
 13231                          // var low = this.low << n;
 13232                      // } else {
 13233                          // var high = this.low << (n - 32);
 13234                          // var low = 0;
 13235                      // }
 13236      
 13237                      // return X64Word.create(high, low);
 13238                  // },
 13239      
 13240                  /**
 13241                   * Shifts this word n bits to the right.
 13242                   *
 13243                   * @param {number} n The number of bits to shift.
 13244                   *
 13245                   * @return {X64Word} A new x64-Word object after shifting.
 13246                   *
 13247                   * @example
 13248                   *
 13249                   *     var shifted = x64Word.shiftR(7);
 13250                   */
 13251                  // shiftR: function (n) {
 13252                      // if (n < 32) {
 13253                          // var low = (this.low >>> n) | (this.high << (32 - n));
 13254                          // var high = this.high >>> n;
 13255                      // } else {
 13256                          // var low = this.high >>> (n - 32);
 13257                          // var high = 0;
 13258                      // }
 13259      
 13260                      // return X64Word.create(high, low);
 13261                  // },
 13262      
 13263                  /**
 13264                   * Rotates this word n bits to the left.
 13265                   *
 13266                   * @param {number} n The number of bits to rotate.
 13267                   *
 13268                   * @return {X64Word} A new x64-Word object after rotating.
 13269                   *
 13270                   * @example
 13271                   *
 13272                   *     var rotated = x64Word.rotL(25);
 13273                   */
 13274                  // rotL: function (n) {
 13275                      // return this.shiftL(n).or(this.shiftR(64 - n));
 13276                  // },
 13277      
 13278                  /**
 13279                   * Rotates this word n bits to the right.
 13280                   *
 13281                   * @param {number} n The number of bits to rotate.
 13282                   *
 13283                   * @return {X64Word} A new x64-Word object after rotating.
 13284                   *
 13285                   * @example
 13286                   *
 13287                   *     var rotated = x64Word.rotR(7);
 13288                   */
 13289                  // rotR: function (n) {
 13290                      // return this.shiftR(n).or(this.shiftL(64 - n));
 13291                  // },
 13292      
 13293                  /**
 13294                   * Adds this word with the passed word.
 13295                   *
 13296                   * @param {X64Word} word The x64-Word to add with this word.
 13297                   *
 13298                   * @return {X64Word} A new x64-Word object after adding.
 13299                   *
 13300                   * @example
 13301                   *
 13302                   *     var added = x64Word.add(anotherX64Word);
 13303                   */
 13304                  // add: function (word) {
 13305                      // var low = (this.low + word.low) | 0;
 13306                      // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
 13307                      // var high = (this.high + word.high + carry) | 0;
 13308      
 13309                      // return X64Word.create(high, low);
 13310                  // }
 13311              });
 13312      
 13313              /**
 13314               * An array of 64-bit words.
 13315               *
 13316               * @property {Array} words The array of CryptoJS.x64.Word objects.
 13317               * @property {number} sigBytes The number of significant bytes in this word array.
 13318               */
 13319              var X64WordArray = C_x64.WordArray = Base.extend({
 13320                  /**
 13321                   * Initializes a newly created word array.
 13322                   *
 13323                   * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
 13324                   * @param {number} sigBytes (Optional) The number of significant bytes in the words.
 13325                   *
 13326                   * @example
 13327                   *
 13328                   *     var wordArray = CryptoJS.x64.WordArray.create();
 13329                   *
 13330                   *     var wordArray = CryptoJS.x64.WordArray.create([
 13331                   *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 13332                   *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 13333                   *     ]);
 13334                   *
 13335                   *     var wordArray = CryptoJS.x64.WordArray.create([
 13336                   *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 13337                   *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 13338                   *     ], 10);
 13339                   */
 13340                  init: function (words, sigBytes) {
 13341                      words = this.words = words || [];
 13342      
 13343                      if (sigBytes != undefined) {
 13344                          this.sigBytes = sigBytes;
 13345                      } else {
 13346                          this.sigBytes = words.length * 8;
 13347                      }
 13348                  },
 13349      
 13350                  /**
 13351                   * Converts this 64-bit word array to a 32-bit word array.
 13352                   *
 13353                   * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
 13354                   *
 13355                   * @example
 13356                   *
 13357                   *     var x32WordArray = x64WordArray.toX32();
 13358                   */
 13359                  toX32: function () {
 13360                      // Shortcuts
 13361                      var x64Words = this.words;
 13362                      var x64WordsLength = x64Words.length;
 13363      
 13364                      // Convert
 13365                      var x32Words = [];
 13366                      for (var i = 0; i < x64WordsLength; i++) {
 13367                          var x64Word = x64Words[i];
 13368                          x32Words.push(x64Word.high);
 13369                          x32Words.push(x64Word.low);
 13370                      }
 13371      
 13372                      return X32WordArray.create(x32Words, this.sigBytes);
 13373                  },
 13374      
 13375                  /**
 13376                   * Creates a copy of this word array.
 13377                   *
 13378                   * @return {X64WordArray} The clone.
 13379                   *
 13380                   * @example
 13381                   *
 13382                   *     var clone = x64WordArray.clone();
 13383                   */
 13384                  clone: function () {
 13385                      var clone = Base.clone.call(this);
 13386      
 13387                      // Clone "words" array
 13388                      var words = clone.words = this.words.slice(0);
 13389      
 13390                      // Clone each X64Word object
 13391                      var wordsLength = words.length;
 13392                      for (var i = 0; i < wordsLength; i++) {
 13393                          words[i] = words[i].clone();
 13394                      }
 13395      
 13396                      return clone;
 13397                  }
 13398              });
 13399          }());
 13400      
 13401      
 13402          return CryptoJS;
 13403      
 13404      }));
 13405      },{"./core":53}],85:[function(require,module,exports){
 13406      /*! https://mths.be/utf8js v2.1.2 by @mathias */
 13407      ;(function(root) {
 13408      
 13409          // Detect free variables `exports`
 13410          var freeExports = typeof exports == 'object' && exports;
 13411      
 13412          // Detect free variable `module`
 13413          var freeModule = typeof module == 'object' && module &&
 13414              module.exports == freeExports && module;
 13415      
 13416          // Detect free variable `global`, from Node.js or Browserified code,
 13417          // and use it as `root`
 13418          var freeGlobal = typeof global == 'object' && global;
 13419          if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
 13420              root = freeGlobal;
 13421          }
 13422      
 13423          /*--------------------------------------------------------------------------*/
 13424      
 13425          var stringFromCharCode = String.fromCharCode;
 13426      
 13427          // Taken from https://mths.be/punycode
 13428          function ucs2decode(string) {
 13429              var output = [];
 13430              var counter = 0;
 13431              var length = string.length;
 13432              var value;
 13433              var extra;
 13434              while (counter < length) {
 13435                  value = string.charCodeAt(counter++);
 13436                  if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
 13437                      // high surrogate, and there is a next character
 13438                      extra = string.charCodeAt(counter++);
 13439                      if ((extra & 0xFC00) == 0xDC00) { // low surrogate
 13440                          output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
 13441                      } else {
 13442                          // unmatched surrogate; only append this code unit, in case the next
 13443                          // code unit is the high surrogate of a surrogate pair
 13444                          output.push(value);
 13445                          counter--;
 13446                      }
 13447                  } else {
 13448                      output.push(value);
 13449                  }
 13450              }
 13451              return output;
 13452          }
 13453      
 13454          // Taken from https://mths.be/punycode
 13455          function ucs2encode(array) {
 13456              var length = array.length;
 13457              var index = -1;
 13458              var value;
 13459              var output = '';
 13460              while (++index < length) {
 13461                  value = array[index];
 13462                  if (value > 0xFFFF) {
 13463                      value -= 0x10000;
 13464                      output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
 13465                      value = 0xDC00 | value & 0x3FF;
 13466                  }
 13467                  output += stringFromCharCode(value);
 13468              }
 13469              return output;
 13470          }
 13471      
 13472          function checkScalarValue(codePoint) {
 13473              if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
 13474                  throw Error(
 13475                      'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
 13476                      ' is not a scalar value'
 13477                  );
 13478              }
 13479          }
 13480          /*--------------------------------------------------------------------------*/
 13481      
 13482          function createByte(codePoint, shift) {
 13483              return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
 13484          }
 13485      
 13486          function encodeCodePoint(codePoint) {
 13487              if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
 13488                  return stringFromCharCode(codePoint);
 13489              }
 13490              var symbol = '';
 13491              if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
 13492                  symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
 13493              }
 13494              else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
 13495                  checkScalarValue(codePoint);
 13496                  symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
 13497                  symbol += createByte(codePoint, 6);
 13498              }
 13499              else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
 13500                  symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
 13501                  symbol += createByte(codePoint, 12);
 13502                  symbol += createByte(codePoint, 6);
 13503              }
 13504              symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
 13505              return symbol;
 13506          }
 13507      
 13508          function utf8encode(string) {
 13509              var codePoints = ucs2decode(string);
 13510              var length = codePoints.length;
 13511              var index = -1;
 13512              var codePoint;
 13513              var byteString = '';
 13514              while (++index < length) {
 13515                  codePoint = codePoints[index];
 13516                  byteString += encodeCodePoint(codePoint);
 13517              }
 13518              return byteString;
 13519          }
 13520      
 13521          /*--------------------------------------------------------------------------*/
 13522      
 13523          function readContinuationByte() {
 13524              if (byteIndex >= byteCount) {
 13525                  throw Error('Invalid byte index');
 13526              }
 13527      
 13528              var continuationByte = byteArray[byteIndex] & 0xFF;
 13529              byteIndex++;
 13530      
 13531              if ((continuationByte & 0xC0) == 0x80) {
 13532                  return continuationByte & 0x3F;
 13533              }
 13534      
 13535              // If we end up here, it’s not a continuation byte
 13536              throw Error('Invalid continuation byte');
 13537          }
 13538      
 13539          function decodeSymbol() {
 13540              var byte1;
 13541              var byte2;
 13542              var byte3;
 13543              var byte4;
 13544              var codePoint;
 13545      
 13546              if (byteIndex > byteCount) {
 13547                  throw Error('Invalid byte index');
 13548              }
 13549      
 13550              if (byteIndex == byteCount) {
 13551                  return false;
 13552              }
 13553      
 13554              // Read first byte
 13555              byte1 = byteArray[byteIndex] & 0xFF;
 13556              byteIndex++;
 13557      
 13558              // 1-byte sequence (no continuation bytes)
 13559              if ((byte1 & 0x80) == 0) {
 13560                  return byte1;
 13561              }
 13562      
 13563              // 2-byte sequence
 13564              if ((byte1 & 0xE0) == 0xC0) {
 13565                  byte2 = readContinuationByte();
 13566                  codePoint = ((byte1 & 0x1F) << 6) | byte2;
 13567                  if (codePoint >= 0x80) {
 13568                      return codePoint;
 13569                  } else {
 13570                      throw Error('Invalid continuation byte');
 13571                  }
 13572              }
 13573      
 13574              // 3-byte sequence (may include unpaired surrogates)
 13575              if ((byte1 & 0xF0) == 0xE0) {
 13576                  byte2 = readContinuationByte();
 13577                  byte3 = readContinuationByte();
 13578                  codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
 13579                  if (codePoint >= 0x0800) {
 13580                      checkScalarValue(codePoint);
 13581                      return codePoint;
 13582                  } else {
 13583                      throw Error('Invalid continuation byte');
 13584                  }
 13585              }
 13586      
 13587              // 4-byte sequence
 13588              if ((byte1 & 0xF8) == 0xF0) {
 13589                  byte2 = readContinuationByte();
 13590                  byte3 = readContinuationByte();
 13591                  byte4 = readContinuationByte();
 13592                  codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
 13593                      (byte3 << 0x06) | byte4;
 13594                  if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
 13595                      return codePoint;
 13596                  }
 13597              }
 13598      
 13599              throw Error('Invalid UTF-8 detected');
 13600          }
 13601      
 13602          var byteArray;
 13603          var byteCount;
 13604          var byteIndex;
 13605          function utf8decode(byteString) {
 13606              byteArray = ucs2decode(byteString);
 13607              byteCount = byteArray.length;
 13608              byteIndex = 0;
 13609              var codePoints = [];
 13610              var tmp;
 13611              while ((tmp = decodeSymbol()) !== false) {
 13612                  codePoints.push(tmp);
 13613              }
 13614              return ucs2encode(codePoints);
 13615          }
 13616      
 13617          /*--------------------------------------------------------------------------*/
 13618      
 13619          var utf8 = {
 13620              'version': '2.1.2',
 13621              'encode': utf8encode,
 13622              'decode': utf8decode
 13623          };
 13624      
 13625          // Some AMD build optimizers, like r.js, check for specific condition patterns
 13626          // like the following:
 13627          if (
 13628              typeof define == 'function' &&
 13629              typeof define.amd == 'object' &&
 13630              define.amd
 13631          ) {
 13632              define(function() {
 13633                  return utf8;
 13634              });
 13635          }	else if (freeExports && !freeExports.nodeType) {
 13636              if (freeModule) { // in Node.js or RingoJS v0.8.0+
 13637                  freeModule.exports = utf8;
 13638              } else { // in Narwhal or RingoJS v0.7.0-
 13639                  var object = {};
 13640                  var hasOwnProperty = object.hasOwnProperty;
 13641                  for (var key in utf8) {
 13642                      hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
 13643                  }
 13644              }
 13645          } else { // in Rhino or a web browser
 13646              root.utf8 = utf8;
 13647          }
 13648      
 13649      }(this));
 13650      
 13651      },{}],86:[function(require,module,exports){
 13652      module.exports = XMLHttpRequest;
 13653      
 13654      },{}],"bignumber.js":[function(require,module,exports){
 13655      'use strict';
 13656      
 13657      module.exports = BigNumber; // jshint ignore:line
 13658      
 13659      
 13660      },{}],"web3":[function(require,module,exports){
 13661      var Web3 = require('./lib/web3');
 13662      
 13663      // don't override global variable
 13664      if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
 13665          window.Web3 = Web3;
 13666      }
 13667      
 13668      module.exports = Web3;
 13669      
 13670      },{"./lib/web3":22}]},{},["web3"])
 13671      //# sourceMappingURL=web3-light.js.map
 13672