github.com/kisexp/xdchain@v0.0.0-20211206025815-490d6b732aa7/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      'kether':       '1000000000000000000000',
  1910      'grand':        '1000000000000000000000',
  1911      'mether':       '1000000000000000000000000',
  1912      'gether':       '1000000000000000000000000000',
  1913      'tether':       '1000000000000000000000000000000'
  1914  };
  1915  
  1916  /**
  1917   * Should be called to pad string to expected length
  1918   *
  1919   * @method padLeft
  1920   * @param {String} string to be padded
  1921   * @param {Number} characters that result string should have
  1922   * @param {String} sign, by default 0
  1923   * @returns {String} right aligned string
  1924   */
  1925  var padLeft = function (string, chars, sign) {
  1926      return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
  1927  };
  1928  
  1929  /**
  1930   * Should be called to pad string to expected length
  1931   *
  1932   * @method padRight
  1933   * @param {String} string to be padded
  1934   * @param {Number} characters that result string should have
  1935   * @param {String} sign, by default 0
  1936   * @returns {String} right aligned string
  1937   */
  1938  var padRight = function (string, chars, sign) {
  1939      return string + (new Array(chars - string.length + 1).join(sign ? sign : "0"));
  1940  };
  1941  
  1942  /**
  1943   * Should be called to get utf8 from it's hex representation
  1944   *
  1945   * @method toUtf8
  1946   * @param {String} string in hex
  1947   * @returns {String} ascii string representation of hex value
  1948   */
  1949  var toUtf8 = function(hex) {
  1950  // Find termination
  1951      var str = "";
  1952      var i = 0, l = hex.length;
  1953      if (hex.substring(0, 2) === '0x') {
  1954          i = 2;
  1955      }
  1956      for (; i < l; i+=2) {
  1957          var code = parseInt(hex.substr(i, 2), 16);
  1958          if (code === 0)
  1959              break;
  1960          str += String.fromCharCode(code);
  1961      }
  1962  
  1963      return utf8.decode(str);
  1964  };
  1965  
  1966  /**
  1967   * Should be called to get ascii from it's hex representation
  1968   *
  1969   * @method toAscii
  1970   * @param {String} string in hex
  1971   * @returns {String} ascii string representation of hex value
  1972   */
  1973  var toAscii = function(hex) {
  1974  // Find termination
  1975      var str = "";
  1976      var i = 0, l = hex.length;
  1977      if (hex.substring(0, 2) === '0x') {
  1978          i = 2;
  1979      }
  1980      for (; i < l; i+=2) {
  1981          var code = parseInt(hex.substr(i, 2), 16);
  1982          str += String.fromCharCode(code);
  1983      }
  1984  
  1985      return str;
  1986  };
  1987  
  1988  /**
  1989   * Should be called to get hex representation (prefixed by 0x) of utf8 string
  1990   *
  1991   * @method fromUtf8
  1992   * @param {String} string
  1993   * @param {Number} optional padding
  1994   * @returns {String} hex representation of input string
  1995   */
  1996  var fromUtf8 = function(str) {
  1997      str = utf8.encode(str);
  1998      var hex = "";
  1999      for(var i = 0; i < str.length; i++) {
  2000          var code = str.charCodeAt(i);
  2001          if (code === 0)
  2002              break;
  2003          var n = code.toString(16);
  2004          hex += n.length < 2 ? '0' + n : n;
  2005      }
  2006  
  2007      return "0x" + hex;
  2008  };
  2009  
  2010  /**
  2011   * Should be called to get hex representation (prefixed by 0x) of ascii string
  2012   *
  2013   * @method fromAscii
  2014   * @param {String} string
  2015   * @param {Number} optional padding
  2016   * @returns {String} hex representation of input string
  2017   */
  2018  var fromAscii = function(str) {
  2019      var hex = "";
  2020      for(var i = 0; i < str.length; i++) {
  2021          var code = str.charCodeAt(i);
  2022          var n = code.toString(16);
  2023          hex += n.length < 2 ? '0' + n : n;
  2024      }
  2025  
  2026      return "0x" + hex;
  2027  };
  2028  
  2029  /**
  2030   * Should be used to create full function/event name from json abi
  2031   *
  2032   * @method transformToFullName
  2033   * @param {Object} json-abi
  2034   * @return {String} full fnction/event name
  2035   */
  2036  var transformToFullName = function (json) {
  2037      if (json.name.indexOf('(') !== -1) {
  2038          return json.name;
  2039      }
  2040  
  2041      var typeName = json.inputs.map(function(i){return i.type; }).join();
  2042      return json.name + '(' + typeName + ')';
  2043  };
  2044  
  2045  /**
  2046   * Should be called to get display name of contract function
  2047   *
  2048   * @method extractDisplayName
  2049   * @param {String} name of function/event
  2050   * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
  2051   */
  2052  var extractDisplayName = function (name) {
  2053      var length = name.indexOf('(');
  2054      return length !== -1 ? name.substr(0, length) : name;
  2055  };
  2056  
  2057  /// @returns overloaded part of function/event name
  2058  var extractTypeName = function (name) {
  2059      /// TODO: make it invulnerable
  2060      var length = name.indexOf('(');
  2061      return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
  2062  };
  2063  
  2064  /**
  2065   * Converts value to it's decimal representation in string
  2066   *
  2067   * @method toDecimal
  2068   * @param {String|Number|BigNumber}
  2069   * @return {String}
  2070   */
  2071  var toDecimal = function (value) {
  2072      return toBigNumber(value).toNumber();
  2073  };
  2074  
  2075  /**
  2076   * Converts value to it's hex representation
  2077   *
  2078   * @method fromDecimal
  2079   * @param {String|Number|BigNumber}
  2080   * @return {String}
  2081   */
  2082  var fromDecimal = function (value) {
  2083      var number = toBigNumber(value);
  2084      var result = number.toString(16);
  2085  
  2086      return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
  2087  };
  2088  
  2089  /**
  2090   * Auto converts any given value into it's hex representation.
  2091   *
  2092   * And even stringifys objects before.
  2093   *
  2094   * @method toHex
  2095   * @param {String|Number|BigNumber|Object}
  2096   * @return {String}
  2097   */
  2098  var toHex = function (val) {
  2099      /*jshint maxcomplexity: 8 */
  2100  
  2101      if (isBoolean(val))
  2102          return fromDecimal(+val);
  2103  
  2104      if (isBigNumber(val))
  2105          return fromDecimal(val);
  2106  
  2107      if (typeof val === 'object')
  2108          return fromUtf8(JSON.stringify(val));
  2109  
  2110      // if its a negative number, pass it through fromDecimal
  2111      if (isString(val)) {
  2112          if (val.indexOf('-0x') === 0)
  2113              return fromDecimal(val);
  2114          else if(val.indexOf('0x') === 0)
  2115              return val;
  2116          else if (!isFinite(val))
  2117              return fromAscii(val);
  2118      }
  2119  
  2120      return fromDecimal(val);
  2121  };
  2122  
  2123  /**
  2124   * Returns value of unit in Wei
  2125   *
  2126   * @method getValueOfUnit
  2127   * @param {String} unit the unit to convert to, default ether
  2128   * @returns {BigNumber} value of the unit (in Wei)
  2129   * @throws error if the unit is not correct:w
  2130   */
  2131  var getValueOfUnit = function (unit) {
  2132      unit = unit ? unit.toLowerCase() : 'ether';
  2133      var unitValue = unitMap[unit];
  2134      if (unitValue === undefined) {
  2135          throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
  2136      }
  2137      return new BigNumber(unitValue, 10);
  2138  };
  2139  
  2140  /**
  2141   * Takes a number of wei and converts it to any other ether unit.
  2142   *
  2143   * Possible units are:
  2144   *   SI Short   SI Full        Effigy       Other
  2145   * - kwei       femtoether     babbage
  2146   * - mwei       picoether      lovelace
  2147   * - gwei       nanoether      shannon      nano
  2148   * - --         microether     szabo        micro
  2149   * - --         milliether     finney       milli
  2150   * - ether      --             --
  2151   * - kether                    --           grand
  2152   * - mether
  2153   * - gether
  2154   * - tether
  2155   *
  2156   * @method fromWei
  2157   * @param {Number|String} number can be a number, number string or a HEX of a decimal
  2158   * @param {String} unit the unit to convert to, default ether
  2159   * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2160  */
  2161  var fromWei = function(number, unit) {
  2162      var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
  2163  
  2164      return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2165  };
  2166  
  2167  /**
  2168   * Takes a number of a unit and converts it to wei.
  2169   *
  2170   * Possible units are:
  2171   *   SI Short   SI Full        Effigy       Other
  2172   * - kwei       femtoether     babbage
  2173   * - mwei       picoether      lovelace
  2174   * - gwei       nanoether      shannon      nano
  2175   * - --         microether     szabo        micro
  2176   * - --         microether     szabo        micro
  2177   * - --         milliether     finney       milli
  2178   * - ether      --             --
  2179   * - kether                    --           grand
  2180   * - mether
  2181   * - gether
  2182   * - tether
  2183   *
  2184   * @method toWei
  2185   * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
  2186   * @param {String} unit the unit to convert from, default ether
  2187   * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2188  */
  2189  var toWei = function(number, unit) {
  2190      var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
  2191  
  2192      return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2193  };
  2194  
  2195  /**
  2196   * Takes an input and transforms it into a bignumber
  2197   *
  2198   * @method toBigNumber
  2199   * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
  2200   * @return {BigNumber} BigNumber
  2201  */
  2202  var toBigNumber = function(number) {
  2203      /*jshint maxcomplexity:5 */
  2204      number = number || 0;
  2205      if (isBigNumber(number))
  2206          return number;
  2207  
  2208      if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
  2209          return new BigNumber(number.replace('0x',''), 16);
  2210      }
  2211  
  2212      return new BigNumber(number.toString(10), 10);
  2213  };
  2214  
  2215  /**
  2216   * Takes and input transforms it into bignumber and if it is negative value, into two's complement
  2217   *
  2218   * @method toTwosComplement
  2219   * @param {Number|String|BigNumber}
  2220   * @return {BigNumber}
  2221   */
  2222  var toTwosComplement = function (number) {
  2223      var bigNumber = toBigNumber(number).round();
  2224      if (bigNumber.lessThan(0)) {
  2225          return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
  2226      }
  2227      return bigNumber;
  2228  };
  2229  
  2230  /**
  2231   * Checks if the given string is strictly an address
  2232   *
  2233   * @method isStrictAddress
  2234   * @param {String} address the given HEX address
  2235   * @return {Boolean}
  2236  */
  2237  var isStrictAddress = function (address) {
  2238      return /^0x[0-9a-f]{40}$/i.test(address);
  2239  };
  2240  
  2241  /**
  2242   * Checks if the given string is an address
  2243   *
  2244   * @method isAddress
  2245   * @param {String} address the given HEX address
  2246   * @return {Boolean}
  2247  */
  2248  var isAddress = function (address) {
  2249      if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
  2250          // check if it has the basic requirements of an address
  2251          return false;
  2252      } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
  2253          // If it's all small caps or all caps, return true
  2254          return true;
  2255      } else {
  2256          // Otherwise check each case
  2257          return isChecksumAddress(address);
  2258      }
  2259  };
  2260  
  2261  /**
  2262   * Checks if the given string is a checksummed address
  2263   *
  2264   * @method isChecksumAddress
  2265   * @param {String} address the given HEX address
  2266   * @return {Boolean}
  2267  */
  2268  var isChecksumAddress = function (address) {
  2269      // Check each case
  2270      address = address.replace('0x','');
  2271      var addressHash = sha3(address.toLowerCase());
  2272  
  2273      for (var i = 0; i < 40; i++ ) {
  2274          // the nth letter should be uppercase if the nth digit of casemap is 1
  2275          if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
  2276              return false;
  2277          }
  2278      }
  2279      return true;
  2280  };
  2281  
  2282  
  2283  
  2284  /**
  2285   * Makes a checksum address
  2286   *
  2287   * @method toChecksumAddress
  2288   * @param {String} address the given HEX address
  2289   * @return {String}
  2290  */
  2291  var toChecksumAddress = function (address) {
  2292      if (typeof address === 'undefined') return '';
  2293  
  2294      address = address.toLowerCase().replace('0x','');
  2295      var addressHash = sha3(address);
  2296      var checksumAddress = '0x';
  2297  
  2298      for (var i = 0; i < address.length; i++ ) {
  2299          // If ith character is 9 to f then make it uppercase
  2300          if (parseInt(addressHash[i], 16) > 7) {
  2301            checksumAddress += address[i].toUpperCase();
  2302          } else {
  2303              checksumAddress += address[i];
  2304          }
  2305      }
  2306      return checksumAddress;
  2307  };
  2308  
  2309  /**
  2310   * Transforms given string to valid 20 bytes-length addres with 0x prefix
  2311   *
  2312   * @method toAddress
  2313   * @param {String} address
  2314   * @return {String} formatted address
  2315   */
  2316  var toAddress = function (address) {
  2317      if (isStrictAddress(address)) {
  2318          return address;
  2319      }
  2320  
  2321      if (/^[0-9a-f]{40}$/.test(address)) {
  2322          return '0x' + address;
  2323      }
  2324  
  2325      return '0x' + padLeft(toHex(address).substr(2), 40);
  2326  };
  2327  
  2328  /**
  2329   * Returns true if object is BigNumber, otherwise false
  2330   *
  2331   * @method isBigNumber
  2332   * @param {Object}
  2333   * @return {Boolean}
  2334   */
  2335  var isBigNumber = function (object) {
  2336      return object instanceof BigNumber ||
  2337          (object && object.constructor && object.constructor.name === 'BigNumber');
  2338  };
  2339  
  2340  /**
  2341   * Returns true if object is string, otherwise false
  2342   *
  2343   * @method isString
  2344   * @param {Object}
  2345   * @return {Boolean}
  2346   */
  2347  var isString = function (object) {
  2348      return typeof object === 'string' ||
  2349          (object && object.constructor && object.constructor.name === 'String');
  2350  };
  2351  
  2352  /**
  2353   * Returns true if object is function, otherwise false
  2354   *
  2355   * @method isFunction
  2356   * @param {Object}
  2357   * @return {Boolean}
  2358   */
  2359  var isFunction = function (object) {
  2360      return typeof object === 'function';
  2361  };
  2362  
  2363  /**
  2364   * Returns true if object is Objet, otherwise false
  2365   *
  2366   * @method isObject
  2367   * @param {Object}
  2368   * @return {Boolean}
  2369   */
  2370  var isObject = function (object) {
  2371      return object !== null && !(object instanceof Array) && typeof object === 'object';
  2372  };
  2373  
  2374  /**
  2375   * Returns true if object is boolean, otherwise false
  2376   *
  2377   * @method isBoolean
  2378   * @param {Object}
  2379   * @return {Boolean}
  2380   */
  2381  var isBoolean = function (object) {
  2382      return typeof object === 'boolean';
  2383  };
  2384  
  2385  /**
  2386   * Returns true if object is array, otherwise false
  2387   *
  2388   * @method isArray
  2389   * @param {Object}
  2390   * @return {Boolean}
  2391   */
  2392  var isArray = function (object) {
  2393      return object instanceof Array;
  2394  };
  2395  
  2396  /**
  2397   * Returns true if given string is valid json object
  2398   *
  2399   * @method isJson
  2400   * @param {String}
  2401   * @return {Boolean}
  2402   */
  2403  var isJson = function (str) {
  2404      try {
  2405          return !!JSON.parse(str);
  2406      } catch (e) {
  2407          return false;
  2408      }
  2409  };
  2410  
  2411  /**
  2412   * Returns true if given string is a valid Ethereum block header bloom.
  2413   *
  2414   * @method isBloom
  2415   * @param {String} hex encoded bloom filter
  2416   * @return {Boolean}
  2417   */
  2418  var isBloom = function (bloom) {
  2419      if (!/^(0x)?[0-9a-f]{512}$/i.test(bloom)) {
  2420          return false;
  2421      } else if (/^(0x)?[0-9a-f]{512}$/.test(bloom) || /^(0x)?[0-9A-F]{512}$/.test(bloom)) {
  2422          return true;
  2423      }
  2424      return false;
  2425  };
  2426  
  2427  /**
  2428   * Returns true if given string is a valid log topic.
  2429   *
  2430   * @method isTopic
  2431   * @param {String} hex encoded topic
  2432   * @return {Boolean}
  2433   */
  2434  var isTopic = function (topic) {
  2435      if (!/^(0x)?[0-9a-f]{64}$/i.test(topic)) {
  2436          return false;
  2437      } else if (/^(0x)?[0-9a-f]{64}$/.test(topic) || /^(0x)?[0-9A-F]{64}$/.test(topic)) {
  2438          return true;
  2439      }
  2440      return false;
  2441  };
  2442  
  2443  module.exports = {
  2444      padLeft: padLeft,
  2445      padRight: padRight,
  2446      toHex: toHex,
  2447      toDecimal: toDecimal,
  2448      fromDecimal: fromDecimal,
  2449      toUtf8: toUtf8,
  2450      toAscii: toAscii,
  2451      fromUtf8: fromUtf8,
  2452      fromAscii: fromAscii,
  2453      transformToFullName: transformToFullName,
  2454      extractDisplayName: extractDisplayName,
  2455      extractTypeName: extractTypeName,
  2456      toWei: toWei,
  2457      fromWei: fromWei,
  2458      toBigNumber: toBigNumber,
  2459      toTwosComplement: toTwosComplement,
  2460      toAddress: toAddress,
  2461      isBigNumber: isBigNumber,
  2462      isStrictAddress: isStrictAddress,
  2463      isAddress: isAddress,
  2464      isChecksumAddress: isChecksumAddress,
  2465      toChecksumAddress: toChecksumAddress,
  2466      isFunction: isFunction,
  2467      isString: isString,
  2468      isObject: isObject,
  2469      isBoolean: isBoolean,
  2470      isArray: isArray,
  2471      isJson: isJson,
  2472      isBloom: isBloom,
  2473      isTopic: isTopic,
  2474  };
  2475  
  2476  },{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":85}],21:[function(require,module,exports){
  2477  module.exports={
  2478      "version": "0.20.1"
  2479  }
  2480  
  2481  },{}],22:[function(require,module,exports){
  2482  /*
  2483      This file is part of web3.js.
  2484  
  2485      web3.js is free software: you can redistribute it and/or modify
  2486      it under the terms of the GNU Lesser General Public License as published by
  2487      the Free Software Foundation, either version 3 of the License, or
  2488      (at your option) any later version.
  2489  
  2490      web3.js is distributed in the hope that it will be useful,
  2491      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2492      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2493      GNU Lesser General Public License for more details.
  2494  
  2495      You should have received a copy of the GNU Lesser General Public License
  2496      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2497  */
  2498  /**
  2499   * @file web3.js
  2500   * @authors:
  2501   *   Jeffrey Wilcke <jeff@ethdev.com>
  2502   *   Marek Kotewicz <marek@ethdev.com>
  2503   *   Marian Oancea <marian@ethdev.com>
  2504   *   Fabian Vogelsteller <fabian@ethdev.com>
  2505   *   Gav Wood <g@ethdev.com>
  2506   * @date 2014
  2507   */
  2508  
  2509  var RequestManager = require('./web3/requestmanager');
  2510  var Iban = require('./web3/iban');
  2511  var Eth = require('./web3/methods/eth');
  2512  var DB = require('./web3/methods/db');
  2513  var Shh = require('./web3/methods/shh');
  2514  var Net = require('./web3/methods/net');
  2515  var Personal = require('./web3/methods/personal');
  2516  var Swarm = require('./web3/methods/swarm');
  2517  var Settings = require('./web3/settings');
  2518  var version = require('./version.json');
  2519  var utils = require('./utils/utils');
  2520  var sha3 = require('./utils/sha3');
  2521  var extend = require('./web3/extend');
  2522  var Batch = require('./web3/batch');
  2523  var Property = require('./web3/property');
  2524  var HttpProvider = require('./web3/httpprovider');
  2525  var IpcProvider = require('./web3/ipcprovider');
  2526  var BigNumber = require('bignumber.js');
  2527  
  2528  
  2529  
  2530  function Web3 (provider) {
  2531      this._requestManager = new RequestManager(provider);
  2532      this.currentProvider = provider;
  2533      this.eth = new Eth(this);
  2534      this.db = new DB(this);
  2535      this.shh = new Shh(this);
  2536      this.net = new Net(this);
  2537      this.personal = new Personal(this);
  2538      this.bzz = new Swarm(this);
  2539      this.settings = new Settings();
  2540      this.version = {
  2541          api: version.version
  2542      };
  2543      this.providers = {
  2544          HttpProvider: HttpProvider,
  2545          IpcProvider: IpcProvider
  2546      };
  2547      this._extend = extend(this);
  2548      this._extend({
  2549          properties: properties()
  2550      });
  2551  }
  2552  
  2553  // expose providers on the class
  2554  Web3.providers = {
  2555      HttpProvider: HttpProvider,
  2556      IpcProvider: IpcProvider
  2557  };
  2558  
  2559  Web3.prototype.setProvider = function (provider) {
  2560      this._requestManager.setProvider(provider);
  2561      this.currentProvider = provider;
  2562  };
  2563  
  2564  Web3.prototype.reset = function (keepIsSyncing) {
  2565      this._requestManager.reset(keepIsSyncing);
  2566      this.settings = new Settings();
  2567  };
  2568  
  2569  Web3.prototype.BigNumber = BigNumber;
  2570  Web3.prototype.toHex = utils.toHex;
  2571  Web3.prototype.toAscii = utils.toAscii;
  2572  Web3.prototype.toUtf8 = utils.toUtf8;
  2573  Web3.prototype.fromAscii = utils.fromAscii;
  2574  Web3.prototype.fromUtf8 = utils.fromUtf8;
  2575  Web3.prototype.toDecimal = utils.toDecimal;
  2576  Web3.prototype.fromDecimal = utils.fromDecimal;
  2577  Web3.prototype.toBigNumber = utils.toBigNumber;
  2578  Web3.prototype.toWei = utils.toWei;
  2579  Web3.prototype.fromWei = utils.fromWei;
  2580  Web3.prototype.isAddress = utils.isAddress;
  2581  Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
  2582  Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
  2583  Web3.prototype.isIBAN = utils.isIBAN;
  2584  Web3.prototype.padLeft = utils.padLeft;
  2585  Web3.prototype.padRight = utils.padRight;
  2586  
  2587  
  2588  Web3.prototype.sha3 = function(string, options) {
  2589      return '0x' + sha3(string, options);
  2590  };
  2591  
  2592  /**
  2593   * Transforms direct icap to address
  2594   */
  2595  Web3.prototype.fromICAP = function (icap) {
  2596      var iban = new Iban(icap);
  2597      return iban.address();
  2598  };
  2599  
  2600  var properties = function () {
  2601      return [
  2602          new Property({
  2603              name: 'version.node',
  2604              getter: 'web3_clientVersion'
  2605          }),
  2606          new Property({
  2607              name: 'version.network',
  2608              getter: 'net_version',
  2609              inputFormatter: utils.toDecimal
  2610          }),
  2611          new Property({
  2612              name: 'version.ethereum',
  2613              getter: 'eth_protocolVersion',
  2614              inputFormatter: utils.toDecimal
  2615          }),
  2616          new Property({
  2617              name: 'version.whisper',
  2618              getter: 'shh_version',
  2619              inputFormatter: utils.toDecimal
  2620          })
  2621      ];
  2622  };
  2623  
  2624  Web3.prototype.isConnected = function(){
  2625      return (this.currentProvider && this.currentProvider.isConnected());
  2626  };
  2627  
  2628  Web3.prototype.createBatch = function () {
  2629      return new Batch(this);
  2630  };
  2631  
  2632  module.exports = Web3;
  2633  
  2634  
  2635  },{"./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){
  2636  /*
  2637      This file is part of web3.js.
  2638  
  2639      web3.js is free software: you can redistribute it and/or modify
  2640      it under the terms of the GNU Lesser General Public License as published by
  2641      the Free Software Foundation, either version 3 of the License, or
  2642      (at your option) any later version.
  2643  
  2644      web3.js is distributed in the hope that it will be useful,
  2645      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2646      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2647      GNU Lesser General Public License for more details.
  2648  
  2649      You should have received a copy of the GNU Lesser General Public License
  2650      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2651  */
  2652  /**
  2653   * @file allevents.js
  2654   * @author Marek Kotewicz <marek@ethdev.com>
  2655   * @date 2014
  2656   */
  2657  
  2658  var sha3 = require('../utils/sha3');
  2659  var SolidityEvent = require('./event');
  2660  var formatters = require('./formatters');
  2661  var utils = require('../utils/utils');
  2662  var Filter = require('./filter');
  2663  var watches = require('./methods/watches');
  2664  
  2665  var AllSolidityEvents = function (requestManager, json, address) {
  2666      this._requestManager = requestManager;
  2667      this._json = json;
  2668      this._address = address;
  2669  };
  2670  
  2671  AllSolidityEvents.prototype.encode = function (options) {
  2672      options = options || {};
  2673      var result = {};
  2674  
  2675      ['fromBlock', 'toBlock'].filter(function (f) {
  2676          return options[f] !== undefined;
  2677      }).forEach(function (f) {
  2678          result[f] = formatters.inputBlockNumberFormatter(options[f]);
  2679      });
  2680  
  2681      result.address = this._address;
  2682  
  2683      return result;
  2684  };
  2685  
  2686  AllSolidityEvents.prototype.decode = function (data) {
  2687      data.data = data.data || '';
  2688      data.topics = data.topics || [];
  2689  
  2690      var eventTopic = data.topics[0].slice(2);
  2691      var match = this._json.filter(function (j) {
  2692          return eventTopic === sha3(utils.transformToFullName(j));
  2693      })[0];
  2694  
  2695      if (!match) { // cannot find matching event?
  2696          console.warn('cannot find event for log');
  2697          return data;
  2698      }
  2699  
  2700      var event = new SolidityEvent(this._requestManager, match, this._address);
  2701      return event.decode(data);
  2702  };
  2703  
  2704  AllSolidityEvents.prototype.execute = function (options, callback) {
  2705  
  2706      if (utils.isFunction(arguments[arguments.length - 1])) {
  2707          callback = arguments[arguments.length - 1];
  2708          if(arguments.length === 1)
  2709              options = null;
  2710      }
  2711  
  2712      var o = this.encode(options);
  2713      var formatter = this.decode.bind(this);
  2714      return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
  2715  };
  2716  
  2717  AllSolidityEvents.prototype.attachToContract = function (contract) {
  2718      var execute = this.execute.bind(this);
  2719      contract.allEvents = execute;
  2720  };
  2721  
  2722  module.exports = AllSolidityEvents;
  2723  
  2724  
  2725  },{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":43}],24:[function(require,module,exports){
  2726  /*
  2727      This file is part of web3.js.
  2728  
  2729      web3.js is free software: you can redistribute it and/or modify
  2730      it under the terms of the GNU Lesser General Public License as published by
  2731      the Free Software Foundation, either version 3 of the License, or
  2732      (at your option) any later version.
  2733  
  2734      web3.js is distributed in the hope that it will be useful,
  2735      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2736      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2737      GNU Lesser General Public License for more details.
  2738  
  2739      You should have received a copy of the GNU Lesser General Public License
  2740      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2741  */
  2742  /** 
  2743   * @file batch.js
  2744   * @author Marek Kotewicz <marek@ethdev.com>
  2745   * @date 2015
  2746   */
  2747  
  2748  var Jsonrpc = require('./jsonrpc');
  2749  var errors = require('./errors');
  2750  
  2751  var Batch = function (web3) {
  2752      this.requestManager = web3._requestManager;
  2753      this.requests = [];
  2754  };
  2755  
  2756  /**
  2757   * Should be called to add create new request to batch request
  2758   *
  2759   * @method add
  2760   * @param {Object} jsonrpc requet object
  2761   */
  2762  Batch.prototype.add = function (request) {
  2763      this.requests.push(request);
  2764  };
  2765  
  2766  /**
  2767   * Should be called to execute batch request
  2768   *
  2769   * @method execute
  2770   */
  2771  Batch.prototype.execute = function () {
  2772      var requests = this.requests;
  2773      this.requestManager.sendBatch(requests, function (err, results) {
  2774          results = results || [];
  2775          requests.map(function (request, index) {
  2776              return results[index] || {};
  2777          }).forEach(function (result, index) {
  2778              if (requests[index].callback) {
  2779  
  2780                  if (!Jsonrpc.isValidResponse(result)) {
  2781                      return requests[index].callback(errors.InvalidResponse(result));
  2782                  }
  2783  
  2784                  requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));
  2785              }
  2786          });
  2787      }); 
  2788  };
  2789  
  2790  module.exports = Batch;
  2791  
  2792  
  2793  },{"./errors":26,"./jsonrpc":35}],25:[function(require,module,exports){
  2794  /*
  2795      This file is part of web3.js.
  2796  
  2797      web3.js is free software: you can redistribute it and/or modify
  2798      it under the terms of the GNU Lesser General Public License as published by
  2799      the Free Software Foundation, either version 3 of the License, or
  2800      (at your option) any later version.
  2801  
  2802      web3.js is distributed in the hope that it will be useful,
  2803      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2804      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2805      GNU Lesser General Public License for more details.
  2806  
  2807      You should have received a copy of the GNU Lesser General Public License
  2808      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2809  */
  2810  /**
  2811   * @file contract.js
  2812   * @author Marek Kotewicz <marek@ethdev.com>
  2813   * @date 2014
  2814   */
  2815  
  2816  var utils = require('../utils/utils');
  2817  var coder = require('../solidity/coder');
  2818  var SolidityEvent = require('./event');
  2819  var SolidityFunction = require('./function');
  2820  var AllEvents = require('./allevents');
  2821  
  2822  /**
  2823   * Should be called to encode constructor params
  2824   *
  2825   * @method encodeConstructorParams
  2826   * @param {Array} abi
  2827   * @param {Array} constructor params
  2828   */
  2829  var encodeConstructorParams = function (abi, params) {
  2830      return abi.filter(function (json) {
  2831          return json.type === 'constructor' && json.inputs.length === params.length;
  2832      }).map(function (json) {
  2833          return json.inputs.map(function (input) {
  2834              return input.type;
  2835          });
  2836      }).map(function (types) {
  2837          return coder.encodeParams(types, params);
  2838      })[0] || '';
  2839  };
  2840  
  2841  /**
  2842   * Should be called to add functions to contract object
  2843   *
  2844   * @method addFunctionsToContract
  2845   * @param {Contract} contract
  2846   * @param {Array} abi
  2847   */
  2848  var addFunctionsToContract = function (contract) {
  2849      contract.abi.filter(function (json) {
  2850          return json.type === 'function';
  2851      }).map(function (json) {
  2852          return new SolidityFunction(contract._eth, json, contract.address);
  2853      }).forEach(function (f) {
  2854          f.attachToContract(contract);
  2855      });
  2856  };
  2857  
  2858  /**
  2859   * Should be called to add events to contract object
  2860   *
  2861   * @method addEventsToContract
  2862   * @param {Contract} contract
  2863   * @param {Array} abi
  2864   */
  2865  var addEventsToContract = function (contract) {
  2866      var events = contract.abi.filter(function (json) {
  2867          return json.type === 'event';
  2868      });
  2869  
  2870      var All = new AllEvents(contract._eth._requestManager, events, contract.address);
  2871      All.attachToContract(contract);
  2872  
  2873      events.map(function (json) {
  2874          return new SolidityEvent(contract._eth._requestManager, json, contract.address);
  2875      }).forEach(function (e) {
  2876          e.attachToContract(contract);
  2877      });
  2878  };
  2879  
  2880  
  2881  /**
  2882   * Should be called to check if the contract gets properly deployed on the blockchain.
  2883   *
  2884   * @method checkForContractAddress
  2885   * @param {Object} contract
  2886   * @param {Function} callback
  2887   * @returns {Undefined}
  2888   */
  2889  var checkForContractAddress = function(contract, callback){
  2890      var count = 0,
  2891          callbackFired = false;
  2892  
  2893      // wait for receipt
  2894      var filter = contract._eth.filter('latest', function(e){
  2895          if (!e && !callbackFired) {
  2896              count++;
  2897  
  2898              // stop watching after 50 blocks (timeout)
  2899              if (count > 50) {
  2900  
  2901                  filter.stopWatching(function() {});
  2902                  callbackFired = true;
  2903  
  2904                  if (callback)
  2905                      callback(new Error('Contract transaction couldn\'t be found after 50 blocks'));
  2906                  else
  2907                      throw new Error('Contract transaction couldn\'t be found after 50 blocks');
  2908  
  2909  
  2910              } else {
  2911  
  2912                  contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
  2913                      if(receipt && !callbackFired) {
  2914                          // (Quorum) if receipt has no contractAddress and is a Quorum privacy marker transaction
  2915                          // then check if there is a transaction receipt for the internal private transaction
  2916                          if(!receipt.contractAddress && receipt.isPrivacyMarkerTransaction) {
  2917                              contract._eth.getPrivateTransactionReceipt(contract.transactionHash, function(e, privateReceipt){
  2918                                  if(privateReceipt.contractAddress) {
  2919                                      receipt = privateReceipt
  2920                                  }
  2921                              })
  2922                          }
  2923                          contract._eth.getCode(receipt.contractAddress, function(e, code){
  2924                              /*jshint maxcomplexity: 6 */
  2925  
  2926                              if(callbackFired || !code)
  2927                                  return;
  2928  
  2929                              filter.stopWatching(function() {});
  2930                              callbackFired = true;
  2931  
  2932                              if(code.length > 3) {
  2933  
  2934                                  // console.log('Contract code deployed!');
  2935  
  2936                                  contract.address = receipt.contractAddress;
  2937  
  2938                                  // attach events and methods again after we have
  2939                                  addFunctionsToContract(contract);
  2940                                  addEventsToContract(contract);
  2941  
  2942                                  // call callback for the second time
  2943                                  if(callback)
  2944                                      callback(null, contract);
  2945  
  2946                              } else {
  2947                                  if(callback)
  2948                                      callback(new Error('The contract code couldn\'t be stored, please check your gas amount.'));
  2949                                  else
  2950                                      throw new Error('The contract code couldn\'t be stored, please check your gas amount.');
  2951                              }
  2952                          });
  2953                      }
  2954                  });
  2955              }
  2956          }
  2957      });
  2958  };
  2959  
  2960  /**
  2961   * Should be called to create new ContractFactory instance
  2962   *
  2963   * @method ContractFactory
  2964   * @param {Array} abi
  2965   */
  2966  var ContractFactory = function (eth, abi) {
  2967      this.eth = eth;
  2968      this.abi = abi;
  2969  
  2970      /**
  2971       * Should be called to create new contract on a blockchain
  2972       *
  2973       * @method new
  2974       * @param {Any} contract constructor param1 (optional)
  2975       * @param {Any} contract constructor param2 (optional)
  2976       * @param {Object} contract transaction object (required)
  2977       * @param {Function} callback
  2978       * @returns {Contract} returns contract instance
  2979       */
  2980      this.new = function () {
  2981          /*jshint maxcomplexity: 7 */
  2982          
  2983          var contract = new Contract(this.eth, this.abi);
  2984  
  2985          // parse arguments
  2986          var options = {}; // required!
  2987          var callback;
  2988  
  2989          var args = Array.prototype.slice.call(arguments);
  2990          if (utils.isFunction(args[args.length - 1])) {
  2991              callback = args.pop();
  2992          }
  2993  
  2994          var last = args[args.length - 1];
  2995          if (utils.isObject(last) && !utils.isArray(last)) {
  2996              options = args.pop();
  2997          }
  2998  
  2999          if (options.value > 0) {
  3000              var constructorAbi = abi.filter(function (json) {
  3001                  return json.type === 'constructor' && json.inputs.length === args.length;
  3002              })[0] || {};
  3003  
  3004              if (!constructorAbi.payable) {
  3005                  throw new Error('Cannot send value to non-payable constructor');
  3006              }
  3007          }
  3008  
  3009          var bytes = encodeConstructorParams(this.abi, args);
  3010          options.data += bytes;
  3011  
  3012          if (callback) {
  3013  
  3014              // wait for the contract address and check if the code was deployed
  3015              this.eth.sendTransaction(options, function (err, hash) {
  3016                  if (err) {
  3017                      callback(err);
  3018                  } else {
  3019                      // add the transaction hash
  3020                      contract.transactionHash = hash;
  3021  
  3022                      // call callback for the first time
  3023                      callback(null, contract);
  3024  
  3025                      checkForContractAddress(contract, callback);
  3026                  }
  3027              });
  3028          } else {
  3029              var hash = this.eth.sendTransaction(options);
  3030              // add the transaction hash
  3031              contract.transactionHash = hash;
  3032              checkForContractAddress(contract);
  3033          }
  3034  
  3035          return contract;
  3036      };
  3037  
  3038      this.new.getData = this.getData.bind(this);
  3039  };
  3040  
  3041  /**
  3042   * Should be called to create new ContractFactory
  3043   *
  3044   * @method contract
  3045   * @param {Array} abi
  3046   * @returns {ContractFactory} new contract factory
  3047   */
  3048  //var contract = function (abi) {
  3049      //return new ContractFactory(abi);
  3050  //};
  3051  
  3052  
  3053  
  3054  /**
  3055   * Should be called to get access to existing contract on a blockchain
  3056   *
  3057   * @method at
  3058   * @param {Address} contract address (required)
  3059   * @param {Function} callback {optional)
  3060   * @returns {Contract} returns contract if no callback was passed,
  3061   * otherwise calls callback function (err, contract)
  3062   */
  3063  ContractFactory.prototype.at = function (address, callback) {
  3064      var contract = new Contract(this.eth, this.abi, address);
  3065  
  3066      // this functions are not part of prototype,
  3067      // because we don't want to spoil the interface
  3068      addFunctionsToContract(contract);
  3069      addEventsToContract(contract);
  3070  
  3071      if (callback) {
  3072          callback(null, contract);
  3073      }
  3074      return contract;
  3075  };
  3076  
  3077  /**
  3078   * Gets the data, which is data to deploy plus constructor params
  3079   *
  3080   * @method getData
  3081   */
  3082  ContractFactory.prototype.getData = function () {
  3083      var options = {}; // required!
  3084      var args = Array.prototype.slice.call(arguments);
  3085  
  3086      var last = args[args.length - 1];
  3087      if (utils.isObject(last) && !utils.isArray(last)) {
  3088          options = args.pop();
  3089      }
  3090  
  3091      var bytes = encodeConstructorParams(this.abi, args);
  3092      options.data += bytes;
  3093  
  3094      return options.data;
  3095  };
  3096  
  3097  /**
  3098   * Should be called to create new contract instance
  3099   *
  3100   * @method Contract
  3101   * @param {Array} abi
  3102   * @param {Address} contract address
  3103   */
  3104  var Contract = function (eth, abi, address) {
  3105      this._eth = eth;
  3106      this.transactionHash = null;
  3107      this.address = address;
  3108      this.abi = abi;
  3109  };
  3110  
  3111  module.exports = ContractFactory;
  3112  
  3113  },{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(require,module,exports){
  3114  /*
  3115      This file is part of web3.js.
  3116  
  3117      web3.js is free software: you can redistribute it and/or modify
  3118      it under the terms of the GNU Lesser General Public License as published by
  3119      the Free Software Foundation, either version 3 of the License, or
  3120      (at your option) any later version.
  3121  
  3122      web3.js is distributed in the hope that it will be useful,
  3123      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3124      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3125      GNU Lesser General Public License for more details.
  3126  
  3127      You should have received a copy of the GNU Lesser General Public License
  3128      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3129  */
  3130  /** 
  3131   * @file errors.js
  3132   * @author Marek Kotewicz <marek@ethdev.com>
  3133   * @date 2015
  3134   */
  3135  
  3136  module.exports = {
  3137      InvalidNumberOfSolidityArgs: function () {
  3138          return new Error('Invalid number of arguments to Solidity function');
  3139      },
  3140      InvalidNumberOfRPCParams: function () {
  3141          return new Error('Invalid number of input parameters to RPC method');
  3142      },
  3143      InvalidConnection: function (host){
  3144          return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
  3145      },
  3146      InvalidProvider: function () {
  3147          return new Error('Provider not set or invalid');
  3148      },
  3149      InvalidResponse: function (result){
  3150          var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);
  3151          return new Error(message);
  3152      },
  3153      ConnectionTimeout: function (ms){
  3154          return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived');
  3155      }
  3156  };
  3157  
  3158  },{}],27:[function(require,module,exports){
  3159  /*
  3160      This file is part of web3.js.
  3161  
  3162      web3.js is free software: you can redistribute it and/or modify
  3163      it under the terms of the GNU Lesser General Public License as published by
  3164      the Free Software Foundation, either version 3 of the License, or
  3165      (at your option) any later version.
  3166  
  3167      web3.js is distributed in the hope that it will be useful,
  3168      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3169      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3170      GNU Lesser General Public License for more details.
  3171  
  3172      You should have received a copy of the GNU Lesser General Public License
  3173      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3174  */
  3175  /**
  3176   * @file event.js
  3177   * @author Marek Kotewicz <marek@ethdev.com>
  3178   * @date 2014
  3179   */
  3180  
  3181  var utils = require('../utils/utils');
  3182  var coder = require('../solidity/coder');
  3183  var formatters = require('./formatters');
  3184  var sha3 = require('../utils/sha3');
  3185  var Filter = require('./filter');
  3186  var watches = require('./methods/watches');
  3187  
  3188  /**
  3189   * This prototype should be used to create event filters
  3190   */
  3191  var SolidityEvent = function (requestManager, json, address) {
  3192      this._requestManager = requestManager;
  3193      this._params = json.inputs;
  3194      this._name = utils.transformToFullName(json);
  3195      this._address = address;
  3196      this._anonymous = json.anonymous;
  3197  };
  3198  
  3199  /**
  3200   * Should be used to get filtered param types
  3201   *
  3202   * @method types
  3203   * @param {Bool} decide if returned typed should be indexed
  3204   * @return {Array} array of types
  3205   */
  3206  SolidityEvent.prototype.types = function (indexed) {
  3207      return this._params.filter(function (i) {
  3208          return i.indexed === indexed;
  3209      }).map(function (i) {
  3210          return i.type;
  3211      });
  3212  };
  3213  
  3214  /**
  3215   * Should be used to get event display name
  3216   *
  3217   * @method displayName
  3218   * @return {String} event display name
  3219   */
  3220  SolidityEvent.prototype.displayName = function () {
  3221      return utils.extractDisplayName(this._name);
  3222  };
  3223  
  3224  /**
  3225   * Should be used to get event type name
  3226   *
  3227   * @method typeName
  3228   * @return {String} event type name
  3229   */
  3230  SolidityEvent.prototype.typeName = function () {
  3231      return utils.extractTypeName(this._name);
  3232  };
  3233  
  3234  /**
  3235   * Should be used to get event signature
  3236   *
  3237   * @method signature
  3238   * @return {String} event signature
  3239   */
  3240  SolidityEvent.prototype.signature = function () {
  3241      return sha3(this._name);
  3242  };
  3243  
  3244  /**
  3245   * Should be used to encode indexed params and options to one final object
  3246   *
  3247   * @method encode
  3248   * @param {Object} indexed
  3249   * @param {Object} options
  3250   * @return {Object} everything combined together and encoded
  3251   */
  3252  SolidityEvent.prototype.encode = function (indexed, options) {
  3253      indexed = indexed || {};
  3254      options = options || {};
  3255      var result = {};
  3256  
  3257      ['fromBlock', 'toBlock'].filter(function (f) {
  3258          return options[f] !== undefined;
  3259      }).forEach(function (f) {
  3260          result[f] = formatters.inputBlockNumberFormatter(options[f]);
  3261      });
  3262  
  3263      result.topics = [];
  3264  
  3265      result.address = this._address;
  3266      if (!this._anonymous) {
  3267          result.topics.push('0x' + this.signature());
  3268      }
  3269  
  3270      var indexedTopics = this._params.filter(function (i) {
  3271          return i.indexed === true;
  3272      }).map(function (i) {
  3273          var value = indexed[i.name];
  3274          if (value === undefined || value === null) {
  3275              return null;
  3276          }
  3277  
  3278          if (utils.isArray(value)) {
  3279              return value.map(function (v) {
  3280                  return '0x' + coder.encodeParam(i.type, v);
  3281              });
  3282          }
  3283          return '0x' + coder.encodeParam(i.type, value);
  3284      });
  3285  
  3286      result.topics = result.topics.concat(indexedTopics);
  3287  
  3288      return result;
  3289  };
  3290  
  3291  /**
  3292   * Should be used to decode indexed params and options
  3293   *
  3294   * @method decode
  3295   * @param {Object} data
  3296   * @return {Object} result object with decoded indexed && not indexed params
  3297   */
  3298  SolidityEvent.prototype.decode = function (data) {
  3299  
  3300      data.data = data.data || '';
  3301      data.topics = data.topics || [];
  3302  
  3303      var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
  3304      var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
  3305      var indexedParams = coder.decodeParams(this.types(true), indexedData);
  3306  
  3307      var notIndexedData = data.data.slice(2);
  3308      var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
  3309  
  3310      var result = formatters.outputLogFormatter(data);
  3311      result.event = this.displayName();
  3312      result.address = data.address;
  3313  
  3314      result.args = this._params.reduce(function (acc, current) {
  3315          acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();
  3316          return acc;
  3317      }, {});
  3318  
  3319      delete result.data;
  3320      delete result.topics;
  3321  
  3322      return result;
  3323  };
  3324  
  3325  /**
  3326   * Should be used to create new filter object from event
  3327   *
  3328   * @method execute
  3329   * @param {Object} indexed
  3330   * @param {Object} options
  3331   * @return {Object} filter object
  3332   */
  3333  SolidityEvent.prototype.execute = function (indexed, options, callback) {
  3334  
  3335      if (utils.isFunction(arguments[arguments.length - 1])) {
  3336          callback = arguments[arguments.length - 1];
  3337          if(arguments.length === 2)
  3338              options = null;
  3339          if(arguments.length === 1) {
  3340              options = null;
  3341              indexed = {};
  3342          }
  3343      }
  3344  
  3345      var o = this.encode(indexed, options);
  3346      var formatter = this.decode.bind(this);
  3347      return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
  3348  };
  3349  
  3350  /**
  3351   * Should be used to attach event to contract object
  3352   *
  3353   * @method attachToContract
  3354   * @param {Contract}
  3355   */
  3356  SolidityEvent.prototype.attachToContract = function (contract) {
  3357      var execute = this.execute.bind(this);
  3358      var displayName = this.displayName();
  3359      if (!contract[displayName]) {
  3360          contract[displayName] = execute;
  3361      }
  3362      contract[displayName][this.typeName()] = this.execute.bind(this, contract);
  3363  };
  3364  
  3365  module.exports = SolidityEvent;
  3366  
  3367  
  3368  },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":43}],28:[function(require,module,exports){
  3369  var formatters = require('./formatters');
  3370  var utils = require('./../utils/utils');
  3371  var Method = require('./method');
  3372  var Property = require('./property');
  3373  
  3374  // TODO: refactor, so the input params are not altered.
  3375  // it's necessary to make same 'extension' work with multiple providers
  3376  var extend = function (web3) {
  3377      /* jshint maxcomplexity:5 */
  3378      var ex = function (extension) {
  3379  
  3380          var extendedObject;
  3381          if (extension.property) {
  3382              if (!web3[extension.property]) {
  3383                  web3[extension.property] = {};
  3384              }
  3385              extendedObject = web3[extension.property];
  3386          } else {
  3387              extendedObject = web3;
  3388          }
  3389  
  3390          if (extension.methods) {
  3391              extension.methods.forEach(function (method) {
  3392                  method.attachToObject(extendedObject);
  3393                  method.setRequestManager(web3._requestManager);
  3394              });
  3395          }
  3396  
  3397          if (extension.properties) {
  3398              extension.properties.forEach(function (property) {
  3399                  property.attachToObject(extendedObject);
  3400                  property.setRequestManager(web3._requestManager);
  3401              });
  3402          }
  3403      };
  3404  
  3405      ex.formatters = formatters; 
  3406      ex.utils = utils;
  3407      ex.Method = Method;
  3408      ex.Property = Property;
  3409  
  3410      return ex;
  3411  };
  3412  
  3413  
  3414  
  3415  module.exports = extend;
  3416  
  3417  
  3418  },{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":45}],29:[function(require,module,exports){
  3419  /*
  3420      This file is part of web3.js.
  3421  
  3422      web3.js is free software: you can redistribute it and/or modify
  3423      it under the terms of the GNU Lesser General Public License as published by
  3424      the Free Software Foundation, either version 3 of the License, or
  3425      (at your option) any later version.
  3426  
  3427      web3.js is distributed in the hope that it will be useful,
  3428      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3429      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3430      GNU Lesser General Public License for more details.
  3431  
  3432      You should have received a copy of the GNU Lesser General Public License
  3433      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3434  */
  3435  /** @file filter.js
  3436   * @authors:
  3437   *   Jeffrey Wilcke <jeff@ethdev.com>
  3438   *   Marek Kotewicz <marek@ethdev.com>
  3439   *   Marian Oancea <marian@ethdev.com>
  3440   *   Fabian Vogelsteller <fabian@ethdev.com>
  3441   *   Gav Wood <g@ethdev.com>
  3442   * @date 2014
  3443   */
  3444  
  3445  var formatters = require('./formatters');
  3446  var utils = require('../utils/utils');
  3447  
  3448  /**
  3449  * Converts a given topic to a hex string, but also allows null values.
  3450  *
  3451  * @param {Mixed} value
  3452  * @return {String}
  3453  */
  3454  var toTopic = function(value){
  3455  
  3456      if(value === null || typeof value === 'undefined')
  3457          return null;
  3458  
  3459      value = String(value);
  3460  
  3461      if(value.indexOf('0x') === 0)
  3462          return value;
  3463      else
  3464          return utils.fromUtf8(value);
  3465  };
  3466  
  3467  /// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
  3468  /// @param should be string or object
  3469  /// @returns options string or object
  3470  var getOptions = function (options, type) {
  3471      /*jshint maxcomplexity: 6 */
  3472  
  3473      if (utils.isString(options)) {
  3474          return options;
  3475      }
  3476  
  3477      options = options || {};
  3478  
  3479  
  3480      switch(type) {
  3481          case 'eth':
  3482  
  3483              // make sure topics, get converted to hex
  3484              options.topics = options.topics || [];
  3485              options.topics = options.topics.map(function(topic){
  3486                  return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
  3487              });
  3488  
  3489              return {
  3490                  topics: options.topics,
  3491                  from: options.from,
  3492                  to: options.to,
  3493                  address: options.address,
  3494                  fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
  3495                  toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
  3496              };
  3497          case 'shh':
  3498              return options;
  3499      }
  3500  };
  3501  
  3502  /**
  3503  Adds the callback and sets up the methods, to iterate over the results.
  3504  
  3505  @method getLogsAtStart
  3506  @param {Object} self
  3507  @param {function} callback
  3508  */
  3509  var getLogsAtStart = function(self, callback){
  3510      // call getFilterLogs for the first watch callback start
  3511      if (!utils.isString(self.options)) {
  3512          self.get(function (err, messages) {
  3513              // don't send all the responses to all the watches again... just to self one
  3514              if (err) {
  3515                  callback(err);
  3516              }
  3517  
  3518              if(utils.isArray(messages)) {
  3519                  messages.forEach(function (message) {
  3520                      callback(null, message);
  3521                  });
  3522              }
  3523          });
  3524      }
  3525  };
  3526  
  3527  /**
  3528  Adds the callback and sets up the methods, to iterate over the results.
  3529  
  3530  @method pollFilter
  3531  @param {Object} self
  3532  */
  3533  var pollFilter = function(self) {
  3534  
  3535      var onMessage = function (error, messages) {
  3536          if (error) {
  3537              return self.callbacks.forEach(function (callback) {
  3538                  callback(error);
  3539              });
  3540          }
  3541  
  3542          if(utils.isArray(messages)) {
  3543              messages.forEach(function (message) {
  3544                  message = self.formatter ? self.formatter(message) : message;
  3545                  self.callbacks.forEach(function (callback) {
  3546                      callback(null, message);
  3547                  });
  3548              });
  3549          }
  3550      };
  3551  
  3552      self.requestManager.startPolling({
  3553          method: self.implementation.poll.call,
  3554          params: [self.filterId],
  3555      }, self.filterId, onMessage, self.stopWatching.bind(self));
  3556  
  3557  };
  3558  
  3559  var Filter = function (options, type, requestManager, methods, formatter, callback, filterCreationErrorCallback) {
  3560      var self = this;
  3561      var implementation = {};
  3562      methods.forEach(function (method) {
  3563          method.setRequestManager(requestManager);
  3564          method.attachToObject(implementation);
  3565      });
  3566      this.requestManager = requestManager;
  3567      this.options = getOptions(options, type);
  3568      this.implementation = implementation;
  3569      this.filterId = null;
  3570      this.callbacks = [];
  3571      this.getLogsCallbacks = [];
  3572      this.pollFilters = [];
  3573      this.formatter = formatter;
  3574      this.implementation.newFilter(this.options, function(error, id){
  3575          if(error) {
  3576              self.callbacks.forEach(function(cb){
  3577                  cb(error);
  3578              });
  3579              if (typeof filterCreationErrorCallback === 'function') {
  3580                filterCreationErrorCallback(error);
  3581              }
  3582          } else {
  3583              self.filterId = id;
  3584  
  3585              // check if there are get pending callbacks as a consequence
  3586              // of calling get() with filterId unassigned.
  3587              self.getLogsCallbacks.forEach(function (cb){
  3588                  self.get(cb);
  3589              });
  3590              self.getLogsCallbacks = [];
  3591  
  3592              // get filter logs for the already existing watch calls
  3593              self.callbacks.forEach(function(cb){
  3594                  getLogsAtStart(self, cb);
  3595              });
  3596              if(self.callbacks.length > 0)
  3597                  pollFilter(self);
  3598  
  3599              // start to watch immediately
  3600              if(typeof callback === 'function') {
  3601                  return self.watch(callback);
  3602              }
  3603          }
  3604      });
  3605  
  3606      return this;
  3607  };
  3608  
  3609  Filter.prototype.watch = function (callback) {
  3610      this.callbacks.push(callback);
  3611  
  3612      if(this.filterId) {
  3613          getLogsAtStart(this, callback);
  3614          pollFilter(this);
  3615      }
  3616  
  3617      return this;
  3618  };
  3619  
  3620  Filter.prototype.stopWatching = function (callback) {
  3621      this.requestManager.stopPolling(this.filterId);
  3622      this.callbacks = [];
  3623      // remove filter async
  3624      if (callback) {
  3625          this.implementation.uninstallFilter(this.filterId, callback);
  3626      } else {
  3627          return this.implementation.uninstallFilter(this.filterId);
  3628      }
  3629  };
  3630  
  3631  Filter.prototype.get = function (callback) {
  3632      var self = this;
  3633      if (utils.isFunction(callback)) {
  3634          if (this.filterId === null) {
  3635              // If filterId is not set yet, call it back
  3636              // when newFilter() assigns it.
  3637              this.getLogsCallbacks.push(callback);
  3638          } else {
  3639              this.implementation.getLogs(this.filterId, function(err, res){
  3640                  if (err) {
  3641                      callback(err);
  3642                  } else {
  3643                      callback(null, res.map(function (log) {
  3644                          return self.formatter ? self.formatter(log) : log;
  3645                      }));
  3646                  }
  3647              });
  3648          }
  3649      } else {
  3650          if (this.filterId === null) {
  3651              throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.');
  3652          }
  3653          var logs = this.implementation.getLogs(this.filterId);
  3654          return logs.map(function (log) {
  3655              return self.formatter ? self.formatter(log) : log;
  3656          });
  3657      }
  3658  
  3659      return this;
  3660  };
  3661  
  3662  module.exports = Filter;
  3663  
  3664  
  3665  },{"../utils/utils":20,"./formatters":30}],30:[function(require,module,exports){
  3666  'use strict'
  3667  
  3668  /*
  3669      This file is part of web3.js.
  3670  
  3671      web3.js is free software: you can redistribute it and/or modify
  3672      it under the terms of the GNU Lesser General Public License as published by
  3673      the Free Software Foundation, either version 3 of the License, or
  3674      (at your option) any later version.
  3675  
  3676      web3.js is distributed in the hope that it will be useful,
  3677      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3678      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3679      GNU Lesser General Public License for more details.
  3680  
  3681      You should have received a copy of the GNU Lesser General Public License
  3682      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3683  */
  3684  /**
  3685   * @file formatters.js
  3686   * @author Marek Kotewicz <marek@ethdev.com>
  3687   * @author Fabian Vogelsteller <fabian@ethdev.com>
  3688   * @date 2015
  3689   */
  3690  
  3691  var utils = require('../utils/utils');
  3692  var config = require('../utils/config');
  3693  var Iban = require('./iban');
  3694  
  3695  /**
  3696   * Should the format output to a big number
  3697   *
  3698   * @method outputBigNumberFormatter
  3699   * @param {String|Number|BigNumber}
  3700   * @returns {BigNumber} object
  3701   */
  3702  var outputBigNumberFormatter = function (number) {
  3703      return utils.toBigNumber(number);
  3704  };
  3705  
  3706  var isPredefinedBlockNumber = function (blockNumber) {
  3707      return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
  3708  };
  3709  
  3710  var inputDefaultBlockNumberFormatter = function (blockNumber) {
  3711      if (blockNumber === undefined) {
  3712          return config.defaultBlock;
  3713      }
  3714      return inputBlockNumberFormatter(blockNumber);
  3715  };
  3716  
  3717  var inputBlockNumberFormatter = function (blockNumber) {
  3718      if (blockNumber === undefined) {
  3719          return undefined;
  3720      } else if (isPredefinedBlockNumber(blockNumber)) {
  3721          return blockNumber;
  3722      }
  3723      return utils.toHex(blockNumber);
  3724  };
  3725  
  3726  /**
  3727   * Formats the input of a transaction and converts all values to HEX
  3728   *
  3729   * @method inputCallFormatter
  3730   * @param {Object} transaction options
  3731   * @returns object
  3732  */
  3733  var inputCallFormatter = function (options){
  3734  
  3735      options.from = options.from || config.defaultAccount;
  3736  
  3737      if (options.from) {
  3738          options.from = inputAddressFormatter(options.from);
  3739      }
  3740  
  3741      if (options.to) { // it might be contract creation
  3742          options.to = inputAddressFormatter(options.to);
  3743      }
  3744  
  3745      ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3746          return options[key] !== undefined;
  3747      }).forEach(function(key){
  3748          options[key] = utils.fromDecimal(options[key]);
  3749      });
  3750  
  3751      return options;
  3752  };
  3753  
  3754  /**
  3755   * Formats the input of a transaction and converts all values to HEX
  3756   *
  3757   * @method inputTransactionFormatter
  3758   * @param {Object} transaction options
  3759   * @returns object
  3760  */
  3761  var inputTransactionFormatter = function (options){
  3762  
  3763      options.from = options.from || config.defaultAccount;
  3764      options.from = inputAddressFormatter(options.from);
  3765  
  3766      if (options.to) { // it might be contract creation
  3767          options.to = inputAddressFormatter(options.to);
  3768      }
  3769  
  3770      ['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 output of a transaction to its proper values
  3781   *
  3782   * @method outputTransactionFormatter
  3783   * @param {Object} tx
  3784   * @returns {Object}
  3785  */
  3786  var outputTransactionFormatter = function (tx){
  3787      if(tx.blockNumber !== null)
  3788          tx.blockNumber = utils.toDecimal(tx.blockNumber);
  3789      if(tx.transactionIndex !== null)
  3790          tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
  3791      tx.nonce = utils.toDecimal(tx.nonce);
  3792      tx.gas = utils.toDecimal(tx.gas);
  3793      tx.gasPrice = utils.toBigNumber(tx.gasPrice);
  3794      tx.value = utils.toBigNumber(tx.value);
  3795      return tx;
  3796  };
  3797  
  3798  /**
  3799   * Formats the output of a transaction receipt to its proper values
  3800   *
  3801   * @method outputTransactionReceiptFormatter
  3802   * @param {Object} receipt
  3803   * @returns {Object}
  3804  */
  3805  var outputTransactionReceiptFormatter = function (receipt){
  3806      if(receipt.blockNumber !== null)
  3807          receipt.blockNumber = utils.toDecimal(receipt.blockNumber);
  3808      if(receipt.transactionIndex !== null)
  3809          receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
  3810      receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
  3811      receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
  3812  
  3813      if(utils.isArray(receipt.logs)) {
  3814          receipt.logs = receipt.logs.map(function(log){
  3815              return outputLogFormatter(log);
  3816          });
  3817      }
  3818  
  3819      return receipt;
  3820  };
  3821  
  3822  /**
  3823   * Formats the output of a block to its proper values
  3824   *
  3825   * @method outputBlockFormatter
  3826   * @param {Object} block
  3827   * @returns {Object}
  3828  */
  3829  var outputBlockFormatter = function(block) {
  3830  
  3831      // transform to number
  3832      block.gasLimit = utils.toDecimal(block.gasLimit);
  3833      block.gasUsed = utils.toDecimal(block.gasUsed);
  3834      block.size = utils.toDecimal(block.size);
  3835      block.timestamp = utils.toDecimal(block.timestamp);
  3836      if(block.number !== null)
  3837          block.number = utils.toDecimal(block.number);
  3838  
  3839      block.difficulty = utils.toBigNumber(block.difficulty);
  3840      block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
  3841  
  3842      if (utils.isArray(block.transactions)) {
  3843          block.transactions.forEach(function(item){
  3844              if(!utils.isString(item))
  3845                  return outputTransactionFormatter(item);
  3846          });
  3847      }
  3848  
  3849      return block;
  3850  };
  3851  
  3852  /**
  3853   * Formats the output of a log
  3854   *
  3855   * @method outputLogFormatter
  3856   * @param {Object} log object
  3857   * @returns {Object} log
  3858  */
  3859  var outputLogFormatter = function(log) {
  3860      if(log.blockNumber)
  3861          log.blockNumber = utils.toDecimal(log.blockNumber);
  3862      if(log.transactionIndex)
  3863          log.transactionIndex = utils.toDecimal(log.transactionIndex);
  3864      if(log.logIndex)
  3865          log.logIndex = utils.toDecimal(log.logIndex);
  3866  
  3867      return log;
  3868  };
  3869  
  3870  /**
  3871   * Formats the input of a whisper post and converts all values to HEX
  3872   *
  3873   * @method inputPostFormatter
  3874   * @param {Object} transaction object
  3875   * @returns {Object}
  3876  */
  3877  var inputPostFormatter = function(post) {
  3878  
  3879      // post.payload = utils.toHex(post.payload);
  3880      post.ttl = utils.fromDecimal(post.ttl);
  3881      post.workToProve = utils.fromDecimal(post.workToProve);
  3882      post.priority = utils.fromDecimal(post.priority);
  3883  
  3884      // fallback
  3885      if (!utils.isArray(post.topics)) {
  3886          post.topics = post.topics ? [post.topics] : [];
  3887      }
  3888  
  3889      // format the following options
  3890      post.topics = post.topics.map(function(topic){
  3891          // convert only if not hex
  3892          return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);
  3893      });
  3894  
  3895      return post;
  3896  };
  3897  
  3898  /**
  3899   * Formats the output of a received post message
  3900   *
  3901   * @method outputPostFormatter
  3902   * @param {Object}
  3903   * @returns {Object}
  3904   */
  3905  var outputPostFormatter = function(post){
  3906  
  3907      post.expiry = utils.toDecimal(post.expiry);
  3908      post.sent = utils.toDecimal(post.sent);
  3909      post.ttl = utils.toDecimal(post.ttl);
  3910      post.workProved = utils.toDecimal(post.workProved);
  3911      // post.payloadRaw = post.payload;
  3912      // post.payload = utils.toAscii(post.payload);
  3913  
  3914      // if (utils.isJson(post.payload)) {
  3915      //     post.payload = JSON.parse(post.payload);
  3916      // }
  3917  
  3918      // format the following options
  3919      if (!post.topics) {
  3920          post.topics = [];
  3921      }
  3922      post.topics = post.topics.map(function(topic){
  3923          return utils.toAscii(topic);
  3924      });
  3925  
  3926      return post;
  3927  };
  3928  
  3929  var inputAddressFormatter = function (address) {
  3930      var iban = new Iban(address);
  3931      if (iban.isValid() && iban.isDirect()) {
  3932          return '0x' + iban.address();
  3933      } else if (utils.isStrictAddress(address)) {
  3934          return address;
  3935      } else if (utils.isAddress(address)) {
  3936          return '0x' + address;
  3937      }
  3938      throw new Error('invalid address');
  3939  };
  3940  
  3941  
  3942  var outputSyncingFormatter = function(result) {
  3943      if (!result) {
  3944          return result;
  3945      }
  3946  
  3947      result.startingBlock = utils.toDecimal(result.startingBlock);
  3948      result.currentBlock = utils.toDecimal(result.currentBlock);
  3949      result.highestBlock = utils.toDecimal(result.highestBlock);
  3950      if (result.knownStates) {
  3951          result.knownStates = utils.toDecimal(result.knownStates);
  3952          result.pulledStates = utils.toDecimal(result.pulledStates);
  3953      }
  3954  
  3955      return result;
  3956  };
  3957  
  3958  module.exports = {
  3959      inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
  3960      inputBlockNumberFormatter: inputBlockNumberFormatter,
  3961      inputCallFormatter: inputCallFormatter,
  3962      inputTransactionFormatter: inputTransactionFormatter,
  3963      inputAddressFormatter: inputAddressFormatter,
  3964      inputPostFormatter: inputPostFormatter,
  3965      outputBigNumberFormatter: outputBigNumberFormatter,
  3966      outputTransactionFormatter: outputTransactionFormatter,
  3967      outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
  3968      outputBlockFormatter: outputBlockFormatter,
  3969      outputLogFormatter: outputLogFormatter,
  3970      outputPostFormatter: outputPostFormatter,
  3971      outputSyncingFormatter: outputSyncingFormatter
  3972  };
  3973  
  3974  
  3975  },{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(require,module,exports){
  3976  /*
  3977      This file is part of web3.js.
  3978  
  3979      web3.js is free software: you can redistribute it and/or modify
  3980      it under the terms of the GNU Lesser General Public License as published by
  3981      the Free Software Foundation, either version 3 of the License, or
  3982      (at your option) any later version.
  3983  
  3984      web3.js is distributed in the hope that it will be useful,
  3985      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3986      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3987      GNU Lesser General Public License for more details.
  3988  
  3989      You should have received a copy of the GNU Lesser General Public License
  3990      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3991  */
  3992  /**
  3993   * @file function.js
  3994   * @author Marek Kotewicz <marek@ethdev.com>
  3995   * @date 2015
  3996   */
  3997  
  3998  var coder = require('../solidity/coder');
  3999  var utils = require('../utils/utils');
  4000  var errors = require('./errors');
  4001  var formatters = require('./formatters');
  4002  var sha3 = require('../utils/sha3');
  4003  
  4004  /**
  4005   * This prototype should be used to call/sendTransaction to solidity functions
  4006   */
  4007  var SolidityFunction = function (eth, json, address) {
  4008      this._eth = eth;
  4009      this._inputTypes = json.inputs.map(function (i) {
  4010          return i.type;
  4011      });
  4012      this._outputTypes = json.outputs.map(function (i) {
  4013          return i.type;
  4014      });
  4015      this._constant = json.constant;
  4016      this._payable = json.payable;
  4017      this._name = utils.transformToFullName(json);
  4018      this._address = address;
  4019  };
  4020  
  4021  SolidityFunction.prototype.extractCallback = function (args) {
  4022      if (utils.isFunction(args[args.length - 1])) {
  4023          return args.pop(); // modify the args array!
  4024      }
  4025  };
  4026  
  4027  SolidityFunction.prototype.extractDefaultBlock = function (args) {
  4028      if (args.length > this._inputTypes.length && !utils.isObject(args[args.length -1])) {
  4029          return formatters.inputDefaultBlockNumberFormatter(args.pop()); // modify the args array!
  4030      }
  4031  };
  4032  
  4033  /**
  4034   * Should be called to check if the number of arguments is correct
  4035   *
  4036   * @method validateArgs
  4037   * @param {Array} arguments
  4038   * @throws {Error} if it is not
  4039   */
  4040  SolidityFunction.prototype.validateArgs = function (args) {
  4041      var inputArgs = args.filter(function (a) {
  4042        // filter the options object but not arguments that are arrays
  4043        return !( (utils.isObject(a) === true) &&
  4044                  (utils.isArray(a) === false) &&
  4045                  (utils.isBigNumber(a) === false)
  4046                );
  4047      });
  4048      if (inputArgs.length !== this._inputTypes.length) {
  4049          throw errors.InvalidNumberOfSolidityArgs();
  4050      }
  4051  };
  4052  
  4053  /**
  4054   * Should be used to create payload from arguments
  4055   *
  4056   * @method toPayload
  4057   * @param {Array} solidity function params
  4058   * @param {Object} optional payload options
  4059   */
  4060  SolidityFunction.prototype.toPayload = function (args) {
  4061      var options = {};
  4062      if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
  4063          options = args[args.length - 1];
  4064      }
  4065      this.validateArgs(args);
  4066      options.to = this._address;
  4067      options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
  4068      return options;
  4069  };
  4070  
  4071  /**
  4072   * Should be used to get function signature
  4073   *
  4074   * @method signature
  4075   * @return {String} function signature
  4076   */
  4077  SolidityFunction.prototype.signature = function () {
  4078      return sha3(this._name).slice(0, 8);
  4079  };
  4080  
  4081  
  4082  SolidityFunction.prototype.unpackOutput = function (output) {
  4083      if (!output) {
  4084          return;
  4085      }
  4086  
  4087      output = output.length >= 2 ? output.slice(2) : output;
  4088      var result = coder.decodeParams(this._outputTypes, output);
  4089      return result.length === 1 ? result[0] : result;
  4090  };
  4091  
  4092  /**
  4093   * Calls a contract function.
  4094   *
  4095   * @method call
  4096   * @param {...Object} Contract function arguments
  4097   * @param {function} If the last argument is a function, the contract function
  4098   *   call will be asynchronous, and the callback will be passed the
  4099   *   error and result.
  4100   * @return {String} output bytes
  4101   */
  4102  SolidityFunction.prototype.call = function () {
  4103      var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4104      var callback = this.extractCallback(args);
  4105      var defaultBlock = this.extractDefaultBlock(args);
  4106      var payload = this.toPayload(args);
  4107  
  4108  
  4109      if (!callback) {
  4110          var output = this._eth.call(payload, defaultBlock);
  4111          return this.unpackOutput(output);
  4112      }
  4113  
  4114      var self = this;
  4115      this._eth.call(payload, defaultBlock, function (error, output) {
  4116          if (error) return callback(error, null);
  4117  
  4118          var unpacked = null;
  4119          try {
  4120              unpacked = self.unpackOutput(output);
  4121          }
  4122          catch (e) {
  4123              error = e;
  4124          }
  4125  
  4126          callback(error, unpacked);
  4127      });
  4128  };
  4129  
  4130  /**
  4131   * Should be used to sendTransaction to solidity function
  4132   *
  4133   * @method sendTransaction
  4134   */
  4135  SolidityFunction.prototype.sendTransaction = function () {
  4136      var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4137      var callback = this.extractCallback(args);
  4138      var payload = this.toPayload(args);
  4139  
  4140      if (payload.value > 0 && !this._payable) {
  4141          throw new Error('Cannot send value to non-payable function');
  4142      }
  4143  
  4144      if (!callback) {
  4145          return this._eth.sendTransaction(payload);
  4146      }
  4147  
  4148      this._eth.sendTransaction(payload, callback);
  4149  };
  4150  
  4151  /**
  4152   * Should be used to estimateGas of solidity function
  4153   *
  4154   * @method estimateGas
  4155   */
  4156  SolidityFunction.prototype.estimateGas = function () {
  4157      var args = Array.prototype.slice.call(arguments);
  4158      var callback = this.extractCallback(args);
  4159      var payload = this.toPayload(args);
  4160  
  4161      if (!callback) {
  4162          return this._eth.estimateGas(payload);
  4163      }
  4164  
  4165      this._eth.estimateGas(payload, callback);
  4166  };
  4167  
  4168  /**
  4169   * Return the encoded data of the call
  4170   *
  4171   * @method getData
  4172   * @return {String} the encoded data
  4173   */
  4174  SolidityFunction.prototype.getData = function () {
  4175      var args = Array.prototype.slice.call(arguments);
  4176      var payload = this.toPayload(args);
  4177  
  4178      return payload.data;
  4179  };
  4180  
  4181  /**
  4182   * Should be used to get function display name
  4183   *
  4184   * @method displayName
  4185   * @return {String} display name of the function
  4186   */
  4187  SolidityFunction.prototype.displayName = function () {
  4188      return utils.extractDisplayName(this._name);
  4189  };
  4190  
  4191  /**
  4192   * Should be used to get function type name
  4193   *
  4194   * @method typeName
  4195   * @return {String} type name of the function
  4196   */
  4197  SolidityFunction.prototype.typeName = function () {
  4198      return utils.extractTypeName(this._name);
  4199  };
  4200  
  4201  /**
  4202   * Should be called to get rpc requests from solidity function
  4203   *
  4204   * @method request
  4205   * @returns {Object}
  4206   */
  4207  SolidityFunction.prototype.request = function () {
  4208      var args = Array.prototype.slice.call(arguments);
  4209      var callback = this.extractCallback(args);
  4210      var payload = this.toPayload(args);
  4211      var format = this.unpackOutput.bind(this);
  4212  
  4213      return {
  4214          method: this._constant ? 'eth_call' : 'eth_sendTransaction',
  4215          callback: callback,
  4216          params: [payload],
  4217          format: format
  4218      };
  4219  };
  4220  
  4221  /**
  4222   * Should be called to execute function
  4223   *
  4224   * @method execute
  4225   */
  4226  SolidityFunction.prototype.execute = function () {
  4227      var transaction = !this._constant;
  4228  
  4229      // send transaction
  4230      if (transaction) {
  4231          return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
  4232      }
  4233  
  4234      // call
  4235      return this.call.apply(this, Array.prototype.slice.call(arguments));
  4236  };
  4237  
  4238  /**
  4239   * Should be called to attach function to contract
  4240   *
  4241   * @method attachToContract
  4242   * @param {Contract}
  4243   */
  4244  SolidityFunction.prototype.attachToContract = function (contract) {
  4245      var execute = this.execute.bind(this);
  4246      execute.request = this.request.bind(this);
  4247      execute.call = this.call.bind(this);
  4248      execute.sendTransaction = this.sendTransaction.bind(this);
  4249      execute.estimateGas = this.estimateGas.bind(this);
  4250      execute.getData = this.getData.bind(this);
  4251      var displayName = this.displayName();
  4252      if (!contract[displayName]) {
  4253          contract[displayName] = execute;
  4254      }
  4255      contract[displayName][this.typeName()] = execute; // circular!!!!
  4256  };
  4257  
  4258  module.exports = SolidityFunction;
  4259  
  4260  },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./errors":26,"./formatters":30}],32:[function(require,module,exports){
  4261  /*
  4262      This file is part of web3.js.
  4263  
  4264      web3.js is free software: you can redistribute it and/or modify
  4265      it under the terms of the GNU Lesser General Public License as published by
  4266      the Free Software Foundation, either version 3 of the License, or
  4267      (at your option) any later version.
  4268  
  4269      web3.js is distributed in the hope that it will be useful,
  4270      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4271      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4272      GNU Lesser General Public License for more details.
  4273  
  4274      You should have received a copy of the GNU Lesser General Public License
  4275      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4276  */
  4277  /** @file httpprovider.js
  4278   * @authors:
  4279   *   Marek Kotewicz <marek@ethdev.com>
  4280   *   Marian Oancea <marian@ethdev.com>
  4281   *   Fabian Vogelsteller <fabian@ethdev.com>
  4282   * @date 2015
  4283   */
  4284  
  4285  var errors = require('./errors');
  4286  
  4287  // workaround to use httpprovider in different envs
  4288  
  4289  // browser
  4290  if (typeof window !== 'undefined' && window.XMLHttpRequest) {
  4291    XMLHttpRequest = window.XMLHttpRequest; // jshint ignore: line
  4292  // node
  4293  } else {
  4294    XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore: line
  4295  }
  4296  
  4297  var XHR2 = require('xhr2'); // jshint ignore: line
  4298  
  4299  /**
  4300   * HttpProvider should be used to send rpc calls over http
  4301   */
  4302  var HttpProvider = function (host, timeout, user, password) {
  4303    this.host = host || 'http://localhost:8545';
  4304    this.timeout = timeout || 0;
  4305    this.user = user;
  4306    this.password = password;
  4307  };
  4308  
  4309  /**
  4310   * Should be called to prepare new XMLHttpRequest
  4311   *
  4312   * @method prepareRequest
  4313   * @param {Boolean} true if request should be async
  4314   * @return {XMLHttpRequest} object
  4315   */
  4316  HttpProvider.prototype.prepareRequest = function (async) {
  4317    var request;
  4318  
  4319    if (async) {
  4320      request = new XHR2();
  4321      request.timeout = this.timeout;
  4322    } else {
  4323      request = new XMLHttpRequest();
  4324    }
  4325  
  4326    request.open('POST', this.host, async);
  4327    if (this.user && this.password) {
  4328      var auth = 'Basic ' + new Buffer(this.user + ':' + this.password).toString('base64');
  4329      request.setRequestHeader('Authorization', auth);
  4330    } request.setRequestHeader('Content-Type', 'application/json');
  4331    return request;
  4332  };
  4333  
  4334  /**
  4335   * Should be called to make sync request
  4336   *
  4337   * @method send
  4338   * @param {Object} payload
  4339   * @return {Object} result
  4340   */
  4341  HttpProvider.prototype.send = function (payload) {
  4342    var request = this.prepareRequest(false);
  4343  
  4344    try {
  4345      request.send(JSON.stringify(payload));
  4346    } catch (error) {
  4347      throw errors.InvalidConnection(this.host);
  4348    }
  4349  
  4350    var result = request.responseText;
  4351  
  4352    try {
  4353      result = JSON.parse(result);
  4354    } catch (e) {
  4355      throw errors.InvalidResponse(request.responseText);
  4356    }
  4357  
  4358    return result;
  4359  };
  4360  
  4361  /**
  4362   * Should be used to make async request
  4363   *
  4364   * @method sendAsync
  4365   * @param {Object} payload
  4366   * @param {Function} callback triggered on end with (err, result)
  4367   */
  4368  HttpProvider.prototype.sendAsync = function (payload, callback) {
  4369    var request = this.prepareRequest(true);
  4370  
  4371    request.onreadystatechange = function () {
  4372      if (request.readyState === 4 && request.timeout !== 1) {
  4373        var result = request.responseText;
  4374        var error = null;
  4375  
  4376        try {
  4377          result = JSON.parse(result);
  4378        } catch (e) {
  4379          error = errors.InvalidResponse(request.responseText);
  4380        }
  4381  
  4382        callback(error, result);
  4383      }
  4384    };
  4385  
  4386    request.ontimeout = function () {
  4387      callback(errors.ConnectionTimeout(this.timeout));
  4388    };
  4389  
  4390    try {
  4391      request.send(JSON.stringify(payload));
  4392    } catch (error) {
  4393      callback(errors.InvalidConnection(this.host));
  4394    }
  4395  };
  4396  
  4397  /**
  4398   * Synchronously tries to make Http request
  4399   *
  4400   * @method isConnected
  4401   * @return {Boolean} returns true if request haven't failed. Otherwise false
  4402   */
  4403  HttpProvider.prototype.isConnected = function () {
  4404    try {
  4405      this.send({
  4406        id: 9999999999,
  4407        jsonrpc: '2.0',
  4408        method: 'net_listening',
  4409        params: []
  4410      });
  4411      return true;
  4412    } catch (e) {
  4413      return false;
  4414    }
  4415  };
  4416  
  4417  module.exports = HttpProvider;
  4418  
  4419  },{"./errors":26,"xhr2":86,"xmlhttprequest":17}],33:[function(require,module,exports){
  4420  /*
  4421      This file is part of web3.js.
  4422  
  4423      web3.js is free software: you can redistribute it and/or modify
  4424      it under the terms of the GNU Lesser General Public License as published by
  4425      the Free Software Foundation, either version 3 of the License, or
  4426      (at your option) any later version.
  4427  
  4428      web3.js is distributed in the hope that it will be useful,
  4429      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4430      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4431      GNU Lesser General Public License for more details.
  4432  
  4433      You should have received a copy of the GNU Lesser General Public License
  4434      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4435  */
  4436  /** 
  4437   * @file iban.js
  4438   * @author Marek Kotewicz <marek@ethdev.com>
  4439   * @date 2015
  4440   */
  4441  
  4442  var BigNumber = require('bignumber.js');
  4443  
  4444  var padLeft = function (string, bytes) {
  4445      var result = string;
  4446      while (result.length < bytes * 2) {
  4447          result = '0' + result;
  4448      }
  4449      return result;
  4450  };
  4451  
  4452  /**
  4453   * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to
  4454   * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.
  4455   *
  4456   * @method iso13616Prepare
  4457   * @param {String} iban the IBAN
  4458   * @returns {String} the prepared IBAN
  4459   */
  4460  var iso13616Prepare = function (iban) {
  4461      var A = 'A'.charCodeAt(0);
  4462      var Z = 'Z'.charCodeAt(0);
  4463  
  4464      iban = iban.toUpperCase();
  4465      iban = iban.substr(4) + iban.substr(0,4);
  4466  
  4467      return iban.split('').map(function(n){
  4468          var code = n.charCodeAt(0);
  4469          if (code >= A && code <= Z){
  4470              // A = 10, B = 11, ... Z = 35
  4471              return code - A + 10;
  4472          } else {
  4473              return n;
  4474          }
  4475      }).join('');
  4476  };
  4477  
  4478  /**
  4479   * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064.
  4480   *
  4481   * @method mod9710
  4482   * @param {String} iban
  4483   * @returns {Number}
  4484   */
  4485  var mod9710 = function (iban) {
  4486      var remainder = iban,
  4487          block;
  4488  
  4489      while (remainder.length > 2){
  4490          block = remainder.slice(0, 9);
  4491          remainder = parseInt(block, 10) % 97 + remainder.slice(block.length);
  4492      }
  4493  
  4494      return parseInt(remainder, 10) % 97;
  4495  };
  4496  
  4497  /**
  4498   * This prototype should be used to create iban object from iban correct string
  4499   *
  4500   * @param {String} iban
  4501   */
  4502  var Iban = function (iban) {
  4503      this._iban = iban;
  4504  };
  4505  
  4506  /**
  4507   * This method should be used to create iban object from ethereum address
  4508   *
  4509   * @method fromAddress
  4510   * @param {String} address
  4511   * @return {Iban} the IBAN object
  4512   */
  4513  Iban.fromAddress = function (address) {
  4514      var asBn = new BigNumber(address, 16);
  4515      var base36 = asBn.toString(36);
  4516      var padded = padLeft(base36, 15);
  4517      return Iban.fromBban(padded.toUpperCase());
  4518  };
  4519  
  4520  /**
  4521   * Convert the passed BBAN to an IBAN for this country specification.
  4522   * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>.
  4523   * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
  4524   *
  4525   * @method fromBban
  4526   * @param {String} bban the BBAN to convert to IBAN
  4527   * @returns {Iban} the IBAN object
  4528   */
  4529  Iban.fromBban = function (bban) {
  4530      var countryCode = 'XE';
  4531  
  4532      var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban));
  4533      var checkDigit = ('0' + (98 - remainder)).slice(-2);
  4534  
  4535      return new Iban(countryCode + checkDigit + bban);
  4536  };
  4537  
  4538  /**
  4539   * Should be used to create IBAN object for given institution and identifier
  4540   *
  4541   * @method createIndirect
  4542   * @param {Object} options, required options are "institution" and "identifier"
  4543   * @return {Iban} the IBAN object
  4544   */
  4545  Iban.createIndirect = function (options) {
  4546      return Iban.fromBban('ETH' + options.institution + options.identifier);
  4547  };
  4548  
  4549  /**
  4550   * Thos method should be used to check if given string is valid iban object
  4551   *
  4552   * @method isValid
  4553   * @param {String} iban string
  4554   * @return {Boolean} true if it is valid IBAN
  4555   */
  4556  Iban.isValid = function (iban) {
  4557      var i = new Iban(iban);
  4558      return i.isValid();
  4559  };
  4560  
  4561  /**
  4562   * Should be called to check if iban is correct
  4563   *
  4564   * @method isValid
  4565   * @returns {Boolean} true if it is, otherwise false
  4566   */
  4567  Iban.prototype.isValid = function () {
  4568      return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) &&
  4569          mod9710(iso13616Prepare(this._iban)) === 1;
  4570  };
  4571  
  4572  /**
  4573   * Should be called to check if iban number is direct
  4574   *
  4575   * @method isDirect
  4576   * @returns {Boolean} true if it is, otherwise false
  4577   */
  4578  Iban.prototype.isDirect = function () {
  4579      return this._iban.length === 34 || this._iban.length === 35;
  4580  };
  4581  
  4582  /**
  4583   * Should be called to check if iban number if indirect
  4584   *
  4585   * @method isIndirect
  4586   * @returns {Boolean} true if it is, otherwise false
  4587   */
  4588  Iban.prototype.isIndirect = function () {
  4589      return this._iban.length === 20;
  4590  };
  4591  
  4592  /**
  4593   * Should be called to get iban checksum
  4594   * Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
  4595   *
  4596   * @method checksum
  4597   * @returns {String} checksum
  4598   */
  4599  Iban.prototype.checksum = function () {
  4600      return this._iban.substr(2, 2);
  4601  };
  4602  
  4603  /**
  4604   * Should be called to get institution identifier
  4605   * eg. XREG
  4606   *
  4607   * @method institution
  4608   * @returns {String} institution identifier
  4609   */
  4610  Iban.prototype.institution = function () {
  4611      return this.isIndirect() ? this._iban.substr(7, 4) : '';
  4612  };
  4613  
  4614  /**
  4615   * Should be called to get client identifier within institution
  4616   * eg. GAVOFYORK
  4617   *
  4618   * @method client
  4619   * @returns {String} client identifier
  4620   */
  4621  Iban.prototype.client = function () {
  4622      return this.isIndirect() ? this._iban.substr(11) : '';
  4623  };
  4624  
  4625  /**
  4626   * Should be called to get client direct address
  4627   *
  4628   * @method address
  4629   * @returns {String} client direct address
  4630   */
  4631  Iban.prototype.address = function () {
  4632      if (this.isDirect()) {
  4633          var base36 = this._iban.substr(4);
  4634          var asBn = new BigNumber(base36, 36);
  4635          return padLeft(asBn.toString(16), 20);
  4636      } 
  4637  
  4638      return '';
  4639  };
  4640  
  4641  Iban.prototype.toString = function () {
  4642      return this._iban;
  4643  };
  4644  
  4645  module.exports = Iban;
  4646  
  4647  
  4648  },{"bignumber.js":"bignumber.js"}],34:[function(require,module,exports){
  4649  /*
  4650      This file is part of web3.js.
  4651  
  4652      web3.js is free software: you can redistribute it and/or modify
  4653      it under the terms of the GNU Lesser General Public License as published by
  4654      the Free Software Foundation, either version 3 of the License, or
  4655      (at your option) any later version.
  4656  
  4657      web3.js is distributed in the hope that it will be useful,
  4658      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4659      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4660      GNU Lesser General Public License for more details.
  4661  
  4662      You should have received a copy of the GNU Lesser General Public License
  4663      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4664  */
  4665  /** @file ipcprovider.js
  4666   * @authors:
  4667   *   Fabian Vogelsteller <fabian@ethdev.com>
  4668   * @date 2015
  4669   */
  4670  
  4671  "use strict";
  4672  
  4673  var utils = require('../utils/utils');
  4674  var errors = require('./errors');
  4675  
  4676  
  4677  var IpcProvider = function (path, net) {
  4678      var _this = this;
  4679      this.responseCallbacks = {};
  4680      this.path = path;
  4681      
  4682      this.connection = net.connect({path: this.path});
  4683  
  4684      this.connection.on('error', function(e){
  4685          console.error('IPC Connection Error', e);
  4686          _this._timeout();
  4687      });
  4688  
  4689      this.connection.on('end', function(){
  4690          _this._timeout();
  4691      }); 
  4692  
  4693  
  4694      // LISTEN FOR CONNECTION RESPONSES
  4695      this.connection.on('data', function(data) {
  4696          /*jshint maxcomplexity: 6 */
  4697  
  4698          _this._parseResponse(data.toString()).forEach(function(result){
  4699  
  4700              var id = null;
  4701  
  4702              // get the id which matches the returned id
  4703              if(utils.isArray(result)) {
  4704                  result.forEach(function(load){
  4705                      if(_this.responseCallbacks[load.id])
  4706                          id = load.id;
  4707                  });
  4708              } else {
  4709                  id = result.id;
  4710              }
  4711  
  4712              // fire the callback
  4713              if(_this.responseCallbacks[id]) {
  4714                  _this.responseCallbacks[id](null, result);
  4715                  delete _this.responseCallbacks[id];
  4716              }
  4717          });
  4718      });
  4719  };
  4720  
  4721  /**
  4722  Will parse the response and make an array out of it.
  4723  
  4724  @method _parseResponse
  4725  @param {String} data
  4726  */
  4727  IpcProvider.prototype._parseResponse = function(data) {
  4728      var _this = this,
  4729          returnValues = [];
  4730      
  4731      // DE-CHUNKER
  4732      var dechunkedData = data
  4733          .replace(/\}[\n\r]?\{/g,'}|--|{') // }{
  4734          .replace(/\}\][\n\r]?\[\{/g,'}]|--|[{') // }][{
  4735          .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{
  4736          .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{
  4737          .split('|--|');
  4738  
  4739      dechunkedData.forEach(function(data){
  4740  
  4741          // prepend the last chunk
  4742          if(_this.lastChunk)
  4743              data = _this.lastChunk + data;
  4744  
  4745          var result = null;
  4746  
  4747          try {
  4748              result = JSON.parse(data);
  4749  
  4750          } catch(e) {
  4751  
  4752              _this.lastChunk = data;
  4753  
  4754              // start timeout to cancel all requests
  4755              clearTimeout(_this.lastChunkTimeout);
  4756              _this.lastChunkTimeout = setTimeout(function(){
  4757                  _this._timeout();
  4758                  throw errors.InvalidResponse(data);
  4759              }, 1000 * 15);
  4760  
  4761              return;
  4762          }
  4763  
  4764          // cancel timeout and set chunk to null
  4765          clearTimeout(_this.lastChunkTimeout);
  4766          _this.lastChunk = null;
  4767  
  4768          if(result)
  4769              returnValues.push(result);
  4770      });
  4771  
  4772      return returnValues;
  4773  };
  4774  
  4775  
  4776  /**
  4777  Get the adds a callback to the responseCallbacks object,
  4778  which will be called if a response matching the response Id will arrive.
  4779  
  4780  @method _addResponseCallback
  4781  */
  4782  IpcProvider.prototype._addResponseCallback = function(payload, callback) {
  4783      var id = payload.id || payload[0].id;
  4784      var method = payload.method || payload[0].method;
  4785  
  4786      this.responseCallbacks[id] = callback;
  4787      this.responseCallbacks[id].method = method;
  4788  };
  4789  
  4790  /**
  4791  Timeout all requests when the end/error event is fired
  4792  
  4793  @method _timeout
  4794  */
  4795  IpcProvider.prototype._timeout = function() {
  4796      for(var key in this.responseCallbacks) {
  4797          if(this.responseCallbacks.hasOwnProperty(key)){
  4798              this.responseCallbacks[key](errors.InvalidConnection('on IPC'));
  4799              delete this.responseCallbacks[key];
  4800          }
  4801      }
  4802  };
  4803  
  4804  
  4805  /**
  4806  Check if the current connection is still valid.
  4807  
  4808  @method isConnected
  4809  */
  4810  IpcProvider.prototype.isConnected = function() {
  4811      var _this = this;
  4812  
  4813      // try reconnect, when connection is gone
  4814      if(!_this.connection.writable)
  4815          _this.connection.connect({path: _this.path});
  4816  
  4817      return !!this.connection.writable;
  4818  };
  4819  
  4820  IpcProvider.prototype.send = function (payload) {
  4821  
  4822      if(this.connection.writeSync) {
  4823          var result;
  4824  
  4825          // try reconnect, when connection is gone
  4826          if(!this.connection.writable)
  4827              this.connection.connect({path: this.path});
  4828  
  4829          var data = this.connection.writeSync(JSON.stringify(payload));
  4830  
  4831          try {
  4832              result = JSON.parse(data);
  4833          } catch(e) {
  4834              throw errors.InvalidResponse(data);                
  4835          }
  4836  
  4837          return result;
  4838  
  4839      } else {
  4840          throw new Error('You tried to send "'+ payload.method +'" synchronously. Synchronous requests are not supported by the IPC provider.');
  4841      }
  4842  };
  4843  
  4844  IpcProvider.prototype.sendAsync = function (payload, callback) {
  4845      // try reconnect, when connection is gone
  4846      if(!this.connection.writable)
  4847          this.connection.connect({path: this.path});
  4848  
  4849  
  4850      this.connection.write(JSON.stringify(payload));
  4851      this._addResponseCallback(payload, callback);
  4852  };
  4853  
  4854  module.exports = IpcProvider;
  4855  
  4856  
  4857  },{"../utils/utils":20,"./errors":26}],35:[function(require,module,exports){
  4858  /*
  4859      This file is part of web3.js.
  4860  
  4861      web3.js is free software: you can redistribute it and/or modify
  4862      it under the terms of the GNU Lesser General Public License as published by
  4863      the Free Software Foundation, either version 3 of the License, or
  4864      (at your option) any later version.
  4865  
  4866      web3.js is distributed in the hope that it will be useful,
  4867      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4868      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4869      GNU Lesser General Public License for more details.
  4870  
  4871      You should have received a copy of the GNU Lesser General Public License
  4872      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4873  */
  4874  /** @file jsonrpc.js
  4875   * @authors:
  4876   *   Marek Kotewicz <marek@ethdev.com>
  4877   *   Aaron Kumavis <aaron@kumavis.me>
  4878   * @date 2015
  4879   */
  4880  
  4881  // Initialize Jsonrpc as a simple object with utility functions.
  4882  var Jsonrpc = {
  4883      messageId: 0
  4884  };
  4885  
  4886  /**
  4887   * Should be called to valid json create payload object
  4888   *
  4889   * @method toPayload
  4890   * @param {Function} method of jsonrpc call, required
  4891   * @param {Array} params, an array of method params, optional
  4892   * @returns {Object} valid jsonrpc payload object
  4893   */
  4894  Jsonrpc.toPayload = function (method, params) {
  4895      if (!method)
  4896          console.error('jsonrpc method should be specified!');
  4897  
  4898      // advance message ID
  4899      Jsonrpc.messageId++;
  4900  
  4901      return {
  4902          jsonrpc: '2.0',
  4903          id: Jsonrpc.messageId,
  4904          method: method,
  4905          params: params || []
  4906      };
  4907  };
  4908  
  4909  /**
  4910   * Should be called to check if jsonrpc response is valid
  4911   *
  4912   * @method isValidResponse
  4913   * @param {Object}
  4914   * @returns {Boolean} true if response is valid, otherwise false
  4915   */
  4916  Jsonrpc.isValidResponse = function (response) {
  4917      return Array.isArray(response) ? response.every(validateSingleMessage) : validateSingleMessage(response);
  4918  
  4919      function validateSingleMessage(message){
  4920        return !!message &&
  4921          !message.error &&
  4922          message.jsonrpc === '2.0' &&
  4923          typeof message.id === 'number' &&
  4924          message.result !== undefined; // only undefined is not valid json object
  4925      }
  4926  };
  4927  
  4928  /**
  4929   * Should be called to create batch payload object
  4930   *
  4931   * @method toBatchPayload
  4932   * @param {Array} messages, an array of objects with method (required) and params (optional) fields
  4933   * @returns {Array} batch payload
  4934   */
  4935  Jsonrpc.toBatchPayload = function (messages) {
  4936      return messages.map(function (message) {
  4937          return Jsonrpc.toPayload(message.method, message.params);
  4938      });
  4939  };
  4940  
  4941  module.exports = Jsonrpc;
  4942  
  4943  
  4944  },{}],36:[function(require,module,exports){
  4945  /*
  4946      This file is part of web3.js.
  4947  
  4948      web3.js is free software: you can redistribute it and/or modify
  4949      it under the terms of the GNU Lesser General Public License as published by
  4950      the Free Software Foundation, either version 3 of the License, or
  4951      (at your option) any later version.
  4952  
  4953      web3.js is distributed in the hope that it will be useful,
  4954      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4955      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4956      GNU Lesser General Public License for more details.
  4957  
  4958      You should have received a copy of the GNU Lesser General Public License
  4959      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4960  */
  4961  /**
  4962   * @file method.js
  4963   * @author Marek Kotewicz <marek@ethdev.com>
  4964   * @date 2015
  4965   */
  4966  
  4967  var utils = require('../utils/utils');
  4968  var errors = require('./errors');
  4969  
  4970  var Method = function (options) {
  4971      this.name = options.name;
  4972      this.call = options.call;
  4973      this.params = options.params || 0;
  4974      this.inputFormatter = options.inputFormatter;
  4975      this.outputFormatter = options.outputFormatter;
  4976      this.requestManager = null;
  4977  };
  4978  
  4979  Method.prototype.setRequestManager = function (rm) {
  4980      this.requestManager = rm;
  4981  };
  4982  
  4983  /**
  4984   * Should be used to determine name of the jsonrpc method based on arguments
  4985   *
  4986   * @method getCall
  4987   * @param {Array} arguments
  4988   * @return {String} name of jsonrpc method
  4989   */
  4990  Method.prototype.getCall = function (args) {
  4991      return utils.isFunction(this.call) ? this.call(args) : this.call;
  4992  };
  4993  
  4994  /**
  4995   * Should be used to extract callback from array of arguments. Modifies input param
  4996   *
  4997   * @method extractCallback
  4998   * @param {Array} arguments
  4999   * @return {Function|Null} callback, if exists
  5000   */
  5001  Method.prototype.extractCallback = function (args) {
  5002      if (utils.isFunction(args[args.length - 1])) {
  5003          return args.pop(); // modify the args array!
  5004      }
  5005  };
  5006  
  5007  /**
  5008   * Should be called to check if the number of arguments is correct
  5009   * 
  5010   * @method validateArgs
  5011   * @param {Array} arguments
  5012   * @throws {Error} if it is not
  5013   */
  5014  Method.prototype.validateArgs = function (args) {
  5015      if (args.length !== this.params) {
  5016          throw errors.InvalidNumberOfRPCParams();
  5017      }
  5018  };
  5019  
  5020  /**
  5021   * Should be called to format input args of method
  5022   * 
  5023   * @method formatInput
  5024   * @param {Array}
  5025   * @return {Array}
  5026   */
  5027  Method.prototype.formatInput = function (args) {
  5028      if (!this.inputFormatter) {
  5029          return args;
  5030      }
  5031  
  5032      return this.inputFormatter.map(function (formatter, index) {
  5033          return formatter ? formatter(args[index]) : args[index];
  5034      });
  5035  };
  5036  
  5037  /**
  5038   * Should be called to format output(result) of method
  5039   *
  5040   * @method formatOutput
  5041   * @param {Object}
  5042   * @return {Object}
  5043   */
  5044  Method.prototype.formatOutput = function (result) {
  5045      return this.outputFormatter && result ? this.outputFormatter(result) : result;
  5046  };
  5047  
  5048  /**
  5049   * Should create payload from given input args
  5050   *
  5051   * @method toPayload
  5052   * @param {Array} args
  5053   * @return {Object}
  5054   */
  5055  Method.prototype.toPayload = function (args) {
  5056      var call = this.getCall(args);
  5057      var callback = this.extractCallback(args);
  5058      var params = this.formatInput(args);
  5059      this.validateArgs(params);
  5060  
  5061      return {
  5062          method: call,
  5063          params: params,
  5064          callback: callback
  5065      };
  5066  };
  5067  
  5068  Method.prototype.attachToObject = function (obj) {
  5069      var func = this.buildCall();
  5070      func.call = this.call; // TODO!!! that's ugly. filter.js uses it
  5071      var name = this.name.split('.');
  5072      if (name.length > 1) {
  5073          obj[name[0]] = obj[name[0]] || {};
  5074          obj[name[0]][name[1]] = func;
  5075      } else {
  5076          obj[name[0]] = func; 
  5077      }
  5078  };
  5079  
  5080  Method.prototype.buildCall = function() {
  5081      var method = this;
  5082      var send = function () {
  5083          var payload = method.toPayload(Array.prototype.slice.call(arguments));
  5084          if (payload.callback) {
  5085              return method.requestManager.sendAsync(payload, function (err, result) {
  5086                  payload.callback(err, method.formatOutput(result));
  5087              });
  5088          }
  5089          return method.formatOutput(method.requestManager.send(payload));
  5090      };
  5091      send.request = this.request.bind(this);
  5092      return send;
  5093  };
  5094  
  5095  /**
  5096   * Should be called to create pure JSONRPC request which can be used in batch request
  5097   *
  5098   * @method request
  5099   * @param {...} params
  5100   * @return {Object} jsonrpc request
  5101   */
  5102  Method.prototype.request = function () {
  5103      var payload = this.toPayload(Array.prototype.slice.call(arguments));
  5104      payload.format = this.formatOutput.bind(this);
  5105      return payload;
  5106  };
  5107  
  5108  module.exports = Method;
  5109  
  5110  },{"../utils/utils":20,"./errors":26}],37:[function(require,module,exports){
  5111  /*
  5112      This file is part of web3.js.
  5113  
  5114      web3.js is free software: you can redistribute it and/or modify
  5115      it under the terms of the GNU Lesser General Public License as published by
  5116      the Free Software Foundation, either version 3 of the License, or
  5117      (at your option) any later version.
  5118  
  5119      web3.js is distributed in the hope that it will be useful,
  5120      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5121      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5122      GNU Lesser General Public License for more details.
  5123  
  5124      You should have received a copy of the GNU Lesser General Public License
  5125      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5126  */
  5127  /** @file db.js
  5128   * @authors:
  5129   *   Marek Kotewicz <marek@ethdev.com>
  5130   * @date 2015
  5131   */
  5132  
  5133  var Method = require('../method');
  5134  
  5135  var DB = function (web3) {
  5136      this._requestManager = web3._requestManager;
  5137  
  5138      var self = this;
  5139      
  5140      methods().forEach(function(method) { 
  5141          method.attachToObject(self);
  5142          method.setRequestManager(web3._requestManager);
  5143      });
  5144  };
  5145  
  5146  var methods = function () {
  5147      var putString = new Method({
  5148          name: 'putString',
  5149          call: 'db_putString',
  5150          params: 3
  5151      });
  5152  
  5153      var getString = new Method({
  5154          name: 'getString',
  5155          call: 'db_getString',
  5156          params: 2
  5157      });
  5158  
  5159      var putHex = new Method({
  5160          name: 'putHex',
  5161          call: 'db_putHex',
  5162          params: 3
  5163      });
  5164  
  5165      var getHex = new Method({
  5166          name: 'getHex',
  5167          call: 'db_getHex',
  5168          params: 2
  5169      });
  5170  
  5171      return [
  5172          putString, getString, putHex, getHex
  5173      ];
  5174  };
  5175  
  5176  module.exports = DB;
  5177  
  5178  },{"../method":36}],38:[function(require,module,exports){
  5179  /*
  5180      This file is part of web3.js.
  5181  
  5182      web3.js is free software: you can redistribute it and/or modify
  5183      it under the terms of the GNU Lesser General Public License as published by
  5184      the Free Software Foundation, either version 3 of the License, or
  5185      (at your option) any later version.
  5186  
  5187      web3.js is distributed in the hope that it will be useful,
  5188      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5189      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5190      GNU Lesser General Public License for more details.
  5191  
  5192      You should have received a copy of the GNU Lesser General Public License
  5193      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5194  */
  5195  /**
  5196   * @file eth.js
  5197   * @author Marek Kotewicz <marek@ethdev.com>
  5198   * @author Fabian Vogelsteller <fabian@ethdev.com>
  5199   * @date 2015
  5200   */
  5201  
  5202  "use strict";
  5203  
  5204  var formatters = require('../formatters');
  5205  var utils = require('../../utils/utils');
  5206  var Method = require('../method');
  5207  var Property = require('../property');
  5208  var c = require('../../utils/config');
  5209  var Contract = require('../contract');
  5210  var watches = require('./watches');
  5211  var Filter = require('../filter');
  5212  var IsSyncing = require('../syncing');
  5213  var namereg = require('../namereg');
  5214  var Iban = require('../iban');
  5215  var transfer = require('../transfer');
  5216  
  5217  var blockCall = function (args) {
  5218      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
  5219  };
  5220  
  5221  var transactionFromBlockCall = function (args) {
  5222      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
  5223  };
  5224  
  5225  var uncleCall = function (args) {
  5226      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
  5227  };
  5228  
  5229  var getBlockTransactionCountCall = function (args) {
  5230      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
  5231  };
  5232  
  5233  var uncleCountCall = function (args) {
  5234      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
  5235  };
  5236  
  5237  function Eth(web3) {
  5238      this._requestManager = web3._requestManager;
  5239  
  5240      var self = this;
  5241  
  5242      methods().forEach(function(method) {
  5243          method.attachToObject(self);
  5244          method.setRequestManager(self._requestManager);
  5245      });
  5246  
  5247      properties().forEach(function(p) {
  5248          p.attachToObject(self);
  5249          p.setRequestManager(self._requestManager);
  5250      });
  5251  
  5252  
  5253      this.iban = Iban;
  5254      this.sendIBANTransaction = transfer.bind(null, this);
  5255  }
  5256  
  5257  Object.defineProperty(Eth.prototype, 'defaultBlock', {
  5258      get: function () {
  5259          return c.defaultBlock;
  5260      },
  5261      set: function (val) {
  5262          c.defaultBlock = val;
  5263          return val;
  5264      }
  5265  });
  5266  
  5267  Object.defineProperty(Eth.prototype, 'defaultAccount', {
  5268      get: function () {
  5269          return c.defaultAccount;
  5270      },
  5271      set: function (val) {
  5272          c.defaultAccount = val;
  5273          return val;
  5274      }
  5275  });
  5276  
  5277  var methods = function () {
  5278      var getBalance = new Method({
  5279          name: 'getBalance',
  5280          call: 'eth_getBalance',
  5281          params: 2,
  5282          inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
  5283          outputFormatter: formatters.outputBigNumberFormatter
  5284      });
  5285  
  5286      var getStorageAt = new Method({
  5287          name: 'getStorageAt',
  5288          call: 'eth_getStorageAt',
  5289          params: 3,
  5290          inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
  5291      });
  5292  
  5293      var getCode = new Method({
  5294          name: 'getCode',
  5295          call: 'eth_getCode',
  5296          params: 2,
  5297          inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
  5298      });
  5299  
  5300      var getBlock = new Method({
  5301          name: 'getBlock',
  5302          call: blockCall,
  5303          params: 2,
  5304          inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
  5305          outputFormatter: formatters.outputBlockFormatter
  5306      });
  5307  
  5308      var getUncle = new Method({
  5309          name: 'getUncle',
  5310          call: uncleCall,
  5311          params: 2,
  5312          inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5313          outputFormatter: formatters.outputBlockFormatter,
  5314  
  5315      });
  5316  
  5317      var getCompilers = new Method({
  5318          name: 'getCompilers',
  5319          call: 'eth_getCompilers',
  5320          params: 0
  5321      });
  5322  
  5323      var getBlockTransactionCount = new Method({
  5324          name: 'getBlockTransactionCount',
  5325          call: getBlockTransactionCountCall,
  5326          params: 1,
  5327          inputFormatter: [formatters.inputBlockNumberFormatter],
  5328          outputFormatter: utils.toDecimal
  5329      });
  5330  
  5331      var getBlockUncleCount = new Method({
  5332          name: 'getBlockUncleCount',
  5333          call: uncleCountCall,
  5334          params: 1,
  5335          inputFormatter: [formatters.inputBlockNumberFormatter],
  5336          outputFormatter: utils.toDecimal
  5337      });
  5338  
  5339      var getTransaction = new Method({
  5340          name: 'getTransaction',
  5341          call: 'eth_getTransactionByHash',
  5342          params: 1,
  5343          outputFormatter: formatters.outputTransactionFormatter
  5344      });
  5345  
  5346      var getTransactionFromBlock = new Method({
  5347          name: 'getTransactionFromBlock',
  5348          call: transactionFromBlockCall,
  5349          params: 2,
  5350          inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5351          outputFormatter: formatters.outputTransactionFormatter
  5352      });
  5353  
  5354      var getTransactionReceipt = new Method({
  5355          name: 'getTransactionReceipt',
  5356          call: 'eth_getTransactionReceipt',
  5357          params: 1,
  5358          outputFormatter: formatters.outputTransactionReceiptFormatter
  5359      });
  5360  
  5361      var getTransactionCount = new Method({
  5362          name: 'getTransactionCount',
  5363          call: 'eth_getTransactionCount',
  5364          params: 2,
  5365          inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
  5366          outputFormatter: utils.toDecimal
  5367      });
  5368  
  5369      var sendRawTransaction = new Method({
  5370          name: 'sendRawTransaction',
  5371          call: 'eth_sendRawTransaction',
  5372          params: 1,
  5373          inputFormatter: [null]
  5374      });
  5375  
  5376      var sendTransaction = new Method({
  5377          name: 'sendTransaction',
  5378          call: 'eth_sendTransaction',
  5379          params: 1,
  5380          inputFormatter: [formatters.inputTransactionFormatter]
  5381      });
  5382  
  5383      var signTransaction = new Method({
  5384          name: 'signTransaction',
  5385          call: 'eth_signTransaction',
  5386          params: 1,
  5387          inputFormatter: [formatters.inputTransactionFormatter]
  5388      });
  5389  
  5390      var sign = new Method({
  5391          name: 'sign',
  5392          call: 'eth_sign',
  5393          params: 2,
  5394          inputFormatter: [formatters.inputAddressFormatter, null]
  5395      });
  5396  
  5397      var call = new Method({
  5398          name: 'call',
  5399          call: 'eth_call',
  5400          params: 2,
  5401          inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
  5402      });
  5403  
  5404      var estimateGas = new Method({
  5405          name: 'estimateGas',
  5406          call: 'eth_estimateGas',
  5407          params: 1,
  5408          inputFormatter: [formatters.inputCallFormatter],
  5409          outputFormatter: utils.toDecimal
  5410      });
  5411  
  5412      var compileSolidity = new Method({
  5413          name: 'compile.solidity',
  5414          call: 'eth_compileSolidity',
  5415          params: 1
  5416      });
  5417  
  5418      var compileLLL = new Method({
  5419          name: 'compile.lll',
  5420          call: 'eth_compileLLL',
  5421          params: 1
  5422      });
  5423  
  5424      var compileSerpent = new Method({
  5425          name: 'compile.serpent',
  5426          call: 'eth_compileSerpent',
  5427          params: 1
  5428      });
  5429  
  5430      var submitWork = new Method({
  5431          name: 'submitWork',
  5432          call: 'eth_submitWork',
  5433          params: 3
  5434      });
  5435  
  5436      var getWork = new Method({
  5437          name: 'getWork',
  5438          call: 'eth_getWork',
  5439          params: 0
  5440      });
  5441  
  5442      return [
  5443          getBalance,
  5444          getStorageAt,
  5445          getCode,
  5446          getBlock,
  5447          getUncle,
  5448          getCompilers,
  5449          getBlockTransactionCount,
  5450          getBlockUncleCount,
  5451          getTransaction,
  5452          getTransactionFromBlock,
  5453          getTransactionReceipt,
  5454          getTransactionCount,
  5455          call,
  5456          estimateGas,
  5457          sendRawTransaction,
  5458          signTransaction,
  5459          sendTransaction,
  5460          sign,
  5461          compileSolidity,
  5462          compileLLL,
  5463          compileSerpent,
  5464          submitWork,
  5465          getWork
  5466      ];
  5467  };
  5468  
  5469  
  5470  var properties = function () {
  5471      return [
  5472          new Property({
  5473              name: 'coinbase',
  5474              getter: 'eth_coinbase'
  5475          }),
  5476          new Property({
  5477              name: 'mining',
  5478              getter: 'eth_mining'
  5479          }),
  5480          new Property({
  5481              name: 'hashrate',
  5482              getter: 'eth_hashrate',
  5483              outputFormatter: utils.toDecimal
  5484          }),
  5485          new Property({
  5486              name: 'syncing',
  5487              getter: 'eth_syncing',
  5488              outputFormatter: formatters.outputSyncingFormatter
  5489          }),
  5490          new Property({
  5491              name: 'gasPrice',
  5492              getter: 'eth_gasPrice',
  5493              outputFormatter: formatters.outputBigNumberFormatter
  5494          }),
  5495          new Property({
  5496              name: 'accounts',
  5497              getter: 'eth_accounts'
  5498          }),
  5499          new Property({
  5500              name: 'blockNumber',
  5501              getter: 'eth_blockNumber',
  5502              outputFormatter: utils.toDecimal
  5503          }),
  5504          new Property({
  5505              name: 'protocolVersion',
  5506              getter: 'eth_protocolVersion'
  5507          })
  5508      ];
  5509  };
  5510  
  5511  Eth.prototype.contract = function (abi) {
  5512      var factory = new Contract(this, abi);
  5513      return factory;
  5514  };
  5515  
  5516  Eth.prototype.filter = function (options, callback, filterCreationErrorCallback) {
  5517      return new Filter(options, 'eth', this._requestManager, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
  5518  };
  5519  
  5520  Eth.prototype.namereg = function () {
  5521      return this.contract(namereg.global.abi).at(namereg.global.address);
  5522  };
  5523  
  5524  Eth.prototype.icapNamereg = function () {
  5525      return this.contract(namereg.icap.abi).at(namereg.icap.address);
  5526  };
  5527  
  5528  Eth.prototype.isSyncing = function (callback) {
  5529      return new IsSyncing(this._requestManager, callback);
  5530  };
  5531  
  5532  module.exports = Eth;
  5533  
  5534  },{"../../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){
  5535  /*
  5536      This file is part of web3.js.
  5537  
  5538      web3.js is free software: you can redistribute it and/or modify
  5539      it under the terms of the GNU Lesser General Public License as published by
  5540      the Free Software Foundation, either version 3 of the License, or
  5541      (at your option) any later version.
  5542  
  5543      web3.js is distributed in the hope that it will be useful,
  5544      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5545      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5546      GNU Lesser General Public License for more details.
  5547  
  5548      You should have received a copy of the GNU Lesser General Public License
  5549      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5550  */
  5551  /** @file eth.js
  5552   * @authors:
  5553   *   Marek Kotewicz <marek@ethdev.com>
  5554   * @date 2015
  5555   */
  5556  
  5557  var utils = require('../../utils/utils');
  5558  var Property = require('../property');
  5559  
  5560  var Net = function (web3) {
  5561      this._requestManager = web3._requestManager;
  5562  
  5563      var self = this;
  5564  
  5565      properties().forEach(function(p) { 
  5566          p.attachToObject(self);
  5567          p.setRequestManager(web3._requestManager);
  5568      });
  5569  };
  5570  
  5571  /// @returns an array of objects describing web3.eth api properties
  5572  var properties = function () {
  5573      return [
  5574          new Property({
  5575              name: 'listening',
  5576              getter: 'net_listening'
  5577          }),
  5578          new Property({
  5579              name: 'peerCount',
  5580              getter: 'net_peerCount',
  5581              outputFormatter: utils.toDecimal
  5582          })
  5583      ];
  5584  };
  5585  
  5586  module.exports = Net;
  5587  
  5588  },{"../../utils/utils":20,"../property":45}],40:[function(require,module,exports){
  5589  /*
  5590      This file is part of web3.js.
  5591  
  5592      web3.js is free software: you can redistribute it and/or modify
  5593      it under the terms of the GNU Lesser General Public License as published by
  5594      the Free Software Foundation, either version 3 of the License, or
  5595      (at your option) any later version.
  5596  
  5597      web3.js is distributed in the hope that it will be useful,
  5598      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5599      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5600      GNU Lesser General Public License for more details.
  5601  
  5602      You should have received a copy of the GNU Lesser General Public License
  5603      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5604  */
  5605  /**
  5606   * @file eth.js
  5607   * @author Marek Kotewicz <marek@ethdev.com>
  5608   * @author Fabian Vogelsteller <fabian@ethdev.com>
  5609   * @date 2015
  5610   */
  5611  
  5612  "use strict";
  5613  
  5614  var Method = require('../method');
  5615  var Property = require('../property');
  5616  var formatters = require('../formatters');
  5617  
  5618  function Personal(web3) {
  5619      this._requestManager = web3._requestManager;
  5620  
  5621      var self = this;
  5622  
  5623      methods().forEach(function(method) {
  5624          method.attachToObject(self);
  5625          method.setRequestManager(self._requestManager);
  5626      });
  5627  
  5628      properties().forEach(function(p) {
  5629          p.attachToObject(self);
  5630          p.setRequestManager(self._requestManager);
  5631      });
  5632  }
  5633  
  5634  var methods = function () {
  5635      var newAccount = new Method({
  5636          name: 'newAccount',
  5637          call: 'personal_newAccount',
  5638          params: 1,
  5639          inputFormatter: [null]
  5640      });
  5641  
  5642      var importRawKey = new Method({
  5643          name: 'importRawKey',
  5644  		call: 'personal_importRawKey',
  5645  		params: 2
  5646      });
  5647  
  5648      var sign = new Method({
  5649          name: 'sign',
  5650  		call: 'personal_sign',
  5651  		params: 3,
  5652  		inputFormatter: [null, formatters.inputAddressFormatter, null]
  5653      });
  5654  
  5655      var ecRecover = new Method({
  5656          name: 'ecRecover',
  5657  		call: 'personal_ecRecover',
  5658  		params: 2
  5659      });
  5660  
  5661      var unlockAccount = new Method({
  5662          name: 'unlockAccount',
  5663          call: 'personal_unlockAccount',
  5664          params: 3,
  5665          inputFormatter: [formatters.inputAddressFormatter, null, null]
  5666      });
  5667  
  5668      var sendTransaction = new Method({
  5669          name: 'sendTransaction',
  5670          call: 'personal_sendTransaction',
  5671          params: 2,
  5672          inputFormatter: [formatters.inputTransactionFormatter, null]
  5673      });
  5674  
  5675      var lockAccount = new Method({
  5676          name: 'lockAccount',
  5677          call: 'personal_lockAccount',
  5678          params: 1,
  5679          inputFormatter: [formatters.inputAddressFormatter]
  5680      });
  5681  
  5682      return [
  5683          newAccount,
  5684          importRawKey,
  5685          unlockAccount,
  5686          ecRecover,
  5687          sign,
  5688          sendTransaction,
  5689          lockAccount
  5690      ];
  5691  };
  5692  
  5693  var properties = function () {
  5694      return [
  5695          new Property({
  5696              name: 'listAccounts',
  5697              getter: 'personal_listAccounts'
  5698          })
  5699      ];
  5700  };
  5701  
  5702  
  5703  module.exports = Personal;
  5704  
  5705  },{"../formatters":30,"../method":36,"../property":45}],41:[function(require,module,exports){
  5706  /*
  5707      This file is part of web3.js.
  5708  
  5709      web3.js is free software: you can redistribute it and/or modify
  5710      it under the terms of the GNU Lesser General Public License as published by
  5711      the Free Software Foundation, either version 3 of the License, or
  5712      (at your option) any later version.
  5713  
  5714      web3.js is distributed in the hope that it will be useful,
  5715      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5716      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5717      GNU Lesser General Public License for more details.
  5718  
  5719      You should have received a copy of the GNU Lesser General Public License
  5720      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5721  */
  5722  /** @file shh.js
  5723   * @authors:
  5724   *   Fabian Vogelsteller <fabian@ethereum.org>
  5725   *   Marek Kotewicz <marek@ethcore.io>
  5726   * @date 2017
  5727   */
  5728  
  5729  var Method = require('../method');
  5730  var Filter = require('../filter');
  5731  var watches = require('./watches');
  5732  
  5733  var Shh = function (web3) {
  5734      this._requestManager = web3._requestManager;
  5735  
  5736      var self = this;
  5737  
  5738      methods().forEach(function(method) {
  5739          method.attachToObject(self);
  5740          method.setRequestManager(self._requestManager);
  5741      });
  5742  };
  5743  
  5744  Shh.prototype.newMessageFilter = function (options, callback, filterCreationErrorCallback) {
  5745      return new Filter(options, 'shh', this._requestManager, watches.shh(), null, callback, filterCreationErrorCallback);
  5746  };
  5747  
  5748  var methods = function () {
  5749  
  5750      return [
  5751          new Method({
  5752              name: 'version',
  5753              call: 'shh_version',
  5754              params: 0
  5755          }),
  5756          new Method({
  5757              name: 'info',
  5758              call: 'shh_info',
  5759              params: 0
  5760          }),
  5761          new Method({
  5762              name: 'setMaxMessageSize',
  5763              call: 'shh_setMaxMessageSize',
  5764              params: 1
  5765          }),
  5766          new Method({
  5767              name: 'setMinPoW',
  5768              call: 'shh_setMinPoW',
  5769              params: 1
  5770          }),
  5771          new Method({
  5772              name: 'markTrustedPeer',
  5773              call: 'shh_markTrustedPeer',
  5774              params: 1
  5775          }),
  5776          new Method({
  5777              name: 'newKeyPair',
  5778              call: 'shh_newKeyPair',
  5779              params: 0
  5780          }),
  5781          new Method({
  5782              name: 'addPrivateKey',
  5783              call: 'shh_addPrivateKey',
  5784              params: 1
  5785          }),
  5786          new Method({
  5787              name: 'deleteKeyPair',
  5788              call: 'shh_deleteKeyPair',
  5789              params: 1
  5790          }),
  5791          new Method({
  5792              name: 'hasKeyPair',
  5793              call: 'shh_hasKeyPair',
  5794              params: 1
  5795          }),
  5796          new Method({
  5797              name: 'getPublicKey',
  5798              call: 'shh_getPublicKey',
  5799              params: 1
  5800          }),
  5801          new Method({
  5802              name: 'getPrivateKey',
  5803              call: 'shh_getPrivateKey',
  5804              params: 1
  5805          }),
  5806          new Method({
  5807              name: 'newSymKey',
  5808              call: 'shh_newSymKey',
  5809              params: 0
  5810          }),
  5811          new Method({
  5812              name: 'addSymKey',
  5813              call: 'shh_addSymKey',
  5814              params: 1
  5815          }),
  5816          new Method({
  5817              name: 'generateSymKeyFromPassword',
  5818              call: 'shh_generateSymKeyFromPassword',
  5819              params: 1
  5820          }),
  5821          new Method({
  5822              name: 'hasSymKey',
  5823              call: 'shh_hasSymKey',
  5824              params: 1
  5825          }),
  5826          new Method({
  5827              name: 'getSymKey',
  5828              call: 'shh_getSymKey',
  5829              params: 1
  5830          }),
  5831          new Method({
  5832              name: 'deleteSymKey',
  5833              call: 'shh_deleteSymKey',
  5834              params: 1
  5835          }),
  5836  
  5837          // subscribe and unsubscribe missing
  5838  
  5839          new Method({
  5840              name: 'post',
  5841              call: 'shh_post',
  5842              params: 1,
  5843              inputFormatter: [null]
  5844          })
  5845      ];
  5846  };
  5847  
  5848  module.exports = Shh;
  5849  
  5850  
  5851  },{"../filter":29,"../method":36,"./watches":43}],42:[function(require,module,exports){
  5852  /*
  5853      This file is part of web3.js.
  5854  
  5855      web3.js is free software: you can redistribute it and/or modify
  5856      it under the terms of the GNU Lesser General Public License as published by
  5857      the Free Software Foundation, either version 3 of the License, or
  5858      (at your option) any later version.
  5859  
  5860      web3.js is distributed in the hope that it will be useful,
  5861      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5862      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5863      GNU Lesser General Public License for more details.
  5864  
  5865      You should have received a copy of the GNU Lesser General Public License
  5866      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5867  */
  5868  /**
  5869   * @file bzz.js
  5870   * @author Alex Beregszaszi <alex@rtfs.hu>
  5871   * @date 2016
  5872   *
  5873   * Reference: https://github.com/kisexp/xdchain/blob/swarm/internal/web3ext/web3ext.go#L33
  5874   */
  5875  
  5876  "use strict";
  5877  
  5878  var Method = require('../method');
  5879  var Property = require('../property');
  5880  
  5881  function Swarm(web3) {
  5882      this._requestManager = web3._requestManager;
  5883  
  5884      var self = this;
  5885  
  5886      methods().forEach(function(method) {
  5887          method.attachToObject(self);
  5888          method.setRequestManager(self._requestManager);
  5889      });
  5890  
  5891      properties().forEach(function(p) {
  5892          p.attachToObject(self);
  5893          p.setRequestManager(self._requestManager);
  5894      });
  5895  }
  5896  
  5897  var methods = function () {
  5898      var blockNetworkRead = new Method({
  5899          name: 'blockNetworkRead',
  5900          call: 'bzz_blockNetworkRead',
  5901          params: 1,
  5902          inputFormatter: [null]
  5903      });
  5904  
  5905      var syncEnabled = new Method({
  5906          name: 'syncEnabled',
  5907          call: 'bzz_syncEnabled',
  5908          params: 1,
  5909          inputFormatter: [null]
  5910      });
  5911  
  5912      var swapEnabled = new Method({
  5913          name: 'swapEnabled',
  5914          call: 'bzz_swapEnabled',
  5915          params: 1,
  5916          inputFormatter: [null]
  5917      });
  5918  
  5919      var download = new Method({
  5920          name: 'download',
  5921          call: 'bzz_download',
  5922          params: 2,
  5923          inputFormatter: [null, null]
  5924      });
  5925  
  5926      var upload = new Method({
  5927          name: 'upload',
  5928          call: 'bzz_upload',
  5929          params: 2,
  5930          inputFormatter: [null, null]
  5931      });
  5932  
  5933      var retrieve = new Method({
  5934          name: 'retrieve',
  5935          call: 'bzz_retrieve',
  5936          params: 1,
  5937          inputFormatter: [null]
  5938      });
  5939  
  5940      var store = new Method({
  5941          name: 'store',
  5942          call: 'bzz_store',
  5943          params: 2,
  5944          inputFormatter: [null, null]
  5945      });
  5946  
  5947      var get = new Method({
  5948          name: 'get',
  5949          call: 'bzz_get',
  5950          params: 1,
  5951          inputFormatter: [null]
  5952      });
  5953  
  5954      var put = new Method({
  5955          name: 'put',
  5956          call: 'bzz_put',
  5957          params: 2,
  5958          inputFormatter: [null, null]
  5959      });
  5960  
  5961      var modify = new Method({
  5962          name: 'modify',
  5963          call: 'bzz_modify',
  5964          params: 4,
  5965          inputFormatter: [null, null, null, null]
  5966      });
  5967  
  5968      return [
  5969          blockNetworkRead,
  5970          syncEnabled,
  5971          swapEnabled,
  5972          download,
  5973          upload,
  5974          retrieve,
  5975          store,
  5976          get,
  5977          put,
  5978          modify
  5979      ];
  5980  };
  5981  
  5982  var properties = function () {
  5983      return [
  5984          new Property({
  5985              name: 'hive',
  5986              getter: 'bzz_hive'
  5987          }),
  5988          new Property({
  5989              name: 'info',
  5990              getter: 'bzz_info'
  5991          })
  5992      ];
  5993  };
  5994  
  5995  
  5996  module.exports = Swarm;
  5997  
  5998  },{"../method":36,"../property":45}],43:[function(require,module,exports){
  5999  /*
  6000      This file is part of web3.js.
  6001  
  6002      web3.js is free software: you can redistribute it and/or modify
  6003      it under the terms of the GNU Lesser General Public License as published by
  6004      the Free Software Foundation, either version 3 of the License, or
  6005      (at your option) any later version.
  6006  
  6007      web3.js is distributed in the hope that it will be useful,
  6008      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6009      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6010      GNU Lesser General Public License for more details.
  6011  
  6012      You should have received a copy of the GNU Lesser General Public License
  6013      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6014  */
  6015  /** @file watches.js
  6016   * @authors:
  6017   *   Marek Kotewicz <marek@ethdev.com>
  6018   * @date 2015
  6019   */
  6020  
  6021  var Method = require('../method');
  6022  
  6023  /// @returns an array of objects describing web3.eth.filter api methods
  6024  var eth = function () {
  6025      var newFilterCall = function (args) {
  6026          var type = args[0];
  6027  
  6028          switch(type) {
  6029              case 'latest':
  6030                  args.shift();
  6031                  this.params = 0;
  6032                  return 'eth_newBlockFilter';
  6033              case 'pending':
  6034                  args.shift();
  6035                  this.params = 0;
  6036                  return 'eth_newPendingTransactionFilter';
  6037              default:
  6038                  return 'eth_newFilter';
  6039          }
  6040      };
  6041  
  6042      var newFilter = new Method({
  6043          name: 'newFilter',
  6044          call: newFilterCall,
  6045          params: 1
  6046      });
  6047  
  6048      var uninstallFilter = new Method({
  6049          name: 'uninstallFilter',
  6050          call: 'eth_uninstallFilter',
  6051          params: 1
  6052      });
  6053  
  6054      var getLogs = new Method({
  6055          name: 'getLogs',
  6056          call: 'eth_getFilterLogs',
  6057          params: 1
  6058      });
  6059  
  6060      var poll = new Method({
  6061          name: 'poll',
  6062          call: 'eth_getFilterChanges',
  6063          params: 1
  6064      });
  6065  
  6066      return [
  6067          newFilter,
  6068          uninstallFilter,
  6069          getLogs,
  6070          poll
  6071      ];
  6072  };
  6073  
  6074  /// @returns an array of objects describing web3.shh.watch api methods
  6075  var shh = function () {
  6076  
  6077      return [
  6078          new Method({
  6079              name: 'newFilter',
  6080              call: 'shh_newMessageFilter',
  6081              params: 1
  6082          }),
  6083          new Method({
  6084              name: 'uninstallFilter',
  6085              call: 'shh_deleteMessageFilter',
  6086              params: 1
  6087          }),
  6088          new Method({
  6089              name: 'getLogs',
  6090              call: 'shh_getFilterMessages',
  6091              params: 1
  6092          }),
  6093          new Method({
  6094              name: 'poll',
  6095              call: 'shh_getFilterMessages',
  6096              params: 1
  6097          })
  6098      ];
  6099  };
  6100  
  6101  module.exports = {
  6102      eth: eth,
  6103      shh: shh
  6104  };
  6105  
  6106  
  6107  },{"../method":36}],44:[function(require,module,exports){
  6108  /*
  6109      This file is part of web3.js.
  6110  
  6111      web3.js is free software: you can redistribute it and/or modify
  6112      it under the terms of the GNU Lesser General Public License as published by
  6113      the Free Software Foundation, either version 3 of the License, or
  6114      (at your option) any later version.
  6115  
  6116      web3.js is distributed in the hope that it will be useful,
  6117      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6118      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6119      GNU Lesser General Public License for more details.
  6120  
  6121      You should have received a copy of the GNU Lesser General Public License
  6122      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6123  */
  6124  /** 
  6125   * @file namereg.js
  6126   * @author Marek Kotewicz <marek@ethdev.com>
  6127   * @date 2015
  6128   */
  6129  
  6130  var globalRegistrarAbi = require('../contracts/GlobalRegistrar.json');
  6131  var icapRegistrarAbi= require('../contracts/ICAPRegistrar.json');
  6132  
  6133  var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
  6134  var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
  6135  
  6136  module.exports = {
  6137      global: {
  6138          abi: globalRegistrarAbi,
  6139          address: globalNameregAddress
  6140      },
  6141      icap: {
  6142          abi: icapRegistrarAbi,
  6143          address: icapNameregAddress
  6144      }
  6145  };
  6146  
  6147  
  6148  },{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],45:[function(require,module,exports){
  6149  /*
  6150      This file is part of web3.js.
  6151  
  6152      web3.js is free software: you can redistribute it and/or modify
  6153      it under the terms of the GNU Lesser General Public License as published by
  6154      the Free Software Foundation, either version 3 of the License, or
  6155      (at your option) any later version.
  6156  
  6157      web3.js is distributed in the hope that it will be useful,
  6158      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6159      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6160      GNU Lesser General Public License for more details.
  6161  
  6162      You should have received a copy of the GNU Lesser General Public License
  6163      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6164  */
  6165  /**
  6166   * @file property.js
  6167   * @author Fabian Vogelsteller <fabian@frozeman.de>
  6168   * @author Marek Kotewicz <marek@ethdev.com>
  6169   * @date 2015
  6170   */
  6171  
  6172  var utils = require('../utils/utils');
  6173  
  6174  var Property = function (options) {
  6175      this.name = options.name;
  6176      this.getter = options.getter;
  6177      this.setter = options.setter;
  6178      this.outputFormatter = options.outputFormatter;
  6179      this.inputFormatter = options.inputFormatter;
  6180      this.requestManager = null;
  6181  };
  6182  
  6183  Property.prototype.setRequestManager = function (rm) {
  6184      this.requestManager = rm;
  6185  };
  6186  
  6187  /**
  6188   * Should be called to format input args of method
  6189   *
  6190   * @method formatInput
  6191   * @param {Array}
  6192   * @return {Array}
  6193   */
  6194  Property.prototype.formatInput = function (arg) {
  6195      return this.inputFormatter ? this.inputFormatter(arg) : arg;
  6196  };
  6197  
  6198  /**
  6199   * Should be called to format output(result) of method
  6200   *
  6201   * @method formatOutput
  6202   * @param {Object}
  6203   * @return {Object}
  6204   */
  6205  Property.prototype.formatOutput = function (result) {
  6206      return this.outputFormatter && result !== null && result !== undefined ? this.outputFormatter(result) : result;
  6207  };
  6208  
  6209  /**
  6210   * Should be used to extract callback from array of arguments. Modifies input param
  6211   *
  6212   * @method extractCallback
  6213   * @param {Array} arguments
  6214   * @return {Function|Null} callback, if exists
  6215   */
  6216  Property.prototype.extractCallback = function (args) {
  6217      if (utils.isFunction(args[args.length - 1])) {
  6218          return args.pop(); // modify the args array!
  6219      }
  6220  };
  6221  
  6222  
  6223  /**
  6224   * Should attach function to method
  6225   *
  6226   * @method attachToObject
  6227   * @param {Object}
  6228   * @param {Function}
  6229   */
  6230  Property.prototype.attachToObject = function (obj) {
  6231      var proto = {
  6232          get: this.buildGet(),
  6233          enumerable: true
  6234      };
  6235  
  6236      var names = this.name.split('.');
  6237      var name = names[0];
  6238      if (names.length > 1) {
  6239          obj[names[0]] = obj[names[0]] || {};
  6240          obj = obj[names[0]];
  6241          name = names[1];
  6242      }
  6243  
  6244      Object.defineProperty(obj, name, proto);
  6245      obj[asyncGetterName(name)] = this.buildAsyncGet();
  6246  };
  6247  
  6248  var asyncGetterName = function (name) {
  6249      return 'get' + name.charAt(0).toUpperCase() + name.slice(1);
  6250  };
  6251  
  6252  Property.prototype.buildGet = function () {
  6253      var property = this;
  6254      return function get() {
  6255          return property.formatOutput(property.requestManager.send({
  6256              method: property.getter
  6257          }));
  6258      };
  6259  };
  6260  
  6261  Property.prototype.buildAsyncGet = function () {
  6262      var property = this;
  6263      var get = function (callback) {
  6264          property.requestManager.sendAsync({
  6265              method: property.getter
  6266          }, function (err, result) {
  6267              callback(err, property.formatOutput(result));
  6268          });
  6269      };
  6270      get.request = this.request.bind(this);
  6271      return get;
  6272  };
  6273  
  6274  /**
  6275   * Should be called to create pure JSONRPC request which can be used in batch request
  6276   *
  6277   * @method request
  6278   * @param {...} params
  6279   * @return {Object} jsonrpc request
  6280   */
  6281  Property.prototype.request = function () {
  6282      var payload = {
  6283          method: this.getter,
  6284          params: [],
  6285          callback: this.extractCallback(Array.prototype.slice.call(arguments))
  6286      };
  6287      payload.format = this.formatOutput.bind(this);
  6288      return payload;
  6289  };
  6290  
  6291  module.exports = Property;
  6292  
  6293  
  6294  },{"../utils/utils":20}],46:[function(require,module,exports){
  6295  /*
  6296      This file is part of web3.js.
  6297  
  6298      web3.js is free software: you can redistribute it and/or modify
  6299      it under the terms of the GNU Lesser General Public License as published by
  6300      the Free Software Foundation, either version 3 of the License, or
  6301      (at your option) any later version.
  6302  
  6303      web3.js is distributed in the hope that it will be useful,
  6304      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6305      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6306      GNU Lesser General Public License for more details.
  6307  
  6308      You should have received a copy of the GNU Lesser General Public License
  6309      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6310  */
  6311  /** 
  6312   * @file requestmanager.js
  6313   * @author Jeffrey Wilcke <jeff@ethdev.com>
  6314   * @author Marek Kotewicz <marek@ethdev.com>
  6315   * @author Marian Oancea <marian@ethdev.com>
  6316   * @author Fabian Vogelsteller <fabian@ethdev.com>
  6317   * @author Gav Wood <g@ethdev.com>
  6318   * @date 2014
  6319   */
  6320  
  6321  var Jsonrpc = require('./jsonrpc');
  6322  var utils = require('../utils/utils');
  6323  var c = require('../utils/config');
  6324  var errors = require('./errors');
  6325  
  6326  /**
  6327   * It's responsible for passing messages to providers
  6328   * It's also responsible for polling the ethereum node for incoming messages
  6329   * Default poll timeout is 1 second
  6330   * Singleton
  6331   */
  6332  var RequestManager = function (provider) {
  6333      this.provider = provider;
  6334      this.polls = {};
  6335      this.timeout = null;
  6336  };
  6337  
  6338  /**
  6339   * Should be used to synchronously send request
  6340   *
  6341   * @method send
  6342   * @param {Object} data
  6343   * @return {Object}
  6344   */
  6345  RequestManager.prototype.send = function (data) {
  6346      if (!this.provider) {
  6347          console.error(errors.InvalidProvider());
  6348          return null;
  6349      }
  6350  
  6351      var payload = Jsonrpc.toPayload(data.method, data.params);
  6352      var result = this.provider.send(payload);
  6353  
  6354      if (!Jsonrpc.isValidResponse(result)) {
  6355          throw errors.InvalidResponse(result);
  6356      }
  6357  
  6358      return result.result;
  6359  };
  6360  
  6361  /**
  6362   * Should be used to asynchronously send request
  6363   *
  6364   * @method sendAsync
  6365   * @param {Object} data
  6366   * @param {Function} callback
  6367   */
  6368  RequestManager.prototype.sendAsync = function (data, callback) {
  6369      if (!this.provider) {
  6370          return callback(errors.InvalidProvider());
  6371      }
  6372  
  6373      var payload = Jsonrpc.toPayload(data.method, data.params);
  6374      this.provider.sendAsync(payload, function (err, result) {
  6375          if (err) {
  6376              return callback(err);
  6377          }
  6378          
  6379          if (!Jsonrpc.isValidResponse(result)) {
  6380              return callback(errors.InvalidResponse(result));
  6381          }
  6382  
  6383          callback(null, result.result);
  6384      });
  6385  };
  6386  
  6387  /**
  6388   * Should be called to asynchronously send batch request
  6389   *
  6390   * @method sendBatch
  6391   * @param {Array} batch data
  6392   * @param {Function} callback
  6393   */
  6394  RequestManager.prototype.sendBatch = function (data, callback) {
  6395      if (!this.provider) {
  6396          return callback(errors.InvalidProvider());
  6397      }
  6398  
  6399      var payload = Jsonrpc.toBatchPayload(data);
  6400  
  6401      this.provider.sendAsync(payload, function (err, results) {
  6402          if (err) {
  6403              return callback(err);
  6404          }
  6405  
  6406          if (!utils.isArray(results)) {
  6407              return callback(errors.InvalidResponse(results));
  6408          }
  6409  
  6410          callback(err, results);
  6411      }); 
  6412  };
  6413  
  6414  /**
  6415   * Should be used to set provider of request manager
  6416   *
  6417   * @method setProvider
  6418   * @param {Object}
  6419   */
  6420  RequestManager.prototype.setProvider = function (p) {
  6421      this.provider = p;
  6422  };
  6423  
  6424  /**
  6425   * Should be used to start polling
  6426   *
  6427   * @method startPolling
  6428   * @param {Object} data
  6429   * @param {Number} pollId
  6430   * @param {Function} callback
  6431   * @param {Function} uninstall
  6432   *
  6433   * @todo cleanup number of params
  6434   */
  6435  RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
  6436      this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
  6437  
  6438  
  6439      // start polling
  6440      if (!this.timeout) {
  6441          this.poll();
  6442      }
  6443  };
  6444  
  6445  /**
  6446   * Should be used to stop polling for filter with given id
  6447   *
  6448   * @method stopPolling
  6449   * @param {Number} pollId
  6450   */
  6451  RequestManager.prototype.stopPolling = function (pollId) {
  6452      delete this.polls[pollId];
  6453  
  6454      // stop polling
  6455      if(Object.keys(this.polls).length === 0 && this.timeout) {
  6456          clearTimeout(this.timeout);
  6457          this.timeout = null;
  6458      }
  6459  };
  6460  
  6461  /**
  6462   * Should be called to reset the polling mechanism of the request manager
  6463   *
  6464   * @method reset
  6465   */
  6466  RequestManager.prototype.reset = function (keepIsSyncing) {
  6467      /*jshint maxcomplexity:5 */
  6468  
  6469      for (var key in this.polls) {
  6470          // remove all polls, except sync polls,
  6471          // they need to be removed manually by calling syncing.stopWatching()
  6472          if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) {
  6473              this.polls[key].uninstall();
  6474              delete this.polls[key];
  6475          }
  6476      }
  6477  
  6478      // stop polling
  6479      if(Object.keys(this.polls).length === 0 && this.timeout) {
  6480          clearTimeout(this.timeout);
  6481          this.timeout = null;
  6482      }
  6483  };
  6484  
  6485  /**
  6486   * Should be called to poll for changes on filter with given id
  6487   *
  6488   * @method poll
  6489   */
  6490  RequestManager.prototype.poll = function () {
  6491      /*jshint maxcomplexity: 6 */
  6492      this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
  6493  
  6494      if (Object.keys(this.polls).length === 0) {
  6495          return;
  6496      }
  6497  
  6498      if (!this.provider) {
  6499          console.error(errors.InvalidProvider());
  6500          return;
  6501      }
  6502  
  6503      var pollsData = [];
  6504      var pollsIds = [];
  6505      for (var key in this.polls) {
  6506          pollsData.push(this.polls[key].data);
  6507          pollsIds.push(key);
  6508      }
  6509  
  6510      if (pollsData.length === 0) {
  6511          return;
  6512      }
  6513  
  6514      var payload = Jsonrpc.toBatchPayload(pollsData);
  6515      
  6516      // map the request id to they poll id
  6517      var pollsIdMap = {};
  6518      payload.forEach(function(load, index){
  6519          pollsIdMap[load.id] = pollsIds[index];
  6520      });
  6521  
  6522  
  6523      var self = this;
  6524      this.provider.sendAsync(payload, function (error, results) {
  6525  
  6526  
  6527          // TODO: console log?
  6528          if (error) {
  6529              return;
  6530          }
  6531  
  6532          if (!utils.isArray(results)) {
  6533              throw errors.InvalidResponse(results);
  6534          }
  6535          results.map(function (result) {
  6536              var id = pollsIdMap[result.id];
  6537  
  6538              // make sure the filter is still installed after arrival of the request
  6539              if (self.polls[id]) {
  6540                  result.callback = self.polls[id].callback;
  6541                  return result;
  6542              } else
  6543                  return false;
  6544          }).filter(function (result) {
  6545              return !!result; 
  6546          }).filter(function (result) {
  6547              var valid = Jsonrpc.isValidResponse(result);
  6548              if (!valid) {
  6549                  result.callback(errors.InvalidResponse(result));
  6550              }
  6551              return valid;
  6552          }).forEach(function (result) {
  6553              result.callback(null, result.result);
  6554          });
  6555      });
  6556  };
  6557  
  6558  module.exports = RequestManager;
  6559  
  6560  
  6561  },{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],47:[function(require,module,exports){
  6562  
  6563  
  6564  var Settings = function () {
  6565      this.defaultBlock = 'latest';
  6566      this.defaultAccount = undefined;
  6567  };
  6568  
  6569  module.exports = Settings;
  6570  
  6571  
  6572  },{}],48:[function(require,module,exports){
  6573  /*
  6574      This file is part of web3.js.
  6575  
  6576      web3.js is free software: you can redistribute it and/or modify
  6577      it under the terms of the GNU Lesser General Public License as published by
  6578      the Free Software Foundation, either version 3 of the License, or
  6579      (at your option) any later version.
  6580  
  6581      web3.js is distributed in the hope that it will be useful,
  6582      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6583      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6584      GNU Lesser General Public License for more details.
  6585  
  6586      You should have received a copy of the GNU Lesser General Public License
  6587      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6588  */
  6589  /** @file syncing.js
  6590   * @authors:
  6591   *   Fabian Vogelsteller <fabian@ethdev.com>
  6592   * @date 2015
  6593   */
  6594  
  6595  var formatters = require('./formatters');
  6596  var utils = require('../utils/utils');
  6597  
  6598  var count = 1;
  6599  
  6600  /**
  6601  Adds the callback and sets up the methods, to iterate over the results.
  6602  
  6603  @method pollSyncing
  6604  @param {Object} self
  6605  */
  6606  var pollSyncing = function(self) {
  6607  
  6608      var onMessage = function (error, sync) {
  6609          if (error) {
  6610              return self.callbacks.forEach(function (callback) {
  6611                  callback(error);
  6612              });
  6613          }
  6614  
  6615          if(utils.isObject(sync) && sync.startingBlock)
  6616              sync = formatters.outputSyncingFormatter(sync);
  6617  
  6618          self.callbacks.forEach(function (callback) {
  6619              if (self.lastSyncState !== sync) {
  6620                  
  6621                  // call the callback with true first so the app can stop anything, before receiving the sync data
  6622                  if(!self.lastSyncState && utils.isObject(sync))
  6623                      callback(null, true);
  6624                  
  6625                  // call on the next CPU cycle, so the actions of the sync stop can be processes first
  6626                  setTimeout(function() {
  6627                      callback(null, sync);
  6628                  }, 0);
  6629                  
  6630                  self.lastSyncState = sync;
  6631              }
  6632          });
  6633      };
  6634  
  6635      self.requestManager.startPolling({
  6636          method: 'eth_syncing',
  6637          params: [],
  6638      }, self.pollId, onMessage, self.stopWatching.bind(self));
  6639  
  6640  };
  6641  
  6642  var IsSyncing = function (requestManager, callback) {
  6643      this.requestManager = requestManager;
  6644      this.pollId = 'syncPoll_'+ count++;
  6645      this.callbacks = [];
  6646      this.addCallback(callback);
  6647      this.lastSyncState = false;
  6648      pollSyncing(this);
  6649  
  6650      return this;
  6651  };
  6652  
  6653  IsSyncing.prototype.addCallback = function (callback) {
  6654      if(callback)
  6655          this.callbacks.push(callback);
  6656      return this;
  6657  };
  6658  
  6659  IsSyncing.prototype.stopWatching = function () {
  6660      this.requestManager.stopPolling(this.pollId);
  6661      this.callbacks = [];
  6662  };
  6663  
  6664  module.exports = IsSyncing;
  6665  
  6666  
  6667  },{"../utils/utils":20,"./formatters":30}],49:[function(require,module,exports){
  6668  /*
  6669      This file is part of web3.js.
  6670  
  6671      web3.js is free software: you can redistribute it and/or modify
  6672      it under the terms of the GNU Lesser General Public License as published by
  6673      the Free Software Foundation, either version 3 of the License, or
  6674      (at your option) any later version.
  6675  
  6676      web3.js is distributed in the hope that it will be useful,
  6677      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6678      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6679      GNU Lesser General Public License for more details.
  6680  
  6681      You should have received a copy of the GNU Lesser General Public License
  6682      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6683  */
  6684  /** 
  6685   * @file transfer.js
  6686   * @author Marek Kotewicz <marek@ethdev.com>
  6687   * @date 2015
  6688   */
  6689  
  6690  var Iban = require('./iban');
  6691  var exchangeAbi = require('../contracts/SmartExchange.json');
  6692  
  6693  /**
  6694   * Should be used to make Iban transfer
  6695   *
  6696   * @method transfer
  6697   * @param {String} from
  6698   * @param {String} to iban
  6699   * @param {Value} value to be tranfered
  6700   * @param {Function} callback, callback
  6701   */
  6702  var transfer = function (eth, from, to, value, callback) {
  6703      var iban = new Iban(to); 
  6704      if (!iban.isValid()) {
  6705          throw new Error('invalid iban address');
  6706      }
  6707  
  6708      if (iban.isDirect()) {
  6709          return transferToAddress(eth, from, iban.address(), value, callback);
  6710      }
  6711      
  6712      if (!callback) {
  6713          var address = eth.icapNamereg().addr(iban.institution());
  6714          return deposit(eth, from, address, value, iban.client());
  6715      }
  6716  
  6717      eth.icapNamereg().addr(iban.institution(), function (err, address) {
  6718          return deposit(eth, from, address, value, iban.client(), callback);
  6719      });
  6720      
  6721  };
  6722  
  6723  /**
  6724   * Should be used to transfer funds to certain address
  6725   *
  6726   * @method transferToAddress
  6727   * @param {String} from
  6728   * @param {String} to
  6729   * @param {Value} value to be tranfered
  6730   * @param {Function} callback, callback
  6731   */
  6732  var transferToAddress = function (eth, from, to, value, callback) {
  6733      return eth.sendTransaction({
  6734          address: to,
  6735          from: from,
  6736          value: value
  6737      }, callback);
  6738  };
  6739  
  6740  /**
  6741   * Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
  6742   *
  6743   * @method deposit
  6744   * @param {String} from
  6745   * @param {String} to
  6746   * @param {Value} value to be transferred
  6747   * @param {String} client unique identifier
  6748   * @param {Function} callback, callback
  6749   */
  6750  var deposit = function (eth, from, to, value, client, callback) {
  6751      var abi = exchangeAbi;
  6752      return eth.contract(abi).at(to).deposit(client, {
  6753          from: from,
  6754          value: value
  6755      }, callback);
  6756  };
  6757  
  6758  module.exports = transfer;
  6759  
  6760  
  6761  },{"../contracts/SmartExchange.json":3,"./iban":33}],50:[function(require,module,exports){
  6762  
  6763  },{}],51:[function(require,module,exports){
  6764  ;(function (root, factory, undef) {
  6765  	if (typeof exports === "object") {
  6766  		// CommonJS
  6767  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  6768  	}
  6769  	else if (typeof define === "function" && define.amd) {
  6770  		// AMD
  6771  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  6772  	}
  6773  	else {
  6774  		// Global (browser)
  6775  		factory(root.CryptoJS);
  6776  	}
  6777  }(this, function (CryptoJS) {
  6778  
  6779  	(function () {
  6780  	    // Shortcuts
  6781  	    var C = CryptoJS;
  6782  	    var C_lib = C.lib;
  6783  	    var BlockCipher = C_lib.BlockCipher;
  6784  	    var C_algo = C.algo;
  6785  
  6786  	    // Lookup tables
  6787  	    var SBOX = [];
  6788  	    var INV_SBOX = [];
  6789  	    var SUB_MIX_0 = [];
  6790  	    var SUB_MIX_1 = [];
  6791  	    var SUB_MIX_2 = [];
  6792  	    var SUB_MIX_3 = [];
  6793  	    var INV_SUB_MIX_0 = [];
  6794  	    var INV_SUB_MIX_1 = [];
  6795  	    var INV_SUB_MIX_2 = [];
  6796  	    var INV_SUB_MIX_3 = [];
  6797  
  6798  	    // Compute lookup tables
  6799  	    (function () {
  6800  	        // Compute double table
  6801  	        var d = [];
  6802  	        for (var i = 0; i < 256; i++) {
  6803  	            if (i < 128) {
  6804  	                d[i] = i << 1;
  6805  	            } else {
  6806  	                d[i] = (i << 1) ^ 0x11b;
  6807  	            }
  6808  	        }
  6809  
  6810  	        // Walk GF(2^8)
  6811  	        var x = 0;
  6812  	        var xi = 0;
  6813  	        for (var i = 0; i < 256; i++) {
  6814  	            // Compute sbox
  6815  	            var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  6816  	            sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  6817  	            SBOX[x] = sx;
  6818  	            INV_SBOX[sx] = x;
  6819  
  6820  	            // Compute multiplication
  6821  	            var x2 = d[x];
  6822  	            var x4 = d[x2];
  6823  	            var x8 = d[x4];
  6824  
  6825  	            // Compute sub bytes, mix columns tables
  6826  	            var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  6827  	            SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  6828  	            SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  6829  	            SUB_MIX_2[x] = (t << 8)  | (t >>> 24);
  6830  	            SUB_MIX_3[x] = t;
  6831  
  6832  	            // Compute inv sub bytes, inv mix columns tables
  6833  	            var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  6834  	            INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  6835  	            INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  6836  	            INV_SUB_MIX_2[sx] = (t << 8)  | (t >>> 24);
  6837  	            INV_SUB_MIX_3[sx] = t;
  6838  
  6839  	            // Compute next counter
  6840  	            if (!x) {
  6841  	                x = xi = 1;
  6842  	            } else {
  6843  	                x = x2 ^ d[d[d[x8 ^ x2]]];
  6844  	                xi ^= d[d[xi]];
  6845  	            }
  6846  	        }
  6847  	    }());
  6848  
  6849  	    // Precomputed Rcon lookup
  6850  	    var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  6851  
  6852  	    /**
  6853  	     * AES block cipher algorithm.
  6854  	     */
  6855  	    var AES = C_algo.AES = BlockCipher.extend({
  6856  	        _doReset: function () {
  6857  	            // Skip reset of nRounds has been set before and key did not change
  6858  	            if (this._nRounds && this._keyPriorReset === this._key) {
  6859  	                return;
  6860  	            }
  6861  
  6862  	            // Shortcuts
  6863  	            var key = this._keyPriorReset = this._key;
  6864  	            var keyWords = key.words;
  6865  	            var keySize = key.sigBytes / 4;
  6866  
  6867  	            // Compute number of rounds
  6868  	            var nRounds = this._nRounds = keySize + 6;
  6869  
  6870  	            // Compute number of key schedule rows
  6871  	            var ksRows = (nRounds + 1) * 4;
  6872  
  6873  	            // Compute key schedule
  6874  	            var keySchedule = this._keySchedule = [];
  6875  	            for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  6876  	                if (ksRow < keySize) {
  6877  	                    keySchedule[ksRow] = keyWords[ksRow];
  6878  	                } else {
  6879  	                    var t = keySchedule[ksRow - 1];
  6880  
  6881  	                    if (!(ksRow % keySize)) {
  6882  	                        // Rot word
  6883  	                        t = (t << 8) | (t >>> 24);
  6884  
  6885  	                        // Sub word
  6886  	                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6887  
  6888  	                        // Mix Rcon
  6889  	                        t ^= RCON[(ksRow / keySize) | 0] << 24;
  6890  	                    } else if (keySize > 6 && ksRow % keySize == 4) {
  6891  	                        // Sub word
  6892  	                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6893  	                    }
  6894  
  6895  	                    keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  6896  	                }
  6897  	            }
  6898  
  6899  	            // Compute inv key schedule
  6900  	            var invKeySchedule = this._invKeySchedule = [];
  6901  	            for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  6902  	                var ksRow = ksRows - invKsRow;
  6903  
  6904  	                if (invKsRow % 4) {
  6905  	                    var t = keySchedule[ksRow];
  6906  	                } else {
  6907  	                    var t = keySchedule[ksRow - 4];
  6908  	                }
  6909  
  6910  	                if (invKsRow < 4 || ksRow <= 4) {
  6911  	                    invKeySchedule[invKsRow] = t;
  6912  	                } else {
  6913  	                    invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  6914  	                                               INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  6915  	                }
  6916  	            }
  6917  	        },
  6918  
  6919  	        encryptBlock: function (M, offset) {
  6920  	            this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  6921  	        },
  6922  
  6923  	        decryptBlock: function (M, offset) {
  6924  	            // Swap 2nd and 4th rows
  6925  	            var t = M[offset + 1];
  6926  	            M[offset + 1] = M[offset + 3];
  6927  	            M[offset + 3] = t;
  6928  
  6929  	            this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  6930  
  6931  	            // Inv swap 2nd and 4th rows
  6932  	            var t = M[offset + 1];
  6933  	            M[offset + 1] = M[offset + 3];
  6934  	            M[offset + 3] = t;
  6935  	        },
  6936  
  6937  	        _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  6938  	            // Shortcut
  6939  	            var nRounds = this._nRounds;
  6940  
  6941  	            // Get input, add round key
  6942  	            var s0 = M[offset]     ^ keySchedule[0];
  6943  	            var s1 = M[offset + 1] ^ keySchedule[1];
  6944  	            var s2 = M[offset + 2] ^ keySchedule[2];
  6945  	            var s3 = M[offset + 3] ^ keySchedule[3];
  6946  
  6947  	            // Key schedule row counter
  6948  	            var ksRow = 4;
  6949  
  6950  	            // Rounds
  6951  	            for (var round = 1; round < nRounds; round++) {
  6952  	                // Shift rows, sub bytes, mix columns, add round key
  6953  	                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++];
  6954  	                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++];
  6955  	                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++];
  6956  	                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++];
  6957  
  6958  	                // Update state
  6959  	                s0 = t0;
  6960  	                s1 = t1;
  6961  	                s2 = t2;
  6962  	                s3 = t3;
  6963  	            }
  6964  
  6965  	            // Shift rows, sub bytes, add round key
  6966  	            var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  6967  	            var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  6968  	            var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  6969  	            var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  6970  
  6971  	            // Set output
  6972  	            M[offset]     = t0;
  6973  	            M[offset + 1] = t1;
  6974  	            M[offset + 2] = t2;
  6975  	            M[offset + 3] = t3;
  6976  	        },
  6977  
  6978  	        keySize: 256/32
  6979  	    });
  6980  
  6981  	    /**
  6982  	     * Shortcut functions to the cipher's object interface.
  6983  	     *
  6984  	     * @example
  6985  	     *
  6986  	     *     var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  6987  	     *     var plaintext  = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  6988  	     */
  6989  	    C.AES = BlockCipher._createHelper(AES);
  6990  	}());
  6991  
  6992  
  6993  	return CryptoJS.AES;
  6994  
  6995  }));
  6996  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],52:[function(require,module,exports){
  6997  ;(function (root, factory) {
  6998  	if (typeof exports === "object") {
  6999  		// CommonJS
  7000  		module.exports = exports = factory(require("./core"));
  7001  	}
  7002  	else if (typeof define === "function" && define.amd) {
  7003  		// AMD
  7004  		define(["./core"], factory);
  7005  	}
  7006  	else {
  7007  		// Global (browser)
  7008  		factory(root.CryptoJS);
  7009  	}
  7010  }(this, function (CryptoJS) {
  7011  
  7012  	/**
  7013  	 * Cipher core components.
  7014  	 */
  7015  	CryptoJS.lib.Cipher || (function (undefined) {
  7016  	    // Shortcuts
  7017  	    var C = CryptoJS;
  7018  	    var C_lib = C.lib;
  7019  	    var Base = C_lib.Base;
  7020  	    var WordArray = C_lib.WordArray;
  7021  	    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  7022  	    var C_enc = C.enc;
  7023  	    var Utf8 = C_enc.Utf8;
  7024  	    var Base64 = C_enc.Base64;
  7025  	    var C_algo = C.algo;
  7026  	    var EvpKDF = C_algo.EvpKDF;
  7027  
  7028  	    /**
  7029  	     * Abstract base cipher template.
  7030  	     *
  7031  	     * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  7032  	     * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  7033  	     * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  7034  	     * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  7035  	     */
  7036  	    var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  7037  	        /**
  7038  	         * Configuration options.
  7039  	         *
  7040  	         * @property {WordArray} iv The IV to use for this operation.
  7041  	         */
  7042  	        cfg: Base.extend(),
  7043  
  7044  	        /**
  7045  	         * Creates this cipher in encryption mode.
  7046  	         *
  7047  	         * @param {WordArray} key The key.
  7048  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7049  	         *
  7050  	         * @return {Cipher} A cipher instance.
  7051  	         *
  7052  	         * @static
  7053  	         *
  7054  	         * @example
  7055  	         *
  7056  	         *     var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  7057  	         */
  7058  	        createEncryptor: function (key, cfg) {
  7059  	            return this.create(this._ENC_XFORM_MODE, key, cfg);
  7060  	        },
  7061  
  7062  	        /**
  7063  	         * Creates this cipher in decryption mode.
  7064  	         *
  7065  	         * @param {WordArray} key The key.
  7066  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7067  	         *
  7068  	         * @return {Cipher} A cipher instance.
  7069  	         *
  7070  	         * @static
  7071  	         *
  7072  	         * @example
  7073  	         *
  7074  	         *     var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  7075  	         */
  7076  	        createDecryptor: function (key, cfg) {
  7077  	            return this.create(this._DEC_XFORM_MODE, key, cfg);
  7078  	        },
  7079  
  7080  	        /**
  7081  	         * Initializes a newly created cipher.
  7082  	         *
  7083  	         * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  7084  	         * @param {WordArray} key The key.
  7085  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7086  	         *
  7087  	         * @example
  7088  	         *
  7089  	         *     var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  7090  	         */
  7091  	        init: function (xformMode, key, cfg) {
  7092  	            // Apply config defaults
  7093  	            this.cfg = this.cfg.extend(cfg);
  7094  
  7095  	            // Store transform mode and key
  7096  	            this._xformMode = xformMode;
  7097  	            this._key = key;
  7098  
  7099  	            // Set initial values
  7100  	            this.reset();
  7101  	        },
  7102  
  7103  	        /**
  7104  	         * Resets this cipher to its initial state.
  7105  	         *
  7106  	         * @example
  7107  	         *
  7108  	         *     cipher.reset();
  7109  	         */
  7110  	        reset: function () {
  7111  	            // Reset data buffer
  7112  	            BufferedBlockAlgorithm.reset.call(this);
  7113  
  7114  	            // Perform concrete-cipher logic
  7115  	            this._doReset();
  7116  	        },
  7117  
  7118  	        /**
  7119  	         * Adds data to be encrypted or decrypted.
  7120  	         *
  7121  	         * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  7122  	         *
  7123  	         * @return {WordArray} The data after processing.
  7124  	         *
  7125  	         * @example
  7126  	         *
  7127  	         *     var encrypted = cipher.process('data');
  7128  	         *     var encrypted = cipher.process(wordArray);
  7129  	         */
  7130  	        process: function (dataUpdate) {
  7131  	            // Append
  7132  	            this._append(dataUpdate);
  7133  
  7134  	            // Process available blocks
  7135  	            return this._process();
  7136  	        },
  7137  
  7138  	        /**
  7139  	         * Finalizes the encryption or decryption process.
  7140  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  7141  	         *
  7142  	         * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  7143  	         *
  7144  	         * @return {WordArray} The data after final processing.
  7145  	         *
  7146  	         * @example
  7147  	         *
  7148  	         *     var encrypted = cipher.finalize();
  7149  	         *     var encrypted = cipher.finalize('data');
  7150  	         *     var encrypted = cipher.finalize(wordArray);
  7151  	         */
  7152  	        finalize: function (dataUpdate) {
  7153  	            // Final data update
  7154  	            if (dataUpdate) {
  7155  	                this._append(dataUpdate);
  7156  	            }
  7157  
  7158  	            // Perform concrete-cipher logic
  7159  	            var finalProcessedData = this._doFinalize();
  7160  
  7161  	            return finalProcessedData;
  7162  	        },
  7163  
  7164  	        keySize: 128/32,
  7165  
  7166  	        ivSize: 128/32,
  7167  
  7168  	        _ENC_XFORM_MODE: 1,
  7169  
  7170  	        _DEC_XFORM_MODE: 2,
  7171  
  7172  	        /**
  7173  	         * Creates shortcut functions to a cipher's object interface.
  7174  	         *
  7175  	         * @param {Cipher} cipher The cipher to create a helper for.
  7176  	         *
  7177  	         * @return {Object} An object with encrypt and decrypt shortcut functions.
  7178  	         *
  7179  	         * @static
  7180  	         *
  7181  	         * @example
  7182  	         *
  7183  	         *     var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  7184  	         */
  7185  	        _createHelper: (function () {
  7186  	            function selectCipherStrategy(key) {
  7187  	                if (typeof key == 'string') {
  7188  	                    return PasswordBasedCipher;
  7189  	                } else {
  7190  	                    return SerializableCipher;
  7191  	                }
  7192  	            }
  7193  
  7194  	            return function (cipher) {
  7195  	                return {
  7196  	                    encrypt: function (message, key, cfg) {
  7197  	                        return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  7198  	                    },
  7199  
  7200  	                    decrypt: function (ciphertext, key, cfg) {
  7201  	                        return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  7202  	                    }
  7203  	                };
  7204  	            };
  7205  	        }())
  7206  	    });
  7207  
  7208  	    /**
  7209  	     * Abstract base stream cipher template.
  7210  	     *
  7211  	     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  7212  	     */
  7213  	    var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  7214  	        _doFinalize: function () {
  7215  	            // Process partial blocks
  7216  	            var finalProcessedBlocks = this._process(!!'flush');
  7217  
  7218  	            return finalProcessedBlocks;
  7219  	        },
  7220  
  7221  	        blockSize: 1
  7222  	    });
  7223  
  7224  	    /**
  7225  	     * Mode namespace.
  7226  	     */
  7227  	    var C_mode = C.mode = {};
  7228  
  7229  	    /**
  7230  	     * Abstract base block cipher mode template.
  7231  	     */
  7232  	    var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  7233  	        /**
  7234  	         * Creates this mode for encryption.
  7235  	         *
  7236  	         * @param {Cipher} cipher A block cipher instance.
  7237  	         * @param {Array} iv The IV words.
  7238  	         *
  7239  	         * @static
  7240  	         *
  7241  	         * @example
  7242  	         *
  7243  	         *     var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  7244  	         */
  7245  	        createEncryptor: function (cipher, iv) {
  7246  	            return this.Encryptor.create(cipher, iv);
  7247  	        },
  7248  
  7249  	        /**
  7250  	         * Creates this mode for decryption.
  7251  	         *
  7252  	         * @param {Cipher} cipher A block cipher instance.
  7253  	         * @param {Array} iv The IV words.
  7254  	         *
  7255  	         * @static
  7256  	         *
  7257  	         * @example
  7258  	         *
  7259  	         *     var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  7260  	         */
  7261  	        createDecryptor: function (cipher, iv) {
  7262  	            return this.Decryptor.create(cipher, iv);
  7263  	        },
  7264  
  7265  	        /**
  7266  	         * Initializes a newly created mode.
  7267  	         *
  7268  	         * @param {Cipher} cipher A block cipher instance.
  7269  	         * @param {Array} iv The IV words.
  7270  	         *
  7271  	         * @example
  7272  	         *
  7273  	         *     var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  7274  	         */
  7275  	        init: function (cipher, iv) {
  7276  	            this._cipher = cipher;
  7277  	            this._iv = iv;
  7278  	        }
  7279  	    });
  7280  
  7281  	    /**
  7282  	     * Cipher Block Chaining mode.
  7283  	     */
  7284  	    var CBC = C_mode.CBC = (function () {
  7285  	        /**
  7286  	         * Abstract base CBC mode.
  7287  	         */
  7288  	        var CBC = BlockCipherMode.extend();
  7289  
  7290  	        /**
  7291  	         * CBC encryptor.
  7292  	         */
  7293  	        CBC.Encryptor = CBC.extend({
  7294  	            /**
  7295  	             * Processes the data block at offset.
  7296  	             *
  7297  	             * @param {Array} words The data words to operate on.
  7298  	             * @param {number} offset The offset where the block starts.
  7299  	             *
  7300  	             * @example
  7301  	             *
  7302  	             *     mode.processBlock(data.words, offset);
  7303  	             */
  7304  	            processBlock: function (words, offset) {
  7305  	                // Shortcuts
  7306  	                var cipher = this._cipher;
  7307  	                var blockSize = cipher.blockSize;
  7308  
  7309  	                // XOR and encrypt
  7310  	                xorBlock.call(this, words, offset, blockSize);
  7311  	                cipher.encryptBlock(words, offset);
  7312  
  7313  	                // Remember this block to use with next block
  7314  	                this._prevBlock = words.slice(offset, offset + blockSize);
  7315  	            }
  7316  	        });
  7317  
  7318  	        /**
  7319  	         * CBC decryptor.
  7320  	         */
  7321  	        CBC.Decryptor = CBC.extend({
  7322  	            /**
  7323  	             * Processes the data block at offset.
  7324  	             *
  7325  	             * @param {Array} words The data words to operate on.
  7326  	             * @param {number} offset The offset where the block starts.
  7327  	             *
  7328  	             * @example
  7329  	             *
  7330  	             *     mode.processBlock(data.words, offset);
  7331  	             */
  7332  	            processBlock: function (words, offset) {
  7333  	                // Shortcuts
  7334  	                var cipher = this._cipher;
  7335  	                var blockSize = cipher.blockSize;
  7336  
  7337  	                // Remember this block to use with next block
  7338  	                var thisBlock = words.slice(offset, offset + blockSize);
  7339  
  7340  	                // Decrypt and XOR
  7341  	                cipher.decryptBlock(words, offset);
  7342  	                xorBlock.call(this, words, offset, blockSize);
  7343  
  7344  	                // This block becomes the previous block
  7345  	                this._prevBlock = thisBlock;
  7346  	            }
  7347  	        });
  7348  
  7349  	        function xorBlock(words, offset, blockSize) {
  7350  	            // Shortcut
  7351  	            var iv = this._iv;
  7352  
  7353  	            // Choose mixing block
  7354  	            if (iv) {
  7355  	                var block = iv;
  7356  
  7357  	                // Remove IV for subsequent blocks
  7358  	                this._iv = undefined;
  7359  	            } else {
  7360  	                var block = this._prevBlock;
  7361  	            }
  7362  
  7363  	            // XOR blocks
  7364  	            for (var i = 0; i < blockSize; i++) {
  7365  	                words[offset + i] ^= block[i];
  7366  	            }
  7367  	        }
  7368  
  7369  	        return CBC;
  7370  	    }());
  7371  
  7372  	    /**
  7373  	     * Padding namespace.
  7374  	     */
  7375  	    var C_pad = C.pad = {};
  7376  
  7377  	    /**
  7378  	     * PKCS #5/7 padding strategy.
  7379  	     */
  7380  	    var Pkcs7 = C_pad.Pkcs7 = {
  7381  	        /**
  7382  	         * Pads data using the algorithm defined in PKCS #5/7.
  7383  	         *
  7384  	         * @param {WordArray} data The data to pad.
  7385  	         * @param {number} blockSize The multiple that the data should be padded to.
  7386  	         *
  7387  	         * @static
  7388  	         *
  7389  	         * @example
  7390  	         *
  7391  	         *     CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  7392  	         */
  7393  	        pad: function (data, blockSize) {
  7394  	            // Shortcut
  7395  	            var blockSizeBytes = blockSize * 4;
  7396  
  7397  	            // Count padding bytes
  7398  	            var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  7399  
  7400  	            // Create padding word
  7401  	            var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  7402  
  7403  	            // Create padding
  7404  	            var paddingWords = [];
  7405  	            for (var i = 0; i < nPaddingBytes; i += 4) {
  7406  	                paddingWords.push(paddingWord);
  7407  	            }
  7408  	            var padding = WordArray.create(paddingWords, nPaddingBytes);
  7409  
  7410  	            // Add padding
  7411  	            data.concat(padding);
  7412  	        },
  7413  
  7414  	        /**
  7415  	         * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  7416  	         *
  7417  	         * @param {WordArray} data The data to unpad.
  7418  	         *
  7419  	         * @static
  7420  	         *
  7421  	         * @example
  7422  	         *
  7423  	         *     CryptoJS.pad.Pkcs7.unpad(wordArray);
  7424  	         */
  7425  	        unpad: function (data) {
  7426  	            // Get number of padding bytes from last byte
  7427  	            var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  7428  
  7429  	            // Remove padding
  7430  	            data.sigBytes -= nPaddingBytes;
  7431  	        }
  7432  	    };
  7433  
  7434  	    /**
  7435  	     * Abstract base block cipher template.
  7436  	     *
  7437  	     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  7438  	     */
  7439  	    var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  7440  	        /**
  7441  	         * Configuration options.
  7442  	         *
  7443  	         * @property {Mode} mode The block mode to use. Default: CBC
  7444  	         * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  7445  	         */
  7446  	        cfg: Cipher.cfg.extend({
  7447  	            mode: CBC,
  7448  	            padding: Pkcs7
  7449  	        }),
  7450  
  7451  	        reset: function () {
  7452  	            // Reset cipher
  7453  	            Cipher.reset.call(this);
  7454  
  7455  	            // Shortcuts
  7456  	            var cfg = this.cfg;
  7457  	            var iv = cfg.iv;
  7458  	            var mode = cfg.mode;
  7459  
  7460  	            // Reset block mode
  7461  	            if (this._xformMode == this._ENC_XFORM_MODE) {
  7462  	                var modeCreator = mode.createEncryptor;
  7463  	            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7464  	                var modeCreator = mode.createDecryptor;
  7465  
  7466  	                // Keep at least one block in the buffer for unpadding
  7467  	                this._minBufferSize = 1;
  7468  	            }
  7469  	            this._mode = modeCreator.call(mode, this, iv && iv.words);
  7470  	        },
  7471  
  7472  	        _doProcessBlock: function (words, offset) {
  7473  	            this._mode.processBlock(words, offset);
  7474  	        },
  7475  
  7476  	        _doFinalize: function () {
  7477  	            // Shortcut
  7478  	            var padding = this.cfg.padding;
  7479  
  7480  	            // Finalize
  7481  	            if (this._xformMode == this._ENC_XFORM_MODE) {
  7482  	                // Pad data
  7483  	                padding.pad(this._data, this.blockSize);
  7484  
  7485  	                // Process final blocks
  7486  	                var finalProcessedBlocks = this._process(!!'flush');
  7487  	            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7488  	                // Process final blocks
  7489  	                var finalProcessedBlocks = this._process(!!'flush');
  7490  
  7491  	                // Unpad data
  7492  	                padding.unpad(finalProcessedBlocks);
  7493  	            }
  7494  
  7495  	            return finalProcessedBlocks;
  7496  	        },
  7497  
  7498  	        blockSize: 128/32
  7499  	    });
  7500  
  7501  	    /**
  7502  	     * A collection of cipher parameters.
  7503  	     *
  7504  	     * @property {WordArray} ciphertext The raw ciphertext.
  7505  	     * @property {WordArray} key The key to this ciphertext.
  7506  	     * @property {WordArray} iv The IV used in the ciphering operation.
  7507  	     * @property {WordArray} salt The salt used with a key derivation function.
  7508  	     * @property {Cipher} algorithm The cipher algorithm.
  7509  	     * @property {Mode} mode The block mode used in the ciphering operation.
  7510  	     * @property {Padding} padding The padding scheme used in the ciphering operation.
  7511  	     * @property {number} blockSize The block size of the cipher.
  7512  	     * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  7513  	     */
  7514  	    var CipherParams = C_lib.CipherParams = Base.extend({
  7515  	        /**
  7516  	         * Initializes a newly created cipher params object.
  7517  	         *
  7518  	         * @param {Object} cipherParams An object with any of the possible cipher parameters.
  7519  	         *
  7520  	         * @example
  7521  	         *
  7522  	         *     var cipherParams = CryptoJS.lib.CipherParams.create({
  7523  	         *         ciphertext: ciphertextWordArray,
  7524  	         *         key: keyWordArray,
  7525  	         *         iv: ivWordArray,
  7526  	         *         salt: saltWordArray,
  7527  	         *         algorithm: CryptoJS.algo.AES,
  7528  	         *         mode: CryptoJS.mode.CBC,
  7529  	         *         padding: CryptoJS.pad.PKCS7,
  7530  	         *         blockSize: 4,
  7531  	         *         formatter: CryptoJS.format.OpenSSL
  7532  	         *     });
  7533  	         */
  7534  	        init: function (cipherParams) {
  7535  	            this.mixIn(cipherParams);
  7536  	        },
  7537  
  7538  	        /**
  7539  	         * Converts this cipher params object to a string.
  7540  	         *
  7541  	         * @param {Format} formatter (Optional) The formatting strategy to use.
  7542  	         *
  7543  	         * @return {string} The stringified cipher params.
  7544  	         *
  7545  	         * @throws Error If neither the formatter nor the default formatter is set.
  7546  	         *
  7547  	         * @example
  7548  	         *
  7549  	         *     var string = cipherParams + '';
  7550  	         *     var string = cipherParams.toString();
  7551  	         *     var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  7552  	         */
  7553  	        toString: function (formatter) {
  7554  	            return (formatter || this.formatter).stringify(this);
  7555  	        }
  7556  	    });
  7557  
  7558  	    /**
  7559  	     * Format namespace.
  7560  	     */
  7561  	    var C_format = C.format = {};
  7562  
  7563  	    /**
  7564  	     * OpenSSL formatting strategy.
  7565  	     */
  7566  	    var OpenSSLFormatter = C_format.OpenSSL = {
  7567  	        /**
  7568  	         * Converts a cipher params object to an OpenSSL-compatible string.
  7569  	         *
  7570  	         * @param {CipherParams} cipherParams The cipher params object.
  7571  	         *
  7572  	         * @return {string} The OpenSSL-compatible string.
  7573  	         *
  7574  	         * @static
  7575  	         *
  7576  	         * @example
  7577  	         *
  7578  	         *     var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  7579  	         */
  7580  	        stringify: function (cipherParams) {
  7581  	            // Shortcuts
  7582  	            var ciphertext = cipherParams.ciphertext;
  7583  	            var salt = cipherParams.salt;
  7584  
  7585  	            // Format
  7586  	            if (salt) {
  7587  	                var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  7588  	            } else {
  7589  	                var wordArray = ciphertext;
  7590  	            }
  7591  
  7592  	            return wordArray.toString(Base64);
  7593  	        },
  7594  
  7595  	        /**
  7596  	         * Converts an OpenSSL-compatible string to a cipher params object.
  7597  	         *
  7598  	         * @param {string} openSSLStr The OpenSSL-compatible string.
  7599  	         *
  7600  	         * @return {CipherParams} The cipher params object.
  7601  	         *
  7602  	         * @static
  7603  	         *
  7604  	         * @example
  7605  	         *
  7606  	         *     var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  7607  	         */
  7608  	        parse: function (openSSLStr) {
  7609  	            // Parse base64
  7610  	            var ciphertext = Base64.parse(openSSLStr);
  7611  
  7612  	            // Shortcut
  7613  	            var ciphertextWords = ciphertext.words;
  7614  
  7615  	            // Test for salt
  7616  	            if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  7617  	                // Extract salt
  7618  	                var salt = WordArray.create(ciphertextWords.slice(2, 4));
  7619  
  7620  	                // Remove salt from ciphertext
  7621  	                ciphertextWords.splice(0, 4);
  7622  	                ciphertext.sigBytes -= 16;
  7623  	            }
  7624  
  7625  	            return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  7626  	        }
  7627  	    };
  7628  
  7629  	    /**
  7630  	     * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  7631  	     */
  7632  	    var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  7633  	        /**
  7634  	         * Configuration options.
  7635  	         *
  7636  	         * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  7637  	         */
  7638  	        cfg: Base.extend({
  7639  	            format: OpenSSLFormatter
  7640  	        }),
  7641  
  7642  	        /**
  7643  	         * Encrypts a message.
  7644  	         *
  7645  	         * @param {Cipher} cipher The cipher algorithm to use.
  7646  	         * @param {WordArray|string} message The message to encrypt.
  7647  	         * @param {WordArray} key The key.
  7648  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7649  	         *
  7650  	         * @return {CipherParams} A cipher params object.
  7651  	         *
  7652  	         * @static
  7653  	         *
  7654  	         * @example
  7655  	         *
  7656  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  7657  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  7658  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7659  	         */
  7660  	        encrypt: function (cipher, message, key, cfg) {
  7661  	            // Apply config defaults
  7662  	            cfg = this.cfg.extend(cfg);
  7663  
  7664  	            // Encrypt
  7665  	            var encryptor = cipher.createEncryptor(key, cfg);
  7666  	            var ciphertext = encryptor.finalize(message);
  7667  
  7668  	            // Shortcut
  7669  	            var cipherCfg = encryptor.cfg;
  7670  
  7671  	            // Create and return serializable cipher params
  7672  	            return CipherParams.create({
  7673  	                ciphertext: ciphertext,
  7674  	                key: key,
  7675  	                iv: cipherCfg.iv,
  7676  	                algorithm: cipher,
  7677  	                mode: cipherCfg.mode,
  7678  	                padding: cipherCfg.padding,
  7679  	                blockSize: cipher.blockSize,
  7680  	                formatter: cfg.format
  7681  	            });
  7682  	        },
  7683  
  7684  	        /**
  7685  	         * Decrypts serialized ciphertext.
  7686  	         *
  7687  	         * @param {Cipher} cipher The cipher algorithm to use.
  7688  	         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7689  	         * @param {WordArray} key The key.
  7690  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7691  	         *
  7692  	         * @return {WordArray} The plaintext.
  7693  	         *
  7694  	         * @static
  7695  	         *
  7696  	         * @example
  7697  	         *
  7698  	         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7699  	         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7700  	         */
  7701  	        decrypt: function (cipher, ciphertext, key, cfg) {
  7702  	            // Apply config defaults
  7703  	            cfg = this.cfg.extend(cfg);
  7704  
  7705  	            // Convert string to CipherParams
  7706  	            ciphertext = this._parse(ciphertext, cfg.format);
  7707  
  7708  	            // Decrypt
  7709  	            var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  7710  
  7711  	            return plaintext;
  7712  	        },
  7713  
  7714  	        /**
  7715  	         * Converts serialized ciphertext to CipherParams,
  7716  	         * else assumed CipherParams already and returns ciphertext unchanged.
  7717  	         *
  7718  	         * @param {CipherParams|string} ciphertext The ciphertext.
  7719  	         * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  7720  	         *
  7721  	         * @return {CipherParams} The unserialized ciphertext.
  7722  	         *
  7723  	         * @static
  7724  	         *
  7725  	         * @example
  7726  	         *
  7727  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  7728  	         */
  7729  	        _parse: function (ciphertext, format) {
  7730  	            if (typeof ciphertext == 'string') {
  7731  	                return format.parse(ciphertext, this);
  7732  	            } else {
  7733  	                return ciphertext;
  7734  	            }
  7735  	        }
  7736  	    });
  7737  
  7738  	    /**
  7739  	     * Key derivation function namespace.
  7740  	     */
  7741  	    var C_kdf = C.kdf = {};
  7742  
  7743  	    /**
  7744  	     * OpenSSL key derivation function.
  7745  	     */
  7746  	    var OpenSSLKdf = C_kdf.OpenSSL = {
  7747  	        /**
  7748  	         * Derives a key and IV from a password.
  7749  	         *
  7750  	         * @param {string} password The password to derive from.
  7751  	         * @param {number} keySize The size in words of the key to generate.
  7752  	         * @param {number} ivSize The size in words of the IV to generate.
  7753  	         * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  7754  	         *
  7755  	         * @return {CipherParams} A cipher params object with the key, IV, and salt.
  7756  	         *
  7757  	         * @static
  7758  	         *
  7759  	         * @example
  7760  	         *
  7761  	         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  7762  	         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  7763  	         */
  7764  	        execute: function (password, keySize, ivSize, salt) {
  7765  	            // Generate random salt
  7766  	            if (!salt) {
  7767  	                salt = WordArray.random(64/8);
  7768  	            }
  7769  
  7770  	            // Derive key and IV
  7771  	            var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  7772  
  7773  	            // Separate key and IV
  7774  	            var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  7775  	            key.sigBytes = keySize * 4;
  7776  
  7777  	            // Return params
  7778  	            return CipherParams.create({ key: key, iv: iv, salt: salt });
  7779  	        }
  7780  	    };
  7781  
  7782  	    /**
  7783  	     * A serializable cipher wrapper that derives the key from a password,
  7784  	     * and returns ciphertext as a serializable cipher params object.
  7785  	     */
  7786  	    var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  7787  	        /**
  7788  	         * Configuration options.
  7789  	         *
  7790  	         * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  7791  	         */
  7792  	        cfg: SerializableCipher.cfg.extend({
  7793  	            kdf: OpenSSLKdf
  7794  	        }),
  7795  
  7796  	        /**
  7797  	         * Encrypts a message using a password.
  7798  	         *
  7799  	         * @param {Cipher} cipher The cipher algorithm to use.
  7800  	         * @param {WordArray|string} message The message to encrypt.
  7801  	         * @param {string} password The password.
  7802  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7803  	         *
  7804  	         * @return {CipherParams} A cipher params object.
  7805  	         *
  7806  	         * @static
  7807  	         *
  7808  	         * @example
  7809  	         *
  7810  	         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  7811  	         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  7812  	         */
  7813  	        encrypt: function (cipher, message, password, cfg) {
  7814  	            // Apply config defaults
  7815  	            cfg = this.cfg.extend(cfg);
  7816  
  7817  	            // Derive key and other params
  7818  	            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  7819  
  7820  	            // Add IV to config
  7821  	            cfg.iv = derivedParams.iv;
  7822  
  7823  	            // Encrypt
  7824  	            var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  7825  
  7826  	            // Mix in derived params
  7827  	            ciphertext.mixIn(derivedParams);
  7828  
  7829  	            return ciphertext;
  7830  	        },
  7831  
  7832  	        /**
  7833  	         * Decrypts serialized ciphertext using a password.
  7834  	         *
  7835  	         * @param {Cipher} cipher The cipher algorithm to use.
  7836  	         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7837  	         * @param {string} password The password.
  7838  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7839  	         *
  7840  	         * @return {WordArray} The plaintext.
  7841  	         *
  7842  	         * @static
  7843  	         *
  7844  	         * @example
  7845  	         *
  7846  	         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  7847  	         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  7848  	         */
  7849  	        decrypt: function (cipher, ciphertext, password, cfg) {
  7850  	            // Apply config defaults
  7851  	            cfg = this.cfg.extend(cfg);
  7852  
  7853  	            // Convert string to CipherParams
  7854  	            ciphertext = this._parse(ciphertext, cfg.format);
  7855  
  7856  	            // Derive key and other params
  7857  	            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  7858  
  7859  	            // Add IV to config
  7860  	            cfg.iv = derivedParams.iv;
  7861  
  7862  	            // Decrypt
  7863  	            var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  7864  
  7865  	            return plaintext;
  7866  	        }
  7867  	    });
  7868  	}());
  7869  
  7870  
  7871  }));
  7872  },{"./core":53}],53:[function(require,module,exports){
  7873  ;(function (root, factory) {
  7874  	if (typeof exports === "object") {
  7875  		// CommonJS
  7876  		module.exports = exports = factory();
  7877  	}
  7878  	else if (typeof define === "function" && define.amd) {
  7879  		// AMD
  7880  		define([], factory);
  7881  	}
  7882  	else {
  7883  		// Global (browser)
  7884  		root.CryptoJS = factory();
  7885  	}
  7886  }(this, function () {
  7887  
  7888  	/**
  7889  	 * CryptoJS core components.
  7890  	 */
  7891  	var CryptoJS = CryptoJS || (function (Math, undefined) {
  7892  	    /*
  7893  	     * Local polyfil of Object.create
  7894  	     */
  7895  	    var create = Object.create || (function () {
  7896  	        function F() {};
  7897  
  7898  	        return function (obj) {
  7899  	            var subtype;
  7900  
  7901  	            F.prototype = obj;
  7902  
  7903  	            subtype = new F();
  7904  
  7905  	            F.prototype = null;
  7906  
  7907  	            return subtype;
  7908  	        };
  7909  	    }())
  7910  
  7911  	    /**
  7912  	     * CryptoJS namespace.
  7913  	     */
  7914  	    var C = {};
  7915  
  7916  	    /**
  7917  	     * Library namespace.
  7918  	     */
  7919  	    var C_lib = C.lib = {};
  7920  
  7921  	    /**
  7922  	     * Base object for prototypal inheritance.
  7923  	     */
  7924  	    var Base = C_lib.Base = (function () {
  7925  
  7926  
  7927  	        return {
  7928  	            /**
  7929  	             * Creates a new object that inherits from this object.
  7930  	             *
  7931  	             * @param {Object} overrides Properties to copy into the new object.
  7932  	             *
  7933  	             * @return {Object} The new object.
  7934  	             *
  7935  	             * @static
  7936  	             *
  7937  	             * @example
  7938  	             *
  7939  	             *     var MyType = CryptoJS.lib.Base.extend({
  7940  	             *         field: 'value',
  7941  	             *
  7942  	             *         method: function () {
  7943  	             *         }
  7944  	             *     });
  7945  	             */
  7946  	            extend: function (overrides) {
  7947  	                // Spawn
  7948  	                var subtype = create(this);
  7949  
  7950  	                // Augment
  7951  	                if (overrides) {
  7952  	                    subtype.mixIn(overrides);
  7953  	                }
  7954  
  7955  	                // Create default initializer
  7956  	                if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  7957  	                    subtype.init = function () {
  7958  	                        subtype.$super.init.apply(this, arguments);
  7959  	                    };
  7960  	                }
  7961  
  7962  	                // Initializer's prototype is the subtype object
  7963  	                subtype.init.prototype = subtype;
  7964  
  7965  	                // Reference supertype
  7966  	                subtype.$super = this;
  7967  
  7968  	                return subtype;
  7969  	            },
  7970  
  7971  	            /**
  7972  	             * Extends this object and runs the init method.
  7973  	             * Arguments to create() will be passed to init().
  7974  	             *
  7975  	             * @return {Object} The new object.
  7976  	             *
  7977  	             * @static
  7978  	             *
  7979  	             * @example
  7980  	             *
  7981  	             *     var instance = MyType.create();
  7982  	             */
  7983  	            create: function () {
  7984  	                var instance = this.extend();
  7985  	                instance.init.apply(instance, arguments);
  7986  
  7987  	                return instance;
  7988  	            },
  7989  
  7990  	            /**
  7991  	             * Initializes a newly created object.
  7992  	             * Override this method to add some logic when your objects are created.
  7993  	             *
  7994  	             * @example
  7995  	             *
  7996  	             *     var MyType = CryptoJS.lib.Base.extend({
  7997  	             *         init: function () {
  7998  	             *             // ...
  7999  	             *         }
  8000  	             *     });
  8001  	             */
  8002  	            init: function () {
  8003  	            },
  8004  
  8005  	            /**
  8006  	             * Copies properties into this object.
  8007  	             *
  8008  	             * @param {Object} properties The properties to mix in.
  8009  	             *
  8010  	             * @example
  8011  	             *
  8012  	             *     MyType.mixIn({
  8013  	             *         field: 'value'
  8014  	             *     });
  8015  	             */
  8016  	            mixIn: function (properties) {
  8017  	                for (var propertyName in properties) {
  8018  	                    if (properties.hasOwnProperty(propertyName)) {
  8019  	                        this[propertyName] = properties[propertyName];
  8020  	                    }
  8021  	                }
  8022  
  8023  	                // IE won't copy toString using the loop above
  8024  	                if (properties.hasOwnProperty('toString')) {
  8025  	                    this.toString = properties.toString;
  8026  	                }
  8027  	            },
  8028  
  8029  	            /**
  8030  	             * Creates a copy of this object.
  8031  	             *
  8032  	             * @return {Object} The clone.
  8033  	             *
  8034  	             * @example
  8035  	             *
  8036  	             *     var clone = instance.clone();
  8037  	             */
  8038  	            clone: function () {
  8039  	                return this.init.prototype.extend(this);
  8040  	            }
  8041  	        };
  8042  	    }());
  8043  
  8044  	    /**
  8045  	     * An array of 32-bit words.
  8046  	     *
  8047  	     * @property {Array} words The array of 32-bit words.
  8048  	     * @property {number} sigBytes The number of significant bytes in this word array.
  8049  	     */
  8050  	    var WordArray = C_lib.WordArray = Base.extend({
  8051  	        /**
  8052  	         * Initializes a newly created word array.
  8053  	         *
  8054  	         * @param {Array} words (Optional) An array of 32-bit words.
  8055  	         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  8056  	         *
  8057  	         * @example
  8058  	         *
  8059  	         *     var wordArray = CryptoJS.lib.WordArray.create();
  8060  	         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  8061  	         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  8062  	         */
  8063  	        init: function (words, sigBytes) {
  8064  	            words = this.words = words || [];
  8065  
  8066  	            if (sigBytes != undefined) {
  8067  	                this.sigBytes = sigBytes;
  8068  	            } else {
  8069  	                this.sigBytes = words.length * 4;
  8070  	            }
  8071  	        },
  8072  
  8073  	        /**
  8074  	         * Converts this word array to a string.
  8075  	         *
  8076  	         * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  8077  	         *
  8078  	         * @return {string} The stringified word array.
  8079  	         *
  8080  	         * @example
  8081  	         *
  8082  	         *     var string = wordArray + '';
  8083  	         *     var string = wordArray.toString();
  8084  	         *     var string = wordArray.toString(CryptoJS.enc.Utf8);
  8085  	         */
  8086  	        toString: function (encoder) {
  8087  	            return (encoder || Hex).stringify(this);
  8088  	        },
  8089  
  8090  	        /**
  8091  	         * Concatenates a word array to this word array.
  8092  	         *
  8093  	         * @param {WordArray} wordArray The word array to append.
  8094  	         *
  8095  	         * @return {WordArray} This word array.
  8096  	         *
  8097  	         * @example
  8098  	         *
  8099  	         *     wordArray1.concat(wordArray2);
  8100  	         */
  8101  	        concat: function (wordArray) {
  8102  	            // Shortcuts
  8103  	            var thisWords = this.words;
  8104  	            var thatWords = wordArray.words;
  8105  	            var thisSigBytes = this.sigBytes;
  8106  	            var thatSigBytes = wordArray.sigBytes;
  8107  
  8108  	            // Clamp excess bits
  8109  	            this.clamp();
  8110  
  8111  	            // Concat
  8112  	            if (thisSigBytes % 4) {
  8113  	                // Copy one byte at a time
  8114  	                for (var i = 0; i < thatSigBytes; i++) {
  8115  	                    var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8116  	                    thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  8117  	                }
  8118  	            } else {
  8119  	                // Copy one word at a time
  8120  	                for (var i = 0; i < thatSigBytes; i += 4) {
  8121  	                    thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
  8122  	                }
  8123  	            }
  8124  	            this.sigBytes += thatSigBytes;
  8125  
  8126  	            // Chainable
  8127  	            return this;
  8128  	        },
  8129  
  8130  	        /**
  8131  	         * Removes insignificant bits.
  8132  	         *
  8133  	         * @example
  8134  	         *
  8135  	         *     wordArray.clamp();
  8136  	         */
  8137  	        clamp: function () {
  8138  	            // Shortcuts
  8139  	            var words = this.words;
  8140  	            var sigBytes = this.sigBytes;
  8141  
  8142  	            // Clamp
  8143  	            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  8144  	            words.length = Math.ceil(sigBytes / 4);
  8145  	        },
  8146  
  8147  	        /**
  8148  	         * Creates a copy of this word array.
  8149  	         *
  8150  	         * @return {WordArray} The clone.
  8151  	         *
  8152  	         * @example
  8153  	         *
  8154  	         *     var clone = wordArray.clone();
  8155  	         */
  8156  	        clone: function () {
  8157  	            var clone = Base.clone.call(this);
  8158  	            clone.words = this.words.slice(0);
  8159  
  8160  	            return clone;
  8161  	        },
  8162  
  8163  	        /**
  8164  	         * Creates a word array filled with random bytes.
  8165  	         *
  8166  	         * @param {number} nBytes The number of random bytes to generate.
  8167  	         *
  8168  	         * @return {WordArray} The random word array.
  8169  	         *
  8170  	         * @static
  8171  	         *
  8172  	         * @example
  8173  	         *
  8174  	         *     var wordArray = CryptoJS.lib.WordArray.random(16);
  8175  	         */
  8176  	        random: function (nBytes) {
  8177  	            var words = [];
  8178  
  8179  	            var r = (function (m_w) {
  8180  	                var m_w = m_w;
  8181  	                var m_z = 0x3ade68b1;
  8182  	                var mask = 0xffffffff;
  8183  
  8184  	                return function () {
  8185  	                    m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
  8186  	                    m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
  8187  	                    var result = ((m_z << 0x10) + m_w) & mask;
  8188  	                    result /= 0x100000000;
  8189  	                    result += 0.5;
  8190  	                    return result * (Math.random() > .5 ? 1 : -1);
  8191  	                }
  8192  	            });
  8193  
  8194  	            for (var i = 0, rcache; i < nBytes; i += 4) {
  8195  	                var _r = r((rcache || Math.random()) * 0x100000000);
  8196  
  8197  	                rcache = _r() * 0x3ade67b7;
  8198  	                words.push((_r() * 0x100000000) | 0);
  8199  	            }
  8200  
  8201  	            return new WordArray.init(words, nBytes);
  8202  	        }
  8203  	    });
  8204  
  8205  	    /**
  8206  	     * Encoder namespace.
  8207  	     */
  8208  	    var C_enc = C.enc = {};
  8209  
  8210  	    /**
  8211  	     * Hex encoding strategy.
  8212  	     */
  8213  	    var Hex = C_enc.Hex = {
  8214  	        /**
  8215  	         * Converts a word array to a hex string.
  8216  	         *
  8217  	         * @param {WordArray} wordArray The word array.
  8218  	         *
  8219  	         * @return {string} The hex string.
  8220  	         *
  8221  	         * @static
  8222  	         *
  8223  	         * @example
  8224  	         *
  8225  	         *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  8226  	         */
  8227  	        stringify: function (wordArray) {
  8228  	            // Shortcuts
  8229  	            var words = wordArray.words;
  8230  	            var sigBytes = wordArray.sigBytes;
  8231  
  8232  	            // Convert
  8233  	            var hexChars = [];
  8234  	            for (var i = 0; i < sigBytes; i++) {
  8235  	                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8236  	                hexChars.push((bite >>> 4).toString(16));
  8237  	                hexChars.push((bite & 0x0f).toString(16));
  8238  	            }
  8239  
  8240  	            return hexChars.join('');
  8241  	        },
  8242  
  8243  	        /**
  8244  	         * Converts a hex string to a word array.
  8245  	         *
  8246  	         * @param {string} hexStr The hex string.
  8247  	         *
  8248  	         * @return {WordArray} The word array.
  8249  	         *
  8250  	         * @static
  8251  	         *
  8252  	         * @example
  8253  	         *
  8254  	         *     var wordArray = CryptoJS.enc.Hex.parse(hexString);
  8255  	         */
  8256  	        parse: function (hexStr) {
  8257  	            // Shortcut
  8258  	            var hexStrLength = hexStr.length;
  8259  
  8260  	            // Convert
  8261  	            var words = [];
  8262  	            for (var i = 0; i < hexStrLength; i += 2) {
  8263  	                words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  8264  	            }
  8265  
  8266  	            return new WordArray.init(words, hexStrLength / 2);
  8267  	        }
  8268  	    };
  8269  
  8270  	    /**
  8271  	     * Latin1 encoding strategy.
  8272  	     */
  8273  	    var Latin1 = C_enc.Latin1 = {
  8274  	        /**
  8275  	         * Converts a word array to a Latin1 string.
  8276  	         *
  8277  	         * @param {WordArray} wordArray The word array.
  8278  	         *
  8279  	         * @return {string} The Latin1 string.
  8280  	         *
  8281  	         * @static
  8282  	         *
  8283  	         * @example
  8284  	         *
  8285  	         *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  8286  	         */
  8287  	        stringify: function (wordArray) {
  8288  	            // Shortcuts
  8289  	            var words = wordArray.words;
  8290  	            var sigBytes = wordArray.sigBytes;
  8291  
  8292  	            // Convert
  8293  	            var latin1Chars = [];
  8294  	            for (var i = 0; i < sigBytes; i++) {
  8295  	                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8296  	                latin1Chars.push(String.fromCharCode(bite));
  8297  	            }
  8298  
  8299  	            return latin1Chars.join('');
  8300  	        },
  8301  
  8302  	        /**
  8303  	         * Converts a Latin1 string to a word array.
  8304  	         *
  8305  	         * @param {string} latin1Str The Latin1 string.
  8306  	         *
  8307  	         * @return {WordArray} The word array.
  8308  	         *
  8309  	         * @static
  8310  	         *
  8311  	         * @example
  8312  	         *
  8313  	         *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  8314  	         */
  8315  	        parse: function (latin1Str) {
  8316  	            // Shortcut
  8317  	            var latin1StrLength = latin1Str.length;
  8318  
  8319  	            // Convert
  8320  	            var words = [];
  8321  	            for (var i = 0; i < latin1StrLength; i++) {
  8322  	                words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  8323  	            }
  8324  
  8325  	            return new WordArray.init(words, latin1StrLength);
  8326  	        }
  8327  	    };
  8328  
  8329  	    /**
  8330  	     * UTF-8 encoding strategy.
  8331  	     */
  8332  	    var Utf8 = C_enc.Utf8 = {
  8333  	        /**
  8334  	         * Converts a word array to a UTF-8 string.
  8335  	         *
  8336  	         * @param {WordArray} wordArray The word array.
  8337  	         *
  8338  	         * @return {string} The UTF-8 string.
  8339  	         *
  8340  	         * @static
  8341  	         *
  8342  	         * @example
  8343  	         *
  8344  	         *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  8345  	         */
  8346  	        stringify: function (wordArray) {
  8347  	            try {
  8348  	                return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  8349  	            } catch (e) {
  8350  	                throw new Error('Malformed UTF-8 data');
  8351  	            }
  8352  	        },
  8353  
  8354  	        /**
  8355  	         * Converts a UTF-8 string to a word array.
  8356  	         *
  8357  	         * @param {string} utf8Str The UTF-8 string.
  8358  	         *
  8359  	         * @return {WordArray} The word array.
  8360  	         *
  8361  	         * @static
  8362  	         *
  8363  	         * @example
  8364  	         *
  8365  	         *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  8366  	         */
  8367  	        parse: function (utf8Str) {
  8368  	            return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  8369  	        }
  8370  	    };
  8371  
  8372  	    /**
  8373  	     * Abstract buffered block algorithm template.
  8374  	     *
  8375  	     * The property blockSize must be implemented in a concrete subtype.
  8376  	     *
  8377  	     * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  8378  	     */
  8379  	    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  8380  	        /**
  8381  	         * Resets this block algorithm's data buffer to its initial state.
  8382  	         *
  8383  	         * @example
  8384  	         *
  8385  	         *     bufferedBlockAlgorithm.reset();
  8386  	         */
  8387  	        reset: function () {
  8388  	            // Initial values
  8389  	            this._data = new WordArray.init();
  8390  	            this._nDataBytes = 0;
  8391  	        },
  8392  
  8393  	        /**
  8394  	         * Adds new data to this block algorithm's buffer.
  8395  	         *
  8396  	         * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  8397  	         *
  8398  	         * @example
  8399  	         *
  8400  	         *     bufferedBlockAlgorithm._append('data');
  8401  	         *     bufferedBlockAlgorithm._append(wordArray);
  8402  	         */
  8403  	        _append: function (data) {
  8404  	            // Convert string to WordArray, else assume WordArray already
  8405  	            if (typeof data == 'string') {
  8406  	                data = Utf8.parse(data);
  8407  	            }
  8408  
  8409  	            // Append
  8410  	            this._data.concat(data);
  8411  	            this._nDataBytes += data.sigBytes;
  8412  	        },
  8413  
  8414  	        /**
  8415  	         * Processes available data blocks.
  8416  	         *
  8417  	         * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  8418  	         *
  8419  	         * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  8420  	         *
  8421  	         * @return {WordArray} The processed data.
  8422  	         *
  8423  	         * @example
  8424  	         *
  8425  	         *     var processedData = bufferedBlockAlgorithm._process();
  8426  	         *     var processedData = bufferedBlockAlgorithm._process(!!'flush');
  8427  	         */
  8428  	        _process: function (doFlush) {
  8429  	            // Shortcuts
  8430  	            var data = this._data;
  8431  	            var dataWords = data.words;
  8432  	            var dataSigBytes = data.sigBytes;
  8433  	            var blockSize = this.blockSize;
  8434  	            var blockSizeBytes = blockSize * 4;
  8435  
  8436  	            // Count blocks ready
  8437  	            var nBlocksReady = dataSigBytes / blockSizeBytes;
  8438  	            if (doFlush) {
  8439  	                // Round up to include partial blocks
  8440  	                nBlocksReady = Math.ceil(nBlocksReady);
  8441  	            } else {
  8442  	                // Round down to include only full blocks,
  8443  	                // less the number of blocks that must remain in the buffer
  8444  	                nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  8445  	            }
  8446  
  8447  	            // Count words ready
  8448  	            var nWordsReady = nBlocksReady * blockSize;
  8449  
  8450  	            // Count bytes ready
  8451  	            var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  8452  
  8453  	            // Process blocks
  8454  	            if (nWordsReady) {
  8455  	                for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  8456  	                    // Perform concrete-algorithm logic
  8457  	                    this._doProcessBlock(dataWords, offset);
  8458  	                }
  8459  
  8460  	                // Remove processed words
  8461  	                var processedWords = dataWords.splice(0, nWordsReady);
  8462  	                data.sigBytes -= nBytesReady;
  8463  	            }
  8464  
  8465  	            // Return processed words
  8466  	            return new WordArray.init(processedWords, nBytesReady);
  8467  	        },
  8468  
  8469  	        /**
  8470  	         * Creates a copy of this object.
  8471  	         *
  8472  	         * @return {Object} The clone.
  8473  	         *
  8474  	         * @example
  8475  	         *
  8476  	         *     var clone = bufferedBlockAlgorithm.clone();
  8477  	         */
  8478  	        clone: function () {
  8479  	            var clone = Base.clone.call(this);
  8480  	            clone._data = this._data.clone();
  8481  
  8482  	            return clone;
  8483  	        },
  8484  
  8485  	        _minBufferSize: 0
  8486  	    });
  8487  
  8488  	    /**
  8489  	     * Abstract hasher template.
  8490  	     *
  8491  	     * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  8492  	     */
  8493  	    var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  8494  	        /**
  8495  	         * Configuration options.
  8496  	         */
  8497  	        cfg: Base.extend(),
  8498  
  8499  	        /**
  8500  	         * Initializes a newly created hasher.
  8501  	         *
  8502  	         * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  8503  	         *
  8504  	         * @example
  8505  	         *
  8506  	         *     var hasher = CryptoJS.algo.SHA256.create();
  8507  	         */
  8508  	        init: function (cfg) {
  8509  	            // Apply config defaults
  8510  	            this.cfg = this.cfg.extend(cfg);
  8511  
  8512  	            // Set initial values
  8513  	            this.reset();
  8514  	        },
  8515  
  8516  	        /**
  8517  	         * Resets this hasher to its initial state.
  8518  	         *
  8519  	         * @example
  8520  	         *
  8521  	         *     hasher.reset();
  8522  	         */
  8523  	        reset: function () {
  8524  	            // Reset data buffer
  8525  	            BufferedBlockAlgorithm.reset.call(this);
  8526  
  8527  	            // Perform concrete-hasher logic
  8528  	            this._doReset();
  8529  	        },
  8530  
  8531  	        /**
  8532  	         * Updates this hasher with a message.
  8533  	         *
  8534  	         * @param {WordArray|string} messageUpdate The message to append.
  8535  	         *
  8536  	         * @return {Hasher} This hasher.
  8537  	         *
  8538  	         * @example
  8539  	         *
  8540  	         *     hasher.update('message');
  8541  	         *     hasher.update(wordArray);
  8542  	         */
  8543  	        update: function (messageUpdate) {
  8544  	            // Append
  8545  	            this._append(messageUpdate);
  8546  
  8547  	            // Update the hash
  8548  	            this._process();
  8549  
  8550  	            // Chainable
  8551  	            return this;
  8552  	        },
  8553  
  8554  	        /**
  8555  	         * Finalizes the hash computation.
  8556  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  8557  	         *
  8558  	         * @param {WordArray|string} messageUpdate (Optional) A final message update.
  8559  	         *
  8560  	         * @return {WordArray} The hash.
  8561  	         *
  8562  	         * @example
  8563  	         *
  8564  	         *     var hash = hasher.finalize();
  8565  	         *     var hash = hasher.finalize('message');
  8566  	         *     var hash = hasher.finalize(wordArray);
  8567  	         */
  8568  	        finalize: function (messageUpdate) {
  8569  	            // Final message update
  8570  	            if (messageUpdate) {
  8571  	                this._append(messageUpdate);
  8572  	            }
  8573  
  8574  	            // Perform concrete-hasher logic
  8575  	            var hash = this._doFinalize();
  8576  
  8577  	            return hash;
  8578  	        },
  8579  
  8580  	        blockSize: 512/32,
  8581  
  8582  	        /**
  8583  	         * Creates a shortcut function to a hasher's object interface.
  8584  	         *
  8585  	         * @param {Hasher} hasher The hasher to create a helper for.
  8586  	         *
  8587  	         * @return {Function} The shortcut function.
  8588  	         *
  8589  	         * @static
  8590  	         *
  8591  	         * @example
  8592  	         *
  8593  	         *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  8594  	         */
  8595  	        _createHelper: function (hasher) {
  8596  	            return function (message, cfg) {
  8597  	                return new hasher.init(cfg).finalize(message);
  8598  	            };
  8599  	        },
  8600  
  8601  	        /**
  8602  	         * Creates a shortcut function to the HMAC's object interface.
  8603  	         *
  8604  	         * @param {Hasher} hasher The hasher to use in this HMAC helper.
  8605  	         *
  8606  	         * @return {Function} The shortcut function.
  8607  	         *
  8608  	         * @static
  8609  	         *
  8610  	         * @example
  8611  	         *
  8612  	         *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  8613  	         */
  8614  	        _createHmacHelper: function (hasher) {
  8615  	            return function (message, key) {
  8616  	                return new C_algo.HMAC.init(hasher, key).finalize(message);
  8617  	            };
  8618  	        }
  8619  	    });
  8620  
  8621  	    /**
  8622  	     * Algorithm namespace.
  8623  	     */
  8624  	    var C_algo = C.algo = {};
  8625  
  8626  	    return C;
  8627  	}(Math));
  8628  
  8629  
  8630  	return CryptoJS;
  8631  
  8632  }));
  8633  },{}],54:[function(require,module,exports){
  8634  ;(function (root, factory) {
  8635  	if (typeof exports === "object") {
  8636  		// CommonJS
  8637  		module.exports = exports = factory(require("./core"));
  8638  	}
  8639  	else if (typeof define === "function" && define.amd) {
  8640  		// AMD
  8641  		define(["./core"], factory);
  8642  	}
  8643  	else {
  8644  		// Global (browser)
  8645  		factory(root.CryptoJS);
  8646  	}
  8647  }(this, function (CryptoJS) {
  8648  
  8649  	(function () {
  8650  	    // Shortcuts
  8651  	    var C = CryptoJS;
  8652  	    var C_lib = C.lib;
  8653  	    var WordArray = C_lib.WordArray;
  8654  	    var C_enc = C.enc;
  8655  
  8656  	    /**
  8657  	     * Base64 encoding strategy.
  8658  	     */
  8659  	    var Base64 = C_enc.Base64 = {
  8660  	        /**
  8661  	         * Converts a word array to a Base64 string.
  8662  	         *
  8663  	         * @param {WordArray} wordArray The word array.
  8664  	         *
  8665  	         * @return {string} The Base64 string.
  8666  	         *
  8667  	         * @static
  8668  	         *
  8669  	         * @example
  8670  	         *
  8671  	         *     var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  8672  	         */
  8673  	        stringify: function (wordArray) {
  8674  	            // Shortcuts
  8675  	            var words = wordArray.words;
  8676  	            var sigBytes = wordArray.sigBytes;
  8677  	            var map = this._map;
  8678  
  8679  	            // Clamp excess bits
  8680  	            wordArray.clamp();
  8681  
  8682  	            // Convert
  8683  	            var base64Chars = [];
  8684  	            for (var i = 0; i < sigBytes; i += 3) {
  8685  	                var byte1 = (words[i >>> 2]       >>> (24 - (i % 4) * 8))       & 0xff;
  8686  	                var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  8687  	                var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  8688  
  8689  	                var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  8690  
  8691  	                for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  8692  	                    base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  8693  	                }
  8694  	            }
  8695  
  8696  	            // Add padding
  8697  	            var paddingChar = map.charAt(64);
  8698  	            if (paddingChar) {
  8699  	                while (base64Chars.length % 4) {
  8700  	                    base64Chars.push(paddingChar);
  8701  	                }
  8702  	            }
  8703  
  8704  	            return base64Chars.join('');
  8705  	        },
  8706  
  8707  	        /**
  8708  	         * Converts a Base64 string to a word array.
  8709  	         *
  8710  	         * @param {string} base64Str The Base64 string.
  8711  	         *
  8712  	         * @return {WordArray} The word array.
  8713  	         *
  8714  	         * @static
  8715  	         *
  8716  	         * @example
  8717  	         *
  8718  	         *     var wordArray = CryptoJS.enc.Base64.parse(base64String);
  8719  	         */
  8720  	        parse: function (base64Str) {
  8721  	            // Shortcuts
  8722  	            var base64StrLength = base64Str.length;
  8723  	            var map = this._map;
  8724  	            var reverseMap = this._reverseMap;
  8725  
  8726  	            if (!reverseMap) {
  8727  	                    reverseMap = this._reverseMap = [];
  8728  	                    for (var j = 0; j < map.length; j++) {
  8729  	                        reverseMap[map.charCodeAt(j)] = j;
  8730  	                    }
  8731  	            }
  8732  
  8733  	            // Ignore padding
  8734  	            var paddingChar = map.charAt(64);
  8735  	            if (paddingChar) {
  8736  	                var paddingIndex = base64Str.indexOf(paddingChar);
  8737  	                if (paddingIndex !== -1) {
  8738  	                    base64StrLength = paddingIndex;
  8739  	                }
  8740  	            }
  8741  
  8742  	            // Convert
  8743  	            return parseLoop(base64Str, base64StrLength, reverseMap);
  8744  
  8745  	        },
  8746  
  8747  	        _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  8748  	    };
  8749  
  8750  	    function parseLoop(base64Str, base64StrLength, reverseMap) {
  8751  	      var words = [];
  8752  	      var nBytes = 0;
  8753  	      for (var i = 0; i < base64StrLength; i++) {
  8754  	          if (i % 4) {
  8755  	              var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  8756  	              var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  8757  	              words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
  8758  	              nBytes++;
  8759  	          }
  8760  	      }
  8761  	      return WordArray.create(words, nBytes);
  8762  	    }
  8763  	}());
  8764  
  8765  
  8766  	return CryptoJS.enc.Base64;
  8767  
  8768  }));
  8769  },{"./core":53}],55:[function(require,module,exports){
  8770  ;(function (root, factory) {
  8771  	if (typeof exports === "object") {
  8772  		// CommonJS
  8773  		module.exports = exports = factory(require("./core"));
  8774  	}
  8775  	else if (typeof define === "function" && define.amd) {
  8776  		// AMD
  8777  		define(["./core"], factory);
  8778  	}
  8779  	else {
  8780  		// Global (browser)
  8781  		factory(root.CryptoJS);
  8782  	}
  8783  }(this, function (CryptoJS) {
  8784  
  8785  	(function () {
  8786  	    // Shortcuts
  8787  	    var C = CryptoJS;
  8788  	    var C_lib = C.lib;
  8789  	    var WordArray = C_lib.WordArray;
  8790  	    var C_enc = C.enc;
  8791  
  8792  	    /**
  8793  	     * UTF-16 BE encoding strategy.
  8794  	     */
  8795  	    var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
  8796  	        /**
  8797  	         * Converts a word array to a UTF-16 BE string.
  8798  	         *
  8799  	         * @param {WordArray} wordArray The word array.
  8800  	         *
  8801  	         * @return {string} The UTF-16 BE string.
  8802  	         *
  8803  	         * @static
  8804  	         *
  8805  	         * @example
  8806  	         *
  8807  	         *     var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
  8808  	         */
  8809  	        stringify: function (wordArray) {
  8810  	            // Shortcuts
  8811  	            var words = wordArray.words;
  8812  	            var sigBytes = wordArray.sigBytes;
  8813  
  8814  	            // Convert
  8815  	            var utf16Chars = [];
  8816  	            for (var i = 0; i < sigBytes; i += 2) {
  8817  	                var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
  8818  	                utf16Chars.push(String.fromCharCode(codePoint));
  8819  	            }
  8820  
  8821  	            return utf16Chars.join('');
  8822  	        },
  8823  
  8824  	        /**
  8825  	         * Converts a UTF-16 BE string to a word array.
  8826  	         *
  8827  	         * @param {string} utf16Str The UTF-16 BE string.
  8828  	         *
  8829  	         * @return {WordArray} The word array.
  8830  	         *
  8831  	         * @static
  8832  	         *
  8833  	         * @example
  8834  	         *
  8835  	         *     var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
  8836  	         */
  8837  	        parse: function (utf16Str) {
  8838  	            // Shortcut
  8839  	            var utf16StrLength = utf16Str.length;
  8840  
  8841  	            // Convert
  8842  	            var words = [];
  8843  	            for (var i = 0; i < utf16StrLength; i++) {
  8844  	                words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
  8845  	            }
  8846  
  8847  	            return WordArray.create(words, utf16StrLength * 2);
  8848  	        }
  8849  	    };
  8850  
  8851  	    /**
  8852  	     * UTF-16 LE encoding strategy.
  8853  	     */
  8854  	    C_enc.Utf16LE = {
  8855  	        /**
  8856  	         * Converts a word array to a UTF-16 LE string.
  8857  	         *
  8858  	         * @param {WordArray} wordArray The word array.
  8859  	         *
  8860  	         * @return {string} The UTF-16 LE string.
  8861  	         *
  8862  	         * @static
  8863  	         *
  8864  	         * @example
  8865  	         *
  8866  	         *     var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
  8867  	         */
  8868  	        stringify: function (wordArray) {
  8869  	            // Shortcuts
  8870  	            var words = wordArray.words;
  8871  	            var sigBytes = wordArray.sigBytes;
  8872  
  8873  	            // Convert
  8874  	            var utf16Chars = [];
  8875  	            for (var i = 0; i < sigBytes; i += 2) {
  8876  	                var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
  8877  	                utf16Chars.push(String.fromCharCode(codePoint));
  8878  	            }
  8879  
  8880  	            return utf16Chars.join('');
  8881  	        },
  8882  
  8883  	        /**
  8884  	         * Converts a UTF-16 LE string to a word array.
  8885  	         *
  8886  	         * @param {string} utf16Str The UTF-16 LE string.
  8887  	         *
  8888  	         * @return {WordArray} The word array.
  8889  	         *
  8890  	         * @static
  8891  	         *
  8892  	         * @example
  8893  	         *
  8894  	         *     var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
  8895  	         */
  8896  	        parse: function (utf16Str) {
  8897  	            // Shortcut
  8898  	            var utf16StrLength = utf16Str.length;
  8899  
  8900  	            // Convert
  8901  	            var words = [];
  8902  	            for (var i = 0; i < utf16StrLength; i++) {
  8903  	                words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
  8904  	            }
  8905  
  8906  	            return WordArray.create(words, utf16StrLength * 2);
  8907  	        }
  8908  	    };
  8909  
  8910  	    function swapEndian(word) {
  8911  	        return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
  8912  	    }
  8913  	}());
  8914  
  8915  
  8916  	return CryptoJS.enc.Utf16;
  8917  
  8918  }));
  8919  },{"./core":53}],56:[function(require,module,exports){
  8920  ;(function (root, factory, undef) {
  8921  	if (typeof exports === "object") {
  8922  		// CommonJS
  8923  		module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
  8924  	}
  8925  	else if (typeof define === "function" && define.amd) {
  8926  		// AMD
  8927  		define(["./core", "./sha1", "./hmac"], factory);
  8928  	}
  8929  	else {
  8930  		// Global (browser)
  8931  		factory(root.CryptoJS);
  8932  	}
  8933  }(this, function (CryptoJS) {
  8934  
  8935  	(function () {
  8936  	    // Shortcuts
  8937  	    var C = CryptoJS;
  8938  	    var C_lib = C.lib;
  8939  	    var Base = C_lib.Base;
  8940  	    var WordArray = C_lib.WordArray;
  8941  	    var C_algo = C.algo;
  8942  	    var MD5 = C_algo.MD5;
  8943  
  8944  	    /**
  8945  	     * This key derivation function is meant to conform with EVP_BytesToKey.
  8946  	     * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  8947  	     */
  8948  	    var EvpKDF = C_algo.EvpKDF = Base.extend({
  8949  	        /**
  8950  	         * Configuration options.
  8951  	         *
  8952  	         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  8953  	         * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  8954  	         * @property {number} iterations The number of iterations to perform. Default: 1
  8955  	         */
  8956  	        cfg: Base.extend({
  8957  	            keySize: 128/32,
  8958  	            hasher: MD5,
  8959  	            iterations: 1
  8960  	        }),
  8961  
  8962  	        /**
  8963  	         * Initializes a newly created key derivation function.
  8964  	         *
  8965  	         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  8966  	         *
  8967  	         * @example
  8968  	         *
  8969  	         *     var kdf = CryptoJS.algo.EvpKDF.create();
  8970  	         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  8971  	         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  8972  	         */
  8973  	        init: function (cfg) {
  8974  	            this.cfg = this.cfg.extend(cfg);
  8975  	        },
  8976  
  8977  	        /**
  8978  	         * Derives a key from a password.
  8979  	         *
  8980  	         * @param {WordArray|string} password The password.
  8981  	         * @param {WordArray|string} salt A salt.
  8982  	         *
  8983  	         * @return {WordArray} The derived key.
  8984  	         *
  8985  	         * @example
  8986  	         *
  8987  	         *     var key = kdf.compute(password, salt);
  8988  	         */
  8989  	        compute: function (password, salt) {
  8990  	            // Shortcut
  8991  	            var cfg = this.cfg;
  8992  
  8993  	            // Init hasher
  8994  	            var hasher = cfg.hasher.create();
  8995  
  8996  	            // Initial values
  8997  	            var derivedKey = WordArray.create();
  8998  
  8999  	            // Shortcuts
  9000  	            var derivedKeyWords = derivedKey.words;
  9001  	            var keySize = cfg.keySize;
  9002  	            var iterations = cfg.iterations;
  9003  
  9004  	            // Generate key
  9005  	            while (derivedKeyWords.length < keySize) {
  9006  	                if (block) {
  9007  	                    hasher.update(block);
  9008  	                }
  9009  	                var block = hasher.update(password).finalize(salt);
  9010  	                hasher.reset();
  9011  
  9012  	                // Iterations
  9013  	                for (var i = 1; i < iterations; i++) {
  9014  	                    block = hasher.finalize(block);
  9015  	                    hasher.reset();
  9016  	                }
  9017  
  9018  	                derivedKey.concat(block);
  9019  	            }
  9020  	            derivedKey.sigBytes = keySize * 4;
  9021  
  9022  	            return derivedKey;
  9023  	        }
  9024  	    });
  9025  
  9026  	    /**
  9027  	     * Derives a key from a password.
  9028  	     *
  9029  	     * @param {WordArray|string} password The password.
  9030  	     * @param {WordArray|string} salt A salt.
  9031  	     * @param {Object} cfg (Optional) The configuration options to use for this computation.
  9032  	     *
  9033  	     * @return {WordArray} The derived key.
  9034  	     *
  9035  	     * @static
  9036  	     *
  9037  	     * @example
  9038  	     *
  9039  	     *     var key = CryptoJS.EvpKDF(password, salt);
  9040  	     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  9041  	     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  9042  	     */
  9043  	    C.EvpKDF = function (password, salt, cfg) {
  9044  	        return EvpKDF.create(cfg).compute(password, salt);
  9045  	    };
  9046  	}());
  9047  
  9048  
  9049  	return CryptoJS.EvpKDF;
  9050  
  9051  }));
  9052  },{"./core":53,"./hmac":58,"./sha1":77}],57:[function(require,module,exports){
  9053  ;(function (root, factory, undef) {
  9054  	if (typeof exports === "object") {
  9055  		// CommonJS
  9056  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9057  	}
  9058  	else if (typeof define === "function" && define.amd) {
  9059  		// AMD
  9060  		define(["./core", "./cipher-core"], factory);
  9061  	}
  9062  	else {
  9063  		// Global (browser)
  9064  		factory(root.CryptoJS);
  9065  	}
  9066  }(this, function (CryptoJS) {
  9067  
  9068  	(function (undefined) {
  9069  	    // Shortcuts
  9070  	    var C = CryptoJS;
  9071  	    var C_lib = C.lib;
  9072  	    var CipherParams = C_lib.CipherParams;
  9073  	    var C_enc = C.enc;
  9074  	    var Hex = C_enc.Hex;
  9075  	    var C_format = C.format;
  9076  
  9077  	    var HexFormatter = C_format.Hex = {
  9078  	        /**
  9079  	         * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  9080  	         *
  9081  	         * @param {CipherParams} cipherParams The cipher params object.
  9082  	         *
  9083  	         * @return {string} The hexadecimally encoded string.
  9084  	         *
  9085  	         * @static
  9086  	         *
  9087  	         * @example
  9088  	         *
  9089  	         *     var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  9090  	         */
  9091  	        stringify: function (cipherParams) {
  9092  	            return cipherParams.ciphertext.toString(Hex);
  9093  	        },
  9094  
  9095  	        /**
  9096  	         * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  9097  	         *
  9098  	         * @param {string} input The hexadecimally encoded string.
  9099  	         *
  9100  	         * @return {CipherParams} The cipher params object.
  9101  	         *
  9102  	         * @static
  9103  	         *
  9104  	         * @example
  9105  	         *
  9106  	         *     var cipherParams = CryptoJS.format.Hex.parse(hexString);
  9107  	         */
  9108  	        parse: function (input) {
  9109  	            var ciphertext = Hex.parse(input);
  9110  	            return CipherParams.create({ ciphertext: ciphertext });
  9111  	        }
  9112  	    };
  9113  	}());
  9114  
  9115  
  9116  	return CryptoJS.format.Hex;
  9117  
  9118  }));
  9119  },{"./cipher-core":52,"./core":53}],58:[function(require,module,exports){
  9120  ;(function (root, factory) {
  9121  	if (typeof exports === "object") {
  9122  		// CommonJS
  9123  		module.exports = exports = factory(require("./core"));
  9124  	}
  9125  	else if (typeof define === "function" && define.amd) {
  9126  		// AMD
  9127  		define(["./core"], factory);
  9128  	}
  9129  	else {
  9130  		// Global (browser)
  9131  		factory(root.CryptoJS);
  9132  	}
  9133  }(this, function (CryptoJS) {
  9134  
  9135  	(function () {
  9136  	    // Shortcuts
  9137  	    var C = CryptoJS;
  9138  	    var C_lib = C.lib;
  9139  	    var Base = C_lib.Base;
  9140  	    var C_enc = C.enc;
  9141  	    var Utf8 = C_enc.Utf8;
  9142  	    var C_algo = C.algo;
  9143  
  9144  	    /**
  9145  	     * HMAC algorithm.
  9146  	     */
  9147  	    var HMAC = C_algo.HMAC = Base.extend({
  9148  	        /**
  9149  	         * Initializes a newly created HMAC.
  9150  	         *
  9151  	         * @param {Hasher} hasher The hash algorithm to use.
  9152  	         * @param {WordArray|string} key The secret key.
  9153  	         *
  9154  	         * @example
  9155  	         *
  9156  	         *     var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  9157  	         */
  9158  	        init: function (hasher, key) {
  9159  	            // Init hasher
  9160  	            hasher = this._hasher = new hasher.init();
  9161  
  9162  	            // Convert string to WordArray, else assume WordArray already
  9163  	            if (typeof key == 'string') {
  9164  	                key = Utf8.parse(key);
  9165  	            }
  9166  
  9167  	            // Shortcuts
  9168  	            var hasherBlockSize = hasher.blockSize;
  9169  	            var hasherBlockSizeBytes = hasherBlockSize * 4;
  9170  
  9171  	            // Allow arbitrary length keys
  9172  	            if (key.sigBytes > hasherBlockSizeBytes) {
  9173  	                key = hasher.finalize(key);
  9174  	            }
  9175  
  9176  	            // Clamp excess bits
  9177  	            key.clamp();
  9178  
  9179  	            // Clone key for inner and outer pads
  9180  	            var oKey = this._oKey = key.clone();
  9181  	            var iKey = this._iKey = key.clone();
  9182  
  9183  	            // Shortcuts
  9184  	            var oKeyWords = oKey.words;
  9185  	            var iKeyWords = iKey.words;
  9186  
  9187  	            // XOR keys with pad constants
  9188  	            for (var i = 0; i < hasherBlockSize; i++) {
  9189  	                oKeyWords[i] ^= 0x5c5c5c5c;
  9190  	                iKeyWords[i] ^= 0x36363636;
  9191  	            }
  9192  	            oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  9193  
  9194  	            // Set initial values
  9195  	            this.reset();
  9196  	        },
  9197  
  9198  	        /**
  9199  	         * Resets this HMAC to its initial state.
  9200  	         *
  9201  	         * @example
  9202  	         *
  9203  	         *     hmacHasher.reset();
  9204  	         */
  9205  	        reset: function () {
  9206  	            // Shortcut
  9207  	            var hasher = this._hasher;
  9208  
  9209  	            // Reset
  9210  	            hasher.reset();
  9211  	            hasher.update(this._iKey);
  9212  	        },
  9213  
  9214  	        /**
  9215  	         * Updates this HMAC with a message.
  9216  	         *
  9217  	         * @param {WordArray|string} messageUpdate The message to append.
  9218  	         *
  9219  	         * @return {HMAC} This HMAC instance.
  9220  	         *
  9221  	         * @example
  9222  	         *
  9223  	         *     hmacHasher.update('message');
  9224  	         *     hmacHasher.update(wordArray);
  9225  	         */
  9226  	        update: function (messageUpdate) {
  9227  	            this._hasher.update(messageUpdate);
  9228  
  9229  	            // Chainable
  9230  	            return this;
  9231  	        },
  9232  
  9233  	        /**
  9234  	         * Finalizes the HMAC computation.
  9235  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  9236  	         *
  9237  	         * @param {WordArray|string} messageUpdate (Optional) A final message update.
  9238  	         *
  9239  	         * @return {WordArray} The HMAC.
  9240  	         *
  9241  	         * @example
  9242  	         *
  9243  	         *     var hmac = hmacHasher.finalize();
  9244  	         *     var hmac = hmacHasher.finalize('message');
  9245  	         *     var hmac = hmacHasher.finalize(wordArray);
  9246  	         */
  9247  	        finalize: function (messageUpdate) {
  9248  	            // Shortcut
  9249  	            var hasher = this._hasher;
  9250  
  9251  	            // Compute HMAC
  9252  	            var innerHash = hasher.finalize(messageUpdate);
  9253  	            hasher.reset();
  9254  	            var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  9255  
  9256  	            return hmac;
  9257  	        }
  9258  	    });
  9259  	}());
  9260  
  9261  
  9262  }));
  9263  },{"./core":53}],59:[function(require,module,exports){
  9264  ;(function (root, factory, undef) {
  9265  	if (typeof exports === "object") {
  9266  		// CommonJS
  9267  		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"));
  9268  	}
  9269  	else if (typeof define === "function" && define.amd) {
  9270  		// AMD
  9271  		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);
  9272  	}
  9273  	else {
  9274  		// Global (browser)
  9275  		root.CryptoJS = factory(root.CryptoJS);
  9276  	}
  9277  }(this, function (CryptoJS) {
  9278  
  9279  	return CryptoJS;
  9280  
  9281  }));
  9282  },{"./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){
  9283  ;(function (root, factory) {
  9284  	if (typeof exports === "object") {
  9285  		// CommonJS
  9286  		module.exports = exports = factory(require("./core"));
  9287  	}
  9288  	else if (typeof define === "function" && define.amd) {
  9289  		// AMD
  9290  		define(["./core"], factory);
  9291  	}
  9292  	else {
  9293  		// Global (browser)
  9294  		factory(root.CryptoJS);
  9295  	}
  9296  }(this, function (CryptoJS) {
  9297  
  9298  	(function () {
  9299  	    // Check if typed arrays are supported
  9300  	    if (typeof ArrayBuffer != 'function') {
  9301  	        return;
  9302  	    }
  9303  
  9304  	    // Shortcuts
  9305  	    var C = CryptoJS;
  9306  	    var C_lib = C.lib;
  9307  	    var WordArray = C_lib.WordArray;
  9308  
  9309  	    // Reference original init
  9310  	    var superInit = WordArray.init;
  9311  
  9312  	    // Augment WordArray.init to handle typed arrays
  9313  	    var subInit = WordArray.init = function (typedArray) {
  9314  	        // Convert buffers to uint8
  9315  	        if (typedArray instanceof ArrayBuffer) {
  9316  	            typedArray = new Uint8Array(typedArray);
  9317  	        }
  9318  
  9319  	        // Convert other array views to uint8
  9320  	        if (
  9321  	            typedArray instanceof Int8Array ||
  9322  	            (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
  9323  	            typedArray instanceof Int16Array ||
  9324  	            typedArray instanceof Uint16Array ||
  9325  	            typedArray instanceof Int32Array ||
  9326  	            typedArray instanceof Uint32Array ||
  9327  	            typedArray instanceof Float32Array ||
  9328  	            typedArray instanceof Float64Array
  9329  	        ) {
  9330  	            typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
  9331  	        }
  9332  
  9333  	        // Handle Uint8Array
  9334  	        if (typedArray instanceof Uint8Array) {
  9335  	            // Shortcut
  9336  	            var typedArrayByteLength = typedArray.byteLength;
  9337  
  9338  	            // Extract bytes
  9339  	            var words = [];
  9340  	            for (var i = 0; i < typedArrayByteLength; i++) {
  9341  	                words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
  9342  	            }
  9343  
  9344  	            // Initialize this word array
  9345  	            superInit.call(this, words, typedArrayByteLength);
  9346  	        } else {
  9347  	            // Else call normal init
  9348  	            superInit.apply(this, arguments);
  9349  	        }
  9350  	    };
  9351  
  9352  	    subInit.prototype = WordArray;
  9353  	}());
  9354  
  9355  
  9356  	return CryptoJS.lib.WordArray;
  9357  
  9358  }));
  9359  },{"./core":53}],61:[function(require,module,exports){
  9360  ;(function (root, factory) {
  9361  	if (typeof exports === "object") {
  9362  		// CommonJS
  9363  		module.exports = exports = factory(require("./core"));
  9364  	}
  9365  	else if (typeof define === "function" && define.amd) {
  9366  		// AMD
  9367  		define(["./core"], factory);
  9368  	}
  9369  	else {
  9370  		// Global (browser)
  9371  		factory(root.CryptoJS);
  9372  	}
  9373  }(this, function (CryptoJS) {
  9374  
  9375  	(function (Math) {
  9376  	    // Shortcuts
  9377  	    var C = CryptoJS;
  9378  	    var C_lib = C.lib;
  9379  	    var WordArray = C_lib.WordArray;
  9380  	    var Hasher = C_lib.Hasher;
  9381  	    var C_algo = C.algo;
  9382  
  9383  	    // Constants table
  9384  	    var T = [];
  9385  
  9386  	    // Compute constants
  9387  	    (function () {
  9388  	        for (var i = 0; i < 64; i++) {
  9389  	            T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  9390  	        }
  9391  	    }());
  9392  
  9393  	    /**
  9394  	     * MD5 hash algorithm.
  9395  	     */
  9396  	    var MD5 = C_algo.MD5 = Hasher.extend({
  9397  	        _doReset: function () {
  9398  	            this._hash = new WordArray.init([
  9399  	                0x67452301, 0xefcdab89,
  9400  	                0x98badcfe, 0x10325476
  9401  	            ]);
  9402  	        },
  9403  
  9404  	        _doProcessBlock: function (M, offset) {
  9405  	            // Swap endian
  9406  	            for (var i = 0; i < 16; i++) {
  9407  	                // Shortcuts
  9408  	                var offset_i = offset + i;
  9409  	                var M_offset_i = M[offset_i];
  9410  
  9411  	                M[offset_i] = (
  9412  	                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
  9413  	                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
  9414  	                );
  9415  	            }
  9416  
  9417  	            // Shortcuts
  9418  	            var H = this._hash.words;
  9419  
  9420  	            var M_offset_0  = M[offset + 0];
  9421  	            var M_offset_1  = M[offset + 1];
  9422  	            var M_offset_2  = M[offset + 2];
  9423  	            var M_offset_3  = M[offset + 3];
  9424  	            var M_offset_4  = M[offset + 4];
  9425  	            var M_offset_5  = M[offset + 5];
  9426  	            var M_offset_6  = M[offset + 6];
  9427  	            var M_offset_7  = M[offset + 7];
  9428  	            var M_offset_8  = M[offset + 8];
  9429  	            var M_offset_9  = M[offset + 9];
  9430  	            var M_offset_10 = M[offset + 10];
  9431  	            var M_offset_11 = M[offset + 11];
  9432  	            var M_offset_12 = M[offset + 12];
  9433  	            var M_offset_13 = M[offset + 13];
  9434  	            var M_offset_14 = M[offset + 14];
  9435  	            var M_offset_15 = M[offset + 15];
  9436  
  9437  	            // Working varialbes
  9438  	            var a = H[0];
  9439  	            var b = H[1];
  9440  	            var c = H[2];
  9441  	            var d = H[3];
  9442  
  9443  	            // Computation
  9444  	            a = FF(a, b, c, d, M_offset_0,  7,  T[0]);
  9445  	            d = FF(d, a, b, c, M_offset_1,  12, T[1]);
  9446  	            c = FF(c, d, a, b, M_offset_2,  17, T[2]);
  9447  	            b = FF(b, c, d, a, M_offset_3,  22, T[3]);
  9448  	            a = FF(a, b, c, d, M_offset_4,  7,  T[4]);
  9449  	            d = FF(d, a, b, c, M_offset_5,  12, T[5]);
  9450  	            c = FF(c, d, a, b, M_offset_6,  17, T[6]);
  9451  	            b = FF(b, c, d, a, M_offset_7,  22, T[7]);
  9452  	            a = FF(a, b, c, d, M_offset_8,  7,  T[8]);
  9453  	            d = FF(d, a, b, c, M_offset_9,  12, T[9]);
  9454  	            c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  9455  	            b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  9456  	            a = FF(a, b, c, d, M_offset_12, 7,  T[12]);
  9457  	            d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  9458  	            c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  9459  	            b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  9460  
  9461  	            a = GG(a, b, c, d, M_offset_1,  5,  T[16]);
  9462  	            d = GG(d, a, b, c, M_offset_6,  9,  T[17]);
  9463  	            c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  9464  	            b = GG(b, c, d, a, M_offset_0,  20, T[19]);
  9465  	            a = GG(a, b, c, d, M_offset_5,  5,  T[20]);
  9466  	            d = GG(d, a, b, c, M_offset_10, 9,  T[21]);
  9467  	            c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  9468  	            b = GG(b, c, d, a, M_offset_4,  20, T[23]);
  9469  	            a = GG(a, b, c, d, M_offset_9,  5,  T[24]);
  9470  	            d = GG(d, a, b, c, M_offset_14, 9,  T[25]);
  9471  	            c = GG(c, d, a, b, M_offset_3,  14, T[26]);
  9472  	            b = GG(b, c, d, a, M_offset_8,  20, T[27]);
  9473  	            a = GG(a, b, c, d, M_offset_13, 5,  T[28]);
  9474  	            d = GG(d, a, b, c, M_offset_2,  9,  T[29]);
  9475  	            c = GG(c, d, a, b, M_offset_7,  14, T[30]);
  9476  	            b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  9477  
  9478  	            a = HH(a, b, c, d, M_offset_5,  4,  T[32]);
  9479  	            d = HH(d, a, b, c, M_offset_8,  11, T[33]);
  9480  	            c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  9481  	            b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  9482  	            a = HH(a, b, c, d, M_offset_1,  4,  T[36]);
  9483  	            d = HH(d, a, b, c, M_offset_4,  11, T[37]);
  9484  	            c = HH(c, d, a, b, M_offset_7,  16, T[38]);
  9485  	            b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  9486  	            a = HH(a, b, c, d, M_offset_13, 4,  T[40]);
  9487  	            d = HH(d, a, b, c, M_offset_0,  11, T[41]);
  9488  	            c = HH(c, d, a, b, M_offset_3,  16, T[42]);
  9489  	            b = HH(b, c, d, a, M_offset_6,  23, T[43]);
  9490  	            a = HH(a, b, c, d, M_offset_9,  4,  T[44]);
  9491  	            d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  9492  	            c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  9493  	            b = HH(b, c, d, a, M_offset_2,  23, T[47]);
  9494  
  9495  	            a = II(a, b, c, d, M_offset_0,  6,  T[48]);
  9496  	            d = II(d, a, b, c, M_offset_7,  10, T[49]);
  9497  	            c = II(c, d, a, b, M_offset_14, 15, T[50]);
  9498  	            b = II(b, c, d, a, M_offset_5,  21, T[51]);
  9499  	            a = II(a, b, c, d, M_offset_12, 6,  T[52]);
  9500  	            d = II(d, a, b, c, M_offset_3,  10, T[53]);
  9501  	            c = II(c, d, a, b, M_offset_10, 15, T[54]);
  9502  	            b = II(b, c, d, a, M_offset_1,  21, T[55]);
  9503  	            a = II(a, b, c, d, M_offset_8,  6,  T[56]);
  9504  	            d = II(d, a, b, c, M_offset_15, 10, T[57]);
  9505  	            c = II(c, d, a, b, M_offset_6,  15, T[58]);
  9506  	            b = II(b, c, d, a, M_offset_13, 21, T[59]);
  9507  	            a = II(a, b, c, d, M_offset_4,  6,  T[60]);
  9508  	            d = II(d, a, b, c, M_offset_11, 10, T[61]);
  9509  	            c = II(c, d, a, b, M_offset_2,  15, T[62]);
  9510  	            b = II(b, c, d, a, M_offset_9,  21, T[63]);
  9511  
  9512  	            // Intermediate hash value
  9513  	            H[0] = (H[0] + a) | 0;
  9514  	            H[1] = (H[1] + b) | 0;
  9515  	            H[2] = (H[2] + c) | 0;
  9516  	            H[3] = (H[3] + d) | 0;
  9517  	        },
  9518  
  9519  	        _doFinalize: function () {
  9520  	            // Shortcuts
  9521  	            var data = this._data;
  9522  	            var dataWords = data.words;
  9523  
  9524  	            var nBitsTotal = this._nDataBytes * 8;
  9525  	            var nBitsLeft = data.sigBytes * 8;
  9526  
  9527  	            // Add padding
  9528  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  9529  
  9530  	            var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  9531  	            var nBitsTotalL = nBitsTotal;
  9532  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  9533  	                (((nBitsTotalH << 8)  | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  9534  	                (((nBitsTotalH << 24) | (nBitsTotalH >>> 8))  & 0xff00ff00)
  9535  	            );
  9536  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  9537  	                (((nBitsTotalL << 8)  | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  9538  	                (((nBitsTotalL << 24) | (nBitsTotalL >>> 8))  & 0xff00ff00)
  9539  	            );
  9540  
  9541  	            data.sigBytes = (dataWords.length + 1) * 4;
  9542  
  9543  	            // Hash final blocks
  9544  	            this._process();
  9545  
  9546  	            // Shortcuts
  9547  	            var hash = this._hash;
  9548  	            var H = hash.words;
  9549  
  9550  	            // Swap endian
  9551  	            for (var i = 0; i < 4; i++) {
  9552  	                // Shortcut
  9553  	                var H_i = H[i];
  9554  
  9555  	                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
  9556  	                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
  9557  	            }
  9558  
  9559  	            // Return final computed hash
  9560  	            return hash;
  9561  	        },
  9562  
  9563  	        clone: function () {
  9564  	            var clone = Hasher.clone.call(this);
  9565  	            clone._hash = this._hash.clone();
  9566  
  9567  	            return clone;
  9568  	        }
  9569  	    });
  9570  
  9571  	    function FF(a, b, c, d, x, s, t) {
  9572  	        var n = a + ((b & c) | (~b & d)) + x + t;
  9573  	        return ((n << s) | (n >>> (32 - s))) + b;
  9574  	    }
  9575  
  9576  	    function GG(a, b, c, d, x, s, t) {
  9577  	        var n = a + ((b & d) | (c & ~d)) + x + t;
  9578  	        return ((n << s) | (n >>> (32 - s))) + b;
  9579  	    }
  9580  
  9581  	    function HH(a, b, c, d, x, s, t) {
  9582  	        var n = a + (b ^ c ^ d) + x + t;
  9583  	        return ((n << s) | (n >>> (32 - s))) + b;
  9584  	    }
  9585  
  9586  	    function II(a, b, c, d, x, s, t) {
  9587  	        var n = a + (c ^ (b | ~d)) + x + t;
  9588  	        return ((n << s) | (n >>> (32 - s))) + b;
  9589  	    }
  9590  
  9591  	    /**
  9592  	     * Shortcut function to the hasher's object interface.
  9593  	     *
  9594  	     * @param {WordArray|string} message The message to hash.
  9595  	     *
  9596  	     * @return {WordArray} The hash.
  9597  	     *
  9598  	     * @static
  9599  	     *
  9600  	     * @example
  9601  	     *
  9602  	     *     var hash = CryptoJS.MD5('message');
  9603  	     *     var hash = CryptoJS.MD5(wordArray);
  9604  	     */
  9605  	    C.MD5 = Hasher._createHelper(MD5);
  9606  
  9607  	    /**
  9608  	     * Shortcut function to the HMAC's object interface.
  9609  	     *
  9610  	     * @param {WordArray|string} message The message to hash.
  9611  	     * @param {WordArray|string} key The secret key.
  9612  	     *
  9613  	     * @return {WordArray} The HMAC.
  9614  	     *
  9615  	     * @static
  9616  	     *
  9617  	     * @example
  9618  	     *
  9619  	     *     var hmac = CryptoJS.HmacMD5(message, key);
  9620  	     */
  9621  	    C.HmacMD5 = Hasher._createHmacHelper(MD5);
  9622  	}(Math));
  9623  
  9624  
  9625  	return CryptoJS.MD5;
  9626  
  9627  }));
  9628  },{"./core":53}],62:[function(require,module,exports){
  9629  ;(function (root, factory, undef) {
  9630  	if (typeof exports === "object") {
  9631  		// CommonJS
  9632  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9633  	}
  9634  	else if (typeof define === "function" && define.amd) {
  9635  		// AMD
  9636  		define(["./core", "./cipher-core"], factory);
  9637  	}
  9638  	else {
  9639  		// Global (browser)
  9640  		factory(root.CryptoJS);
  9641  	}
  9642  }(this, function (CryptoJS) {
  9643  
  9644  	/**
  9645  	 * Cipher Feedback block mode.
  9646  	 */
  9647  	CryptoJS.mode.CFB = (function () {
  9648  	    var CFB = CryptoJS.lib.BlockCipherMode.extend();
  9649  
  9650  	    CFB.Encryptor = CFB.extend({
  9651  	        processBlock: function (words, offset) {
  9652  	            // Shortcuts
  9653  	            var cipher = this._cipher;
  9654  	            var blockSize = cipher.blockSize;
  9655  
  9656  	            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9657  
  9658  	            // Remember this block to use with next block
  9659  	            this._prevBlock = words.slice(offset, offset + blockSize);
  9660  	        }
  9661  	    });
  9662  
  9663  	    CFB.Decryptor = CFB.extend({
  9664  	        processBlock: function (words, offset) {
  9665  	            // Shortcuts
  9666  	            var cipher = this._cipher;
  9667  	            var blockSize = cipher.blockSize;
  9668  
  9669  	            // Remember this block to use with next block
  9670  	            var thisBlock = words.slice(offset, offset + blockSize);
  9671  
  9672  	            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9673  
  9674  	            // This block becomes the previous block
  9675  	            this._prevBlock = thisBlock;
  9676  	        }
  9677  	    });
  9678  
  9679  	    function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
  9680  	        // Shortcut
  9681  	        var iv = this._iv;
  9682  
  9683  	        // Generate keystream
  9684  	        if (iv) {
  9685  	            var keystream = iv.slice(0);
  9686  
  9687  	            // Remove IV for subsequent blocks
  9688  	            this._iv = undefined;
  9689  	        } else {
  9690  	            var keystream = this._prevBlock;
  9691  	        }
  9692  	        cipher.encryptBlock(keystream, 0);
  9693  
  9694  	        // Encrypt
  9695  	        for (var i = 0; i < blockSize; i++) {
  9696  	            words[offset + i] ^= keystream[i];
  9697  	        }
  9698  	    }
  9699  
  9700  	    return CFB;
  9701  	}());
  9702  
  9703  
  9704  	return CryptoJS.mode.CFB;
  9705  
  9706  }));
  9707  },{"./cipher-core":52,"./core":53}],63:[function(require,module,exports){
  9708  ;(function (root, factory, undef) {
  9709  	if (typeof exports === "object") {
  9710  		// CommonJS
  9711  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9712  	}
  9713  	else if (typeof define === "function" && define.amd) {
  9714  		// AMD
  9715  		define(["./core", "./cipher-core"], factory);
  9716  	}
  9717  	else {
  9718  		// Global (browser)
  9719  		factory(root.CryptoJS);
  9720  	}
  9721  }(this, function (CryptoJS) {
  9722  
  9723  	/** @preserve
  9724  	 * Counter block mode compatible with  Dr Brian Gladman fileenc.c
  9725  	 * derived from CryptoJS.mode.CTR
  9726  	 * Jan Hruby jhruby.web@gmail.com
  9727  	 */
  9728  	CryptoJS.mode.CTRGladman = (function () {
  9729  	    var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
  9730  
  9731  		function incWord(word)
  9732  		{
  9733  			if (((word >> 24) & 0xff) === 0xff) { //overflow
  9734  			var b1 = (word >> 16)&0xff;
  9735  			var b2 = (word >> 8)&0xff;
  9736  			var b3 = word & 0xff;
  9737  
  9738  			if (b1 === 0xff) // overflow b1
  9739  			{
  9740  			b1 = 0;
  9741  			if (b2 === 0xff)
  9742  			{
  9743  				b2 = 0;
  9744  				if (b3 === 0xff)
  9745  				{
  9746  					b3 = 0;
  9747  				}
  9748  				else
  9749  				{
  9750  					++b3;
  9751  				}
  9752  			}
  9753  			else
  9754  			{
  9755  				++b2;
  9756  			}
  9757  			}
  9758  			else
  9759  			{
  9760  			++b1;
  9761  			}
  9762  
  9763  			word = 0;
  9764  			word += (b1 << 16);
  9765  			word += (b2 << 8);
  9766  			word += b3;
  9767  			}
  9768  			else
  9769  			{
  9770  			word += (0x01 << 24);
  9771  			}
  9772  			return word;
  9773  		}
  9774  
  9775  		function incCounter(counter)
  9776  		{
  9777  			if ((counter[0] = incWord(counter[0])) === 0)
  9778  			{
  9779  				// encr_data in fileenc.c from  Dr Brian Gladman's counts only with DWORD j < 8
  9780  				counter[1] = incWord(counter[1]);
  9781  			}
  9782  			return counter;
  9783  		}
  9784  
  9785  	    var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
  9786  	        processBlock: function (words, offset) {
  9787  	            // Shortcuts
  9788  	            var cipher = this._cipher
  9789  	            var blockSize = cipher.blockSize;
  9790  	            var iv = this._iv;
  9791  	            var counter = this._counter;
  9792  
  9793  	            // Generate keystream
  9794  	            if (iv) {
  9795  	                counter = this._counter = iv.slice(0);
  9796  
  9797  	                // Remove IV for subsequent blocks
  9798  	                this._iv = undefined;
  9799  	            }
  9800  
  9801  				incCounter(counter);
  9802  
  9803  				var keystream = counter.slice(0);
  9804  	            cipher.encryptBlock(keystream, 0);
  9805  
  9806  	            // Encrypt
  9807  	            for (var i = 0; i < blockSize; i++) {
  9808  	                words[offset + i] ^= keystream[i];
  9809  	            }
  9810  	        }
  9811  	    });
  9812  
  9813  	    CTRGladman.Decryptor = Encryptor;
  9814  
  9815  	    return CTRGladman;
  9816  	}());
  9817  
  9818  
  9819  
  9820  
  9821  	return CryptoJS.mode.CTRGladman;
  9822  
  9823  }));
  9824  },{"./cipher-core":52,"./core":53}],64:[function(require,module,exports){
  9825  ;(function (root, factory, undef) {
  9826  	if (typeof exports === "object") {
  9827  		// CommonJS
  9828  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9829  	}
  9830  	else if (typeof define === "function" && define.amd) {
  9831  		// AMD
  9832  		define(["./core", "./cipher-core"], factory);
  9833  	}
  9834  	else {
  9835  		// Global (browser)
  9836  		factory(root.CryptoJS);
  9837  	}
  9838  }(this, function (CryptoJS) {
  9839  
  9840  	/**
  9841  	 * Counter block mode.
  9842  	 */
  9843  	CryptoJS.mode.CTR = (function () {
  9844  	    var CTR = CryptoJS.lib.BlockCipherMode.extend();
  9845  
  9846  	    var Encryptor = CTR.Encryptor = CTR.extend({
  9847  	        processBlock: function (words, offset) {
  9848  	            // Shortcuts
  9849  	            var cipher = this._cipher
  9850  	            var blockSize = cipher.blockSize;
  9851  	            var iv = this._iv;
  9852  	            var counter = this._counter;
  9853  
  9854  	            // Generate keystream
  9855  	            if (iv) {
  9856  	                counter = this._counter = iv.slice(0);
  9857  
  9858  	                // Remove IV for subsequent blocks
  9859  	                this._iv = undefined;
  9860  	            }
  9861  	            var keystream = counter.slice(0);
  9862  	            cipher.encryptBlock(keystream, 0);
  9863  
  9864  	            // Increment counter
  9865  	            counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
  9866  
  9867  	            // Encrypt
  9868  	            for (var i = 0; i < blockSize; i++) {
  9869  	                words[offset + i] ^= keystream[i];
  9870  	            }
  9871  	        }
  9872  	    });
  9873  
  9874  	    CTR.Decryptor = Encryptor;
  9875  
  9876  	    return CTR;
  9877  	}());
  9878  
  9879  
  9880  	return CryptoJS.mode.CTR;
  9881  
  9882  }));
  9883  },{"./cipher-core":52,"./core":53}],65:[function(require,module,exports){
  9884  ;(function (root, factory, undef) {
  9885  	if (typeof exports === "object") {
  9886  		// CommonJS
  9887  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9888  	}
  9889  	else if (typeof define === "function" && define.amd) {
  9890  		// AMD
  9891  		define(["./core", "./cipher-core"], factory);
  9892  	}
  9893  	else {
  9894  		// Global (browser)
  9895  		factory(root.CryptoJS);
  9896  	}
  9897  }(this, function (CryptoJS) {
  9898  
  9899  	/**
  9900  	 * Electronic Codebook block mode.
  9901  	 */
  9902  	CryptoJS.mode.ECB = (function () {
  9903  	    var ECB = CryptoJS.lib.BlockCipherMode.extend();
  9904  
  9905  	    ECB.Encryptor = ECB.extend({
  9906  	        processBlock: function (words, offset) {
  9907  	            this._cipher.encryptBlock(words, offset);
  9908  	        }
  9909  	    });
  9910  
  9911  	    ECB.Decryptor = ECB.extend({
  9912  	        processBlock: function (words, offset) {
  9913  	            this._cipher.decryptBlock(words, offset);
  9914  	        }
  9915  	    });
  9916  
  9917  	    return ECB;
  9918  	}());
  9919  
  9920  
  9921  	return CryptoJS.mode.ECB;
  9922  
  9923  }));
  9924  },{"./cipher-core":52,"./core":53}],66:[function(require,module,exports){
  9925  ;(function (root, factory, undef) {
  9926  	if (typeof exports === "object") {
  9927  		// CommonJS
  9928  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9929  	}
  9930  	else if (typeof define === "function" && define.amd) {
  9931  		// AMD
  9932  		define(["./core", "./cipher-core"], factory);
  9933  	}
  9934  	else {
  9935  		// Global (browser)
  9936  		factory(root.CryptoJS);
  9937  	}
  9938  }(this, function (CryptoJS) {
  9939  
  9940  	/**
  9941  	 * Output Feedback block mode.
  9942  	 */
  9943  	CryptoJS.mode.OFB = (function () {
  9944  	    var OFB = CryptoJS.lib.BlockCipherMode.extend();
  9945  
  9946  	    var Encryptor = OFB.Encryptor = OFB.extend({
  9947  	        processBlock: function (words, offset) {
  9948  	            // Shortcuts
  9949  	            var cipher = this._cipher
  9950  	            var blockSize = cipher.blockSize;
  9951  	            var iv = this._iv;
  9952  	            var keystream = this._keystream;
  9953  
  9954  	            // Generate keystream
  9955  	            if (iv) {
  9956  	                keystream = this._keystream = iv.slice(0);
  9957  
  9958  	                // Remove IV for subsequent blocks
  9959  	                this._iv = undefined;
  9960  	            }
  9961  	            cipher.encryptBlock(keystream, 0);
  9962  
  9963  	            // Encrypt
  9964  	            for (var i = 0; i < blockSize; i++) {
  9965  	                words[offset + i] ^= keystream[i];
  9966  	            }
  9967  	        }
  9968  	    });
  9969  
  9970  	    OFB.Decryptor = Encryptor;
  9971  
  9972  	    return OFB;
  9973  	}());
  9974  
  9975  
  9976  	return CryptoJS.mode.OFB;
  9977  
  9978  }));
  9979  },{"./cipher-core":52,"./core":53}],67:[function(require,module,exports){
  9980  ;(function (root, factory, undef) {
  9981  	if (typeof exports === "object") {
  9982  		// CommonJS
  9983  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9984  	}
  9985  	else if (typeof define === "function" && define.amd) {
  9986  		// AMD
  9987  		define(["./core", "./cipher-core"], factory);
  9988  	}
  9989  	else {
  9990  		// Global (browser)
  9991  		factory(root.CryptoJS);
  9992  	}
  9993  }(this, function (CryptoJS) {
  9994  
  9995  	/**
  9996  	 * ANSI X.923 padding strategy.
  9997  	 */
  9998  	CryptoJS.pad.AnsiX923 = {
  9999  	    pad: function (data, blockSize) {
 10000  	        // Shortcuts
 10001  	        var dataSigBytes = data.sigBytes;
 10002  	        var blockSizeBytes = blockSize * 4;
 10003  
 10004  	        // Count padding bytes
 10005  	        var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
 10006  
 10007  	        // Compute last byte position
 10008  	        var lastBytePos = dataSigBytes + nPaddingBytes - 1;
 10009  
 10010  	        // Pad
 10011  	        data.clamp();
 10012  	        data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
 10013  	        data.sigBytes += nPaddingBytes;
 10014  	    },
 10015  
 10016  	    unpad: function (data) {
 10017  	        // Get number of padding bytes from last byte
 10018  	        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
 10019  
 10020  	        // Remove padding
 10021  	        data.sigBytes -= nPaddingBytes;
 10022  	    }
 10023  	};
 10024  
 10025  
 10026  	return CryptoJS.pad.Ansix923;
 10027  
 10028  }));
 10029  },{"./cipher-core":52,"./core":53}],68:[function(require,module,exports){
 10030  ;(function (root, factory, undef) {
 10031  	if (typeof exports === "object") {
 10032  		// CommonJS
 10033  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10034  	}
 10035  	else if (typeof define === "function" && define.amd) {
 10036  		// AMD
 10037  		define(["./core", "./cipher-core"], factory);
 10038  	}
 10039  	else {
 10040  		// Global (browser)
 10041  		factory(root.CryptoJS);
 10042  	}
 10043  }(this, function (CryptoJS) {
 10044  
 10045  	/**
 10046  	 * ISO 10126 padding strategy.
 10047  	 */
 10048  	CryptoJS.pad.Iso10126 = {
 10049  	    pad: function (data, blockSize) {
 10050  	        // Shortcut
 10051  	        var blockSizeBytes = blockSize * 4;
 10052  
 10053  	        // Count padding bytes
 10054  	        var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
 10055  
 10056  	        // Pad
 10057  	        data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
 10058  	             concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
 10059  	    },
 10060  
 10061  	    unpad: function (data) {
 10062  	        // Get number of padding bytes from last byte
 10063  	        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
 10064  
 10065  	        // Remove padding
 10066  	        data.sigBytes -= nPaddingBytes;
 10067  	    }
 10068  	};
 10069  
 10070  
 10071  	return CryptoJS.pad.Iso10126;
 10072  
 10073  }));
 10074  },{"./cipher-core":52,"./core":53}],69:[function(require,module,exports){
 10075  ;(function (root, factory, undef) {
 10076  	if (typeof exports === "object") {
 10077  		// CommonJS
 10078  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10079  	}
 10080  	else if (typeof define === "function" && define.amd) {
 10081  		// AMD
 10082  		define(["./core", "./cipher-core"], factory);
 10083  	}
 10084  	else {
 10085  		// Global (browser)
 10086  		factory(root.CryptoJS);
 10087  	}
 10088  }(this, function (CryptoJS) {
 10089  
 10090  	/**
 10091  	 * ISO/IEC 9797-1 Padding Method 2.
 10092  	 */
 10093  	CryptoJS.pad.Iso97971 = {
 10094  	    pad: function (data, blockSize) {
 10095  	        // Add 0x80 byte
 10096  	        data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
 10097  
 10098  	        // Zero pad the rest
 10099  	        CryptoJS.pad.ZeroPadding.pad(data, blockSize);
 10100  	    },
 10101  
 10102  	    unpad: function (data) {
 10103  	        // Remove zero padding
 10104  	        CryptoJS.pad.ZeroPadding.unpad(data);
 10105  
 10106  	        // Remove one more byte -- the 0x80 byte
 10107  	        data.sigBytes--;
 10108  	    }
 10109  	};
 10110  
 10111  
 10112  	return CryptoJS.pad.Iso97971;
 10113  
 10114  }));
 10115  },{"./cipher-core":52,"./core":53}],70:[function(require,module,exports){
 10116  ;(function (root, factory, undef) {
 10117  	if (typeof exports === "object") {
 10118  		// CommonJS
 10119  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10120  	}
 10121  	else if (typeof define === "function" && define.amd) {
 10122  		// AMD
 10123  		define(["./core", "./cipher-core"], factory);
 10124  	}
 10125  	else {
 10126  		// Global (browser)
 10127  		factory(root.CryptoJS);
 10128  	}
 10129  }(this, function (CryptoJS) {
 10130  
 10131  	/**
 10132  	 * A noop padding strategy.
 10133  	 */
 10134  	CryptoJS.pad.NoPadding = {
 10135  	    pad: function () {
 10136  	    },
 10137  
 10138  	    unpad: function () {
 10139  	    }
 10140  	};
 10141  
 10142  
 10143  	return CryptoJS.pad.NoPadding;
 10144  
 10145  }));
 10146  },{"./cipher-core":52,"./core":53}],71:[function(require,module,exports){
 10147  ;(function (root, factory, undef) {
 10148  	if (typeof exports === "object") {
 10149  		// CommonJS
 10150  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10151  	}
 10152  	else if (typeof define === "function" && define.amd) {
 10153  		// AMD
 10154  		define(["./core", "./cipher-core"], factory);
 10155  	}
 10156  	else {
 10157  		// Global (browser)
 10158  		factory(root.CryptoJS);
 10159  	}
 10160  }(this, function (CryptoJS) {
 10161  
 10162  	/**
 10163  	 * Zero padding strategy.
 10164  	 */
 10165  	CryptoJS.pad.ZeroPadding = {
 10166  	    pad: function (data, blockSize) {
 10167  	        // Shortcut
 10168  	        var blockSizeBytes = blockSize * 4;
 10169  
 10170  	        // Pad
 10171  	        data.clamp();
 10172  	        data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
 10173  	    },
 10174  
 10175  	    unpad: function (data) {
 10176  	        // Shortcut
 10177  	        var dataWords = data.words;
 10178  
 10179  	        // Unpad
 10180  	        var i = data.sigBytes - 1;
 10181  	        while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
 10182  	            i--;
 10183  	        }
 10184  	        data.sigBytes = i + 1;
 10185  	    }
 10186  	};
 10187  
 10188  
 10189  	return CryptoJS.pad.ZeroPadding;
 10190  
 10191  }));
 10192  },{"./cipher-core":52,"./core":53}],72:[function(require,module,exports){
 10193  ;(function (root, factory, undef) {
 10194  	if (typeof exports === "object") {
 10195  		// CommonJS
 10196  		module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
 10197  	}
 10198  	else if (typeof define === "function" && define.amd) {
 10199  		// AMD
 10200  		define(["./core", "./sha1", "./hmac"], factory);
 10201  	}
 10202  	else {
 10203  		// Global (browser)
 10204  		factory(root.CryptoJS);
 10205  	}
 10206  }(this, function (CryptoJS) {
 10207  
 10208  	(function () {
 10209  	    // Shortcuts
 10210  	    var C = CryptoJS;
 10211  	    var C_lib = C.lib;
 10212  	    var Base = C_lib.Base;
 10213  	    var WordArray = C_lib.WordArray;
 10214  	    var C_algo = C.algo;
 10215  	    var SHA1 = C_algo.SHA1;
 10216  	    var HMAC = C_algo.HMAC;
 10217  
 10218  	    /**
 10219  	     * Password-Based Key Derivation Function 2 algorithm.
 10220  	     */
 10221  	    var PBKDF2 = C_algo.PBKDF2 = Base.extend({
 10222  	        /**
 10223  	         * Configuration options.
 10224  	         *
 10225  	         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
 10226  	         * @property {Hasher} hasher The hasher to use. Default: SHA1
 10227  	         * @property {number} iterations The number of iterations to perform. Default: 1
 10228  	         */
 10229  	        cfg: Base.extend({
 10230  	            keySize: 128/32,
 10231  	            hasher: SHA1,
 10232  	            iterations: 1
 10233  	        }),
 10234  
 10235  	        /**
 10236  	         * Initializes a newly created key derivation function.
 10237  	         *
 10238  	         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
 10239  	         *
 10240  	         * @example
 10241  	         *
 10242  	         *     var kdf = CryptoJS.algo.PBKDF2.create();
 10243  	         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
 10244  	         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
 10245  	         */
 10246  	        init: function (cfg) {
 10247  	            this.cfg = this.cfg.extend(cfg);
 10248  	        },
 10249  
 10250  	        /**
 10251  	         * Computes the Password-Based Key Derivation Function 2.
 10252  	         *
 10253  	         * @param {WordArray|string} password The password.
 10254  	         * @param {WordArray|string} salt A salt.
 10255  	         *
 10256  	         * @return {WordArray} The derived key.
 10257  	         *
 10258  	         * @example
 10259  	         *
 10260  	         *     var key = kdf.compute(password, salt);
 10261  	         */
 10262  	        compute: function (password, salt) {
 10263  	            // Shortcut
 10264  	            var cfg = this.cfg;
 10265  
 10266  	            // Init HMAC
 10267  	            var hmac = HMAC.create(cfg.hasher, password);
 10268  
 10269  	            // Initial values
 10270  	            var derivedKey = WordArray.create();
 10271  	            var blockIndex = WordArray.create([0x00000001]);
 10272  
 10273  	            // Shortcuts
 10274  	            var derivedKeyWords = derivedKey.words;
 10275  	            var blockIndexWords = blockIndex.words;
 10276  	            var keySize = cfg.keySize;
 10277  	            var iterations = cfg.iterations;
 10278  
 10279  	            // Generate key
 10280  	            while (derivedKeyWords.length < keySize) {
 10281  	                var block = hmac.update(salt).finalize(blockIndex);
 10282  	                hmac.reset();
 10283  
 10284  	                // Shortcuts
 10285  	                var blockWords = block.words;
 10286  	                var blockWordsLength = blockWords.length;
 10287  
 10288  	                // Iterations
 10289  	                var intermediate = block;
 10290  	                for (var i = 1; i < iterations; i++) {
 10291  	                    intermediate = hmac.finalize(intermediate);
 10292  	                    hmac.reset();
 10293  
 10294  	                    // Shortcut
 10295  	                    var intermediateWords = intermediate.words;
 10296  
 10297  	                    // XOR intermediate with block
 10298  	                    for (var j = 0; j < blockWordsLength; j++) {
 10299  	                        blockWords[j] ^= intermediateWords[j];
 10300  	                    }
 10301  	                }
 10302  
 10303  	                derivedKey.concat(block);
 10304  	                blockIndexWords[0]++;
 10305  	            }
 10306  	            derivedKey.sigBytes = keySize * 4;
 10307  
 10308  	            return derivedKey;
 10309  	        }
 10310  	    });
 10311  
 10312  	    /**
 10313  	     * Computes the Password-Based Key Derivation Function 2.
 10314  	     *
 10315  	     * @param {WordArray|string} password The password.
 10316  	     * @param {WordArray|string} salt A salt.
 10317  	     * @param {Object} cfg (Optional) The configuration options to use for this computation.
 10318  	     *
 10319  	     * @return {WordArray} The derived key.
 10320  	     *
 10321  	     * @static
 10322  	     *
 10323  	     * @example
 10324  	     *
 10325  	     *     var key = CryptoJS.PBKDF2(password, salt);
 10326  	     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
 10327  	     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
 10328  	     */
 10329  	    C.PBKDF2 = function (password, salt, cfg) {
 10330  	        return PBKDF2.create(cfg).compute(password, salt);
 10331  	    };
 10332  	}());
 10333  
 10334  
 10335  	return CryptoJS.PBKDF2;
 10336  
 10337  }));
 10338  },{"./core":53,"./hmac":58,"./sha1":77}],73:[function(require,module,exports){
 10339  ;(function (root, factory, undef) {
 10340  	if (typeof exports === "object") {
 10341  		// CommonJS
 10342  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10343  	}
 10344  	else if (typeof define === "function" && define.amd) {
 10345  		// AMD
 10346  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10347  	}
 10348  	else {
 10349  		// Global (browser)
 10350  		factory(root.CryptoJS);
 10351  	}
 10352  }(this, function (CryptoJS) {
 10353  
 10354  	(function () {
 10355  	    // Shortcuts
 10356  	    var C = CryptoJS;
 10357  	    var C_lib = C.lib;
 10358  	    var StreamCipher = C_lib.StreamCipher;
 10359  	    var C_algo = C.algo;
 10360  
 10361  	    // Reusable objects
 10362  	    var S  = [];
 10363  	    var C_ = [];
 10364  	    var G  = [];
 10365  
 10366  	    /**
 10367  	     * Rabbit stream cipher algorithm.
 10368  	     *
 10369  	     * This is a legacy version that neglected to convert the key to little-endian.
 10370  	     * This error doesn't affect the cipher's security,
 10371  	     * but it does affect its compatibility with other implementations.
 10372  	     */
 10373  	    var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
 10374  	        _doReset: function () {
 10375  	            // Shortcuts
 10376  	            var K = this._key.words;
 10377  	            var iv = this.cfg.iv;
 10378  
 10379  	            // Generate initial state values
 10380  	            var X = this._X = [
 10381  	                K[0], (K[3] << 16) | (K[2] >>> 16),
 10382  	                K[1], (K[0] << 16) | (K[3] >>> 16),
 10383  	                K[2], (K[1] << 16) | (K[0] >>> 16),
 10384  	                K[3], (K[2] << 16) | (K[1] >>> 16)
 10385  	            ];
 10386  
 10387  	            // Generate initial counter values
 10388  	            var C = this._C = [
 10389  	                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10390  	                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10391  	                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10392  	                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10393  	            ];
 10394  
 10395  	            // Carry bit
 10396  	            this._b = 0;
 10397  
 10398  	            // Iterate the system four times
 10399  	            for (var i = 0; i < 4; i++) {
 10400  	                nextState.call(this);
 10401  	            }
 10402  
 10403  	            // Modify the counters
 10404  	            for (var i = 0; i < 8; i++) {
 10405  	                C[i] ^= X[(i + 4) & 7];
 10406  	            }
 10407  
 10408  	            // IV setup
 10409  	            if (iv) {
 10410  	                // Shortcuts
 10411  	                var IV = iv.words;
 10412  	                var IV_0 = IV[0];
 10413  	                var IV_1 = IV[1];
 10414  
 10415  	                // Generate four subvectors
 10416  	                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10417  	                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10418  	                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10419  	                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10420  
 10421  	                // Modify counter values
 10422  	                C[0] ^= i0;
 10423  	                C[1] ^= i1;
 10424  	                C[2] ^= i2;
 10425  	                C[3] ^= i3;
 10426  	                C[4] ^= i0;
 10427  	                C[5] ^= i1;
 10428  	                C[6] ^= i2;
 10429  	                C[7] ^= i3;
 10430  
 10431  	                // Iterate the system four times
 10432  	                for (var i = 0; i < 4; i++) {
 10433  	                    nextState.call(this);
 10434  	                }
 10435  	            }
 10436  	        },
 10437  
 10438  	        _doProcessBlock: function (M, offset) {
 10439  	            // Shortcut
 10440  	            var X = this._X;
 10441  
 10442  	            // Iterate the system
 10443  	            nextState.call(this);
 10444  
 10445  	            // Generate four keystream words
 10446  	            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10447  	            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10448  	            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10449  	            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10450  
 10451  	            for (var i = 0; i < 4; i++) {
 10452  	                // Swap endian
 10453  	                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10454  	                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10455  
 10456  	                // Encrypt
 10457  	                M[offset + i] ^= S[i];
 10458  	            }
 10459  	        },
 10460  
 10461  	        blockSize: 128/32,
 10462  
 10463  	        ivSize: 64/32
 10464  	    });
 10465  
 10466  	    function nextState() {
 10467  	        // Shortcuts
 10468  	        var X = this._X;
 10469  	        var C = this._C;
 10470  
 10471  	        // Save old counter values
 10472  	        for (var i = 0; i < 8; i++) {
 10473  	            C_[i] = C[i];
 10474  	        }
 10475  
 10476  	        // Calculate new counter values
 10477  	        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10478  	        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10479  	        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10480  	        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10481  	        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10482  	        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10483  	        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10484  	        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10485  	        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10486  
 10487  	        // Calculate the g-values
 10488  	        for (var i = 0; i < 8; i++) {
 10489  	            var gx = X[i] + C[i];
 10490  
 10491  	            // Construct high and low argument for squaring
 10492  	            var ga = gx & 0xffff;
 10493  	            var gb = gx >>> 16;
 10494  
 10495  	            // Calculate high and low result of squaring
 10496  	            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10497  	            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10498  
 10499  	            // High XOR low
 10500  	            G[i] = gh ^ gl;
 10501  	        }
 10502  
 10503  	        // Calculate new state values
 10504  	        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10505  	        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10506  	        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10507  	        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10508  	        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10509  	        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10510  	        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10511  	        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10512  	    }
 10513  
 10514  	    /**
 10515  	     * Shortcut functions to the cipher's object interface.
 10516  	     *
 10517  	     * @example
 10518  	     *
 10519  	     *     var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
 10520  	     *     var plaintext  = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
 10521  	     */
 10522  	    C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
 10523  	}());
 10524  
 10525  
 10526  	return CryptoJS.RabbitLegacy;
 10527  
 10528  }));
 10529  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],74:[function(require,module,exports){
 10530  ;(function (root, factory, undef) {
 10531  	if (typeof exports === "object") {
 10532  		// CommonJS
 10533  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10534  	}
 10535  	else if (typeof define === "function" && define.amd) {
 10536  		// AMD
 10537  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10538  	}
 10539  	else {
 10540  		// Global (browser)
 10541  		factory(root.CryptoJS);
 10542  	}
 10543  }(this, function (CryptoJS) {
 10544  
 10545  	(function () {
 10546  	    // Shortcuts
 10547  	    var C = CryptoJS;
 10548  	    var C_lib = C.lib;
 10549  	    var StreamCipher = C_lib.StreamCipher;
 10550  	    var C_algo = C.algo;
 10551  
 10552  	    // Reusable objects
 10553  	    var S  = [];
 10554  	    var C_ = [];
 10555  	    var G  = [];
 10556  
 10557  	    /**
 10558  	     * Rabbit stream cipher algorithm
 10559  	     */
 10560  	    var Rabbit = C_algo.Rabbit = StreamCipher.extend({
 10561  	        _doReset: function () {
 10562  	            // Shortcuts
 10563  	            var K = this._key.words;
 10564  	            var iv = this.cfg.iv;
 10565  
 10566  	            // Swap endian
 10567  	            for (var i = 0; i < 4; i++) {
 10568  	                K[i] = (((K[i] << 8)  | (K[i] >>> 24)) & 0x00ff00ff) |
 10569  	                       (((K[i] << 24) | (K[i] >>> 8))  & 0xff00ff00);
 10570  	            }
 10571  
 10572  	            // Generate initial state values
 10573  	            var X = this._X = [
 10574  	                K[0], (K[3] << 16) | (K[2] >>> 16),
 10575  	                K[1], (K[0] << 16) | (K[3] >>> 16),
 10576  	                K[2], (K[1] << 16) | (K[0] >>> 16),
 10577  	                K[3], (K[2] << 16) | (K[1] >>> 16)
 10578  	            ];
 10579  
 10580  	            // Generate initial counter values
 10581  	            var C = this._C = [
 10582  	                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10583  	                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10584  	                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10585  	                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10586  	            ];
 10587  
 10588  	            // Carry bit
 10589  	            this._b = 0;
 10590  
 10591  	            // Iterate the system four times
 10592  	            for (var i = 0; i < 4; i++) {
 10593  	                nextState.call(this);
 10594  	            }
 10595  
 10596  	            // Modify the counters
 10597  	            for (var i = 0; i < 8; i++) {
 10598  	                C[i] ^= X[(i + 4) & 7];
 10599  	            }
 10600  
 10601  	            // IV setup
 10602  	            if (iv) {
 10603  	                // Shortcuts
 10604  	                var IV = iv.words;
 10605  	                var IV_0 = IV[0];
 10606  	                var IV_1 = IV[1];
 10607  
 10608  	                // Generate four subvectors
 10609  	                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10610  	                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10611  	                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10612  	                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10613  
 10614  	                // Modify counter values
 10615  	                C[0] ^= i0;
 10616  	                C[1] ^= i1;
 10617  	                C[2] ^= i2;
 10618  	                C[3] ^= i3;
 10619  	                C[4] ^= i0;
 10620  	                C[5] ^= i1;
 10621  	                C[6] ^= i2;
 10622  	                C[7] ^= i3;
 10623  
 10624  	                // Iterate the system four times
 10625  	                for (var i = 0; i < 4; i++) {
 10626  	                    nextState.call(this);
 10627  	                }
 10628  	            }
 10629  	        },
 10630  
 10631  	        _doProcessBlock: function (M, offset) {
 10632  	            // Shortcut
 10633  	            var X = this._X;
 10634  
 10635  	            // Iterate the system
 10636  	            nextState.call(this);
 10637  
 10638  	            // Generate four keystream words
 10639  	            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10640  	            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10641  	            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10642  	            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10643  
 10644  	            for (var i = 0; i < 4; i++) {
 10645  	                // Swap endian
 10646  	                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10647  	                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10648  
 10649  	                // Encrypt
 10650  	                M[offset + i] ^= S[i];
 10651  	            }
 10652  	        },
 10653  
 10654  	        blockSize: 128/32,
 10655  
 10656  	        ivSize: 64/32
 10657  	    });
 10658  
 10659  	    function nextState() {
 10660  	        // Shortcuts
 10661  	        var X = this._X;
 10662  	        var C = this._C;
 10663  
 10664  	        // Save old counter values
 10665  	        for (var i = 0; i < 8; i++) {
 10666  	            C_[i] = C[i];
 10667  	        }
 10668  
 10669  	        // Calculate new counter values
 10670  	        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10671  	        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10672  	        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10673  	        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10674  	        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10675  	        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10676  	        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10677  	        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10678  	        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10679  
 10680  	        // Calculate the g-values
 10681  	        for (var i = 0; i < 8; i++) {
 10682  	            var gx = X[i] + C[i];
 10683  
 10684  	            // Construct high and low argument for squaring
 10685  	            var ga = gx & 0xffff;
 10686  	            var gb = gx >>> 16;
 10687  
 10688  	            // Calculate high and low result of squaring
 10689  	            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10690  	            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10691  
 10692  	            // High XOR low
 10693  	            G[i] = gh ^ gl;
 10694  	        }
 10695  
 10696  	        // Calculate new state values
 10697  	        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10698  	        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10699  	        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10700  	        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10701  	        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10702  	        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10703  	        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10704  	        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10705  	    }
 10706  
 10707  	    /**
 10708  	     * Shortcut functions to the cipher's object interface.
 10709  	     *
 10710  	     * @example
 10711  	     *
 10712  	     *     var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
 10713  	     *     var plaintext  = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
 10714  	     */
 10715  	    C.Rabbit = StreamCipher._createHelper(Rabbit);
 10716  	}());
 10717  
 10718  
 10719  	return CryptoJS.Rabbit;
 10720  
 10721  }));
 10722  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],75:[function(require,module,exports){
 10723  ;(function (root, factory, undef) {
 10724  	if (typeof exports === "object") {
 10725  		// CommonJS
 10726  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10727  	}
 10728  	else if (typeof define === "function" && define.amd) {
 10729  		// AMD
 10730  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10731  	}
 10732  	else {
 10733  		// Global (browser)
 10734  		factory(root.CryptoJS);
 10735  	}
 10736  }(this, function (CryptoJS) {
 10737  
 10738  	(function () {
 10739  	    // Shortcuts
 10740  	    var C = CryptoJS;
 10741  	    var C_lib = C.lib;
 10742  	    var StreamCipher = C_lib.StreamCipher;
 10743  	    var C_algo = C.algo;
 10744  
 10745  	    /**
 10746  	     * RC4 stream cipher algorithm.
 10747  	     */
 10748  	    var RC4 = C_algo.RC4 = StreamCipher.extend({
 10749  	        _doReset: function () {
 10750  	            // Shortcuts
 10751  	            var key = this._key;
 10752  	            var keyWords = key.words;
 10753  	            var keySigBytes = key.sigBytes;
 10754  
 10755  	            // Init sbox
 10756  	            var S = this._S = [];
 10757  	            for (var i = 0; i < 256; i++) {
 10758  	                S[i] = i;
 10759  	            }
 10760  
 10761  	            // Key setup
 10762  	            for (var i = 0, j = 0; i < 256; i++) {
 10763  	                var keyByteIndex = i % keySigBytes;
 10764  	                var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
 10765  
 10766  	                j = (j + S[i] + keyByte) % 256;
 10767  
 10768  	                // Swap
 10769  	                var t = S[i];
 10770  	                S[i] = S[j];
 10771  	                S[j] = t;
 10772  	            }
 10773  
 10774  	            // Counters
 10775  	            this._i = this._j = 0;
 10776  	        },
 10777  
 10778  	        _doProcessBlock: function (M, offset) {
 10779  	            M[offset] ^= generateKeystreamWord.call(this);
 10780  	        },
 10781  
 10782  	        keySize: 256/32,
 10783  
 10784  	        ivSize: 0
 10785  	    });
 10786  
 10787  	    function generateKeystreamWord() {
 10788  	        // Shortcuts
 10789  	        var S = this._S;
 10790  	        var i = this._i;
 10791  	        var j = this._j;
 10792  
 10793  	        // Generate keystream word
 10794  	        var keystreamWord = 0;
 10795  	        for (var n = 0; n < 4; n++) {
 10796  	            i = (i + 1) % 256;
 10797  	            j = (j + S[i]) % 256;
 10798  
 10799  	            // Swap
 10800  	            var t = S[i];
 10801  	            S[i] = S[j];
 10802  	            S[j] = t;
 10803  
 10804  	            keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
 10805  	        }
 10806  
 10807  	        // Update counters
 10808  	        this._i = i;
 10809  	        this._j = j;
 10810  
 10811  	        return keystreamWord;
 10812  	    }
 10813  
 10814  	    /**
 10815  	     * Shortcut functions to the cipher's object interface.
 10816  	     *
 10817  	     * @example
 10818  	     *
 10819  	     *     var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
 10820  	     *     var plaintext  = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
 10821  	     */
 10822  	    C.RC4 = StreamCipher._createHelper(RC4);
 10823  
 10824  	    /**
 10825  	     * Modified RC4 stream cipher algorithm.
 10826  	     */
 10827  	    var RC4Drop = C_algo.RC4Drop = RC4.extend({
 10828  	        /**
 10829  	         * Configuration options.
 10830  	         *
 10831  	         * @property {number} drop The number of keystream words to drop. Default 192
 10832  	         */
 10833  	        cfg: RC4.cfg.extend({
 10834  	            drop: 192
 10835  	        }),
 10836  
 10837  	        _doReset: function () {
 10838  	            RC4._doReset.call(this);
 10839  
 10840  	            // Drop
 10841  	            for (var i = this.cfg.drop; i > 0; i--) {
 10842  	                generateKeystreamWord.call(this);
 10843  	            }
 10844  	        }
 10845  	    });
 10846  
 10847  	    /**
 10848  	     * Shortcut functions to the cipher's object interface.
 10849  	     *
 10850  	     * @example
 10851  	     *
 10852  	     *     var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
 10853  	     *     var plaintext  = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
 10854  	     */
 10855  	    C.RC4Drop = StreamCipher._createHelper(RC4Drop);
 10856  	}());
 10857  
 10858  
 10859  	return CryptoJS.RC4;
 10860  
 10861  }));
 10862  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],76:[function(require,module,exports){
 10863  ;(function (root, factory) {
 10864  	if (typeof exports === "object") {
 10865  		// CommonJS
 10866  		module.exports = exports = factory(require("./core"));
 10867  	}
 10868  	else if (typeof define === "function" && define.amd) {
 10869  		// AMD
 10870  		define(["./core"], factory);
 10871  	}
 10872  	else {
 10873  		// Global (browser)
 10874  		factory(root.CryptoJS);
 10875  	}
 10876  }(this, function (CryptoJS) {
 10877  
 10878  	/** @preserve
 10879  	(c) 2012 by CĂ©dric Mesnil. All rights reserved.
 10880  
 10881  	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 10882  
 10883  	    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 10884  	    - 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.
 10885  
 10886  	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.
 10887  	*/
 10888  
 10889  	(function (Math) {
 10890  	    // Shortcuts
 10891  	    var C = CryptoJS;
 10892  	    var C_lib = C.lib;
 10893  	    var WordArray = C_lib.WordArray;
 10894  	    var Hasher = C_lib.Hasher;
 10895  	    var C_algo = C.algo;
 10896  
 10897  	    // Constants table
 10898  	    var _zl = WordArray.create([
 10899  	        0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
 10900  	        7,  4, 13,  1, 10,  6, 15,  3, 12,  0,  9,  5,  2, 14, 11,  8,
 10901  	        3, 10, 14,  4,  9, 15,  8,  1,  2,  7,  0,  6, 13, 11,  5, 12,
 10902  	        1,  9, 11, 10,  0,  8, 12,  4, 13,  3,  7, 15, 14,  5,  6,  2,
 10903  	        4,  0,  5,  9,  7, 12,  2, 10, 14,  1,  3,  8, 11,  6, 15, 13]);
 10904  	    var _zr = WordArray.create([
 10905  	        5, 14,  7,  0,  9,  2, 11,  4, 13,  6, 15,  8,  1, 10,  3, 12,
 10906  	        6, 11,  3,  7,  0, 13,  5, 10, 14, 15,  8, 12,  4,  9,  1,  2,
 10907  	        15,  5,  1,  3,  7, 14,  6,  9, 11,  8, 12,  2, 10,  0,  4, 13,
 10908  	        8,  6,  4,  1,  3, 11, 15,  0,  5, 12,  2, 13,  9,  7, 10, 14,
 10909  	        12, 15, 10,  4,  1,  5,  8,  7,  6,  2, 13, 14,  0,  3,  9, 11]);
 10910  	    var _sl = WordArray.create([
 10911  	         11, 14, 15, 12,  5,  8,  7,  9, 11, 13, 14, 15,  6,  7,  9,  8,
 10912  	        7, 6,   8, 13, 11,  9,  7, 15,  7, 12, 15,  9, 11,  7, 13, 12,
 10913  	        11, 13,  6,  7, 14,  9, 13, 15, 14,  8, 13,  6,  5, 12,  7,  5,
 10914  	          11, 12, 14, 15, 14, 15,  9,  8,  9, 14,  5,  6,  8,  6,  5, 12,
 10915  	        9, 15,  5, 11,  6,  8, 13, 12,  5, 12, 13, 14, 11,  8,  5,  6 ]);
 10916  	    var _sr = WordArray.create([
 10917  	        8,  9,  9, 11, 13, 15, 15,  5,  7,  7,  8, 11, 14, 14, 12,  6,
 10918  	        9, 13, 15,  7, 12,  8,  9, 11,  7,  7, 12,  7,  6, 15, 13, 11,
 10919  	        9,  7, 15, 11,  8,  6,  6, 14, 12, 13,  5, 14, 13, 13,  7,  5,
 10920  	        15,  5,  8, 11, 14, 14,  6, 14,  6,  9, 12,  9, 12,  5, 15,  8,
 10921  	        8,  5, 12,  9, 12,  5, 14,  6,  8, 13,  6,  5, 15, 13, 11, 11 ]);
 10922  
 10923  	    var _hl =  WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
 10924  	    var _hr =  WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
 10925  
 10926  	    /**
 10927  	     * RIPEMD160 hash algorithm.
 10928  	     */
 10929  	    var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
 10930  	        _doReset: function () {
 10931  	            this._hash  = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
 10932  	        },
 10933  
 10934  	        _doProcessBlock: function (M, offset) {
 10935  
 10936  	            // Swap endian
 10937  	            for (var i = 0; i < 16; i++) {
 10938  	                // Shortcuts
 10939  	                var offset_i = offset + i;
 10940  	                var M_offset_i = M[offset_i];
 10941  
 10942  	                // Swap
 10943  	                M[offset_i] = (
 10944  	                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
 10945  	                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
 10946  	                );
 10947  	            }
 10948  	            // Shortcut
 10949  	            var H  = this._hash.words;
 10950  	            var hl = _hl.words;
 10951  	            var hr = _hr.words;
 10952  	            var zl = _zl.words;
 10953  	            var zr = _zr.words;
 10954  	            var sl = _sl.words;
 10955  	            var sr = _sr.words;
 10956  
 10957  	            // Working variables
 10958  	            var al, bl, cl, dl, el;
 10959  	            var ar, br, cr, dr, er;
 10960  
 10961  	            ar = al = H[0];
 10962  	            br = bl = H[1];
 10963  	            cr = cl = H[2];
 10964  	            dr = dl = H[3];
 10965  	            er = el = H[4];
 10966  	            // Computation
 10967  	            var t;
 10968  	            for (var i = 0; i < 80; i += 1) {
 10969  	                t = (al +  M[offset+zl[i]])|0;
 10970  	                if (i<16){
 10971  		            t +=  f1(bl,cl,dl) + hl[0];
 10972  	                } else if (i<32) {
 10973  		            t +=  f2(bl,cl,dl) + hl[1];
 10974  	                } else if (i<48) {
 10975  		            t +=  f3(bl,cl,dl) + hl[2];
 10976  	                } else if (i<64) {
 10977  		            t +=  f4(bl,cl,dl) + hl[3];
 10978  	                } else {// if (i<80) {
 10979  		            t +=  f5(bl,cl,dl) + hl[4];
 10980  	                }
 10981  	                t = t|0;
 10982  	                t =  rotl(t,sl[i]);
 10983  	                t = (t+el)|0;
 10984  	                al = el;
 10985  	                el = dl;
 10986  	                dl = rotl(cl, 10);
 10987  	                cl = bl;
 10988  	                bl = t;
 10989  
 10990  	                t = (ar + M[offset+zr[i]])|0;
 10991  	                if (i<16){
 10992  		            t +=  f5(br,cr,dr) + hr[0];
 10993  	                } else if (i<32) {
 10994  		            t +=  f4(br,cr,dr) + hr[1];
 10995  	                } else if (i<48) {
 10996  		            t +=  f3(br,cr,dr) + hr[2];
 10997  	                } else if (i<64) {
 10998  		            t +=  f2(br,cr,dr) + hr[3];
 10999  	                } else {// if (i<80) {
 11000  		            t +=  f1(br,cr,dr) + hr[4];
 11001  	                }
 11002  	                t = t|0;
 11003  	                t =  rotl(t,sr[i]) ;
 11004  	                t = (t+er)|0;
 11005  	                ar = er;
 11006  	                er = dr;
 11007  	                dr = rotl(cr, 10);
 11008  	                cr = br;
 11009  	                br = t;
 11010  	            }
 11011  	            // Intermediate hash value
 11012  	            t    = (H[1] + cl + dr)|0;
 11013  	            H[1] = (H[2] + dl + er)|0;
 11014  	            H[2] = (H[3] + el + ar)|0;
 11015  	            H[3] = (H[4] + al + br)|0;
 11016  	            H[4] = (H[0] + bl + cr)|0;
 11017  	            H[0] =  t;
 11018  	        },
 11019  
 11020  	        _doFinalize: function () {
 11021  	            // Shortcuts
 11022  	            var data = this._data;
 11023  	            var dataWords = data.words;
 11024  
 11025  	            var nBitsTotal = this._nDataBytes * 8;
 11026  	            var nBitsLeft = data.sigBytes * 8;
 11027  
 11028  	            // Add padding
 11029  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11030  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
 11031  	                (((nBitsTotal << 8)  | (nBitsTotal >>> 24)) & 0x00ff00ff) |
 11032  	                (((nBitsTotal << 24) | (nBitsTotal >>> 8))  & 0xff00ff00)
 11033  	            );
 11034  	            data.sigBytes = (dataWords.length + 1) * 4;
 11035  
 11036  	            // Hash final blocks
 11037  	            this._process();
 11038  
 11039  	            // Shortcuts
 11040  	            var hash = this._hash;
 11041  	            var H = hash.words;
 11042  
 11043  	            // Swap endian
 11044  	            for (var i = 0; i < 5; i++) {
 11045  	                // Shortcut
 11046  	                var H_i = H[i];
 11047  
 11048  	                // Swap
 11049  	                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
 11050  	                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
 11051  	            }
 11052  
 11053  	            // Return final computed hash
 11054  	            return hash;
 11055  	        },
 11056  
 11057  	        clone: function () {
 11058  	            var clone = Hasher.clone.call(this);
 11059  	            clone._hash = this._hash.clone();
 11060  
 11061  	            return clone;
 11062  	        }
 11063  	    });
 11064  
 11065  
 11066  	    function f1(x, y, z) {
 11067  	        return ((x) ^ (y) ^ (z));
 11068  
 11069  	    }
 11070  
 11071  	    function f2(x, y, z) {
 11072  	        return (((x)&(y)) | ((~x)&(z)));
 11073  	    }
 11074  
 11075  	    function f3(x, y, z) {
 11076  	        return (((x) | (~(y))) ^ (z));
 11077  	    }
 11078  
 11079  	    function f4(x, y, z) {
 11080  	        return (((x) & (z)) | ((y)&(~(z))));
 11081  	    }
 11082  
 11083  	    function f5(x, y, z) {
 11084  	        return ((x) ^ ((y) |(~(z))));
 11085  
 11086  	    }
 11087  
 11088  	    function rotl(x,n) {
 11089  	        return (x<<n) | (x>>>(32-n));
 11090  	    }
 11091  
 11092  
 11093  	    /**
 11094  	     * Shortcut function to the hasher's object interface.
 11095  	     *
 11096  	     * @param {WordArray|string} message The message to hash.
 11097  	     *
 11098  	     * @return {WordArray} The hash.
 11099  	     *
 11100  	     * @static
 11101  	     *
 11102  	     * @example
 11103  	     *
 11104  	     *     var hash = CryptoJS.RIPEMD160('message');
 11105  	     *     var hash = CryptoJS.RIPEMD160(wordArray);
 11106  	     */
 11107  	    C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
 11108  
 11109  	    /**
 11110  	     * Shortcut function to the HMAC's object interface.
 11111  	     *
 11112  	     * @param {WordArray|string} message The message to hash.
 11113  	     * @param {WordArray|string} key The secret key.
 11114  	     *
 11115  	     * @return {WordArray} The HMAC.
 11116  	     *
 11117  	     * @static
 11118  	     *
 11119  	     * @example
 11120  	     *
 11121  	     *     var hmac = CryptoJS.HmacRIPEMD160(message, key);
 11122  	     */
 11123  	    C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
 11124  	}(Math));
 11125  
 11126  
 11127  	return CryptoJS.RIPEMD160;
 11128  
 11129  }));
 11130  },{"./core":53}],77:[function(require,module,exports){
 11131  ;(function (root, factory) {
 11132  	if (typeof exports === "object") {
 11133  		// CommonJS
 11134  		module.exports = exports = factory(require("./core"));
 11135  	}
 11136  	else if (typeof define === "function" && define.amd) {
 11137  		// AMD
 11138  		define(["./core"], factory);
 11139  	}
 11140  	else {
 11141  		// Global (browser)
 11142  		factory(root.CryptoJS);
 11143  	}
 11144  }(this, function (CryptoJS) {
 11145  
 11146  	(function () {
 11147  	    // Shortcuts
 11148  	    var C = CryptoJS;
 11149  	    var C_lib = C.lib;
 11150  	    var WordArray = C_lib.WordArray;
 11151  	    var Hasher = C_lib.Hasher;
 11152  	    var C_algo = C.algo;
 11153  
 11154  	    // Reusable object
 11155  	    var W = [];
 11156  
 11157  	    /**
 11158  	     * SHA-1 hash algorithm.
 11159  	     */
 11160  	    var SHA1 = C_algo.SHA1 = Hasher.extend({
 11161  	        _doReset: function () {
 11162  	            this._hash = new WordArray.init([
 11163  	                0x67452301, 0xefcdab89,
 11164  	                0x98badcfe, 0x10325476,
 11165  	                0xc3d2e1f0
 11166  	            ]);
 11167  	        },
 11168  
 11169  	        _doProcessBlock: function (M, offset) {
 11170  	            // Shortcut
 11171  	            var H = this._hash.words;
 11172  
 11173  	            // Working variables
 11174  	            var a = H[0];
 11175  	            var b = H[1];
 11176  	            var c = H[2];
 11177  	            var d = H[3];
 11178  	            var e = H[4];
 11179  
 11180  	            // Computation
 11181  	            for (var i = 0; i < 80; i++) {
 11182  	                if (i < 16) {
 11183  	                    W[i] = M[offset + i] | 0;
 11184  	                } else {
 11185  	                    var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
 11186  	                    W[i] = (n << 1) | (n >>> 31);
 11187  	                }
 11188  
 11189  	                var t = ((a << 5) | (a >>> 27)) + e + W[i];
 11190  	                if (i < 20) {
 11191  	                    t += ((b & c) | (~b & d)) + 0x5a827999;
 11192  	                } else if (i < 40) {
 11193  	                    t += (b ^ c ^ d) + 0x6ed9eba1;
 11194  	                } else if (i < 60) {
 11195  	                    t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
 11196  	                } else /* if (i < 80) */ {
 11197  	                    t += (b ^ c ^ d) - 0x359d3e2a;
 11198  	                }
 11199  
 11200  	                e = d;
 11201  	                d = c;
 11202  	                c = (b << 30) | (b >>> 2);
 11203  	                b = a;
 11204  	                a = t;
 11205  	            }
 11206  
 11207  	            // Intermediate hash value
 11208  	            H[0] = (H[0] + a) | 0;
 11209  	            H[1] = (H[1] + b) | 0;
 11210  	            H[2] = (H[2] + c) | 0;
 11211  	            H[3] = (H[3] + d) | 0;
 11212  	            H[4] = (H[4] + e) | 0;
 11213  	        },
 11214  
 11215  	        _doFinalize: function () {
 11216  	            // Shortcuts
 11217  	            var data = this._data;
 11218  	            var dataWords = data.words;
 11219  
 11220  	            var nBitsTotal = this._nDataBytes * 8;
 11221  	            var nBitsLeft = data.sigBytes * 8;
 11222  
 11223  	            // Add padding
 11224  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11225  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11226  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11227  	            data.sigBytes = dataWords.length * 4;
 11228  
 11229  	            // Hash final blocks
 11230  	            this._process();
 11231  
 11232  	            // Return final computed hash
 11233  	            return this._hash;
 11234  	        },
 11235  
 11236  	        clone: function () {
 11237  	            var clone = Hasher.clone.call(this);
 11238  	            clone._hash = this._hash.clone();
 11239  
 11240  	            return clone;
 11241  	        }
 11242  	    });
 11243  
 11244  	    /**
 11245  	     * Shortcut function to the hasher's object interface.
 11246  	     *
 11247  	     * @param {WordArray|string} message The message to hash.
 11248  	     *
 11249  	     * @return {WordArray} The hash.
 11250  	     *
 11251  	     * @static
 11252  	     *
 11253  	     * @example
 11254  	     *
 11255  	     *     var hash = CryptoJS.SHA1('message');
 11256  	     *     var hash = CryptoJS.SHA1(wordArray);
 11257  	     */
 11258  	    C.SHA1 = Hasher._createHelper(SHA1);
 11259  
 11260  	    /**
 11261  	     * Shortcut function to the HMAC's object interface.
 11262  	     *
 11263  	     * @param {WordArray|string} message The message to hash.
 11264  	     * @param {WordArray|string} key The secret key.
 11265  	     *
 11266  	     * @return {WordArray} The HMAC.
 11267  	     *
 11268  	     * @static
 11269  	     *
 11270  	     * @example
 11271  	     *
 11272  	     *     var hmac = CryptoJS.HmacSHA1(message, key);
 11273  	     */
 11274  	    C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
 11275  	}());
 11276  
 11277  
 11278  	return CryptoJS.SHA1;
 11279  
 11280  }));
 11281  },{"./core":53}],78:[function(require,module,exports){
 11282  ;(function (root, factory, undef) {
 11283  	if (typeof exports === "object") {
 11284  		// CommonJS
 11285  		module.exports = exports = factory(require("./core"), require("./sha256"));
 11286  	}
 11287  	else if (typeof define === "function" && define.amd) {
 11288  		// AMD
 11289  		define(["./core", "./sha256"], factory);
 11290  	}
 11291  	else {
 11292  		// Global (browser)
 11293  		factory(root.CryptoJS);
 11294  	}
 11295  }(this, function (CryptoJS) {
 11296  
 11297  	(function () {
 11298  	    // Shortcuts
 11299  	    var C = CryptoJS;
 11300  	    var C_lib = C.lib;
 11301  	    var WordArray = C_lib.WordArray;
 11302  	    var C_algo = C.algo;
 11303  	    var SHA256 = C_algo.SHA256;
 11304  
 11305  	    /**
 11306  	     * SHA-224 hash algorithm.
 11307  	     */
 11308  	    var SHA224 = C_algo.SHA224 = SHA256.extend({
 11309  	        _doReset: function () {
 11310  	            this._hash = new WordArray.init([
 11311  	                0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
 11312  	                0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
 11313  	            ]);
 11314  	        },
 11315  
 11316  	        _doFinalize: function () {
 11317  	            var hash = SHA256._doFinalize.call(this);
 11318  
 11319  	            hash.sigBytes -= 4;
 11320  
 11321  	            return hash;
 11322  	        }
 11323  	    });
 11324  
 11325  	    /**
 11326  	     * Shortcut function to the hasher's object interface.
 11327  	     *
 11328  	     * @param {WordArray|string} message The message to hash.
 11329  	     *
 11330  	     * @return {WordArray} The hash.
 11331  	     *
 11332  	     * @static
 11333  	     *
 11334  	     * @example
 11335  	     *
 11336  	     *     var hash = CryptoJS.SHA224('message');
 11337  	     *     var hash = CryptoJS.SHA224(wordArray);
 11338  	     */
 11339  	    C.SHA224 = SHA256._createHelper(SHA224);
 11340  
 11341  	    /**
 11342  	     * Shortcut function to the HMAC's object interface.
 11343  	     *
 11344  	     * @param {WordArray|string} message The message to hash.
 11345  	     * @param {WordArray|string} key The secret key.
 11346  	     *
 11347  	     * @return {WordArray} The HMAC.
 11348  	     *
 11349  	     * @static
 11350  	     *
 11351  	     * @example
 11352  	     *
 11353  	     *     var hmac = CryptoJS.HmacSHA224(message, key);
 11354  	     */
 11355  	    C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
 11356  	}());
 11357  
 11358  
 11359  	return CryptoJS.SHA224;
 11360  
 11361  }));
 11362  },{"./core":53,"./sha256":79}],79:[function(require,module,exports){
 11363  ;(function (root, factory) {
 11364  	if (typeof exports === "object") {
 11365  		// CommonJS
 11366  		module.exports = exports = factory(require("./core"));
 11367  	}
 11368  	else if (typeof define === "function" && define.amd) {
 11369  		// AMD
 11370  		define(["./core"], factory);
 11371  	}
 11372  	else {
 11373  		// Global (browser)
 11374  		factory(root.CryptoJS);
 11375  	}
 11376  }(this, function (CryptoJS) {
 11377  
 11378  	(function (Math) {
 11379  	    // Shortcuts
 11380  	    var C = CryptoJS;
 11381  	    var C_lib = C.lib;
 11382  	    var WordArray = C_lib.WordArray;
 11383  	    var Hasher = C_lib.Hasher;
 11384  	    var C_algo = C.algo;
 11385  
 11386  	    // Initialization and round constants tables
 11387  	    var H = [];
 11388  	    var K = [];
 11389  
 11390  	    // Compute constants
 11391  	    (function () {
 11392  	        function isPrime(n) {
 11393  	            var sqrtN = Math.sqrt(n);
 11394  	            for (var factor = 2; factor <= sqrtN; factor++) {
 11395  	                if (!(n % factor)) {
 11396  	                    return false;
 11397  	                }
 11398  	            }
 11399  
 11400  	            return true;
 11401  	        }
 11402  
 11403  	        function getFractionalBits(n) {
 11404  	            return ((n - (n | 0)) * 0x100000000) | 0;
 11405  	        }
 11406  
 11407  	        var n = 2;
 11408  	        var nPrime = 0;
 11409  	        while (nPrime < 64) {
 11410  	            if (isPrime(n)) {
 11411  	                if (nPrime < 8) {
 11412  	                    H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
 11413  	                }
 11414  	                K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
 11415  
 11416  	                nPrime++;
 11417  	            }
 11418  
 11419  	            n++;
 11420  	        }
 11421  	    }());
 11422  
 11423  	    // Reusable object
 11424  	    var W = [];
 11425  
 11426  	    /**
 11427  	     * SHA-256 hash algorithm.
 11428  	     */
 11429  	    var SHA256 = C_algo.SHA256 = Hasher.extend({
 11430  	        _doReset: function () {
 11431  	            this._hash = new WordArray.init(H.slice(0));
 11432  	        },
 11433  
 11434  	        _doProcessBlock: function (M, offset) {
 11435  	            // Shortcut
 11436  	            var H = this._hash.words;
 11437  
 11438  	            // Working variables
 11439  	            var a = H[0];
 11440  	            var b = H[1];
 11441  	            var c = H[2];
 11442  	            var d = H[3];
 11443  	            var e = H[4];
 11444  	            var f = H[5];
 11445  	            var g = H[6];
 11446  	            var h = H[7];
 11447  
 11448  	            // Computation
 11449  	            for (var i = 0; i < 64; i++) {
 11450  	                if (i < 16) {
 11451  	                    W[i] = M[offset + i] | 0;
 11452  	                } else {
 11453  	                    var gamma0x = W[i - 15];
 11454  	                    var gamma0  = ((gamma0x << 25) | (gamma0x >>> 7))  ^
 11455  	                                  ((gamma0x << 14) | (gamma0x >>> 18)) ^
 11456  	                                   (gamma0x >>> 3);
 11457  
 11458  	                    var gamma1x = W[i - 2];
 11459  	                    var gamma1  = ((gamma1x << 15) | (gamma1x >>> 17)) ^
 11460  	                                  ((gamma1x << 13) | (gamma1x >>> 19)) ^
 11461  	                                   (gamma1x >>> 10);
 11462  
 11463  	                    W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
 11464  	                }
 11465  
 11466  	                var ch  = (e & f) ^ (~e & g);
 11467  	                var maj = (a & b) ^ (a & c) ^ (b & c);
 11468  
 11469  	                var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
 11470  	                var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7)  | (e >>> 25));
 11471  
 11472  	                var t1 = h + sigma1 + ch + K[i] + W[i];
 11473  	                var t2 = sigma0 + maj;
 11474  
 11475  	                h = g;
 11476  	                g = f;
 11477  	                f = e;
 11478  	                e = (d + t1) | 0;
 11479  	                d = c;
 11480  	                c = b;
 11481  	                b = a;
 11482  	                a = (t1 + t2) | 0;
 11483  	            }
 11484  
 11485  	            // Intermediate hash value
 11486  	            H[0] = (H[0] + a) | 0;
 11487  	            H[1] = (H[1] + b) | 0;
 11488  	            H[2] = (H[2] + c) | 0;
 11489  	            H[3] = (H[3] + d) | 0;
 11490  	            H[4] = (H[4] + e) | 0;
 11491  	            H[5] = (H[5] + f) | 0;
 11492  	            H[6] = (H[6] + g) | 0;
 11493  	            H[7] = (H[7] + h) | 0;
 11494  	        },
 11495  
 11496  	        _doFinalize: function () {
 11497  	            // Shortcuts
 11498  	            var data = this._data;
 11499  	            var dataWords = data.words;
 11500  
 11501  	            var nBitsTotal = this._nDataBytes * 8;
 11502  	            var nBitsLeft = data.sigBytes * 8;
 11503  
 11504  	            // Add padding
 11505  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11506  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11507  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11508  	            data.sigBytes = dataWords.length * 4;
 11509  
 11510  	            // Hash final blocks
 11511  	            this._process();
 11512  
 11513  	            // Return final computed hash
 11514  	            return this._hash;
 11515  	        },
 11516  
 11517  	        clone: function () {
 11518  	            var clone = Hasher.clone.call(this);
 11519  	            clone._hash = this._hash.clone();
 11520  
 11521  	            return clone;
 11522  	        }
 11523  	    });
 11524  
 11525  	    /**
 11526  	     * Shortcut function to the hasher's object interface.
 11527  	     *
 11528  	     * @param {WordArray|string} message The message to hash.
 11529  	     *
 11530  	     * @return {WordArray} The hash.
 11531  	     *
 11532  	     * @static
 11533  	     *
 11534  	     * @example
 11535  	     *
 11536  	     *     var hash = CryptoJS.SHA256('message');
 11537  	     *     var hash = CryptoJS.SHA256(wordArray);
 11538  	     */
 11539  	    C.SHA256 = Hasher._createHelper(SHA256);
 11540  
 11541  	    /**
 11542  	     * Shortcut function to the HMAC's object interface.
 11543  	     *
 11544  	     * @param {WordArray|string} message The message to hash.
 11545  	     * @param {WordArray|string} key The secret key.
 11546  	     *
 11547  	     * @return {WordArray} The HMAC.
 11548  	     *
 11549  	     * @static
 11550  	     *
 11551  	     * @example
 11552  	     *
 11553  	     *     var hmac = CryptoJS.HmacSHA256(message, key);
 11554  	     */
 11555  	    C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
 11556  	}(Math));
 11557  
 11558  
 11559  	return CryptoJS.SHA256;
 11560  
 11561  }));
 11562  },{"./core":53}],80:[function(require,module,exports){
 11563  ;(function (root, factory, undef) {
 11564  	if (typeof exports === "object") {
 11565  		// CommonJS
 11566  		module.exports = exports = factory(require("./core"), require("./x64-core"));
 11567  	}
 11568  	else if (typeof define === "function" && define.amd) {
 11569  		// AMD
 11570  		define(["./core", "./x64-core"], factory);
 11571  	}
 11572  	else {
 11573  		// Global (browser)
 11574  		factory(root.CryptoJS);
 11575  	}
 11576  }(this, function (CryptoJS) {
 11577  
 11578  	(function (Math) {
 11579  	    // Shortcuts
 11580  	    var C = CryptoJS;
 11581  	    var C_lib = C.lib;
 11582  	    var WordArray = C_lib.WordArray;
 11583  	    var Hasher = C_lib.Hasher;
 11584  	    var C_x64 = C.x64;
 11585  	    var X64Word = C_x64.Word;
 11586  	    var C_algo = C.algo;
 11587  
 11588  	    // Constants tables
 11589  	    var RHO_OFFSETS = [];
 11590  	    var PI_INDEXES  = [];
 11591  	    var ROUND_CONSTANTS = [];
 11592  
 11593  	    // Compute Constants
 11594  	    (function () {
 11595  	        // Compute rho offset constants
 11596  	        var x = 1, y = 0;
 11597  	        for (var t = 0; t < 24; t++) {
 11598  	            RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
 11599  
 11600  	            var newX = y % 5;
 11601  	            var newY = (2 * x + 3 * y) % 5;
 11602  	            x = newX;
 11603  	            y = newY;
 11604  	        }
 11605  
 11606  	        // Compute pi index constants
 11607  	        for (var x = 0; x < 5; x++) {
 11608  	            for (var y = 0; y < 5; y++) {
 11609  	                PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
 11610  	            }
 11611  	        }
 11612  
 11613  	        // Compute round constants
 11614  	        var LFSR = 0x01;
 11615  	        for (var i = 0; i < 24; i++) {
 11616  	            var roundConstantMsw = 0;
 11617  	            var roundConstantLsw = 0;
 11618  
 11619  	            for (var j = 0; j < 7; j++) {
 11620  	                if (LFSR & 0x01) {
 11621  	                    var bitPosition = (1 << j) - 1;
 11622  	                    if (bitPosition < 32) {
 11623  	                        roundConstantLsw ^= 1 << bitPosition;
 11624  	                    } else /* if (bitPosition >= 32) */ {
 11625  	                        roundConstantMsw ^= 1 << (bitPosition - 32);
 11626  	                    }
 11627  	                }
 11628  
 11629  	                // Compute next LFSR
 11630  	                if (LFSR & 0x80) {
 11631  	                    // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
 11632  	                    LFSR = (LFSR << 1) ^ 0x71;
 11633  	                } else {
 11634  	                    LFSR <<= 1;
 11635  	                }
 11636  	            }
 11637  
 11638  	            ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
 11639  	        }
 11640  	    }());
 11641  
 11642  	    // Reusable objects for temporary values
 11643  	    var T = [];
 11644  	    (function () {
 11645  	        for (var i = 0; i < 25; i++) {
 11646  	            T[i] = X64Word.create();
 11647  	        }
 11648  	    }());
 11649  
 11650  	    /**
 11651  	     * SHA-3 hash algorithm.
 11652  	     */
 11653  	    var SHA3 = C_algo.SHA3 = Hasher.extend({
 11654  	        /**
 11655  	         * Configuration options.
 11656  	         *
 11657  	         * @property {number} outputLength
 11658  	         *   The desired number of bits in the output hash.
 11659  	         *   Only values permitted are: 224, 256, 384, 512.
 11660  	         *   Default: 512
 11661  	         */
 11662  	        cfg: Hasher.cfg.extend({
 11663  	            outputLength: 512
 11664  	        }),
 11665  
 11666  	        _doReset: function () {
 11667  	            var state = this._state = []
 11668  	            for (var i = 0; i < 25; i++) {
 11669  	                state[i] = new X64Word.init();
 11670  	            }
 11671  
 11672  	            this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
 11673  	        },
 11674  
 11675  	        _doProcessBlock: function (M, offset) {
 11676  	            // Shortcuts
 11677  	            var state = this._state;
 11678  	            var nBlockSizeLanes = this.blockSize / 2;
 11679  
 11680  	            // Absorb
 11681  	            for (var i = 0; i < nBlockSizeLanes; i++) {
 11682  	                // Shortcuts
 11683  	                var M2i  = M[offset + 2 * i];
 11684  	                var M2i1 = M[offset + 2 * i + 1];
 11685  
 11686  	                // Swap endian
 11687  	                M2i = (
 11688  	                    (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |
 11689  	                    (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)
 11690  	                );
 11691  	                M2i1 = (
 11692  	                    (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |
 11693  	                    (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)
 11694  	                );
 11695  
 11696  	                // Absorb message into state
 11697  	                var lane = state[i];
 11698  	                lane.high ^= M2i1;
 11699  	                lane.low  ^= M2i;
 11700  	            }
 11701  
 11702  	            // Rounds
 11703  	            for (var round = 0; round < 24; round++) {
 11704  	                // Theta
 11705  	                for (var x = 0; x < 5; x++) {
 11706  	                    // Mix column lanes
 11707  	                    var tMsw = 0, tLsw = 0;
 11708  	                    for (var y = 0; y < 5; y++) {
 11709  	                        var lane = state[x + 5 * y];
 11710  	                        tMsw ^= lane.high;
 11711  	                        tLsw ^= lane.low;
 11712  	                    }
 11713  
 11714  	                    // Temporary values
 11715  	                    var Tx = T[x];
 11716  	                    Tx.high = tMsw;
 11717  	                    Tx.low  = tLsw;
 11718  	                }
 11719  	                for (var x = 0; x < 5; x++) {
 11720  	                    // Shortcuts
 11721  	                    var Tx4 = T[(x + 4) % 5];
 11722  	                    var Tx1 = T[(x + 1) % 5];
 11723  	                    var Tx1Msw = Tx1.high;
 11724  	                    var Tx1Lsw = Tx1.low;
 11725  
 11726  	                    // Mix surrounding columns
 11727  	                    var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
 11728  	                    var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
 11729  	                    for (var y = 0; y < 5; y++) {
 11730  	                        var lane = state[x + 5 * y];
 11731  	                        lane.high ^= tMsw;
 11732  	                        lane.low  ^= tLsw;
 11733  	                    }
 11734  	                }
 11735  
 11736  	                // Rho Pi
 11737  	                for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
 11738  	                    // Shortcuts
 11739  	                    var lane = state[laneIndex];
 11740  	                    var laneMsw = lane.high;
 11741  	                    var laneLsw = lane.low;
 11742  	                    var rhoOffset = RHO_OFFSETS[laneIndex];
 11743  
 11744  	                    // Rotate lanes
 11745  	                    if (rhoOffset < 32) {
 11746  	                        var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
 11747  	                        var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
 11748  	                    } else /* if (rhoOffset >= 32) */ {
 11749  	                        var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
 11750  	                        var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
 11751  	                    }
 11752  
 11753  	                    // Transpose lanes
 11754  	                    var TPiLane = T[PI_INDEXES[laneIndex]];
 11755  	                    TPiLane.high = tMsw;
 11756  	                    TPiLane.low  = tLsw;
 11757  	                }
 11758  
 11759  	                // Rho pi at x = y = 0
 11760  	                var T0 = T[0];
 11761  	                var state0 = state[0];
 11762  	                T0.high = state0.high;
 11763  	                T0.low  = state0.low;
 11764  
 11765  	                // Chi
 11766  	                for (var x = 0; x < 5; x++) {
 11767  	                    for (var y = 0; y < 5; y++) {
 11768  	                        // Shortcuts
 11769  	                        var laneIndex = x + 5 * y;
 11770  	                        var lane = state[laneIndex];
 11771  	                        var TLane = T[laneIndex];
 11772  	                        var Tx1Lane = T[((x + 1) % 5) + 5 * y];
 11773  	                        var Tx2Lane = T[((x + 2) % 5) + 5 * y];
 11774  
 11775  	                        // Mix rows
 11776  	                        lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
 11777  	                        lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);
 11778  	                    }
 11779  	                }
 11780  
 11781  	                // Iota
 11782  	                var lane = state[0];
 11783  	                var roundConstant = ROUND_CONSTANTS[round];
 11784  	                lane.high ^= roundConstant.high;
 11785  	                lane.low  ^= roundConstant.low;;
 11786  	            }
 11787  	        },
 11788  
 11789  	        _doFinalize: function () {
 11790  	            // Shortcuts
 11791  	            var data = this._data;
 11792  	            var dataWords = data.words;
 11793  	            var nBitsTotal = this._nDataBytes * 8;
 11794  	            var nBitsLeft = data.sigBytes * 8;
 11795  	            var blockSizeBits = this.blockSize * 32;
 11796  
 11797  	            // Add padding
 11798  	            dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
 11799  	            dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
 11800  	            data.sigBytes = dataWords.length * 4;
 11801  
 11802  	            // Hash final blocks
 11803  	            this._process();
 11804  
 11805  	            // Shortcuts
 11806  	            var state = this._state;
 11807  	            var outputLengthBytes = this.cfg.outputLength / 8;
 11808  	            var outputLengthLanes = outputLengthBytes / 8;
 11809  
 11810  	            // Squeeze
 11811  	            var hashWords = [];
 11812  	            for (var i = 0; i < outputLengthLanes; i++) {
 11813  	                // Shortcuts
 11814  	                var lane = state[i];
 11815  	                var laneMsw = lane.high;
 11816  	                var laneLsw = lane.low;
 11817  
 11818  	                // Swap endian
 11819  	                laneMsw = (
 11820  	                    (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |
 11821  	                    (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)
 11822  	                );
 11823  	                laneLsw = (
 11824  	                    (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |
 11825  	                    (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)
 11826  	                );
 11827  
 11828  	                // Squeeze state to retrieve hash
 11829  	                hashWords.push(laneLsw);
 11830  	                hashWords.push(laneMsw);
 11831  	            }
 11832  
 11833  	            // Return final computed hash
 11834  	            return new WordArray.init(hashWords, outputLengthBytes);
 11835  	        },
 11836  
 11837  	        clone: function () {
 11838  	            var clone = Hasher.clone.call(this);
 11839  
 11840  	            var state = clone._state = this._state.slice(0);
 11841  	            for (var i = 0; i < 25; i++) {
 11842  	                state[i] = state[i].clone();
 11843  	            }
 11844  
 11845  	            return clone;
 11846  	        }
 11847  	    });
 11848  
 11849  	    /**
 11850  	     * Shortcut function to the hasher's object interface.
 11851  	     *
 11852  	     * @param {WordArray|string} message The message to hash.
 11853  	     *
 11854  	     * @return {WordArray} The hash.
 11855  	     *
 11856  	     * @static
 11857  	     *
 11858  	     * @example
 11859  	     *
 11860  	     *     var hash = CryptoJS.SHA3('message');
 11861  	     *     var hash = CryptoJS.SHA3(wordArray);
 11862  	     */
 11863  	    C.SHA3 = Hasher._createHelper(SHA3);
 11864  
 11865  	    /**
 11866  	     * Shortcut function to the HMAC's object interface.
 11867  	     *
 11868  	     * @param {WordArray|string} message The message to hash.
 11869  	     * @param {WordArray|string} key The secret key.
 11870  	     *
 11871  	     * @return {WordArray} The HMAC.
 11872  	     *
 11873  	     * @static
 11874  	     *
 11875  	     * @example
 11876  	     *
 11877  	     *     var hmac = CryptoJS.HmacSHA3(message, key);
 11878  	     */
 11879  	    C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
 11880  	}(Math));
 11881  
 11882  
 11883  	return CryptoJS.SHA3;
 11884  
 11885  }));
 11886  },{"./core":53,"./x64-core":84}],81:[function(require,module,exports){
 11887  ;(function (root, factory, undef) {
 11888  	if (typeof exports === "object") {
 11889  		// CommonJS
 11890  		module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512"));
 11891  	}
 11892  	else if (typeof define === "function" && define.amd) {
 11893  		// AMD
 11894  		define(["./core", "./x64-core", "./sha512"], factory);
 11895  	}
 11896  	else {
 11897  		// Global (browser)
 11898  		factory(root.CryptoJS);
 11899  	}
 11900  }(this, function (CryptoJS) {
 11901  
 11902  	(function () {
 11903  	    // Shortcuts
 11904  	    var C = CryptoJS;
 11905  	    var C_x64 = C.x64;
 11906  	    var X64Word = C_x64.Word;
 11907  	    var X64WordArray = C_x64.WordArray;
 11908  	    var C_algo = C.algo;
 11909  	    var SHA512 = C_algo.SHA512;
 11910  
 11911  	    /**
 11912  	     * SHA-384 hash algorithm.
 11913  	     */
 11914  	    var SHA384 = C_algo.SHA384 = SHA512.extend({
 11915  	        _doReset: function () {
 11916  	            this._hash = new X64WordArray.init([
 11917  	                new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
 11918  	                new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
 11919  	                new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
 11920  	                new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
 11921  	            ]);
 11922  	        },
 11923  
 11924  	        _doFinalize: function () {
 11925  	            var hash = SHA512._doFinalize.call(this);
 11926  
 11927  	            hash.sigBytes -= 16;
 11928  
 11929  	            return hash;
 11930  	        }
 11931  	    });
 11932  
 11933  	    /**
 11934  	     * Shortcut function to the hasher's object interface.
 11935  	     *
 11936  	     * @param {WordArray|string} message The message to hash.
 11937  	     *
 11938  	     * @return {WordArray} The hash.
 11939  	     *
 11940  	     * @static
 11941  	     *
 11942  	     * @example
 11943  	     *
 11944  	     *     var hash = CryptoJS.SHA384('message');
 11945  	     *     var hash = CryptoJS.SHA384(wordArray);
 11946  	     */
 11947  	    C.SHA384 = SHA512._createHelper(SHA384);
 11948  
 11949  	    /**
 11950  	     * Shortcut function to the HMAC's object interface.
 11951  	     *
 11952  	     * @param {WordArray|string} message The message to hash.
 11953  	     * @param {WordArray|string} key The secret key.
 11954  	     *
 11955  	     * @return {WordArray} The HMAC.
 11956  	     *
 11957  	     * @static
 11958  	     *
 11959  	     * @example
 11960  	     *
 11961  	     *     var hmac = CryptoJS.HmacSHA384(message, key);
 11962  	     */
 11963  	    C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
 11964  	}());
 11965  
 11966  
 11967  	return CryptoJS.SHA384;
 11968  
 11969  }));
 11970  },{"./core":53,"./sha512":82,"./x64-core":84}],82:[function(require,module,exports){
 11971  ;(function (root, factory, undef) {
 11972  	if (typeof exports === "object") {
 11973  		// CommonJS
 11974  		module.exports = exports = factory(require("./core"), require("./x64-core"));
 11975  	}
 11976  	else if (typeof define === "function" && define.amd) {
 11977  		// AMD
 11978  		define(["./core", "./x64-core"], factory);
 11979  	}
 11980  	else {
 11981  		// Global (browser)
 11982  		factory(root.CryptoJS);
 11983  	}
 11984  }(this, function (CryptoJS) {
 11985  
 11986  	(function () {
 11987  	    // Shortcuts
 11988  	    var C = CryptoJS;
 11989  	    var C_lib = C.lib;
 11990  	    var Hasher = C_lib.Hasher;
 11991  	    var C_x64 = C.x64;
 11992  	    var X64Word = C_x64.Word;
 11993  	    var X64WordArray = C_x64.WordArray;
 11994  	    var C_algo = C.algo;
 11995  
 11996  	    function X64Word_create() {
 11997  	        return X64Word.create.apply(X64Word, arguments);
 11998  	    }
 11999  
 12000  	    // Constants
 12001  	    var K = [
 12002  	        X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
 12003  	        X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
 12004  	        X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
 12005  	        X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
 12006  	        X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
 12007  	        X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
 12008  	        X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
 12009  	        X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
 12010  	        X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
 12011  	        X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
 12012  	        X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
 12013  	        X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
 12014  	        X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
 12015  	        X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
 12016  	        X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
 12017  	        X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
 12018  	        X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
 12019  	        X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
 12020  	        X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
 12021  	        X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
 12022  	        X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
 12023  	        X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
 12024  	        X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
 12025  	        X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
 12026  	        X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
 12027  	        X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
 12028  	        X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
 12029  	        X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
 12030  	        X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
 12031  	        X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
 12032  	        X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
 12033  	        X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
 12034  	        X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
 12035  	        X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
 12036  	        X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
 12037  	        X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
 12038  	        X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
 12039  	        X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
 12040  	        X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
 12041  	        X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
 12042  	    ];
 12043  
 12044  	    // Reusable objects
 12045  	    var W = [];
 12046  	    (function () {
 12047  	        for (var i = 0; i < 80; i++) {
 12048  	            W[i] = X64Word_create();
 12049  	        }
 12050  	    }());
 12051  
 12052  	    /**
 12053  	     * SHA-512 hash algorithm.
 12054  	     */
 12055  	    var SHA512 = C_algo.SHA512 = Hasher.extend({
 12056  	        _doReset: function () {
 12057  	            this._hash = new X64WordArray.init([
 12058  	                new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
 12059  	                new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
 12060  	                new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
 12061  	                new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
 12062  	            ]);
 12063  	        },
 12064  
 12065  	        _doProcessBlock: function (M, offset) {
 12066  	            // Shortcuts
 12067  	            var H = this._hash.words;
 12068  
 12069  	            var H0 = H[0];
 12070  	            var H1 = H[1];
 12071  	            var H2 = H[2];
 12072  	            var H3 = H[3];
 12073  	            var H4 = H[4];
 12074  	            var H5 = H[5];
 12075  	            var H6 = H[6];
 12076  	            var H7 = H[7];
 12077  
 12078  	            var H0h = H0.high;
 12079  	            var H0l = H0.low;
 12080  	            var H1h = H1.high;
 12081  	            var H1l = H1.low;
 12082  	            var H2h = H2.high;
 12083  	            var H2l = H2.low;
 12084  	            var H3h = H3.high;
 12085  	            var H3l = H3.low;
 12086  	            var H4h = H4.high;
 12087  	            var H4l = H4.low;
 12088  	            var H5h = H5.high;
 12089  	            var H5l = H5.low;
 12090  	            var H6h = H6.high;
 12091  	            var H6l = H6.low;
 12092  	            var H7h = H7.high;
 12093  	            var H7l = H7.low;
 12094  
 12095  	            // Working variables
 12096  	            var ah = H0h;
 12097  	            var al = H0l;
 12098  	            var bh = H1h;
 12099  	            var bl = H1l;
 12100  	            var ch = H2h;
 12101  	            var cl = H2l;
 12102  	            var dh = H3h;
 12103  	            var dl = H3l;
 12104  	            var eh = H4h;
 12105  	            var el = H4l;
 12106  	            var fh = H5h;
 12107  	            var fl = H5l;
 12108  	            var gh = H6h;
 12109  	            var gl = H6l;
 12110  	            var hh = H7h;
 12111  	            var hl = H7l;
 12112  
 12113  	            // Rounds
 12114  	            for (var i = 0; i < 80; i++) {
 12115  	                // Shortcut
 12116  	                var Wi = W[i];
 12117  
 12118  	                // Extend message
 12119  	                if (i < 16) {
 12120  	                    var Wih = Wi.high = M[offset + i * 2]     | 0;
 12121  	                    var Wil = Wi.low  = M[offset + i * 2 + 1] | 0;
 12122  	                } else {
 12123  	                    // Gamma0
 12124  	                    var gamma0x  = W[i - 15];
 12125  	                    var gamma0xh = gamma0x.high;
 12126  	                    var gamma0xl = gamma0x.low;
 12127  	                    var gamma0h  = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
 12128  	                    var gamma0l  = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
 12129  
 12130  	                    // Gamma1
 12131  	                    var gamma1x  = W[i - 2];
 12132  	                    var gamma1xh = gamma1x.high;
 12133  	                    var gamma1xl = gamma1x.low;
 12134  	                    var gamma1h  = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
 12135  	                    var gamma1l  = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
 12136  
 12137  	                    // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
 12138  	                    var Wi7  = W[i - 7];
 12139  	                    var Wi7h = Wi7.high;
 12140  	                    var Wi7l = Wi7.low;
 12141  
 12142  	                    var Wi16  = W[i - 16];
 12143  	                    var Wi16h = Wi16.high;
 12144  	                    var Wi16l = Wi16.low;
 12145  
 12146  	                    var Wil = gamma0l + Wi7l;
 12147  	                    var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
 12148  	                    var Wil = Wil + gamma1l;
 12149  	                    var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
 12150  	                    var Wil = Wil + Wi16l;
 12151  	                    var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
 12152  
 12153  	                    Wi.high = Wih;
 12154  	                    Wi.low  = Wil;
 12155  	                }
 12156  
 12157  	                var chh  = (eh & fh) ^ (~eh & gh);
 12158  	                var chl  = (el & fl) ^ (~el & gl);
 12159  	                var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
 12160  	                var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
 12161  
 12162  	                var sigma0h = ((ah >>> 28) | (al << 4))  ^ ((ah << 30)  | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
 12163  	                var sigma0l = ((al >>> 28) | (ah << 4))  ^ ((al << 30)  | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
 12164  	                var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
 12165  	                var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
 12166  
 12167  	                // t1 = h + sigma1 + ch + K[i] + W[i]
 12168  	                var Ki  = K[i];
 12169  	                var Kih = Ki.high;
 12170  	                var Kil = Ki.low;
 12171  
 12172  	                var t1l = hl + sigma1l;
 12173  	                var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
 12174  	                var t1l = t1l + chl;
 12175  	                var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
 12176  	                var t1l = t1l + Kil;
 12177  	                var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
 12178  	                var t1l = t1l + Wil;
 12179  	                var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
 12180  
 12181  	                // t2 = sigma0 + maj
 12182  	                var t2l = sigma0l + majl;
 12183  	                var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
 12184  
 12185  	                // Update working variables
 12186  	                hh = gh;
 12187  	                hl = gl;
 12188  	                gh = fh;
 12189  	                gl = fl;
 12190  	                fh = eh;
 12191  	                fl = el;
 12192  	                el = (dl + t1l) | 0;
 12193  	                eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
 12194  	                dh = ch;
 12195  	                dl = cl;
 12196  	                ch = bh;
 12197  	                cl = bl;
 12198  	                bh = ah;
 12199  	                bl = al;
 12200  	                al = (t1l + t2l) | 0;
 12201  	                ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
 12202  	            }
 12203  
 12204  	            // Intermediate hash value
 12205  	            H0l = H0.low  = (H0l + al);
 12206  	            H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
 12207  	            H1l = H1.low  = (H1l + bl);
 12208  	            H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
 12209  	            H2l = H2.low  = (H2l + cl);
 12210  	            H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
 12211  	            H3l = H3.low  = (H3l + dl);
 12212  	            H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
 12213  	            H4l = H4.low  = (H4l + el);
 12214  	            H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
 12215  	            H5l = H5.low  = (H5l + fl);
 12216  	            H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
 12217  	            H6l = H6.low  = (H6l + gl);
 12218  	            H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
 12219  	            H7l = H7.low  = (H7l + hl);
 12220  	            H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
 12221  	        },
 12222  
 12223  	        _doFinalize: function () {
 12224  	            // Shortcuts
 12225  	            var data = this._data;
 12226  	            var dataWords = data.words;
 12227  
 12228  	            var nBitsTotal = this._nDataBytes * 8;
 12229  	            var nBitsLeft = data.sigBytes * 8;
 12230  
 12231  	            // Add padding
 12232  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 12233  	            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
 12234  	            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
 12235  	            data.sigBytes = dataWords.length * 4;
 12236  
 12237  	            // Hash final blocks
 12238  	            this._process();
 12239  
 12240  	            // Convert hash to 32-bit word array before returning
 12241  	            var hash = this._hash.toX32();
 12242  
 12243  	            // Return final computed hash
 12244  	            return hash;
 12245  	        },
 12246  
 12247  	        clone: function () {
 12248  	            var clone = Hasher.clone.call(this);
 12249  	            clone._hash = this._hash.clone();
 12250  
 12251  	            return clone;
 12252  	        },
 12253  
 12254  	        blockSize: 1024/32
 12255  	    });
 12256  
 12257  	    /**
 12258  	     * Shortcut function to the hasher's object interface.
 12259  	     *
 12260  	     * @param {WordArray|string} message The message to hash.
 12261  	     *
 12262  	     * @return {WordArray} The hash.
 12263  	     *
 12264  	     * @static
 12265  	     *
 12266  	     * @example
 12267  	     *
 12268  	     *     var hash = CryptoJS.SHA512('message');
 12269  	     *     var hash = CryptoJS.SHA512(wordArray);
 12270  	     */
 12271  	    C.SHA512 = Hasher._createHelper(SHA512);
 12272  
 12273  	    /**
 12274  	     * Shortcut function to the HMAC's object interface.
 12275  	     *
 12276  	     * @param {WordArray|string} message The message to hash.
 12277  	     * @param {WordArray|string} key The secret key.
 12278  	     *
 12279  	     * @return {WordArray} The HMAC.
 12280  	     *
 12281  	     * @static
 12282  	     *
 12283  	     * @example
 12284  	     *
 12285  	     *     var hmac = CryptoJS.HmacSHA512(message, key);
 12286  	     */
 12287  	    C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
 12288  	}());
 12289  
 12290  
 12291  	return CryptoJS.SHA512;
 12292  
 12293  }));
 12294  },{"./core":53,"./x64-core":84}],83:[function(require,module,exports){
 12295  ;(function (root, factory, undef) {
 12296  	if (typeof exports === "object") {
 12297  		// CommonJS
 12298  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 12299  	}
 12300  	else if (typeof define === "function" && define.amd) {
 12301  		// AMD
 12302  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 12303  	}
 12304  	else {
 12305  		// Global (browser)
 12306  		factory(root.CryptoJS);
 12307  	}
 12308  }(this, function (CryptoJS) {
 12309  
 12310  	(function () {
 12311  	    // Shortcuts
 12312  	    var C = CryptoJS;
 12313  	    var C_lib = C.lib;
 12314  	    var WordArray = C_lib.WordArray;
 12315  	    var BlockCipher = C_lib.BlockCipher;
 12316  	    var C_algo = C.algo;
 12317  
 12318  	    // Permuted Choice 1 constants
 12319  	    var PC1 = [
 12320  	        57, 49, 41, 33, 25, 17, 9,  1,
 12321  	        58, 50, 42, 34, 26, 18, 10, 2,
 12322  	        59, 51, 43, 35, 27, 19, 11, 3,
 12323  	        60, 52, 44, 36, 63, 55, 47, 39,
 12324  	        31, 23, 15, 7,  62, 54, 46, 38,
 12325  	        30, 22, 14, 6,  61, 53, 45, 37,
 12326  	        29, 21, 13, 5,  28, 20, 12, 4
 12327  	    ];
 12328  
 12329  	    // Permuted Choice 2 constants
 12330  	    var PC2 = [
 12331  	        14, 17, 11, 24, 1,  5,
 12332  	        3,  28, 15, 6,  21, 10,
 12333  	        23, 19, 12, 4,  26, 8,
 12334  	        16, 7,  27, 20, 13, 2,
 12335  	        41, 52, 31, 37, 47, 55,
 12336  	        30, 40, 51, 45, 33, 48,
 12337  	        44, 49, 39, 56, 34, 53,
 12338  	        46, 42, 50, 36, 29, 32
 12339  	    ];
 12340  
 12341  	    // Cumulative bit shift constants
 12342  	    var BIT_SHIFTS = [1,  2,  4,  6,  8,  10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
 12343  
 12344  	    // SBOXes and round permutation constants
 12345  	    var SBOX_P = [
 12346  	        {
 12347  	            0x0: 0x808200,
 12348  	            0x10000000: 0x8000,
 12349  	            0x20000000: 0x808002,
 12350  	            0x30000000: 0x2,
 12351  	            0x40000000: 0x200,
 12352  	            0x50000000: 0x808202,
 12353  	            0x60000000: 0x800202,
 12354  	            0x70000000: 0x800000,
 12355  	            0x80000000: 0x202,
 12356  	            0x90000000: 0x800200,
 12357  	            0xa0000000: 0x8200,
 12358  	            0xb0000000: 0x808000,
 12359  	            0xc0000000: 0x8002,
 12360  	            0xd0000000: 0x800002,
 12361  	            0xe0000000: 0x0,
 12362  	            0xf0000000: 0x8202,
 12363  	            0x8000000: 0x0,
 12364  	            0x18000000: 0x808202,
 12365  	            0x28000000: 0x8202,
 12366  	            0x38000000: 0x8000,
 12367  	            0x48000000: 0x808200,
 12368  	            0x58000000: 0x200,
 12369  	            0x68000000: 0x808002,
 12370  	            0x78000000: 0x2,
 12371  	            0x88000000: 0x800200,
 12372  	            0x98000000: 0x8200,
 12373  	            0xa8000000: 0x808000,
 12374  	            0xb8000000: 0x800202,
 12375  	            0xc8000000: 0x800002,
 12376  	            0xd8000000: 0x8002,
 12377  	            0xe8000000: 0x202,
 12378  	            0xf8000000: 0x800000,
 12379  	            0x1: 0x8000,
 12380  	            0x10000001: 0x2,
 12381  	            0x20000001: 0x808200,
 12382  	            0x30000001: 0x800000,
 12383  	            0x40000001: 0x808002,
 12384  	            0x50000001: 0x8200,
 12385  	            0x60000001: 0x200,
 12386  	            0x70000001: 0x800202,
 12387  	            0x80000001: 0x808202,
 12388  	            0x90000001: 0x808000,
 12389  	            0xa0000001: 0x800002,
 12390  	            0xb0000001: 0x8202,
 12391  	            0xc0000001: 0x202,
 12392  	            0xd0000001: 0x800200,
 12393  	            0xe0000001: 0x8002,
 12394  	            0xf0000001: 0x0,
 12395  	            0x8000001: 0x808202,
 12396  	            0x18000001: 0x808000,
 12397  	            0x28000001: 0x800000,
 12398  	            0x38000001: 0x200,
 12399  	            0x48000001: 0x8000,
 12400  	            0x58000001: 0x800002,
 12401  	            0x68000001: 0x2,
 12402  	            0x78000001: 0x8202,
 12403  	            0x88000001: 0x8002,
 12404  	            0x98000001: 0x800202,
 12405  	            0xa8000001: 0x202,
 12406  	            0xb8000001: 0x808200,
 12407  	            0xc8000001: 0x800200,
 12408  	            0xd8000001: 0x0,
 12409  	            0xe8000001: 0x8200,
 12410  	            0xf8000001: 0x808002
 12411  	        },
 12412  	        {
 12413  	            0x0: 0x40084010,
 12414  	            0x1000000: 0x4000,
 12415  	            0x2000000: 0x80000,
 12416  	            0x3000000: 0x40080010,
 12417  	            0x4000000: 0x40000010,
 12418  	            0x5000000: 0x40084000,
 12419  	            0x6000000: 0x40004000,
 12420  	            0x7000000: 0x10,
 12421  	            0x8000000: 0x84000,
 12422  	            0x9000000: 0x40004010,
 12423  	            0xa000000: 0x40000000,
 12424  	            0xb000000: 0x84010,
 12425  	            0xc000000: 0x80010,
 12426  	            0xd000000: 0x0,
 12427  	            0xe000000: 0x4010,
 12428  	            0xf000000: 0x40080000,
 12429  	            0x800000: 0x40004000,
 12430  	            0x1800000: 0x84010,
 12431  	            0x2800000: 0x10,
 12432  	            0x3800000: 0x40004010,
 12433  	            0x4800000: 0x40084010,
 12434  	            0x5800000: 0x40000000,
 12435  	            0x6800000: 0x80000,
 12436  	            0x7800000: 0x40080010,
 12437  	            0x8800000: 0x80010,
 12438  	            0x9800000: 0x0,
 12439  	            0xa800000: 0x4000,
 12440  	            0xb800000: 0x40080000,
 12441  	            0xc800000: 0x40000010,
 12442  	            0xd800000: 0x84000,
 12443  	            0xe800000: 0x40084000,
 12444  	            0xf800000: 0x4010,
 12445  	            0x10000000: 0x0,
 12446  	            0x11000000: 0x40080010,
 12447  	            0x12000000: 0x40004010,
 12448  	            0x13000000: 0x40084000,
 12449  	            0x14000000: 0x40080000,
 12450  	            0x15000000: 0x10,
 12451  	            0x16000000: 0x84010,
 12452  	            0x17000000: 0x4000,
 12453  	            0x18000000: 0x4010,
 12454  	            0x19000000: 0x80000,
 12455  	            0x1a000000: 0x80010,
 12456  	            0x1b000000: 0x40000010,
 12457  	            0x1c000000: 0x84000,
 12458  	            0x1d000000: 0x40004000,
 12459  	            0x1e000000: 0x40000000,
 12460  	            0x1f000000: 0x40084010,
 12461  	            0x10800000: 0x84010,
 12462  	            0x11800000: 0x80000,
 12463  	            0x12800000: 0x40080000,
 12464  	            0x13800000: 0x4000,
 12465  	            0x14800000: 0x40004000,
 12466  	            0x15800000: 0x40084010,
 12467  	            0x16800000: 0x10,
 12468  	            0x17800000: 0x40000000,
 12469  	            0x18800000: 0x40084000,
 12470  	            0x19800000: 0x40000010,
 12471  	            0x1a800000: 0x40004010,
 12472  	            0x1b800000: 0x80010,
 12473  	            0x1c800000: 0x0,
 12474  	            0x1d800000: 0x4010,
 12475  	            0x1e800000: 0x40080010,
 12476  	            0x1f800000: 0x84000
 12477  	        },
 12478  	        {
 12479  	            0x0: 0x104,
 12480  	            0x100000: 0x0,
 12481  	            0x200000: 0x4000100,
 12482  	            0x300000: 0x10104,
 12483  	            0x400000: 0x10004,
 12484  	            0x500000: 0x4000004,
 12485  	            0x600000: 0x4010104,
 12486  	            0x700000: 0x4010000,
 12487  	            0x800000: 0x4000000,
 12488  	            0x900000: 0x4010100,
 12489  	            0xa00000: 0x10100,
 12490  	            0xb00000: 0x4010004,
 12491  	            0xc00000: 0x4000104,
 12492  	            0xd00000: 0x10000,
 12493  	            0xe00000: 0x4,
 12494  	            0xf00000: 0x100,
 12495  	            0x80000: 0x4010100,
 12496  	            0x180000: 0x4010004,
 12497  	            0x280000: 0x0,
 12498  	            0x380000: 0x4000100,
 12499  	            0x480000: 0x4000004,
 12500  	            0x580000: 0x10000,
 12501  	            0x680000: 0x10004,
 12502  	            0x780000: 0x104,
 12503  	            0x880000: 0x4,
 12504  	            0x980000: 0x100,
 12505  	            0xa80000: 0x4010000,
 12506  	            0xb80000: 0x10104,
 12507  	            0xc80000: 0x10100,
 12508  	            0xd80000: 0x4000104,
 12509  	            0xe80000: 0x4010104,
 12510  	            0xf80000: 0x4000000,
 12511  	            0x1000000: 0x4010100,
 12512  	            0x1100000: 0x10004,
 12513  	            0x1200000: 0x10000,
 12514  	            0x1300000: 0x4000100,
 12515  	            0x1400000: 0x100,
 12516  	            0x1500000: 0x4010104,
 12517  	            0x1600000: 0x4000004,
 12518  	            0x1700000: 0x0,
 12519  	            0x1800000: 0x4000104,
 12520  	            0x1900000: 0x4000000,
 12521  	            0x1a00000: 0x4,
 12522  	            0x1b00000: 0x10100,
 12523  	            0x1c00000: 0x4010000,
 12524  	            0x1d00000: 0x104,
 12525  	            0x1e00000: 0x10104,
 12526  	            0x1f00000: 0x4010004,
 12527  	            0x1080000: 0x4000000,
 12528  	            0x1180000: 0x104,
 12529  	            0x1280000: 0x4010100,
 12530  	            0x1380000: 0x0,
 12531  	            0x1480000: 0x10004,
 12532  	            0x1580000: 0x4000100,
 12533  	            0x1680000: 0x100,
 12534  	            0x1780000: 0x4010004,
 12535  	            0x1880000: 0x10000,
 12536  	            0x1980000: 0x4010104,
 12537  	            0x1a80000: 0x10104,
 12538  	            0x1b80000: 0x4000004,
 12539  	            0x1c80000: 0x4000104,
 12540  	            0x1d80000: 0x4010000,
 12541  	            0x1e80000: 0x4,
 12542  	            0x1f80000: 0x10100
 12543  	        },
 12544  	        {
 12545  	            0x0: 0x80401000,
 12546  	            0x10000: 0x80001040,
 12547  	            0x20000: 0x401040,
 12548  	            0x30000: 0x80400000,
 12549  	            0x40000: 0x0,
 12550  	            0x50000: 0x401000,
 12551  	            0x60000: 0x80000040,
 12552  	            0x70000: 0x400040,
 12553  	            0x80000: 0x80000000,
 12554  	            0x90000: 0x400000,
 12555  	            0xa0000: 0x40,
 12556  	            0xb0000: 0x80001000,
 12557  	            0xc0000: 0x80400040,
 12558  	            0xd0000: 0x1040,
 12559  	            0xe0000: 0x1000,
 12560  	            0xf0000: 0x80401040,
 12561  	            0x8000: 0x80001040,
 12562  	            0x18000: 0x40,
 12563  	            0x28000: 0x80400040,
 12564  	            0x38000: 0x80001000,
 12565  	            0x48000: 0x401000,
 12566  	            0x58000: 0x80401040,
 12567  	            0x68000: 0x0,
 12568  	            0x78000: 0x80400000,
 12569  	            0x88000: 0x1000,
 12570  	            0x98000: 0x80401000,
 12571  	            0xa8000: 0x400000,
 12572  	            0xb8000: 0x1040,
 12573  	            0xc8000: 0x80000000,
 12574  	            0xd8000: 0x400040,
 12575  	            0xe8000: 0x401040,
 12576  	            0xf8000: 0x80000040,
 12577  	            0x100000: 0x400040,
 12578  	            0x110000: 0x401000,
 12579  	            0x120000: 0x80000040,
 12580  	            0x130000: 0x0,
 12581  	            0x140000: 0x1040,
 12582  	            0x150000: 0x80400040,
 12583  	            0x160000: 0x80401000,
 12584  	            0x170000: 0x80001040,
 12585  	            0x180000: 0x80401040,
 12586  	            0x190000: 0x80000000,
 12587  	            0x1a0000: 0x80400000,
 12588  	            0x1b0000: 0x401040,
 12589  	            0x1c0000: 0x80001000,
 12590  	            0x1d0000: 0x400000,
 12591  	            0x1e0000: 0x40,
 12592  	            0x1f0000: 0x1000,
 12593  	            0x108000: 0x80400000,
 12594  	            0x118000: 0x80401040,
 12595  	            0x128000: 0x0,
 12596  	            0x138000: 0x401000,
 12597  	            0x148000: 0x400040,
 12598  	            0x158000: 0x80000000,
 12599  	            0x168000: 0x80001040,
 12600  	            0x178000: 0x40,
 12601  	            0x188000: 0x80000040,
 12602  	            0x198000: 0x1000,
 12603  	            0x1a8000: 0x80001000,
 12604  	            0x1b8000: 0x80400040,
 12605  	            0x1c8000: 0x1040,
 12606  	            0x1d8000: 0x80401000,
 12607  	            0x1e8000: 0x400000,
 12608  	            0x1f8000: 0x401040
 12609  	        },
 12610  	        {
 12611  	            0x0: 0x80,
 12612  	            0x1000: 0x1040000,
 12613  	            0x2000: 0x40000,
 12614  	            0x3000: 0x20000000,
 12615  	            0x4000: 0x20040080,
 12616  	            0x5000: 0x1000080,
 12617  	            0x6000: 0x21000080,
 12618  	            0x7000: 0x40080,
 12619  	            0x8000: 0x1000000,
 12620  	            0x9000: 0x20040000,
 12621  	            0xa000: 0x20000080,
 12622  	            0xb000: 0x21040080,
 12623  	            0xc000: 0x21040000,
 12624  	            0xd000: 0x0,
 12625  	            0xe000: 0x1040080,
 12626  	            0xf000: 0x21000000,
 12627  	            0x800: 0x1040080,
 12628  	            0x1800: 0x21000080,
 12629  	            0x2800: 0x80,
 12630  	            0x3800: 0x1040000,
 12631  	            0x4800: 0x40000,
 12632  	            0x5800: 0x20040080,
 12633  	            0x6800: 0x21040000,
 12634  	            0x7800: 0x20000000,
 12635  	            0x8800: 0x20040000,
 12636  	            0x9800: 0x0,
 12637  	            0xa800: 0x21040080,
 12638  	            0xb800: 0x1000080,
 12639  	            0xc800: 0x20000080,
 12640  	            0xd800: 0x21000000,
 12641  	            0xe800: 0x1000000,
 12642  	            0xf800: 0x40080,
 12643  	            0x10000: 0x40000,
 12644  	            0x11000: 0x80,
 12645  	            0x12000: 0x20000000,
 12646  	            0x13000: 0x21000080,
 12647  	            0x14000: 0x1000080,
 12648  	            0x15000: 0x21040000,
 12649  	            0x16000: 0x20040080,
 12650  	            0x17000: 0x1000000,
 12651  	            0x18000: 0x21040080,
 12652  	            0x19000: 0x21000000,
 12653  	            0x1a000: 0x1040000,
 12654  	            0x1b000: 0x20040000,
 12655  	            0x1c000: 0x40080,
 12656  	            0x1d000: 0x20000080,
 12657  	            0x1e000: 0x0,
 12658  	            0x1f000: 0x1040080,
 12659  	            0x10800: 0x21000080,
 12660  	            0x11800: 0x1000000,
 12661  	            0x12800: 0x1040000,
 12662  	            0x13800: 0x20040080,
 12663  	            0x14800: 0x20000000,
 12664  	            0x15800: 0x1040080,
 12665  	            0x16800: 0x80,
 12666  	            0x17800: 0x21040000,
 12667  	            0x18800: 0x40080,
 12668  	            0x19800: 0x21040080,
 12669  	            0x1a800: 0x0,
 12670  	            0x1b800: 0x21000000,
 12671  	            0x1c800: 0x1000080,
 12672  	            0x1d800: 0x40000,
 12673  	            0x1e800: 0x20040000,
 12674  	            0x1f800: 0x20000080
 12675  	        },
 12676  	        {
 12677  	            0x0: 0x10000008,
 12678  	            0x100: 0x2000,
 12679  	            0x200: 0x10200000,
 12680  	            0x300: 0x10202008,
 12681  	            0x400: 0x10002000,
 12682  	            0x500: 0x200000,
 12683  	            0x600: 0x200008,
 12684  	            0x700: 0x10000000,
 12685  	            0x800: 0x0,
 12686  	            0x900: 0x10002008,
 12687  	            0xa00: 0x202000,
 12688  	            0xb00: 0x8,
 12689  	            0xc00: 0x10200008,
 12690  	            0xd00: 0x202008,
 12691  	            0xe00: 0x2008,
 12692  	            0xf00: 0x10202000,
 12693  	            0x80: 0x10200000,
 12694  	            0x180: 0x10202008,
 12695  	            0x280: 0x8,
 12696  	            0x380: 0x200000,
 12697  	            0x480: 0x202008,
 12698  	            0x580: 0x10000008,
 12699  	            0x680: 0x10002000,
 12700  	            0x780: 0x2008,
 12701  	            0x880: 0x200008,
 12702  	            0x980: 0x2000,
 12703  	            0xa80: 0x10002008,
 12704  	            0xb80: 0x10200008,
 12705  	            0xc80: 0x0,
 12706  	            0xd80: 0x10202000,
 12707  	            0xe80: 0x202000,
 12708  	            0xf80: 0x10000000,
 12709  	            0x1000: 0x10002000,
 12710  	            0x1100: 0x10200008,
 12711  	            0x1200: 0x10202008,
 12712  	            0x1300: 0x2008,
 12713  	            0x1400: 0x200000,
 12714  	            0x1500: 0x10000000,
 12715  	            0x1600: 0x10000008,
 12716  	            0x1700: 0x202000,
 12717  	            0x1800: 0x202008,
 12718  	            0x1900: 0x0,
 12719  	            0x1a00: 0x8,
 12720  	            0x1b00: 0x10200000,
 12721  	            0x1c00: 0x2000,
 12722  	            0x1d00: 0x10002008,
 12723  	            0x1e00: 0x10202000,
 12724  	            0x1f00: 0x200008,
 12725  	            0x1080: 0x8,
 12726  	            0x1180: 0x202000,
 12727  	            0x1280: 0x200000,
 12728  	            0x1380: 0x10000008,
 12729  	            0x1480: 0x10002000,
 12730  	            0x1580: 0x2008,
 12731  	            0x1680: 0x10202008,
 12732  	            0x1780: 0x10200000,
 12733  	            0x1880: 0x10202000,
 12734  	            0x1980: 0x10200008,
 12735  	            0x1a80: 0x2000,
 12736  	            0x1b80: 0x202008,
 12737  	            0x1c80: 0x200008,
 12738  	            0x1d80: 0x0,
 12739  	            0x1e80: 0x10000000,
 12740  	            0x1f80: 0x10002008
 12741  	        },
 12742  	        {
 12743  	            0x0: 0x100000,
 12744  	            0x10: 0x2000401,
 12745  	            0x20: 0x400,
 12746  	            0x30: 0x100401,
 12747  	            0x40: 0x2100401,
 12748  	            0x50: 0x0,
 12749  	            0x60: 0x1,
 12750  	            0x70: 0x2100001,
 12751  	            0x80: 0x2000400,
 12752  	            0x90: 0x100001,
 12753  	            0xa0: 0x2000001,
 12754  	            0xb0: 0x2100400,
 12755  	            0xc0: 0x2100000,
 12756  	            0xd0: 0x401,
 12757  	            0xe0: 0x100400,
 12758  	            0xf0: 0x2000000,
 12759  	            0x8: 0x2100001,
 12760  	            0x18: 0x0,
 12761  	            0x28: 0x2000401,
 12762  	            0x38: 0x2100400,
 12763  	            0x48: 0x100000,
 12764  	            0x58: 0x2000001,
 12765  	            0x68: 0x2000000,
 12766  	            0x78: 0x401,
 12767  	            0x88: 0x100401,
 12768  	            0x98: 0x2000400,
 12769  	            0xa8: 0x2100000,
 12770  	            0xb8: 0x100001,
 12771  	            0xc8: 0x400,
 12772  	            0xd8: 0x2100401,
 12773  	            0xe8: 0x1,
 12774  	            0xf8: 0x100400,
 12775  	            0x100: 0x2000000,
 12776  	            0x110: 0x100000,
 12777  	            0x120: 0x2000401,
 12778  	            0x130: 0x2100001,
 12779  	            0x140: 0x100001,
 12780  	            0x150: 0x2000400,
 12781  	            0x160: 0x2100400,
 12782  	            0x170: 0x100401,
 12783  	            0x180: 0x401,
 12784  	            0x190: 0x2100401,
 12785  	            0x1a0: 0x100400,
 12786  	            0x1b0: 0x1,
 12787  	            0x1c0: 0x0,
 12788  	            0x1d0: 0x2100000,
 12789  	            0x1e0: 0x2000001,
 12790  	            0x1f0: 0x400,
 12791  	            0x108: 0x100400,
 12792  	            0x118: 0x2000401,
 12793  	            0x128: 0x2100001,
 12794  	            0x138: 0x1,
 12795  	            0x148: 0x2000000,
 12796  	            0x158: 0x100000,
 12797  	            0x168: 0x401,
 12798  	            0x178: 0x2100400,
 12799  	            0x188: 0x2000001,
 12800  	            0x198: 0x2100000,
 12801  	            0x1a8: 0x0,
 12802  	            0x1b8: 0x2100401,
 12803  	            0x1c8: 0x100401,
 12804  	            0x1d8: 0x400,
 12805  	            0x1e8: 0x2000400,
 12806  	            0x1f8: 0x100001
 12807  	        },
 12808  	        {
 12809  	            0x0: 0x8000820,
 12810  	            0x1: 0x20000,
 12811  	            0x2: 0x8000000,
 12812  	            0x3: 0x20,
 12813  	            0x4: 0x20020,
 12814  	            0x5: 0x8020820,
 12815  	            0x6: 0x8020800,
 12816  	            0x7: 0x800,
 12817  	            0x8: 0x8020000,
 12818  	            0x9: 0x8000800,
 12819  	            0xa: 0x20800,
 12820  	            0xb: 0x8020020,
 12821  	            0xc: 0x820,
 12822  	            0xd: 0x0,
 12823  	            0xe: 0x8000020,
 12824  	            0xf: 0x20820,
 12825  	            0x80000000: 0x800,
 12826  	            0x80000001: 0x8020820,
 12827  	            0x80000002: 0x8000820,
 12828  	            0x80000003: 0x8000000,
 12829  	            0x80000004: 0x8020000,
 12830  	            0x80000005: 0x20800,
 12831  	            0x80000006: 0x20820,
 12832  	            0x80000007: 0x20,
 12833  	            0x80000008: 0x8000020,
 12834  	            0x80000009: 0x820,
 12835  	            0x8000000a: 0x20020,
 12836  	            0x8000000b: 0x8020800,
 12837  	            0x8000000c: 0x0,
 12838  	            0x8000000d: 0x8020020,
 12839  	            0x8000000e: 0x8000800,
 12840  	            0x8000000f: 0x20000,
 12841  	            0x10: 0x20820,
 12842  	            0x11: 0x8020800,
 12843  	            0x12: 0x20,
 12844  	            0x13: 0x800,
 12845  	            0x14: 0x8000800,
 12846  	            0x15: 0x8000020,
 12847  	            0x16: 0x8020020,
 12848  	            0x17: 0x20000,
 12849  	            0x18: 0x0,
 12850  	            0x19: 0x20020,
 12851  	            0x1a: 0x8020000,
 12852  	            0x1b: 0x8000820,
 12853  	            0x1c: 0x8020820,
 12854  	            0x1d: 0x20800,
 12855  	            0x1e: 0x820,
 12856  	            0x1f: 0x8000000,
 12857  	            0x80000010: 0x20000,
 12858  	            0x80000011: 0x800,
 12859  	            0x80000012: 0x8020020,
 12860  	            0x80000013: 0x20820,
 12861  	            0x80000014: 0x20,
 12862  	            0x80000015: 0x8020000,
 12863  	            0x80000016: 0x8000000,
 12864  	            0x80000017: 0x8000820,
 12865  	            0x80000018: 0x8020820,
 12866  	            0x80000019: 0x8000020,
 12867  	            0x8000001a: 0x8000800,
 12868  	            0x8000001b: 0x0,
 12869  	            0x8000001c: 0x20800,
 12870  	            0x8000001d: 0x820,
 12871  	            0x8000001e: 0x20020,
 12872  	            0x8000001f: 0x8020800
 12873  	        }
 12874  	    ];
 12875  
 12876  	    // Masks that select the SBOX input
 12877  	    var SBOX_MASK = [
 12878  	        0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
 12879  	        0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
 12880  	    ];
 12881  
 12882  	    /**
 12883  	     * DES block cipher algorithm.
 12884  	     */
 12885  	    var DES = C_algo.DES = BlockCipher.extend({
 12886  	        _doReset: function () {
 12887  	            // Shortcuts
 12888  	            var key = this._key;
 12889  	            var keyWords = key.words;
 12890  
 12891  	            // Select 56 bits according to PC1
 12892  	            var keyBits = [];
 12893  	            for (var i = 0; i < 56; i++) {
 12894  	                var keyBitPos = PC1[i] - 1;
 12895  	                keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
 12896  	            }
 12897  
 12898  	            // Assemble 16 subkeys
 12899  	            var subKeys = this._subKeys = [];
 12900  	            for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
 12901  	                // Create subkey
 12902  	                var subKey = subKeys[nSubKey] = [];
 12903  
 12904  	                // Shortcut
 12905  	                var bitShift = BIT_SHIFTS[nSubKey];
 12906  
 12907  	                // Select 48 bits according to PC2
 12908  	                for (var i = 0; i < 24; i++) {
 12909  	                    // Select from the left 28 key bits
 12910  	                    subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
 12911  
 12912  	                    // Select from the right 28 key bits
 12913  	                    subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
 12914  	                }
 12915  
 12916  	                // Since each subkey is applied to an expanded 32-bit input,
 12917  	                // the subkey can be broken into 8 values scaled to 32-bits,
 12918  	                // which allows the key to be used without expansion
 12919  	                subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
 12920  	                for (var i = 1; i < 7; i++) {
 12921  	                    subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
 12922  	                }
 12923  	                subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
 12924  	            }
 12925  
 12926  	            // Compute inverse subkeys
 12927  	            var invSubKeys = this._invSubKeys = [];
 12928  	            for (var i = 0; i < 16; i++) {
 12929  	                invSubKeys[i] = subKeys[15 - i];
 12930  	            }
 12931  	        },
 12932  
 12933  	        encryptBlock: function (M, offset) {
 12934  	            this._doCryptBlock(M, offset, this._subKeys);
 12935  	        },
 12936  
 12937  	        decryptBlock: function (M, offset) {
 12938  	            this._doCryptBlock(M, offset, this._invSubKeys);
 12939  	        },
 12940  
 12941  	        _doCryptBlock: function (M, offset, subKeys) {
 12942  	            // Get input
 12943  	            this._lBlock = M[offset];
 12944  	            this._rBlock = M[offset + 1];
 12945  
 12946  	            // Initial permutation
 12947  	            exchangeLR.call(this, 4,  0x0f0f0f0f);
 12948  	            exchangeLR.call(this, 16, 0x0000ffff);
 12949  	            exchangeRL.call(this, 2,  0x33333333);
 12950  	            exchangeRL.call(this, 8,  0x00ff00ff);
 12951  	            exchangeLR.call(this, 1,  0x55555555);
 12952  
 12953  	            // Rounds
 12954  	            for (var round = 0; round < 16; round++) {
 12955  	                // Shortcuts
 12956  	                var subKey = subKeys[round];
 12957  	                var lBlock = this._lBlock;
 12958  	                var rBlock = this._rBlock;
 12959  
 12960  	                // Feistel function
 12961  	                var f = 0;
 12962  	                for (var i = 0; i < 8; i++) {
 12963  	                    f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
 12964  	                }
 12965  	                this._lBlock = rBlock;
 12966  	                this._rBlock = lBlock ^ f;
 12967  	            }
 12968  
 12969  	            // Undo swap from last round
 12970  	            var t = this._lBlock;
 12971  	            this._lBlock = this._rBlock;
 12972  	            this._rBlock = t;
 12973  
 12974  	            // Final permutation
 12975  	            exchangeLR.call(this, 1,  0x55555555);
 12976  	            exchangeRL.call(this, 8,  0x00ff00ff);
 12977  	            exchangeRL.call(this, 2,  0x33333333);
 12978  	            exchangeLR.call(this, 16, 0x0000ffff);
 12979  	            exchangeLR.call(this, 4,  0x0f0f0f0f);
 12980  
 12981  	            // Set output
 12982  	            M[offset] = this._lBlock;
 12983  	            M[offset + 1] = this._rBlock;
 12984  	        },
 12985  
 12986  	        keySize: 64/32,
 12987  
 12988  	        ivSize: 64/32,
 12989  
 12990  	        blockSize: 64/32
 12991  	    });
 12992  
 12993  	    // Swap bits across the left and right words
 12994  	    function exchangeLR(offset, mask) {
 12995  	        var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
 12996  	        this._rBlock ^= t;
 12997  	        this._lBlock ^= t << offset;
 12998  	    }
 12999  
 13000  	    function exchangeRL(offset, mask) {
 13001  	        var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
 13002  	        this._lBlock ^= t;
 13003  	        this._rBlock ^= t << offset;
 13004  	    }
 13005  
 13006  	    /**
 13007  	     * Shortcut functions to the cipher's object interface.
 13008  	     *
 13009  	     * @example
 13010  	     *
 13011  	     *     var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
 13012  	     *     var plaintext  = CryptoJS.DES.decrypt(ciphertext, key, cfg);
 13013  	     */
 13014  	    C.DES = BlockCipher._createHelper(DES);
 13015  
 13016  	    /**
 13017  	     * Triple-DES block cipher algorithm.
 13018  	     */
 13019  	    var TripleDES = C_algo.TripleDES = BlockCipher.extend({
 13020  	        _doReset: function () {
 13021  	            // Shortcuts
 13022  	            var key = this._key;
 13023  	            var keyWords = key.words;
 13024  
 13025  	            // Create DES instances
 13026  	            this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
 13027  	            this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
 13028  	            this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
 13029  	        },
 13030  
 13031  	        encryptBlock: function (M, offset) {
 13032  	            this._des1.encryptBlock(M, offset);
 13033  	            this._des2.decryptBlock(M, offset);
 13034  	            this._des3.encryptBlock(M, offset);
 13035  	        },
 13036  
 13037  	        decryptBlock: function (M, offset) {
 13038  	            this._des3.decryptBlock(M, offset);
 13039  	            this._des2.encryptBlock(M, offset);
 13040  	            this._des1.decryptBlock(M, offset);
 13041  	        },
 13042  
 13043  	        keySize: 192/32,
 13044  
 13045  	        ivSize: 64/32,
 13046  
 13047  	        blockSize: 64/32
 13048  	    });
 13049  
 13050  	    /**
 13051  	     * Shortcut functions to the cipher's object interface.
 13052  	     *
 13053  	     * @example
 13054  	     *
 13055  	     *     var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
 13056  	     *     var plaintext  = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
 13057  	     */
 13058  	    C.TripleDES = BlockCipher._createHelper(TripleDES);
 13059  	}());
 13060  
 13061  
 13062  	return CryptoJS.TripleDES;
 13063  
 13064  }));
 13065  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],84:[function(require,module,exports){
 13066  ;(function (root, factory) {
 13067  	if (typeof exports === "object") {
 13068  		// CommonJS
 13069  		module.exports = exports = factory(require("./core"));
 13070  	}
 13071  	else if (typeof define === "function" && define.amd) {
 13072  		// AMD
 13073  		define(["./core"], factory);
 13074  	}
 13075  	else {
 13076  		// Global (browser)
 13077  		factory(root.CryptoJS);
 13078  	}
 13079  }(this, function (CryptoJS) {
 13080  
 13081  	(function (undefined) {
 13082  	    // Shortcuts
 13083  	    var C = CryptoJS;
 13084  	    var C_lib = C.lib;
 13085  	    var Base = C_lib.Base;
 13086  	    var X32WordArray = C_lib.WordArray;
 13087  
 13088  	    /**
 13089  	     * x64 namespace.
 13090  	     */
 13091  	    var C_x64 = C.x64 = {};
 13092  
 13093  	    /**
 13094  	     * A 64-bit word.
 13095  	     */
 13096  	    var X64Word = C_x64.Word = Base.extend({
 13097  	        /**
 13098  	         * Initializes a newly created 64-bit word.
 13099  	         *
 13100  	         * @param {number} high The high 32 bits.
 13101  	         * @param {number} low The low 32 bits.
 13102  	         *
 13103  	         * @example
 13104  	         *
 13105  	         *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
 13106  	         */
 13107  	        init: function (high, low) {
 13108  	            this.high = high;
 13109  	            this.low = low;
 13110  	        }
 13111  
 13112  	        /**
 13113  	         * Bitwise NOTs this word.
 13114  	         *
 13115  	         * @return {X64Word} A new x64-Word object after negating.
 13116  	         *
 13117  	         * @example
 13118  	         *
 13119  	         *     var negated = x64Word.not();
 13120  	         */
 13121  	        // not: function () {
 13122  	            // var high = ~this.high;
 13123  	            // var low = ~this.low;
 13124  
 13125  	            // return X64Word.create(high, low);
 13126  	        // },
 13127  
 13128  	        /**
 13129  	         * Bitwise ANDs this word with the passed word.
 13130  	         *
 13131  	         * @param {X64Word} word The x64-Word to AND with this word.
 13132  	         *
 13133  	         * @return {X64Word} A new x64-Word object after ANDing.
 13134  	         *
 13135  	         * @example
 13136  	         *
 13137  	         *     var anded = x64Word.and(anotherX64Word);
 13138  	         */
 13139  	        // and: function (word) {
 13140  	            // var high = this.high & word.high;
 13141  	            // var low = this.low & word.low;
 13142  
 13143  	            // return X64Word.create(high, low);
 13144  	        // },
 13145  
 13146  	        /**
 13147  	         * Bitwise ORs this word with the passed word.
 13148  	         *
 13149  	         * @param {X64Word} word The x64-Word to OR with this word.
 13150  	         *
 13151  	         * @return {X64Word} A new x64-Word object after ORing.
 13152  	         *
 13153  	         * @example
 13154  	         *
 13155  	         *     var ored = x64Word.or(anotherX64Word);
 13156  	         */
 13157  	        // or: function (word) {
 13158  	            // var high = this.high | word.high;
 13159  	            // var low = this.low | word.low;
 13160  
 13161  	            // return X64Word.create(high, low);
 13162  	        // },
 13163  
 13164  	        /**
 13165  	         * Bitwise XORs this word with the passed word.
 13166  	         *
 13167  	         * @param {X64Word} word The x64-Word to XOR with this word.
 13168  	         *
 13169  	         * @return {X64Word} A new x64-Word object after XORing.
 13170  	         *
 13171  	         * @example
 13172  	         *
 13173  	         *     var xored = x64Word.xor(anotherX64Word);
 13174  	         */
 13175  	        // xor: function (word) {
 13176  	            // var high = this.high ^ word.high;
 13177  	            // var low = this.low ^ word.low;
 13178  
 13179  	            // return X64Word.create(high, low);
 13180  	        // },
 13181  
 13182  	        /**
 13183  	         * Shifts this word n bits to the left.
 13184  	         *
 13185  	         * @param {number} n The number of bits to shift.
 13186  	         *
 13187  	         * @return {X64Word} A new x64-Word object after shifting.
 13188  	         *
 13189  	         * @example
 13190  	         *
 13191  	         *     var shifted = x64Word.shiftL(25);
 13192  	         */
 13193  	        // shiftL: function (n) {
 13194  	            // if (n < 32) {
 13195  	                // var high = (this.high << n) | (this.low >>> (32 - n));
 13196  	                // var low = this.low << n;
 13197  	            // } else {
 13198  	                // var high = this.low << (n - 32);
 13199  	                // var low = 0;
 13200  	            // }
 13201  
 13202  	            // return X64Word.create(high, low);
 13203  	        // },
 13204  
 13205  	        /**
 13206  	         * Shifts this word n bits to the right.
 13207  	         *
 13208  	         * @param {number} n The number of bits to shift.
 13209  	         *
 13210  	         * @return {X64Word} A new x64-Word object after shifting.
 13211  	         *
 13212  	         * @example
 13213  	         *
 13214  	         *     var shifted = x64Word.shiftR(7);
 13215  	         */
 13216  	        // shiftR: function (n) {
 13217  	            // if (n < 32) {
 13218  	                // var low = (this.low >>> n) | (this.high << (32 - n));
 13219  	                // var high = this.high >>> n;
 13220  	            // } else {
 13221  	                // var low = this.high >>> (n - 32);
 13222  	                // var high = 0;
 13223  	            // }
 13224  
 13225  	            // return X64Word.create(high, low);
 13226  	        // },
 13227  
 13228  	        /**
 13229  	         * Rotates this word n bits to the left.
 13230  	         *
 13231  	         * @param {number} n The number of bits to rotate.
 13232  	         *
 13233  	         * @return {X64Word} A new x64-Word object after rotating.
 13234  	         *
 13235  	         * @example
 13236  	         *
 13237  	         *     var rotated = x64Word.rotL(25);
 13238  	         */
 13239  	        // rotL: function (n) {
 13240  	            // return this.shiftL(n).or(this.shiftR(64 - n));
 13241  	        // },
 13242  
 13243  	        /**
 13244  	         * Rotates this word n bits to the right.
 13245  	         *
 13246  	         * @param {number} n The number of bits to rotate.
 13247  	         *
 13248  	         * @return {X64Word} A new x64-Word object after rotating.
 13249  	         *
 13250  	         * @example
 13251  	         *
 13252  	         *     var rotated = x64Word.rotR(7);
 13253  	         */
 13254  	        // rotR: function (n) {
 13255  	            // return this.shiftR(n).or(this.shiftL(64 - n));
 13256  	        // },
 13257  
 13258  	        /**
 13259  	         * Adds this word with the passed word.
 13260  	         *
 13261  	         * @param {X64Word} word The x64-Word to add with this word.
 13262  	         *
 13263  	         * @return {X64Word} A new x64-Word object after adding.
 13264  	         *
 13265  	         * @example
 13266  	         *
 13267  	         *     var added = x64Word.add(anotherX64Word);
 13268  	         */
 13269  	        // add: function (word) {
 13270  	            // var low = (this.low + word.low) | 0;
 13271  	            // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
 13272  	            // var high = (this.high + word.high + carry) | 0;
 13273  
 13274  	            // return X64Word.create(high, low);
 13275  	        // }
 13276  	    });
 13277  
 13278  	    /**
 13279  	     * An array of 64-bit words.
 13280  	     *
 13281  	     * @property {Array} words The array of CryptoJS.x64.Word objects.
 13282  	     * @property {number} sigBytes The number of significant bytes in this word array.
 13283  	     */
 13284  	    var X64WordArray = C_x64.WordArray = Base.extend({
 13285  	        /**
 13286  	         * Initializes a newly created word array.
 13287  	         *
 13288  	         * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
 13289  	         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
 13290  	         *
 13291  	         * @example
 13292  	         *
 13293  	         *     var wordArray = CryptoJS.x64.WordArray.create();
 13294  	         *
 13295  	         *     var wordArray = CryptoJS.x64.WordArray.create([
 13296  	         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 13297  	         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 13298  	         *     ]);
 13299  	         *
 13300  	         *     var wordArray = CryptoJS.x64.WordArray.create([
 13301  	         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 13302  	         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 13303  	         *     ], 10);
 13304  	         */
 13305  	        init: function (words, sigBytes) {
 13306  	            words = this.words = words || [];
 13307  
 13308  	            if (sigBytes != undefined) {
 13309  	                this.sigBytes = sigBytes;
 13310  	            } else {
 13311  	                this.sigBytes = words.length * 8;
 13312  	            }
 13313  	        },
 13314  
 13315  	        /**
 13316  	         * Converts this 64-bit word array to a 32-bit word array.
 13317  	         *
 13318  	         * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
 13319  	         *
 13320  	         * @example
 13321  	         *
 13322  	         *     var x32WordArray = x64WordArray.toX32();
 13323  	         */
 13324  	        toX32: function () {
 13325  	            // Shortcuts
 13326  	            var x64Words = this.words;
 13327  	            var x64WordsLength = x64Words.length;
 13328  
 13329  	            // Convert
 13330  	            var x32Words = [];
 13331  	            for (var i = 0; i < x64WordsLength; i++) {
 13332  	                var x64Word = x64Words[i];
 13333  	                x32Words.push(x64Word.high);
 13334  	                x32Words.push(x64Word.low);
 13335  	            }
 13336  
 13337  	            return X32WordArray.create(x32Words, this.sigBytes);
 13338  	        },
 13339  
 13340  	        /**
 13341  	         * Creates a copy of this word array.
 13342  	         *
 13343  	         * @return {X64WordArray} The clone.
 13344  	         *
 13345  	         * @example
 13346  	         *
 13347  	         *     var clone = x64WordArray.clone();
 13348  	         */
 13349  	        clone: function () {
 13350  	            var clone = Base.clone.call(this);
 13351  
 13352  	            // Clone "words" array
 13353  	            var words = clone.words = this.words.slice(0);
 13354  
 13355  	            // Clone each X64Word object
 13356  	            var wordsLength = words.length;
 13357  	            for (var i = 0; i < wordsLength; i++) {
 13358  	                words[i] = words[i].clone();
 13359  	            }
 13360  
 13361  	            return clone;
 13362  	        }
 13363  	    });
 13364  	}());
 13365  
 13366  
 13367  	return CryptoJS;
 13368  
 13369  }));
 13370  },{"./core":53}],85:[function(require,module,exports){
 13371  /*! https://mths.be/utf8js v2.1.2 by @mathias */
 13372  ;(function(root) {
 13373  
 13374  	// Detect free variables `exports`
 13375  	var freeExports = typeof exports == 'object' && exports;
 13376  
 13377  	// Detect free variable `module`
 13378  	var freeModule = typeof module == 'object' && module &&
 13379  		module.exports == freeExports && module;
 13380  
 13381  	// Detect free variable `global`, from Node.js or Browserified code,
 13382  	// and use it as `root`
 13383  	var freeGlobal = typeof global == 'object' && global;
 13384  	if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
 13385  		root = freeGlobal;
 13386  	}
 13387  
 13388  	/*--------------------------------------------------------------------------*/
 13389  
 13390  	var stringFromCharCode = String.fromCharCode;
 13391  
 13392  	// Taken from https://mths.be/punycode
 13393  	function ucs2decode(string) {
 13394  		var output = [];
 13395  		var counter = 0;
 13396  		var length = string.length;
 13397  		var value;
 13398  		var extra;
 13399  		while (counter < length) {
 13400  			value = string.charCodeAt(counter++);
 13401  			if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
 13402  				// high surrogate, and there is a next character
 13403  				extra = string.charCodeAt(counter++);
 13404  				if ((extra & 0xFC00) == 0xDC00) { // low surrogate
 13405  					output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
 13406  				} else {
 13407  					// unmatched surrogate; only append this code unit, in case the next
 13408  					// code unit is the high surrogate of a surrogate pair
 13409  					output.push(value);
 13410  					counter--;
 13411  				}
 13412  			} else {
 13413  				output.push(value);
 13414  			}
 13415  		}
 13416  		return output;
 13417  	}
 13418  
 13419  	// Taken from https://mths.be/punycode
 13420  	function ucs2encode(array) {
 13421  		var length = array.length;
 13422  		var index = -1;
 13423  		var value;
 13424  		var output = '';
 13425  		while (++index < length) {
 13426  			value = array[index];
 13427  			if (value > 0xFFFF) {
 13428  				value -= 0x10000;
 13429  				output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
 13430  				value = 0xDC00 | value & 0x3FF;
 13431  			}
 13432  			output += stringFromCharCode(value);
 13433  		}
 13434  		return output;
 13435  	}
 13436  
 13437  	function checkScalarValue(codePoint) {
 13438  		if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
 13439  			throw Error(
 13440  				'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
 13441  				' is not a scalar value'
 13442  			);
 13443  		}
 13444  	}
 13445  	/*--------------------------------------------------------------------------*/
 13446  
 13447  	function createByte(codePoint, shift) {
 13448  		return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
 13449  	}
 13450  
 13451  	function encodeCodePoint(codePoint) {
 13452  		if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
 13453  			return stringFromCharCode(codePoint);
 13454  		}
 13455  		var symbol = '';
 13456  		if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
 13457  			symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
 13458  		}
 13459  		else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
 13460  			checkScalarValue(codePoint);
 13461  			symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
 13462  			symbol += createByte(codePoint, 6);
 13463  		}
 13464  		else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
 13465  			symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
 13466  			symbol += createByte(codePoint, 12);
 13467  			symbol += createByte(codePoint, 6);
 13468  		}
 13469  		symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
 13470  		return symbol;
 13471  	}
 13472  
 13473  	function utf8encode(string) {
 13474  		var codePoints = ucs2decode(string);
 13475  		var length = codePoints.length;
 13476  		var index = -1;
 13477  		var codePoint;
 13478  		var byteString = '';
 13479  		while (++index < length) {
 13480  			codePoint = codePoints[index];
 13481  			byteString += encodeCodePoint(codePoint);
 13482  		}
 13483  		return byteString;
 13484  	}
 13485  
 13486  	/*--------------------------------------------------------------------------*/
 13487  
 13488  	function readContinuationByte() {
 13489  		if (byteIndex >= byteCount) {
 13490  			throw Error('Invalid byte index');
 13491  		}
 13492  
 13493  		var continuationByte = byteArray[byteIndex] & 0xFF;
 13494  		byteIndex++;
 13495  
 13496  		if ((continuationByte & 0xC0) == 0x80) {
 13497  			return continuationByte & 0x3F;
 13498  		}
 13499  
 13500  		// If we end up here, it’s not a continuation byte
 13501  		throw Error('Invalid continuation byte');
 13502  	}
 13503  
 13504  	function decodeSymbol() {
 13505  		var byte1;
 13506  		var byte2;
 13507  		var byte3;
 13508  		var byte4;
 13509  		var codePoint;
 13510  
 13511  		if (byteIndex > byteCount) {
 13512  			throw Error('Invalid byte index');
 13513  		}
 13514  
 13515  		if (byteIndex == byteCount) {
 13516  			return false;
 13517  		}
 13518  
 13519  		// Read first byte
 13520  		byte1 = byteArray[byteIndex] & 0xFF;
 13521  		byteIndex++;
 13522  
 13523  		// 1-byte sequence (no continuation bytes)
 13524  		if ((byte1 & 0x80) == 0) {
 13525  			return byte1;
 13526  		}
 13527  
 13528  		// 2-byte sequence
 13529  		if ((byte1 & 0xE0) == 0xC0) {
 13530  			byte2 = readContinuationByte();
 13531  			codePoint = ((byte1 & 0x1F) << 6) | byte2;
 13532  			if (codePoint >= 0x80) {
 13533  				return codePoint;
 13534  			} else {
 13535  				throw Error('Invalid continuation byte');
 13536  			}
 13537  		}
 13538  
 13539  		// 3-byte sequence (may include unpaired surrogates)
 13540  		if ((byte1 & 0xF0) == 0xE0) {
 13541  			byte2 = readContinuationByte();
 13542  			byte3 = readContinuationByte();
 13543  			codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
 13544  			if (codePoint >= 0x0800) {
 13545  				checkScalarValue(codePoint);
 13546  				return codePoint;
 13547  			} else {
 13548  				throw Error('Invalid continuation byte');
 13549  			}
 13550  		}
 13551  
 13552  		// 4-byte sequence
 13553  		if ((byte1 & 0xF8) == 0xF0) {
 13554  			byte2 = readContinuationByte();
 13555  			byte3 = readContinuationByte();
 13556  			byte4 = readContinuationByte();
 13557  			codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
 13558  				(byte3 << 0x06) | byte4;
 13559  			if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
 13560  				return codePoint;
 13561  			}
 13562  		}
 13563  
 13564  		throw Error('Invalid UTF-8 detected');
 13565  	}
 13566  
 13567  	var byteArray;
 13568  	var byteCount;
 13569  	var byteIndex;
 13570  	function utf8decode(byteString) {
 13571  		byteArray = ucs2decode(byteString);
 13572  		byteCount = byteArray.length;
 13573  		byteIndex = 0;
 13574  		var codePoints = [];
 13575  		var tmp;
 13576  		while ((tmp = decodeSymbol()) !== false) {
 13577  			codePoints.push(tmp);
 13578  		}
 13579  		return ucs2encode(codePoints);
 13580  	}
 13581  
 13582  	/*--------------------------------------------------------------------------*/
 13583  
 13584  	var utf8 = {
 13585  		'version': '2.1.2',
 13586  		'encode': utf8encode,
 13587  		'decode': utf8decode
 13588  	};
 13589  
 13590  	// Some AMD build optimizers, like r.js, check for specific condition patterns
 13591  	// like the following:
 13592  	if (
 13593  		typeof define == 'function' &&
 13594  		typeof define.amd == 'object' &&
 13595  		define.amd
 13596  	) {
 13597  		define(function() {
 13598  			return utf8;
 13599  		});
 13600  	}	else if (freeExports && !freeExports.nodeType) {
 13601  		if (freeModule) { // in Node.js or RingoJS v0.8.0+
 13602  			freeModule.exports = utf8;
 13603  		} else { // in Narwhal or RingoJS v0.7.0-
 13604  			var object = {};
 13605  			var hasOwnProperty = object.hasOwnProperty;
 13606  			for (var key in utf8) {
 13607  				hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
 13608  			}
 13609  		}
 13610  	} else { // in Rhino or a web browser
 13611  		root.utf8 = utf8;
 13612  	}
 13613  
 13614  }(this));
 13615  
 13616  },{}],86:[function(require,module,exports){
 13617  module.exports = XMLHttpRequest;
 13618  
 13619  },{}],"bignumber.js":[function(require,module,exports){
 13620  'use strict';
 13621  
 13622  module.exports = BigNumber; // jshint ignore:line
 13623  
 13624  
 13625  },{}],"web3":[function(require,module,exports){
 13626  var Web3 = require('./lib/web3');
 13627  
 13628  // don't override global variable
 13629  if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
 13630      window.Web3 = Web3;
 13631  }
 13632  
 13633  module.exports = Web3;
 13634  
 13635  },{"./lib/web3":22}]},{},["web3"])
 13636  //# sourceMappingURL=web3-light.js.map