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