github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/internal/jsre/deps/web3.js (about)

     1  require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
     2  module.exports=[
     3    {
     4      "constant": true,
     5      "inputs": [
     6        {
     7          "name": "_owner",
     8          "type": "address"
     9        }
    10      ],
    11      "name": "name",
    12      "outputs": [
    13        {
    14          "name": "o_name",
    15          "type": "bytes32"
    16        }
    17      ],
    18      "type": "function"
    19    },
    20    {
    21      "constant": true,
    22      "inputs": [
    23        {
    24          "name": "_name",
    25          "type": "bytes32"
    26        }
    27      ],
    28      "name": "owner",
    29      "outputs": [
    30        {
    31          "name": "",
    32          "type": "address"
    33        }
    34      ],
    35      "type": "function"
    36    },
    37    {
    38      "constant": true,
    39      "inputs": [
    40        {
    41          "name": "_name",
    42          "type": "bytes32"
    43        }
    44      ],
    45      "name": "content",
    46      "outputs": [
    47        {
    48          "name": "",
    49          "type": "bytes32"
    50        }
    51      ],
    52      "type": "function"
    53    },
    54    {
    55      "constant": true,
    56      "inputs": [
    57        {
    58          "name": "_name",
    59          "type": "bytes32"
    60        }
    61      ],
    62      "name": "addr",
    63      "outputs": [
    64        {
    65          "name": "",
    66          "type": "address"
    67        }
    68      ],
    69      "type": "function"
    70    },
    71    {
    72      "constant": false,
    73      "inputs": [
    74        {
    75          "name": "_name",
    76          "type": "bytes32"
    77        }
    78      ],
    79      "name": "reserve",
    80      "outputs": [],
    81      "type": "function"
    82    },
    83    {
    84      "constant": true,
    85      "inputs": [
    86        {
    87          "name": "_name",
    88          "type": "bytes32"
    89        }
    90      ],
    91      "name": "subRegistrar",
    92      "outputs": [
    93        {
    94          "name": "",
    95          "type": "address"
    96        }
    97      ],
    98      "type": "function"
    99    },
   100    {
   101      "constant": false,
   102      "inputs": [
   103        {
   104          "name": "_name",
   105          "type": "bytes32"
   106        },
   107        {
   108          "name": "_newOwner",
   109          "type": "address"
   110        }
   111      ],
   112      "name": "transfer",
   113      "outputs": [],
   114      "type": "function"
   115    },
   116    {
   117      "constant": false,
   118      "inputs": [
   119        {
   120          "name": "_name",
   121          "type": "bytes32"
   122        },
   123        {
   124          "name": "_registrar",
   125          "type": "address"
   126        }
   127      ],
   128      "name": "setSubRegistrar",
   129      "outputs": [],
   130      "type": "function"
   131    },
   132    {
   133      "constant": false,
   134      "inputs": [],
   135      "name": "Registrar",
   136      "outputs": [],
   137      "type": "function"
   138    },
   139    {
   140      "constant": false,
   141      "inputs": [
   142        {
   143          "name": "_name",
   144          "type": "bytes32"
   145        },
   146        {
   147          "name": "_a",
   148          "type": "address"
   149        },
   150        {
   151          "name": "_primary",
   152          "type": "bool"
   153        }
   154      ],
   155      "name": "setAddress",
   156      "outputs": [],
   157      "type": "function"
   158    },
   159    {
   160      "constant": false,
   161      "inputs": [
   162        {
   163          "name": "_name",
   164          "type": "bytes32"
   165        },
   166        {
   167          "name": "_content",
   168          "type": "bytes32"
   169        }
   170      ],
   171      "name": "setContent",
   172      "outputs": [],
   173      "type": "function"
   174    },
   175    {
   176      "constant": false,
   177      "inputs": [
   178        {
   179          "name": "_name",
   180          "type": "bytes32"
   181        }
   182      ],
   183      "name": "disown",
   184      "outputs": [],
   185      "type": "function"
   186    },
   187    {
   188      "anonymous": false,
   189      "inputs": [
   190        {
   191          "indexed": true,
   192          "name": "_name",
   193          "type": "bytes32"
   194        },
   195        {
   196          "indexed": false,
   197          "name": "_winner",
   198          "type": "address"
   199        }
   200      ],
   201      "name": "AuctionEnded",
   202      "type": "event"
   203    },
   204    {
   205      "anonymous": false,
   206      "inputs": [
   207        {
   208          "indexed": true,
   209          "name": "_name",
   210          "type": "bytes32"
   211        },
   212        {
   213          "indexed": false,
   214          "name": "_bidder",
   215          "type": "address"
   216        },
   217        {
   218          "indexed": false,
   219          "name": "_value",
   220          "type": "uint256"
   221        }
   222      ],
   223      "name": "NewBid",
   224      "type": "event"
   225    },
   226    {
   227      "anonymous": false,
   228      "inputs": [
   229        {
   230          "indexed": true,
   231          "name": "name",
   232          "type": "bytes32"
   233        }
   234      ],
   235      "name": "Changed",
   236      "type": "event"
   237    },
   238    {
   239      "anonymous": false,
   240      "inputs": [
   241        {
   242          "indexed": true,
   243          "name": "name",
   244          "type": "bytes32"
   245        },
   246        {
   247          "indexed": true,
   248          "name": "addr",
   249          "type": "address"
   250        }
   251      ],
   252      "name": "PrimaryChanged",
   253      "type": "event"
   254    }
   255  ]
   256  
   257  },{}],2:[function(require,module,exports){
   258  module.exports=[
   259    {
   260      "constant": true,
   261      "inputs": [
   262        {
   263          "name": "_name",
   264          "type": "bytes32"
   265        }
   266      ],
   267      "name": "owner",
   268      "outputs": [
   269        {
   270          "name": "",
   271          "type": "address"
   272        }
   273      ],
   274      "type": "function"
   275    },
   276    {
   277      "constant": false,
   278      "inputs": [
   279        {
   280          "name": "_name",
   281          "type": "bytes32"
   282        },
   283        {
   284          "name": "_refund",
   285          "type": "address"
   286        }
   287      ],
   288      "name": "disown",
   289      "outputs": [],
   290      "type": "function"
   291    },
   292    {
   293      "constant": true,
   294      "inputs": [
   295        {
   296          "name": "_name",
   297          "type": "bytes32"
   298        }
   299      ],
   300      "name": "addr",
   301      "outputs": [
   302        {
   303          "name": "",
   304          "type": "address"
   305        }
   306      ],
   307      "type": "function"
   308    },
   309    {
   310      "constant": false,
   311      "inputs": [
   312        {
   313          "name": "_name",
   314          "type": "bytes32"
   315        }
   316      ],
   317      "name": "reserve",
   318      "outputs": [],
   319      "type": "function"
   320    },
   321    {
   322      "constant": false,
   323      "inputs": [
   324        {
   325          "name": "_name",
   326          "type": "bytes32"
   327        },
   328        {
   329          "name": "_newOwner",
   330          "type": "address"
   331        }
   332      ],
   333      "name": "transfer",
   334      "outputs": [],
   335      "type": "function"
   336    },
   337    {
   338      "constant": false,
   339      "inputs": [
   340        {
   341          "name": "_name",
   342          "type": "bytes32"
   343        },
   344        {
   345          "name": "_a",
   346          "type": "address"
   347        }
   348      ],
   349      "name": "setAddr",
   350      "outputs": [],
   351      "type": "function"
   352    },
   353    {
   354      "anonymous": false,
   355      "inputs": [
   356        {
   357          "indexed": true,
   358          "name": "name",
   359          "type": "bytes32"
   360        }
   361      ],
   362      "name": "Changed",
   363      "type": "event"
   364    }
   365  ]
   366  
   367  },{}],3:[function(require,module,exports){
   368  module.exports=[
   369    {
   370      "constant": false,
   371      "inputs": [
   372        {
   373          "name": "from",
   374          "type": "bytes32"
   375        },
   376        {
   377          "name": "to",
   378          "type": "address"
   379        },
   380        {
   381          "name": "value",
   382          "type": "uint256"
   383        }
   384      ],
   385      "name": "transfer",
   386      "outputs": [],
   387      "type": "function"
   388    },
   389    {
   390      "constant": false,
   391      "inputs": [
   392        {
   393          "name": "from",
   394          "type": "bytes32"
   395        },
   396        {
   397          "name": "to",
   398          "type": "address"
   399        },
   400        {
   401          "name": "indirectId",
   402          "type": "bytes32"
   403        },
   404        {
   405          "name": "value",
   406          "type": "uint256"
   407        }
   408      ],
   409      "name": "icapTransfer",
   410      "outputs": [],
   411      "type": "function"
   412    },
   413    {
   414      "constant": false,
   415      "inputs": [
   416        {
   417          "name": "to",
   418          "type": "bytes32"
   419        }
   420      ],
   421      "name": "deposit",
   422      "outputs": [],
   423      "payable": true,
   424      "type": "function"
   425    },
   426    {
   427      "anonymous": false,
   428      "inputs": [
   429        {
   430          "indexed": true,
   431          "name": "from",
   432          "type": "address"
   433        },
   434        {
   435          "indexed": false,
   436          "name": "value",
   437          "type": "uint256"
   438        }
   439      ],
   440      "name": "AnonymousDeposit",
   441      "type": "event"
   442    },
   443    {
   444      "anonymous": false,
   445      "inputs": [
   446        {
   447          "indexed": true,
   448          "name": "from",
   449          "type": "address"
   450        },
   451        {
   452          "indexed": true,
   453          "name": "to",
   454          "type": "bytes32"
   455        },
   456        {
   457          "indexed": false,
   458          "name": "value",
   459          "type": "uint256"
   460        }
   461      ],
   462      "name": "Deposit",
   463      "type": "event"
   464    },
   465    {
   466      "anonymous": false,
   467      "inputs": [
   468        {
   469          "indexed": true,
   470          "name": "from",
   471          "type": "bytes32"
   472        },
   473        {
   474          "indexed": true,
   475          "name": "to",
   476          "type": "address"
   477        },
   478        {
   479          "indexed": false,
   480          "name": "value",
   481          "type": "uint256"
   482        }
   483      ],
   484      "name": "Transfer",
   485      "type": "event"
   486    },
   487    {
   488      "anonymous": false,
   489      "inputs": [
   490        {
   491          "indexed": true,
   492          "name": "from",
   493          "type": "bytes32"
   494        },
   495        {
   496          "indexed": true,
   497          "name": "to",
   498          "type": "address"
   499        },
   500        {
   501          "indexed": false,
   502          "name": "indirectId",
   503          "type": "bytes32"
   504        },
   505        {
   506          "indexed": false,
   507          "name": "value",
   508          "type": "uint256"
   509        }
   510      ],
   511      "name": "IcapTransfer",
   512      "type": "event"
   513    }
   514  ]
   515  
   516  },{}],4:[function(require,module,exports){
   517  var f = require('./formatters');
   518  var SolidityType = require('./type');
   519  
   520  /**
   521   * SolidityTypeAddress is a prootype that represents address type
   522   * It matches:
   523   * address
   524   * address[]
   525   * address[4]
   526   * address[][]
   527   * address[3][]
   528   * address[][6][], ...
   529   */
   530  var SolidityTypeAddress = function () {
   531      this._inputFormatter = f.formatInputInt;
   532      this._outputFormatter = f.formatOutputAddress;
   533  };
   534  
   535  SolidityTypeAddress.prototype = new SolidityType({});
   536  SolidityTypeAddress.prototype.constructor = SolidityTypeAddress;
   537  
   538  SolidityTypeAddress.prototype.isType = function (name) {
   539      return !!name.match(/address(\[([0-9]*)\])?/);
   540  };
   541  
   542  module.exports = SolidityTypeAddress;
   543  
   544  },{"./formatters":9,"./type":14}],5:[function(require,module,exports){
   545  var f = require('./formatters');
   546  var SolidityType = require('./type');
   547  
   548  /**
   549   * SolidityTypeBool is a prootype that represents bool type
   550   * It matches:
   551   * bool
   552   * bool[]
   553   * bool[4]
   554   * bool[][]
   555   * bool[3][]
   556   * bool[][6][], ...
   557   */
   558  var SolidityTypeBool = function () {
   559      this._inputFormatter = f.formatInputBool;
   560      this._outputFormatter = f.formatOutputBool;
   561  };
   562  
   563  SolidityTypeBool.prototype = new SolidityType({});
   564  SolidityTypeBool.prototype.constructor = SolidityTypeBool;
   565  
   566  SolidityTypeBool.prototype.isType = function (name) {
   567      return !!name.match(/^bool(\[([0-9]*)\])*$/);
   568  };
   569  
   570  module.exports = SolidityTypeBool;
   571  
   572  },{"./formatters":9,"./type":14}],6:[function(require,module,exports){
   573  var f = require('./formatters');
   574  var SolidityType = require('./type');
   575  
   576  /**
   577   * SolidityTypeBytes is a prototype that represents the bytes type.
   578   * It matches:
   579   * bytes
   580   * bytes[]
   581   * bytes[4]
   582   * bytes[][]
   583   * bytes[3][]
   584   * bytes[][6][], ...
   585   * bytes32
   586   * bytes8[4]
   587   * bytes[3][]
   588   */
   589  var SolidityTypeBytes = function () {
   590      this._inputFormatter = f.formatInputBytes;
   591      this._outputFormatter = f.formatOutputBytes;
   592  };
   593  
   594  SolidityTypeBytes.prototype = new SolidityType({});
   595  SolidityTypeBytes.prototype.constructor = SolidityTypeBytes;
   596  
   597  SolidityTypeBytes.prototype.isType = function (name) {
   598      return !!name.match(/^bytes([0-9]{1,})(\[([0-9]*)\])*$/);
   599  };
   600  
   601  module.exports = SolidityTypeBytes;
   602  
   603  },{"./formatters":9,"./type":14}],7:[function(require,module,exports){
   604  /*
   605      This file is part of web3.js.
   606  
   607      web3.js is free software: you can redistribute it and/or modify
   608      it under the terms of the GNU Lesser General Public License as published by
   609      the Free Software Foundation, either version 3 of the License, or
   610      (at your option) any later version.
   611  
   612      web3.js is distributed in the hope that it will be useful,
   613      but WITHOUT ANY WARRANTY; without even the implied warranty of
   614      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   615      GNU Lesser General Public License for more details.
   616  
   617      You should have received a copy of the GNU Lesser General Public License
   618      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
   619  */
   620  /**
   621   * @file coder.js
   622   * @author Marek Kotewicz <marek@ethdev.com>
   623   * @date 2015
   624   */
   625  
   626  var f = require('./formatters');
   627  
   628  var SolidityTypeAddress = require('./address');
   629  var SolidityTypeBool = require('./bool');
   630  var SolidityTypeInt = require('./int');
   631  var SolidityTypeUInt = require('./uint');
   632  var SolidityTypeDynamicBytes = require('./dynamicbytes');
   633  var SolidityTypeString = require('./string');
   634  var SolidityTypeReal = require('./real');
   635  var SolidityTypeUReal = require('./ureal');
   636  var SolidityTypeBytes = require('./bytes');
   637  
   638  var isDynamic = function (solidityType, type) {
   639     return solidityType.isDynamicType(type) ||
   640            solidityType.isDynamicArray(type);
   641  };
   642  
   643  /**
   644   * SolidityCoder prototype should be used to encode/decode solidity params of any type
   645   */
   646  var SolidityCoder = function (types) {
   647      this._types = types;
   648  };
   649  
   650  /**
   651   * This method should be used to transform type to SolidityType
   652   *
   653   * @method _requireType
   654   * @param {String} type
   655   * @returns {SolidityType}
   656   * @throws {Error} throws if no matching type is found
   657   */
   658  SolidityCoder.prototype._requireType = function (type) {
   659      var solidityType = this._types.filter(function (t) {
   660          return t.isType(type);
   661      })[0];
   662  
   663      if (!solidityType) {
   664          throw Error('invalid solidity type!: ' + type);
   665      }
   666  
   667      return solidityType;
   668  };
   669  
   670  /**
   671   * Should be used to encode plain param
   672   *
   673   * @method encodeParam
   674   * @param {String} type
   675   * @param {Object} plain param
   676   * @return {String} encoded plain param
   677   */
   678  SolidityCoder.prototype.encodeParam = function (type, param) {
   679      return this.encodeParams([type], [param]);
   680  };
   681  
   682  /**
   683   * Should be used to encode list of params
   684   *
   685   * @method encodeParams
   686   * @param {Array} types
   687   * @param {Array} params
   688   * @return {String} encoded list of params
   689   */
   690  SolidityCoder.prototype.encodeParams = function (types, params) {
   691      var solidityTypes = this.getSolidityTypes(types);
   692  
   693      var encodeds = solidityTypes.map(function (solidityType, index) {
   694          return solidityType.encode(params[index], types[index]);
   695      });
   696  
   697      var dynamicOffset = solidityTypes.reduce(function (acc, solidityType, index) {
   698          var staticPartLength = solidityType.staticPartLength(types[index]);
   699          var roundedStaticPartLength = Math.floor((staticPartLength + 31) / 32) * 32;
   700  
   701          return acc + (isDynamic(solidityTypes[index], types[index]) ?
   702              32 :
   703              roundedStaticPartLength);
   704      }, 0);
   705  
   706      var result = this.encodeMultiWithOffset(types, solidityTypes, encodeds, dynamicOffset);
   707  
   708      return result;
   709  };
   710  
   711  SolidityCoder.prototype.encodeMultiWithOffset = function (types, solidityTypes, encodeds, dynamicOffset) {
   712      var result = "";
   713      var self = this;
   714  
   715      types.forEach(function (type, i) {
   716          if (isDynamic(solidityTypes[i], types[i])) {
   717              result += f.formatInputInt(dynamicOffset).encode();
   718              var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   719              dynamicOffset += e.length / 2;
   720          } else {
   721              // don't add length to dynamicOffset. it's already counted
   722              result += self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   723          }
   724  
   725          // TODO: figure out nested arrays
   726      });
   727  
   728      types.forEach(function (type, i) {
   729          if (isDynamic(solidityTypes[i], types[i])) {
   730              var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   731              dynamicOffset += e.length / 2;
   732              result += e;
   733          }
   734      });
   735      return result;
   736  };
   737  
   738  // TODO: refactor whole encoding!
   739  SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded, offset) {
   740      var self = this;
   741      if (solidityType.isDynamicArray(type)) {
   742          return (function () {
   743              // offset was already set
   744              var nestedName = solidityType.nestedName(type);
   745              var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
   746              var result = encoded[0];
   747  
   748              (function () {
   749                  var previousLength = 2; // in int
   750                  if (solidityType.isDynamicArray(nestedName)) {
   751                      for (var i = 1; i < encoded.length; i++) {
   752                          previousLength += +(encoded[i - 1])[0] || 0;
   753                          result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
   754                      }
   755                  }
   756              })();
   757  
   758              // first element is length, skip it
   759              (function () {
   760                  for (var i = 0; i < encoded.length - 1; i++) {
   761                      var additionalOffset = result / 2;
   762                      result += self.encodeWithOffset(nestedName, solidityType, encoded[i + 1], offset +  additionalOffset);
   763                  }
   764              })();
   765  
   766              return result;
   767          })();
   768  
   769      } else if (solidityType.isStaticArray(type)) {
   770          return (function () {
   771              var nestedName = solidityType.nestedName(type);
   772              var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
   773              var result = "";
   774  
   775  
   776              if (solidityType.isDynamicArray(nestedName)) {
   777                  (function () {
   778                      var previousLength = 0; // in int
   779                      for (var i = 0; i < encoded.length; i++) {
   780                          // calculate length of previous item
   781                          previousLength += +(encoded[i - 1] || [])[0] || 0;
   782                          result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
   783                      }
   784                  })();
   785              }
   786  
   787              (function () {
   788                  for (var i = 0; i < encoded.length; i++) {
   789                      var additionalOffset = result / 2;
   790                      result += self.encodeWithOffset(nestedName, solidityType, encoded[i], offset + additionalOffset);
   791                  }
   792              })();
   793  
   794              return result;
   795          })();
   796      }
   797  
   798      return encoded;
   799  };
   800  
   801  /**
   802   * Should be used to decode bytes to plain param
   803   *
   804   * @method decodeParam
   805   * @param {String} type
   806   * @param {String} bytes
   807   * @return {Object} plain param
   808   */
   809  SolidityCoder.prototype.decodeParam = function (type, bytes) {
   810      return this.decodeParams([type], bytes)[0];
   811  };
   812  
   813  /**
   814   * Should be used to decode list of params
   815   *
   816   * @method decodeParam
   817   * @param {Array} types
   818   * @param {String} bytes
   819   * @return {Array} array of plain params
   820   */
   821  SolidityCoder.prototype.decodeParams = function (types, bytes) {
   822      var solidityTypes = this.getSolidityTypes(types);
   823      var offsets = this.getOffsets(types, solidityTypes);
   824  
   825      return solidityTypes.map(function (solidityType, index) {
   826          return solidityType.decode(bytes, offsets[index],  types[index], index);
   827      });
   828  };
   829  
   830  SolidityCoder.prototype.getOffsets = function (types, solidityTypes) {
   831      var lengths =  solidityTypes.map(function (solidityType, index) {
   832          return solidityType.staticPartLength(types[index]);
   833      });
   834  
   835      for (var i = 1; i < lengths.length; i++) {
   836           // sum with length of previous element
   837          lengths[i] += lengths[i - 1];
   838      }
   839  
   840      return lengths.map(function (length, index) {
   841          // remove the current length, so the length is sum of previous elements
   842          var staticPartLength = solidityTypes[index].staticPartLength(types[index]);
   843          return length - staticPartLength;
   844      });
   845  };
   846  
   847  SolidityCoder.prototype.getSolidityTypes = function (types) {
   848      var self = this;
   849      return types.map(function (type) {
   850          return self._requireType(type);
   851      });
   852  };
   853  
   854  var coder = new SolidityCoder([
   855      new SolidityTypeAddress(),
   856      new SolidityTypeBool(),
   857      new SolidityTypeInt(),
   858      new SolidityTypeUInt(),
   859      new SolidityTypeDynamicBytes(),
   860      new SolidityTypeBytes(),
   861      new SolidityTypeString(),
   862      new SolidityTypeReal(),
   863      new SolidityTypeUReal()
   864  ]);
   865  
   866  module.exports = coder;
   867  
   868  },{"./address":4,"./bool":5,"./bytes":6,"./dynamicbytes":8,"./formatters":9,"./int":10,"./real":12,"./string":13,"./uint":15,"./ureal":16}],8:[function(require,module,exports){
   869  var f = require('./formatters');
   870  var SolidityType = require('./type');
   871  
   872  var SolidityTypeDynamicBytes = function () {
   873      this._inputFormatter = f.formatInputDynamicBytes;
   874      this._outputFormatter = f.formatOutputDynamicBytes;
   875  };
   876  
   877  SolidityTypeDynamicBytes.prototype = new SolidityType({});
   878  SolidityTypeDynamicBytes.prototype.constructor = SolidityTypeDynamicBytes;
   879  
   880  SolidityTypeDynamicBytes.prototype.isType = function (name) {
   881      return !!name.match(/^bytes(\[([0-9]*)\])*$/);
   882  };
   883  
   884  SolidityTypeDynamicBytes.prototype.isDynamicType = function () {
   885      return true;
   886  };
   887  
   888  module.exports = SolidityTypeDynamicBytes;
   889  
   890  },{"./formatters":9,"./type":14}],9:[function(require,module,exports){
   891  /*
   892      This file is part of web3.js.
   893  
   894      web3.js is free software: you can redistribute it and/or modify
   895      it under the terms of the GNU Lesser General Public License as published by
   896      the Free Software Foundation, either version 3 of the License, or
   897      (at your option) any later version.
   898  
   899      web3.js is distributed in the hope that it will be useful,
   900      but WITHOUT ANY WARRANTY; without even the implied warranty of
   901      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   902      GNU Lesser General Public License for more details.
   903  
   904      You should have received a copy of the GNU Lesser General Public License
   905      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
   906  */
   907  /**
   908   * @file formatters.js
   909   * @author Marek Kotewicz <marek@ethdev.com>
   910   * @date 2015
   911   */
   912  
   913  var BigNumber = require('bignumber.js');
   914  var utils = require('../utils/utils');
   915  var c = require('../utils/config');
   916  var SolidityParam = require('./param');
   917  
   918  
   919  /**
   920   * Formats input value to byte representation of int
   921   * If value is negative, return it's two's complement
   922   * If the value is floating point, round it down
   923   *
   924   * @method formatInputInt
   925   * @param {String|Number|BigNumber} value that needs to be formatted
   926   * @returns {SolidityParam}
   927   */
   928  var formatInputInt = function (value) {
   929      BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
   930      var result = utils.padLeft(utils.toTwosComplement(value).toString(16), 64);
   931      return new SolidityParam(result);
   932  };
   933  
   934  /**
   935   * Formats input bytes
   936   *
   937   * @method formatInputBytes
   938   * @param {String}
   939   * @returns {SolidityParam}
   940   */
   941  var formatInputBytes = function (value) {
   942      var result = utils.toHex(value).substr(2);
   943      var l = Math.floor((result.length + 63) / 64);
   944      result = utils.padRight(result, l * 64);
   945      return new SolidityParam(result);
   946  };
   947  
   948  /**
   949   * Formats input bytes
   950   *
   951   * @method formatDynamicInputBytes
   952   * @param {String}
   953   * @returns {SolidityParam}
   954   */
   955  var formatInputDynamicBytes = function (value) {
   956      var result = utils.toHex(value).substr(2);
   957      var length = result.length / 2;
   958      var l = Math.floor((result.length + 63) / 64);
   959      result = utils.padRight(result, l * 64);
   960      return new SolidityParam(formatInputInt(length).value + result);
   961  };
   962  
   963  /**
   964   * Formats input value to byte representation of string
   965   *
   966   * @method formatInputString
   967   * @param {String}
   968   * @returns {SolidityParam}
   969   */
   970  var formatInputString = function (value) {
   971      var result = utils.fromUtf8(value).substr(2);
   972      var length = result.length / 2;
   973      var l = Math.floor((result.length + 63) / 64);
   974      result = utils.padRight(result, l * 64);
   975      return new SolidityParam(formatInputInt(length).value + result);
   976  };
   977  
   978  /**
   979   * Formats input value to byte representation of bool
   980   *
   981   * @method formatInputBool
   982   * @param {Boolean}
   983   * @returns {SolidityParam}
   984   */
   985  var formatInputBool = function (value) {
   986      var result = '000000000000000000000000000000000000000000000000000000000000000' + (value ?  '1' : '0');
   987      return new SolidityParam(result);
   988  };
   989  
   990  /**
   991   * Formats input value to byte representation of real
   992   * Values are multiplied by 2^m and encoded as integers
   993   *
   994   * @method formatInputReal
   995   * @param {String|Number|BigNumber}
   996   * @returns {SolidityParam}
   997   */
   998  var formatInputReal = function (value) {
   999      return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
  1000  };
  1001  
  1002  /**
  1003   * Check if input value is negative
  1004   *
  1005   * @method signedIsNegative
  1006   * @param {String} value is hex format
  1007   * @returns {Boolean} true if it is negative, otherwise false
  1008   */
  1009  var signedIsNegative = function (value) {
  1010      return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
  1011  };
  1012  
  1013  /**
  1014   * Formats right-aligned output bytes to int
  1015   *
  1016   * @method formatOutputInt
  1017   * @param {SolidityParam} param
  1018   * @returns {BigNumber} right-aligned output bytes formatted to big number
  1019   */
  1020  var formatOutputInt = function (param) {
  1021      var value = param.staticPart() || "0";
  1022  
  1023      // check if it's negative number
  1024      // it it is, return two's complement
  1025      if (signedIsNegative(value)) {
  1026          return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
  1027      }
  1028      return new BigNumber(value, 16);
  1029  };
  1030  
  1031  /**
  1032   * Formats right-aligned output bytes to uint
  1033   *
  1034   * @method formatOutputUInt
  1035   * @param {SolidityParam}
  1036   * @returns {BigNumeber} right-aligned output bytes formatted to uint
  1037   */
  1038  var formatOutputUInt = function (param) {
  1039      var value = param.staticPart() || "0";
  1040      return new BigNumber(value, 16);
  1041  };
  1042  
  1043  /**
  1044   * Formats right-aligned output bytes to real
  1045   *
  1046   * @method formatOutputReal
  1047   * @param {SolidityParam}
  1048   * @returns {BigNumber} input bytes formatted to real
  1049   */
  1050  var formatOutputReal = function (param) {
  1051      return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
  1052  };
  1053  
  1054  /**
  1055   * Formats right-aligned output bytes to ureal
  1056   *
  1057   * @method formatOutputUReal
  1058   * @param {SolidityParam}
  1059   * @returns {BigNumber} input bytes formatted to ureal
  1060   */
  1061  var formatOutputUReal = function (param) {
  1062      return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
  1063  };
  1064  
  1065  /**
  1066   * Should be used to format output bool
  1067   *
  1068   * @method formatOutputBool
  1069   * @param {SolidityParam}
  1070   * @returns {Boolean} right-aligned input bytes formatted to bool
  1071   */
  1072  var formatOutputBool = function (param) {
  1073      return param.staticPart() === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
  1074  };
  1075  
  1076  /**
  1077   * Should be used to format output bytes
  1078   *
  1079   * @method formatOutputBytes
  1080   * @param {SolidityParam} left-aligned hex representation of string
  1081   * @param {String} name type name
  1082   * @returns {String} hex string
  1083   */
  1084  var formatOutputBytes = function (param, name) {
  1085      var matches = name.match(/^bytes([0-9]*)/);
  1086      var size = parseInt(matches[1]);
  1087      return '0x' + param.staticPart().slice(0, 2 * size);
  1088  };
  1089  
  1090  /**
  1091   * Should be used to format output bytes
  1092   *
  1093   * @method formatOutputDynamicBytes
  1094   * @param {SolidityParam} left-aligned hex representation of string
  1095   * @returns {String} hex string
  1096   */
  1097  var formatOutputDynamicBytes = function (param) {
  1098      var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1099      return '0x' + param.dynamicPart().substr(64, length);
  1100  };
  1101  
  1102  /**
  1103   * Should be used to format output string
  1104   *
  1105   * @method formatOutputString
  1106   * @param {SolidityParam} left-aligned hex representation of string
  1107   * @returns {String} ascii string
  1108   */
  1109  var formatOutputString = function (param) {
  1110      var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1111      return utils.toUtf8(param.dynamicPart().substr(64, length));
  1112  };
  1113  
  1114  /**
  1115   * Should be used to format output address
  1116   *
  1117   * @method formatOutputAddress
  1118   * @param {SolidityParam} right-aligned input bytes
  1119   * @returns {String} address
  1120   */
  1121  var formatOutputAddress = function (param) {
  1122      var value = param.staticPart();
  1123      return "0x" + value.slice(value.length - 40, value.length);
  1124  };
  1125  
  1126  module.exports = {
  1127      formatInputInt: formatInputInt,
  1128      formatInputBytes: formatInputBytes,
  1129      formatInputDynamicBytes: formatInputDynamicBytes,
  1130      formatInputString: formatInputString,
  1131      formatInputBool: formatInputBool,
  1132      formatInputReal: formatInputReal,
  1133      formatOutputInt: formatOutputInt,
  1134      formatOutputUInt: formatOutputUInt,
  1135      formatOutputReal: formatOutputReal,
  1136      formatOutputUReal: formatOutputUReal,
  1137      formatOutputBool: formatOutputBool,
  1138      formatOutputBytes: formatOutputBytes,
  1139      formatOutputDynamicBytes: formatOutputDynamicBytes,
  1140      formatOutputString: formatOutputString,
  1141      formatOutputAddress: formatOutputAddress
  1142  };
  1143  
  1144  },{"../utils/config":18,"../utils/utils":20,"./param":11,"bignumber.js":"bignumber.js"}],10:[function(require,module,exports){
  1145  var f = require('./formatters');
  1146  var SolidityType = require('./type');
  1147  
  1148  /**
  1149   * SolidityTypeInt is a prootype that represents int type
  1150   * It matches:
  1151   * int
  1152   * int[]
  1153   * int[4]
  1154   * int[][]
  1155   * int[3][]
  1156   * int[][6][], ...
  1157   * int32
  1158   * int64[]
  1159   * int8[4]
  1160   * int256[][]
  1161   * int[3][]
  1162   * int64[][6][], ...
  1163   */
  1164  var SolidityTypeInt = function () {
  1165      this._inputFormatter = f.formatInputInt;
  1166      this._outputFormatter = f.formatOutputInt;
  1167  };
  1168  
  1169  SolidityTypeInt.prototype = new SolidityType({});
  1170  SolidityTypeInt.prototype.constructor = SolidityTypeInt;
  1171  
  1172  SolidityTypeInt.prototype.isType = function (name) {
  1173      return !!name.match(/^int([0-9]*)?(\[([0-9]*)\])*$/);
  1174  };
  1175  
  1176  module.exports = SolidityTypeInt;
  1177  
  1178  },{"./formatters":9,"./type":14}],11:[function(require,module,exports){
  1179  /*
  1180      This file is part of web3.js.
  1181  
  1182      web3.js is free software: you can redistribute it and/or modify
  1183      it under the terms of the GNU Lesser General Public License as published by
  1184      the Free Software Foundation, either version 3 of the License, or
  1185      (at your option) any later version.
  1186  
  1187      web3.js is distributed in the hope that it will be useful,
  1188      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1189      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1190      GNU Lesser General Public License for more details.
  1191  
  1192      You should have received a copy of the GNU Lesser General Public License
  1193      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1194  */
  1195  /** 
  1196   * @file param.js
  1197   * @author Marek Kotewicz <marek@ethdev.com>
  1198   * @date 2015
  1199   */
  1200  
  1201  var utils = require('../utils/utils');
  1202  
  1203  /**
  1204   * SolidityParam object prototype.
  1205   * Should be used when encoding, decoding solidity bytes
  1206   */
  1207  var SolidityParam = function (value, offset) {
  1208      this.value = value || '';
  1209      this.offset = offset; // offset in bytes
  1210  };
  1211  
  1212  /**
  1213   * This method should be used to get length of params's dynamic part
  1214   * 
  1215   * @method dynamicPartLength
  1216   * @returns {Number} length of dynamic part (in bytes)
  1217   */
  1218  SolidityParam.prototype.dynamicPartLength = function () {
  1219      return this.dynamicPart().length / 2;
  1220  };
  1221  
  1222  /**
  1223   * This method should be used to create copy of solidity param with different offset
  1224   *
  1225   * @method withOffset
  1226   * @param {Number} offset length in bytes
  1227   * @returns {SolidityParam} new solidity param with applied offset
  1228   */
  1229  SolidityParam.prototype.withOffset = function (offset) {
  1230      return new SolidityParam(this.value, offset);
  1231  };
  1232  
  1233  /**
  1234   * This method should be used to combine solidity params together
  1235   * eg. when appending an array
  1236   *
  1237   * @method combine
  1238   * @param {SolidityParam} param with which we should combine
  1239   * @param {SolidityParam} result of combination
  1240   */
  1241  SolidityParam.prototype.combine = function (param) {
  1242      return new SolidityParam(this.value + param.value); 
  1243  };
  1244  
  1245  /**
  1246   * This method should be called to check if param has dynamic size.
  1247   * If it has, it returns true, otherwise false
  1248   *
  1249   * @method isDynamic
  1250   * @returns {Boolean}
  1251   */
  1252  SolidityParam.prototype.isDynamic = function () {
  1253      return this.offset !== undefined;
  1254  };
  1255  
  1256  /**
  1257   * This method should be called to transform offset to bytes
  1258   *
  1259   * @method offsetAsBytes
  1260   * @returns {String} bytes representation of offset
  1261   */
  1262  SolidityParam.prototype.offsetAsBytes = function () {
  1263      return !this.isDynamic() ? '' : utils.padLeft(utils.toTwosComplement(this.offset).toString(16), 64);
  1264  };
  1265  
  1266  /**
  1267   * This method should be called to get static part of param
  1268   *
  1269   * @method staticPart
  1270   * @returns {String} offset if it is a dynamic param, otherwise value
  1271   */
  1272  SolidityParam.prototype.staticPart = function () {
  1273      if (!this.isDynamic()) {
  1274          return this.value; 
  1275      } 
  1276      return this.offsetAsBytes();
  1277  };
  1278  
  1279  /**
  1280   * This method should be called to get dynamic part of param
  1281   *
  1282   * @method dynamicPart
  1283   * @returns {String} returns a value if it is a dynamic param, otherwise empty string
  1284   */
  1285  SolidityParam.prototype.dynamicPart = function () {
  1286      return this.isDynamic() ? this.value : '';
  1287  };
  1288  
  1289  /**
  1290   * This method should be called to encode param
  1291   *
  1292   * @method encode
  1293   * @returns {String}
  1294   */
  1295  SolidityParam.prototype.encode = function () {
  1296      return this.staticPart() + this.dynamicPart();
  1297  };
  1298  
  1299  /**
  1300   * This method should be called to encode array of params
  1301   *
  1302   * @method encodeList
  1303   * @param {Array[SolidityParam]} params
  1304   * @returns {String}
  1305   */
  1306  SolidityParam.encodeList = function (params) {
  1307      
  1308      // updating offsets
  1309      var totalOffset = params.length * 32;
  1310      var offsetParams = params.map(function (param) {
  1311          if (!param.isDynamic()) {
  1312              return param;
  1313          }
  1314          var offset = totalOffset;
  1315          totalOffset += param.dynamicPartLength();
  1316          return param.withOffset(offset);
  1317      });
  1318  
  1319      // encode everything!
  1320      return offsetParams.reduce(function (result, param) {
  1321          return result + param.dynamicPart();
  1322      }, offsetParams.reduce(function (result, param) {
  1323          return result + param.staticPart();
  1324      }, ''));
  1325  };
  1326  
  1327  
  1328  
  1329  module.exports = SolidityParam;
  1330  
  1331  
  1332  },{"../utils/utils":20}],12:[function(require,module,exports){
  1333  var f = require('./formatters');
  1334  var SolidityType = require('./type');
  1335  
  1336  /**
  1337   * SolidityTypeReal is a prootype that represents real type
  1338   * It matches:
  1339   * real
  1340   * real[]
  1341   * real[4]
  1342   * real[][]
  1343   * real[3][]
  1344   * real[][6][], ...
  1345   * real32
  1346   * real64[]
  1347   * real8[4]
  1348   * real256[][]
  1349   * real[3][]
  1350   * real64[][6][], ...
  1351   */
  1352  var SolidityTypeReal = function () {
  1353      this._inputFormatter = f.formatInputReal;
  1354      this._outputFormatter = f.formatOutputReal;
  1355  };
  1356  
  1357  SolidityTypeReal.prototype = new SolidityType({});
  1358  SolidityTypeReal.prototype.constructor = SolidityTypeReal;
  1359  
  1360  SolidityTypeReal.prototype.isType = function (name) {
  1361      return !!name.match(/real([0-9]*)?(\[([0-9]*)\])?/);
  1362  };
  1363  
  1364  module.exports = SolidityTypeReal;
  1365  
  1366  },{"./formatters":9,"./type":14}],13:[function(require,module,exports){
  1367  var f = require('./formatters');
  1368  var SolidityType = require('./type');
  1369  
  1370  var SolidityTypeString = function () {
  1371      this._inputFormatter = f.formatInputString;
  1372      this._outputFormatter = f.formatOutputString;
  1373  };
  1374  
  1375  SolidityTypeString.prototype = new SolidityType({});
  1376  SolidityTypeString.prototype.constructor = SolidityTypeString;
  1377  
  1378  SolidityTypeString.prototype.isType = function (name) {
  1379      return !!name.match(/^string(\[([0-9]*)\])*$/);
  1380  };
  1381  
  1382  SolidityTypeString.prototype.isDynamicType = function () {
  1383      return true;
  1384  };
  1385  
  1386  module.exports = SolidityTypeString;
  1387  
  1388  },{"./formatters":9,"./type":14}],14:[function(require,module,exports){
  1389  var f = require('./formatters');
  1390  var SolidityParam = require('./param');
  1391  
  1392  /**
  1393   * SolidityType prototype is used to encode/decode solidity params of certain type
  1394   */
  1395  var SolidityType = function (config) {
  1396      this._inputFormatter = config.inputFormatter;
  1397      this._outputFormatter = config.outputFormatter;
  1398  };
  1399  
  1400  /**
  1401   * Should be used to determine if this SolidityType do match given name
  1402   *
  1403   * @method isType
  1404   * @param {String} name
  1405   * @return {Bool} true if type match this SolidityType, otherwise false
  1406   */
  1407  SolidityType.prototype.isType = function (name) {
  1408      throw "this method should be overrwritten for type " + name;
  1409  };
  1410  
  1411  /**
  1412   * Should be used to determine what is the length of static part in given type
  1413   *
  1414   * @method staticPartLength
  1415   * @param {String} name
  1416   * @return {Number} length of static part in bytes
  1417   */
  1418  SolidityType.prototype.staticPartLength = function (name) {
  1419      // If name isn't an array then treat it like a single element array.
  1420      return (this.nestedTypes(name) || ['[1]'])
  1421          .map(function (type) {
  1422              // the length of the nested array
  1423              return parseInt(type.slice(1, -1), 10) || 1;
  1424          })
  1425          .reduce(function (previous, current) {
  1426              return previous * current;
  1427          // all basic types are 32 bytes long
  1428          }, 32);
  1429  };
  1430  
  1431  /**
  1432   * Should be used to determine if type is dynamic array
  1433   * eg:
  1434   * "type[]" => true
  1435   * "type[4]" => false
  1436   *
  1437   * @method isDynamicArray
  1438   * @param {String} name
  1439   * @return {Bool} true if the type is dynamic array
  1440   */
  1441  SolidityType.prototype.isDynamicArray = function (name) {
  1442      var nestedTypes = this.nestedTypes(name);
  1443      return !!nestedTypes && !nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1444  };
  1445  
  1446  /**
  1447   * Should be used to determine if type is static array
  1448   * eg:
  1449   * "type[]" => false
  1450   * "type[4]" => true
  1451   *
  1452   * @method isStaticArray
  1453   * @param {String} name
  1454   * @return {Bool} true if the type is static array
  1455   */
  1456  SolidityType.prototype.isStaticArray = function (name) {
  1457      var nestedTypes = this.nestedTypes(name);
  1458      return !!nestedTypes && !!nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1459  };
  1460  
  1461  /**
  1462   * Should return length of static array
  1463   * eg.
  1464   * "int[32]" => 32
  1465   * "int256[14]" => 14
  1466   * "int[2][3]" => 3
  1467   * "int" => 1
  1468   * "int[1]" => 1
  1469   * "int[]" => 1
  1470   *
  1471   * @method staticArrayLength
  1472   * @param {String} name
  1473   * @return {Number} static array length
  1474   */
  1475  SolidityType.prototype.staticArrayLength = function (name) {
  1476      var nestedTypes = this.nestedTypes(name);
  1477      if (nestedTypes) {
  1478         return parseInt(nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g) || 1);
  1479      }
  1480      return 1;
  1481  };
  1482  
  1483  /**
  1484   * Should return nested type
  1485   * eg.
  1486   * "int[32]" => "int"
  1487   * "int256[14]" => "int256"
  1488   * "int[2][3]" => "int[2]"
  1489   * "int" => "int"
  1490   * "int[]" => "int"
  1491   *
  1492   * @method nestedName
  1493   * @param {String} name
  1494   * @return {String} nested name
  1495   */
  1496  SolidityType.prototype.nestedName = function (name) {
  1497      // remove last [] in name
  1498      var nestedTypes = this.nestedTypes(name);
  1499      if (!nestedTypes) {
  1500          return name;
  1501      }
  1502  
  1503      return name.substr(0, name.length - nestedTypes[nestedTypes.length - 1].length);
  1504  };
  1505  
  1506  /**
  1507   * Should return true if type has dynamic size by default
  1508   * such types are "string", "bytes"
  1509   *
  1510   * @method isDynamicType
  1511   * @param {String} name
  1512   * @return {Bool} true if is dynamic, otherwise false
  1513   */
  1514  SolidityType.prototype.isDynamicType = function () {
  1515      return false;
  1516  };
  1517  
  1518  /**
  1519   * Should return array of nested types
  1520   * eg.
  1521   * "int[2][3][]" => ["[2]", "[3]", "[]"]
  1522   * "int[] => ["[]"]
  1523   * "int" => null
  1524   *
  1525   * @method nestedTypes
  1526   * @param {String} name
  1527   * @return {Array} array of nested types
  1528   */
  1529  SolidityType.prototype.nestedTypes = function (name) {
  1530      // return list of strings eg. "[]", "[3]", "[]", "[2]"
  1531      return name.match(/(\[[0-9]*\])/g);
  1532  };
  1533  
  1534  /**
  1535   * Should be used to encode the value
  1536   *
  1537   * @method encode
  1538   * @param {Object} value
  1539   * @param {String} name
  1540   * @return {String} encoded value
  1541   */
  1542  SolidityType.prototype.encode = function (value, name) {
  1543      var self = this;
  1544      if (this.isDynamicArray(name)) {
  1545  
  1546          return (function () {
  1547              var length = value.length;                          // in int
  1548              var nestedName = self.nestedName(name);
  1549  
  1550              var result = [];
  1551              result.push(f.formatInputInt(length).encode());
  1552  
  1553              value.forEach(function (v) {
  1554                  result.push(self.encode(v, nestedName));
  1555              });
  1556  
  1557              return result;
  1558          })();
  1559  
  1560      } else if (this.isStaticArray(name)) {
  1561  
  1562          return (function () {
  1563              var length = self.staticArrayLength(name);          // in int
  1564              var nestedName = self.nestedName(name);
  1565  
  1566              var result = [];
  1567              for (var i = 0; i < length; i++) {
  1568                  result.push(self.encode(value[i], nestedName));
  1569              }
  1570  
  1571              return result;
  1572          })();
  1573  
  1574      }
  1575  
  1576      return this._inputFormatter(value, name).encode();
  1577  };
  1578  
  1579  /**
  1580   * Should be used to decode value from bytes
  1581   *
  1582   * @method decode
  1583   * @param {String} bytes
  1584   * @param {Number} offset in bytes
  1585   * @param {String} name type name
  1586   * @returns {Object} decoded value
  1587   */
  1588  SolidityType.prototype.decode = function (bytes, offset, name) {
  1589      var self = this;
  1590  
  1591      if (this.isDynamicArray(name)) {
  1592  
  1593          return (function () {
  1594              var arrayOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
  1595              var length = parseInt('0x' + bytes.substr(arrayOffset * 2, 64)); // in int
  1596              var arrayStart = arrayOffset + 32; // array starts after length; // in bytes
  1597  
  1598              var nestedName = self.nestedName(name);
  1599              var nestedStaticPartLength = self.staticPartLength(nestedName);  // in bytes
  1600              var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1601              var result = [];
  1602  
  1603              for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1604                  result.push(self.decode(bytes, arrayStart + i, nestedName));
  1605              }
  1606  
  1607              return result;
  1608          })();
  1609  
  1610      } else if (this.isStaticArray(name)) {
  1611  
  1612          return (function () {
  1613              var length = self.staticArrayLength(name);                      // in int
  1614              var arrayStart = offset;                                        // in bytes
  1615  
  1616              var nestedName = self.nestedName(name);
  1617              var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
  1618              var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1619              var result = [];
  1620  
  1621              for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1622                  result.push(self.decode(bytes, arrayStart + i, nestedName));
  1623              }
  1624  
  1625              return result;
  1626          })();
  1627      } else if (this.isDynamicType(name)) {
  1628  
  1629          return (function () {
  1630              var dynamicOffset = parseInt('0x' + bytes.substr(offset * 2, 64));      // in bytes
  1631              var length = parseInt('0x' + bytes.substr(dynamicOffset * 2, 64));      // in bytes
  1632              var roundedLength = Math.floor((length + 31) / 32);                     // in int
  1633              var param = new SolidityParam(bytes.substr(dynamicOffset * 2, ( 1 + roundedLength) * 64), 0);
  1634              return self._outputFormatter(param, name);
  1635          })();
  1636      }
  1637  
  1638      var length = this.staticPartLength(name);
  1639      var param = new SolidityParam(bytes.substr(offset * 2, length * 2));
  1640      return this._outputFormatter(param, name);
  1641  };
  1642  
  1643  module.exports = SolidityType;
  1644  
  1645  },{"./formatters":9,"./param":11}],15:[function(require,module,exports){
  1646  var f = require('./formatters');
  1647  var SolidityType = require('./type');
  1648  
  1649  /**
  1650   * SolidityTypeUInt is a prootype that represents uint type
  1651   * It matches:
  1652   * uint
  1653   * uint[]
  1654   * uint[4]
  1655   * uint[][]
  1656   * uint[3][]
  1657   * uint[][6][], ...
  1658   * uint32
  1659   * uint64[]
  1660   * uint8[4]
  1661   * uint256[][]
  1662   * uint[3][]
  1663   * uint64[][6][], ...
  1664   */
  1665  var SolidityTypeUInt = function () {
  1666      this._inputFormatter = f.formatInputInt;
  1667      this._outputFormatter = f.formatOutputUInt;
  1668  };
  1669  
  1670  SolidityTypeUInt.prototype = new SolidityType({});
  1671  SolidityTypeUInt.prototype.constructor = SolidityTypeUInt;
  1672  
  1673  SolidityTypeUInt.prototype.isType = function (name) {
  1674      return !!name.match(/^uint([0-9]*)?(\[([0-9]*)\])*$/);
  1675  };
  1676  
  1677  module.exports = SolidityTypeUInt;
  1678  
  1679  },{"./formatters":9,"./type":14}],16:[function(require,module,exports){
  1680  var f = require('./formatters');
  1681  var SolidityType = require('./type');
  1682  
  1683  /**
  1684   * SolidityTypeUReal is a prootype that represents ureal type
  1685   * It matches:
  1686   * ureal
  1687   * ureal[]
  1688   * ureal[4]
  1689   * ureal[][]
  1690   * ureal[3][]
  1691   * ureal[][6][], ...
  1692   * ureal32
  1693   * ureal64[]
  1694   * ureal8[4]
  1695   * ureal256[][]
  1696   * ureal[3][]
  1697   * ureal64[][6][], ...
  1698   */
  1699  var SolidityTypeUReal = function () {
  1700      this._inputFormatter = f.formatInputReal;
  1701      this._outputFormatter = f.formatOutputUReal;
  1702  };
  1703  
  1704  SolidityTypeUReal.prototype = new SolidityType({});
  1705  SolidityTypeUReal.prototype.constructor = SolidityTypeUReal;
  1706  
  1707  SolidityTypeUReal.prototype.isType = function (name) {
  1708      return !!name.match(/^ureal([0-9]*)?(\[([0-9]*)\])*$/);
  1709  };
  1710  
  1711  module.exports = SolidityTypeUReal;
  1712  
  1713  },{"./formatters":9,"./type":14}],17:[function(require,module,exports){
  1714  'use strict';
  1715  
  1716  // go env doesn't have and need XMLHttpRequest
  1717  if (typeof XMLHttpRequest === 'undefined') {
  1718      exports.XMLHttpRequest = {};
  1719  } else {
  1720      exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line
  1721  }
  1722  
  1723  
  1724  },{}],18:[function(require,module,exports){
  1725  /*
  1726      This file is part of web3.js.
  1727  
  1728      web3.js is free software: you can redistribute it and/or modify
  1729      it under the terms of the GNU Lesser General Public License as published by
  1730      the Free Software Foundation, either version 3 of the License, or
  1731      (at your option) any later version.
  1732  
  1733      web3.js is distributed in the hope that it will be useful,
  1734      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1735      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1736      GNU Lesser General Public License for more details.
  1737  
  1738      You should have received a copy of the GNU Lesser General Public License
  1739      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1740  */
  1741  /** @file config.js
  1742   * @authors:
  1743   *   Marek Kotewicz <marek@ethdev.com>
  1744   * @date 2015
  1745   */
  1746  
  1747  /**
  1748   * Utils
  1749   * 
  1750   * @module utils
  1751   */
  1752  
  1753  /**
  1754   * Utility functions
  1755   * 
  1756   * @class [utils] config
  1757   * @constructor
  1758   */
  1759  
  1760  
  1761  /// required to define ETH_BIGNUMBER_ROUNDING_MODE
  1762  var BigNumber = require('bignumber.js');
  1763  
  1764  var ETH_UNITS = [
  1765      'leto',
  1766      'serg',
  1767      'bit',
  1768      'sbr',
  1769      'ann'
  1770  ];
  1771  
  1772  module.exports = {
  1773      ETH_PADDING: 32,
  1774      ETH_SIGNATURE_LENGTH: 4,
  1775      ETH_UNITS: ETH_UNITS,
  1776      ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
  1777      ETH_POLLING_TIMEOUT: 1000/2,
  1778      defaultBlock: 'latest',
  1779      defaultAccount: undefined
  1780  };
  1781  
  1782  
  1783  },{"bignumber.js":"bignumber.js"}],19:[function(require,module,exports){
  1784  /*
  1785      This file is part of web3.js.
  1786  
  1787      web3.js is free software: you can redistribute it and/or modify
  1788      it under the terms of the GNU Lesser General Public License as published by
  1789      the Free Software Foundation, either version 3 of the License, or
  1790      (at your option) any later version.
  1791  
  1792      web3.js is distributed in the hope that it will be useful,
  1793      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1794      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1795      GNU Lesser General Public License for more details.
  1796  
  1797      You should have received a copy of the GNU Lesser General Public License
  1798      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1799  */
  1800  /** 
  1801   * @file sha3.js
  1802   * @author Marek Kotewicz <marek@ethdev.com>
  1803   * @date 2015
  1804   */
  1805  
  1806  var CryptoJS = require('crypto-js');
  1807  var sha3 = require('crypto-js/sha3');
  1808  
  1809  module.exports = function (value, options) {
  1810      if (options && options.encoding === 'hex') {
  1811          if (value.length > 2 && value.substr(0, 2) === '0x') {
  1812              value = value.substr(2);
  1813          }
  1814          value = CryptoJS.enc.Hex.parse(value);
  1815      }
  1816  
  1817      return sha3(value, {
  1818          outputLength: 256
  1819      }).toString();
  1820  };
  1821  
  1822  
  1823  },{"crypto-js":59,"crypto-js/sha3":80}],20:[function(require,module,exports){
  1824  /*
  1825      This file is part of web3.js.
  1826  
  1827      web3.js is free software: you can redistribute it and/or modify
  1828      it under the terms of the GNU Lesser General Public License as published by
  1829      the Free Software Foundation, either version 3 of the License, or
  1830      (at your option) any later version.
  1831  
  1832      web3.js is distributed in the hope that it will be useful,
  1833      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1834      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1835      GNU Lesser General Public License for more details.
  1836  
  1837      You should have received a copy of the GNU Lesser General Public License
  1838      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1839  */
  1840  /**
  1841   * @file utils.js
  1842   * @author Marek Kotewicz <marek@ethdev.com>
  1843   * @date 2015
  1844   */
  1845  
  1846  /**
  1847   * Utils
  1848   *
  1849   * @module utils
  1850   */
  1851  
  1852  /**
  1853   * Utility functions
  1854   *
  1855   * @class [utils] utils
  1856   * @constructor
  1857   */
  1858  
  1859  
  1860  var BigNumber = require('bignumber.js');
  1861  var sha3 = require('./sha3.js');
  1862  var utf8 = require('utf8');
  1863  
  1864  var unitMap = {
  1865      'nosbr':        '0',
  1866      'leto':         '1',
  1867      'serg':         '1000000000',
  1868      'sbr':          '1000000000000000000',
  1869      'ann':          '1000000000000000000000'
  1870  };
  1871  
  1872  /**
  1873   * Should be called to pad string to expected length
  1874   *
  1875   * @method padLeft
  1876   * @param {String} string to be padded
  1877   * @param {Number} characters that result string should have
  1878   * @param {String} sign, by default 0
  1879   * @returns {String} right aligned string
  1880   */
  1881  var padLeft = function (string, chars, sign) {
  1882      return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
  1883  };
  1884  
  1885  /**
  1886   * Should be called to pad string to expected length
  1887   *
  1888   * @method padRight
  1889   * @param {String} string to be padded
  1890   * @param {Number} characters that result string should have
  1891   * @param {String} sign, by default 0
  1892   * @returns {String} right aligned string
  1893   */
  1894  var padRight = function (string, chars, sign) {
  1895      return string + (new Array(chars - string.length + 1).join(sign ? sign : "0"));
  1896  };
  1897  
  1898  /**
  1899   * Should be called to get utf8 from it's hex representation
  1900   *
  1901   * @method toUtf8
  1902   * @param {String} string in hex
  1903   * @returns {String} ascii string representation of hex value
  1904   */
  1905  var toUtf8 = function(hex) {
  1906  // Find termination
  1907      var str = "";
  1908      var i = 0, l = hex.length;
  1909      if (hex.substring(0, 2) === '0x') {
  1910          i = 2;
  1911      }
  1912      for (; i < l; i+=2) {
  1913          var code = parseInt(hex.substr(i, 2), 16);
  1914          if (code === 0)
  1915              break;
  1916          str += String.fromCharCode(code);
  1917      }
  1918  
  1919      return utf8.decode(str);
  1920  };
  1921  
  1922  /**
  1923   * Should be called to get ascii from it's hex representation
  1924   *
  1925   * @method toAscii
  1926   * @param {String} string in hex
  1927   * @returns {String} ascii string representation of hex value
  1928   */
  1929  var toAscii = function(hex) {
  1930  // Find termination
  1931      var str = "";
  1932      var i = 0, l = hex.length;
  1933      if (hex.substring(0, 2) === '0x') {
  1934          i = 2;
  1935      }
  1936      for (; i < l; i+=2) {
  1937          var code = parseInt(hex.substr(i, 2), 16);
  1938          str += String.fromCharCode(code);
  1939      }
  1940  
  1941      return str;
  1942  };
  1943  
  1944  /**
  1945   * Should be called to get hex representation (prefixed by 0x) of utf8 string
  1946   *
  1947   * @method fromUtf8
  1948   * @param {String} string
  1949   * @param {Number} optional padding
  1950   * @returns {String} hex representation of input string
  1951   */
  1952  var fromUtf8 = function(str) {
  1953      str = utf8.encode(str);
  1954      var hex = "";
  1955      for(var i = 0; i < str.length; i++) {
  1956          var code = str.charCodeAt(i);
  1957          if (code === 0)
  1958              break;
  1959          var n = code.toString(16);
  1960          hex += n.length < 2 ? '0' + n : n;
  1961      }
  1962  
  1963      return "0x" + hex;
  1964  };
  1965  
  1966  /**
  1967   * Should be called to get hex representation (prefixed by 0x) of ascii string
  1968   *
  1969   * @method fromAscii
  1970   * @param {String} string
  1971   * @param {Number} optional padding
  1972   * @returns {String} hex representation of input string
  1973   */
  1974  var fromAscii = function(str) {
  1975      var hex = "";
  1976      for(var i = 0; i < str.length; i++) {
  1977          var code = str.charCodeAt(i);
  1978          var n = code.toString(16);
  1979          hex += n.length < 2 ? '0' + n : n;
  1980      }
  1981  
  1982      return "0x" + hex;
  1983  };
  1984  
  1985  /**
  1986   * Should be used to create full function/event name from json abi
  1987   *
  1988   * @method transformToFullName
  1989   * @param {Object} json-abi
  1990   * @return {String} full fnction/event name
  1991   */
  1992  var transformToFullName = function (json) {
  1993      if (json.name.indexOf('(') !== -1) {
  1994          return json.name;
  1995      }
  1996  
  1997      var typeName = json.inputs.map(function(i){return i.type; }).join();
  1998      return json.name + '(' + typeName + ')';
  1999  };
  2000  
  2001  /**
  2002   * Should be called to get display name of contract function
  2003   *
  2004   * @method extractDisplayName
  2005   * @param {String} name of function/event
  2006   * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
  2007   */
  2008  var extractDisplayName = function (name) {
  2009      var length = name.indexOf('(');
  2010      return length !== -1 ? name.substr(0, length) : name;
  2011  };
  2012  
  2013  /// @returns overloaded part of function/event name
  2014  var extractTypeName = function (name) {
  2015      /// TODO: make it invulnerable
  2016      var length = name.indexOf('(');
  2017      return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
  2018  };
  2019  
  2020  /**
  2021   * Converts value to it's decimal representation in string
  2022   *
  2023   * @method toDecimal
  2024   * @param {String|Number|BigNumber}
  2025   * @return {String}
  2026   */
  2027  var toDecimal = function (value) {
  2028      return toBigNumber(value).toNumber();
  2029  };
  2030  
  2031  /**
  2032   * Converts value to it's hex representation
  2033   *
  2034   * @method fromDecimal
  2035   * @param {String|Number|BigNumber}
  2036   * @return {String}
  2037   */
  2038  var fromDecimal = function (value) {
  2039      var number = toBigNumber(value);
  2040      var result = number.toString(16);
  2041  
  2042      return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
  2043  };
  2044  
  2045  /**
  2046   * Auto converts any given value into it's hex representation.
  2047   *
  2048   * And even stringifys objects before.
  2049   *
  2050   * @method toHex
  2051   * @param {String|Number|BigNumber|Object}
  2052   * @return {String}
  2053   */
  2054  var toHex = function (val) {
  2055      /*jshint maxcomplexity: 8 */
  2056  
  2057      if (isBoolean(val))
  2058          return fromDecimal(+val);
  2059  
  2060      if (isBigNumber(val))
  2061          return fromDecimal(val);
  2062  
  2063      if (typeof val === 'object')
  2064          return fromUtf8(JSON.stringify(val));
  2065  
  2066      // if its a negative number, pass it through fromDecimal
  2067      if (isString(val)) {
  2068          if (val.indexOf('-0x') === 0)
  2069              return fromDecimal(val);
  2070          else if(val.indexOf('0x') === 0)
  2071              return val;
  2072          else if (!isFinite(val))
  2073              return fromAscii(val);
  2074      }
  2075  
  2076      return fromDecimal(val);
  2077  };
  2078  
  2079  /**
  2080   * Returns value of unit in Leto
  2081   *
  2082   * @method getValueOfUnit
  2083   * @param {String} unit the unit to convert to, default sbr
  2084   * @returns {BigNumber} value of the unit (in Leto)
  2085   * @throws error if the unit is not correct:w
  2086   */
  2087  var getValueOfUnit = function (unit) {
  2088      unit = unit ? unit.toLowerCase() : 'sbr';
  2089      var unitValue = unitMap[unit];
  2090      if (unitValue === undefined) {
  2091          throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
  2092      }
  2093      return new BigNumber(unitValue, 10);
  2094  };
  2095  
  2096  /**
  2097   * Takes a number of leto and converts it to any other sbr unit.
  2098   *
  2099   * Possible units are:
  2100   *   SI Short   SI Full        Effigy       Other
  2101   * - --         --             shannon      --
  2102   * - sbr        --             --           --
  2103   * - ann        --             --           --
  2104   *
  2105   * @method fromLeto
  2106   * @param {Number|String} number can be a number, number string or a HEX of a decimal
  2107   * @param {String} unit the unit to convert to, default ether
  2108   * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2109  */
  2110  var fromLeto = function(number, unit) {
  2111      var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
  2112  
  2113      return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2114  };
  2115  
  2116  /**
  2117   * Takes a number of a unit and converts it to leto.
  2118   *
  2119   * Possible units are:
  2120   *   SI Short   SI Full        Effigy       Other
  2121   * - --         --             shannon      --
  2122   * - sbr        --             --           --
  2123   * - ann        --             --           --
  2124   *
  2125   * @method toLeto
  2126   * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
  2127   * @param {String} unit the unit to convert from, default sbr
  2128   * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2129  */
  2130  var toLeto = function(number, unit) {
  2131      var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
  2132  
  2133      return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2134  };
  2135  
  2136  /**
  2137   * Takes an input and transforms it into an bignumber
  2138   *
  2139   * @method toBigNumber
  2140   * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
  2141   * @return {BigNumber} BigNumber
  2142  */
  2143  var toBigNumber = function(number) {
  2144      /*jshint maxcomplexity:5 */
  2145      number = number || 0;
  2146      if (isBigNumber(number))
  2147          return number;
  2148  
  2149      if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
  2150          return new BigNumber(number.replace('0x',''), 16);
  2151      }
  2152  
  2153      return new BigNumber(number.toString(10), 10);
  2154  };
  2155  
  2156  /**
  2157   * Takes and input transforms it into bignumber and if it is negative value, into two's complement
  2158   *
  2159   * @method toTwosComplement
  2160   * @param {Number|String|BigNumber}
  2161   * @return {BigNumber}
  2162   */
  2163  var toTwosComplement = function (number) {
  2164      var bigNumber = toBigNumber(number).round();
  2165      if (bigNumber.lessThan(0)) {
  2166          return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
  2167      }
  2168      return bigNumber;
  2169  };
  2170  
  2171  /**
  2172   * Checks if the given string is strictly an address
  2173   *
  2174   * @method isStrictAddress
  2175   * @param {String} address the given HEX adress
  2176   * @return {Boolean}
  2177  */
  2178  var isStrictAddress = function (address) {
  2179      return /^0x[0-9a-f]{40}$/i.test(address);
  2180  };
  2181  
  2182  /**
  2183   * Checks if the given string is an address
  2184   *
  2185   * @method isAddress
  2186   * @param {String} address the given HEX adress
  2187   * @return {Boolean}
  2188  */
  2189  var isAddress = function (address) {
  2190      if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
  2191          // check if it has the basic requirements of an address
  2192          return false;
  2193      } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
  2194          // If it's all small caps or all all caps, return true
  2195          return true;
  2196      } else {
  2197          // Otherwise check each case
  2198          return isChecksumAddress(address);
  2199      }
  2200  };
  2201  
  2202  /**
  2203   * Checks if the given string is a checksummed address
  2204   *
  2205   * @method isChecksumAddress
  2206   * @param {String} address the given HEX adress
  2207   * @return {Boolean}
  2208  */
  2209  var isChecksumAddress = function (address) {
  2210      // Check each case
  2211      address = address.replace('0x','');
  2212      var addressHash = sha3(address.toLowerCase());
  2213  
  2214      for (var i = 0; i < 40; i++ ) {
  2215          // the nth letter should be uppercase if the nth digit of casemap is 1
  2216          if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
  2217              return false;
  2218          }
  2219      }
  2220      return true;
  2221  };
  2222  
  2223  
  2224  
  2225  /**
  2226   * Makes a checksum address
  2227   *
  2228   * @method toChecksumAddress
  2229   * @param {String} address the given HEX adress
  2230   * @return {String}
  2231  */
  2232  var toChecksumAddress = function (address) {
  2233      if (typeof address === 'undefined') return '';
  2234  
  2235      address = address.toLowerCase().replace('0x','');
  2236      var addressHash = sha3(address);
  2237      var checksumAddress = '0x';
  2238  
  2239      for (var i = 0; i < address.length; i++ ) {
  2240          // If ith character is 9 to f then make it uppercase
  2241          if (parseInt(addressHash[i], 16) > 7) {
  2242            checksumAddress += address[i].toUpperCase();
  2243          } else {
  2244              checksumAddress += address[i];
  2245          }
  2246      }
  2247      return checksumAddress;
  2248  };
  2249  
  2250  /**
  2251   * Transforms given string to valid 20 bytes-length addres with 0x prefix
  2252   *
  2253   * @method toAddress
  2254   * @param {String} address
  2255   * @return {String} formatted address
  2256   */
  2257  var toAddress = function (address) {
  2258      if (isStrictAddress(address)) {
  2259          return address;
  2260      }
  2261  
  2262      if (/^[0-9a-f]{40}$/.test(address)) {
  2263          return '0x' + address;
  2264      }
  2265  
  2266      return '0x' + padLeft(toHex(address).substr(2), 40);
  2267  };
  2268  
  2269  /**
  2270   * Returns true if object is BigNumber, otherwise false
  2271   *
  2272   * @method isBigNumber
  2273   * @param {Object}
  2274   * @return {Boolean}
  2275   */
  2276  var isBigNumber = function (object) {
  2277      return object instanceof BigNumber ||
  2278          (object && object.constructor && object.constructor.name === 'BigNumber');
  2279  };
  2280  
  2281  /**
  2282   * Returns true if object is string, otherwise false
  2283   *
  2284   * @method isString
  2285   * @param {Object}
  2286   * @return {Boolean}
  2287   */
  2288  var isString = function (object) {
  2289      return typeof object === 'string' ||
  2290          (object && object.constructor && object.constructor.name === 'String');
  2291  };
  2292  
  2293  /**
  2294   * Returns true if object is function, otherwise false
  2295   *
  2296   * @method isFunction
  2297   * @param {Object}
  2298   * @return {Boolean}
  2299   */
  2300  var isFunction = function (object) {
  2301      return typeof object === 'function';
  2302  };
  2303  
  2304  /**
  2305   * Returns true if object is Objet, otherwise false
  2306   *
  2307   * @method isObject
  2308   * @param {Object}
  2309   * @return {Boolean}
  2310   */
  2311  var isObject = function (object) {
  2312      return object !== null && !(object instanceof Array) && typeof object === 'object';
  2313  };
  2314  
  2315  /**
  2316   * Returns true if object is boolean, otherwise false
  2317   *
  2318   * @method isBoolean
  2319   * @param {Object}
  2320   * @return {Boolean}
  2321   */
  2322  var isBoolean = function (object) {
  2323      return typeof object === 'boolean';
  2324  };
  2325  
  2326  /**
  2327   * Returns true if object is array, otherwise false
  2328   *
  2329   * @method isArray
  2330   * @param {Object}
  2331   * @return {Boolean}
  2332   */
  2333  var isArray = function (object) {
  2334      return object instanceof Array;
  2335  };
  2336  
  2337  /**
  2338   * Returns true if given string is valid json object
  2339   *
  2340   * @method isJson
  2341   * @param {String}
  2342   * @return {Boolean}
  2343   */
  2344  var isJson = function (str) {
  2345      try {
  2346          return !!JSON.parse(str);
  2347      } catch (e) {
  2348          return false;
  2349      }
  2350  };
  2351  
  2352  /**
  2353   * Returns true if given string is a valid Sberex block header bloom.
  2354   *
  2355   * @method isBloom
  2356   * @param {String} hex encoded bloom filter
  2357   * @return {Boolean}
  2358   */
  2359  var isBloom = function (bloom) {
  2360      if (!/^(0x)?[0-9a-f]{512}$/i.test(bloom)) {
  2361          return false;
  2362      } else if (/^(0x)?[0-9a-f]{512}$/.test(bloom) || /^(0x)?[0-9A-F]{512}$/.test(bloom)) {
  2363          return true;
  2364      }
  2365      return false;
  2366  };
  2367  
  2368  /**
  2369   * Returns true if given string is a valid log topic.
  2370   *
  2371   * @method isTopic
  2372   * @param {String} hex encoded topic
  2373   * @return {Boolean}
  2374   */
  2375  var isTopic = function (topic) {
  2376      if (!/^(0x)?[0-9a-f]{64}$/i.test(topic)) {
  2377          return false;
  2378      } else if (/^(0x)?[0-9a-f]{64}$/.test(topic) || /^(0x)?[0-9A-F]{64}$/.test(topic)) {
  2379          return true;
  2380      }
  2381      return false;
  2382  };
  2383  
  2384  module.exports = {
  2385      padLeft: padLeft,
  2386      padRight: padRight,
  2387      toHex: toHex,
  2388      toDecimal: toDecimal,
  2389      fromDecimal: fromDecimal,
  2390      toUtf8: toUtf8,
  2391      toAscii: toAscii,
  2392      fromUtf8: fromUtf8,
  2393      fromAscii: fromAscii,
  2394      transformToFullName: transformToFullName,
  2395      extractDisplayName: extractDisplayName,
  2396      extractTypeName: extractTypeName,
  2397      toLeto: toLeto,
  2398      fromLeto: fromLeto,
  2399      toBigNumber: toBigNumber,
  2400      toTwosComplement: toTwosComplement,
  2401      toAddress: toAddress,
  2402      isBigNumber: isBigNumber,
  2403      isStrictAddress: isStrictAddress,
  2404      isAddress: isAddress,
  2405      isChecksumAddress: isChecksumAddress,
  2406      toChecksumAddress: toChecksumAddress,
  2407      isFunction: isFunction,
  2408      isString: isString,
  2409      isObject: isObject,
  2410      isBoolean: isBoolean,
  2411      isArray: isArray,
  2412      isJson: isJson,
  2413      isBloom: isBloom,
  2414      isTopic: isTopic,
  2415  };
  2416  
  2417  },{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":85}],21:[function(require,module,exports){
  2418  module.exports={
  2419      "version": "0.20.1"
  2420  }
  2421  
  2422  },{}],22:[function(require,module,exports){
  2423  /*
  2424      This file is part of web3.js.
  2425  
  2426      web3.js is free software: you can redistribute it and/or modify
  2427      it under the terms of the GNU Lesser General Public License as published by
  2428      the Free Software Foundation, either version 3 of the License, or
  2429      (at your option) any later version.
  2430  
  2431      web3.js is distributed in the hope that it will be useful,
  2432      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2433      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2434      GNU Lesser General Public License for more details.
  2435  
  2436      You should have received a copy of the GNU Lesser General Public License
  2437      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2438  */
  2439  /**
  2440   * @file web3.js
  2441   * @authors:
  2442   *   Jeffrey Wilcke <jeff@ethdev.com>
  2443   *   Marek Kotewicz <marek@ethdev.com>
  2444   *   Marian Oancea <marian@ethdev.com>
  2445   *   Fabian Vogelsteller <fabian@ethdev.com>
  2446   *   Gav Wood <g@ethdev.com>
  2447   * @date 2014
  2448   */
  2449  
  2450  var RequestManager = require('./web3/requestmanager');
  2451  var Iban = require('./web3/iban');
  2452  var Eth = require('./web3/methods/eth');
  2453  var DB = require('./web3/methods/db');
  2454  var Shh = require('./web3/methods/shh');
  2455  var Net = require('./web3/methods/net');
  2456  var Personal = require('./web3/methods/personal');
  2457  var Swarm = require('./web3/methods/swarm');
  2458  var Settings = require('./web3/settings');
  2459  var version = require('./version.json');
  2460  var utils = require('./utils/utils');
  2461  var sha3 = require('./utils/sha3');
  2462  var extend = require('./web3/extend');
  2463  var Batch = require('./web3/batch');
  2464  var Property = require('./web3/property');
  2465  var HttpProvider = require('./web3/httpprovider');
  2466  var IpcProvider = require('./web3/ipcprovider');
  2467  var BigNumber = require('bignumber.js');
  2468  
  2469  
  2470  
  2471  function Web3 (provider) {
  2472      this._requestManager = new RequestManager(provider);
  2473      this.currentProvider = provider;
  2474      this.eth = new Eth(this);
  2475      this.db = new DB(this);
  2476      this.shh = new Shh(this);
  2477      this.net = new Net(this);
  2478      this.personal = new Personal(this);
  2479      this.bzz = new Swarm(this);
  2480      this.settings = new Settings();
  2481      this.version = {
  2482          api: version.version
  2483      };
  2484      this.providers = {
  2485          HttpProvider: HttpProvider,
  2486          IpcProvider: IpcProvider
  2487      };
  2488      this._extend = extend(this);
  2489      this._extend({
  2490          properties: properties()
  2491      });
  2492  }
  2493  
  2494  // expose providers on the class
  2495  Web3.providers = {
  2496      HttpProvider: HttpProvider,
  2497      IpcProvider: IpcProvider
  2498  };
  2499  
  2500  Web3.prototype.setProvider = function (provider) {
  2501      this._requestManager.setProvider(provider);
  2502      this.currentProvider = provider;
  2503  };
  2504  
  2505  Web3.prototype.reset = function (keepIsSyncing) {
  2506      this._requestManager.reset(keepIsSyncing);
  2507      this.settings = new Settings();
  2508  };
  2509  
  2510  Web3.prototype.BigNumber = BigNumber;
  2511  Web3.prototype.toHex = utils.toHex;
  2512  Web3.prototype.toAscii = utils.toAscii;
  2513  Web3.prototype.toUtf8 = utils.toUtf8;
  2514  Web3.prototype.fromAscii = utils.fromAscii;
  2515  Web3.prototype.fromUtf8 = utils.fromUtf8;
  2516  Web3.prototype.toDecimal = utils.toDecimal;
  2517  Web3.prototype.fromDecimal = utils.fromDecimal;
  2518  Web3.prototype.toBigNumber = utils.toBigNumber;
  2519  Web3.prototype.toLeto = utils.toLeto;
  2520  Web3.prototype.fromLeto = utils.fromLeto;
  2521  Web3.prototype.isAddress = utils.isAddress;
  2522  Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
  2523  Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
  2524  Web3.prototype.isIBAN = utils.isIBAN;
  2525  Web3.prototype.padLeft = utils.padLeft;
  2526  Web3.prototype.padRight = utils.padRight;
  2527  
  2528  
  2529  Web3.prototype.sha3 = function(string, options) {
  2530      return '0x' + sha3(string, options);
  2531  };
  2532  
  2533  /**
  2534   * Transforms direct icap to address
  2535   */
  2536  Web3.prototype.fromICAP = function (icap) {
  2537      var iban = new Iban(icap);
  2538      return iban.address();
  2539  };
  2540  
  2541  var properties = function () {
  2542      return [
  2543          new Property({
  2544              name: 'version.node',
  2545              getter: 'web3_clientVersion'
  2546          }),
  2547          new Property({
  2548              name: 'version.network',
  2549              getter: 'net_version',
  2550              inputFormatter: utils.toDecimal
  2551          }),
  2552          new Property({
  2553              name: 'version.sberex',
  2554              getter: 'eth_protocolVersion',
  2555              inputFormatter: utils.toDecimal
  2556          }),
  2557          new Property({
  2558              name: 'version.whisper',
  2559              getter: 'shh_version',
  2560              inputFormatter: utils.toDecimal
  2561          })
  2562      ];
  2563  };
  2564  
  2565  Web3.prototype.isConnected = function(){
  2566      return (this.currentProvider && this.currentProvider.isConnected());
  2567  };
  2568  
  2569  Web3.prototype.createBatch = function () {
  2570      return new Batch(this);
  2571  };
  2572  
  2573  module.exports = Web3;
  2574  
  2575  
  2576  },{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/eth":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/methods/shh":41,"./web3/methods/swarm":42,"./web3/property":45,"./web3/requestmanager":46,"./web3/settings":47,"bignumber.js":"bignumber.js"}],23:[function(require,module,exports){
  2577  /*
  2578      This file is part of web3.js.
  2579  
  2580      web3.js is free software: you can redistribute it and/or modify
  2581      it under the terms of the GNU Lesser General Public License as published by
  2582      the Free Software Foundation, either version 3 of the License, or
  2583      (at your option) any later version.
  2584  
  2585      web3.js is distributed in the hope that it will be useful,
  2586      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2587      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2588      GNU Lesser General Public License for more details.
  2589  
  2590      You should have received a copy of the GNU Lesser General Public License
  2591      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2592  */
  2593  /**
  2594   * @file allevents.js
  2595   * @author Marek Kotewicz <marek@ethdev.com>
  2596   * @date 2014
  2597   */
  2598  
  2599  var sha3 = require('../utils/sha3');
  2600  var SolidityEvent = require('./event');
  2601  var formatters = require('./formatters');
  2602  var utils = require('../utils/utils');
  2603  var Filter = require('./filter');
  2604  var watches = require('./methods/watches');
  2605  
  2606  var AllSolidityEvents = function (requestManager, json, address) {
  2607      this._requestManager = requestManager;
  2608      this._json = json;
  2609      this._address = address;
  2610  };
  2611  
  2612  AllSolidityEvents.prototype.encode = function (options) {
  2613      options = options || {};
  2614      var result = {};
  2615  
  2616      ['fromBlock', 'toBlock'].filter(function (f) {
  2617          return options[f] !== undefined;
  2618      }).forEach(function (f) {
  2619          result[f] = formatters.inputBlockNumberFormatter(options[f]);
  2620      });
  2621  
  2622      result.address = this._address;
  2623  
  2624      return result;
  2625  };
  2626  
  2627  AllSolidityEvents.prototype.decode = function (data) {
  2628      data.data = data.data || '';
  2629      data.topics = data.topics || [];
  2630  
  2631      var eventTopic = data.topics[0].slice(2);
  2632      var match = this._json.filter(function (j) {
  2633          return eventTopic === sha3(utils.transformToFullName(j));
  2634      })[0];
  2635  
  2636      if (!match) { // cannot find matching event?
  2637          console.warn('cannot find event for log');
  2638          return data;
  2639      }
  2640  
  2641      var event = new SolidityEvent(this._requestManager, match, this._address);
  2642      return event.decode(data);
  2643  };
  2644  
  2645  AllSolidityEvents.prototype.execute = function (options, callback) {
  2646  
  2647      if (utils.isFunction(arguments[arguments.length - 1])) {
  2648          callback = arguments[arguments.length - 1];
  2649          if(arguments.length === 1)
  2650              options = null;
  2651      }
  2652  
  2653      var o = this.encode(options);
  2654      var formatter = this.decode.bind(this);
  2655      return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
  2656  };
  2657  
  2658  AllSolidityEvents.prototype.attachToContract = function (contract) {
  2659      var execute = this.execute.bind(this);
  2660      contract.allEvents = execute;
  2661  };
  2662  
  2663  module.exports = AllSolidityEvents;
  2664  
  2665  
  2666  },{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":43}],24:[function(require,module,exports){
  2667  /*
  2668      This file is part of web3.js.
  2669  
  2670      web3.js is free software: you can redistribute it and/or modify
  2671      it under the terms of the GNU Lesser General Public License as published by
  2672      the Free Software Foundation, either version 3 of the License, or
  2673      (at your option) any later version.
  2674  
  2675      web3.js is distributed in the hope that it will be useful,
  2676      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2677      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2678      GNU Lesser General Public License for more details.
  2679  
  2680      You should have received a copy of the GNU Lesser General Public License
  2681      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2682  */
  2683  /** 
  2684   * @file batch.js
  2685   * @author Marek Kotewicz <marek@ethdev.com>
  2686   * @date 2015
  2687   */
  2688  
  2689  var Jsonrpc = require('./jsonrpc');
  2690  var errors = require('./errors');
  2691  
  2692  var Batch = function (web3) {
  2693      this.requestManager = web3._requestManager;
  2694      this.requests = [];
  2695  };
  2696  
  2697  /**
  2698   * Should be called to add create new request to batch request
  2699   *
  2700   * @method add
  2701   * @param {Object} jsonrpc requet object
  2702   */
  2703  Batch.prototype.add = function (request) {
  2704      this.requests.push(request);
  2705  };
  2706  
  2707  /**
  2708   * Should be called to execute batch request
  2709   *
  2710   * @method execute
  2711   */
  2712  Batch.prototype.execute = function () {
  2713      var requests = this.requests;
  2714      this.requestManager.sendBatch(requests, function (err, results) {
  2715          results = results || [];
  2716          requests.map(function (request, index) {
  2717              return results[index] || {};
  2718          }).forEach(function (result, index) {
  2719              if (requests[index].callback) {
  2720  
  2721                  if (!Jsonrpc.isValidResponse(result)) {
  2722                      return requests[index].callback(errors.InvalidResponse(result));
  2723                  }
  2724  
  2725                  requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));
  2726              }
  2727          });
  2728      }); 
  2729  };
  2730  
  2731  module.exports = Batch;
  2732  
  2733  
  2734  },{"./errors":26,"./jsonrpc":35}],25:[function(require,module,exports){
  2735  /*
  2736      This file is part of web3.js.
  2737  
  2738      web3.js is free software: you can redistribute it and/or modify
  2739      it under the terms of the GNU Lesser General Public License as published by
  2740      the Free Software Foundation, either version 3 of the License, or
  2741      (at your option) any later version.
  2742  
  2743      web3.js is distributed in the hope that it will be useful,
  2744      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2745      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2746      GNU Lesser General Public License for more details.
  2747  
  2748      You should have received a copy of the GNU Lesser General Public License
  2749      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2750  */
  2751  /**
  2752   * @file contract.js
  2753   * @author Marek Kotewicz <marek@ethdev.com>
  2754   * @date 2014
  2755   */
  2756  
  2757  var utils = require('../utils/utils');
  2758  var coder = require('../solidity/coder');
  2759  var SolidityEvent = require('./event');
  2760  var SolidityFunction = require('./function');
  2761  var AllEvents = require('./allevents');
  2762  
  2763  /**
  2764   * Should be called to encode constructor params
  2765   *
  2766   * @method encodeConstructorParams
  2767   * @param {Array} abi
  2768   * @param {Array} constructor params
  2769   */
  2770  var encodeConstructorParams = function (abi, params) {
  2771      return abi.filter(function (json) {
  2772          return json.type === 'constructor' && json.inputs.length === params.length;
  2773      }).map(function (json) {
  2774          return json.inputs.map(function (input) {
  2775              return input.type;
  2776          });
  2777      }).map(function (types) {
  2778          return coder.encodeParams(types, params);
  2779      })[0] || '';
  2780  };
  2781  
  2782  /**
  2783   * Should be called to add functions to contract object
  2784   *
  2785   * @method addFunctionsToContract
  2786   * @param {Contract} contract
  2787   * @param {Array} abi
  2788   */
  2789  var addFunctionsToContract = function (contract) {
  2790      contract.abi.filter(function (json) {
  2791          return json.type === 'function';
  2792      }).map(function (json) {
  2793          return new SolidityFunction(contract._eth, json, contract.address);
  2794      }).forEach(function (f) {
  2795          f.attachToContract(contract);
  2796      });
  2797  };
  2798  
  2799  /**
  2800   * Should be called to add events to contract object
  2801   *
  2802   * @method addEventsToContract
  2803   * @param {Contract} contract
  2804   * @param {Array} abi
  2805   */
  2806  var addEventsToContract = function (contract) {
  2807      var events = contract.abi.filter(function (json) {
  2808          return json.type === 'event';
  2809      });
  2810  
  2811      var All = new AllEvents(contract._eth._requestManager, events, contract.address);
  2812      All.attachToContract(contract);
  2813  
  2814      events.map(function (json) {
  2815          return new SolidityEvent(contract._eth._requestManager, json, contract.address);
  2816      }).forEach(function (e) {
  2817          e.attachToContract(contract);
  2818      });
  2819  };
  2820  
  2821  
  2822  /**
  2823   * Should be called to check if the contract gets properly deployed on the blockchain.
  2824   *
  2825   * @method checkForContractAddress
  2826   * @param {Object} contract
  2827   * @param {Function} callback
  2828   * @returns {Undefined}
  2829   */
  2830  var checkForContractAddress = function(contract, callback){
  2831      var count = 0,
  2832          callbackFired = false;
  2833  
  2834      // wait for receipt
  2835      var filter = contract._eth.filter('latest', function(e){
  2836          if (!e && !callbackFired) {
  2837              count++;
  2838  
  2839              // stop watching after 50 blocks (timeout)
  2840              if (count > 50) {
  2841  
  2842                  filter.stopWatching(function() {});
  2843                  callbackFired = true;
  2844  
  2845                  if (callback)
  2846                      callback(new Error('Contract transaction couldn\'t be found after 50 blocks'));
  2847                  else
  2848                      throw new Error('Contract transaction couldn\'t be found after 50 blocks');
  2849  
  2850  
  2851              } else {
  2852  
  2853                  contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
  2854                      if(receipt && !callbackFired) {
  2855  
  2856                          contract._eth.getCode(receipt.contractAddress, function(e, code){
  2857                              /*jshint maxcomplexity: 6 */
  2858  
  2859                              if(callbackFired || !code)
  2860                                  return;
  2861  
  2862                              filter.stopWatching(function() {});
  2863                              callbackFired = true;
  2864  
  2865                              if(code.length > 3) {
  2866  
  2867                                  // console.log('Contract code deployed!');
  2868  
  2869                                  contract.address = receipt.contractAddress;
  2870  
  2871                                  // attach events and methods again after we have
  2872                                  addFunctionsToContract(contract);
  2873                                  addEventsToContract(contract);
  2874  
  2875                                  // call callback for the second time
  2876                                  if(callback)
  2877                                      callback(null, contract);
  2878  
  2879                              } else {
  2880                                  if(callback)
  2881                                      callback(new Error('The contract code couldn\'t be stored, please check your gas amount.'));
  2882                                  else
  2883                                      throw new Error('The contract code couldn\'t be stored, please check your gas amount.');
  2884                              }
  2885                          });
  2886                      }
  2887                  });
  2888              }
  2889          }
  2890      });
  2891  };
  2892  
  2893  /**
  2894   * Should be called to create new ContractFactory instance
  2895   *
  2896   * @method ContractFactory
  2897   * @param {Array} abi
  2898   */
  2899  var ContractFactory = function (eth, abi) {
  2900      this.eth = eth;
  2901      this.abi = abi;
  2902  
  2903      /**
  2904       * Should be called to create new contract on a blockchain
  2905       *
  2906       * @method new
  2907       * @param {Any} contract constructor param1 (optional)
  2908       * @param {Any} contract constructor param2 (optional)
  2909       * @param {Object} contract transaction object (required)
  2910       * @param {Function} callback
  2911       * @returns {Contract} returns contract instance
  2912       */
  2913      this.new = function () {
  2914          /*jshint maxcomplexity: 7 */
  2915          
  2916          var contract = new Contract(this.eth, this.abi);
  2917  
  2918          // parse arguments
  2919          var options = {}; // required!
  2920          var callback;
  2921  
  2922          var args = Array.prototype.slice.call(arguments);
  2923          if (utils.isFunction(args[args.length - 1])) {
  2924              callback = args.pop();
  2925          }
  2926  
  2927          var last = args[args.length - 1];
  2928          if (utils.isObject(last) && !utils.isArray(last)) {
  2929              options = args.pop();
  2930          }
  2931  
  2932          if (options.value > 0) {
  2933              var constructorAbi = abi.filter(function (json) {
  2934                  return json.type === 'constructor' && json.inputs.length === args.length;
  2935              })[0] || {};
  2936  
  2937              if (!constructorAbi.payable) {
  2938                  throw new Error('Cannot send value to non-payable constructor');
  2939              }
  2940          }
  2941  
  2942          var bytes = encodeConstructorParams(this.abi, args);
  2943          options.data += bytes;
  2944  
  2945          if (callback) {
  2946  
  2947              // wait for the contract address adn check if the code was deployed
  2948              this.eth.sendTransaction(options, function (err, hash) {
  2949                  if (err) {
  2950                      callback(err);
  2951                  } else {
  2952                      // add the transaction hash
  2953                      contract.transactionHash = hash;
  2954  
  2955                      // call callback for the first time
  2956                      callback(null, contract);
  2957  
  2958                      checkForContractAddress(contract, callback);
  2959                  }
  2960              });
  2961          } else {
  2962              var hash = this.eth.sendTransaction(options);
  2963              // add the transaction hash
  2964              contract.transactionHash = hash;
  2965              checkForContractAddress(contract);
  2966          }
  2967  
  2968          return contract;
  2969      };
  2970  
  2971      this.new.getData = this.getData.bind(this);
  2972  };
  2973  
  2974  /**
  2975   * Should be called to create new ContractFactory
  2976   *
  2977   * @method contract
  2978   * @param {Array} abi
  2979   * @returns {ContractFactory} new contract factory
  2980   */
  2981  //var contract = function (abi) {
  2982      //return new ContractFactory(abi);
  2983  //};
  2984  
  2985  
  2986  
  2987  /**
  2988   * Should be called to get access to existing contract on a blockchain
  2989   *
  2990   * @method at
  2991   * @param {Address} contract address (required)
  2992   * @param {Function} callback {optional)
  2993   * @returns {Contract} returns contract if no callback was passed,
  2994   * otherwise calls callback function (err, contract)
  2995   */
  2996  ContractFactory.prototype.at = function (address, callback) {
  2997      var contract = new Contract(this.eth, this.abi, address);
  2998  
  2999      // this functions are not part of prototype,
  3000      // because we dont want to spoil the interface
  3001      addFunctionsToContract(contract);
  3002      addEventsToContract(contract);
  3003  
  3004      if (callback) {
  3005          callback(null, contract);
  3006      }
  3007      return contract;
  3008  };
  3009  
  3010  /**
  3011   * Gets the data, which is data to deploy plus constructor params
  3012   *
  3013   * @method getData
  3014   */
  3015  ContractFactory.prototype.getData = function () {
  3016      var options = {}; // required!
  3017      var args = Array.prototype.slice.call(arguments);
  3018  
  3019      var last = args[args.length - 1];
  3020      if (utils.isObject(last) && !utils.isArray(last)) {
  3021          options = args.pop();
  3022      }
  3023  
  3024      var bytes = encodeConstructorParams(this.abi, args);
  3025      options.data += bytes;
  3026  
  3027      return options.data;
  3028  };
  3029  
  3030  /**
  3031   * Should be called to create new contract instance
  3032   *
  3033   * @method Contract
  3034   * @param {Array} abi
  3035   * @param {Address} contract address
  3036   */
  3037  var Contract = function (eth, abi, address) {
  3038      this._eth = eth;
  3039      this.transactionHash = null;
  3040      this.address = address;
  3041      this.abi = abi;
  3042  };
  3043  
  3044  module.exports = ContractFactory;
  3045  
  3046  },{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(require,module,exports){
  3047  /*
  3048      This file is part of web3.js.
  3049  
  3050      web3.js is free software: you can redistribute it and/or modify
  3051      it under the terms of the GNU Lesser General Public License as published by
  3052      the Free Software Foundation, either version 3 of the License, or
  3053      (at your option) any later version.
  3054  
  3055      web3.js is distributed in the hope that it will be useful,
  3056      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3057      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3058      GNU Lesser General Public License for more details.
  3059  
  3060      You should have received a copy of the GNU Lesser General Public License
  3061      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3062  */
  3063  /** 
  3064   * @file errors.js
  3065   * @author Marek Kotewicz <marek@ethdev.com>
  3066   * @date 2015
  3067   */
  3068  
  3069  module.exports = {
  3070      InvalidNumberOfSolidityArgs: function () {
  3071          return new Error('Invalid number of arguments to Solidity function');
  3072      },
  3073      InvalidNumberOfRPCParams: function () {
  3074          return new Error('Invalid number of input parameters to RPC method');
  3075      },
  3076      InvalidConnection: function (host){
  3077          return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
  3078      },
  3079      InvalidProvider: function () {
  3080          return new Error('Provider not set or invalid');
  3081      },
  3082      InvalidResponse: function (result){
  3083          var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);
  3084          return new Error(message);
  3085      },
  3086      ConnectionTimeout: function (ms){
  3087          return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived');
  3088      }
  3089  };
  3090  
  3091  },{}],27:[function(require,module,exports){
  3092  /*
  3093      This file is part of web3.js.
  3094  
  3095      web3.js is free software: you can redistribute it and/or modify
  3096      it under the terms of the GNU Lesser General Public License as published by
  3097      the Free Software Foundation, either version 3 of the License, or
  3098      (at your option) any later version.
  3099  
  3100      web3.js is distributed in the hope that it will be useful,
  3101      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3102      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3103      GNU Lesser General Public License for more details.
  3104  
  3105      You should have received a copy of the GNU Lesser General Public License
  3106      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3107  */
  3108  /**
  3109   * @file event.js
  3110   * @author Marek Kotewicz <marek@ethdev.com>
  3111   * @date 2014
  3112   */
  3113  
  3114  var utils = require('../utils/utils');
  3115  var coder = require('../solidity/coder');
  3116  var formatters = require('./formatters');
  3117  var sha3 = require('../utils/sha3');
  3118  var Filter = require('./filter');
  3119  var watches = require('./methods/watches');
  3120  
  3121  /**
  3122   * This prototype should be used to create event filters
  3123   */
  3124  var SolidityEvent = function (requestManager, json, address) {
  3125      this._requestManager = requestManager;
  3126      this._params = json.inputs;
  3127      this._name = utils.transformToFullName(json);
  3128      this._address = address;
  3129      this._anonymous = json.anonymous;
  3130  };
  3131  
  3132  /**
  3133   * Should be used to get filtered param types
  3134   *
  3135   * @method types
  3136   * @param {Bool} decide if returned typed should be indexed
  3137   * @return {Array} array of types
  3138   */
  3139  SolidityEvent.prototype.types = function (indexed) {
  3140      return this._params.filter(function (i) {
  3141          return i.indexed === indexed;
  3142      }).map(function (i) {
  3143          return i.type;
  3144      });
  3145  };
  3146  
  3147  /**
  3148   * Should be used to get event display name
  3149   *
  3150   * @method displayName
  3151   * @return {String} event display name
  3152   */
  3153  SolidityEvent.prototype.displayName = function () {
  3154      return utils.extractDisplayName(this._name);
  3155  };
  3156  
  3157  /**
  3158   * Should be used to get event type name
  3159   *
  3160   * @method typeName
  3161   * @return {String} event type name
  3162   */
  3163  SolidityEvent.prototype.typeName = function () {
  3164      return utils.extractTypeName(this._name);
  3165  };
  3166  
  3167  /**
  3168   * Should be used to get event signature
  3169   *
  3170   * @method signature
  3171   * @return {String} event signature
  3172   */
  3173  SolidityEvent.prototype.signature = function () {
  3174      return sha3(this._name);
  3175  };
  3176  
  3177  /**
  3178   * Should be used to encode indexed params and options to one final object
  3179   *
  3180   * @method encode
  3181   * @param {Object} indexed
  3182   * @param {Object} options
  3183   * @return {Object} everything combined together and encoded
  3184   */
  3185  SolidityEvent.prototype.encode = function (indexed, options) {
  3186      indexed = indexed || {};
  3187      options = options || {};
  3188      var result = {};
  3189  
  3190      ['fromBlock', 'toBlock'].filter(function (f) {
  3191          return options[f] !== undefined;
  3192      }).forEach(function (f) {
  3193          result[f] = formatters.inputBlockNumberFormatter(options[f]);
  3194      });
  3195  
  3196      result.topics = [];
  3197  
  3198      result.address = this._address;
  3199      if (!this._anonymous) {
  3200          result.topics.push('0x' + this.signature());
  3201      }
  3202  
  3203      var indexedTopics = this._params.filter(function (i) {
  3204          return i.indexed === true;
  3205      }).map(function (i) {
  3206          var value = indexed[i.name];
  3207          if (value === undefined || value === null) {
  3208              return null;
  3209          }
  3210  
  3211          if (utils.isArray(value)) {
  3212              return value.map(function (v) {
  3213                  return '0x' + coder.encodeParam(i.type, v);
  3214              });
  3215          }
  3216          return '0x' + coder.encodeParam(i.type, value);
  3217      });
  3218  
  3219      result.topics = result.topics.concat(indexedTopics);
  3220  
  3221      return result;
  3222  };
  3223  
  3224  /**
  3225   * Should be used to decode indexed params and options
  3226   *
  3227   * @method decode
  3228   * @param {Object} data
  3229   * @return {Object} result object with decoded indexed && not indexed params
  3230   */
  3231  SolidityEvent.prototype.decode = function (data) {
  3232  
  3233      data.data = data.data || '';
  3234      data.topics = data.topics || [];
  3235  
  3236      var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
  3237      var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
  3238      var indexedParams = coder.decodeParams(this.types(true), indexedData);
  3239  
  3240      var notIndexedData = data.data.slice(2);
  3241      var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
  3242  
  3243      var result = formatters.outputLogFormatter(data);
  3244      result.event = this.displayName();
  3245      result.address = data.address;
  3246  
  3247      result.args = this._params.reduce(function (acc, current) {
  3248          acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();
  3249          return acc;
  3250      }, {});
  3251  
  3252      delete result.data;
  3253      delete result.topics;
  3254  
  3255      return result;
  3256  };
  3257  
  3258  /**
  3259   * Should be used to create new filter object from event
  3260   *
  3261   * @method execute
  3262   * @param {Object} indexed
  3263   * @param {Object} options
  3264   * @return {Object} filter object
  3265   */
  3266  SolidityEvent.prototype.execute = function (indexed, options, callback) {
  3267  
  3268      if (utils.isFunction(arguments[arguments.length - 1])) {
  3269          callback = arguments[arguments.length - 1];
  3270          if(arguments.length === 2)
  3271              options = null;
  3272          if(arguments.length === 1) {
  3273              options = null;
  3274              indexed = {};
  3275          }
  3276      }
  3277  
  3278      var o = this.encode(indexed, options);
  3279      var formatter = this.decode.bind(this);
  3280      return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
  3281  };
  3282  
  3283  /**
  3284   * Should be used to attach event to contract object
  3285   *
  3286   * @method attachToContract
  3287   * @param {Contract}
  3288   */
  3289  SolidityEvent.prototype.attachToContract = function (contract) {
  3290      var execute = this.execute.bind(this);
  3291      var displayName = this.displayName();
  3292      if (!contract[displayName]) {
  3293          contract[displayName] = execute;
  3294      }
  3295      contract[displayName][this.typeName()] = this.execute.bind(this, contract);
  3296  };
  3297  
  3298  module.exports = SolidityEvent;
  3299  
  3300  
  3301  },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":43}],28:[function(require,module,exports){
  3302  var formatters = require('./formatters');
  3303  var utils = require('./../utils/utils');
  3304  var Method = require('./method');
  3305  var Property = require('./property');
  3306  
  3307  // TODO: refactor, so the input params are not altered.
  3308  // it's necessary to make same 'extension' work with multiple providers
  3309  var extend = function (web3) {
  3310      /* jshint maxcomplexity:5 */
  3311      var ex = function (extension) {
  3312  
  3313          var extendedObject;
  3314          if (extension.property) {
  3315              if (!web3[extension.property]) {
  3316                  web3[extension.property] = {};
  3317              }
  3318              extendedObject = web3[extension.property];
  3319          } else {
  3320              extendedObject = web3;
  3321          }
  3322  
  3323          if (extension.methods) {
  3324              extension.methods.forEach(function (method) {
  3325                  method.attachToObject(extendedObject);
  3326                  method.setRequestManager(web3._requestManager);
  3327              });
  3328          }
  3329  
  3330          if (extension.properties) {
  3331              extension.properties.forEach(function (property) {
  3332                  property.attachToObject(extendedObject);
  3333                  property.setRequestManager(web3._requestManager);
  3334              });
  3335          }
  3336      };
  3337  
  3338      ex.formatters = formatters; 
  3339      ex.utils = utils;
  3340      ex.Method = Method;
  3341      ex.Property = Property;
  3342  
  3343      return ex;
  3344  };
  3345  
  3346  
  3347  
  3348  module.exports = extend;
  3349  
  3350  
  3351  },{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":45}],29:[function(require,module,exports){
  3352  /*
  3353      This file is part of web3.js.
  3354  
  3355      web3.js is free software: you can redistribute it and/or modify
  3356      it under the terms of the GNU Lesser General Public License as published by
  3357      the Free Software Foundation, either version 3 of the License, or
  3358      (at your option) any later version.
  3359  
  3360      web3.js is distributed in the hope that it will be useful,
  3361      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3362      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3363      GNU Lesser General Public License for more details.
  3364  
  3365      You should have received a copy of the GNU Lesser General Public License
  3366      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3367  */
  3368  /** @file filter.js
  3369   * @authors:
  3370   *   Jeffrey Wilcke <jeff@ethdev.com>
  3371   *   Marek Kotewicz <marek@ethdev.com>
  3372   *   Marian Oancea <marian@ethdev.com>
  3373   *   Fabian Vogelsteller <fabian@ethdev.com>
  3374   *   Gav Wood <g@ethdev.com>
  3375   * @date 2014
  3376   */
  3377  
  3378  var formatters = require('./formatters');
  3379  var utils = require('../utils/utils');
  3380  
  3381  /**
  3382  * Converts a given topic to a hex string, but also allows null values.
  3383  *
  3384  * @param {Mixed} value
  3385  * @return {String}
  3386  */
  3387  var toTopic = function(value){
  3388  
  3389      if(value === null || typeof value === 'undefined')
  3390          return null;
  3391  
  3392      value = String(value);
  3393  
  3394      if(value.indexOf('0x') === 0)
  3395          return value;
  3396      else
  3397          return utils.fromUtf8(value);
  3398  };
  3399  
  3400  /// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
  3401  /// @param should be string or object
  3402  /// @returns options string or object
  3403  var getOptions = function (options, type) {
  3404      /*jshint maxcomplexity: 6 */
  3405  
  3406      if (utils.isString(options)) {
  3407          return options;
  3408      }
  3409  
  3410      options = options || {};
  3411  
  3412  
  3413      switch(type) {
  3414          case 'eth':
  3415  
  3416              // make sure topics, get converted to hex
  3417              options.topics = options.topics || [];
  3418              options.topics = options.topics.map(function(topic){
  3419                  return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
  3420              });
  3421  
  3422              return {
  3423                  topics: options.topics,
  3424                  from: options.from,
  3425                  to: options.to,
  3426                  address: options.address,
  3427                  fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
  3428                  toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
  3429              };
  3430          case 'shh':
  3431              return options;
  3432      }
  3433  };
  3434  
  3435  /**
  3436  Adds the callback and sets up the methods, to iterate over the results.
  3437  
  3438  @method getLogsAtStart
  3439  @param {Object} self
  3440  @param {function} callback
  3441  */
  3442  var getLogsAtStart = function(self, callback){
  3443      // call getFilterLogs for the first watch callback start
  3444      if (!utils.isString(self.options)) {
  3445          self.get(function (err, messages) {
  3446              // don't send all the responses to all the watches again... just to self one
  3447              if (err) {
  3448                  callback(err);
  3449              }
  3450  
  3451              if(utils.isArray(messages)) {
  3452                  messages.forEach(function (message) {
  3453                      callback(null, message);
  3454                  });
  3455              }
  3456          });
  3457      }
  3458  };
  3459  
  3460  /**
  3461  Adds the callback and sets up the methods, to iterate over the results.
  3462  
  3463  @method pollFilter
  3464  @param {Object} self
  3465  */
  3466  var pollFilter = function(self) {
  3467  
  3468      var onMessage = function (error, messages) {
  3469          if (error) {
  3470              return self.callbacks.forEach(function (callback) {
  3471                  callback(error);
  3472              });
  3473          }
  3474  
  3475          if(utils.isArray(messages)) {
  3476              messages.forEach(function (message) {
  3477                  message = self.formatter ? self.formatter(message) : message;
  3478                  self.callbacks.forEach(function (callback) {
  3479                      callback(null, message);
  3480                  });
  3481              });
  3482          }
  3483      };
  3484  
  3485      self.requestManager.startPolling({
  3486          method: self.implementation.poll.call,
  3487          params: [self.filterId],
  3488      }, self.filterId, onMessage, self.stopWatching.bind(self));
  3489  
  3490  };
  3491  
  3492  var Filter = function (options, type, requestManager, methods, formatter, callback, filterCreationErrorCallback) {
  3493      var self = this;
  3494      var implementation = {};
  3495      methods.forEach(function (method) {
  3496          method.setRequestManager(requestManager);
  3497          method.attachToObject(implementation);
  3498      });
  3499      this.requestManager = requestManager;
  3500      this.options = getOptions(options, type);
  3501      this.implementation = implementation;
  3502      this.filterId = null;
  3503      this.callbacks = [];
  3504      this.getLogsCallbacks = [];
  3505      this.pollFilters = [];
  3506      this.formatter = formatter;
  3507      this.implementation.newFilter(this.options, function(error, id){
  3508          if(error) {
  3509              self.callbacks.forEach(function(cb){
  3510                  cb(error);
  3511              });
  3512              if (typeof filterCreationErrorCallback === 'function') {
  3513                filterCreationErrorCallback(error);
  3514              }
  3515          } else {
  3516              self.filterId = id;
  3517  
  3518              // check if there are get pending callbacks as a consequence
  3519              // of calling get() with filterId unassigned.
  3520              self.getLogsCallbacks.forEach(function (cb){
  3521                  self.get(cb);
  3522              });
  3523              self.getLogsCallbacks = [];
  3524  
  3525              // get filter logs for the already existing watch calls
  3526              self.callbacks.forEach(function(cb){
  3527                  getLogsAtStart(self, cb);
  3528              });
  3529              if(self.callbacks.length > 0)
  3530                  pollFilter(self);
  3531  
  3532              // start to watch immediately
  3533              if(typeof callback === 'function') {
  3534                  return self.watch(callback);
  3535              }
  3536          }
  3537      });
  3538  
  3539      return this;
  3540  };
  3541  
  3542  Filter.prototype.watch = function (callback) {
  3543      this.callbacks.push(callback);
  3544  
  3545      if(this.filterId) {
  3546          getLogsAtStart(this, callback);
  3547          pollFilter(this);
  3548      }
  3549  
  3550      return this;
  3551  };
  3552  
  3553  Filter.prototype.stopWatching = function (callback) {
  3554      this.requestManager.stopPolling(this.filterId);
  3555      this.callbacks = [];
  3556      // remove filter async
  3557      if (callback) {
  3558          this.implementation.uninstallFilter(this.filterId, callback);
  3559      } else {
  3560          return this.implementation.uninstallFilter(this.filterId);
  3561      }
  3562  };
  3563  
  3564  Filter.prototype.get = function (callback) {
  3565      var self = this;
  3566      if (utils.isFunction(callback)) {
  3567          if (this.filterId === null) {
  3568              // If filterId is not set yet, call it back
  3569              // when newFilter() assigns it.
  3570              this.getLogsCallbacks.push(callback);
  3571          } else {
  3572              this.implementation.getLogs(this.filterId, function(err, res){
  3573                  if (err) {
  3574                      callback(err);
  3575                  } else {
  3576                      callback(null, res.map(function (log) {
  3577                          return self.formatter ? self.formatter(log) : log;
  3578                      }));
  3579                  }
  3580              });
  3581          }
  3582      } else {
  3583          if (this.filterId === null) {
  3584              throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.');
  3585          }
  3586          var logs = this.implementation.getLogs(this.filterId);
  3587          return logs.map(function (log) {
  3588              return self.formatter ? self.formatter(log) : log;
  3589          });
  3590      }
  3591  
  3592      return this;
  3593  };
  3594  
  3595  module.exports = Filter;
  3596  
  3597  
  3598  },{"../utils/utils":20,"./formatters":30}],30:[function(require,module,exports){
  3599  'use strict'
  3600  
  3601  /*
  3602      This file is part of web3.js.
  3603  
  3604      web3.js is free software: you can redistribute it and/or modify
  3605      it under the terms of the GNU Lesser General Public License as published by
  3606      the Free Software Foundation, either version 3 of the License, or
  3607      (at your option) any later version.
  3608  
  3609      web3.js is distributed in the hope that it will be useful,
  3610      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3611      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3612      GNU Lesser General Public License for more details.
  3613  
  3614      You should have received a copy of the GNU Lesser General Public License
  3615      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3616  */
  3617  /**
  3618   * @file formatters.js
  3619   * @author Marek Kotewicz <marek@ethdev.com>
  3620   * @author Fabian Vogelsteller <fabian@ethdev.com>
  3621   * @date 2015
  3622   */
  3623  
  3624  var utils = require('../utils/utils');
  3625  var config = require('../utils/config');
  3626  var Iban = require('./iban');
  3627  
  3628  /**
  3629   * Should the format output to a big number
  3630   *
  3631   * @method outputBigNumberFormatter
  3632   * @param {String|Number|BigNumber}
  3633   * @returns {BigNumber} object
  3634   */
  3635  var outputBigNumberFormatter = function (number) {
  3636      return utils.toBigNumber(number);
  3637  };
  3638  
  3639  var isPredefinedBlockNumber = function (blockNumber) {
  3640      return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
  3641  };
  3642  
  3643  var inputDefaultBlockNumberFormatter = function (blockNumber) {
  3644      if (blockNumber === undefined) {
  3645          return config.defaultBlock;
  3646      }
  3647      return inputBlockNumberFormatter(blockNumber);
  3648  };
  3649  
  3650  var inputBlockNumberFormatter = function (blockNumber) {
  3651      if (blockNumber === undefined) {
  3652          return undefined;
  3653      } else if (isPredefinedBlockNumber(blockNumber)) {
  3654          return blockNumber;
  3655      }
  3656      return utils.toHex(blockNumber);
  3657  };
  3658  
  3659  /**
  3660   * Formats the input of a transaction and converts all values to HEX
  3661   *
  3662   * @method inputCallFormatter
  3663   * @param {Object} transaction options
  3664   * @returns object
  3665  */
  3666  var inputCallFormatter = function (options){
  3667  
  3668      options.from = options.from || config.defaultAccount;
  3669  
  3670      if (options.from) {
  3671          options.from = inputAddressFormatter(options.from);
  3672      }
  3673  
  3674      if (options.to) { // it might be contract creation
  3675          options.to = inputAddressFormatter(options.to);
  3676      }
  3677  
  3678      ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3679          return options[key] !== undefined;
  3680      }).forEach(function(key){
  3681          options[key] = utils.fromDecimal(options[key]);
  3682      });
  3683  
  3684      return options;
  3685  };
  3686  
  3687  /**
  3688   * Formats the input of a transaction and converts all values to HEX
  3689   *
  3690   * @method inputTransactionFormatter
  3691   * @param {Object} transaction options
  3692   * @returns object
  3693  */
  3694  var inputTransactionFormatter = function (options){
  3695  
  3696      options.from = options.from || config.defaultAccount;
  3697      options.from = inputAddressFormatter(options.from);
  3698  
  3699      if (options.to) { // it might be contract creation
  3700          options.to = inputAddressFormatter(options.to);
  3701      }
  3702  
  3703      ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3704          return options[key] !== undefined;
  3705      }).forEach(function(key){
  3706          options[key] = utils.fromDecimal(options[key]);
  3707      });
  3708  
  3709      return options;
  3710  };
  3711  
  3712  /**
  3713   * Formats the output of a transaction to its proper values
  3714   *
  3715   * @method outputTransactionFormatter
  3716   * @param {Object} tx
  3717   * @returns {Object}
  3718  */
  3719  var outputTransactionFormatter = function (tx){
  3720      if(tx.blockNumber !== null)
  3721          tx.blockNumber = utils.toDecimal(tx.blockNumber);
  3722      if(tx.transactionIndex !== null)
  3723          tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
  3724      tx.nonce = utils.toDecimal(tx.nonce);
  3725      tx.gas = utils.toDecimal(tx.gas);
  3726      tx.gasPrice = utils.toBigNumber(tx.gasPrice);
  3727      tx.value = utils.toBigNumber(tx.value);
  3728      return tx;
  3729  };
  3730  
  3731  /**
  3732   * Formats the output of a transaction receipt to its proper values
  3733   *
  3734   * @method outputTransactionReceiptFormatter
  3735   * @param {Object} receipt
  3736   * @returns {Object}
  3737  */
  3738  var outputTransactionReceiptFormatter = function (receipt){
  3739      if(receipt.blockNumber !== null)
  3740          receipt.blockNumber = utils.toDecimal(receipt.blockNumber);
  3741      if(receipt.transactionIndex !== null)
  3742          receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
  3743      receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
  3744      receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
  3745  
  3746      if(utils.isArray(receipt.logs)) {
  3747          receipt.logs = receipt.logs.map(function(log){
  3748              return outputLogFormatter(log);
  3749          });
  3750      }
  3751  
  3752      return receipt;
  3753  };
  3754  
  3755  /**
  3756   * Formats the output of a block to its proper values
  3757   *
  3758   * @method outputBlockFormatter
  3759   * @param {Object} block
  3760   * @returns {Object}
  3761  */
  3762  var outputBlockFormatter = function(block) {
  3763  
  3764      // transform to number
  3765      block.gasLimit = utils.toDecimal(block.gasLimit);
  3766      block.gasUsed = utils.toDecimal(block.gasUsed);
  3767      block.size = utils.toDecimal(block.size);
  3768      block.timestamp = utils.toDecimal(block.timestamp);
  3769      if(block.number !== null)
  3770          block.number = utils.toDecimal(block.number);
  3771  
  3772      block.difficulty = utils.toBigNumber(block.difficulty);
  3773      block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
  3774  
  3775      if (utils.isArray(block.transactions)) {
  3776          block.transactions.forEach(function(item){
  3777              if(!utils.isString(item))
  3778                  return outputTransactionFormatter(item);
  3779          });
  3780      }
  3781  
  3782      return block;
  3783  };
  3784  
  3785  /**
  3786   * Formats the output of a log
  3787   *
  3788   * @method outputLogFormatter
  3789   * @param {Object} log object
  3790   * @returns {Object} log
  3791  */
  3792  var outputLogFormatter = function(log) {
  3793      if(log.blockNumber)
  3794          log.blockNumber = utils.toDecimal(log.blockNumber);
  3795      if(log.transactionIndex)
  3796          log.transactionIndex = utils.toDecimal(log.transactionIndex);
  3797      if(log.logIndex)
  3798          log.logIndex = utils.toDecimal(log.logIndex);
  3799  
  3800      return log;
  3801  };
  3802  
  3803  /**
  3804   * Formats the input of a whisper post and converts all values to HEX
  3805   *
  3806   * @method inputPostFormatter
  3807   * @param {Object} transaction object
  3808   * @returns {Object}
  3809  */
  3810  var inputPostFormatter = function(post) {
  3811  
  3812      // post.payload = utils.toHex(post.payload);
  3813      post.ttl = utils.fromDecimal(post.ttl);
  3814      post.workToProve = utils.fromDecimal(post.workToProve);
  3815      post.priority = utils.fromDecimal(post.priority);
  3816  
  3817      // fallback
  3818      if (!utils.isArray(post.topics)) {
  3819          post.topics = post.topics ? [post.topics] : [];
  3820      }
  3821  
  3822      // format the following options
  3823      post.topics = post.topics.map(function(topic){
  3824          // convert only if not hex
  3825          return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);
  3826      });
  3827  
  3828      return post;
  3829  };
  3830  
  3831  /**
  3832   * Formats the output of a received post message
  3833   *
  3834   * @method outputPostFormatter
  3835   * @param {Object}
  3836   * @returns {Object}
  3837   */
  3838  var outputPostFormatter = function(post){
  3839  
  3840      post.expiry = utils.toDecimal(post.expiry);
  3841      post.sent = utils.toDecimal(post.sent);
  3842      post.ttl = utils.toDecimal(post.ttl);
  3843      post.workProved = utils.toDecimal(post.workProved);
  3844      // post.payloadRaw = post.payload;
  3845      // post.payload = utils.toAscii(post.payload);
  3846  
  3847      // if (utils.isJson(post.payload)) {
  3848      //     post.payload = JSON.parse(post.payload);
  3849      // }
  3850  
  3851      // format the following options
  3852      if (!post.topics) {
  3853          post.topics = [];
  3854      }
  3855      post.topics = post.topics.map(function(topic){
  3856          return utils.toAscii(topic);
  3857      });
  3858  
  3859      return post;
  3860  };
  3861  
  3862  var inputAddressFormatter = function (address) {
  3863      var iban = new Iban(address);
  3864      if (iban.isValid() && iban.isDirect()) {
  3865          return '0x' + iban.address();
  3866      } else if (utils.isStrictAddress(address)) {
  3867          return address;
  3868      } else if (utils.isAddress(address)) {
  3869          return '0x' + address;
  3870      }
  3871      throw new Error('invalid address');
  3872  };
  3873  
  3874  
  3875  var outputSyncingFormatter = function(result) {
  3876      if (!result) {
  3877          return result;
  3878      }
  3879  
  3880      result.startingBlock = utils.toDecimal(result.startingBlock);
  3881      result.currentBlock = utils.toDecimal(result.currentBlock);
  3882      result.highestBlock = utils.toDecimal(result.highestBlock);
  3883      if (result.knownStates) {
  3884          result.knownStates = utils.toDecimal(result.knownStates);
  3885          result.pulledStates = utils.toDecimal(result.pulledStates);
  3886      }
  3887  
  3888      return result;
  3889  };
  3890  
  3891  module.exports = {
  3892      inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
  3893      inputBlockNumberFormatter: inputBlockNumberFormatter,
  3894      inputCallFormatter: inputCallFormatter,
  3895      inputTransactionFormatter: inputTransactionFormatter,
  3896      inputAddressFormatter: inputAddressFormatter,
  3897      inputPostFormatter: inputPostFormatter,
  3898      outputBigNumberFormatter: outputBigNumberFormatter,
  3899      outputTransactionFormatter: outputTransactionFormatter,
  3900      outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
  3901      outputBlockFormatter: outputBlockFormatter,
  3902      outputLogFormatter: outputLogFormatter,
  3903      outputPostFormatter: outputPostFormatter,
  3904      outputSyncingFormatter: outputSyncingFormatter
  3905  };
  3906  
  3907  
  3908  },{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(require,module,exports){
  3909  /*
  3910      This file is part of web3.js.
  3911  
  3912      web3.js is free software: you can redistribute it and/or modify
  3913      it under the terms of the GNU Lesser General Public License as published by
  3914      the Free Software Foundation, either version 3 of the License, or
  3915      (at your option) any later version.
  3916  
  3917      web3.js is distributed in the hope that it will be useful,
  3918      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3919      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3920      GNU Lesser General Public License for more details.
  3921  
  3922      You should have received a copy of the GNU Lesser General Public License
  3923      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3924  */
  3925  /**
  3926   * @file function.js
  3927   * @author Marek Kotewicz <marek@ethdev.com>
  3928   * @date 2015
  3929   */
  3930  
  3931  var coder = require('../solidity/coder');
  3932  var utils = require('../utils/utils');
  3933  var errors = require('./errors');
  3934  var formatters = require('./formatters');
  3935  var sha3 = require('../utils/sha3');
  3936  
  3937  /**
  3938   * This prototype should be used to call/sendTransaction to solidity functions
  3939   */
  3940  var SolidityFunction = function (eth, json, address) {
  3941      this._eth = eth;
  3942      this._inputTypes = json.inputs.map(function (i) {
  3943          return i.type;
  3944      });
  3945      this._outputTypes = json.outputs.map(function (i) {
  3946          return i.type;
  3947      });
  3948      this._constant = json.constant;
  3949      this._payable = json.payable;
  3950      this._name = utils.transformToFullName(json);
  3951      this._address = address;
  3952  };
  3953  
  3954  SolidityFunction.prototype.extractCallback = function (args) {
  3955      if (utils.isFunction(args[args.length - 1])) {
  3956          return args.pop(); // modify the args array!
  3957      }
  3958  };
  3959  
  3960  SolidityFunction.prototype.extractDefaultBlock = function (args) {
  3961      if (args.length > this._inputTypes.length && !utils.isObject(args[args.length -1])) {
  3962          return formatters.inputDefaultBlockNumberFormatter(args.pop()); // modify the args array!
  3963      }
  3964  };
  3965  
  3966  /**
  3967   * Should be called to check if the number of arguments is correct
  3968   *
  3969   * @method validateArgs
  3970   * @param {Array} arguments
  3971   * @throws {Error} if it is not
  3972   */
  3973  SolidityFunction.prototype.validateArgs = function (args) {
  3974      var inputArgs = args.filter(function (a) {
  3975        // filter the options object but not arguments that are arrays
  3976        return !( (utils.isObject(a) === true) &&
  3977                  (utils.isArray(a) === false) &&
  3978                  (utils.isBigNumber(a) === false)
  3979                );
  3980      });
  3981      if (inputArgs.length !== this._inputTypes.length) {
  3982          throw errors.InvalidNumberOfSolidityArgs();
  3983      }
  3984  };
  3985  
  3986  /**
  3987   * Should be used to create payload from arguments
  3988   *
  3989   * @method toPayload
  3990   * @param {Array} solidity function params
  3991   * @param {Object} optional payload options
  3992   */
  3993  SolidityFunction.prototype.toPayload = function (args) {
  3994      var options = {};
  3995      if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
  3996          options = args[args.length - 1];
  3997      }
  3998      this.validateArgs(args);
  3999      options.to = this._address;
  4000      options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
  4001      return options;
  4002  };
  4003  
  4004  /**
  4005   * Should be used to get function signature
  4006   *
  4007   * @method signature
  4008   * @return {String} function signature
  4009   */
  4010  SolidityFunction.prototype.signature = function () {
  4011      return sha3(this._name).slice(0, 8);
  4012  };
  4013  
  4014  
  4015  SolidityFunction.prototype.unpackOutput = function (output) {
  4016      if (!output) {
  4017          return;
  4018      }
  4019  
  4020      output = output.length >= 2 ? output.slice(2) : output;
  4021      var result = coder.decodeParams(this._outputTypes, output);
  4022      return result.length === 1 ? result[0] : result;
  4023  };
  4024  
  4025  /**
  4026   * Calls a contract function.
  4027   *
  4028   * @method call
  4029   * @param {...Object} Contract function arguments
  4030   * @param {function} If the last argument is a function, the contract function
  4031   *   call will be asynchronous, and the callback will be passed the
  4032   *   error and result.
  4033   * @return {String} output bytes
  4034   */
  4035  SolidityFunction.prototype.call = function () {
  4036      var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4037      var callback = this.extractCallback(args);
  4038      var defaultBlock = this.extractDefaultBlock(args);
  4039      var payload = this.toPayload(args);
  4040  
  4041  
  4042      if (!callback) {
  4043          var output = this._eth.call(payload, defaultBlock);
  4044          return this.unpackOutput(output);
  4045      }
  4046  
  4047      var self = this;
  4048      this._eth.call(payload, defaultBlock, function (error, output) {
  4049          if (error) return callback(error, null);
  4050  
  4051          var unpacked = null;
  4052          try {
  4053              unpacked = self.unpackOutput(output);
  4054          }
  4055          catch (e) {
  4056              error = e;
  4057          }
  4058  
  4059          callback(error, unpacked);
  4060      });
  4061  };
  4062  
  4063  /**
  4064   * Should be used to sendTransaction to solidity function
  4065   *
  4066   * @method sendTransaction
  4067   */
  4068  SolidityFunction.prototype.sendTransaction = function () {
  4069      var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4070      var callback = this.extractCallback(args);
  4071      var payload = this.toPayload(args);
  4072  
  4073      if (payload.value > 0 && !this._payable) {
  4074          throw new Error('Cannot send value to non-payable function');
  4075      }
  4076  
  4077      if (!callback) {
  4078          return this._eth.sendTransaction(payload);
  4079      }
  4080  
  4081      this._eth.sendTransaction(payload, callback);
  4082  };
  4083  
  4084  /**
  4085   * Should be used to estimateGas of solidity function
  4086   *
  4087   * @method estimateGas
  4088   */
  4089  SolidityFunction.prototype.estimateGas = function () {
  4090      var args = Array.prototype.slice.call(arguments);
  4091      var callback = this.extractCallback(args);
  4092      var payload = this.toPayload(args);
  4093  
  4094      if (!callback) {
  4095          return this._eth.estimateGas(payload);
  4096      }
  4097  
  4098      this._eth.estimateGas(payload, callback);
  4099  };
  4100  
  4101  /**
  4102   * Return the encoded data of the call
  4103   *
  4104   * @method getData
  4105   * @return {String} the encoded data
  4106   */
  4107  SolidityFunction.prototype.getData = function () {
  4108      var args = Array.prototype.slice.call(arguments);
  4109      var payload = this.toPayload(args);
  4110  
  4111      return payload.data;
  4112  };
  4113  
  4114  /**
  4115   * Should be used to get function display name
  4116   *
  4117   * @method displayName
  4118   * @return {String} display name of the function
  4119   */
  4120  SolidityFunction.prototype.displayName = function () {
  4121      return utils.extractDisplayName(this._name);
  4122  };
  4123  
  4124  /**
  4125   * Should be used to get function type name
  4126   *
  4127   * @method typeName
  4128   * @return {String} type name of the function
  4129   */
  4130  SolidityFunction.prototype.typeName = function () {
  4131      return utils.extractTypeName(this._name);
  4132  };
  4133  
  4134  /**
  4135   * Should be called to get rpc requests from solidity function
  4136   *
  4137   * @method request
  4138   * @returns {Object}
  4139   */
  4140  SolidityFunction.prototype.request = function () {
  4141      var args = Array.prototype.slice.call(arguments);
  4142      var callback = this.extractCallback(args);
  4143      var payload = this.toPayload(args);
  4144      var format = this.unpackOutput.bind(this);
  4145  
  4146      return {
  4147          method: this._constant ? 'eth_call' : 'eth_sendTransaction',
  4148          callback: callback,
  4149          params: [payload],
  4150          format: format
  4151      };
  4152  };
  4153  
  4154  /**
  4155   * Should be called to execute function
  4156   *
  4157   * @method execute
  4158   */
  4159  SolidityFunction.prototype.execute = function () {
  4160      var transaction = !this._constant;
  4161  
  4162      // send transaction
  4163      if (transaction) {
  4164          return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
  4165      }
  4166  
  4167      // call
  4168      return this.call.apply(this, Array.prototype.slice.call(arguments));
  4169  };
  4170  
  4171  /**
  4172   * Should be called to attach function to contract
  4173   *
  4174   * @method attachToContract
  4175   * @param {Contract}
  4176   */
  4177  SolidityFunction.prototype.attachToContract = function (contract) {
  4178      var execute = this.execute.bind(this);
  4179      execute.request = this.request.bind(this);
  4180      execute.call = this.call.bind(this);
  4181      execute.sendTransaction = this.sendTransaction.bind(this);
  4182      execute.estimateGas = this.estimateGas.bind(this);
  4183      execute.getData = this.getData.bind(this);
  4184      var displayName = this.displayName();
  4185      if (!contract[displayName]) {
  4186          contract[displayName] = execute;
  4187      }
  4188      contract[displayName][this.typeName()] = execute; // circular!!!!
  4189  };
  4190  
  4191  module.exports = SolidityFunction;
  4192  
  4193  },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./errors":26,"./formatters":30}],32:[function(require,module,exports){
  4194  /*
  4195      This file is part of web3.js.
  4196  
  4197      web3.js is free software: you can redistribute it and/or modify
  4198      it under the terms of the GNU Lesser General Public License as published by
  4199      the Free Software Foundation, either version 3 of the License, or
  4200      (at your option) any later version.
  4201  
  4202      web3.js is distributed in the hope that it will be useful,
  4203      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4204      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4205      GNU Lesser General Public License for more details.
  4206  
  4207      You should have received a copy of the GNU Lesser General Public License
  4208      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4209  */
  4210  /** @file httpprovider.js
  4211   * @authors:
  4212   *   Marek Kotewicz <marek@ethdev.com>
  4213   *   Marian Oancea <marian@ethdev.com>
  4214   *   Fabian Vogelsteller <fabian@ethdev.com>
  4215   * @date 2015
  4216   */
  4217  
  4218  var errors = require('./errors');
  4219  
  4220  // workaround to use httpprovider in different envs
  4221  
  4222  // browser
  4223  if (typeof window !== 'undefined' && window.XMLHttpRequest) {
  4224    XMLHttpRequest = window.XMLHttpRequest; // jshint ignore: line
  4225  // node
  4226  } else {
  4227    XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore: line
  4228  }
  4229  
  4230  var XHR2 = require('xhr2'); // jshint ignore: line
  4231  
  4232  /**
  4233   * HttpProvider should be used to send rpc calls over http
  4234   */
  4235  var HttpProvider = function (host, timeout, user, password) {
  4236    this.host = host || 'http://localhost:8545';
  4237    this.timeout = timeout || 0;
  4238    this.user = user;
  4239    this.password = password;
  4240  };
  4241  
  4242  /**
  4243   * Should be called to prepare new XMLHttpRequest
  4244   *
  4245   * @method prepareRequest
  4246   * @param {Boolean} true if request should be async
  4247   * @return {XMLHttpRequest} object
  4248   */
  4249  HttpProvider.prototype.prepareRequest = function (async) {
  4250    var request;
  4251  
  4252    if (async) {
  4253      request = new XHR2();
  4254      request.timeout = this.timeout;
  4255    } else {
  4256      request = new XMLHttpRequest();
  4257    }
  4258  
  4259    request.open('POST', this.host, async);
  4260    if (this.user && this.password) {
  4261      var auth = 'Basic ' + new Buffer(this.user + ':' + this.password).toString('base64');
  4262      request.setRequestHeader('Authorization', auth);
  4263    } request.setRequestHeader('Content-Type', 'application/json');
  4264    return request;
  4265  };
  4266  
  4267  /**
  4268   * Should be called to make sync request
  4269   *
  4270   * @method send
  4271   * @param {Object} payload
  4272   * @return {Object} result
  4273   */
  4274  HttpProvider.prototype.send = function (payload) {
  4275    var request = this.prepareRequest(false);
  4276  
  4277    try {
  4278      request.send(JSON.stringify(payload));
  4279    } catch (error) {
  4280      throw errors.InvalidConnection(this.host);
  4281    }
  4282  
  4283    var result = request.responseText;
  4284  
  4285    try {
  4286      result = JSON.parse(result);
  4287    } catch (e) {
  4288      throw errors.InvalidResponse(request.responseText);
  4289    }
  4290  
  4291    return result;
  4292  };
  4293  
  4294  /**
  4295   * Should be used to make async request
  4296   *
  4297   * @method sendAsync
  4298   * @param {Object} payload
  4299   * @param {Function} callback triggered on end with (err, result)
  4300   */
  4301  HttpProvider.prototype.sendAsync = function (payload, callback) {
  4302    var request = this.prepareRequest(true);
  4303  
  4304    request.onreadystatechange = function () {
  4305      if (request.readyState === 4 && request.timeout !== 1) {
  4306        var result = request.responseText;
  4307        var error = null;
  4308  
  4309        try {
  4310          result = JSON.parse(result);
  4311        } catch (e) {
  4312          error = errors.InvalidResponse(request.responseText);
  4313        }
  4314  
  4315        callback(error, result);
  4316      }
  4317    };
  4318  
  4319    request.ontimeout = function () {
  4320      callback(errors.ConnectionTimeout(this.timeout));
  4321    };
  4322  
  4323    try {
  4324      request.send(JSON.stringify(payload));
  4325    } catch (error) {
  4326      callback(errors.InvalidConnection(this.host));
  4327    }
  4328  };
  4329  
  4330  /**
  4331   * Synchronously tries to make Http request
  4332   *
  4333   * @method isConnected
  4334   * @return {Boolean} returns true if request haven't failed. Otherwise false
  4335   */
  4336  HttpProvider.prototype.isConnected = function () {
  4337    try {
  4338      this.send({
  4339        id: 9999999999,
  4340        jsonrpc: '2.0',
  4341        method: 'net_listening',
  4342        params: []
  4343      });
  4344      return true;
  4345    } catch (e) {
  4346      return false;
  4347    }
  4348  };
  4349  
  4350  module.exports = HttpProvider;
  4351  
  4352  },{"./errors":26,"xhr2":86,"xmlhttprequest":17}],33:[function(require,module,exports){
  4353  /*
  4354      This file is part of web3.js.
  4355  
  4356      web3.js is free software: you can redistribute it and/or modify
  4357      it under the terms of the GNU Lesser General Public License as published by
  4358      the Free Software Foundation, either version 3 of the License, or
  4359      (at your option) any later version.
  4360  
  4361      web3.js is distributed in the hope that it will be useful,
  4362      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4363      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4364      GNU Lesser General Public License for more details.
  4365  
  4366      You should have received a copy of the GNU Lesser General Public License
  4367      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4368  */
  4369  /** 
  4370   * @file iban.js
  4371   * @author Marek Kotewicz <marek@ethdev.com>
  4372   * @date 2015
  4373   */
  4374  
  4375  var BigNumber = require('bignumber.js');
  4376  
  4377  var padLeft = function (string, bytes) {
  4378      var result = string;
  4379      while (result.length < bytes * 2) {
  4380          result = '0' + result;
  4381      }
  4382      return result;
  4383  };
  4384  
  4385  /**
  4386   * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to
  4387   * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.
  4388   *
  4389   * @method iso13616Prepare
  4390   * @param {String} iban the IBAN
  4391   * @returns {String} the prepared IBAN
  4392   */
  4393  var iso13616Prepare = function (iban) {
  4394      var A = 'A'.charCodeAt(0);
  4395      var Z = 'Z'.charCodeAt(0);
  4396  
  4397      iban = iban.toUpperCase();
  4398      iban = iban.substr(4) + iban.substr(0,4);
  4399  
  4400      return iban.split('').map(function(n){
  4401          var code = n.charCodeAt(0);
  4402          if (code >= A && code <= Z){
  4403              // A = 10, B = 11, ... Z = 35
  4404              return code - A + 10;
  4405          } else {
  4406              return n;
  4407          }
  4408      }).join('');
  4409  };
  4410  
  4411  /**
  4412   * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064.
  4413   *
  4414   * @method mod9710
  4415   * @param {String} iban
  4416   * @returns {Number}
  4417   */
  4418  var mod9710 = function (iban) {
  4419      var remainder = iban,
  4420          block;
  4421  
  4422      while (remainder.length > 2){
  4423          block = remainder.slice(0, 9);
  4424          remainder = parseInt(block, 10) % 97 + remainder.slice(block.length);
  4425      }
  4426  
  4427      return parseInt(remainder, 10) % 97;
  4428  };
  4429  
  4430  /**
  4431   * This prototype should be used to create iban object from iban correct string
  4432   *
  4433   * @param {String} iban
  4434   */
  4435  var Iban = function (iban) {
  4436      this._iban = iban;
  4437  };
  4438  
  4439  /**
  4440   * This method should be used to create iban object from sberex address
  4441   *
  4442   * @method fromAddress
  4443   * @param {String} address
  4444   * @return {Iban} the IBAN object
  4445   */
  4446  Iban.fromAddress = function (address) {
  4447      var asBn = new BigNumber(address, 16);
  4448      var base36 = asBn.toString(36);
  4449      var padded = padLeft(base36, 15);
  4450      return Iban.fromBban(padded.toUpperCase());
  4451  };
  4452  
  4453  /**
  4454   * Convert the passed BBAN to an IBAN for this country specification.
  4455   * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>.
  4456   * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
  4457   *
  4458   * @method fromBban
  4459   * @param {String} bban the BBAN to convert to IBAN
  4460   * @returns {Iban} the IBAN object
  4461   */
  4462  Iban.fromBban = function (bban) {
  4463      var countryCode = 'XE';
  4464  
  4465      var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban));
  4466      var checkDigit = ('0' + (98 - remainder)).slice(-2);
  4467  
  4468      return new Iban(countryCode + checkDigit + bban);
  4469  };
  4470  
  4471  /**
  4472   * Should be used to create IBAN object for given institution and identifier
  4473   *
  4474   * @method createIndirect
  4475   * @param {Object} options, required options are "institution" and "identifier"
  4476   * @return {Iban} the IBAN object
  4477   */
  4478  Iban.createIndirect = function (options) {
  4479      return Iban.fromBban('ETH' + options.institution + options.identifier);
  4480  };
  4481  
  4482  /**
  4483   * Thos method should be used to check if given string is valid iban object
  4484   *
  4485   * @method isValid
  4486   * @param {String} iban string
  4487   * @return {Boolean} true if it is valid IBAN
  4488   */
  4489  Iban.isValid = function (iban) {
  4490      var i = new Iban(iban);
  4491      return i.isValid();
  4492  };
  4493  
  4494  /**
  4495   * Should be called to check if iban is correct
  4496   *
  4497   * @method isValid
  4498   * @returns {Boolean} true if it is, otherwise false
  4499   */
  4500  Iban.prototype.isValid = function () {
  4501      return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) &&
  4502          mod9710(iso13616Prepare(this._iban)) === 1;
  4503  };
  4504  
  4505  /**
  4506   * Should be called to check if iban number is direct
  4507   *
  4508   * @method isDirect
  4509   * @returns {Boolean} true if it is, otherwise false
  4510   */
  4511  Iban.prototype.isDirect = function () {
  4512      return this._iban.length === 34 || this._iban.length === 35;
  4513  };
  4514  
  4515  /**
  4516   * Should be called to check if iban number if indirect
  4517   *
  4518   * @method isIndirect
  4519   * @returns {Boolean} true if it is, otherwise false
  4520   */
  4521  Iban.prototype.isIndirect = function () {
  4522      return this._iban.length === 20;
  4523  };
  4524  
  4525  /**
  4526   * Should be called to get iban checksum
  4527   * Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
  4528   *
  4529   * @method checksum
  4530   * @returns {String} checksum
  4531   */
  4532  Iban.prototype.checksum = function () {
  4533      return this._iban.substr(2, 2);
  4534  };
  4535  
  4536  /**
  4537   * Should be called to get institution identifier
  4538   * eg. XREG
  4539   *
  4540   * @method institution
  4541   * @returns {String} institution identifier
  4542   */
  4543  Iban.prototype.institution = function () {
  4544      return this.isIndirect() ? this._iban.substr(7, 4) : '';
  4545  };
  4546  
  4547  /**
  4548   * Should be called to get client identifier within institution
  4549   * eg. GAVOFYORK
  4550   *
  4551   * @method client
  4552   * @returns {String} client identifier
  4553   */
  4554  Iban.prototype.client = function () {
  4555      return this.isIndirect() ? this._iban.substr(11) : '';
  4556  };
  4557  
  4558  /**
  4559   * Should be called to get client direct address
  4560   *
  4561   * @method address
  4562   * @returns {String} client direct address
  4563   */
  4564  Iban.prototype.address = function () {
  4565      if (this.isDirect()) {
  4566          var base36 = this._iban.substr(4);
  4567          var asBn = new BigNumber(base36, 36);
  4568          return padLeft(asBn.toString(16), 20);
  4569      } 
  4570  
  4571      return '';
  4572  };
  4573  
  4574  Iban.prototype.toString = function () {
  4575      return this._iban;
  4576  };
  4577  
  4578  module.exports = Iban;
  4579  
  4580  
  4581  },{"bignumber.js":"bignumber.js"}],34:[function(require,module,exports){
  4582  /*
  4583      This file is part of web3.js.
  4584  
  4585      web3.js is free software: you can redistribute it and/or modify
  4586      it under the terms of the GNU Lesser General Public License as published by
  4587      the Free Software Foundation, either version 3 of the License, or
  4588      (at your option) any later version.
  4589  
  4590      web3.js is distributed in the hope that it will be useful,
  4591      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4592      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4593      GNU Lesser General Public License for more details.
  4594  
  4595      You should have received a copy of the GNU Lesser General Public License
  4596      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4597  */
  4598  /** @file ipcprovider.js
  4599   * @authors:
  4600   *   Fabian Vogelsteller <fabian@ethdev.com>
  4601   * @date 2015
  4602   */
  4603  
  4604  "use strict";
  4605  
  4606  var utils = require('../utils/utils');
  4607  var errors = require('./errors');
  4608  
  4609  
  4610  var IpcProvider = function (path, net) {
  4611      var _this = this;
  4612      this.responseCallbacks = {};
  4613      this.path = path;
  4614      
  4615      this.connection = net.connect({path: this.path});
  4616  
  4617      this.connection.on('error', function(e){
  4618          console.error('IPC Connection Error', e);
  4619          _this._timeout();
  4620      });
  4621  
  4622      this.connection.on('end', function(){
  4623          _this._timeout();
  4624      }); 
  4625  
  4626  
  4627      // LISTEN FOR CONNECTION RESPONSES
  4628      this.connection.on('data', function(data) {
  4629          /*jshint maxcomplexity: 6 */
  4630  
  4631          _this._parseResponse(data.toString()).forEach(function(result){
  4632  
  4633              var id = null;
  4634  
  4635              // get the id which matches the returned id
  4636              if(utils.isArray(result)) {
  4637                  result.forEach(function(load){
  4638                      if(_this.responseCallbacks[load.id])
  4639                          id = load.id;
  4640                  });
  4641              } else {
  4642                  id = result.id;
  4643              }
  4644  
  4645              // fire the callback
  4646              if(_this.responseCallbacks[id]) {
  4647                  _this.responseCallbacks[id](null, result);
  4648                  delete _this.responseCallbacks[id];
  4649              }
  4650          });
  4651      });
  4652  };
  4653  
  4654  /**
  4655  Will parse the response and make an array out of it.
  4656  
  4657  @method _parseResponse
  4658  @param {String} data
  4659  */
  4660  IpcProvider.prototype._parseResponse = function(data) {
  4661      var _this = this,
  4662          returnValues = [];
  4663      
  4664      // DE-CHUNKER
  4665      var dechunkedData = data
  4666          .replace(/\}[\n\r]?\{/g,'}|--|{') // }{
  4667          .replace(/\}\][\n\r]?\[\{/g,'}]|--|[{') // }][{
  4668          .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{
  4669          .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{
  4670          .split('|--|');
  4671  
  4672      dechunkedData.forEach(function(data){
  4673  
  4674          // prepend the last chunk
  4675          if(_this.lastChunk)
  4676              data = _this.lastChunk + data;
  4677  
  4678          var result = null;
  4679  
  4680          try {
  4681              result = JSON.parse(data);
  4682  
  4683          } catch(e) {
  4684  
  4685              _this.lastChunk = data;
  4686  
  4687              // start timeout to cancel all requests
  4688              clearTimeout(_this.lastChunkTimeout);
  4689              _this.lastChunkTimeout = setTimeout(function(){
  4690                  _this._timeout();
  4691                  throw errors.InvalidResponse(data);
  4692              }, 1000 * 15);
  4693  
  4694              return;
  4695          }
  4696  
  4697          // cancel timeout and set chunk to null
  4698          clearTimeout(_this.lastChunkTimeout);
  4699          _this.lastChunk = null;
  4700  
  4701          if(result)
  4702              returnValues.push(result);
  4703      });
  4704  
  4705      return returnValues;
  4706  };
  4707  
  4708  
  4709  /**
  4710  Get the adds a callback to the responseCallbacks object,
  4711  which will be called if a response matching the response Id will arrive.
  4712  
  4713  @method _addResponseCallback
  4714  */
  4715  IpcProvider.prototype._addResponseCallback = function(payload, callback) {
  4716      var id = payload.id || payload[0].id;
  4717      var method = payload.method || payload[0].method;
  4718  
  4719      this.responseCallbacks[id] = callback;
  4720      this.responseCallbacks[id].method = method;
  4721  };
  4722  
  4723  /**
  4724  Timeout all requests when the end/error event is fired
  4725  
  4726  @method _timeout
  4727  */
  4728  IpcProvider.prototype._timeout = function() {
  4729      for(var key in this.responseCallbacks) {
  4730          if(this.responseCallbacks.hasOwnProperty(key)){
  4731              this.responseCallbacks[key](errors.InvalidConnection('on IPC'));
  4732              delete this.responseCallbacks[key];
  4733          }
  4734      }
  4735  };
  4736  
  4737  
  4738  /**
  4739  Check if the current connection is still valid.
  4740  
  4741  @method isConnected
  4742  */
  4743  IpcProvider.prototype.isConnected = function() {
  4744      var _this = this;
  4745  
  4746      // try reconnect, when connection is gone
  4747      if(!_this.connection.writable)
  4748          _this.connection.connect({path: _this.path});
  4749  
  4750      return !!this.connection.writable;
  4751  };
  4752  
  4753  IpcProvider.prototype.send = function (payload) {
  4754  
  4755      if(this.connection.writeSync) {
  4756          var result;
  4757  
  4758          // try reconnect, when connection is gone
  4759          if(!this.connection.writable)
  4760              this.connection.connect({path: this.path});
  4761  
  4762          var data = this.connection.writeSync(JSON.stringify(payload));
  4763  
  4764          try {
  4765              result = JSON.parse(data);
  4766          } catch(e) {
  4767              throw errors.InvalidResponse(data);                
  4768          }
  4769  
  4770          return result;
  4771  
  4772      } else {
  4773          throw new Error('You tried to send "'+ payload.method +'" synchronously. Synchronous requests are not supported by the IPC provider.');
  4774      }
  4775  };
  4776  
  4777  IpcProvider.prototype.sendAsync = function (payload, callback) {
  4778      // try reconnect, when connection is gone
  4779      if(!this.connection.writable)
  4780          this.connection.connect({path: this.path});
  4781  
  4782  
  4783      this.connection.write(JSON.stringify(payload));
  4784      this._addResponseCallback(payload, callback);
  4785  };
  4786  
  4787  module.exports = IpcProvider;
  4788  
  4789  
  4790  },{"../utils/utils":20,"./errors":26}],35:[function(require,module,exports){
  4791  /*
  4792      This file is part of web3.js.
  4793  
  4794      web3.js is free software: you can redistribute it and/or modify
  4795      it under the terms of the GNU Lesser General Public License as published by
  4796      the Free Software Foundation, either version 3 of the License, or
  4797      (at your option) any later version.
  4798  
  4799      web3.js is distributed in the hope that it will be useful,
  4800      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4801      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4802      GNU Lesser General Public License for more details.
  4803  
  4804      You should have received a copy of the GNU Lesser General Public License
  4805      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4806  */
  4807  /** @file jsonrpc.js
  4808   * @authors:
  4809   *   Marek Kotewicz <marek@ethdev.com>
  4810   *   Aaron Kumavis <aaron@kumavis.me>
  4811   * @date 2015
  4812   */
  4813  
  4814  // Initialize Jsonrpc as a simple object with utility functions.
  4815  var Jsonrpc = {
  4816      messageId: 0
  4817  };
  4818  
  4819  /**
  4820   * Should be called to valid json create payload object
  4821   *
  4822   * @method toPayload
  4823   * @param {Function} method of jsonrpc call, required
  4824   * @param {Array} params, an array of method params, optional
  4825   * @returns {Object} valid jsonrpc payload object
  4826   */
  4827  Jsonrpc.toPayload = function (method, params) {
  4828      if (!method)
  4829          console.error('jsonrpc method should be specified!');
  4830  
  4831      // advance message ID
  4832      Jsonrpc.messageId++;
  4833  
  4834      return {
  4835          jsonrpc: '2.0',
  4836          id: Jsonrpc.messageId,
  4837          method: method,
  4838          params: params || []
  4839      };
  4840  };
  4841  
  4842  /**
  4843   * Should be called to check if jsonrpc response is valid
  4844   *
  4845   * @method isValidResponse
  4846   * @param {Object}
  4847   * @returns {Boolean} true if response is valid, otherwise false
  4848   */
  4849  Jsonrpc.isValidResponse = function (response) {
  4850      return Array.isArray(response) ? response.every(validateSingleMessage) : validateSingleMessage(response);
  4851  
  4852      function validateSingleMessage(message){
  4853        return !!message &&
  4854          !message.error &&
  4855          message.jsonrpc === '2.0' &&
  4856          typeof message.id === 'number' &&
  4857          message.result !== undefined; // only undefined is not valid json object
  4858      }
  4859  };
  4860  
  4861  /**
  4862   * Should be called to create batch payload object
  4863   *
  4864   * @method toBatchPayload
  4865   * @param {Array} messages, an array of objects with method (required) and params (optional) fields
  4866   * @returns {Array} batch payload
  4867   */
  4868  Jsonrpc.toBatchPayload = function (messages) {
  4869      return messages.map(function (message) {
  4870          return Jsonrpc.toPayload(message.method, message.params);
  4871      });
  4872  };
  4873  
  4874  module.exports = Jsonrpc;
  4875  
  4876  
  4877  },{}],36:[function(require,module,exports){
  4878  /*
  4879      This file is part of web3.js.
  4880  
  4881      web3.js is free software: you can redistribute it and/or modify
  4882      it under the terms of the GNU Lesser General Public License as published by
  4883      the Free Software Foundation, either version 3 of the License, or
  4884      (at your option) any later version.
  4885  
  4886      web3.js is distributed in the hope that it will be useful,
  4887      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4888      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4889      GNU Lesser General Public License for more details.
  4890  
  4891      You should have received a copy of the GNU Lesser General Public License
  4892      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4893  */
  4894  /**
  4895   * @file method.js
  4896   * @author Marek Kotewicz <marek@ethdev.com>
  4897   * @date 2015
  4898   */
  4899  
  4900  var utils = require('../utils/utils');
  4901  var errors = require('./errors');
  4902  
  4903  var Method = function (options) {
  4904      this.name = options.name;
  4905      this.call = options.call;
  4906      this.params = options.params || 0;
  4907      this.inputFormatter = options.inputFormatter;
  4908      this.outputFormatter = options.outputFormatter;
  4909      this.requestManager = null;
  4910  };
  4911  
  4912  Method.prototype.setRequestManager = function (rm) {
  4913      this.requestManager = rm;
  4914  };
  4915  
  4916  /**
  4917   * Should be used to determine name of the jsonrpc method based on arguments
  4918   *
  4919   * @method getCall
  4920   * @param {Array} arguments
  4921   * @return {String} name of jsonrpc method
  4922   */
  4923  Method.prototype.getCall = function (args) {
  4924      return utils.isFunction(this.call) ? this.call(args) : this.call;
  4925  };
  4926  
  4927  /**
  4928   * Should be used to extract callback from array of arguments. Modifies input param
  4929   *
  4930   * @method extractCallback
  4931   * @param {Array} arguments
  4932   * @return {Function|Null} callback, if exists
  4933   */
  4934  Method.prototype.extractCallback = function (args) {
  4935      if (utils.isFunction(args[args.length - 1])) {
  4936          return args.pop(); // modify the args array!
  4937      }
  4938  };
  4939  
  4940  /**
  4941   * Should be called to check if the number of arguments is correct
  4942   * 
  4943   * @method validateArgs
  4944   * @param {Array} arguments
  4945   * @throws {Error} if it is not
  4946   */
  4947  Method.prototype.validateArgs = function (args) {
  4948      if (args.length !== this.params) {
  4949          throw errors.InvalidNumberOfRPCParams();
  4950      }
  4951  };
  4952  
  4953  /**
  4954   * Should be called to format input args of method
  4955   * 
  4956   * @method formatInput
  4957   * @param {Array}
  4958   * @return {Array}
  4959   */
  4960  Method.prototype.formatInput = function (args) {
  4961      if (!this.inputFormatter) {
  4962          return args;
  4963      }
  4964  
  4965      return this.inputFormatter.map(function (formatter, index) {
  4966          return formatter ? formatter(args[index]) : args[index];
  4967      });
  4968  };
  4969  
  4970  /**
  4971   * Should be called to format output(result) of method
  4972   *
  4973   * @method formatOutput
  4974   * @param {Object}
  4975   * @return {Object}
  4976   */
  4977  Method.prototype.formatOutput = function (result) {
  4978      return this.outputFormatter && result ? this.outputFormatter(result) : result;
  4979  };
  4980  
  4981  /**
  4982   * Should create payload from given input args
  4983   *
  4984   * @method toPayload
  4985   * @param {Array} args
  4986   * @return {Object}
  4987   */
  4988  Method.prototype.toPayload = function (args) {
  4989      var call = this.getCall(args);
  4990      var callback = this.extractCallback(args);
  4991      var params = this.formatInput(args);
  4992      this.validateArgs(params);
  4993  
  4994      return {
  4995          method: call,
  4996          params: params,
  4997          callback: callback
  4998      };
  4999  };
  5000  
  5001  Method.prototype.attachToObject = function (obj) {
  5002      var func = this.buildCall();
  5003      func.call = this.call; // TODO!!! that's ugly. filter.js uses it
  5004      var name = this.name.split('.');
  5005      if (name.length > 1) {
  5006          obj[name[0]] = obj[name[0]] || {};
  5007          obj[name[0]][name[1]] = func;
  5008      } else {
  5009          obj[name[0]] = func; 
  5010      }
  5011  };
  5012  
  5013  Method.prototype.buildCall = function() {
  5014      var method = this;
  5015      var send = function () {
  5016          var payload = method.toPayload(Array.prototype.slice.call(arguments));
  5017          if (payload.callback) {
  5018              return method.requestManager.sendAsync(payload, function (err, result) {
  5019                  payload.callback(err, method.formatOutput(result));
  5020              });
  5021          }
  5022          return method.formatOutput(method.requestManager.send(payload));
  5023      };
  5024      send.request = this.request.bind(this);
  5025      return send;
  5026  };
  5027  
  5028  /**
  5029   * Should be called to create pure JSONRPC request which can be used in batch request
  5030   *
  5031   * @method request
  5032   * @param {...} params
  5033   * @return {Object} jsonrpc request
  5034   */
  5035  Method.prototype.request = function () {
  5036      var payload = this.toPayload(Array.prototype.slice.call(arguments));
  5037      payload.format = this.formatOutput.bind(this);
  5038      return payload;
  5039  };
  5040  
  5041  module.exports = Method;
  5042  
  5043  },{"../utils/utils":20,"./errors":26}],37:[function(require,module,exports){
  5044  /*
  5045      This file is part of web3.js.
  5046  
  5047      web3.js is free software: you can redistribute it and/or modify
  5048      it under the terms of the GNU Lesser General Public License as published by
  5049      the Free Software Foundation, either version 3 of the License, or
  5050      (at your option) any later version.
  5051  
  5052      web3.js is distributed in the hope that it will be useful,
  5053      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5054      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5055      GNU Lesser General Public License for more details.
  5056  
  5057      You should have received a copy of the GNU Lesser General Public License
  5058      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5059  */
  5060  /** @file db.js
  5061   * @authors:
  5062   *   Marek Kotewicz <marek@ethdev.com>
  5063   * @date 2015
  5064   */
  5065  
  5066  var Method = require('../method');
  5067  
  5068  var DB = function (web3) {
  5069      this._requestManager = web3._requestManager;
  5070  
  5071      var self = this;
  5072      
  5073      methods().forEach(function(method) { 
  5074          method.attachToObject(self);
  5075          method.setRequestManager(web3._requestManager);
  5076      });
  5077  };
  5078  
  5079  var methods = function () {
  5080      var putString = new Method({
  5081          name: 'putString',
  5082          call: 'db_putString',
  5083          params: 3
  5084      });
  5085  
  5086      var getString = new Method({
  5087          name: 'getString',
  5088          call: 'db_getString',
  5089          params: 2
  5090      });
  5091  
  5092      var putHex = new Method({
  5093          name: 'putHex',
  5094          call: 'db_putHex',
  5095          params: 3
  5096      });
  5097  
  5098      var getHex = new Method({
  5099          name: 'getHex',
  5100          call: 'db_getHex',
  5101          params: 2
  5102      });
  5103  
  5104      return [
  5105          putString, getString, putHex, getHex
  5106      ];
  5107  };
  5108  
  5109  module.exports = DB;
  5110  
  5111  },{"../method":36}],38:[function(require,module,exports){
  5112  /*
  5113      This file is part of web3.js.
  5114  
  5115      web3.js is free software: you can redistribute it and/or modify
  5116      it under the terms of the GNU Lesser General Public License as published by
  5117      the Free Software Foundation, either version 3 of the License, or
  5118      (at your option) any later version.
  5119  
  5120      web3.js is distributed in the hope that it will be useful,
  5121      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5122      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5123      GNU Lesser General Public License for more details.
  5124  
  5125      You should have received a copy of the GNU Lesser General Public License
  5126      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5127  */
  5128  /**
  5129   * @file eth.js
  5130   * @author Marek Kotewicz <marek@ethdev.com>
  5131   * @author Fabian Vogelsteller <fabian@ethdev.com>
  5132   * @date 2015
  5133   */
  5134  
  5135  "use strict";
  5136  
  5137  var formatters = require('../formatters');
  5138  var utils = require('../../utils/utils');
  5139  var Method = require('../method');
  5140  var Property = require('../property');
  5141  var c = require('../../utils/config');
  5142  var Contract = require('../contract');
  5143  var watches = require('./watches');
  5144  var Filter = require('../filter');
  5145  var IsSyncing = require('../syncing');
  5146  var namereg = require('../namereg');
  5147  var Iban = require('../iban');
  5148  var transfer = require('../transfer');
  5149  
  5150  var blockCall = function (args) {
  5151      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
  5152  };
  5153  
  5154  var transactionFromBlockCall = function (args) {
  5155      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
  5156  };
  5157  
  5158  var uncleCall = function (args) {
  5159      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
  5160  };
  5161  
  5162  var getBlockTransactionCountCall = function (args) {
  5163      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
  5164  };
  5165  
  5166  var uncleCountCall = function (args) {
  5167      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
  5168  };
  5169  
  5170  function Eth(web3) {
  5171      this._requestManager = web3._requestManager;
  5172  
  5173      var self = this;
  5174  
  5175      methods().forEach(function(method) {
  5176          method.attachToObject(self);
  5177          method.setRequestManager(self._requestManager);
  5178      });
  5179  
  5180      properties().forEach(function(p) {
  5181          p.attachToObject(self);
  5182          p.setRequestManager(self._requestManager);
  5183      });
  5184  
  5185  
  5186      this.iban = Iban;
  5187      this.sendIBANTransaction = transfer.bind(null, this);
  5188  }
  5189  
  5190  Object.defineProperty(Eth.prototype, 'defaultBlock', {
  5191      get: function () {
  5192          return c.defaultBlock;
  5193      },
  5194      set: function (val) {
  5195          c.defaultBlock = val;
  5196          return val;
  5197      }
  5198  });
  5199  
  5200  Object.defineProperty(Eth.prototype, 'defaultAccount', {
  5201      get: function () {
  5202          return c.defaultAccount;
  5203      },
  5204      set: function (val) {
  5205          c.defaultAccount = val;
  5206          return val;
  5207      }
  5208  });
  5209  
  5210  var methods = function () {
  5211      var getBalance = new Method({
  5212          name: 'getBalance',
  5213          call: 'eth_getBalance',
  5214          params: 2,
  5215          inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
  5216          outputFormatter: formatters.outputBigNumberFormatter
  5217      });
  5218  
  5219      var getStorageAt = new Method({
  5220          name: 'getStorageAt',
  5221          call: 'eth_getStorageAt',
  5222          params: 3,
  5223          inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
  5224      });
  5225  
  5226      var getCode = new Method({
  5227          name: 'getCode',
  5228          call: 'eth_getCode',
  5229          params: 2,
  5230          inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
  5231      });
  5232  
  5233      var getBlock = new Method({
  5234          name: 'getBlock',
  5235          call: blockCall,
  5236          params: 2,
  5237          inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
  5238          outputFormatter: formatters.outputBlockFormatter
  5239      });
  5240  
  5241      var getUncle = new Method({
  5242          name: 'getUncle',
  5243          call: uncleCall,
  5244          params: 2,
  5245          inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5246          outputFormatter: formatters.outputBlockFormatter,
  5247  
  5248      });
  5249  
  5250      var getCompilers = new Method({
  5251          name: 'getCompilers',
  5252          call: 'eth_getCompilers',
  5253          params: 0
  5254      });
  5255  
  5256      var getBlockTransactionCount = new Method({
  5257          name: 'getBlockTransactionCount',
  5258          call: getBlockTransactionCountCall,
  5259          params: 1,
  5260          inputFormatter: [formatters.inputBlockNumberFormatter],
  5261          outputFormatter: utils.toDecimal
  5262      });
  5263  
  5264      var getBlockUncleCount = new Method({
  5265          name: 'getBlockUncleCount',
  5266          call: uncleCountCall,
  5267          params: 1,
  5268          inputFormatter: [formatters.inputBlockNumberFormatter],
  5269          outputFormatter: utils.toDecimal
  5270      });
  5271  
  5272      var getTransaction = new Method({
  5273          name: 'getTransaction',
  5274          call: 'eth_getTransactionByHash',
  5275          params: 1,
  5276          outputFormatter: formatters.outputTransactionFormatter
  5277      });
  5278  
  5279      var getTransactionFromBlock = new Method({
  5280          name: 'getTransactionFromBlock',
  5281          call: transactionFromBlockCall,
  5282          params: 2,
  5283          inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5284          outputFormatter: formatters.outputTransactionFormatter
  5285      });
  5286  
  5287      var getTransactionReceipt = new Method({
  5288          name: 'getTransactionReceipt',
  5289          call: 'eth_getTransactionReceipt',
  5290          params: 1,
  5291          outputFormatter: formatters.outputTransactionReceiptFormatter
  5292      });
  5293  
  5294      var getTransactionCount = new Method({
  5295          name: 'getTransactionCount',
  5296          call: 'eth_getTransactionCount',
  5297          params: 2,
  5298          inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
  5299          outputFormatter: utils.toDecimal
  5300      });
  5301  
  5302      var sendRawTransaction = new Method({
  5303          name: 'sendRawTransaction',
  5304          call: 'eth_sendRawTransaction',
  5305          params: 1,
  5306          inputFormatter: [null]
  5307      });
  5308  
  5309      var sendTransaction = new Method({
  5310          name: 'sendTransaction',
  5311          call: 'eth_sendTransaction',
  5312          params: 1,
  5313          inputFormatter: [formatters.inputTransactionFormatter]
  5314      });
  5315  
  5316      var signTransaction = new Method({
  5317          name: 'signTransaction',
  5318          call: 'eth_signTransaction',
  5319          params: 1,
  5320          inputFormatter: [formatters.inputTransactionFormatter]
  5321      });
  5322  
  5323      var sign = new Method({
  5324          name: 'sign',
  5325          call: 'eth_sign',
  5326          params: 2,
  5327          inputFormatter: [formatters.inputAddressFormatter, null]
  5328      });
  5329  
  5330      var call = new Method({
  5331          name: 'call',
  5332          call: 'eth_call',
  5333          params: 2,
  5334          inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
  5335      });
  5336  
  5337      var estimateGas = new Method({
  5338          name: 'estimateGas',
  5339          call: 'eth_estimateGas',
  5340          params: 1,
  5341          inputFormatter: [formatters.inputCallFormatter],
  5342          outputFormatter: utils.toDecimal
  5343      });
  5344  
  5345      var compileSolidity = new Method({
  5346          name: 'compile.solidity',
  5347          call: 'eth_compileSolidity',
  5348          params: 1
  5349      });
  5350  
  5351      var compileLLL = new Method({
  5352          name: 'compile.lll',
  5353          call: 'eth_compileLLL',
  5354          params: 1
  5355      });
  5356  
  5357      var compileSerpent = new Method({
  5358          name: 'compile.serpent',
  5359          call: 'eth_compileSerpent',
  5360          params: 1
  5361      });
  5362  
  5363      var submitWork = new Method({
  5364          name: 'submitWork',
  5365          call: 'eth_submitWork',
  5366          params: 3
  5367      });
  5368  
  5369      var getWork = new Method({
  5370          name: 'getWork',
  5371          call: 'eth_getWork',
  5372          params: 0
  5373      });
  5374  
  5375      return [
  5376          getBalance,
  5377          getStorageAt,
  5378          getCode,
  5379          getBlock,
  5380          getUncle,
  5381          getCompilers,
  5382          getBlockTransactionCount,
  5383          getBlockUncleCount,
  5384          getTransaction,
  5385          getTransactionFromBlock,
  5386          getTransactionReceipt,
  5387          getTransactionCount,
  5388          call,
  5389          estimateGas,
  5390          sendRawTransaction,
  5391          signTransaction,
  5392          sendTransaction,
  5393          sign,
  5394          compileSolidity,
  5395          compileLLL,
  5396          compileSerpent,
  5397          submitWork,
  5398          getWork
  5399      ];
  5400  };
  5401  
  5402  
  5403  var properties = function () {
  5404      return [
  5405          new Property({
  5406              name: 'coinbase',
  5407              getter: 'eth_coinbase'
  5408          }),
  5409          new Property({
  5410              name: 'mining',
  5411              getter: 'eth_mining'
  5412          }),
  5413          new Property({
  5414              name: 'hashrate',
  5415              getter: 'eth_hashrate',
  5416              outputFormatter: utils.toDecimal
  5417          }),
  5418          new Property({
  5419              name: 'syncing',
  5420              getter: 'eth_syncing',
  5421              outputFormatter: formatters.outputSyncingFormatter
  5422          }),
  5423          new Property({
  5424              name: 'gasPrice',
  5425              getter: 'eth_gasPrice',
  5426              outputFormatter: formatters.outputBigNumberFormatter
  5427          }),
  5428          new Property({
  5429              name: 'accounts',
  5430              getter: 'eth_accounts'
  5431          }),
  5432          new Property({
  5433              name: 'blockNumber',
  5434              getter: 'eth_blockNumber',
  5435              outputFormatter: utils.toDecimal
  5436          }),
  5437          new Property({
  5438              name: 'protocolVersion',
  5439              getter: 'eth_protocolVersion'
  5440          })
  5441      ];
  5442  };
  5443  
  5444  Eth.prototype.contract = function (abi) {
  5445      var factory = new Contract(this, abi);
  5446      return factory;
  5447  };
  5448  
  5449  Eth.prototype.filter = function (options, callback, filterCreationErrorCallback) {
  5450      return new Filter(options, 'eth', this._requestManager, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
  5451  };
  5452  
  5453  Eth.prototype.namereg = function () {
  5454      return this.contract(namereg.global.abi).at(namereg.global.address);
  5455  };
  5456  
  5457  Eth.prototype.icapNamereg = function () {
  5458      return this.contract(namereg.icap.abi).at(namereg.icap.address);
  5459  };
  5460  
  5461  Eth.prototype.isSyncing = function (callback) {
  5462      return new IsSyncing(this._requestManager, callback);
  5463  };
  5464  
  5465  module.exports = Eth;
  5466  
  5467  },{"../../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){
  5468  /*
  5469      This file is part of web3.js.
  5470  
  5471      web3.js is free software: you can redistribute it and/or modify
  5472      it under the terms of the GNU Lesser General Public License as published by
  5473      the Free Software Foundation, either version 3 of the License, or
  5474      (at your option) any later version.
  5475  
  5476      web3.js is distributed in the hope that it will be useful,
  5477      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5478      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5479      GNU Lesser General Public License for more details.
  5480  
  5481      You should have received a copy of the GNU Lesser General Public License
  5482      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5483  */
  5484  /** @file eth.js
  5485   * @authors:
  5486   *   Marek Kotewicz <marek@ethdev.com>
  5487   * @date 2015
  5488   */
  5489  
  5490  var utils = require('../../utils/utils');
  5491  var Property = require('../property');
  5492  
  5493  var Net = function (web3) {
  5494      this._requestManager = web3._requestManager;
  5495  
  5496      var self = this;
  5497  
  5498      properties().forEach(function(p) { 
  5499          p.attachToObject(self);
  5500          p.setRequestManager(web3._requestManager);
  5501      });
  5502  };
  5503  
  5504  /// @returns an array of objects describing web3.eth api properties
  5505  var properties = function () {
  5506      return [
  5507          new Property({
  5508              name: 'listening',
  5509              getter: 'net_listening'
  5510          }),
  5511          new Property({
  5512              name: 'peerCount',
  5513              getter: 'net_peerCount',
  5514              outputFormatter: utils.toDecimal
  5515          })
  5516      ];
  5517  };
  5518  
  5519  module.exports = Net;
  5520  
  5521  },{"../../utils/utils":20,"../property":45}],40:[function(require,module,exports){
  5522  /*
  5523      This file is part of web3.js.
  5524  
  5525      web3.js is free software: you can redistribute it and/or modify
  5526      it under the terms of the GNU Lesser General Public License as published by
  5527      the Free Software Foundation, either version 3 of the License, or
  5528      (at your option) any later version.
  5529  
  5530      web3.js is distributed in the hope that it will be useful,
  5531      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5532      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5533      GNU Lesser General Public License for more details.
  5534  
  5535      You should have received a copy of the GNU Lesser General Public License
  5536      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5537  */
  5538  /**
  5539   * @file eth.js
  5540   * @author Marek Kotewicz <marek@ethdev.com>
  5541   * @author Fabian Vogelsteller <fabian@ethdev.com>
  5542   * @date 2015
  5543   */
  5544  
  5545  "use strict";
  5546  
  5547  var Method = require('../method');
  5548  var Property = require('../property');
  5549  var formatters = require('../formatters');
  5550  
  5551  function Personal(web3) {
  5552      this._requestManager = web3._requestManager;
  5553  
  5554      var self = this;
  5555  
  5556      methods().forEach(function(method) {
  5557          method.attachToObject(self);
  5558          method.setRequestManager(self._requestManager);
  5559      });
  5560  
  5561      properties().forEach(function(p) {
  5562          p.attachToObject(self);
  5563          p.setRequestManager(self._requestManager);
  5564      });
  5565  }
  5566  
  5567  var methods = function () {
  5568      var newAccount = new Method({
  5569          name: 'newAccount',
  5570          call: 'personal_newAccount',
  5571          params: 1,
  5572          inputFormatter: [null]
  5573      });
  5574  
  5575      var importRawKey = new Method({
  5576          name: 'importRawKey',
  5577  		call: 'personal_importRawKey',
  5578  		params: 2
  5579      });
  5580  
  5581      var sign = new Method({
  5582          name: 'sign',
  5583  		call: 'personal_sign',
  5584  		params: 3,
  5585  		inputFormatter: [null, formatters.inputAddressFormatter, null]
  5586      });
  5587  
  5588      var ecRecover = new Method({
  5589          name: 'ecRecover',
  5590  		call: 'personal_ecRecover',
  5591  		params: 2
  5592      });
  5593  
  5594      var unlockAccount = new Method({
  5595          name: 'unlockAccount',
  5596          call: 'personal_unlockAccount',
  5597          params: 3,
  5598          inputFormatter: [formatters.inputAddressFormatter, null, null]
  5599      });
  5600  
  5601      var sendTransaction = new Method({
  5602          name: 'sendTransaction',
  5603          call: 'personal_sendTransaction',
  5604          params: 2,
  5605          inputFormatter: [formatters.inputTransactionFormatter, null]
  5606      });
  5607  
  5608      var lockAccount = new Method({
  5609          name: 'lockAccount',
  5610          call: 'personal_lockAccount',
  5611          params: 1,
  5612          inputFormatter: [formatters.inputAddressFormatter]
  5613      });
  5614  
  5615      return [
  5616          newAccount,
  5617          importRawKey,
  5618          unlockAccount,
  5619          ecRecover,
  5620          sign,
  5621          sendTransaction,
  5622          lockAccount
  5623      ];
  5624  };
  5625  
  5626  var properties = function () {
  5627      return [
  5628          new Property({
  5629              name: 'listAccounts',
  5630              getter: 'personal_listAccounts'
  5631          })
  5632      ];
  5633  };
  5634  
  5635  
  5636  module.exports = Personal;
  5637  
  5638  },{"../formatters":30,"../method":36,"../property":45}],41:[function(require,module,exports){
  5639  /*
  5640      This file is part of web3.js.
  5641  
  5642      web3.js is free software: you can redistribute it and/or modify
  5643      it under the terms of the GNU Lesser General Public License as published by
  5644      the Free Software Foundation, either version 3 of the License, or
  5645      (at your option) any later version.
  5646  
  5647      web3.js is distributed in the hope that it will be useful,
  5648      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5649      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5650      GNU Lesser General Public License for more details.
  5651  
  5652      You should have received a copy of the GNU Lesser General Public License
  5653      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5654  */
  5655  /** @file shh.js
  5656   * @authors:
  5657   *   Fabian Vogelsteller <fabian@ethereum.org>
  5658   *   Marek Kotewicz <marek@ethcore.io>
  5659   * @date 2017
  5660   */
  5661  
  5662  var Method = require('../method');
  5663  var Filter = require('../filter');
  5664  var watches = require('./watches');
  5665  
  5666  var Shh = function (web3) {
  5667      this._requestManager = web3._requestManager;
  5668  
  5669      var self = this;
  5670  
  5671      methods().forEach(function(method) {
  5672          method.attachToObject(self);
  5673          method.setRequestManager(self._requestManager);
  5674      });
  5675  };
  5676  
  5677  Shh.prototype.newMessageFilter = function (options, callback, filterCreationErrorCallback) {
  5678      return new Filter(options, 'shh', this._requestManager, watches.shh(), null, callback, filterCreationErrorCallback);
  5679  };
  5680  
  5681  var methods = function () {
  5682  
  5683      return [
  5684          new Method({
  5685              name: 'version',
  5686              call: 'shh_version',
  5687              params: 0
  5688          }),
  5689          new Method({
  5690              name: 'info',
  5691              call: 'shh_info',
  5692              params: 0
  5693          }),
  5694          new Method({
  5695              name: 'setMaxMessageSize',
  5696              call: 'shh_setMaxMessageSize',
  5697              params: 1
  5698          }),
  5699          new Method({
  5700              name: 'setMinPoW',
  5701              call: 'shh_setMinPoW',
  5702              params: 1
  5703          }),
  5704          new Method({
  5705              name: 'markTrustedPeer',
  5706              call: 'shh_markTrustedPeer',
  5707              params: 1
  5708          }),
  5709          new Method({
  5710              name: 'newKeyPair',
  5711              call: 'shh_newKeyPair',
  5712              params: 0
  5713          }),
  5714          new Method({
  5715              name: 'addPrivateKey',
  5716              call: 'shh_addPrivateKey',
  5717              params: 1
  5718          }),
  5719          new Method({
  5720              name: 'deleteKeyPair',
  5721              call: 'shh_deleteKeyPair',
  5722              params: 1
  5723          }),
  5724          new Method({
  5725              name: 'hasKeyPair',
  5726              call: 'shh_hasKeyPair',
  5727              params: 1
  5728          }),
  5729          new Method({
  5730              name: 'getPublicKey',
  5731              call: 'shh_getPublicKey',
  5732              params: 1
  5733          }),
  5734          new Method({
  5735              name: 'getPrivateKey',
  5736              call: 'shh_getPrivateKey',
  5737              params: 1
  5738          }),
  5739          new Method({
  5740              name: 'newSymKey',
  5741              call: 'shh_newSymKey',
  5742              params: 0
  5743          }),
  5744          new Method({
  5745              name: 'addSymKey',
  5746              call: 'shh_addSymKey',
  5747              params: 1
  5748          }),
  5749          new Method({
  5750              name: 'generateSymKeyFromPassword',
  5751              call: 'shh_generateSymKeyFromPassword',
  5752              params: 1
  5753          }),
  5754          new Method({
  5755              name: 'hasSymKey',
  5756              call: 'shh_hasSymKey',
  5757              params: 1
  5758          }),
  5759          new Method({
  5760              name: 'getSymKey',
  5761              call: 'shh_getSymKey',
  5762              params: 1
  5763          }),
  5764          new Method({
  5765              name: 'deleteSymKey',
  5766              call: 'shh_deleteSymKey',
  5767              params: 1
  5768          }),
  5769  
  5770          // subscribe and unsubscribe missing
  5771  
  5772          new Method({
  5773              name: 'post',
  5774              call: 'shh_post',
  5775              params: 1,
  5776              inputFormatter: [null]
  5777          })
  5778      ];
  5779  };
  5780  
  5781  module.exports = Shh;
  5782  
  5783  
  5784  },{"../filter":29,"../method":36,"./watches":43}],42:[function(require,module,exports){
  5785  /*
  5786      This file is part of web3.js.
  5787  
  5788      web3.js is free software: you can redistribute it and/or modify
  5789      it under the terms of the GNU Lesser General Public License as published by
  5790      the Free Software Foundation, either version 3 of the License, or
  5791      (at your option) any later version.
  5792  
  5793      web3.js is distributed in the hope that it will be useful,
  5794      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5795      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5796      GNU Lesser General Public License for more details.
  5797  
  5798      You should have received a copy of the GNU Lesser General Public License
  5799      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5800  */
  5801  /**
  5802   * @file bzz.js
  5803   * @author Alex Beregszaszi <alex@rtfs.hu>
  5804   * @date 2016
  5805   *
  5806   * Reference: https://github.com/Sberex/go-sberex/blob/swarm/internal/web3ext/web3ext.go#L33
  5807   */
  5808  
  5809  "use strict";
  5810  
  5811  var Method = require('../method');
  5812  var Property = require('../property');
  5813  
  5814  function Swarm(web3) {
  5815      this._requestManager = web3._requestManager;
  5816  
  5817      var self = this;
  5818  
  5819      methods().forEach(function(method) {
  5820          method.attachToObject(self);
  5821          method.setRequestManager(self._requestManager);
  5822      });
  5823  
  5824      properties().forEach(function(p) {
  5825          p.attachToObject(self);
  5826          p.setRequestManager(self._requestManager);
  5827      });
  5828  }
  5829  
  5830  var methods = function () {
  5831      var blockNetworkRead = new Method({
  5832          name: 'blockNetworkRead',
  5833          call: 'bzz_blockNetworkRead',
  5834          params: 1,
  5835          inputFormatter: [null]
  5836      });
  5837  
  5838      var syncEnabled = new Method({
  5839          name: 'syncEnabled',
  5840          call: 'bzz_syncEnabled',
  5841          params: 1,
  5842          inputFormatter: [null]
  5843      });
  5844  
  5845      var swapEnabled = new Method({
  5846          name: 'swapEnabled',
  5847          call: 'bzz_swapEnabled',
  5848          params: 1,
  5849          inputFormatter: [null]
  5850      });
  5851  
  5852      var download = new Method({
  5853          name: 'download',
  5854          call: 'bzz_download',
  5855          params: 2,
  5856          inputFormatter: [null, null]
  5857      });
  5858  
  5859      var upload = new Method({
  5860          name: 'upload',
  5861          call: 'bzz_upload',
  5862          params: 2,
  5863          inputFormatter: [null, null]
  5864      });
  5865  
  5866      var retrieve = new Method({
  5867          name: 'retrieve',
  5868          call: 'bzz_retrieve',
  5869          params: 1,
  5870          inputFormatter: [null]
  5871      });
  5872  
  5873      var store = new Method({
  5874          name: 'store',
  5875          call: 'bzz_store',
  5876          params: 2,
  5877          inputFormatter: [null, null]
  5878      });
  5879  
  5880      var get = new Method({
  5881          name: 'get',
  5882          call: 'bzz_get',
  5883          params: 1,
  5884          inputFormatter: [null]
  5885      });
  5886  
  5887      var put = new Method({
  5888          name: 'put',
  5889          call: 'bzz_put',
  5890          params: 2,
  5891          inputFormatter: [null, null]
  5892      });
  5893  
  5894      var modify = new Method({
  5895          name: 'modify',
  5896          call: 'bzz_modify',
  5897          params: 4,
  5898          inputFormatter: [null, null, null, null]
  5899      });
  5900  
  5901      return [
  5902          blockNetworkRead,
  5903          syncEnabled,
  5904          swapEnabled,
  5905          download,
  5906          upload,
  5907          retrieve,
  5908          store,
  5909          get,
  5910          put,
  5911          modify
  5912      ];
  5913  };
  5914  
  5915  var properties = function () {
  5916      return [
  5917          new Property({
  5918              name: 'hive',
  5919              getter: 'bzz_hive'
  5920          }),
  5921          new Property({
  5922              name: 'info',
  5923              getter: 'bzz_info'
  5924          })
  5925      ];
  5926  };
  5927  
  5928  
  5929  module.exports = Swarm;
  5930  
  5931  },{"../method":36,"../property":45}],43:[function(require,module,exports){
  5932  /*
  5933      This file is part of web3.js.
  5934  
  5935      web3.js is free software: you can redistribute it and/or modify
  5936      it under the terms of the GNU Lesser General Public License as published by
  5937      the Free Software Foundation, either version 3 of the License, or
  5938      (at your option) any later version.
  5939  
  5940      web3.js is distributed in the hope that it will be useful,
  5941      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5942      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5943      GNU Lesser General Public License for more details.
  5944  
  5945      You should have received a copy of the GNU Lesser General Public License
  5946      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5947  */
  5948  /** @file watches.js
  5949   * @authors:
  5950   *   Marek Kotewicz <marek@ethdev.com>
  5951   * @date 2015
  5952   */
  5953  
  5954  var Method = require('../method');
  5955  
  5956  /// @returns an array of objects describing web3.eth.filter api methods
  5957  var eth = function () {
  5958      var newFilterCall = function (args) {
  5959          var type = args[0];
  5960  
  5961          switch(type) {
  5962              case 'latest':
  5963                  args.shift();
  5964                  this.params = 0;
  5965                  return 'eth_newBlockFilter';
  5966              case 'pending':
  5967                  args.shift();
  5968                  this.params = 0;
  5969                  return 'eth_newPendingTransactionFilter';
  5970              default:
  5971                  return 'eth_newFilter';
  5972          }
  5973      };
  5974  
  5975      var newFilter = new Method({
  5976          name: 'newFilter',
  5977          call: newFilterCall,
  5978          params: 1
  5979      });
  5980  
  5981      var uninstallFilter = new Method({
  5982          name: 'uninstallFilter',
  5983          call: 'eth_uninstallFilter',
  5984          params: 1
  5985      });
  5986  
  5987      var getLogs = new Method({
  5988          name: 'getLogs',
  5989          call: 'eth_getFilterLogs',
  5990          params: 1
  5991      });
  5992  
  5993      var poll = new Method({
  5994          name: 'poll',
  5995          call: 'eth_getFilterChanges',
  5996          params: 1
  5997      });
  5998  
  5999      return [
  6000          newFilter,
  6001          uninstallFilter,
  6002          getLogs,
  6003          poll
  6004      ];
  6005  };
  6006  
  6007  /// @returns an array of objects describing web3.shh.watch api methods
  6008  var shh = function () {
  6009  
  6010      return [
  6011          new Method({
  6012              name: 'newFilter',
  6013              call: 'shh_newMessageFilter',
  6014              params: 1
  6015          }),
  6016          new Method({
  6017              name: 'uninstallFilter',
  6018              call: 'shh_deleteMessageFilter',
  6019              params: 1
  6020          }),
  6021          new Method({
  6022              name: 'getLogs',
  6023              call: 'shh_getFilterMessages',
  6024              params: 1
  6025          }),
  6026          new Method({
  6027              name: 'poll',
  6028              call: 'shh_getFilterMessages',
  6029              params: 1
  6030          })
  6031      ];
  6032  };
  6033  
  6034  module.exports = {
  6035      eth: eth,
  6036      shh: shh
  6037  };
  6038  
  6039  
  6040  },{"../method":36}],44:[function(require,module,exports){
  6041  /*
  6042      This file is part of web3.js.
  6043  
  6044      web3.js is free software: you can redistribute it and/or modify
  6045      it under the terms of the GNU Lesser General Public License as published by
  6046      the Free Software Foundation, either version 3 of the License, or
  6047      (at your option) any later version.
  6048  
  6049      web3.js is distributed in the hope that it will be useful,
  6050      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6051      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6052      GNU Lesser General Public License for more details.
  6053  
  6054      You should have received a copy of the GNU Lesser General Public License
  6055      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6056  */
  6057  /** 
  6058   * @file namereg.js
  6059   * @author Marek Kotewicz <marek@ethdev.com>
  6060   * @date 2015
  6061   */
  6062  
  6063  var globalRegistrarAbi = require('../contracts/GlobalRegistrar.json');
  6064  var icapRegistrarAbi= require('../contracts/ICAPRegistrar.json');
  6065  
  6066  var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
  6067  var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
  6068  
  6069  module.exports = {
  6070      global: {
  6071          abi: globalRegistrarAbi,
  6072          address: globalNameregAddress
  6073      },
  6074      icap: {
  6075          abi: icapRegistrarAbi,
  6076          address: icapNameregAddress
  6077      }
  6078  };
  6079  
  6080  
  6081  },{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],45:[function(require,module,exports){
  6082  /*
  6083      This file is part of web3.js.
  6084  
  6085      web3.js is free software: you can redistribute it and/or modify
  6086      it under the terms of the GNU Lesser General Public License as published by
  6087      the Free Software Foundation, either version 3 of the License, or
  6088      (at your option) any later version.
  6089  
  6090      web3.js is distributed in the hope that it will be useful,
  6091      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6092      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6093      GNU Lesser General Public License for more details.
  6094  
  6095      You should have received a copy of the GNU Lesser General Public License
  6096      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6097  */
  6098  /**
  6099   * @file property.js
  6100   * @author Fabian Vogelsteller <fabian@frozeman.de>
  6101   * @author Marek Kotewicz <marek@ethdev.com>
  6102   * @date 2015
  6103   */
  6104  
  6105  var utils = require('../utils/utils');
  6106  
  6107  var Property = function (options) {
  6108      this.name = options.name;
  6109      this.getter = options.getter;
  6110      this.setter = options.setter;
  6111      this.outputFormatter = options.outputFormatter;
  6112      this.inputFormatter = options.inputFormatter;
  6113      this.requestManager = null;
  6114  };
  6115  
  6116  Property.prototype.setRequestManager = function (rm) {
  6117      this.requestManager = rm;
  6118  };
  6119  
  6120  /**
  6121   * Should be called to format input args of method
  6122   *
  6123   * @method formatInput
  6124   * @param {Array}
  6125   * @return {Array}
  6126   */
  6127  Property.prototype.formatInput = function (arg) {
  6128      return this.inputFormatter ? this.inputFormatter(arg) : arg;
  6129  };
  6130  
  6131  /**
  6132   * Should be called to format output(result) of method
  6133   *
  6134   * @method formatOutput
  6135   * @param {Object}
  6136   * @return {Object}
  6137   */
  6138  Property.prototype.formatOutput = function (result) {
  6139      return this.outputFormatter && result !== null && result !== undefined ? this.outputFormatter(result) : result;
  6140  };
  6141  
  6142  /**
  6143   * Should be used to extract callback from array of arguments. Modifies input param
  6144   *
  6145   * @method extractCallback
  6146   * @param {Array} arguments
  6147   * @return {Function|Null} callback, if exists
  6148   */
  6149  Property.prototype.extractCallback = function (args) {
  6150      if (utils.isFunction(args[args.length - 1])) {
  6151          return args.pop(); // modify the args array!
  6152      }
  6153  };
  6154  
  6155  
  6156  /**
  6157   * Should attach function to method
  6158   *
  6159   * @method attachToObject
  6160   * @param {Object}
  6161   * @param {Function}
  6162   */
  6163  Property.prototype.attachToObject = function (obj) {
  6164      var proto = {
  6165          get: this.buildGet(),
  6166          enumerable: true
  6167      };
  6168  
  6169      var names = this.name.split('.');
  6170      var name = names[0];
  6171      if (names.length > 1) {
  6172          obj[names[0]] = obj[names[0]] || {};
  6173          obj = obj[names[0]];
  6174          name = names[1];
  6175      }
  6176  
  6177      Object.defineProperty(obj, name, proto);
  6178      obj[asyncGetterName(name)] = this.buildAsyncGet();
  6179  };
  6180  
  6181  var asyncGetterName = function (name) {
  6182      return 'get' + name.charAt(0).toUpperCase() + name.slice(1);
  6183  };
  6184  
  6185  Property.prototype.buildGet = function () {
  6186      var property = this;
  6187      return function get() {
  6188          return property.formatOutput(property.requestManager.send({
  6189              method: property.getter
  6190          }));
  6191      };
  6192  };
  6193  
  6194  Property.prototype.buildAsyncGet = function () {
  6195      var property = this;
  6196      var get = function (callback) {
  6197          property.requestManager.sendAsync({
  6198              method: property.getter
  6199          }, function (err, result) {
  6200              callback(err, property.formatOutput(result));
  6201          });
  6202      };
  6203      get.request = this.request.bind(this);
  6204      return get;
  6205  };
  6206  
  6207  /**
  6208   * Should be called to create pure JSONRPC request which can be used in batch request
  6209   *
  6210   * @method request
  6211   * @param {...} params
  6212   * @return {Object} jsonrpc request
  6213   */
  6214  Property.prototype.request = function () {
  6215      var payload = {
  6216          method: this.getter,
  6217          params: [],
  6218          callback: this.extractCallback(Array.prototype.slice.call(arguments))
  6219      };
  6220      payload.format = this.formatOutput.bind(this);
  6221      return payload;
  6222  };
  6223  
  6224  module.exports = Property;
  6225  
  6226  
  6227  },{"../utils/utils":20}],46:[function(require,module,exports){
  6228  /*
  6229      This file is part of web3.js.
  6230  
  6231      web3.js is free software: you can redistribute it and/or modify
  6232      it under the terms of the GNU Lesser General Public License as published by
  6233      the Free Software Foundation, either version 3 of the License, or
  6234      (at your option) any later version.
  6235  
  6236      web3.js is distributed in the hope that it will be useful,
  6237      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6238      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6239      GNU Lesser General Public License for more details.
  6240  
  6241      You should have received a copy of the GNU Lesser General Public License
  6242      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6243  */
  6244  /** 
  6245   * @file requestmanager.js
  6246   * @author Jeffrey Wilcke <jeff@ethdev.com>
  6247   * @author Marek Kotewicz <marek@ethdev.com>
  6248   * @author Marian Oancea <marian@ethdev.com>
  6249   * @author Fabian Vogelsteller <fabian@ethdev.com>
  6250   * @author Gav Wood <g@ethdev.com>
  6251   * @date 2014
  6252   */
  6253  
  6254  var Jsonrpc = require('./jsonrpc');
  6255  var utils = require('../utils/utils');
  6256  var c = require('../utils/config');
  6257  var errors = require('./errors');
  6258  
  6259  /**
  6260   * It's responsible for passing messages to providers
  6261   * It's also responsible for polling the sberex node for incoming messages
  6262   * Default poll timeout is 1 second
  6263   * Singleton
  6264   */
  6265  var RequestManager = function (provider) {
  6266      this.provider = provider;
  6267      this.polls = {};
  6268      this.timeout = null;
  6269  };
  6270  
  6271  /**
  6272   * Should be used to synchronously send request
  6273   *
  6274   * @method send
  6275   * @param {Object} data
  6276   * @return {Object}
  6277   */
  6278  RequestManager.prototype.send = function (data) {
  6279      if (!this.provider) {
  6280          console.error(errors.InvalidProvider());
  6281          return null;
  6282      }
  6283  
  6284      var payload = Jsonrpc.toPayload(data.method, data.params);
  6285      var result = this.provider.send(payload);
  6286  
  6287      if (!Jsonrpc.isValidResponse(result)) {
  6288          throw errors.InvalidResponse(result);
  6289      }
  6290  
  6291      return result.result;
  6292  };
  6293  
  6294  /**
  6295   * Should be used to asynchronously send request
  6296   *
  6297   * @method sendAsync
  6298   * @param {Object} data
  6299   * @param {Function} callback
  6300   */
  6301  RequestManager.prototype.sendAsync = function (data, callback) {
  6302      if (!this.provider) {
  6303          return callback(errors.InvalidProvider());
  6304      }
  6305  
  6306      var payload = Jsonrpc.toPayload(data.method, data.params);
  6307      this.provider.sendAsync(payload, function (err, result) {
  6308          if (err) {
  6309              return callback(err);
  6310          }
  6311          
  6312          if (!Jsonrpc.isValidResponse(result)) {
  6313              return callback(errors.InvalidResponse(result));
  6314          }
  6315  
  6316          callback(null, result.result);
  6317      });
  6318  };
  6319  
  6320  /**
  6321   * Should be called to asynchronously send batch request
  6322   *
  6323   * @method sendBatch
  6324   * @param {Array} batch data
  6325   * @param {Function} callback
  6326   */
  6327  RequestManager.prototype.sendBatch = function (data, callback) {
  6328      if (!this.provider) {
  6329          return callback(errors.InvalidProvider());
  6330      }
  6331  
  6332      var payload = Jsonrpc.toBatchPayload(data);
  6333  
  6334      this.provider.sendAsync(payload, function (err, results) {
  6335          if (err) {
  6336              return callback(err);
  6337          }
  6338  
  6339          if (!utils.isArray(results)) {
  6340              return callback(errors.InvalidResponse(results));
  6341          }
  6342  
  6343          callback(err, results);
  6344      }); 
  6345  };
  6346  
  6347  /**
  6348   * Should be used to set provider of request manager
  6349   *
  6350   * @method setProvider
  6351   * @param {Object}
  6352   */
  6353  RequestManager.prototype.setProvider = function (p) {
  6354      this.provider = p;
  6355  };
  6356  
  6357  /**
  6358   * Should be used to start polling
  6359   *
  6360   * @method startPolling
  6361   * @param {Object} data
  6362   * @param {Number} pollId
  6363   * @param {Function} callback
  6364   * @param {Function} uninstall
  6365   *
  6366   * @todo cleanup number of params
  6367   */
  6368  RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
  6369      this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
  6370  
  6371  
  6372      // start polling
  6373      if (!this.timeout) {
  6374          this.poll();
  6375      }
  6376  };
  6377  
  6378  /**
  6379   * Should be used to stop polling for filter with given id
  6380   *
  6381   * @method stopPolling
  6382   * @param {Number} pollId
  6383   */
  6384  RequestManager.prototype.stopPolling = function (pollId) {
  6385      delete this.polls[pollId];
  6386  
  6387      // stop polling
  6388      if(Object.keys(this.polls).length === 0 && this.timeout) {
  6389          clearTimeout(this.timeout);
  6390          this.timeout = null;
  6391      }
  6392  };
  6393  
  6394  /**
  6395   * Should be called to reset the polling mechanism of the request manager
  6396   *
  6397   * @method reset
  6398   */
  6399  RequestManager.prototype.reset = function (keepIsSyncing) {
  6400      /*jshint maxcomplexity:5 */
  6401  
  6402      for (var key in this.polls) {
  6403          // remove all polls, except sync polls,
  6404          // they need to be removed manually by calling syncing.stopWatching()
  6405          if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) {
  6406              this.polls[key].uninstall();
  6407              delete this.polls[key];
  6408          }
  6409      }
  6410  
  6411      // stop polling
  6412      if(Object.keys(this.polls).length === 0 && this.timeout) {
  6413          clearTimeout(this.timeout);
  6414          this.timeout = null;
  6415      }
  6416  };
  6417  
  6418  /**
  6419   * Should be called to poll for changes on filter with given id
  6420   *
  6421   * @method poll
  6422   */
  6423  RequestManager.prototype.poll = function () {
  6424      /*jshint maxcomplexity: 6 */
  6425      this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
  6426  
  6427      if (Object.keys(this.polls).length === 0) {
  6428          return;
  6429      }
  6430  
  6431      if (!this.provider) {
  6432          console.error(errors.InvalidProvider());
  6433          return;
  6434      }
  6435  
  6436      var pollsData = [];
  6437      var pollsIds = [];
  6438      for (var key in this.polls) {
  6439          pollsData.push(this.polls[key].data);
  6440          pollsIds.push(key);
  6441      }
  6442  
  6443      if (pollsData.length === 0) {
  6444          return;
  6445      }
  6446  
  6447      var payload = Jsonrpc.toBatchPayload(pollsData);
  6448      
  6449      // map the request id to they poll id
  6450      var pollsIdMap = {};
  6451      payload.forEach(function(load, index){
  6452          pollsIdMap[load.id] = pollsIds[index];
  6453      });
  6454  
  6455  
  6456      var self = this;
  6457      this.provider.sendAsync(payload, function (error, results) {
  6458  
  6459  
  6460          // TODO: console log?
  6461          if (error) {
  6462              return;
  6463          }
  6464  
  6465          if (!utils.isArray(results)) {
  6466              throw errors.InvalidResponse(results);
  6467          }
  6468          results.map(function (result) {
  6469              var id = pollsIdMap[result.id];
  6470  
  6471              // make sure the filter is still installed after arrival of the request
  6472              if (self.polls[id]) {
  6473                  result.callback = self.polls[id].callback;
  6474                  return result;
  6475              } else
  6476                  return false;
  6477          }).filter(function (result) {
  6478              return !!result; 
  6479          }).filter(function (result) {
  6480              var valid = Jsonrpc.isValidResponse(result);
  6481              if (!valid) {
  6482                  result.callback(errors.InvalidResponse(result));
  6483              }
  6484              return valid;
  6485          }).forEach(function (result) {
  6486              result.callback(null, result.result);
  6487          });
  6488      });
  6489  };
  6490  
  6491  module.exports = RequestManager;
  6492  
  6493  
  6494  },{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],47:[function(require,module,exports){
  6495  
  6496  
  6497  var Settings = function () {
  6498      this.defaultBlock = 'latest';
  6499      this.defaultAccount = undefined;
  6500  };
  6501  
  6502  module.exports = Settings;
  6503  
  6504  
  6505  },{}],48:[function(require,module,exports){
  6506  /*
  6507      This file is part of web3.js.
  6508  
  6509      web3.js is free software: you can redistribute it and/or modify
  6510      it under the terms of the GNU Lesser General Public License as published by
  6511      the Free Software Foundation, either version 3 of the License, or
  6512      (at your option) any later version.
  6513  
  6514      web3.js is distributed in the hope that it will be useful,
  6515      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6516      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6517      GNU Lesser General Public License for more details.
  6518  
  6519      You should have received a copy of the GNU Lesser General Public License
  6520      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6521  */
  6522  /** @file syncing.js
  6523   * @authors:
  6524   *   Fabian Vogelsteller <fabian@ethdev.com>
  6525   * @date 2015
  6526   */
  6527  
  6528  var formatters = require('./formatters');
  6529  var utils = require('../utils/utils');
  6530  
  6531  var count = 1;
  6532  
  6533  /**
  6534  Adds the callback and sets up the methods, to iterate over the results.
  6535  
  6536  @method pollSyncing
  6537  @param {Object} self
  6538  */
  6539  var pollSyncing = function(self) {
  6540  
  6541      var onMessage = function (error, sync) {
  6542          if (error) {
  6543              return self.callbacks.forEach(function (callback) {
  6544                  callback(error);
  6545              });
  6546          }
  6547  
  6548          if(utils.isObject(sync) && sync.startingBlock)
  6549              sync = formatters.outputSyncingFormatter(sync);
  6550  
  6551          self.callbacks.forEach(function (callback) {
  6552              if (self.lastSyncState !== sync) {
  6553                  
  6554                  // call the callback with true first so the app can stop anything, before receiving the sync data
  6555                  if(!self.lastSyncState && utils.isObject(sync))
  6556                      callback(null, true);
  6557                  
  6558                  // call on the next CPU cycle, so the actions of the sync stop can be processes first
  6559                  setTimeout(function() {
  6560                      callback(null, sync);
  6561                  }, 0);
  6562                  
  6563                  self.lastSyncState = sync;
  6564              }
  6565          });
  6566      };
  6567  
  6568      self.requestManager.startPolling({
  6569          method: 'eth_syncing',
  6570          params: [],
  6571      }, self.pollId, onMessage, self.stopWatching.bind(self));
  6572  
  6573  };
  6574  
  6575  var IsSyncing = function (requestManager, callback) {
  6576      this.requestManager = requestManager;
  6577      this.pollId = 'syncPoll_'+ count++;
  6578      this.callbacks = [];
  6579      this.addCallback(callback);
  6580      this.lastSyncState = false;
  6581      pollSyncing(this);
  6582  
  6583      return this;
  6584  };
  6585  
  6586  IsSyncing.prototype.addCallback = function (callback) {
  6587      if(callback)
  6588          this.callbacks.push(callback);
  6589      return this;
  6590  };
  6591  
  6592  IsSyncing.prototype.stopWatching = function () {
  6593      this.requestManager.stopPolling(this.pollId);
  6594      this.callbacks = [];
  6595  };
  6596  
  6597  module.exports = IsSyncing;
  6598  
  6599  
  6600  },{"../utils/utils":20,"./formatters":30}],49:[function(require,module,exports){
  6601  /*
  6602      This file is part of web3.js.
  6603  
  6604      web3.js is free software: you can redistribute it and/or modify
  6605      it under the terms of the GNU Lesser General Public License as published by
  6606      the Free Software Foundation, either version 3 of the License, or
  6607      (at your option) any later version.
  6608  
  6609      web3.js is distributed in the hope that it will be useful,
  6610      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6611      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6612      GNU Lesser General Public License for more details.
  6613  
  6614      You should have received a copy of the GNU Lesser General Public License
  6615      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6616  */
  6617  /** 
  6618   * @file transfer.js
  6619   * @author Marek Kotewicz <marek@ethdev.com>
  6620   * @date 2015
  6621   */
  6622  
  6623  var Iban = require('./iban');
  6624  var exchangeAbi = require('../contracts/SmartExchange.json');
  6625  
  6626  /**
  6627   * Should be used to make Iban transfer
  6628   *
  6629   * @method transfer
  6630   * @param {String} from
  6631   * @param {String} to iban
  6632   * @param {Value} value to be tranfered
  6633   * @param {Function} callback, callback
  6634   */
  6635  var transfer = function (eth, from, to, value, callback) {
  6636      var iban = new Iban(to); 
  6637      if (!iban.isValid()) {
  6638          throw new Error('invalid iban address');
  6639      }
  6640  
  6641      if (iban.isDirect()) {
  6642          return transferToAddress(eth, from, iban.address(), value, callback);
  6643      }
  6644      
  6645      if (!callback) {
  6646          var address = eth.icapNamereg().addr(iban.institution());
  6647          return deposit(eth, from, address, value, iban.client());
  6648      }
  6649  
  6650      eth.icapNamereg().addr(iban.institution(), function (err, address) {
  6651          return deposit(eth, from, address, value, iban.client(), callback);
  6652      });
  6653      
  6654  };
  6655  
  6656  /**
  6657   * Should be used to transfer funds to certain address
  6658   *
  6659   * @method transferToAddress
  6660   * @param {String} from
  6661   * @param {String} to
  6662   * @param {Value} value to be tranfered
  6663   * @param {Function} callback, callback
  6664   */
  6665  var transferToAddress = function (eth, from, to, value, callback) {
  6666      return eth.sendTransaction({
  6667          address: to,
  6668          from: from,
  6669          value: value
  6670      }, callback);
  6671  };
  6672  
  6673  /**
  6674   * Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
  6675   *
  6676   * @method deposit
  6677   * @param {String} from
  6678   * @param {String} to
  6679   * @param {Value} value to be transfered
  6680   * @param {String} client unique identifier
  6681   * @param {Function} callback, callback
  6682   */
  6683  var deposit = function (eth, from, to, value, client, callback) {
  6684      var abi = exchangeAbi;
  6685      return eth.contract(abi).at(to).deposit(client, {
  6686          from: from,
  6687          value: value
  6688      }, callback);
  6689  };
  6690  
  6691  module.exports = transfer;
  6692  
  6693  
  6694  },{"../contracts/SmartExchange.json":3,"./iban":33}],50:[function(require,module,exports){
  6695  
  6696  },{}],51:[function(require,module,exports){
  6697  ;(function (root, factory, undef) {
  6698  	if (typeof exports === "object") {
  6699  		// CommonJS
  6700  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  6701  	}
  6702  	else if (typeof define === "function" && define.amd) {
  6703  		// AMD
  6704  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  6705  	}
  6706  	else {
  6707  		// Global (browser)
  6708  		factory(root.CryptoJS);
  6709  	}
  6710  }(this, function (CryptoJS) {
  6711  
  6712  	(function () {
  6713  	    // Shortcuts
  6714  	    var C = CryptoJS;
  6715  	    var C_lib = C.lib;
  6716  	    var BlockCipher = C_lib.BlockCipher;
  6717  	    var C_algo = C.algo;
  6718  
  6719  	    // Lookup tables
  6720  	    var SBOX = [];
  6721  	    var INV_SBOX = [];
  6722  	    var SUB_MIX_0 = [];
  6723  	    var SUB_MIX_1 = [];
  6724  	    var SUB_MIX_2 = [];
  6725  	    var SUB_MIX_3 = [];
  6726  	    var INV_SUB_MIX_0 = [];
  6727  	    var INV_SUB_MIX_1 = [];
  6728  	    var INV_SUB_MIX_2 = [];
  6729  	    var INV_SUB_MIX_3 = [];
  6730  
  6731  	    // Compute lookup tables
  6732  	    (function () {
  6733  	        // Compute double table
  6734  	        var d = [];
  6735  	        for (var i = 0; i < 256; i++) {
  6736  	            if (i < 128) {
  6737  	                d[i] = i << 1;
  6738  	            } else {
  6739  	                d[i] = (i << 1) ^ 0x11b;
  6740  	            }
  6741  	        }
  6742  
  6743  	        // Walk GF(2^8)
  6744  	        var x = 0;
  6745  	        var xi = 0;
  6746  	        for (var i = 0; i < 256; i++) {
  6747  	            // Compute sbox
  6748  	            var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  6749  	            sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  6750  	            SBOX[x] = sx;
  6751  	            INV_SBOX[sx] = x;
  6752  
  6753  	            // Compute multiplication
  6754  	            var x2 = d[x];
  6755  	            var x4 = d[x2];
  6756  	            var x8 = d[x4];
  6757  
  6758  	            // Compute sub bytes, mix columns tables
  6759  	            var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  6760  	            SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  6761  	            SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  6762  	            SUB_MIX_2[x] = (t << 8)  | (t >>> 24);
  6763  	            SUB_MIX_3[x] = t;
  6764  
  6765  	            // Compute inv sub bytes, inv mix columns tables
  6766  	            var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  6767  	            INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  6768  	            INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  6769  	            INV_SUB_MIX_2[sx] = (t << 8)  | (t >>> 24);
  6770  	            INV_SUB_MIX_3[sx] = t;
  6771  
  6772  	            // Compute next counter
  6773  	            if (!x) {
  6774  	                x = xi = 1;
  6775  	            } else {
  6776  	                x = x2 ^ d[d[d[x8 ^ x2]]];
  6777  	                xi ^= d[d[xi]];
  6778  	            }
  6779  	        }
  6780  	    }());
  6781  
  6782  	    // Precomputed Rcon lookup
  6783  	    var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  6784  
  6785  	    /**
  6786  	     * AES block cipher algorithm.
  6787  	     */
  6788  	    var AES = C_algo.AES = BlockCipher.extend({
  6789  	        _doReset: function () {
  6790  	            // Skip reset of nRounds has been set before and key did not change
  6791  	            if (this._nRounds && this._keyPriorReset === this._key) {
  6792  	                return;
  6793  	            }
  6794  
  6795  	            // Shortcuts
  6796  	            var key = this._keyPriorReset = this._key;
  6797  	            var keyWords = key.words;
  6798  	            var keySize = key.sigBytes / 4;
  6799  
  6800  	            // Compute number of rounds
  6801  	            var nRounds = this._nRounds = keySize + 6;
  6802  
  6803  	            // Compute number of key schedule rows
  6804  	            var ksRows = (nRounds + 1) * 4;
  6805  
  6806  	            // Compute key schedule
  6807  	            var keySchedule = this._keySchedule = [];
  6808  	            for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  6809  	                if (ksRow < keySize) {
  6810  	                    keySchedule[ksRow] = keyWords[ksRow];
  6811  	                } else {
  6812  	                    var t = keySchedule[ksRow - 1];
  6813  
  6814  	                    if (!(ksRow % keySize)) {
  6815  	                        // Rot word
  6816  	                        t = (t << 8) | (t >>> 24);
  6817  
  6818  	                        // Sub word
  6819  	                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6820  
  6821  	                        // Mix Rcon
  6822  	                        t ^= RCON[(ksRow / keySize) | 0] << 24;
  6823  	                    } else if (keySize > 6 && ksRow % keySize == 4) {
  6824  	                        // Sub word
  6825  	                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6826  	                    }
  6827  
  6828  	                    keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  6829  	                }
  6830  	            }
  6831  
  6832  	            // Compute inv key schedule
  6833  	            var invKeySchedule = this._invKeySchedule = [];
  6834  	            for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  6835  	                var ksRow = ksRows - invKsRow;
  6836  
  6837  	                if (invKsRow % 4) {
  6838  	                    var t = keySchedule[ksRow];
  6839  	                } else {
  6840  	                    var t = keySchedule[ksRow - 4];
  6841  	                }
  6842  
  6843  	                if (invKsRow < 4 || ksRow <= 4) {
  6844  	                    invKeySchedule[invKsRow] = t;
  6845  	                } else {
  6846  	                    invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  6847  	                                               INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  6848  	                }
  6849  	            }
  6850  	        },
  6851  
  6852  	        encryptBlock: function (M, offset) {
  6853  	            this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  6854  	        },
  6855  
  6856  	        decryptBlock: function (M, offset) {
  6857  	            // Swap 2nd and 4th rows
  6858  	            var t = M[offset + 1];
  6859  	            M[offset + 1] = M[offset + 3];
  6860  	            M[offset + 3] = t;
  6861  
  6862  	            this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  6863  
  6864  	            // Inv swap 2nd and 4th rows
  6865  	            var t = M[offset + 1];
  6866  	            M[offset + 1] = M[offset + 3];
  6867  	            M[offset + 3] = t;
  6868  	        },
  6869  
  6870  	        _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  6871  	            // Shortcut
  6872  	            var nRounds = this._nRounds;
  6873  
  6874  	            // Get input, add round key
  6875  	            var s0 = M[offset]     ^ keySchedule[0];
  6876  	            var s1 = M[offset + 1] ^ keySchedule[1];
  6877  	            var s2 = M[offset + 2] ^ keySchedule[2];
  6878  	            var s3 = M[offset + 3] ^ keySchedule[3];
  6879  
  6880  	            // Key schedule row counter
  6881  	            var ksRow = 4;
  6882  
  6883  	            // Rounds
  6884  	            for (var round = 1; round < nRounds; round++) {
  6885  	                // Shift rows, sub bytes, mix columns, add round key
  6886  	                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++];
  6887  	                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++];
  6888  	                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++];
  6889  	                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++];
  6890  
  6891  	                // Update state
  6892  	                s0 = t0;
  6893  	                s1 = t1;
  6894  	                s2 = t2;
  6895  	                s3 = t3;
  6896  	            }
  6897  
  6898  	            // Shift rows, sub bytes, add round key
  6899  	            var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  6900  	            var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  6901  	            var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  6902  	            var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  6903  
  6904  	            // Set output
  6905  	            M[offset]     = t0;
  6906  	            M[offset + 1] = t1;
  6907  	            M[offset + 2] = t2;
  6908  	            M[offset + 3] = t3;
  6909  	        },
  6910  
  6911  	        keySize: 256/32
  6912  	    });
  6913  
  6914  	    /**
  6915  	     * Shortcut functions to the cipher's object interface.
  6916  	     *
  6917  	     * @example
  6918  	     *
  6919  	     *     var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  6920  	     *     var plaintext  = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  6921  	     */
  6922  	    C.AES = BlockCipher._createHelper(AES);
  6923  	}());
  6924  
  6925  
  6926  	return CryptoJS.AES;
  6927  
  6928  }));
  6929  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],52:[function(require,module,exports){
  6930  ;(function (root, factory) {
  6931  	if (typeof exports === "object") {
  6932  		// CommonJS
  6933  		module.exports = exports = factory(require("./core"));
  6934  	}
  6935  	else if (typeof define === "function" && define.amd) {
  6936  		// AMD
  6937  		define(["./core"], factory);
  6938  	}
  6939  	else {
  6940  		// Global (browser)
  6941  		factory(root.CryptoJS);
  6942  	}
  6943  }(this, function (CryptoJS) {
  6944  
  6945  	/**
  6946  	 * Cipher core components.
  6947  	 */
  6948  	CryptoJS.lib.Cipher || (function (undefined) {
  6949  	    // Shortcuts
  6950  	    var C = CryptoJS;
  6951  	    var C_lib = C.lib;
  6952  	    var Base = C_lib.Base;
  6953  	    var WordArray = C_lib.WordArray;
  6954  	    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  6955  	    var C_enc = C.enc;
  6956  	    var Utf8 = C_enc.Utf8;
  6957  	    var Base64 = C_enc.Base64;
  6958  	    var C_algo = C.algo;
  6959  	    var EvpKDF = C_algo.EvpKDF;
  6960  
  6961  	    /**
  6962  	     * Abstract base cipher template.
  6963  	     *
  6964  	     * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  6965  	     * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  6966  	     * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  6967  	     * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  6968  	     */
  6969  	    var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  6970  	        /**
  6971  	         * Configuration options.
  6972  	         *
  6973  	         * @property {WordArray} iv The IV to use for this operation.
  6974  	         */
  6975  	        cfg: Base.extend(),
  6976  
  6977  	        /**
  6978  	         * Creates this cipher in encryption mode.
  6979  	         *
  6980  	         * @param {WordArray} key The key.
  6981  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6982  	         *
  6983  	         * @return {Cipher} A cipher instance.
  6984  	         *
  6985  	         * @static
  6986  	         *
  6987  	         * @example
  6988  	         *
  6989  	         *     var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  6990  	         */
  6991  	        createEncryptor: function (key, cfg) {
  6992  	            return this.create(this._ENC_XFORM_MODE, key, cfg);
  6993  	        },
  6994  
  6995  	        /**
  6996  	         * Creates this cipher in decryption mode.
  6997  	         *
  6998  	         * @param {WordArray} key The key.
  6999  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7000  	         *
  7001  	         * @return {Cipher} A cipher instance.
  7002  	         *
  7003  	         * @static
  7004  	         *
  7005  	         * @example
  7006  	         *
  7007  	         *     var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  7008  	         */
  7009  	        createDecryptor: function (key, cfg) {
  7010  	            return this.create(this._DEC_XFORM_MODE, key, cfg);
  7011  	        },
  7012  
  7013  	        /**
  7014  	         * Initializes a newly created cipher.
  7015  	         *
  7016  	         * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  7017  	         * @param {WordArray} key The key.
  7018  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7019  	         *
  7020  	         * @example
  7021  	         *
  7022  	         *     var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  7023  	         */
  7024  	        init: function (xformMode, key, cfg) {
  7025  	            // Apply config defaults
  7026  	            this.cfg = this.cfg.extend(cfg);
  7027  
  7028  	            // Store transform mode and key
  7029  	            this._xformMode = xformMode;
  7030  	            this._key = key;
  7031  
  7032  	            // Set initial values
  7033  	            this.reset();
  7034  	        },
  7035  
  7036  	        /**
  7037  	         * Resets this cipher to its initial state.
  7038  	         *
  7039  	         * @example
  7040  	         *
  7041  	         *     cipher.reset();
  7042  	         */
  7043  	        reset: function () {
  7044  	            // Reset data buffer
  7045  	            BufferedBlockAlgorithm.reset.call(this);
  7046  
  7047  	            // Perform concrete-cipher logic
  7048  	            this._doReset();
  7049  	        },
  7050  
  7051  	        /**
  7052  	         * Adds data to be encrypted or decrypted.
  7053  	         *
  7054  	         * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  7055  	         *
  7056  	         * @return {WordArray} The data after processing.
  7057  	         *
  7058  	         * @example
  7059  	         *
  7060  	         *     var encrypted = cipher.process('data');
  7061  	         *     var encrypted = cipher.process(wordArray);
  7062  	         */
  7063  	        process: function (dataUpdate) {
  7064  	            // Append
  7065  	            this._append(dataUpdate);
  7066  
  7067  	            // Process available blocks
  7068  	            return this._process();
  7069  	        },
  7070  
  7071  	        /**
  7072  	         * Finalizes the encryption or decryption process.
  7073  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  7074  	         *
  7075  	         * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  7076  	         *
  7077  	         * @return {WordArray} The data after final processing.
  7078  	         *
  7079  	         * @example
  7080  	         *
  7081  	         *     var encrypted = cipher.finalize();
  7082  	         *     var encrypted = cipher.finalize('data');
  7083  	         *     var encrypted = cipher.finalize(wordArray);
  7084  	         */
  7085  	        finalize: function (dataUpdate) {
  7086  	            // Final data update
  7087  	            if (dataUpdate) {
  7088  	                this._append(dataUpdate);
  7089  	            }
  7090  
  7091  	            // Perform concrete-cipher logic
  7092  	            var finalProcessedData = this._doFinalize();
  7093  
  7094  	            return finalProcessedData;
  7095  	        },
  7096  
  7097  	        keySize: 128/32,
  7098  
  7099  	        ivSize: 128/32,
  7100  
  7101  	        _ENC_XFORM_MODE: 1,
  7102  
  7103  	        _DEC_XFORM_MODE: 2,
  7104  
  7105  	        /**
  7106  	         * Creates shortcut functions to a cipher's object interface.
  7107  	         *
  7108  	         * @param {Cipher} cipher The cipher to create a helper for.
  7109  	         *
  7110  	         * @return {Object} An object with encrypt and decrypt shortcut functions.
  7111  	         *
  7112  	         * @static
  7113  	         *
  7114  	         * @example
  7115  	         *
  7116  	         *     var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  7117  	         */
  7118  	        _createHelper: (function () {
  7119  	            function selectCipherStrategy(key) {
  7120  	                if (typeof key == 'string') {
  7121  	                    return PasswordBasedCipher;
  7122  	                } else {
  7123  	                    return SerializableCipher;
  7124  	                }
  7125  	            }
  7126  
  7127  	            return function (cipher) {
  7128  	                return {
  7129  	                    encrypt: function (message, key, cfg) {
  7130  	                        return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  7131  	                    },
  7132  
  7133  	                    decrypt: function (ciphertext, key, cfg) {
  7134  	                        return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  7135  	                    }
  7136  	                };
  7137  	            };
  7138  	        }())
  7139  	    });
  7140  
  7141  	    /**
  7142  	     * Abstract base stream cipher template.
  7143  	     *
  7144  	     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  7145  	     */
  7146  	    var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  7147  	        _doFinalize: function () {
  7148  	            // Process partial blocks
  7149  	            var finalProcessedBlocks = this._process(!!'flush');
  7150  
  7151  	            return finalProcessedBlocks;
  7152  	        },
  7153  
  7154  	        blockSize: 1
  7155  	    });
  7156  
  7157  	    /**
  7158  	     * Mode namespace.
  7159  	     */
  7160  	    var C_mode = C.mode = {};
  7161  
  7162  	    /**
  7163  	     * Abstract base block cipher mode template.
  7164  	     */
  7165  	    var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  7166  	        /**
  7167  	         * Creates this mode for encryption.
  7168  	         *
  7169  	         * @param {Cipher} cipher A block cipher instance.
  7170  	         * @param {Array} iv The IV words.
  7171  	         *
  7172  	         * @static
  7173  	         *
  7174  	         * @example
  7175  	         *
  7176  	         *     var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  7177  	         */
  7178  	        createEncryptor: function (cipher, iv) {
  7179  	            return this.Encryptor.create(cipher, iv);
  7180  	        },
  7181  
  7182  	        /**
  7183  	         * Creates this mode for decryption.
  7184  	         *
  7185  	         * @param {Cipher} cipher A block cipher instance.
  7186  	         * @param {Array} iv The IV words.
  7187  	         *
  7188  	         * @static
  7189  	         *
  7190  	         * @example
  7191  	         *
  7192  	         *     var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  7193  	         */
  7194  	        createDecryptor: function (cipher, iv) {
  7195  	            return this.Decryptor.create(cipher, iv);
  7196  	        },
  7197  
  7198  	        /**
  7199  	         * Initializes a newly created mode.
  7200  	         *
  7201  	         * @param {Cipher} cipher A block cipher instance.
  7202  	         * @param {Array} iv The IV words.
  7203  	         *
  7204  	         * @example
  7205  	         *
  7206  	         *     var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  7207  	         */
  7208  	        init: function (cipher, iv) {
  7209  	            this._cipher = cipher;
  7210  	            this._iv = iv;
  7211  	        }
  7212  	    });
  7213  
  7214  	    /**
  7215  	     * Cipher Block Chaining mode.
  7216  	     */
  7217  	    var CBC = C_mode.CBC = (function () {
  7218  	        /**
  7219  	         * Abstract base CBC mode.
  7220  	         */
  7221  	        var CBC = BlockCipherMode.extend();
  7222  
  7223  	        /**
  7224  	         * CBC encryptor.
  7225  	         */
  7226  	        CBC.Encryptor = CBC.extend({
  7227  	            /**
  7228  	             * Processes the data block at offset.
  7229  	             *
  7230  	             * @param {Array} words The data words to operate on.
  7231  	             * @param {number} offset The offset where the block starts.
  7232  	             *
  7233  	             * @example
  7234  	             *
  7235  	             *     mode.processBlock(data.words, offset);
  7236  	             */
  7237  	            processBlock: function (words, offset) {
  7238  	                // Shortcuts
  7239  	                var cipher = this._cipher;
  7240  	                var blockSize = cipher.blockSize;
  7241  
  7242  	                // XOR and encrypt
  7243  	                xorBlock.call(this, words, offset, blockSize);
  7244  	                cipher.encryptBlock(words, offset);
  7245  
  7246  	                // Remember this block to use with next block
  7247  	                this._prevBlock = words.slice(offset, offset + blockSize);
  7248  	            }
  7249  	        });
  7250  
  7251  	        /**
  7252  	         * CBC decryptor.
  7253  	         */
  7254  	        CBC.Decryptor = CBC.extend({
  7255  	            /**
  7256  	             * Processes the data block at offset.
  7257  	             *
  7258  	             * @param {Array} words The data words to operate on.
  7259  	             * @param {number} offset The offset where the block starts.
  7260  	             *
  7261  	             * @example
  7262  	             *
  7263  	             *     mode.processBlock(data.words, offset);
  7264  	             */
  7265  	            processBlock: function (words, offset) {
  7266  	                // Shortcuts
  7267  	                var cipher = this._cipher;
  7268  	                var blockSize = cipher.blockSize;
  7269  
  7270  	                // Remember this block to use with next block
  7271  	                var thisBlock = words.slice(offset, offset + blockSize);
  7272  
  7273  	                // Decrypt and XOR
  7274  	                cipher.decryptBlock(words, offset);
  7275  	                xorBlock.call(this, words, offset, blockSize);
  7276  
  7277  	                // This block becomes the previous block
  7278  	                this._prevBlock = thisBlock;
  7279  	            }
  7280  	        });
  7281  
  7282  	        function xorBlock(words, offset, blockSize) {
  7283  	            // Shortcut
  7284  	            var iv = this._iv;
  7285  
  7286  	            // Choose mixing block
  7287  	            if (iv) {
  7288  	                var block = iv;
  7289  
  7290  	                // Remove IV for subsequent blocks
  7291  	                this._iv = undefined;
  7292  	            } else {
  7293  	                var block = this._prevBlock;
  7294  	            }
  7295  
  7296  	            // XOR blocks
  7297  	            for (var i = 0; i < blockSize; i++) {
  7298  	                words[offset + i] ^= block[i];
  7299  	            }
  7300  	        }
  7301  
  7302  	        return CBC;
  7303  	    }());
  7304  
  7305  	    /**
  7306  	     * Padding namespace.
  7307  	     */
  7308  	    var C_pad = C.pad = {};
  7309  
  7310  	    /**
  7311  	     * PKCS #5/7 padding strategy.
  7312  	     */
  7313  	    var Pkcs7 = C_pad.Pkcs7 = {
  7314  	        /**
  7315  	         * Pads data using the algorithm defined in PKCS #5/7.
  7316  	         *
  7317  	         * @param {WordArray} data The data to pad.
  7318  	         * @param {number} blockSize The multiple that the data should be padded to.
  7319  	         *
  7320  	         * @static
  7321  	         *
  7322  	         * @example
  7323  	         *
  7324  	         *     CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  7325  	         */
  7326  	        pad: function (data, blockSize) {
  7327  	            // Shortcut
  7328  	            var blockSizeBytes = blockSize * 4;
  7329  
  7330  	            // Count padding bytes
  7331  	            var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  7332  
  7333  	            // Create padding word
  7334  	            var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  7335  
  7336  	            // Create padding
  7337  	            var paddingWords = [];
  7338  	            for (var i = 0; i < nPaddingBytes; i += 4) {
  7339  	                paddingWords.push(paddingWord);
  7340  	            }
  7341  	            var padding = WordArray.create(paddingWords, nPaddingBytes);
  7342  
  7343  	            // Add padding
  7344  	            data.concat(padding);
  7345  	        },
  7346  
  7347  	        /**
  7348  	         * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  7349  	         *
  7350  	         * @param {WordArray} data The data to unpad.
  7351  	         *
  7352  	         * @static
  7353  	         *
  7354  	         * @example
  7355  	         *
  7356  	         *     CryptoJS.pad.Pkcs7.unpad(wordArray);
  7357  	         */
  7358  	        unpad: function (data) {
  7359  	            // Get number of padding bytes from last byte
  7360  	            var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  7361  
  7362  	            // Remove padding
  7363  	            data.sigBytes -= nPaddingBytes;
  7364  	        }
  7365  	    };
  7366  
  7367  	    /**
  7368  	     * Abstract base block cipher template.
  7369  	     *
  7370  	     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  7371  	     */
  7372  	    var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  7373  	        /**
  7374  	         * Configuration options.
  7375  	         *
  7376  	         * @property {Mode} mode The block mode to use. Default: CBC
  7377  	         * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  7378  	         */
  7379  	        cfg: Cipher.cfg.extend({
  7380  	            mode: CBC,
  7381  	            padding: Pkcs7
  7382  	        }),
  7383  
  7384  	        reset: function () {
  7385  	            // Reset cipher
  7386  	            Cipher.reset.call(this);
  7387  
  7388  	            // Shortcuts
  7389  	            var cfg = this.cfg;
  7390  	            var iv = cfg.iv;
  7391  	            var mode = cfg.mode;
  7392  
  7393  	            // Reset block mode
  7394  	            if (this._xformMode == this._ENC_XFORM_MODE) {
  7395  	                var modeCreator = mode.createEncryptor;
  7396  	            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7397  	                var modeCreator = mode.createDecryptor;
  7398  
  7399  	                // Keep at least one block in the buffer for unpadding
  7400  	                this._minBufferSize = 1;
  7401  	            }
  7402  	            this._mode = modeCreator.call(mode, this, iv && iv.words);
  7403  	        },
  7404  
  7405  	        _doProcessBlock: function (words, offset) {
  7406  	            this._mode.processBlock(words, offset);
  7407  	        },
  7408  
  7409  	        _doFinalize: function () {
  7410  	            // Shortcut
  7411  	            var padding = this.cfg.padding;
  7412  
  7413  	            // Finalize
  7414  	            if (this._xformMode == this._ENC_XFORM_MODE) {
  7415  	                // Pad data
  7416  	                padding.pad(this._data, this.blockSize);
  7417  
  7418  	                // Process final blocks
  7419  	                var finalProcessedBlocks = this._process(!!'flush');
  7420  	            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7421  	                // Process final blocks
  7422  	                var finalProcessedBlocks = this._process(!!'flush');
  7423  
  7424  	                // Unpad data
  7425  	                padding.unpad(finalProcessedBlocks);
  7426  	            }
  7427  
  7428  	            return finalProcessedBlocks;
  7429  	        },
  7430  
  7431  	        blockSize: 128/32
  7432  	    });
  7433  
  7434  	    /**
  7435  	     * A collection of cipher parameters.
  7436  	     *
  7437  	     * @property {WordArray} ciphertext The raw ciphertext.
  7438  	     * @property {WordArray} key The key to this ciphertext.
  7439  	     * @property {WordArray} iv The IV used in the ciphering operation.
  7440  	     * @property {WordArray} salt The salt used with a key derivation function.
  7441  	     * @property {Cipher} algorithm The cipher algorithm.
  7442  	     * @property {Mode} mode The block mode used in the ciphering operation.
  7443  	     * @property {Padding} padding The padding scheme used in the ciphering operation.
  7444  	     * @property {number} blockSize The block size of the cipher.
  7445  	     * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  7446  	     */
  7447  	    var CipherParams = C_lib.CipherParams = Base.extend({
  7448  	        /**
  7449  	         * Initializes a newly created cipher params object.
  7450  	         *
  7451  	         * @param {Object} cipherParams An object with any of the possible cipher parameters.
  7452  	         *
  7453  	         * @example
  7454  	         *
  7455  	         *     var cipherParams = CryptoJS.lib.CipherParams.create({
  7456  	         *         ciphertext: ciphertextWordArray,
  7457  	         *         key: keyWordArray,
  7458  	         *         iv: ivWordArray,
  7459  	         *         salt: saltWordArray,
  7460  	         *         algorithm: CryptoJS.algo.AES,
  7461  	         *         mode: CryptoJS.mode.CBC,
  7462  	         *         padding: CryptoJS.pad.PKCS7,
  7463  	         *         blockSize: 4,
  7464  	         *         formatter: CryptoJS.format.OpenSSL
  7465  	         *     });
  7466  	         */
  7467  	        init: function (cipherParams) {
  7468  	            this.mixIn(cipherParams);
  7469  	        },
  7470  
  7471  	        /**
  7472  	         * Converts this cipher params object to a string.
  7473  	         *
  7474  	         * @param {Format} formatter (Optional) The formatting strategy to use.
  7475  	         *
  7476  	         * @return {string} The stringified cipher params.
  7477  	         *
  7478  	         * @throws Error If neither the formatter nor the default formatter is set.
  7479  	         *
  7480  	         * @example
  7481  	         *
  7482  	         *     var string = cipherParams + '';
  7483  	         *     var string = cipherParams.toString();
  7484  	         *     var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  7485  	         */
  7486  	        toString: function (formatter) {
  7487  	            return (formatter || this.formatter).stringify(this);
  7488  	        }
  7489  	    });
  7490  
  7491  	    /**
  7492  	     * Format namespace.
  7493  	     */
  7494  	    var C_format = C.format = {};
  7495  
  7496  	    /**
  7497  	     * OpenSSL formatting strategy.
  7498  	     */
  7499  	    var OpenSSLFormatter = C_format.OpenSSL = {
  7500  	        /**
  7501  	         * Converts a cipher params object to an OpenSSL-compatible string.
  7502  	         *
  7503  	         * @param {CipherParams} cipherParams The cipher params object.
  7504  	         *
  7505  	         * @return {string} The OpenSSL-compatible string.
  7506  	         *
  7507  	         * @static
  7508  	         *
  7509  	         * @example
  7510  	         *
  7511  	         *     var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  7512  	         */
  7513  	        stringify: function (cipherParams) {
  7514  	            // Shortcuts
  7515  	            var ciphertext = cipherParams.ciphertext;
  7516  	            var salt = cipherParams.salt;
  7517  
  7518  	            // Format
  7519  	            if (salt) {
  7520  	                var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  7521  	            } else {
  7522  	                var wordArray = ciphertext;
  7523  	            }
  7524  
  7525  	            return wordArray.toString(Base64);
  7526  	        },
  7527  
  7528  	        /**
  7529  	         * Converts an OpenSSL-compatible string to a cipher params object.
  7530  	         *
  7531  	         * @param {string} openSSLStr The OpenSSL-compatible string.
  7532  	         *
  7533  	         * @return {CipherParams} The cipher params object.
  7534  	         *
  7535  	         * @static
  7536  	         *
  7537  	         * @example
  7538  	         *
  7539  	         *     var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  7540  	         */
  7541  	        parse: function (openSSLStr) {
  7542  	            // Parse base64
  7543  	            var ciphertext = Base64.parse(openSSLStr);
  7544  
  7545  	            // Shortcut
  7546  	            var ciphertextWords = ciphertext.words;
  7547  
  7548  	            // Test for salt
  7549  	            if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  7550  	                // Extract salt
  7551  	                var salt = WordArray.create(ciphertextWords.slice(2, 4));
  7552  
  7553  	                // Remove salt from ciphertext
  7554  	                ciphertextWords.splice(0, 4);
  7555  	                ciphertext.sigBytes -= 16;
  7556  	            }
  7557  
  7558  	            return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  7559  	        }
  7560  	    };
  7561  
  7562  	    /**
  7563  	     * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  7564  	     */
  7565  	    var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  7566  	        /**
  7567  	         * Configuration options.
  7568  	         *
  7569  	         * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  7570  	         */
  7571  	        cfg: Base.extend({
  7572  	            format: OpenSSLFormatter
  7573  	        }),
  7574  
  7575  	        /**
  7576  	         * Encrypts a message.
  7577  	         *
  7578  	         * @param {Cipher} cipher The cipher algorithm to use.
  7579  	         * @param {WordArray|string} message The message to encrypt.
  7580  	         * @param {WordArray} key The key.
  7581  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7582  	         *
  7583  	         * @return {CipherParams} A cipher params object.
  7584  	         *
  7585  	         * @static
  7586  	         *
  7587  	         * @example
  7588  	         *
  7589  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  7590  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  7591  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7592  	         */
  7593  	        encrypt: function (cipher, message, key, cfg) {
  7594  	            // Apply config defaults
  7595  	            cfg = this.cfg.extend(cfg);
  7596  
  7597  	            // Encrypt
  7598  	            var encryptor = cipher.createEncryptor(key, cfg);
  7599  	            var ciphertext = encryptor.finalize(message);
  7600  
  7601  	            // Shortcut
  7602  	            var cipherCfg = encryptor.cfg;
  7603  
  7604  	            // Create and return serializable cipher params
  7605  	            return CipherParams.create({
  7606  	                ciphertext: ciphertext,
  7607  	                key: key,
  7608  	                iv: cipherCfg.iv,
  7609  	                algorithm: cipher,
  7610  	                mode: cipherCfg.mode,
  7611  	                padding: cipherCfg.padding,
  7612  	                blockSize: cipher.blockSize,
  7613  	                formatter: cfg.format
  7614  	            });
  7615  	        },
  7616  
  7617  	        /**
  7618  	         * Decrypts serialized ciphertext.
  7619  	         *
  7620  	         * @param {Cipher} cipher The cipher algorithm to use.
  7621  	         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7622  	         * @param {WordArray} key The key.
  7623  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7624  	         *
  7625  	         * @return {WordArray} The plaintext.
  7626  	         *
  7627  	         * @static
  7628  	         *
  7629  	         * @example
  7630  	         *
  7631  	         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7632  	         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7633  	         */
  7634  	        decrypt: function (cipher, ciphertext, key, cfg) {
  7635  	            // Apply config defaults
  7636  	            cfg = this.cfg.extend(cfg);
  7637  
  7638  	            // Convert string to CipherParams
  7639  	            ciphertext = this._parse(ciphertext, cfg.format);
  7640  
  7641  	            // Decrypt
  7642  	            var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  7643  
  7644  	            return plaintext;
  7645  	        },
  7646  
  7647  	        /**
  7648  	         * Converts serialized ciphertext to CipherParams,
  7649  	         * else assumed CipherParams already and returns ciphertext unchanged.
  7650  	         *
  7651  	         * @param {CipherParams|string} ciphertext The ciphertext.
  7652  	         * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  7653  	         *
  7654  	         * @return {CipherParams} The unserialized ciphertext.
  7655  	         *
  7656  	         * @static
  7657  	         *
  7658  	         * @example
  7659  	         *
  7660  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  7661  	         */
  7662  	        _parse: function (ciphertext, format) {
  7663  	            if (typeof ciphertext == 'string') {
  7664  	                return format.parse(ciphertext, this);
  7665  	            } else {
  7666  	                return ciphertext;
  7667  	            }
  7668  	        }
  7669  	    });
  7670  
  7671  	    /**
  7672  	     * Key derivation function namespace.
  7673  	     */
  7674  	    var C_kdf = C.kdf = {};
  7675  
  7676  	    /**
  7677  	     * OpenSSL key derivation function.
  7678  	     */
  7679  	    var OpenSSLKdf = C_kdf.OpenSSL = {
  7680  	        /**
  7681  	         * Derives a key and IV from a password.
  7682  	         *
  7683  	         * @param {string} password The password to derive from.
  7684  	         * @param {number} keySize The size in words of the key to generate.
  7685  	         * @param {number} ivSize The size in words of the IV to generate.
  7686  	         * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  7687  	         *
  7688  	         * @return {CipherParams} A cipher params object with the key, IV, and salt.
  7689  	         *
  7690  	         * @static
  7691  	         *
  7692  	         * @example
  7693  	         *
  7694  	         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  7695  	         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  7696  	         */
  7697  	        execute: function (password, keySize, ivSize, salt) {
  7698  	            // Generate random salt
  7699  	            if (!salt) {
  7700  	                salt = WordArray.random(64/8);
  7701  	            }
  7702  
  7703  	            // Derive key and IV
  7704  	            var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  7705  
  7706  	            // Separate key and IV
  7707  	            var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  7708  	            key.sigBytes = keySize * 4;
  7709  
  7710  	            // Return params
  7711  	            return CipherParams.create({ key: key, iv: iv, salt: salt });
  7712  	        }
  7713  	    };
  7714  
  7715  	    /**
  7716  	     * A serializable cipher wrapper that derives the key from a password,
  7717  	     * and returns ciphertext as a serializable cipher params object.
  7718  	     */
  7719  	    var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  7720  	        /**
  7721  	         * Configuration options.
  7722  	         *
  7723  	         * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  7724  	         */
  7725  	        cfg: SerializableCipher.cfg.extend({
  7726  	            kdf: OpenSSLKdf
  7727  	        }),
  7728  
  7729  	        /**
  7730  	         * Encrypts a message using a password.
  7731  	         *
  7732  	         * @param {Cipher} cipher The cipher algorithm to use.
  7733  	         * @param {WordArray|string} message The message to encrypt.
  7734  	         * @param {string} password The password.
  7735  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7736  	         *
  7737  	         * @return {CipherParams} A cipher params object.
  7738  	         *
  7739  	         * @static
  7740  	         *
  7741  	         * @example
  7742  	         *
  7743  	         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  7744  	         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  7745  	         */
  7746  	        encrypt: function (cipher, message, password, cfg) {
  7747  	            // Apply config defaults
  7748  	            cfg = this.cfg.extend(cfg);
  7749  
  7750  	            // Derive key and other params
  7751  	            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  7752  
  7753  	            // Add IV to config
  7754  	            cfg.iv = derivedParams.iv;
  7755  
  7756  	            // Encrypt
  7757  	            var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  7758  
  7759  	            // Mix in derived params
  7760  	            ciphertext.mixIn(derivedParams);
  7761  
  7762  	            return ciphertext;
  7763  	        },
  7764  
  7765  	        /**
  7766  	         * Decrypts serialized ciphertext using a password.
  7767  	         *
  7768  	         * @param {Cipher} cipher The cipher algorithm to use.
  7769  	         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7770  	         * @param {string} password The password.
  7771  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7772  	         *
  7773  	         * @return {WordArray} The plaintext.
  7774  	         *
  7775  	         * @static
  7776  	         *
  7777  	         * @example
  7778  	         *
  7779  	         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  7780  	         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  7781  	         */
  7782  	        decrypt: function (cipher, ciphertext, password, cfg) {
  7783  	            // Apply config defaults
  7784  	            cfg = this.cfg.extend(cfg);
  7785  
  7786  	            // Convert string to CipherParams
  7787  	            ciphertext = this._parse(ciphertext, cfg.format);
  7788  
  7789  	            // Derive key and other params
  7790  	            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  7791  
  7792  	            // Add IV to config
  7793  	            cfg.iv = derivedParams.iv;
  7794  
  7795  	            // Decrypt
  7796  	            var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  7797  
  7798  	            return plaintext;
  7799  	        }
  7800  	    });
  7801  	}());
  7802  
  7803  
  7804  }));
  7805  },{"./core":53}],53:[function(require,module,exports){
  7806  ;(function (root, factory) {
  7807  	if (typeof exports === "object") {
  7808  		// CommonJS
  7809  		module.exports = exports = factory();
  7810  	}
  7811  	else if (typeof define === "function" && define.amd) {
  7812  		// AMD
  7813  		define([], factory);
  7814  	}
  7815  	else {
  7816  		// Global (browser)
  7817  		root.CryptoJS = factory();
  7818  	}
  7819  }(this, function () {
  7820  
  7821  	/**
  7822  	 * CryptoJS core components.
  7823  	 */
  7824  	var CryptoJS = CryptoJS || (function (Math, undefined) {
  7825  	    /*
  7826  	     * Local polyfil of Object.create
  7827  	     */
  7828  	    var create = Object.create || (function () {
  7829  	        function F() {};
  7830  
  7831  	        return function (obj) {
  7832  	            var subtype;
  7833  
  7834  	            F.prototype = obj;
  7835  
  7836  	            subtype = new F();
  7837  
  7838  	            F.prototype = null;
  7839  
  7840  	            return subtype;
  7841  	        };
  7842  	    }())
  7843  
  7844  	    /**
  7845  	     * CryptoJS namespace.
  7846  	     */
  7847  	    var C = {};
  7848  
  7849  	    /**
  7850  	     * Library namespace.
  7851  	     */
  7852  	    var C_lib = C.lib = {};
  7853  
  7854  	    /**
  7855  	     * Base object for prototypal inheritance.
  7856  	     */
  7857  	    var Base = C_lib.Base = (function () {
  7858  
  7859  
  7860  	        return {
  7861  	            /**
  7862  	             * Creates a new object that inherits from this object.
  7863  	             *
  7864  	             * @param {Object} overrides Properties to copy into the new object.
  7865  	             *
  7866  	             * @return {Object} The new object.
  7867  	             *
  7868  	             * @static
  7869  	             *
  7870  	             * @example
  7871  	             *
  7872  	             *     var MyType = CryptoJS.lib.Base.extend({
  7873  	             *         field: 'value',
  7874  	             *
  7875  	             *         method: function () {
  7876  	             *         }
  7877  	             *     });
  7878  	             */
  7879  	            extend: function (overrides) {
  7880  	                // Spawn
  7881  	                var subtype = create(this);
  7882  
  7883  	                // Augment
  7884  	                if (overrides) {
  7885  	                    subtype.mixIn(overrides);
  7886  	                }
  7887  
  7888  	                // Create default initializer
  7889  	                if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  7890  	                    subtype.init = function () {
  7891  	                        subtype.$super.init.apply(this, arguments);
  7892  	                    };
  7893  	                }
  7894  
  7895  	                // Initializer's prototype is the subtype object
  7896  	                subtype.init.prototype = subtype;
  7897  
  7898  	                // Reference supertype
  7899  	                subtype.$super = this;
  7900  
  7901  	                return subtype;
  7902  	            },
  7903  
  7904  	            /**
  7905  	             * Extends this object and runs the init method.
  7906  	             * Arguments to create() will be passed to init().
  7907  	             *
  7908  	             * @return {Object} The new object.
  7909  	             *
  7910  	             * @static
  7911  	             *
  7912  	             * @example
  7913  	             *
  7914  	             *     var instance = MyType.create();
  7915  	             */
  7916  	            create: function () {
  7917  	                var instance = this.extend();
  7918  	                instance.init.apply(instance, arguments);
  7919  
  7920  	                return instance;
  7921  	            },
  7922  
  7923  	            /**
  7924  	             * Initializes a newly created object.
  7925  	             * Override this method to add some logic when your objects are created.
  7926  	             *
  7927  	             * @example
  7928  	             *
  7929  	             *     var MyType = CryptoJS.lib.Base.extend({
  7930  	             *         init: function () {
  7931  	             *             // ...
  7932  	             *         }
  7933  	             *     });
  7934  	             */
  7935  	            init: function () {
  7936  	            },
  7937  
  7938  	            /**
  7939  	             * Copies properties into this object.
  7940  	             *
  7941  	             * @param {Object} properties The properties to mix in.
  7942  	             *
  7943  	             * @example
  7944  	             *
  7945  	             *     MyType.mixIn({
  7946  	             *         field: 'value'
  7947  	             *     });
  7948  	             */
  7949  	            mixIn: function (properties) {
  7950  	                for (var propertyName in properties) {
  7951  	                    if (properties.hasOwnProperty(propertyName)) {
  7952  	                        this[propertyName] = properties[propertyName];
  7953  	                    }
  7954  	                }
  7955  
  7956  	                // IE won't copy toString using the loop above
  7957  	                if (properties.hasOwnProperty('toString')) {
  7958  	                    this.toString = properties.toString;
  7959  	                }
  7960  	            },
  7961  
  7962  	            /**
  7963  	             * Creates a copy of this object.
  7964  	             *
  7965  	             * @return {Object} The clone.
  7966  	             *
  7967  	             * @example
  7968  	             *
  7969  	             *     var clone = instance.clone();
  7970  	             */
  7971  	            clone: function () {
  7972  	                return this.init.prototype.extend(this);
  7973  	            }
  7974  	        };
  7975  	    }());
  7976  
  7977  	    /**
  7978  	     * An array of 32-bit words.
  7979  	     *
  7980  	     * @property {Array} words The array of 32-bit words.
  7981  	     * @property {number} sigBytes The number of significant bytes in this word array.
  7982  	     */
  7983  	    var WordArray = C_lib.WordArray = Base.extend({
  7984  	        /**
  7985  	         * Initializes a newly created word array.
  7986  	         *
  7987  	         * @param {Array} words (Optional) An array of 32-bit words.
  7988  	         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  7989  	         *
  7990  	         * @example
  7991  	         *
  7992  	         *     var wordArray = CryptoJS.lib.WordArray.create();
  7993  	         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  7994  	         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  7995  	         */
  7996  	        init: function (words, sigBytes) {
  7997  	            words = this.words = words || [];
  7998  
  7999  	            if (sigBytes != undefined) {
  8000  	                this.sigBytes = sigBytes;
  8001  	            } else {
  8002  	                this.sigBytes = words.length * 4;
  8003  	            }
  8004  	        },
  8005  
  8006  	        /**
  8007  	         * Converts this word array to a string.
  8008  	         *
  8009  	         * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  8010  	         *
  8011  	         * @return {string} The stringified word array.
  8012  	         *
  8013  	         * @example
  8014  	         *
  8015  	         *     var string = wordArray + '';
  8016  	         *     var string = wordArray.toString();
  8017  	         *     var string = wordArray.toString(CryptoJS.enc.Utf8);
  8018  	         */
  8019  	        toString: function (encoder) {
  8020  	            return (encoder || Hex).stringify(this);
  8021  	        },
  8022  
  8023  	        /**
  8024  	         * Concatenates a word array to this word array.
  8025  	         *
  8026  	         * @param {WordArray} wordArray The word array to append.
  8027  	         *
  8028  	         * @return {WordArray} This word array.
  8029  	         *
  8030  	         * @example
  8031  	         *
  8032  	         *     wordArray1.concat(wordArray2);
  8033  	         */
  8034  	        concat: function (wordArray) {
  8035  	            // Shortcuts
  8036  	            var thisWords = this.words;
  8037  	            var thatWords = wordArray.words;
  8038  	            var thisSigBytes = this.sigBytes;
  8039  	            var thatSigBytes = wordArray.sigBytes;
  8040  
  8041  	            // Clamp excess bits
  8042  	            this.clamp();
  8043  
  8044  	            // Concat
  8045  	            if (thisSigBytes % 4) {
  8046  	                // Copy one byte at a time
  8047  	                for (var i = 0; i < thatSigBytes; i++) {
  8048  	                    var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8049  	                    thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  8050  	                }
  8051  	            } else {
  8052  	                // Copy one word at a time
  8053  	                for (var i = 0; i < thatSigBytes; i += 4) {
  8054  	                    thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
  8055  	                }
  8056  	            }
  8057  	            this.sigBytes += thatSigBytes;
  8058  
  8059  	            // Chainable
  8060  	            return this;
  8061  	        },
  8062  
  8063  	        /**
  8064  	         * Removes insignificant bits.
  8065  	         *
  8066  	         * @example
  8067  	         *
  8068  	         *     wordArray.clamp();
  8069  	         */
  8070  	        clamp: function () {
  8071  	            // Shortcuts
  8072  	            var words = this.words;
  8073  	            var sigBytes = this.sigBytes;
  8074  
  8075  	            // Clamp
  8076  	            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  8077  	            words.length = Math.ceil(sigBytes / 4);
  8078  	        },
  8079  
  8080  	        /**
  8081  	         * Creates a copy of this word array.
  8082  	         *
  8083  	         * @return {WordArray} The clone.
  8084  	         *
  8085  	         * @example
  8086  	         *
  8087  	         *     var clone = wordArray.clone();
  8088  	         */
  8089  	        clone: function () {
  8090  	            var clone = Base.clone.call(this);
  8091  	            clone.words = this.words.slice(0);
  8092  
  8093  	            return clone;
  8094  	        },
  8095  
  8096  	        /**
  8097  	         * Creates a word array filled with random bytes.
  8098  	         *
  8099  	         * @param {number} nBytes The number of random bytes to generate.
  8100  	         *
  8101  	         * @return {WordArray} The random word array.
  8102  	         *
  8103  	         * @static
  8104  	         *
  8105  	         * @example
  8106  	         *
  8107  	         *     var wordArray = CryptoJS.lib.WordArray.random(16);
  8108  	         */
  8109  	        random: function (nBytes) {
  8110  	            var words = [];
  8111  
  8112  	            var r = (function (m_w) {
  8113  	                var m_w = m_w;
  8114  	                var m_z = 0x3ade68b1;
  8115  	                var mask = 0xffffffff;
  8116  
  8117  	                return function () {
  8118  	                    m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
  8119  	                    m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
  8120  	                    var result = ((m_z << 0x10) + m_w) & mask;
  8121  	                    result /= 0x100000000;
  8122  	                    result += 0.5;
  8123  	                    return result * (Math.random() > .5 ? 1 : -1);
  8124  	                }
  8125  	            });
  8126  
  8127  	            for (var i = 0, rcache; i < nBytes; i += 4) {
  8128  	                var _r = r((rcache || Math.random()) * 0x100000000);
  8129  
  8130  	                rcache = _r() * 0x3ade67b7;
  8131  	                words.push((_r() * 0x100000000) | 0);
  8132  	            }
  8133  
  8134  	            return new WordArray.init(words, nBytes);
  8135  	        }
  8136  	    });
  8137  
  8138  	    /**
  8139  	     * Encoder namespace.
  8140  	     */
  8141  	    var C_enc = C.enc = {};
  8142  
  8143  	    /**
  8144  	     * Hex encoding strategy.
  8145  	     */
  8146  	    var Hex = C_enc.Hex = {
  8147  	        /**
  8148  	         * Converts a word array to a hex string.
  8149  	         *
  8150  	         * @param {WordArray} wordArray The word array.
  8151  	         *
  8152  	         * @return {string} The hex string.
  8153  	         *
  8154  	         * @static
  8155  	         *
  8156  	         * @example
  8157  	         *
  8158  	         *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  8159  	         */
  8160  	        stringify: function (wordArray) {
  8161  	            // Shortcuts
  8162  	            var words = wordArray.words;
  8163  	            var sigBytes = wordArray.sigBytes;
  8164  
  8165  	            // Convert
  8166  	            var hexChars = [];
  8167  	            for (var i = 0; i < sigBytes; i++) {
  8168  	                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8169  	                hexChars.push((bite >>> 4).toString(16));
  8170  	                hexChars.push((bite & 0x0f).toString(16));
  8171  	            }
  8172  
  8173  	            return hexChars.join('');
  8174  	        },
  8175  
  8176  	        /**
  8177  	         * Converts a hex string to a word array.
  8178  	         *
  8179  	         * @param {string} hexStr The hex string.
  8180  	         *
  8181  	         * @return {WordArray} The word array.
  8182  	         *
  8183  	         * @static
  8184  	         *
  8185  	         * @example
  8186  	         *
  8187  	         *     var wordArray = CryptoJS.enc.Hex.parse(hexString);
  8188  	         */
  8189  	        parse: function (hexStr) {
  8190  	            // Shortcut
  8191  	            var hexStrLength = hexStr.length;
  8192  
  8193  	            // Convert
  8194  	            var words = [];
  8195  	            for (var i = 0; i < hexStrLength; i += 2) {
  8196  	                words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  8197  	            }
  8198  
  8199  	            return new WordArray.init(words, hexStrLength / 2);
  8200  	        }
  8201  	    };
  8202  
  8203  	    /**
  8204  	     * Latin1 encoding strategy.
  8205  	     */
  8206  	    var Latin1 = C_enc.Latin1 = {
  8207  	        /**
  8208  	         * Converts a word array to a Latin1 string.
  8209  	         *
  8210  	         * @param {WordArray} wordArray The word array.
  8211  	         *
  8212  	         * @return {string} The Latin1 string.
  8213  	         *
  8214  	         * @static
  8215  	         *
  8216  	         * @example
  8217  	         *
  8218  	         *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  8219  	         */
  8220  	        stringify: function (wordArray) {
  8221  	            // Shortcuts
  8222  	            var words = wordArray.words;
  8223  	            var sigBytes = wordArray.sigBytes;
  8224  
  8225  	            // Convert
  8226  	            var latin1Chars = [];
  8227  	            for (var i = 0; i < sigBytes; i++) {
  8228  	                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8229  	                latin1Chars.push(String.fromCharCode(bite));
  8230  	            }
  8231  
  8232  	            return latin1Chars.join('');
  8233  	        },
  8234  
  8235  	        /**
  8236  	         * Converts a Latin1 string to a word array.
  8237  	         *
  8238  	         * @param {string} latin1Str The Latin1 string.
  8239  	         *
  8240  	         * @return {WordArray} The word array.
  8241  	         *
  8242  	         * @static
  8243  	         *
  8244  	         * @example
  8245  	         *
  8246  	         *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  8247  	         */
  8248  	        parse: function (latin1Str) {
  8249  	            // Shortcut
  8250  	            var latin1StrLength = latin1Str.length;
  8251  
  8252  	            // Convert
  8253  	            var words = [];
  8254  	            for (var i = 0; i < latin1StrLength; i++) {
  8255  	                words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  8256  	            }
  8257  
  8258  	            return new WordArray.init(words, latin1StrLength);
  8259  	        }
  8260  	    };
  8261  
  8262  	    /**
  8263  	     * UTF-8 encoding strategy.
  8264  	     */
  8265  	    var Utf8 = C_enc.Utf8 = {
  8266  	        /**
  8267  	         * Converts a word array to a UTF-8 string.
  8268  	         *
  8269  	         * @param {WordArray} wordArray The word array.
  8270  	         *
  8271  	         * @return {string} The UTF-8 string.
  8272  	         *
  8273  	         * @static
  8274  	         *
  8275  	         * @example
  8276  	         *
  8277  	         *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  8278  	         */
  8279  	        stringify: function (wordArray) {
  8280  	            try {
  8281  	                return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  8282  	            } catch (e) {
  8283  	                throw new Error('Malformed UTF-8 data');
  8284  	            }
  8285  	        },
  8286  
  8287  	        /**
  8288  	         * Converts a UTF-8 string to a word array.
  8289  	         *
  8290  	         * @param {string} utf8Str The UTF-8 string.
  8291  	         *
  8292  	         * @return {WordArray} The word array.
  8293  	         *
  8294  	         * @static
  8295  	         *
  8296  	         * @example
  8297  	         *
  8298  	         *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  8299  	         */
  8300  	        parse: function (utf8Str) {
  8301  	            return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  8302  	        }
  8303  	    };
  8304  
  8305  	    /**
  8306  	     * Abstract buffered block algorithm template.
  8307  	     *
  8308  	     * The property blockSize must be implemented in a concrete subtype.
  8309  	     *
  8310  	     * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  8311  	     */
  8312  	    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  8313  	        /**
  8314  	         * Resets this block algorithm's data buffer to its initial state.
  8315  	         *
  8316  	         * @example
  8317  	         *
  8318  	         *     bufferedBlockAlgorithm.reset();
  8319  	         */
  8320  	        reset: function () {
  8321  	            // Initial values
  8322  	            this._data = new WordArray.init();
  8323  	            this._nDataBytes = 0;
  8324  	        },
  8325  
  8326  	        /**
  8327  	         * Adds new data to this block algorithm's buffer.
  8328  	         *
  8329  	         * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  8330  	         *
  8331  	         * @example
  8332  	         *
  8333  	         *     bufferedBlockAlgorithm._append('data');
  8334  	         *     bufferedBlockAlgorithm._append(wordArray);
  8335  	         */
  8336  	        _append: function (data) {
  8337  	            // Convert string to WordArray, else assume WordArray already
  8338  	            if (typeof data == 'string') {
  8339  	                data = Utf8.parse(data);
  8340  	            }
  8341  
  8342  	            // Append
  8343  	            this._data.concat(data);
  8344  	            this._nDataBytes += data.sigBytes;
  8345  	        },
  8346  
  8347  	        /**
  8348  	         * Processes available data blocks.
  8349  	         *
  8350  	         * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  8351  	         *
  8352  	         * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  8353  	         *
  8354  	         * @return {WordArray} The processed data.
  8355  	         *
  8356  	         * @example
  8357  	         *
  8358  	         *     var processedData = bufferedBlockAlgorithm._process();
  8359  	         *     var processedData = bufferedBlockAlgorithm._process(!!'flush');
  8360  	         */
  8361  	        _process: function (doFlush) {
  8362  	            // Shortcuts
  8363  	            var data = this._data;
  8364  	            var dataWords = data.words;
  8365  	            var dataSigBytes = data.sigBytes;
  8366  	            var blockSize = this.blockSize;
  8367  	            var blockSizeBytes = blockSize * 4;
  8368  
  8369  	            // Count blocks ready
  8370  	            var nBlocksReady = dataSigBytes / blockSizeBytes;
  8371  	            if (doFlush) {
  8372  	                // Round up to include partial blocks
  8373  	                nBlocksReady = Math.ceil(nBlocksReady);
  8374  	            } else {
  8375  	                // Round down to include only full blocks,
  8376  	                // less the number of blocks that must remain in the buffer
  8377  	                nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  8378  	            }
  8379  
  8380  	            // Count words ready
  8381  	            var nWordsReady = nBlocksReady * blockSize;
  8382  
  8383  	            // Count bytes ready
  8384  	            var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  8385  
  8386  	            // Process blocks
  8387  	            if (nWordsReady) {
  8388  	                for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  8389  	                    // Perform concrete-algorithm logic
  8390  	                    this._doProcessBlock(dataWords, offset);
  8391  	                }
  8392  
  8393  	                // Remove processed words
  8394  	                var processedWords = dataWords.splice(0, nWordsReady);
  8395  	                data.sigBytes -= nBytesReady;
  8396  	            }
  8397  
  8398  	            // Return processed words
  8399  	            return new WordArray.init(processedWords, nBytesReady);
  8400  	        },
  8401  
  8402  	        /**
  8403  	         * Creates a copy of this object.
  8404  	         *
  8405  	         * @return {Object} The clone.
  8406  	         *
  8407  	         * @example
  8408  	         *
  8409  	         *     var clone = bufferedBlockAlgorithm.clone();
  8410  	         */
  8411  	        clone: function () {
  8412  	            var clone = Base.clone.call(this);
  8413  	            clone._data = this._data.clone();
  8414  
  8415  	            return clone;
  8416  	        },
  8417  
  8418  	        _minBufferSize: 0
  8419  	    });
  8420  
  8421  	    /**
  8422  	     * Abstract hasher template.
  8423  	     *
  8424  	     * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  8425  	     */
  8426  	    var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  8427  	        /**
  8428  	         * Configuration options.
  8429  	         */
  8430  	        cfg: Base.extend(),
  8431  
  8432  	        /**
  8433  	         * Initializes a newly created hasher.
  8434  	         *
  8435  	         * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  8436  	         *
  8437  	         * @example
  8438  	         *
  8439  	         *     var hasher = CryptoJS.algo.SHA256.create();
  8440  	         */
  8441  	        init: function (cfg) {
  8442  	            // Apply config defaults
  8443  	            this.cfg = this.cfg.extend(cfg);
  8444  
  8445  	            // Set initial values
  8446  	            this.reset();
  8447  	        },
  8448  
  8449  	        /**
  8450  	         * Resets this hasher to its initial state.
  8451  	         *
  8452  	         * @example
  8453  	         *
  8454  	         *     hasher.reset();
  8455  	         */
  8456  	        reset: function () {
  8457  	            // Reset data buffer
  8458  	            BufferedBlockAlgorithm.reset.call(this);
  8459  
  8460  	            // Perform concrete-hasher logic
  8461  	            this._doReset();
  8462  	        },
  8463  
  8464  	        /**
  8465  	         * Updates this hasher with a message.
  8466  	         *
  8467  	         * @param {WordArray|string} messageUpdate The message to append.
  8468  	         *
  8469  	         * @return {Hasher} This hasher.
  8470  	         *
  8471  	         * @example
  8472  	         *
  8473  	         *     hasher.update('message');
  8474  	         *     hasher.update(wordArray);
  8475  	         */
  8476  	        update: function (messageUpdate) {
  8477  	            // Append
  8478  	            this._append(messageUpdate);
  8479  
  8480  	            // Update the hash
  8481  	            this._process();
  8482  
  8483  	            // Chainable
  8484  	            return this;
  8485  	        },
  8486  
  8487  	        /**
  8488  	         * Finalizes the hash computation.
  8489  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  8490  	         *
  8491  	         * @param {WordArray|string} messageUpdate (Optional) A final message update.
  8492  	         *
  8493  	         * @return {WordArray} The hash.
  8494  	         *
  8495  	         * @example
  8496  	         *
  8497  	         *     var hash = hasher.finalize();
  8498  	         *     var hash = hasher.finalize('message');
  8499  	         *     var hash = hasher.finalize(wordArray);
  8500  	         */
  8501  	        finalize: function (messageUpdate) {
  8502  	            // Final message update
  8503  	            if (messageUpdate) {
  8504  	                this._append(messageUpdate);
  8505  	            }
  8506  
  8507  	            // Perform concrete-hasher logic
  8508  	            var hash = this._doFinalize();
  8509  
  8510  	            return hash;
  8511  	        },
  8512  
  8513  	        blockSize: 512/32,
  8514  
  8515  	        /**
  8516  	         * Creates a shortcut function to a hasher's object interface.
  8517  	         *
  8518  	         * @param {Hasher} hasher The hasher to create a helper for.
  8519  	         *
  8520  	         * @return {Function} The shortcut function.
  8521  	         *
  8522  	         * @static
  8523  	         *
  8524  	         * @example
  8525  	         *
  8526  	         *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  8527  	         */
  8528  	        _createHelper: function (hasher) {
  8529  	            return function (message, cfg) {
  8530  	                return new hasher.init(cfg).finalize(message);
  8531  	            };
  8532  	        },
  8533  
  8534  	        /**
  8535  	         * Creates a shortcut function to the HMAC's object interface.
  8536  	         *
  8537  	         * @param {Hasher} hasher The hasher to use in this HMAC helper.
  8538  	         *
  8539  	         * @return {Function} The shortcut function.
  8540  	         *
  8541  	         * @static
  8542  	         *
  8543  	         * @example
  8544  	         *
  8545  	         *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  8546  	         */
  8547  	        _createHmacHelper: function (hasher) {
  8548  	            return function (message, key) {
  8549  	                return new C_algo.HMAC.init(hasher, key).finalize(message);
  8550  	            };
  8551  	        }
  8552  	    });
  8553  
  8554  	    /**
  8555  	     * Algorithm namespace.
  8556  	     */
  8557  	    var C_algo = C.algo = {};
  8558  
  8559  	    return C;
  8560  	}(Math));
  8561  
  8562  
  8563  	return CryptoJS;
  8564  
  8565  }));
  8566  },{}],54:[function(require,module,exports){
  8567  ;(function (root, factory) {
  8568  	if (typeof exports === "object") {
  8569  		// CommonJS
  8570  		module.exports = exports = factory(require("./core"));
  8571  	}
  8572  	else if (typeof define === "function" && define.amd) {
  8573  		// AMD
  8574  		define(["./core"], factory);
  8575  	}
  8576  	else {
  8577  		// Global (browser)
  8578  		factory(root.CryptoJS);
  8579  	}
  8580  }(this, function (CryptoJS) {
  8581  
  8582  	(function () {
  8583  	    // Shortcuts
  8584  	    var C = CryptoJS;
  8585  	    var C_lib = C.lib;
  8586  	    var WordArray = C_lib.WordArray;
  8587  	    var C_enc = C.enc;
  8588  
  8589  	    /**
  8590  	     * Base64 encoding strategy.
  8591  	     */
  8592  	    var Base64 = C_enc.Base64 = {
  8593  	        /**
  8594  	         * Converts a word array to a Base64 string.
  8595  	         *
  8596  	         * @param {WordArray} wordArray The word array.
  8597  	         *
  8598  	         * @return {string} The Base64 string.
  8599  	         *
  8600  	         * @static
  8601  	         *
  8602  	         * @example
  8603  	         *
  8604  	         *     var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  8605  	         */
  8606  	        stringify: function (wordArray) {
  8607  	            // Shortcuts
  8608  	            var words = wordArray.words;
  8609  	            var sigBytes = wordArray.sigBytes;
  8610  	            var map = this._map;
  8611  
  8612  	            // Clamp excess bits
  8613  	            wordArray.clamp();
  8614  
  8615  	            // Convert
  8616  	            var base64Chars = [];
  8617  	            for (var i = 0; i < sigBytes; i += 3) {
  8618  	                var byte1 = (words[i >>> 2]       >>> (24 - (i % 4) * 8))       & 0xff;
  8619  	                var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  8620  	                var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  8621  
  8622  	                var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  8623  
  8624  	                for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  8625  	                    base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  8626  	                }
  8627  	            }
  8628  
  8629  	            // Add padding
  8630  	            var paddingChar = map.charAt(64);
  8631  	            if (paddingChar) {
  8632  	                while (base64Chars.length % 4) {
  8633  	                    base64Chars.push(paddingChar);
  8634  	                }
  8635  	            }
  8636  
  8637  	            return base64Chars.join('');
  8638  	        },
  8639  
  8640  	        /**
  8641  	         * Converts a Base64 string to a word array.
  8642  	         *
  8643  	         * @param {string} base64Str The Base64 string.
  8644  	         *
  8645  	         * @return {WordArray} The word array.
  8646  	         *
  8647  	         * @static
  8648  	         *
  8649  	         * @example
  8650  	         *
  8651  	         *     var wordArray = CryptoJS.enc.Base64.parse(base64String);
  8652  	         */
  8653  	        parse: function (base64Str) {
  8654  	            // Shortcuts
  8655  	            var base64StrLength = base64Str.length;
  8656  	            var map = this._map;
  8657  	            var reverseMap = this._reverseMap;
  8658  
  8659  	            if (!reverseMap) {
  8660  	                    reverseMap = this._reverseMap = [];
  8661  	                    for (var j = 0; j < map.length; j++) {
  8662  	                        reverseMap[map.charCodeAt(j)] = j;
  8663  	                    }
  8664  	            }
  8665  
  8666  	            // Ignore padding
  8667  	            var paddingChar = map.charAt(64);
  8668  	            if (paddingChar) {
  8669  	                var paddingIndex = base64Str.indexOf(paddingChar);
  8670  	                if (paddingIndex !== -1) {
  8671  	                    base64StrLength = paddingIndex;
  8672  	                }
  8673  	            }
  8674  
  8675  	            // Convert
  8676  	            return parseLoop(base64Str, base64StrLength, reverseMap);
  8677  
  8678  	        },
  8679  
  8680  	        _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  8681  	    };
  8682  
  8683  	    function parseLoop(base64Str, base64StrLength, reverseMap) {
  8684  	      var words = [];
  8685  	      var nBytes = 0;
  8686  	      for (var i = 0; i < base64StrLength; i++) {
  8687  	          if (i % 4) {
  8688  	              var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  8689  	              var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  8690  	              words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
  8691  	              nBytes++;
  8692  	          }
  8693  	      }
  8694  	      return WordArray.create(words, nBytes);
  8695  	    }
  8696  	}());
  8697  
  8698  
  8699  	return CryptoJS.enc.Base64;
  8700  
  8701  }));
  8702  },{"./core":53}],55:[function(require,module,exports){
  8703  ;(function (root, factory) {
  8704  	if (typeof exports === "object") {
  8705  		// CommonJS
  8706  		module.exports = exports = factory(require("./core"));
  8707  	}
  8708  	else if (typeof define === "function" && define.amd) {
  8709  		// AMD
  8710  		define(["./core"], factory);
  8711  	}
  8712  	else {
  8713  		// Global (browser)
  8714  		factory(root.CryptoJS);
  8715  	}
  8716  }(this, function (CryptoJS) {
  8717  
  8718  	(function () {
  8719  	    // Shortcuts
  8720  	    var C = CryptoJS;
  8721  	    var C_lib = C.lib;
  8722  	    var WordArray = C_lib.WordArray;
  8723  	    var C_enc = C.enc;
  8724  
  8725  	    /**
  8726  	     * UTF-16 BE encoding strategy.
  8727  	     */
  8728  	    var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
  8729  	        /**
  8730  	         * Converts a word array to a UTF-16 BE string.
  8731  	         *
  8732  	         * @param {WordArray} wordArray The word array.
  8733  	         *
  8734  	         * @return {string} The UTF-16 BE string.
  8735  	         *
  8736  	         * @static
  8737  	         *
  8738  	         * @example
  8739  	         *
  8740  	         *     var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
  8741  	         */
  8742  	        stringify: function (wordArray) {
  8743  	            // Shortcuts
  8744  	            var words = wordArray.words;
  8745  	            var sigBytes = wordArray.sigBytes;
  8746  
  8747  	            // Convert
  8748  	            var utf16Chars = [];
  8749  	            for (var i = 0; i < sigBytes; i += 2) {
  8750  	                var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
  8751  	                utf16Chars.push(String.fromCharCode(codePoint));
  8752  	            }
  8753  
  8754  	            return utf16Chars.join('');
  8755  	        },
  8756  
  8757  	        /**
  8758  	         * Converts a UTF-16 BE string to a word array.
  8759  	         *
  8760  	         * @param {string} utf16Str The UTF-16 BE string.
  8761  	         *
  8762  	         * @return {WordArray} The word array.
  8763  	         *
  8764  	         * @static
  8765  	         *
  8766  	         * @example
  8767  	         *
  8768  	         *     var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
  8769  	         */
  8770  	        parse: function (utf16Str) {
  8771  	            // Shortcut
  8772  	            var utf16StrLength = utf16Str.length;
  8773  
  8774  	            // Convert
  8775  	            var words = [];
  8776  	            for (var i = 0; i < utf16StrLength; i++) {
  8777  	                words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
  8778  	            }
  8779  
  8780  	            return WordArray.create(words, utf16StrLength * 2);
  8781  	        }
  8782  	    };
  8783  
  8784  	    /**
  8785  	     * UTF-16 LE encoding strategy.
  8786  	     */
  8787  	    C_enc.Utf16LE = {
  8788  	        /**
  8789  	         * Converts a word array to a UTF-16 LE string.
  8790  	         *
  8791  	         * @param {WordArray} wordArray The word array.
  8792  	         *
  8793  	         * @return {string} The UTF-16 LE string.
  8794  	         *
  8795  	         * @static
  8796  	         *
  8797  	         * @example
  8798  	         *
  8799  	         *     var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
  8800  	         */
  8801  	        stringify: function (wordArray) {
  8802  	            // Shortcuts
  8803  	            var words = wordArray.words;
  8804  	            var sigBytes = wordArray.sigBytes;
  8805  
  8806  	            // Convert
  8807  	            var utf16Chars = [];
  8808  	            for (var i = 0; i < sigBytes; i += 2) {
  8809  	                var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
  8810  	                utf16Chars.push(String.fromCharCode(codePoint));
  8811  	            }
  8812  
  8813  	            return utf16Chars.join('');
  8814  	        },
  8815  
  8816  	        /**
  8817  	         * Converts a UTF-16 LE string to a word array.
  8818  	         *
  8819  	         * @param {string} utf16Str The UTF-16 LE string.
  8820  	         *
  8821  	         * @return {WordArray} The word array.
  8822  	         *
  8823  	         * @static
  8824  	         *
  8825  	         * @example
  8826  	         *
  8827  	         *     var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
  8828  	         */
  8829  	        parse: function (utf16Str) {
  8830  	            // Shortcut
  8831  	            var utf16StrLength = utf16Str.length;
  8832  
  8833  	            // Convert
  8834  	            var words = [];
  8835  	            for (var i = 0; i < utf16StrLength; i++) {
  8836  	                words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
  8837  	            }
  8838  
  8839  	            return WordArray.create(words, utf16StrLength * 2);
  8840  	        }
  8841  	    };
  8842  
  8843  	    function swapEndian(word) {
  8844  	        return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
  8845  	    }
  8846  	}());
  8847  
  8848  
  8849  	return CryptoJS.enc.Utf16;
  8850  
  8851  }));
  8852  },{"./core":53}],56:[function(require,module,exports){
  8853  ;(function (root, factory, undef) {
  8854  	if (typeof exports === "object") {
  8855  		// CommonJS
  8856  		module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
  8857  	}
  8858  	else if (typeof define === "function" && define.amd) {
  8859  		// AMD
  8860  		define(["./core", "./sha1", "./hmac"], factory);
  8861  	}
  8862  	else {
  8863  		// Global (browser)
  8864  		factory(root.CryptoJS);
  8865  	}
  8866  }(this, function (CryptoJS) {
  8867  
  8868  	(function () {
  8869  	    // Shortcuts
  8870  	    var C = CryptoJS;
  8871  	    var C_lib = C.lib;
  8872  	    var Base = C_lib.Base;
  8873  	    var WordArray = C_lib.WordArray;
  8874  	    var C_algo = C.algo;
  8875  	    var MD5 = C_algo.MD5;
  8876  
  8877  	    /**
  8878  	     * This key derivation function is meant to conform with EVP_BytesToKey.
  8879  	     * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  8880  	     */
  8881  	    var EvpKDF = C_algo.EvpKDF = Base.extend({
  8882  	        /**
  8883  	         * Configuration options.
  8884  	         *
  8885  	         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  8886  	         * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  8887  	         * @property {number} iterations The number of iterations to perform. Default: 1
  8888  	         */
  8889  	        cfg: Base.extend({
  8890  	            keySize: 128/32,
  8891  	            hasher: MD5,
  8892  	            iterations: 1
  8893  	        }),
  8894  
  8895  	        /**
  8896  	         * Initializes a newly created key derivation function.
  8897  	         *
  8898  	         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  8899  	         *
  8900  	         * @example
  8901  	         *
  8902  	         *     var kdf = CryptoJS.algo.EvpKDF.create();
  8903  	         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  8904  	         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  8905  	         */
  8906  	        init: function (cfg) {
  8907  	            this.cfg = this.cfg.extend(cfg);
  8908  	        },
  8909  
  8910  	        /**
  8911  	         * Derives a key from a password.
  8912  	         *
  8913  	         * @param {WordArray|string} password The password.
  8914  	         * @param {WordArray|string} salt A salt.
  8915  	         *
  8916  	         * @return {WordArray} The derived key.
  8917  	         *
  8918  	         * @example
  8919  	         *
  8920  	         *     var key = kdf.compute(password, salt);
  8921  	         */
  8922  	        compute: function (password, salt) {
  8923  	            // Shortcut
  8924  	            var cfg = this.cfg;
  8925  
  8926  	            // Init hasher
  8927  	            var hasher = cfg.hasher.create();
  8928  
  8929  	            // Initial values
  8930  	            var derivedKey = WordArray.create();
  8931  
  8932  	            // Shortcuts
  8933  	            var derivedKeyWords = derivedKey.words;
  8934  	            var keySize = cfg.keySize;
  8935  	            var iterations = cfg.iterations;
  8936  
  8937  	            // Generate key
  8938  	            while (derivedKeyWords.length < keySize) {
  8939  	                if (block) {
  8940  	                    hasher.update(block);
  8941  	                }
  8942  	                var block = hasher.update(password).finalize(salt);
  8943  	                hasher.reset();
  8944  
  8945  	                // Iterations
  8946  	                for (var i = 1; i < iterations; i++) {
  8947  	                    block = hasher.finalize(block);
  8948  	                    hasher.reset();
  8949  	                }
  8950  
  8951  	                derivedKey.concat(block);
  8952  	            }
  8953  	            derivedKey.sigBytes = keySize * 4;
  8954  
  8955  	            return derivedKey;
  8956  	        }
  8957  	    });
  8958  
  8959  	    /**
  8960  	     * Derives a key from a password.
  8961  	     *
  8962  	     * @param {WordArray|string} password The password.
  8963  	     * @param {WordArray|string} salt A salt.
  8964  	     * @param {Object} cfg (Optional) The configuration options to use for this computation.
  8965  	     *
  8966  	     * @return {WordArray} The derived key.
  8967  	     *
  8968  	     * @static
  8969  	     *
  8970  	     * @example
  8971  	     *
  8972  	     *     var key = CryptoJS.EvpKDF(password, salt);
  8973  	     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  8974  	     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  8975  	     */
  8976  	    C.EvpKDF = function (password, salt, cfg) {
  8977  	        return EvpKDF.create(cfg).compute(password, salt);
  8978  	    };
  8979  	}());
  8980  
  8981  
  8982  	return CryptoJS.EvpKDF;
  8983  
  8984  }));
  8985  },{"./core":53,"./hmac":58,"./sha1":77}],57:[function(require,module,exports){
  8986  ;(function (root, factory, undef) {
  8987  	if (typeof exports === "object") {
  8988  		// CommonJS
  8989  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8990  	}
  8991  	else if (typeof define === "function" && define.amd) {
  8992  		// AMD
  8993  		define(["./core", "./cipher-core"], factory);
  8994  	}
  8995  	else {
  8996  		// Global (browser)
  8997  		factory(root.CryptoJS);
  8998  	}
  8999  }(this, function (CryptoJS) {
  9000  
  9001  	(function (undefined) {
  9002  	    // Shortcuts
  9003  	    var C = CryptoJS;
  9004  	    var C_lib = C.lib;
  9005  	    var CipherParams = C_lib.CipherParams;
  9006  	    var C_enc = C.enc;
  9007  	    var Hex = C_enc.Hex;
  9008  	    var C_format = C.format;
  9009  
  9010  	    var HexFormatter = C_format.Hex = {
  9011  	        /**
  9012  	         * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  9013  	         *
  9014  	         * @param {CipherParams} cipherParams The cipher params object.
  9015  	         *
  9016  	         * @return {string} The hexadecimally encoded string.
  9017  	         *
  9018  	         * @static
  9019  	         *
  9020  	         * @example
  9021  	         *
  9022  	         *     var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  9023  	         */
  9024  	        stringify: function (cipherParams) {
  9025  	            return cipherParams.ciphertext.toString(Hex);
  9026  	        },
  9027  
  9028  	        /**
  9029  	         * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  9030  	         *
  9031  	         * @param {string} input The hexadecimally encoded string.
  9032  	         *
  9033  	         * @return {CipherParams} The cipher params object.
  9034  	         *
  9035  	         * @static
  9036  	         *
  9037  	         * @example
  9038  	         *
  9039  	         *     var cipherParams = CryptoJS.format.Hex.parse(hexString);
  9040  	         */
  9041  	        parse: function (input) {
  9042  	            var ciphertext = Hex.parse(input);
  9043  	            return CipherParams.create({ ciphertext: ciphertext });
  9044  	        }
  9045  	    };
  9046  	}());
  9047  
  9048  
  9049  	return CryptoJS.format.Hex;
  9050  
  9051  }));
  9052  },{"./cipher-core":52,"./core":53}],58:[function(require,module,exports){
  9053  ;(function (root, factory) {
  9054  	if (typeof exports === "object") {
  9055  		// CommonJS
  9056  		module.exports = exports = factory(require("./core"));
  9057  	}
  9058  	else if (typeof define === "function" && define.amd) {
  9059  		// AMD
  9060  		define(["./core"], factory);
  9061  	}
  9062  	else {
  9063  		// Global (browser)
  9064  		factory(root.CryptoJS);
  9065  	}
  9066  }(this, function (CryptoJS) {
  9067  
  9068  	(function () {
  9069  	    // Shortcuts
  9070  	    var C = CryptoJS;
  9071  	    var C_lib = C.lib;
  9072  	    var Base = C_lib.Base;
  9073  	    var C_enc = C.enc;
  9074  	    var Utf8 = C_enc.Utf8;
  9075  	    var C_algo = C.algo;
  9076  
  9077  	    /**
  9078  	     * HMAC algorithm.
  9079  	     */
  9080  	    var HMAC = C_algo.HMAC = Base.extend({
  9081  	        /**
  9082  	         * Initializes a newly created HMAC.
  9083  	         *
  9084  	         * @param {Hasher} hasher The hash algorithm to use.
  9085  	         * @param {WordArray|string} key The secret key.
  9086  	         *
  9087  	         * @example
  9088  	         *
  9089  	         *     var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  9090  	         */
  9091  	        init: function (hasher, key) {
  9092  	            // Init hasher
  9093  	            hasher = this._hasher = new hasher.init();
  9094  
  9095  	            // Convert string to WordArray, else assume WordArray already
  9096  	            if (typeof key == 'string') {
  9097  	                key = Utf8.parse(key);
  9098  	            }
  9099  
  9100  	            // Shortcuts
  9101  	            var hasherBlockSize = hasher.blockSize;
  9102  	            var hasherBlockSizeBytes = hasherBlockSize * 4;
  9103  
  9104  	            // Allow arbitrary length keys
  9105  	            if (key.sigBytes > hasherBlockSizeBytes) {
  9106  	                key = hasher.finalize(key);
  9107  	            }
  9108  
  9109  	            // Clamp excess bits
  9110  	            key.clamp();
  9111  
  9112  	            // Clone key for inner and outer pads
  9113  	            var oKey = this._oKey = key.clone();
  9114  	            var iKey = this._iKey = key.clone();
  9115  
  9116  	            // Shortcuts
  9117  	            var oKeyWords = oKey.words;
  9118  	            var iKeyWords = iKey.words;
  9119  
  9120  	            // XOR keys with pad constants
  9121  	            for (var i = 0; i < hasherBlockSize; i++) {
  9122  	                oKeyWords[i] ^= 0x5c5c5c5c;
  9123  	                iKeyWords[i] ^= 0x36363636;
  9124  	            }
  9125  	            oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  9126  
  9127  	            // Set initial values
  9128  	            this.reset();
  9129  	        },
  9130  
  9131  	        /**
  9132  	         * Resets this HMAC to its initial state.
  9133  	         *
  9134  	         * @example
  9135  	         *
  9136  	         *     hmacHasher.reset();
  9137  	         */
  9138  	        reset: function () {
  9139  	            // Shortcut
  9140  	            var hasher = this._hasher;
  9141  
  9142  	            // Reset
  9143  	            hasher.reset();
  9144  	            hasher.update(this._iKey);
  9145  	        },
  9146  
  9147  	        /**
  9148  	         * Updates this HMAC with a message.
  9149  	         *
  9150  	         * @param {WordArray|string} messageUpdate The message to append.
  9151  	         *
  9152  	         * @return {HMAC} This HMAC instance.
  9153  	         *
  9154  	         * @example
  9155  	         *
  9156  	         *     hmacHasher.update('message');
  9157  	         *     hmacHasher.update(wordArray);
  9158  	         */
  9159  	        update: function (messageUpdate) {
  9160  	            this._hasher.update(messageUpdate);
  9161  
  9162  	            // Chainable
  9163  	            return this;
  9164  	        },
  9165  
  9166  	        /**
  9167  	         * Finalizes the HMAC computation.
  9168  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  9169  	         *
  9170  	         * @param {WordArray|string} messageUpdate (Optional) A final message update.
  9171  	         *
  9172  	         * @return {WordArray} The HMAC.
  9173  	         *
  9174  	         * @example
  9175  	         *
  9176  	         *     var hmac = hmacHasher.finalize();
  9177  	         *     var hmac = hmacHasher.finalize('message');
  9178  	         *     var hmac = hmacHasher.finalize(wordArray);
  9179  	         */
  9180  	        finalize: function (messageUpdate) {
  9181  	            // Shortcut
  9182  	            var hasher = this._hasher;
  9183  
  9184  	            // Compute HMAC
  9185  	            var innerHash = hasher.finalize(messageUpdate);
  9186  	            hasher.reset();
  9187  	            var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  9188  
  9189  	            return hmac;
  9190  	        }
  9191  	    });
  9192  	}());
  9193  
  9194  
  9195  }));
  9196  },{"./core":53}],59:[function(require,module,exports){
  9197  ;(function (root, factory, undef) {
  9198  	if (typeof exports === "object") {
  9199  		// CommonJS
  9200  		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"));
  9201  	}
  9202  	else if (typeof define === "function" && define.amd) {
  9203  		// AMD
  9204  		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);
  9205  	}
  9206  	else {
  9207  		// Global (browser)
  9208  		root.CryptoJS = factory(root.CryptoJS);
  9209  	}
  9210  }(this, function (CryptoJS) {
  9211  
  9212  	return CryptoJS;
  9213  
  9214  }));
  9215  },{"./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){
  9216  ;(function (root, factory) {
  9217  	if (typeof exports === "object") {
  9218  		// CommonJS
  9219  		module.exports = exports = factory(require("./core"));
  9220  	}
  9221  	else if (typeof define === "function" && define.amd) {
  9222  		// AMD
  9223  		define(["./core"], factory);
  9224  	}
  9225  	else {
  9226  		// Global (browser)
  9227  		factory(root.CryptoJS);
  9228  	}
  9229  }(this, function (CryptoJS) {
  9230  
  9231  	(function () {
  9232  	    // Check if typed arrays are supported
  9233  	    if (typeof ArrayBuffer != 'function') {
  9234  	        return;
  9235  	    }
  9236  
  9237  	    // Shortcuts
  9238  	    var C = CryptoJS;
  9239  	    var C_lib = C.lib;
  9240  	    var WordArray = C_lib.WordArray;
  9241  
  9242  	    // Reference original init
  9243  	    var superInit = WordArray.init;
  9244  
  9245  	    // Augment WordArray.init to handle typed arrays
  9246  	    var subInit = WordArray.init = function (typedArray) {
  9247  	        // Convert buffers to uint8
  9248  	        if (typedArray instanceof ArrayBuffer) {
  9249  	            typedArray = new Uint8Array(typedArray);
  9250  	        }
  9251  
  9252  	        // Convert other array views to uint8
  9253  	        if (
  9254  	            typedArray instanceof Int8Array ||
  9255  	            (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
  9256  	            typedArray instanceof Int16Array ||
  9257  	            typedArray instanceof Uint16Array ||
  9258  	            typedArray instanceof Int32Array ||
  9259  	            typedArray instanceof Uint32Array ||
  9260  	            typedArray instanceof Float32Array ||
  9261  	            typedArray instanceof Float64Array
  9262  	        ) {
  9263  	            typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
  9264  	        }
  9265  
  9266  	        // Handle Uint8Array
  9267  	        if (typedArray instanceof Uint8Array) {
  9268  	            // Shortcut
  9269  	            var typedArrayByteLength = typedArray.byteLength;
  9270  
  9271  	            // Extract bytes
  9272  	            var words = [];
  9273  	            for (var i = 0; i < typedArrayByteLength; i++) {
  9274  	                words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
  9275  	            }
  9276  
  9277  	            // Initialize this word array
  9278  	            superInit.call(this, words, typedArrayByteLength);
  9279  	        } else {
  9280  	            // Else call normal init
  9281  	            superInit.apply(this, arguments);
  9282  	        }
  9283  	    };
  9284  
  9285  	    subInit.prototype = WordArray;
  9286  	}());
  9287  
  9288  
  9289  	return CryptoJS.lib.WordArray;
  9290  
  9291  }));
  9292  },{"./core":53}],61:[function(require,module,exports){
  9293  ;(function (root, factory) {
  9294  	if (typeof exports === "object") {
  9295  		// CommonJS
  9296  		module.exports = exports = factory(require("./core"));
  9297  	}
  9298  	else if (typeof define === "function" && define.amd) {
  9299  		// AMD
  9300  		define(["./core"], factory);
  9301  	}
  9302  	else {
  9303  		// Global (browser)
  9304  		factory(root.CryptoJS);
  9305  	}
  9306  }(this, function (CryptoJS) {
  9307  
  9308  	(function (Math) {
  9309  	    // Shortcuts
  9310  	    var C = CryptoJS;
  9311  	    var C_lib = C.lib;
  9312  	    var WordArray = C_lib.WordArray;
  9313  	    var Hasher = C_lib.Hasher;
  9314  	    var C_algo = C.algo;
  9315  
  9316  	    // Constants table
  9317  	    var T = [];
  9318  
  9319  	    // Compute constants
  9320  	    (function () {
  9321  	        for (var i = 0; i < 64; i++) {
  9322  	            T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  9323  	        }
  9324  	    }());
  9325  
  9326  	    /**
  9327  	     * MD5 hash algorithm.
  9328  	     */
  9329  	    var MD5 = C_algo.MD5 = Hasher.extend({
  9330  	        _doReset: function () {
  9331  	            this._hash = new WordArray.init([
  9332  	                0x67452301, 0xefcdab89,
  9333  	                0x98badcfe, 0x10325476
  9334  	            ]);
  9335  	        },
  9336  
  9337  	        _doProcessBlock: function (M, offset) {
  9338  	            // Swap endian
  9339  	            for (var i = 0; i < 16; i++) {
  9340  	                // Shortcuts
  9341  	                var offset_i = offset + i;
  9342  	                var M_offset_i = M[offset_i];
  9343  
  9344  	                M[offset_i] = (
  9345  	                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
  9346  	                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
  9347  	                );
  9348  	            }
  9349  
  9350  	            // Shortcuts
  9351  	            var H = this._hash.words;
  9352  
  9353  	            var M_offset_0  = M[offset + 0];
  9354  	            var M_offset_1  = M[offset + 1];
  9355  	            var M_offset_2  = M[offset + 2];
  9356  	            var M_offset_3  = M[offset + 3];
  9357  	            var M_offset_4  = M[offset + 4];
  9358  	            var M_offset_5  = M[offset + 5];
  9359  	            var M_offset_6  = M[offset + 6];
  9360  	            var M_offset_7  = M[offset + 7];
  9361  	            var M_offset_8  = M[offset + 8];
  9362  	            var M_offset_9  = M[offset + 9];
  9363  	            var M_offset_10 = M[offset + 10];
  9364  	            var M_offset_11 = M[offset + 11];
  9365  	            var M_offset_12 = M[offset + 12];
  9366  	            var M_offset_13 = M[offset + 13];
  9367  	            var M_offset_14 = M[offset + 14];
  9368  	            var M_offset_15 = M[offset + 15];
  9369  
  9370  	            // Working varialbes
  9371  	            var a = H[0];
  9372  	            var b = H[1];
  9373  	            var c = H[2];
  9374  	            var d = H[3];
  9375  
  9376  	            // Computation
  9377  	            a = FF(a, b, c, d, M_offset_0,  7,  T[0]);
  9378  	            d = FF(d, a, b, c, M_offset_1,  12, T[1]);
  9379  	            c = FF(c, d, a, b, M_offset_2,  17, T[2]);
  9380  	            b = FF(b, c, d, a, M_offset_3,  22, T[3]);
  9381  	            a = FF(a, b, c, d, M_offset_4,  7,  T[4]);
  9382  	            d = FF(d, a, b, c, M_offset_5,  12, T[5]);
  9383  	            c = FF(c, d, a, b, M_offset_6,  17, T[6]);
  9384  	            b = FF(b, c, d, a, M_offset_7,  22, T[7]);
  9385  	            a = FF(a, b, c, d, M_offset_8,  7,  T[8]);
  9386  	            d = FF(d, a, b, c, M_offset_9,  12, T[9]);
  9387  	            c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  9388  	            b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  9389  	            a = FF(a, b, c, d, M_offset_12, 7,  T[12]);
  9390  	            d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  9391  	            c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  9392  	            b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  9393  
  9394  	            a = GG(a, b, c, d, M_offset_1,  5,  T[16]);
  9395  	            d = GG(d, a, b, c, M_offset_6,  9,  T[17]);
  9396  	            c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  9397  	            b = GG(b, c, d, a, M_offset_0,  20, T[19]);
  9398  	            a = GG(a, b, c, d, M_offset_5,  5,  T[20]);
  9399  	            d = GG(d, a, b, c, M_offset_10, 9,  T[21]);
  9400  	            c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  9401  	            b = GG(b, c, d, a, M_offset_4,  20, T[23]);
  9402  	            a = GG(a, b, c, d, M_offset_9,  5,  T[24]);
  9403  	            d = GG(d, a, b, c, M_offset_14, 9,  T[25]);
  9404  	            c = GG(c, d, a, b, M_offset_3,  14, T[26]);
  9405  	            b = GG(b, c, d, a, M_offset_8,  20, T[27]);
  9406  	            a = GG(a, b, c, d, M_offset_13, 5,  T[28]);
  9407  	            d = GG(d, a, b, c, M_offset_2,  9,  T[29]);
  9408  	            c = GG(c, d, a, b, M_offset_7,  14, T[30]);
  9409  	            b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  9410  
  9411  	            a = HH(a, b, c, d, M_offset_5,  4,  T[32]);
  9412  	            d = HH(d, a, b, c, M_offset_8,  11, T[33]);
  9413  	            c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  9414  	            b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  9415  	            a = HH(a, b, c, d, M_offset_1,  4,  T[36]);
  9416  	            d = HH(d, a, b, c, M_offset_4,  11, T[37]);
  9417  	            c = HH(c, d, a, b, M_offset_7,  16, T[38]);
  9418  	            b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  9419  	            a = HH(a, b, c, d, M_offset_13, 4,  T[40]);
  9420  	            d = HH(d, a, b, c, M_offset_0,  11, T[41]);
  9421  	            c = HH(c, d, a, b, M_offset_3,  16, T[42]);
  9422  	            b = HH(b, c, d, a, M_offset_6,  23, T[43]);
  9423  	            a = HH(a, b, c, d, M_offset_9,  4,  T[44]);
  9424  	            d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  9425  	            c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  9426  	            b = HH(b, c, d, a, M_offset_2,  23, T[47]);
  9427  
  9428  	            a = II(a, b, c, d, M_offset_0,  6,  T[48]);
  9429  	            d = II(d, a, b, c, M_offset_7,  10, T[49]);
  9430  	            c = II(c, d, a, b, M_offset_14, 15, T[50]);
  9431  	            b = II(b, c, d, a, M_offset_5,  21, T[51]);
  9432  	            a = II(a, b, c, d, M_offset_12, 6,  T[52]);
  9433  	            d = II(d, a, b, c, M_offset_3,  10, T[53]);
  9434  	            c = II(c, d, a, b, M_offset_10, 15, T[54]);
  9435  	            b = II(b, c, d, a, M_offset_1,  21, T[55]);
  9436  	            a = II(a, b, c, d, M_offset_8,  6,  T[56]);
  9437  	            d = II(d, a, b, c, M_offset_15, 10, T[57]);
  9438  	            c = II(c, d, a, b, M_offset_6,  15, T[58]);
  9439  	            b = II(b, c, d, a, M_offset_13, 21, T[59]);
  9440  	            a = II(a, b, c, d, M_offset_4,  6,  T[60]);
  9441  	            d = II(d, a, b, c, M_offset_11, 10, T[61]);
  9442  	            c = II(c, d, a, b, M_offset_2,  15, T[62]);
  9443  	            b = II(b, c, d, a, M_offset_9,  21, T[63]);
  9444  
  9445  	            // Intermediate hash value
  9446  	            H[0] = (H[0] + a) | 0;
  9447  	            H[1] = (H[1] + b) | 0;
  9448  	            H[2] = (H[2] + c) | 0;
  9449  	            H[3] = (H[3] + d) | 0;
  9450  	        },
  9451  
  9452  	        _doFinalize: function () {
  9453  	            // Shortcuts
  9454  	            var data = this._data;
  9455  	            var dataWords = data.words;
  9456  
  9457  	            var nBitsTotal = this._nDataBytes * 8;
  9458  	            var nBitsLeft = data.sigBytes * 8;
  9459  
  9460  	            // Add padding
  9461  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  9462  
  9463  	            var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  9464  	            var nBitsTotalL = nBitsTotal;
  9465  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  9466  	                (((nBitsTotalH << 8)  | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  9467  	                (((nBitsTotalH << 24) | (nBitsTotalH >>> 8))  & 0xff00ff00)
  9468  	            );
  9469  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  9470  	                (((nBitsTotalL << 8)  | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  9471  	                (((nBitsTotalL << 24) | (nBitsTotalL >>> 8))  & 0xff00ff00)
  9472  	            );
  9473  
  9474  	            data.sigBytes = (dataWords.length + 1) * 4;
  9475  
  9476  	            // Hash final blocks
  9477  	            this._process();
  9478  
  9479  	            // Shortcuts
  9480  	            var hash = this._hash;
  9481  	            var H = hash.words;
  9482  
  9483  	            // Swap endian
  9484  	            for (var i = 0; i < 4; i++) {
  9485  	                // Shortcut
  9486  	                var H_i = H[i];
  9487  
  9488  	                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
  9489  	                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
  9490  	            }
  9491  
  9492  	            // Return final computed hash
  9493  	            return hash;
  9494  	        },
  9495  
  9496  	        clone: function () {
  9497  	            var clone = Hasher.clone.call(this);
  9498  	            clone._hash = this._hash.clone();
  9499  
  9500  	            return clone;
  9501  	        }
  9502  	    });
  9503  
  9504  	    function FF(a, b, c, d, x, s, t) {
  9505  	        var n = a + ((b & c) | (~b & d)) + x + t;
  9506  	        return ((n << s) | (n >>> (32 - s))) + b;
  9507  	    }
  9508  
  9509  	    function GG(a, b, c, d, x, s, t) {
  9510  	        var n = a + ((b & d) | (c & ~d)) + x + t;
  9511  	        return ((n << s) | (n >>> (32 - s))) + b;
  9512  	    }
  9513  
  9514  	    function HH(a, b, c, d, x, s, t) {
  9515  	        var n = a + (b ^ c ^ d) + x + t;
  9516  	        return ((n << s) | (n >>> (32 - s))) + b;
  9517  	    }
  9518  
  9519  	    function II(a, b, c, d, x, s, t) {
  9520  	        var n = a + (c ^ (b | ~d)) + x + t;
  9521  	        return ((n << s) | (n >>> (32 - s))) + b;
  9522  	    }
  9523  
  9524  	    /**
  9525  	     * Shortcut function to the hasher's object interface.
  9526  	     *
  9527  	     * @param {WordArray|string} message The message to hash.
  9528  	     *
  9529  	     * @return {WordArray} The hash.
  9530  	     *
  9531  	     * @static
  9532  	     *
  9533  	     * @example
  9534  	     *
  9535  	     *     var hash = CryptoJS.MD5('message');
  9536  	     *     var hash = CryptoJS.MD5(wordArray);
  9537  	     */
  9538  	    C.MD5 = Hasher._createHelper(MD5);
  9539  
  9540  	    /**
  9541  	     * Shortcut function to the HMAC's object interface.
  9542  	     *
  9543  	     * @param {WordArray|string} message The message to hash.
  9544  	     * @param {WordArray|string} key The secret key.
  9545  	     *
  9546  	     * @return {WordArray} The HMAC.
  9547  	     *
  9548  	     * @static
  9549  	     *
  9550  	     * @example
  9551  	     *
  9552  	     *     var hmac = CryptoJS.HmacMD5(message, key);
  9553  	     */
  9554  	    C.HmacMD5 = Hasher._createHmacHelper(MD5);
  9555  	}(Math));
  9556  
  9557  
  9558  	return CryptoJS.MD5;
  9559  
  9560  }));
  9561  },{"./core":53}],62:[function(require,module,exports){
  9562  ;(function (root, factory, undef) {
  9563  	if (typeof exports === "object") {
  9564  		// CommonJS
  9565  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9566  	}
  9567  	else if (typeof define === "function" && define.amd) {
  9568  		// AMD
  9569  		define(["./core", "./cipher-core"], factory);
  9570  	}
  9571  	else {
  9572  		// Global (browser)
  9573  		factory(root.CryptoJS);
  9574  	}
  9575  }(this, function (CryptoJS) {
  9576  
  9577  	/**
  9578  	 * Cipher Feedback block mode.
  9579  	 */
  9580  	CryptoJS.mode.CFB = (function () {
  9581  	    var CFB = CryptoJS.lib.BlockCipherMode.extend();
  9582  
  9583  	    CFB.Encryptor = CFB.extend({
  9584  	        processBlock: function (words, offset) {
  9585  	            // Shortcuts
  9586  	            var cipher = this._cipher;
  9587  	            var blockSize = cipher.blockSize;
  9588  
  9589  	            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9590  
  9591  	            // Remember this block to use with next block
  9592  	            this._prevBlock = words.slice(offset, offset + blockSize);
  9593  	        }
  9594  	    });
  9595  
  9596  	    CFB.Decryptor = CFB.extend({
  9597  	        processBlock: function (words, offset) {
  9598  	            // Shortcuts
  9599  	            var cipher = this._cipher;
  9600  	            var blockSize = cipher.blockSize;
  9601  
  9602  	            // Remember this block to use with next block
  9603  	            var thisBlock = words.slice(offset, offset + blockSize);
  9604  
  9605  	            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9606  
  9607  	            // This block becomes the previous block
  9608  	            this._prevBlock = thisBlock;
  9609  	        }
  9610  	    });
  9611  
  9612  	    function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
  9613  	        // Shortcut
  9614  	        var iv = this._iv;
  9615  
  9616  	        // Generate keystream
  9617  	        if (iv) {
  9618  	            var keystream = iv.slice(0);
  9619  
  9620  	            // Remove IV for subsequent blocks
  9621  	            this._iv = undefined;
  9622  	        } else {
  9623  	            var keystream = this._prevBlock;
  9624  	        }
  9625  	        cipher.encryptBlock(keystream, 0);
  9626  
  9627  	        // Encrypt
  9628  	        for (var i = 0; i < blockSize; i++) {
  9629  	            words[offset + i] ^= keystream[i];
  9630  	        }
  9631  	    }
  9632  
  9633  	    return CFB;
  9634  	}());
  9635  
  9636  
  9637  	return CryptoJS.mode.CFB;
  9638  
  9639  }));
  9640  },{"./cipher-core":52,"./core":53}],63:[function(require,module,exports){
  9641  ;(function (root, factory, undef) {
  9642  	if (typeof exports === "object") {
  9643  		// CommonJS
  9644  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9645  	}
  9646  	else if (typeof define === "function" && define.amd) {
  9647  		// AMD
  9648  		define(["./core", "./cipher-core"], factory);
  9649  	}
  9650  	else {
  9651  		// Global (browser)
  9652  		factory(root.CryptoJS);
  9653  	}
  9654  }(this, function (CryptoJS) {
  9655  
  9656  	/** @preserve
  9657  	 * Counter block mode compatible with  Dr Brian Gladman fileenc.c
  9658  	 * derived from CryptoJS.mode.CTR
  9659  	 * Jan Hruby jhruby.web@gmail.com
  9660  	 */
  9661  	CryptoJS.mode.CTRGladman = (function () {
  9662  	    var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
  9663  
  9664  		function incWord(word)
  9665  		{
  9666  			if (((word >> 24) & 0xff) === 0xff) { //overflow
  9667  			var b1 = (word >> 16)&0xff;
  9668  			var b2 = (word >> 8)&0xff;
  9669  			var b3 = word & 0xff;
  9670  
  9671  			if (b1 === 0xff) // overflow b1
  9672  			{
  9673  			b1 = 0;
  9674  			if (b2 === 0xff)
  9675  			{
  9676  				b2 = 0;
  9677  				if (b3 === 0xff)
  9678  				{
  9679  					b3 = 0;
  9680  				}
  9681  				else
  9682  				{
  9683  					++b3;
  9684  				}
  9685  			}
  9686  			else
  9687  			{
  9688  				++b2;
  9689  			}
  9690  			}
  9691  			else
  9692  			{
  9693  			++b1;
  9694  			}
  9695  
  9696  			word = 0;
  9697  			word += (b1 << 16);
  9698  			word += (b2 << 8);
  9699  			word += b3;
  9700  			}
  9701  			else
  9702  			{
  9703  			word += (0x01 << 24);
  9704  			}
  9705  			return word;
  9706  		}
  9707  
  9708  		function incCounter(counter)
  9709  		{
  9710  			if ((counter[0] = incWord(counter[0])) === 0)
  9711  			{
  9712  				// encr_data in fileenc.c from  Dr Brian Gladman's counts only with DWORD j < 8
  9713  				counter[1] = incWord(counter[1]);
  9714  			}
  9715  			return counter;
  9716  		}
  9717  
  9718  	    var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
  9719  	        processBlock: function (words, offset) {
  9720  	            // Shortcuts
  9721  	            var cipher = this._cipher
  9722  	            var blockSize = cipher.blockSize;
  9723  	            var iv = this._iv;
  9724  	            var counter = this._counter;
  9725  
  9726  	            // Generate keystream
  9727  	            if (iv) {
  9728  	                counter = this._counter = iv.slice(0);
  9729  
  9730  	                // Remove IV for subsequent blocks
  9731  	                this._iv = undefined;
  9732  	            }
  9733  
  9734  				incCounter(counter);
  9735  
  9736  				var keystream = counter.slice(0);
  9737  	            cipher.encryptBlock(keystream, 0);
  9738  
  9739  	            // Encrypt
  9740  	            for (var i = 0; i < blockSize; i++) {
  9741  	                words[offset + i] ^= keystream[i];
  9742  	            }
  9743  	        }
  9744  	    });
  9745  
  9746  	    CTRGladman.Decryptor = Encryptor;
  9747  
  9748  	    return CTRGladman;
  9749  	}());
  9750  
  9751  
  9752  
  9753  
  9754  	return CryptoJS.mode.CTRGladman;
  9755  
  9756  }));
  9757  },{"./cipher-core":52,"./core":53}],64:[function(require,module,exports){
  9758  ;(function (root, factory, undef) {
  9759  	if (typeof exports === "object") {
  9760  		// CommonJS
  9761  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9762  	}
  9763  	else if (typeof define === "function" && define.amd) {
  9764  		// AMD
  9765  		define(["./core", "./cipher-core"], factory);
  9766  	}
  9767  	else {
  9768  		// Global (browser)
  9769  		factory(root.CryptoJS);
  9770  	}
  9771  }(this, function (CryptoJS) {
  9772  
  9773  	/**
  9774  	 * Counter block mode.
  9775  	 */
  9776  	CryptoJS.mode.CTR = (function () {
  9777  	    var CTR = CryptoJS.lib.BlockCipherMode.extend();
  9778  
  9779  	    var Encryptor = CTR.Encryptor = CTR.extend({
  9780  	        processBlock: function (words, offset) {
  9781  	            // Shortcuts
  9782  	            var cipher = this._cipher
  9783  	            var blockSize = cipher.blockSize;
  9784  	            var iv = this._iv;
  9785  	            var counter = this._counter;
  9786  
  9787  	            // Generate keystream
  9788  	            if (iv) {
  9789  	                counter = this._counter = iv.slice(0);
  9790  
  9791  	                // Remove IV for subsequent blocks
  9792  	                this._iv = undefined;
  9793  	            }
  9794  	            var keystream = counter.slice(0);
  9795  	            cipher.encryptBlock(keystream, 0);
  9796  
  9797  	            // Increment counter
  9798  	            counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
  9799  
  9800  	            // Encrypt
  9801  	            for (var i = 0; i < blockSize; i++) {
  9802  	                words[offset + i] ^= keystream[i];
  9803  	            }
  9804  	        }
  9805  	    });
  9806  
  9807  	    CTR.Decryptor = Encryptor;
  9808  
  9809  	    return CTR;
  9810  	}());
  9811  
  9812  
  9813  	return CryptoJS.mode.CTR;
  9814  
  9815  }));
  9816  },{"./cipher-core":52,"./core":53}],65:[function(require,module,exports){
  9817  ;(function (root, factory, undef) {
  9818  	if (typeof exports === "object") {
  9819  		// CommonJS
  9820  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9821  	}
  9822  	else if (typeof define === "function" && define.amd) {
  9823  		// AMD
  9824  		define(["./core", "./cipher-core"], factory);
  9825  	}
  9826  	else {
  9827  		// Global (browser)
  9828  		factory(root.CryptoJS);
  9829  	}
  9830  }(this, function (CryptoJS) {
  9831  
  9832  	/**
  9833  	 * Electronic Codebook block mode.
  9834  	 */
  9835  	CryptoJS.mode.ECB = (function () {
  9836  	    var ECB = CryptoJS.lib.BlockCipherMode.extend();
  9837  
  9838  	    ECB.Encryptor = ECB.extend({
  9839  	        processBlock: function (words, offset) {
  9840  	            this._cipher.encryptBlock(words, offset);
  9841  	        }
  9842  	    });
  9843  
  9844  	    ECB.Decryptor = ECB.extend({
  9845  	        processBlock: function (words, offset) {
  9846  	            this._cipher.decryptBlock(words, offset);
  9847  	        }
  9848  	    });
  9849  
  9850  	    return ECB;
  9851  	}());
  9852  
  9853  
  9854  	return CryptoJS.mode.ECB;
  9855  
  9856  }));
  9857  },{"./cipher-core":52,"./core":53}],66:[function(require,module,exports){
  9858  ;(function (root, factory, undef) {
  9859  	if (typeof exports === "object") {
  9860  		// CommonJS
  9861  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9862  	}
  9863  	else if (typeof define === "function" && define.amd) {
  9864  		// AMD
  9865  		define(["./core", "./cipher-core"], factory);
  9866  	}
  9867  	else {
  9868  		// Global (browser)
  9869  		factory(root.CryptoJS);
  9870  	}
  9871  }(this, function (CryptoJS) {
  9872  
  9873  	/**
  9874  	 * Output Feedback block mode.
  9875  	 */
  9876  	CryptoJS.mode.OFB = (function () {
  9877  	    var OFB = CryptoJS.lib.BlockCipherMode.extend();
  9878  
  9879  	    var Encryptor = OFB.Encryptor = OFB.extend({
  9880  	        processBlock: function (words, offset) {
  9881  	            // Shortcuts
  9882  	            var cipher = this._cipher
  9883  	            var blockSize = cipher.blockSize;
  9884  	            var iv = this._iv;
  9885  	            var keystream = this._keystream;
  9886  
  9887  	            // Generate keystream
  9888  	            if (iv) {
  9889  	                keystream = this._keystream = iv.slice(0);
  9890  
  9891  	                // Remove IV for subsequent blocks
  9892  	                this._iv = undefined;
  9893  	            }
  9894  	            cipher.encryptBlock(keystream, 0);
  9895  
  9896  	            // Encrypt
  9897  	            for (var i = 0; i < blockSize; i++) {
  9898  	                words[offset + i] ^= keystream[i];
  9899  	            }
  9900  	        }
  9901  	    });
  9902  
  9903  	    OFB.Decryptor = Encryptor;
  9904  
  9905  	    return OFB;
  9906  	}());
  9907  
  9908  
  9909  	return CryptoJS.mode.OFB;
  9910  
  9911  }));
  9912  },{"./cipher-core":52,"./core":53}],67:[function(require,module,exports){
  9913  ;(function (root, factory, undef) {
  9914  	if (typeof exports === "object") {
  9915  		// CommonJS
  9916  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9917  	}
  9918  	else if (typeof define === "function" && define.amd) {
  9919  		// AMD
  9920  		define(["./core", "./cipher-core"], factory);
  9921  	}
  9922  	else {
  9923  		// Global (browser)
  9924  		factory(root.CryptoJS);
  9925  	}
  9926  }(this, function (CryptoJS) {
  9927  
  9928  	/**
  9929  	 * ANSI X.923 padding strategy.
  9930  	 */
  9931  	CryptoJS.pad.AnsiX923 = {
  9932  	    pad: function (data, blockSize) {
  9933  	        // Shortcuts
  9934  	        var dataSigBytes = data.sigBytes;
  9935  	        var blockSizeBytes = blockSize * 4;
  9936  
  9937  	        // Count padding bytes
  9938  	        var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
  9939  
  9940  	        // Compute last byte position
  9941  	        var lastBytePos = dataSigBytes + nPaddingBytes - 1;
  9942  
  9943  	        // Pad
  9944  	        data.clamp();
  9945  	        data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
  9946  	        data.sigBytes += nPaddingBytes;
  9947  	    },
  9948  
  9949  	    unpad: function (data) {
  9950  	        // Get number of padding bytes from last byte
  9951  	        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  9952  
  9953  	        // Remove padding
  9954  	        data.sigBytes -= nPaddingBytes;
  9955  	    }
  9956  	};
  9957  
  9958  
  9959  	return CryptoJS.pad.Ansix923;
  9960  
  9961  }));
  9962  },{"./cipher-core":52,"./core":53}],68:[function(require,module,exports){
  9963  ;(function (root, factory, undef) {
  9964  	if (typeof exports === "object") {
  9965  		// CommonJS
  9966  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9967  	}
  9968  	else if (typeof define === "function" && define.amd) {
  9969  		// AMD
  9970  		define(["./core", "./cipher-core"], factory);
  9971  	}
  9972  	else {
  9973  		// Global (browser)
  9974  		factory(root.CryptoJS);
  9975  	}
  9976  }(this, function (CryptoJS) {
  9977  
  9978  	/**
  9979  	 * ISO 10126 padding strategy.
  9980  	 */
  9981  	CryptoJS.pad.Iso10126 = {
  9982  	    pad: function (data, blockSize) {
  9983  	        // Shortcut
  9984  	        var blockSizeBytes = blockSize * 4;
  9985  
  9986  	        // Count padding bytes
  9987  	        var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  9988  
  9989  	        // Pad
  9990  	        data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
  9991  	             concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
  9992  	    },
  9993  
  9994  	    unpad: function (data) {
  9995  	        // Get number of padding bytes from last byte
  9996  	        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  9997  
  9998  	        // Remove padding
  9999  	        data.sigBytes -= nPaddingBytes;
 10000  	    }
 10001  	};
 10002  
 10003  
 10004  	return CryptoJS.pad.Iso10126;
 10005  
 10006  }));
 10007  },{"./cipher-core":52,"./core":53}],69:[function(require,module,exports){
 10008  ;(function (root, factory, undef) {
 10009  	if (typeof exports === "object") {
 10010  		// CommonJS
 10011  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10012  	}
 10013  	else if (typeof define === "function" && define.amd) {
 10014  		// AMD
 10015  		define(["./core", "./cipher-core"], factory);
 10016  	}
 10017  	else {
 10018  		// Global (browser)
 10019  		factory(root.CryptoJS);
 10020  	}
 10021  }(this, function (CryptoJS) {
 10022  
 10023  	/**
 10024  	 * ISO/IEC 9797-1 Padding Method 2.
 10025  	 */
 10026  	CryptoJS.pad.Iso97971 = {
 10027  	    pad: function (data, blockSize) {
 10028  	        // Add 0x80 byte
 10029  	        data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
 10030  
 10031  	        // Zero pad the rest
 10032  	        CryptoJS.pad.ZeroPadding.pad(data, blockSize);
 10033  	    },
 10034  
 10035  	    unpad: function (data) {
 10036  	        // Remove zero padding
 10037  	        CryptoJS.pad.ZeroPadding.unpad(data);
 10038  
 10039  	        // Remove one more byte -- the 0x80 byte
 10040  	        data.sigBytes--;
 10041  	    }
 10042  	};
 10043  
 10044  
 10045  	return CryptoJS.pad.Iso97971;
 10046  
 10047  }));
 10048  },{"./cipher-core":52,"./core":53}],70:[function(require,module,exports){
 10049  ;(function (root, factory, undef) {
 10050  	if (typeof exports === "object") {
 10051  		// CommonJS
 10052  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10053  	}
 10054  	else if (typeof define === "function" && define.amd) {
 10055  		// AMD
 10056  		define(["./core", "./cipher-core"], factory);
 10057  	}
 10058  	else {
 10059  		// Global (browser)
 10060  		factory(root.CryptoJS);
 10061  	}
 10062  }(this, function (CryptoJS) {
 10063  
 10064  	/**
 10065  	 * A noop padding strategy.
 10066  	 */
 10067  	CryptoJS.pad.NoPadding = {
 10068  	    pad: function () {
 10069  	    },
 10070  
 10071  	    unpad: function () {
 10072  	    }
 10073  	};
 10074  
 10075  
 10076  	return CryptoJS.pad.NoPadding;
 10077  
 10078  }));
 10079  },{"./cipher-core":52,"./core":53}],71:[function(require,module,exports){
 10080  ;(function (root, factory, undef) {
 10081  	if (typeof exports === "object") {
 10082  		// CommonJS
 10083  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
 10084  	}
 10085  	else if (typeof define === "function" && define.amd) {
 10086  		// AMD
 10087  		define(["./core", "./cipher-core"], factory);
 10088  	}
 10089  	else {
 10090  		// Global (browser)
 10091  		factory(root.CryptoJS);
 10092  	}
 10093  }(this, function (CryptoJS) {
 10094  
 10095  	/**
 10096  	 * Zero padding strategy.
 10097  	 */
 10098  	CryptoJS.pad.ZeroPadding = {
 10099  	    pad: function (data, blockSize) {
 10100  	        // Shortcut
 10101  	        var blockSizeBytes = blockSize * 4;
 10102  
 10103  	        // Pad
 10104  	        data.clamp();
 10105  	        data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
 10106  	    },
 10107  
 10108  	    unpad: function (data) {
 10109  	        // Shortcut
 10110  	        var dataWords = data.words;
 10111  
 10112  	        // Unpad
 10113  	        var i = data.sigBytes - 1;
 10114  	        while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
 10115  	            i--;
 10116  	        }
 10117  	        data.sigBytes = i + 1;
 10118  	    }
 10119  	};
 10120  
 10121  
 10122  	return CryptoJS.pad.ZeroPadding;
 10123  
 10124  }));
 10125  },{"./cipher-core":52,"./core":53}],72:[function(require,module,exports){
 10126  ;(function (root, factory, undef) {
 10127  	if (typeof exports === "object") {
 10128  		// CommonJS
 10129  		module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
 10130  	}
 10131  	else if (typeof define === "function" && define.amd) {
 10132  		// AMD
 10133  		define(["./core", "./sha1", "./hmac"], factory);
 10134  	}
 10135  	else {
 10136  		// Global (browser)
 10137  		factory(root.CryptoJS);
 10138  	}
 10139  }(this, function (CryptoJS) {
 10140  
 10141  	(function () {
 10142  	    // Shortcuts
 10143  	    var C = CryptoJS;
 10144  	    var C_lib = C.lib;
 10145  	    var Base = C_lib.Base;
 10146  	    var WordArray = C_lib.WordArray;
 10147  	    var C_algo = C.algo;
 10148  	    var SHA1 = C_algo.SHA1;
 10149  	    var HMAC = C_algo.HMAC;
 10150  
 10151  	    /**
 10152  	     * Password-Based Key Derivation Function 2 algorithm.
 10153  	     */
 10154  	    var PBKDF2 = C_algo.PBKDF2 = Base.extend({
 10155  	        /**
 10156  	         * Configuration options.
 10157  	         *
 10158  	         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
 10159  	         * @property {Hasher} hasher The hasher to use. Default: SHA1
 10160  	         * @property {number} iterations The number of iterations to perform. Default: 1
 10161  	         */
 10162  	        cfg: Base.extend({
 10163  	            keySize: 128/32,
 10164  	            hasher: SHA1,
 10165  	            iterations: 1
 10166  	        }),
 10167  
 10168  	        /**
 10169  	         * Initializes a newly created key derivation function.
 10170  	         *
 10171  	         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
 10172  	         *
 10173  	         * @example
 10174  	         *
 10175  	         *     var kdf = CryptoJS.algo.PBKDF2.create();
 10176  	         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
 10177  	         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
 10178  	         */
 10179  	        init: function (cfg) {
 10180  	            this.cfg = this.cfg.extend(cfg);
 10181  	        },
 10182  
 10183  	        /**
 10184  	         * Computes the Password-Based Key Derivation Function 2.
 10185  	         *
 10186  	         * @param {WordArray|string} password The password.
 10187  	         * @param {WordArray|string} salt A salt.
 10188  	         *
 10189  	         * @return {WordArray} The derived key.
 10190  	         *
 10191  	         * @example
 10192  	         *
 10193  	         *     var key = kdf.compute(password, salt);
 10194  	         */
 10195  	        compute: function (password, salt) {
 10196  	            // Shortcut
 10197  	            var cfg = this.cfg;
 10198  
 10199  	            // Init HMAC
 10200  	            var hmac = HMAC.create(cfg.hasher, password);
 10201  
 10202  	            // Initial values
 10203  	            var derivedKey = WordArray.create();
 10204  	            var blockIndex = WordArray.create([0x00000001]);
 10205  
 10206  	            // Shortcuts
 10207  	            var derivedKeyWords = derivedKey.words;
 10208  	            var blockIndexWords = blockIndex.words;
 10209  	            var keySize = cfg.keySize;
 10210  	            var iterations = cfg.iterations;
 10211  
 10212  	            // Generate key
 10213  	            while (derivedKeyWords.length < keySize) {
 10214  	                var block = hmac.update(salt).finalize(blockIndex);
 10215  	                hmac.reset();
 10216  
 10217  	                // Shortcuts
 10218  	                var blockWords = block.words;
 10219  	                var blockWordsLength = blockWords.length;
 10220  
 10221  	                // Iterations
 10222  	                var intermediate = block;
 10223  	                for (var i = 1; i < iterations; i++) {
 10224  	                    intermediate = hmac.finalize(intermediate);
 10225  	                    hmac.reset();
 10226  
 10227  	                    // Shortcut
 10228  	                    var intermediateWords = intermediate.words;
 10229  
 10230  	                    // XOR intermediate with block
 10231  	                    for (var j = 0; j < blockWordsLength; j++) {
 10232  	                        blockWords[j] ^= intermediateWords[j];
 10233  	                    }
 10234  	                }
 10235  
 10236  	                derivedKey.concat(block);
 10237  	                blockIndexWords[0]++;
 10238  	            }
 10239  	            derivedKey.sigBytes = keySize * 4;
 10240  
 10241  	            return derivedKey;
 10242  	        }
 10243  	    });
 10244  
 10245  	    /**
 10246  	     * Computes the Password-Based Key Derivation Function 2.
 10247  	     *
 10248  	     * @param {WordArray|string} password The password.
 10249  	     * @param {WordArray|string} salt A salt.
 10250  	     * @param {Object} cfg (Optional) The configuration options to use for this computation.
 10251  	     *
 10252  	     * @return {WordArray} The derived key.
 10253  	     *
 10254  	     * @static
 10255  	     *
 10256  	     * @example
 10257  	     *
 10258  	     *     var key = CryptoJS.PBKDF2(password, salt);
 10259  	     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
 10260  	     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
 10261  	     */
 10262  	    C.PBKDF2 = function (password, salt, cfg) {
 10263  	        return PBKDF2.create(cfg).compute(password, salt);
 10264  	    };
 10265  	}());
 10266  
 10267  
 10268  	return CryptoJS.PBKDF2;
 10269  
 10270  }));
 10271  },{"./core":53,"./hmac":58,"./sha1":77}],73:[function(require,module,exports){
 10272  ;(function (root, factory, undef) {
 10273  	if (typeof exports === "object") {
 10274  		// CommonJS
 10275  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10276  	}
 10277  	else if (typeof define === "function" && define.amd) {
 10278  		// AMD
 10279  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10280  	}
 10281  	else {
 10282  		// Global (browser)
 10283  		factory(root.CryptoJS);
 10284  	}
 10285  }(this, function (CryptoJS) {
 10286  
 10287  	(function () {
 10288  	    // Shortcuts
 10289  	    var C = CryptoJS;
 10290  	    var C_lib = C.lib;
 10291  	    var StreamCipher = C_lib.StreamCipher;
 10292  	    var C_algo = C.algo;
 10293  
 10294  	    // Reusable objects
 10295  	    var S  = [];
 10296  	    var C_ = [];
 10297  	    var G  = [];
 10298  
 10299  	    /**
 10300  	     * Rabbit stream cipher algorithm.
 10301  	     *
 10302  	     * This is a legacy version that neglected to convert the key to little-endian.
 10303  	     * This error doesn't affect the cipher's security,
 10304  	     * but it does affect its compatibility with other implementations.
 10305  	     */
 10306  	    var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
 10307  	        _doReset: function () {
 10308  	            // Shortcuts
 10309  	            var K = this._key.words;
 10310  	            var iv = this.cfg.iv;
 10311  
 10312  	            // Generate initial state values
 10313  	            var X = this._X = [
 10314  	                K[0], (K[3] << 16) | (K[2] >>> 16),
 10315  	                K[1], (K[0] << 16) | (K[3] >>> 16),
 10316  	                K[2], (K[1] << 16) | (K[0] >>> 16),
 10317  	                K[3], (K[2] << 16) | (K[1] >>> 16)
 10318  	            ];
 10319  
 10320  	            // Generate initial counter values
 10321  	            var C = this._C = [
 10322  	                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10323  	                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10324  	                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10325  	                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10326  	            ];
 10327  
 10328  	            // Carry bit
 10329  	            this._b = 0;
 10330  
 10331  	            // Iterate the system four times
 10332  	            for (var i = 0; i < 4; i++) {
 10333  	                nextState.call(this);
 10334  	            }
 10335  
 10336  	            // Modify the counters
 10337  	            for (var i = 0; i < 8; i++) {
 10338  	                C[i] ^= X[(i + 4) & 7];
 10339  	            }
 10340  
 10341  	            // IV setup
 10342  	            if (iv) {
 10343  	                // Shortcuts
 10344  	                var IV = iv.words;
 10345  	                var IV_0 = IV[0];
 10346  	                var IV_1 = IV[1];
 10347  
 10348  	                // Generate four subvectors
 10349  	                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10350  	                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10351  	                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10352  	                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10353  
 10354  	                // Modify counter values
 10355  	                C[0] ^= i0;
 10356  	                C[1] ^= i1;
 10357  	                C[2] ^= i2;
 10358  	                C[3] ^= i3;
 10359  	                C[4] ^= i0;
 10360  	                C[5] ^= i1;
 10361  	                C[6] ^= i2;
 10362  	                C[7] ^= i3;
 10363  
 10364  	                // Iterate the system four times
 10365  	                for (var i = 0; i < 4; i++) {
 10366  	                    nextState.call(this);
 10367  	                }
 10368  	            }
 10369  	        },
 10370  
 10371  	        _doProcessBlock: function (M, offset) {
 10372  	            // Shortcut
 10373  	            var X = this._X;
 10374  
 10375  	            // Iterate the system
 10376  	            nextState.call(this);
 10377  
 10378  	            // Generate four keystream words
 10379  	            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10380  	            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10381  	            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10382  	            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10383  
 10384  	            for (var i = 0; i < 4; i++) {
 10385  	                // Swap endian
 10386  	                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10387  	                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10388  
 10389  	                // Encrypt
 10390  	                M[offset + i] ^= S[i];
 10391  	            }
 10392  	        },
 10393  
 10394  	        blockSize: 128/32,
 10395  
 10396  	        ivSize: 64/32
 10397  	    });
 10398  
 10399  	    function nextState() {
 10400  	        // Shortcuts
 10401  	        var X = this._X;
 10402  	        var C = this._C;
 10403  
 10404  	        // Save old counter values
 10405  	        for (var i = 0; i < 8; i++) {
 10406  	            C_[i] = C[i];
 10407  	        }
 10408  
 10409  	        // Calculate new counter values
 10410  	        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10411  	        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10412  	        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10413  	        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10414  	        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10415  	        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10416  	        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10417  	        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10418  	        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10419  
 10420  	        // Calculate the g-values
 10421  	        for (var i = 0; i < 8; i++) {
 10422  	            var gx = X[i] + C[i];
 10423  
 10424  	            // Construct high and low argument for squaring
 10425  	            var ga = gx & 0xffff;
 10426  	            var gb = gx >>> 16;
 10427  
 10428  	            // Calculate high and low result of squaring
 10429  	            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10430  	            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10431  
 10432  	            // High XOR low
 10433  	            G[i] = gh ^ gl;
 10434  	        }
 10435  
 10436  	        // Calculate new state values
 10437  	        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10438  	        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10439  	        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10440  	        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10441  	        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10442  	        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10443  	        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10444  	        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10445  	    }
 10446  
 10447  	    /**
 10448  	     * Shortcut functions to the cipher's object interface.
 10449  	     *
 10450  	     * @example
 10451  	     *
 10452  	     *     var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
 10453  	     *     var plaintext  = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
 10454  	     */
 10455  	    C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
 10456  	}());
 10457  
 10458  
 10459  	return CryptoJS.RabbitLegacy;
 10460  
 10461  }));
 10462  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],74:[function(require,module,exports){
 10463  ;(function (root, factory, undef) {
 10464  	if (typeof exports === "object") {
 10465  		// CommonJS
 10466  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10467  	}
 10468  	else if (typeof define === "function" && define.amd) {
 10469  		// AMD
 10470  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10471  	}
 10472  	else {
 10473  		// Global (browser)
 10474  		factory(root.CryptoJS);
 10475  	}
 10476  }(this, function (CryptoJS) {
 10477  
 10478  	(function () {
 10479  	    // Shortcuts
 10480  	    var C = CryptoJS;
 10481  	    var C_lib = C.lib;
 10482  	    var StreamCipher = C_lib.StreamCipher;
 10483  	    var C_algo = C.algo;
 10484  
 10485  	    // Reusable objects
 10486  	    var S  = [];
 10487  	    var C_ = [];
 10488  	    var G  = [];
 10489  
 10490  	    /**
 10491  	     * Rabbit stream cipher algorithm
 10492  	     */
 10493  	    var Rabbit = C_algo.Rabbit = StreamCipher.extend({
 10494  	        _doReset: function () {
 10495  	            // Shortcuts
 10496  	            var K = this._key.words;
 10497  	            var iv = this.cfg.iv;
 10498  
 10499  	            // Swap endian
 10500  	            for (var i = 0; i < 4; i++) {
 10501  	                K[i] = (((K[i] << 8)  | (K[i] >>> 24)) & 0x00ff00ff) |
 10502  	                       (((K[i] << 24) | (K[i] >>> 8))  & 0xff00ff00);
 10503  	            }
 10504  
 10505  	            // Generate initial state values
 10506  	            var X = this._X = [
 10507  	                K[0], (K[3] << 16) | (K[2] >>> 16),
 10508  	                K[1], (K[0] << 16) | (K[3] >>> 16),
 10509  	                K[2], (K[1] << 16) | (K[0] >>> 16),
 10510  	                K[3], (K[2] << 16) | (K[1] >>> 16)
 10511  	            ];
 10512  
 10513  	            // Generate initial counter values
 10514  	            var C = this._C = [
 10515  	                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10516  	                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10517  	                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10518  	                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10519  	            ];
 10520  
 10521  	            // Carry bit
 10522  	            this._b = 0;
 10523  
 10524  	            // Iterate the system four times
 10525  	            for (var i = 0; i < 4; i++) {
 10526  	                nextState.call(this);
 10527  	            }
 10528  
 10529  	            // Modify the counters
 10530  	            for (var i = 0; i < 8; i++) {
 10531  	                C[i] ^= X[(i + 4) & 7];
 10532  	            }
 10533  
 10534  	            // IV setup
 10535  	            if (iv) {
 10536  	                // Shortcuts
 10537  	                var IV = iv.words;
 10538  	                var IV_0 = IV[0];
 10539  	                var IV_1 = IV[1];
 10540  
 10541  	                // Generate four subvectors
 10542  	                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10543  	                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10544  	                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10545  	                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10546  
 10547  	                // Modify counter values
 10548  	                C[0] ^= i0;
 10549  	                C[1] ^= i1;
 10550  	                C[2] ^= i2;
 10551  	                C[3] ^= i3;
 10552  	                C[4] ^= i0;
 10553  	                C[5] ^= i1;
 10554  	                C[6] ^= i2;
 10555  	                C[7] ^= i3;
 10556  
 10557  	                // Iterate the system four times
 10558  	                for (var i = 0; i < 4; i++) {
 10559  	                    nextState.call(this);
 10560  	                }
 10561  	            }
 10562  	        },
 10563  
 10564  	        _doProcessBlock: function (M, offset) {
 10565  	            // Shortcut
 10566  	            var X = this._X;
 10567  
 10568  	            // Iterate the system
 10569  	            nextState.call(this);
 10570  
 10571  	            // Generate four keystream words
 10572  	            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10573  	            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10574  	            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10575  	            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10576  
 10577  	            for (var i = 0; i < 4; i++) {
 10578  	                // Swap endian
 10579  	                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10580  	                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10581  
 10582  	                // Encrypt
 10583  	                M[offset + i] ^= S[i];
 10584  	            }
 10585  	        },
 10586  
 10587  	        blockSize: 128/32,
 10588  
 10589  	        ivSize: 64/32
 10590  	    });
 10591  
 10592  	    function nextState() {
 10593  	        // Shortcuts
 10594  	        var X = this._X;
 10595  	        var C = this._C;
 10596  
 10597  	        // Save old counter values
 10598  	        for (var i = 0; i < 8; i++) {
 10599  	            C_[i] = C[i];
 10600  	        }
 10601  
 10602  	        // Calculate new counter values
 10603  	        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10604  	        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10605  	        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10606  	        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10607  	        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10608  	        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10609  	        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10610  	        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10611  	        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10612  
 10613  	        // Calculate the g-values
 10614  	        for (var i = 0; i < 8; i++) {
 10615  	            var gx = X[i] + C[i];
 10616  
 10617  	            // Construct high and low argument for squaring
 10618  	            var ga = gx & 0xffff;
 10619  	            var gb = gx >>> 16;
 10620  
 10621  	            // Calculate high and low result of squaring
 10622  	            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10623  	            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10624  
 10625  	            // High XOR low
 10626  	            G[i] = gh ^ gl;
 10627  	        }
 10628  
 10629  	        // Calculate new state values
 10630  	        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10631  	        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10632  	        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10633  	        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10634  	        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10635  	        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10636  	        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10637  	        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10638  	    }
 10639  
 10640  	    /**
 10641  	     * Shortcut functions to the cipher's object interface.
 10642  	     *
 10643  	     * @example
 10644  	     *
 10645  	     *     var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
 10646  	     *     var plaintext  = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
 10647  	     */
 10648  	    C.Rabbit = StreamCipher._createHelper(Rabbit);
 10649  	}());
 10650  
 10651  
 10652  	return CryptoJS.Rabbit;
 10653  
 10654  }));
 10655  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],75:[function(require,module,exports){
 10656  ;(function (root, factory, undef) {
 10657  	if (typeof exports === "object") {
 10658  		// CommonJS
 10659  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10660  	}
 10661  	else if (typeof define === "function" && define.amd) {
 10662  		// AMD
 10663  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10664  	}
 10665  	else {
 10666  		// Global (browser)
 10667  		factory(root.CryptoJS);
 10668  	}
 10669  }(this, function (CryptoJS) {
 10670  
 10671  	(function () {
 10672  	    // Shortcuts
 10673  	    var C = CryptoJS;
 10674  	    var C_lib = C.lib;
 10675  	    var StreamCipher = C_lib.StreamCipher;
 10676  	    var C_algo = C.algo;
 10677  
 10678  	    /**
 10679  	     * RC4 stream cipher algorithm.
 10680  	     */
 10681  	    var RC4 = C_algo.RC4 = StreamCipher.extend({
 10682  	        _doReset: function () {
 10683  	            // Shortcuts
 10684  	            var key = this._key;
 10685  	            var keyWords = key.words;
 10686  	            var keySigBytes = key.sigBytes;
 10687  
 10688  	            // Init sbox
 10689  	            var S = this._S = [];
 10690  	            for (var i = 0; i < 256; i++) {
 10691  	                S[i] = i;
 10692  	            }
 10693  
 10694  	            // Key setup
 10695  	            for (var i = 0, j = 0; i < 256; i++) {
 10696  	                var keyByteIndex = i % keySigBytes;
 10697  	                var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
 10698  
 10699  	                j = (j + S[i] + keyByte) % 256;
 10700  
 10701  	                // Swap
 10702  	                var t = S[i];
 10703  	                S[i] = S[j];
 10704  	                S[j] = t;
 10705  	            }
 10706  
 10707  	            // Counters
 10708  	            this._i = this._j = 0;
 10709  	        },
 10710  
 10711  	        _doProcessBlock: function (M, offset) {
 10712  	            M[offset] ^= generateKeystreamWord.call(this);
 10713  	        },
 10714  
 10715  	        keySize: 256/32,
 10716  
 10717  	        ivSize: 0
 10718  	    });
 10719  
 10720  	    function generateKeystreamWord() {
 10721  	        // Shortcuts
 10722  	        var S = this._S;
 10723  	        var i = this._i;
 10724  	        var j = this._j;
 10725  
 10726  	        // Generate keystream word
 10727  	        var keystreamWord = 0;
 10728  	        for (var n = 0; n < 4; n++) {
 10729  	            i = (i + 1) % 256;
 10730  	            j = (j + S[i]) % 256;
 10731  
 10732  	            // Swap
 10733  	            var t = S[i];
 10734  	            S[i] = S[j];
 10735  	            S[j] = t;
 10736  
 10737  	            keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
 10738  	        }
 10739  
 10740  	        // Update counters
 10741  	        this._i = i;
 10742  	        this._j = j;
 10743  
 10744  	        return keystreamWord;
 10745  	    }
 10746  
 10747  	    /**
 10748  	     * Shortcut functions to the cipher's object interface.
 10749  	     *
 10750  	     * @example
 10751  	     *
 10752  	     *     var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
 10753  	     *     var plaintext  = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
 10754  	     */
 10755  	    C.RC4 = StreamCipher._createHelper(RC4);
 10756  
 10757  	    /**
 10758  	     * Modified RC4 stream cipher algorithm.
 10759  	     */
 10760  	    var RC4Drop = C_algo.RC4Drop = RC4.extend({
 10761  	        /**
 10762  	         * Configuration options.
 10763  	         *
 10764  	         * @property {number} drop The number of keystream words to drop. Default 192
 10765  	         */
 10766  	        cfg: RC4.cfg.extend({
 10767  	            drop: 192
 10768  	        }),
 10769  
 10770  	        _doReset: function () {
 10771  	            RC4._doReset.call(this);
 10772  
 10773  	            // Drop
 10774  	            for (var i = this.cfg.drop; i > 0; i--) {
 10775  	                generateKeystreamWord.call(this);
 10776  	            }
 10777  	        }
 10778  	    });
 10779  
 10780  	    /**
 10781  	     * Shortcut functions to the cipher's object interface.
 10782  	     *
 10783  	     * @example
 10784  	     *
 10785  	     *     var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
 10786  	     *     var plaintext  = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
 10787  	     */
 10788  	    C.RC4Drop = StreamCipher._createHelper(RC4Drop);
 10789  	}());
 10790  
 10791  
 10792  	return CryptoJS.RC4;
 10793  
 10794  }));
 10795  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],76:[function(require,module,exports){
 10796  ;(function (root, factory) {
 10797  	if (typeof exports === "object") {
 10798  		// CommonJS
 10799  		module.exports = exports = factory(require("./core"));
 10800  	}
 10801  	else if (typeof define === "function" && define.amd) {
 10802  		// AMD
 10803  		define(["./core"], factory);
 10804  	}
 10805  	else {
 10806  		// Global (browser)
 10807  		factory(root.CryptoJS);
 10808  	}
 10809  }(this, function (CryptoJS) {
 10810  
 10811  	/** @preserve
 10812  	(c) 2012 by CĂ©dric Mesnil. All rights reserved.
 10813  
 10814  	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 10815  
 10816  	    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 10817  	    - 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.
 10818  
 10819  	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 10820  	*/
 10821  
 10822  	(function (Math) {
 10823  	    // Shortcuts
 10824  	    var C = CryptoJS;
 10825  	    var C_lib = C.lib;
 10826  	    var WordArray = C_lib.WordArray;
 10827  	    var Hasher = C_lib.Hasher;
 10828  	    var C_algo = C.algo;
 10829  
 10830  	    // Constants table
 10831  	    var _zl = WordArray.create([
 10832  	        0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
 10833  	        7,  4, 13,  1, 10,  6, 15,  3, 12,  0,  9,  5,  2, 14, 11,  8,
 10834  	        3, 10, 14,  4,  9, 15,  8,  1,  2,  7,  0,  6, 13, 11,  5, 12,
 10835  	        1,  9, 11, 10,  0,  8, 12,  4, 13,  3,  7, 15, 14,  5,  6,  2,
 10836  	        4,  0,  5,  9,  7, 12,  2, 10, 14,  1,  3,  8, 11,  6, 15, 13]);
 10837  	    var _zr = WordArray.create([
 10838  	        5, 14,  7,  0,  9,  2, 11,  4, 13,  6, 15,  8,  1, 10,  3, 12,
 10839  	        6, 11,  3,  7,  0, 13,  5, 10, 14, 15,  8, 12,  4,  9,  1,  2,
 10840  	        15,  5,  1,  3,  7, 14,  6,  9, 11,  8, 12,  2, 10,  0,  4, 13,
 10841  	        8,  6,  4,  1,  3, 11, 15,  0,  5, 12,  2, 13,  9,  7, 10, 14,
 10842  	        12, 15, 10,  4,  1,  5,  8,  7,  6,  2, 13, 14,  0,  3,  9, 11]);
 10843  	    var _sl = WordArray.create([
 10844  	         11, 14, 15, 12,  5,  8,  7,  9, 11, 13, 14, 15,  6,  7,  9,  8,
 10845  	        7, 6,   8, 13, 11,  9,  7, 15,  7, 12, 15,  9, 11,  7, 13, 12,
 10846  	        11, 13,  6,  7, 14,  9, 13, 15, 14,  8, 13,  6,  5, 12,  7,  5,
 10847  	          11, 12, 14, 15, 14, 15,  9,  8,  9, 14,  5,  6,  8,  6,  5, 12,
 10848  	        9, 15,  5, 11,  6,  8, 13, 12,  5, 12, 13, 14, 11,  8,  5,  6 ]);
 10849  	    var _sr = WordArray.create([
 10850  	        8,  9,  9, 11, 13, 15, 15,  5,  7,  7,  8, 11, 14, 14, 12,  6,
 10851  	        9, 13, 15,  7, 12,  8,  9, 11,  7,  7, 12,  7,  6, 15, 13, 11,
 10852  	        9,  7, 15, 11,  8,  6,  6, 14, 12, 13,  5, 14, 13, 13,  7,  5,
 10853  	        15,  5,  8, 11, 14, 14,  6, 14,  6,  9, 12,  9, 12,  5, 15,  8,
 10854  	        8,  5, 12,  9, 12,  5, 14,  6,  8, 13,  6,  5, 15, 13, 11, 11 ]);
 10855  
 10856  	    var _hl =  WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
 10857  	    var _hr =  WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
 10858  
 10859  	    /**
 10860  	     * RIPEMD160 hash algorithm.
 10861  	     */
 10862  	    var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
 10863  	        _doReset: function () {
 10864  	            this._hash  = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
 10865  	        },
 10866  
 10867  	        _doProcessBlock: function (M, offset) {
 10868  
 10869  	            // Swap endian
 10870  	            for (var i = 0; i < 16; i++) {
 10871  	                // Shortcuts
 10872  	                var offset_i = offset + i;
 10873  	                var M_offset_i = M[offset_i];
 10874  
 10875  	                // Swap
 10876  	                M[offset_i] = (
 10877  	                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
 10878  	                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
 10879  	                );
 10880  	            }
 10881  	            // Shortcut
 10882  	            var H  = this._hash.words;
 10883  	            var hl = _hl.words;
 10884  	            var hr = _hr.words;
 10885  	            var zl = _zl.words;
 10886  	            var zr = _zr.words;
 10887  	            var sl = _sl.words;
 10888  	            var sr = _sr.words;
 10889  
 10890  	            // Working variables
 10891  	            var al, bl, cl, dl, el;
 10892  	            var ar, br, cr, dr, er;
 10893  
 10894  	            ar = al = H[0];
 10895  	            br = bl = H[1];
 10896  	            cr = cl = H[2];
 10897  	            dr = dl = H[3];
 10898  	            er = el = H[4];
 10899  	            // Computation
 10900  	            var t;
 10901  	            for (var i = 0; i < 80; i += 1) {
 10902  	                t = (al +  M[offset+zl[i]])|0;
 10903  	                if (i<16){
 10904  		            t +=  f1(bl,cl,dl) + hl[0];
 10905  	                } else if (i<32) {
 10906  		            t +=  f2(bl,cl,dl) + hl[1];
 10907  	                } else if (i<48) {
 10908  		            t +=  f3(bl,cl,dl) + hl[2];
 10909  	                } else if (i<64) {
 10910  		            t +=  f4(bl,cl,dl) + hl[3];
 10911  	                } else {// if (i<80) {
 10912  		            t +=  f5(bl,cl,dl) + hl[4];
 10913  	                }
 10914  	                t = t|0;
 10915  	                t =  rotl(t,sl[i]);
 10916  	                t = (t+el)|0;
 10917  	                al = el;
 10918  	                el = dl;
 10919  	                dl = rotl(cl, 10);
 10920  	                cl = bl;
 10921  	                bl = t;
 10922  
 10923  	                t = (ar + M[offset+zr[i]])|0;
 10924  	                if (i<16){
 10925  		            t +=  f5(br,cr,dr) + hr[0];
 10926  	                } else if (i<32) {
 10927  		            t +=  f4(br,cr,dr) + hr[1];
 10928  	                } else if (i<48) {
 10929  		            t +=  f3(br,cr,dr) + hr[2];
 10930  	                } else if (i<64) {
 10931  		            t +=  f2(br,cr,dr) + hr[3];
 10932  	                } else {// if (i<80) {
 10933  		            t +=  f1(br,cr,dr) + hr[4];
 10934  	                }
 10935  	                t = t|0;
 10936  	                t =  rotl(t,sr[i]) ;
 10937  	                t = (t+er)|0;
 10938  	                ar = er;
 10939  	                er = dr;
 10940  	                dr = rotl(cr, 10);
 10941  	                cr = br;
 10942  	                br = t;
 10943  	            }
 10944  	            // Intermediate hash value
 10945  	            t    = (H[1] + cl + dr)|0;
 10946  	            H[1] = (H[2] + dl + er)|0;
 10947  	            H[2] = (H[3] + el + ar)|0;
 10948  	            H[3] = (H[4] + al + br)|0;
 10949  	            H[4] = (H[0] + bl + cr)|0;
 10950  	            H[0] =  t;
 10951  	        },
 10952  
 10953  	        _doFinalize: function () {
 10954  	            // Shortcuts
 10955  	            var data = this._data;
 10956  	            var dataWords = data.words;
 10957  
 10958  	            var nBitsTotal = this._nDataBytes * 8;
 10959  	            var nBitsLeft = data.sigBytes * 8;
 10960  
 10961  	            // Add padding
 10962  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 10963  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
 10964  	                (((nBitsTotal << 8)  | (nBitsTotal >>> 24)) & 0x00ff00ff) |
 10965  	                (((nBitsTotal << 24) | (nBitsTotal >>> 8))  & 0xff00ff00)
 10966  	            );
 10967  	            data.sigBytes = (dataWords.length + 1) * 4;
 10968  
 10969  	            // Hash final blocks
 10970  	            this._process();
 10971  
 10972  	            // Shortcuts
 10973  	            var hash = this._hash;
 10974  	            var H = hash.words;
 10975  
 10976  	            // Swap endian
 10977  	            for (var i = 0; i < 5; i++) {
 10978  	                // Shortcut
 10979  	                var H_i = H[i];
 10980  
 10981  	                // Swap
 10982  	                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
 10983  	                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
 10984  	            }
 10985  
 10986  	            // Return final computed hash
 10987  	            return hash;
 10988  	        },
 10989  
 10990  	        clone: function () {
 10991  	            var clone = Hasher.clone.call(this);
 10992  	            clone._hash = this._hash.clone();
 10993  
 10994  	            return clone;
 10995  	        }
 10996  	    });
 10997  
 10998  
 10999  	    function f1(x, y, z) {
 11000  	        return ((x) ^ (y) ^ (z));
 11001  
 11002  	    }
 11003  
 11004  	    function f2(x, y, z) {
 11005  	        return (((x)&(y)) | ((~x)&(z)));
 11006  	    }
 11007  
 11008  	    function f3(x, y, z) {
 11009  	        return (((x) | (~(y))) ^ (z));
 11010  	    }
 11011  
 11012  	    function f4(x, y, z) {
 11013  	        return (((x) & (z)) | ((y)&(~(z))));
 11014  	    }
 11015  
 11016  	    function f5(x, y, z) {
 11017  	        return ((x) ^ ((y) |(~(z))));
 11018  
 11019  	    }
 11020  
 11021  	    function rotl(x,n) {
 11022  	        return (x<<n) | (x>>>(32-n));
 11023  	    }
 11024  
 11025  
 11026  	    /**
 11027  	     * Shortcut function to the hasher's object interface.
 11028  	     *
 11029  	     * @param {WordArray|string} message The message to hash.
 11030  	     *
 11031  	     * @return {WordArray} The hash.
 11032  	     *
 11033  	     * @static
 11034  	     *
 11035  	     * @example
 11036  	     *
 11037  	     *     var hash = CryptoJS.RIPEMD160('message');
 11038  	     *     var hash = CryptoJS.RIPEMD160(wordArray);
 11039  	     */
 11040  	    C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
 11041  
 11042  	    /**
 11043  	     * Shortcut function to the HMAC's object interface.
 11044  	     *
 11045  	     * @param {WordArray|string} message The message to hash.
 11046  	     * @param {WordArray|string} key The secret key.
 11047  	     *
 11048  	     * @return {WordArray} The HMAC.
 11049  	     *
 11050  	     * @static
 11051  	     *
 11052  	     * @example
 11053  	     *
 11054  	     *     var hmac = CryptoJS.HmacRIPEMD160(message, key);
 11055  	     */
 11056  	    C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
 11057  	}(Math));
 11058  
 11059  
 11060  	return CryptoJS.RIPEMD160;
 11061  
 11062  }));
 11063  },{"./core":53}],77:[function(require,module,exports){
 11064  ;(function (root, factory) {
 11065  	if (typeof exports === "object") {
 11066  		// CommonJS
 11067  		module.exports = exports = factory(require("./core"));
 11068  	}
 11069  	else if (typeof define === "function" && define.amd) {
 11070  		// AMD
 11071  		define(["./core"], factory);
 11072  	}
 11073  	else {
 11074  		// Global (browser)
 11075  		factory(root.CryptoJS);
 11076  	}
 11077  }(this, function (CryptoJS) {
 11078  
 11079  	(function () {
 11080  	    // Shortcuts
 11081  	    var C = CryptoJS;
 11082  	    var C_lib = C.lib;
 11083  	    var WordArray = C_lib.WordArray;
 11084  	    var Hasher = C_lib.Hasher;
 11085  	    var C_algo = C.algo;
 11086  
 11087  	    // Reusable object
 11088  	    var W = [];
 11089  
 11090  	    /**
 11091  	     * SHA-1 hash algorithm.
 11092  	     */
 11093  	    var SHA1 = C_algo.SHA1 = Hasher.extend({
 11094  	        _doReset: function () {
 11095  	            this._hash = new WordArray.init([
 11096  	                0x67452301, 0xefcdab89,
 11097  	                0x98badcfe, 0x10325476,
 11098  	                0xc3d2e1f0
 11099  	            ]);
 11100  	        },
 11101  
 11102  	        _doProcessBlock: function (M, offset) {
 11103  	            // Shortcut
 11104  	            var H = this._hash.words;
 11105  
 11106  	            // Working variables
 11107  	            var a = H[0];
 11108  	            var b = H[1];
 11109  	            var c = H[2];
 11110  	            var d = H[3];
 11111  	            var e = H[4];
 11112  
 11113  	            // Computation
 11114  	            for (var i = 0; i < 80; i++) {
 11115  	                if (i < 16) {
 11116  	                    W[i] = M[offset + i] | 0;
 11117  	                } else {
 11118  	                    var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
 11119  	                    W[i] = (n << 1) | (n >>> 31);
 11120  	                }
 11121  
 11122  	                var t = ((a << 5) | (a >>> 27)) + e + W[i];
 11123  	                if (i < 20) {
 11124  	                    t += ((b & c) | (~b & d)) + 0x5a827999;
 11125  	                } else if (i < 40) {
 11126  	                    t += (b ^ c ^ d) + 0x6ed9eba1;
 11127  	                } else if (i < 60) {
 11128  	                    t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
 11129  	                } else /* if (i < 80) */ {
 11130  	                    t += (b ^ c ^ d) - 0x359d3e2a;
 11131  	                }
 11132  
 11133  	                e = d;
 11134  	                d = c;
 11135  	                c = (b << 30) | (b >>> 2);
 11136  	                b = a;
 11137  	                a = t;
 11138  	            }
 11139  
 11140  	            // Intermediate hash value
 11141  	            H[0] = (H[0] + a) | 0;
 11142  	            H[1] = (H[1] + b) | 0;
 11143  	            H[2] = (H[2] + c) | 0;
 11144  	            H[3] = (H[3] + d) | 0;
 11145  	            H[4] = (H[4] + e) | 0;
 11146  	        },
 11147  
 11148  	        _doFinalize: function () {
 11149  	            // Shortcuts
 11150  	            var data = this._data;
 11151  	            var dataWords = data.words;
 11152  
 11153  	            var nBitsTotal = this._nDataBytes * 8;
 11154  	            var nBitsLeft = data.sigBytes * 8;
 11155  
 11156  	            // Add padding
 11157  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11158  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11159  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11160  	            data.sigBytes = dataWords.length * 4;
 11161  
 11162  	            // Hash final blocks
 11163  	            this._process();
 11164  
 11165  	            // Return final computed hash
 11166  	            return this._hash;
 11167  	        },
 11168  
 11169  	        clone: function () {
 11170  	            var clone = Hasher.clone.call(this);
 11171  	            clone._hash = this._hash.clone();
 11172  
 11173  	            return clone;
 11174  	        }
 11175  	    });
 11176  
 11177  	    /**
 11178  	     * Shortcut function to the hasher's object interface.
 11179  	     *
 11180  	     * @param {WordArray|string} message The message to hash.
 11181  	     *
 11182  	     * @return {WordArray} The hash.
 11183  	     *
 11184  	     * @static
 11185  	     *
 11186  	     * @example
 11187  	     *
 11188  	     *     var hash = CryptoJS.SHA1('message');
 11189  	     *     var hash = CryptoJS.SHA1(wordArray);
 11190  	     */
 11191  	    C.SHA1 = Hasher._createHelper(SHA1);
 11192  
 11193  	    /**
 11194  	     * Shortcut function to the HMAC's object interface.
 11195  	     *
 11196  	     * @param {WordArray|string} message The message to hash.
 11197  	     * @param {WordArray|string} key The secret key.
 11198  	     *
 11199  	     * @return {WordArray} The HMAC.
 11200  	     *
 11201  	     * @static
 11202  	     *
 11203  	     * @example
 11204  	     *
 11205  	     *     var hmac = CryptoJS.HmacSHA1(message, key);
 11206  	     */
 11207  	    C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
 11208  	}());
 11209  
 11210  
 11211  	return CryptoJS.SHA1;
 11212  
 11213  }));
 11214  },{"./core":53}],78:[function(require,module,exports){
 11215  ;(function (root, factory, undef) {
 11216  	if (typeof exports === "object") {
 11217  		// CommonJS
 11218  		module.exports = exports = factory(require("./core"), require("./sha256"));
 11219  	}
 11220  	else if (typeof define === "function" && define.amd) {
 11221  		// AMD
 11222  		define(["./core", "./sha256"], factory);
 11223  	}
 11224  	else {
 11225  		// Global (browser)
 11226  		factory(root.CryptoJS);
 11227  	}
 11228  }(this, function (CryptoJS) {
 11229  
 11230  	(function () {
 11231  	    // Shortcuts
 11232  	    var C = CryptoJS;
 11233  	    var C_lib = C.lib;
 11234  	    var WordArray = C_lib.WordArray;
 11235  	    var C_algo = C.algo;
 11236  	    var SHA256 = C_algo.SHA256;
 11237  
 11238  	    /**
 11239  	     * SHA-224 hash algorithm.
 11240  	     */
 11241  	    var SHA224 = C_algo.SHA224 = SHA256.extend({
 11242  	        _doReset: function () {
 11243  	            this._hash = new WordArray.init([
 11244  	                0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
 11245  	                0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
 11246  	            ]);
 11247  	        },
 11248  
 11249  	        _doFinalize: function () {
 11250  	            var hash = SHA256._doFinalize.call(this);
 11251  
 11252  	            hash.sigBytes -= 4;
 11253  
 11254  	            return hash;
 11255  	        }
 11256  	    });
 11257  
 11258  	    /**
 11259  	     * Shortcut function to the hasher's object interface.
 11260  	     *
 11261  	     * @param {WordArray|string} message The message to hash.
 11262  	     *
 11263  	     * @return {WordArray} The hash.
 11264  	     *
 11265  	     * @static
 11266  	     *
 11267  	     * @example
 11268  	     *
 11269  	     *     var hash = CryptoJS.SHA224('message');
 11270  	     *     var hash = CryptoJS.SHA224(wordArray);
 11271  	     */
 11272  	    C.SHA224 = SHA256._createHelper(SHA224);
 11273  
 11274  	    /**
 11275  	     * Shortcut function to the HMAC's object interface.
 11276  	     *
 11277  	     * @param {WordArray|string} message The message to hash.
 11278  	     * @param {WordArray|string} key The secret key.
 11279  	     *
 11280  	     * @return {WordArray} The HMAC.
 11281  	     *
 11282  	     * @static
 11283  	     *
 11284  	     * @example
 11285  	     *
 11286  	     *     var hmac = CryptoJS.HmacSHA224(message, key);
 11287  	     */
 11288  	    C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
 11289  	}());
 11290  
 11291  
 11292  	return CryptoJS.SHA224;
 11293  
 11294  }));
 11295  },{"./core":53,"./sha256":79}],79:[function(require,module,exports){
 11296  ;(function (root, factory) {
 11297  	if (typeof exports === "object") {
 11298  		// CommonJS
 11299  		module.exports = exports = factory(require("./core"));
 11300  	}
 11301  	else if (typeof define === "function" && define.amd) {
 11302  		// AMD
 11303  		define(["./core"], factory);
 11304  	}
 11305  	else {
 11306  		// Global (browser)
 11307  		factory(root.CryptoJS);
 11308  	}
 11309  }(this, function (CryptoJS) {
 11310  
 11311  	(function (Math) {
 11312  	    // Shortcuts
 11313  	    var C = CryptoJS;
 11314  	    var C_lib = C.lib;
 11315  	    var WordArray = C_lib.WordArray;
 11316  	    var Hasher = C_lib.Hasher;
 11317  	    var C_algo = C.algo;
 11318  
 11319  	    // Initialization and round constants tables
 11320  	    var H = [];
 11321  	    var K = [];
 11322  
 11323  	    // Compute constants
 11324  	    (function () {
 11325  	        function isPrime(n) {
 11326  	            var sqrtN = Math.sqrt(n);
 11327  	            for (var factor = 2; factor <= sqrtN; factor++) {
 11328  	                if (!(n % factor)) {
 11329  	                    return false;
 11330  	                }
 11331  	            }
 11332  
 11333  	            return true;
 11334  	        }
 11335  
 11336  	        function getFractionalBits(n) {
 11337  	            return ((n - (n | 0)) * 0x100000000) | 0;
 11338  	        }
 11339  
 11340  	        var n = 2;
 11341  	        var nPrime = 0;
 11342  	        while (nPrime < 64) {
 11343  	            if (isPrime(n)) {
 11344  	                if (nPrime < 8) {
 11345  	                    H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
 11346  	                }
 11347  	                K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
 11348  
 11349  	                nPrime++;
 11350  	            }
 11351  
 11352  	            n++;
 11353  	        }
 11354  	    }());
 11355  
 11356  	    // Reusable object
 11357  	    var W = [];
 11358  
 11359  	    /**
 11360  	     * SHA-256 hash algorithm.
 11361  	     */
 11362  	    var SHA256 = C_algo.SHA256 = Hasher.extend({
 11363  	        _doReset: function () {
 11364  	            this._hash = new WordArray.init(H.slice(0));
 11365  	        },
 11366  
 11367  	        _doProcessBlock: function (M, offset) {
 11368  	            // Shortcut
 11369  	            var H = this._hash.words;
 11370  
 11371  	            // Working variables
 11372  	            var a = H[0];
 11373  	            var b = H[1];
 11374  	            var c = H[2];
 11375  	            var d = H[3];
 11376  	            var e = H[4];
 11377  	            var f = H[5];
 11378  	            var g = H[6];
 11379  	            var h = H[7];
 11380  
 11381  	            // Computation
 11382  	            for (var i = 0; i < 64; i++) {
 11383  	                if (i < 16) {
 11384  	                    W[i] = M[offset + i] | 0;
 11385  	                } else {
 11386  	                    var gamma0x = W[i - 15];
 11387  	                    var gamma0  = ((gamma0x << 25) | (gamma0x >>> 7))  ^
 11388  	                                  ((gamma0x << 14) | (gamma0x >>> 18)) ^
 11389  	                                   (gamma0x >>> 3);
 11390  
 11391  	                    var gamma1x = W[i - 2];
 11392  	                    var gamma1  = ((gamma1x << 15) | (gamma1x >>> 17)) ^
 11393  	                                  ((gamma1x << 13) | (gamma1x >>> 19)) ^
 11394  	                                   (gamma1x >>> 10);
 11395  
 11396  	                    W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
 11397  	                }
 11398  
 11399  	                var ch  = (e & f) ^ (~e & g);
 11400  	                var maj = (a & b) ^ (a & c) ^ (b & c);
 11401  
 11402  	                var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
 11403  	                var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7)  | (e >>> 25));
 11404  
 11405  	                var t1 = h + sigma1 + ch + K[i] + W[i];
 11406  	                var t2 = sigma0 + maj;
 11407  
 11408  	                h = g;
 11409  	                g = f;
 11410  	                f = e;
 11411  	                e = (d + t1) | 0;
 11412  	                d = c;
 11413  	                c = b;
 11414  	                b = a;
 11415  	                a = (t1 + t2) | 0;
 11416  	            }
 11417  
 11418  	            // Intermediate hash value
 11419  	            H[0] = (H[0] + a) | 0;
 11420  	            H[1] = (H[1] + b) | 0;
 11421  	            H[2] = (H[2] + c) | 0;
 11422  	            H[3] = (H[3] + d) | 0;
 11423  	            H[4] = (H[4] + e) | 0;
 11424  	            H[5] = (H[5] + f) | 0;
 11425  	            H[6] = (H[6] + g) | 0;
 11426  	            H[7] = (H[7] + h) | 0;
 11427  	        },
 11428  
 11429  	        _doFinalize: function () {
 11430  	            // Shortcuts
 11431  	            var data = this._data;
 11432  	            var dataWords = data.words;
 11433  
 11434  	            var nBitsTotal = this._nDataBytes * 8;
 11435  	            var nBitsLeft = data.sigBytes * 8;
 11436  
 11437  	            // Add padding
 11438  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11439  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11440  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11441  	            data.sigBytes = dataWords.length * 4;
 11442  
 11443  	            // Hash final blocks
 11444  	            this._process();
 11445  
 11446  	            // Return final computed hash
 11447  	            return this._hash;
 11448  	        },
 11449  
 11450  	        clone: function () {
 11451  	            var clone = Hasher.clone.call(this);
 11452  	            clone._hash = this._hash.clone();
 11453  
 11454  	            return clone;
 11455  	        }
 11456  	    });
 11457  
 11458  	    /**
 11459  	     * Shortcut function to the hasher's object interface.
 11460  	     *
 11461  	     * @param {WordArray|string} message The message to hash.
 11462  	     *
 11463  	     * @return {WordArray} The hash.
 11464  	     *
 11465  	     * @static
 11466  	     *
 11467  	     * @example
 11468  	     *
 11469  	     *     var hash = CryptoJS.SHA256('message');
 11470  	     *     var hash = CryptoJS.SHA256(wordArray);
 11471  	     */
 11472  	    C.SHA256 = Hasher._createHelper(SHA256);
 11473  
 11474  	    /**
 11475  	     * Shortcut function to the HMAC's object interface.
 11476  	     *
 11477  	     * @param {WordArray|string} message The message to hash.
 11478  	     * @param {WordArray|string} key The secret key.
 11479  	     *
 11480  	     * @return {WordArray} The HMAC.
 11481  	     *
 11482  	     * @static
 11483  	     *
 11484  	     * @example
 11485  	     *
 11486  	     *     var hmac = CryptoJS.HmacSHA256(message, key);
 11487  	     */
 11488  	    C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
 11489  	}(Math));
 11490  
 11491  
 11492  	return CryptoJS.SHA256;
 11493  
 11494  }));
 11495  },{"./core":53}],80:[function(require,module,exports){
 11496  ;(function (root, factory, undef) {
 11497  	if (typeof exports === "object") {
 11498  		// CommonJS
 11499  		module.exports = exports = factory(require("./core"), require("./x64-core"));
 11500  	}
 11501  	else if (typeof define === "function" && define.amd) {
 11502  		// AMD
 11503  		define(["./core", "./x64-core"], factory);
 11504  	}
 11505  	else {
 11506  		// Global (browser)
 11507  		factory(root.CryptoJS);
 11508  	}
 11509  }(this, function (CryptoJS) {
 11510  
 11511  	(function (Math) {
 11512  	    // Shortcuts
 11513  	    var C = CryptoJS;
 11514  	    var C_lib = C.lib;
 11515  	    var WordArray = C_lib.WordArray;
 11516  	    var Hasher = C_lib.Hasher;
 11517  	    var C_x64 = C.x64;
 11518  	    var X64Word = C_x64.Word;
 11519  	    var C_algo = C.algo;
 11520  
 11521  	    // Constants tables
 11522  	    var RHO_OFFSETS = [];
 11523  	    var PI_INDEXES  = [];
 11524  	    var ROUND_CONSTANTS = [];
 11525  
 11526  	    // Compute Constants
 11527  	    (function () {
 11528  	        // Compute rho offset constants
 11529  	        var x = 1, y = 0;
 11530  	        for (var t = 0; t < 24; t++) {
 11531  	            RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
 11532  
 11533  	            var newX = y % 5;
 11534  	            var newY = (2 * x + 3 * y) % 5;
 11535  	            x = newX;
 11536  	            y = newY;
 11537  	        }
 11538  
 11539  	        // Compute pi index constants
 11540  	        for (var x = 0; x < 5; x++) {
 11541  	            for (var y = 0; y < 5; y++) {
 11542  	                PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
 11543  	            }
 11544  	        }
 11545  
 11546  	        // Compute round constants
 11547  	        var LFSR = 0x01;
 11548  	        for (var i = 0; i < 24; i++) {
 11549  	            var roundConstantMsw = 0;
 11550  	            var roundConstantLsw = 0;
 11551  
 11552  	            for (var j = 0; j < 7; j++) {
 11553  	                if (LFSR & 0x01) {
 11554  	                    var bitPosition = (1 << j) - 1;
 11555  	                    if (bitPosition < 32) {
 11556  	                        roundConstantLsw ^= 1 << bitPosition;
 11557  	                    } else /* if (bitPosition >= 32) */ {
 11558  	                        roundConstantMsw ^= 1 << (bitPosition - 32);
 11559  	                    }
 11560  	                }
 11561  
 11562  	                // Compute next LFSR
 11563  	                if (LFSR & 0x80) {
 11564  	                    // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
 11565  	                    LFSR = (LFSR << 1) ^ 0x71;
 11566  	                } else {
 11567  	                    LFSR <<= 1;
 11568  	                }
 11569  	            }
 11570  
 11571  	            ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
 11572  	        }
 11573  	    }());
 11574  
 11575  	    // Reusable objects for temporary values
 11576  	    var T = [];
 11577  	    (function () {
 11578  	        for (var i = 0; i < 25; i++) {
 11579  	            T[i] = X64Word.create();
 11580  	        }
 11581  	    }());
 11582  
 11583  	    /**
 11584  	     * SHA-3 hash algorithm.
 11585  	     */
 11586  	    var SHA3 = C_algo.SHA3 = Hasher.extend({
 11587  	        /**
 11588  	         * Configuration options.
 11589  	         *
 11590  	         * @property {number} outputLength
 11591  	         *   The desired number of bits in the output hash.
 11592  	         *   Only values permitted are: 224, 256, 384, 512.
 11593  	         *   Default: 512
 11594  	         */
 11595  	        cfg: Hasher.cfg.extend({
 11596  	            outputLength: 512
 11597  	        }),
 11598  
 11599  	        _doReset: function () {
 11600  	            var state = this._state = []
 11601  	            for (var i = 0; i < 25; i++) {
 11602  	                state[i] = new X64Word.init();
 11603  	            }
 11604  
 11605  	            this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
 11606  	        },
 11607  
 11608  	        _doProcessBlock: function (M, offset) {
 11609  	            // Shortcuts
 11610  	            var state = this._state;
 11611  	            var nBlockSizeLanes = this.blockSize / 2;
 11612  
 11613  	            // Absorb
 11614  	            for (var i = 0; i < nBlockSizeLanes; i++) {
 11615  	                // Shortcuts
 11616  	                var M2i  = M[offset + 2 * i];
 11617  	                var M2i1 = M[offset + 2 * i + 1];
 11618  
 11619  	                // Swap endian
 11620  	                M2i = (
 11621  	                    (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |
 11622  	                    (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)
 11623  	                );
 11624  	                M2i1 = (
 11625  	                    (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |
 11626  	                    (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)
 11627  	                );
 11628  
 11629  	                // Absorb message into state
 11630  	                var lane = state[i];
 11631  	                lane.high ^= M2i1;
 11632  	                lane.low  ^= M2i;
 11633  	            }
 11634  
 11635  	            // Rounds
 11636  	            for (var round = 0; round < 24; round++) {
 11637  	                // Theta
 11638  	                for (var x = 0; x < 5; x++) {
 11639  	                    // Mix column lanes
 11640  	                    var tMsw = 0, tLsw = 0;
 11641  	                    for (var y = 0; y < 5; y++) {
 11642  	                        var lane = state[x + 5 * y];
 11643  	                        tMsw ^= lane.high;
 11644  	                        tLsw ^= lane.low;
 11645  	                    }
 11646  
 11647  	                    // Temporary values
 11648  	                    var Tx = T[x];
 11649  	                    Tx.high = tMsw;
 11650  	                    Tx.low  = tLsw;
 11651  	                }
 11652  	                for (var x = 0; x < 5; x++) {
 11653  	                    // Shortcuts
 11654  	                    var Tx4 = T[(x + 4) % 5];
 11655  	                    var Tx1 = T[(x + 1) % 5];
 11656  	                    var Tx1Msw = Tx1.high;
 11657  	                    var Tx1Lsw = Tx1.low;
 11658  
 11659  	                    // Mix surrounding columns
 11660  	                    var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
 11661  	                    var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
 11662  	                    for (var y = 0; y < 5; y++) {
 11663  	                        var lane = state[x + 5 * y];
 11664  	                        lane.high ^= tMsw;
 11665  	                        lane.low  ^= tLsw;
 11666  	                    }
 11667  	                }
 11668  
 11669  	                // Rho Pi
 11670  	                for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
 11671  	                    // Shortcuts
 11672  	                    var lane = state[laneIndex];
 11673  	                    var laneMsw = lane.high;
 11674  	                    var laneLsw = lane.low;
 11675  	                    var rhoOffset = RHO_OFFSETS[laneIndex];
 11676  
 11677  	                    // Rotate lanes
 11678  	                    if (rhoOffset < 32) {
 11679  	                        var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
 11680  	                        var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
 11681  	                    } else /* if (rhoOffset >= 32) */ {
 11682  	                        var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
 11683  	                        var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
 11684  	                    }
 11685  
 11686  	                    // Transpose lanes
 11687  	                    var TPiLane = T[PI_INDEXES[laneIndex]];
 11688  	                    TPiLane.high = tMsw;
 11689  	                    TPiLane.low  = tLsw;
 11690  	                }
 11691  
 11692  	                // Rho pi at x = y = 0
 11693  	                var T0 = T[0];
 11694  	                var state0 = state[0];
 11695  	                T0.high = state0.high;
 11696  	                T0.low  = state0.low;
 11697  
 11698  	                // Chi
 11699  	                for (var x = 0; x < 5; x++) {
 11700  	                    for (var y = 0; y < 5; y++) {
 11701  	                        // Shortcuts
 11702  	                        var laneIndex = x + 5 * y;
 11703  	                        var lane = state[laneIndex];
 11704  	                        var TLane = T[laneIndex];
 11705  	                        var Tx1Lane = T[((x + 1) % 5) + 5 * y];
 11706  	                        var Tx2Lane = T[((x + 2) % 5) + 5 * y];
 11707  
 11708  	                        // Mix rows
 11709  	                        lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
 11710  	                        lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);
 11711  	                    }
 11712  	                }
 11713  
 11714  	                // Iota
 11715  	                var lane = state[0];
 11716  	                var roundConstant = ROUND_CONSTANTS[round];
 11717  	                lane.high ^= roundConstant.high;
 11718  	                lane.low  ^= roundConstant.low;;
 11719  	            }
 11720  	        },
 11721  
 11722  	        _doFinalize: function () {
 11723  	            // Shortcuts
 11724  	            var data = this._data;
 11725  	            var dataWords = data.words;
 11726  	            var nBitsTotal = this._nDataBytes * 8;
 11727  	            var nBitsLeft = data.sigBytes * 8;
 11728  	            var blockSizeBits = this.blockSize * 32;
 11729  
 11730  	            // Add padding
 11731  	            dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
 11732  	            dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
 11733  	            data.sigBytes = dataWords.length * 4;
 11734  
 11735  	            // Hash final blocks
 11736  	            this._process();
 11737  
 11738  	            // Shortcuts
 11739  	            var state = this._state;
 11740  	            var outputLengthBytes = this.cfg.outputLength / 8;
 11741  	            var outputLengthLanes = outputLengthBytes / 8;
 11742  
 11743  	            // Squeeze
 11744  	            var hashWords = [];
 11745  	            for (var i = 0; i < outputLengthLanes; i++) {
 11746  	                // Shortcuts
 11747  	                var lane = state[i];
 11748  	                var laneMsw = lane.high;
 11749  	                var laneLsw = lane.low;
 11750  
 11751  	                // Swap endian
 11752  	                laneMsw = (
 11753  	                    (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |
 11754  	                    (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)
 11755  	                );
 11756  	                laneLsw = (
 11757  	                    (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |
 11758  	                    (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)
 11759  	                );
 11760  
 11761  	                // Squeeze state to retrieve hash
 11762  	                hashWords.push(laneLsw);
 11763  	                hashWords.push(laneMsw);
 11764  	            }
 11765  
 11766  	            // Return final computed hash
 11767  	            return new WordArray.init(hashWords, outputLengthBytes);
 11768  	        },
 11769  
 11770  	        clone: function () {
 11771  	            var clone = Hasher.clone.call(this);
 11772  
 11773  	            var state = clone._state = this._state.slice(0);
 11774  	            for (var i = 0; i < 25; i++) {
 11775  	                state[i] = state[i].clone();
 11776  	            }
 11777  
 11778  	            return clone;
 11779  	        }
 11780  	    });
 11781  
 11782  	    /**
 11783  	     * Shortcut function to the hasher's object interface.
 11784  	     *
 11785  	     * @param {WordArray|string} message The message to hash.
 11786  	     *
 11787  	     * @return {WordArray} The hash.
 11788  	     *
 11789  	     * @static
 11790  	     *
 11791  	     * @example
 11792  	     *
 11793  	     *     var hash = CryptoJS.SHA3('message');
 11794  	     *     var hash = CryptoJS.SHA3(wordArray);
 11795  	     */
 11796  	    C.SHA3 = Hasher._createHelper(SHA3);
 11797  
 11798  	    /**
 11799  	     * Shortcut function to the HMAC's object interface.
 11800  	     *
 11801  	     * @param {WordArray|string} message The message to hash.
 11802  	     * @param {WordArray|string} key The secret key.
 11803  	     *
 11804  	     * @return {WordArray} The HMAC.
 11805  	     *
 11806  	     * @static
 11807  	     *
 11808  	     * @example
 11809  	     *
 11810  	     *     var hmac = CryptoJS.HmacSHA3(message, key);
 11811  	     */
 11812  	    C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
 11813  	}(Math));
 11814  
 11815  
 11816  	return CryptoJS.SHA3;
 11817  
 11818  }));
 11819  },{"./core":53,"./x64-core":84}],81:[function(require,module,exports){
 11820  ;(function (root, factory, undef) {
 11821  	if (typeof exports === "object") {
 11822  		// CommonJS
 11823  		module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512"));
 11824  	}
 11825  	else if (typeof define === "function" && define.amd) {
 11826  		// AMD
 11827  		define(["./core", "./x64-core", "./sha512"], factory);
 11828  	}
 11829  	else {
 11830  		// Global (browser)
 11831  		factory(root.CryptoJS);
 11832  	}
 11833  }(this, function (CryptoJS) {
 11834  
 11835  	(function () {
 11836  	    // Shortcuts
 11837  	    var C = CryptoJS;
 11838  	    var C_x64 = C.x64;
 11839  	    var X64Word = C_x64.Word;
 11840  	    var X64WordArray = C_x64.WordArray;
 11841  	    var C_algo = C.algo;
 11842  	    var SHA512 = C_algo.SHA512;
 11843  
 11844  	    /**
 11845  	     * SHA-384 hash algorithm.
 11846  	     */
 11847  	    var SHA384 = C_algo.SHA384 = SHA512.extend({
 11848  	        _doReset: function () {
 11849  	            this._hash = new X64WordArray.init([
 11850  	                new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
 11851  	                new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
 11852  	                new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
 11853  	                new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
 11854  	            ]);
 11855  	        },
 11856  
 11857  	        _doFinalize: function () {
 11858  	            var hash = SHA512._doFinalize.call(this);
 11859  
 11860  	            hash.sigBytes -= 16;
 11861  
 11862  	            return hash;
 11863  	        }
 11864  	    });
 11865  
 11866  	    /**
 11867  	     * Shortcut function to the hasher's object interface.
 11868  	     *
 11869  	     * @param {WordArray|string} message The message to hash.
 11870  	     *
 11871  	     * @return {WordArray} The hash.
 11872  	     *
 11873  	     * @static
 11874  	     *
 11875  	     * @example
 11876  	     *
 11877  	     *     var hash = CryptoJS.SHA384('message');
 11878  	     *     var hash = CryptoJS.SHA384(wordArray);
 11879  	     */
 11880  	    C.SHA384 = SHA512._createHelper(SHA384);
 11881  
 11882  	    /**
 11883  	     * Shortcut function to the HMAC's object interface.
 11884  	     *
 11885  	     * @param {WordArray|string} message The message to hash.
 11886  	     * @param {WordArray|string} key The secret key.
 11887  	     *
 11888  	     * @return {WordArray} The HMAC.
 11889  	     *
 11890  	     * @static
 11891  	     *
 11892  	     * @example
 11893  	     *
 11894  	     *     var hmac = CryptoJS.HmacSHA384(message, key);
 11895  	     */
 11896  	    C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
 11897  	}());
 11898  
 11899  
 11900  	return CryptoJS.SHA384;
 11901  
 11902  }));
 11903  },{"./core":53,"./sha512":82,"./x64-core":84}],82:[function(require,module,exports){
 11904  ;(function (root, factory, undef) {
 11905  	if (typeof exports === "object") {
 11906  		// CommonJS
 11907  		module.exports = exports = factory(require("./core"), require("./x64-core"));
 11908  	}
 11909  	else if (typeof define === "function" && define.amd) {
 11910  		// AMD
 11911  		define(["./core", "./x64-core"], factory);
 11912  	}
 11913  	else {
 11914  		// Global (browser)
 11915  		factory(root.CryptoJS);
 11916  	}
 11917  }(this, function (CryptoJS) {
 11918  
 11919  	(function () {
 11920  	    // Shortcuts
 11921  	    var C = CryptoJS;
 11922  	    var C_lib = C.lib;
 11923  	    var Hasher = C_lib.Hasher;
 11924  	    var C_x64 = C.x64;
 11925  	    var X64Word = C_x64.Word;
 11926  	    var X64WordArray = C_x64.WordArray;
 11927  	    var C_algo = C.algo;
 11928  
 11929  	    function X64Word_create() {
 11930  	        return X64Word.create.apply(X64Word, arguments);
 11931  	    }
 11932  
 11933  	    // Constants
 11934  	    var K = [
 11935  	        X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
 11936  	        X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
 11937  	        X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
 11938  	        X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
 11939  	        X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
 11940  	        X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
 11941  	        X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
 11942  	        X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
 11943  	        X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
 11944  	        X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
 11945  	        X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
 11946  	        X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
 11947  	        X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
 11948  	        X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
 11949  	        X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
 11950  	        X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
 11951  	        X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
 11952  	        X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
 11953  	        X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
 11954  	        X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
 11955  	        X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
 11956  	        X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
 11957  	        X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
 11958  	        X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
 11959  	        X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
 11960  	        X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
 11961  	        X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
 11962  	        X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
 11963  	        X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
 11964  	        X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
 11965  	        X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
 11966  	        X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
 11967  	        X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
 11968  	        X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
 11969  	        X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
 11970  	        X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
 11971  	        X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
 11972  	        X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
 11973  	        X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
 11974  	        X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
 11975  	    ];
 11976  
 11977  	    // Reusable objects
 11978  	    var W = [];
 11979  	    (function () {
 11980  	        for (var i = 0; i < 80; i++) {
 11981  	            W[i] = X64Word_create();
 11982  	        }
 11983  	    }());
 11984  
 11985  	    /**
 11986  	     * SHA-512 hash algorithm.
 11987  	     */
 11988  	    var SHA512 = C_algo.SHA512 = Hasher.extend({
 11989  	        _doReset: function () {
 11990  	            this._hash = new X64WordArray.init([
 11991  	                new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
 11992  	                new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
 11993  	                new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
 11994  	                new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
 11995  	            ]);
 11996  	        },
 11997  
 11998  	        _doProcessBlock: function (M, offset) {
 11999  	            // Shortcuts
 12000  	            var H = this._hash.words;
 12001  
 12002  	            var H0 = H[0];
 12003  	            var H1 = H[1];
 12004  	            var H2 = H[2];
 12005  	            var H3 = H[3];
 12006  	            var H4 = H[4];
 12007  	            var H5 = H[5];
 12008  	            var H6 = H[6];
 12009  	            var H7 = H[7];
 12010  
 12011  	            var H0h = H0.high;
 12012  	            var H0l = H0.low;
 12013  	            var H1h = H1.high;
 12014  	            var H1l = H1.low;
 12015  	            var H2h = H2.high;
 12016  	            var H2l = H2.low;
 12017  	            var H3h = H3.high;
 12018  	            var H3l = H3.low;
 12019  	            var H4h = H4.high;
 12020  	            var H4l = H4.low;
 12021  	            var H5h = H5.high;
 12022  	            var H5l = H5.low;
 12023  	            var H6h = H6.high;
 12024  	            var H6l = H6.low;
 12025  	            var H7h = H7.high;
 12026  	            var H7l = H7.low;
 12027  
 12028  	            // Working variables
 12029  	            var ah = H0h;
 12030  	            var al = H0l;
 12031  	            var bh = H1h;
 12032  	            var bl = H1l;
 12033  	            var ch = H2h;
 12034  	            var cl = H2l;
 12035  	            var dh = H3h;
 12036  	            var dl = H3l;
 12037  	            var eh = H4h;
 12038  	            var el = H4l;
 12039  	            var fh = H5h;
 12040  	            var fl = H5l;
 12041  	            var gh = H6h;
 12042  	            var gl = H6l;
 12043  	            var hh = H7h;
 12044  	            var hl = H7l;
 12045  
 12046  	            // Rounds
 12047  	            for (var i = 0; i < 80; i++) {
 12048  	                // Shortcut
 12049  	                var Wi = W[i];
 12050  
 12051  	                // Extend message
 12052  	                if (i < 16) {
 12053  	                    var Wih = Wi.high = M[offset + i * 2]     | 0;
 12054  	                    var Wil = Wi.low  = M[offset + i * 2 + 1] | 0;
 12055  	                } else {
 12056  	                    // Gamma0
 12057  	                    var gamma0x  = W[i - 15];
 12058  	                    var gamma0xh = gamma0x.high;
 12059  	                    var gamma0xl = gamma0x.low;
 12060  	                    var gamma0h  = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
 12061  	                    var gamma0l  = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
 12062  
 12063  	                    // Gamma1
 12064  	                    var gamma1x  = W[i - 2];
 12065  	                    var gamma1xh = gamma1x.high;
 12066  	                    var gamma1xl = gamma1x.low;
 12067  	                    var gamma1h  = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
 12068  	                    var gamma1l  = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
 12069  
 12070  	                    // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
 12071  	                    var Wi7  = W[i - 7];
 12072  	                    var Wi7h = Wi7.high;
 12073  	                    var Wi7l = Wi7.low;
 12074  
 12075  	                    var Wi16  = W[i - 16];
 12076  	                    var Wi16h = Wi16.high;
 12077  	                    var Wi16l = Wi16.low;
 12078  
 12079  	                    var Wil = gamma0l + Wi7l;
 12080  	                    var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
 12081  	                    var Wil = Wil + gamma1l;
 12082  	                    var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
 12083  	                    var Wil = Wil + Wi16l;
 12084  	                    var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
 12085  
 12086  	                    Wi.high = Wih;
 12087  	                    Wi.low  = Wil;
 12088  	                }
 12089  
 12090  	                var chh  = (eh & fh) ^ (~eh & gh);
 12091  	                var chl  = (el & fl) ^ (~el & gl);
 12092  	                var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
 12093  	                var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
 12094  
 12095  	                var sigma0h = ((ah >>> 28) | (al << 4))  ^ ((ah << 30)  | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
 12096  	                var sigma0l = ((al >>> 28) | (ah << 4))  ^ ((al << 30)  | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
 12097  	                var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
 12098  	                var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
 12099  
 12100  	                // t1 = h + sigma1 + ch + K[i] + W[i]
 12101  	                var Ki  = K[i];
 12102  	                var Kih = Ki.high;
 12103  	                var Kil = Ki.low;
 12104  
 12105  	                var t1l = hl + sigma1l;
 12106  	                var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
 12107  	                var t1l = t1l + chl;
 12108  	                var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
 12109  	                var t1l = t1l + Kil;
 12110  	                var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
 12111  	                var t1l = t1l + Wil;
 12112  	                var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
 12113  
 12114  	                // t2 = sigma0 + maj
 12115  	                var t2l = sigma0l + majl;
 12116  	                var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
 12117  
 12118  	                // Update working variables
 12119  	                hh = gh;
 12120  	                hl = gl;
 12121  	                gh = fh;
 12122  	                gl = fl;
 12123  	                fh = eh;
 12124  	                fl = el;
 12125  	                el = (dl + t1l) | 0;
 12126  	                eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
 12127  	                dh = ch;
 12128  	                dl = cl;
 12129  	                ch = bh;
 12130  	                cl = bl;
 12131  	                bh = ah;
 12132  	                bl = al;
 12133  	                al = (t1l + t2l) | 0;
 12134  	                ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
 12135  	            }
 12136  
 12137  	            // Intermediate hash value
 12138  	            H0l = H0.low  = (H0l + al);
 12139  	            H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
 12140  	            H1l = H1.low  = (H1l + bl);
 12141  	            H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
 12142  	            H2l = H2.low  = (H2l + cl);
 12143  	            H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
 12144  	            H3l = H3.low  = (H3l + dl);
 12145  	            H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
 12146  	            H4l = H4.low  = (H4l + el);
 12147  	            H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
 12148  	            H5l = H5.low  = (H5l + fl);
 12149  	            H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
 12150  	            H6l = H6.low  = (H6l + gl);
 12151  	            H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
 12152  	            H7l = H7.low  = (H7l + hl);
 12153  	            H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
 12154  	        },
 12155  
 12156  	        _doFinalize: function () {
 12157  	            // Shortcuts
 12158  	            var data = this._data;
 12159  	            var dataWords = data.words;
 12160  
 12161  	            var nBitsTotal = this._nDataBytes * 8;
 12162  	            var nBitsLeft = data.sigBytes * 8;
 12163  
 12164  	            // Add padding
 12165  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 12166  	            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
 12167  	            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
 12168  	            data.sigBytes = dataWords.length * 4;
 12169  
 12170  	            // Hash final blocks
 12171  	            this._process();
 12172  
 12173  	            // Convert hash to 32-bit word array before returning
 12174  	            var hash = this._hash.toX32();
 12175  
 12176  	            // Return final computed hash
 12177  	            return hash;
 12178  	        },
 12179  
 12180  	        clone: function () {
 12181  	            var clone = Hasher.clone.call(this);
 12182  	            clone._hash = this._hash.clone();
 12183  
 12184  	            return clone;
 12185  	        },
 12186  
 12187  	        blockSize: 1024/32
 12188  	    });
 12189  
 12190  	    /**
 12191  	     * Shortcut function to the hasher's object interface.
 12192  	     *
 12193  	     * @param {WordArray|string} message The message to hash.
 12194  	     *
 12195  	     * @return {WordArray} The hash.
 12196  	     *
 12197  	     * @static
 12198  	     *
 12199  	     * @example
 12200  	     *
 12201  	     *     var hash = CryptoJS.SHA512('message');
 12202  	     *     var hash = CryptoJS.SHA512(wordArray);
 12203  	     */
 12204  	    C.SHA512 = Hasher._createHelper(SHA512);
 12205  
 12206  	    /**
 12207  	     * Shortcut function to the HMAC's object interface.
 12208  	     *
 12209  	     * @param {WordArray|string} message The message to hash.
 12210  	     * @param {WordArray|string} key The secret key.
 12211  	     *
 12212  	     * @return {WordArray} The HMAC.
 12213  	     *
 12214  	     * @static
 12215  	     *
 12216  	     * @example
 12217  	     *
 12218  	     *     var hmac = CryptoJS.HmacSHA512(message, key);
 12219  	     */
 12220  	    C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
 12221  	}());
 12222  
 12223  
 12224  	return CryptoJS.SHA512;
 12225  
 12226  }));
 12227  },{"./core":53,"./x64-core":84}],83:[function(require,module,exports){
 12228  ;(function (root, factory, undef) {
 12229  	if (typeof exports === "object") {
 12230  		// CommonJS
 12231  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 12232  	}
 12233  	else if (typeof define === "function" && define.amd) {
 12234  		// AMD
 12235  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 12236  	}
 12237  	else {
 12238  		// Global (browser)
 12239  		factory(root.CryptoJS);
 12240  	}
 12241  }(this, function (CryptoJS) {
 12242  
 12243  	(function () {
 12244  	    // Shortcuts
 12245  	    var C = CryptoJS;
 12246  	    var C_lib = C.lib;
 12247  	    var WordArray = C_lib.WordArray;
 12248  	    var BlockCipher = C_lib.BlockCipher;
 12249  	    var C_algo = C.algo;
 12250  
 12251  	    // Permuted Choice 1 constants
 12252  	    var PC1 = [
 12253  	        57, 49, 41, 33, 25, 17, 9,  1,
 12254  	        58, 50, 42, 34, 26, 18, 10, 2,
 12255  	        59, 51, 43, 35, 27, 19, 11, 3,
 12256  	        60, 52, 44, 36, 63, 55, 47, 39,
 12257  	        31, 23, 15, 7,  62, 54, 46, 38,
 12258  	        30, 22, 14, 6,  61, 53, 45, 37,
 12259  	        29, 21, 13, 5,  28, 20, 12, 4
 12260  	    ];
 12261  
 12262  	    // Permuted Choice 2 constants
 12263  	    var PC2 = [
 12264  	        14, 17, 11, 24, 1,  5,
 12265  	        3,  28, 15, 6,  21, 10,
 12266  	        23, 19, 12, 4,  26, 8,
 12267  	        16, 7,  27, 20, 13, 2,
 12268  	        41, 52, 31, 37, 47, 55,
 12269  	        30, 40, 51, 45, 33, 48,
 12270  	        44, 49, 39, 56, 34, 53,
 12271  	        46, 42, 50, 36, 29, 32
 12272  	    ];
 12273  
 12274  	    // Cumulative bit shift constants
 12275  	    var BIT_SHIFTS = [1,  2,  4,  6,  8,  10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
 12276  
 12277  	    // SBOXes and round permutation constants
 12278  	    var SBOX_P = [
 12279  	        {
 12280  	            0x0: 0x808200,
 12281  	            0x10000000: 0x8000,
 12282  	            0x20000000: 0x808002,
 12283  	            0x30000000: 0x2,
 12284  	            0x40000000: 0x200,
 12285  	            0x50000000: 0x808202,
 12286  	            0x60000000: 0x800202,
 12287  	            0x70000000: 0x800000,
 12288  	            0x80000000: 0x202,
 12289  	            0x90000000: 0x800200,
 12290  	            0xa0000000: 0x8200,
 12291  	            0xb0000000: 0x808000,
 12292  	            0xc0000000: 0x8002,
 12293  	            0xd0000000: 0x800002,
 12294  	            0xe0000000: 0x0,
 12295  	            0xf0000000: 0x8202,
 12296  	            0x8000000: 0x0,
 12297  	            0x18000000: 0x808202,
 12298  	            0x28000000: 0x8202,
 12299  	            0x38000000: 0x8000,
 12300  	            0x48000000: 0x808200,
 12301  	            0x58000000: 0x200,
 12302  	            0x68000000: 0x808002,
 12303  	            0x78000000: 0x2,
 12304  	            0x88000000: 0x800200,
 12305  	            0x98000000: 0x8200,
 12306  	            0xa8000000: 0x808000,
 12307  	            0xb8000000: 0x800202,
 12308  	            0xc8000000: 0x800002,
 12309  	            0xd8000000: 0x8002,
 12310  	            0xe8000000: 0x202,
 12311  	            0xf8000000: 0x800000,
 12312  	            0x1: 0x8000,
 12313  	            0x10000001: 0x2,
 12314  	            0x20000001: 0x808200,
 12315  	            0x30000001: 0x800000,
 12316  	            0x40000001: 0x808002,
 12317  	            0x50000001: 0x8200,
 12318  	            0x60000001: 0x200,
 12319  	            0x70000001: 0x800202,
 12320  	            0x80000001: 0x808202,
 12321  	            0x90000001: 0x808000,
 12322  	            0xa0000001: 0x800002,
 12323  	            0xb0000001: 0x8202,
 12324  	            0xc0000001: 0x202,
 12325  	            0xd0000001: 0x800200,
 12326  	            0xe0000001: 0x8002,
 12327  	            0xf0000001: 0x0,
 12328  	            0x8000001: 0x808202,
 12329  	            0x18000001: 0x808000,
 12330  	            0x28000001: 0x800000,
 12331  	            0x38000001: 0x200,
 12332  	            0x48000001: 0x8000,
 12333  	            0x58000001: 0x800002,
 12334  	            0x68000001: 0x2,
 12335  	            0x78000001: 0x8202,
 12336  	            0x88000001: 0x8002,
 12337  	            0x98000001: 0x800202,
 12338  	            0xa8000001: 0x202,
 12339  	            0xb8000001: 0x808200,
 12340  	            0xc8000001: 0x800200,
 12341  	            0xd8000001: 0x0,
 12342  	            0xe8000001: 0x8200,
 12343  	            0xf8000001: 0x808002
 12344  	        },
 12345  	        {
 12346  	            0x0: 0x40084010,
 12347  	            0x1000000: 0x4000,
 12348  	            0x2000000: 0x80000,
 12349  	            0x3000000: 0x40080010,
 12350  	            0x4000000: 0x40000010,
 12351  	            0x5000000: 0x40084000,
 12352  	            0x6000000: 0x40004000,
 12353  	            0x7000000: 0x10,
 12354  	            0x8000000: 0x84000,
 12355  	            0x9000000: 0x40004010,
 12356  	            0xa000000: 0x40000000,
 12357  	            0xb000000: 0x84010,
 12358  	            0xc000000: 0x80010,
 12359  	            0xd000000: 0x0,
 12360  	            0xe000000: 0x4010,
 12361  	            0xf000000: 0x40080000,
 12362  	            0x800000: 0x40004000,
 12363  	            0x1800000: 0x84010,
 12364  	            0x2800000: 0x10,
 12365  	            0x3800000: 0x40004010,
 12366  	            0x4800000: 0x40084010,
 12367  	            0x5800000: 0x40000000,
 12368  	            0x6800000: 0x80000,
 12369  	            0x7800000: 0x40080010,
 12370  	            0x8800000: 0x80010,
 12371  	            0x9800000: 0x0,
 12372  	            0xa800000: 0x4000,
 12373  	            0xb800000: 0x40080000,
 12374  	            0xc800000: 0x40000010,
 12375  	            0xd800000: 0x84000,
 12376  	            0xe800000: 0x40084000,
 12377  	            0xf800000: 0x4010,
 12378  	            0x10000000: 0x0,
 12379  	            0x11000000: 0x40080010,
 12380  	            0x12000000: 0x40004010,
 12381  	            0x13000000: 0x40084000,
 12382  	            0x14000000: 0x40080000,
 12383  	            0x15000000: 0x10,
 12384  	            0x16000000: 0x84010,
 12385  	            0x17000000: 0x4000,
 12386  	            0x18000000: 0x4010,
 12387  	            0x19000000: 0x80000,
 12388  	            0x1a000000: 0x80010,
 12389  	            0x1b000000: 0x40000010,
 12390  	            0x1c000000: 0x84000,
 12391  	            0x1d000000: 0x40004000,
 12392  	            0x1e000000: 0x40000000,
 12393  	            0x1f000000: 0x40084010,
 12394  	            0x10800000: 0x84010,
 12395  	            0x11800000: 0x80000,
 12396  	            0x12800000: 0x40080000,
 12397  	            0x13800000: 0x4000,
 12398  	            0x14800000: 0x40004000,
 12399  	            0x15800000: 0x40084010,
 12400  	            0x16800000: 0x10,
 12401  	            0x17800000: 0x40000000,
 12402  	            0x18800000: 0x40084000,
 12403  	            0x19800000: 0x40000010,
 12404  	            0x1a800000: 0x40004010,
 12405  	            0x1b800000: 0x80010,
 12406  	            0x1c800000: 0x0,
 12407  	            0x1d800000: 0x4010,
 12408  	            0x1e800000: 0x40080010,
 12409  	            0x1f800000: 0x84000
 12410  	        },
 12411  	        {
 12412  	            0x0: 0x104,
 12413  	            0x100000: 0x0,
 12414  	            0x200000: 0x4000100,
 12415  	            0x300000: 0x10104,
 12416  	            0x400000: 0x10004,
 12417  	            0x500000: 0x4000004,
 12418  	            0x600000: 0x4010104,
 12419  	            0x700000: 0x4010000,
 12420  	            0x800000: 0x4000000,
 12421  	            0x900000: 0x4010100,
 12422  	            0xa00000: 0x10100,
 12423  	            0xb00000: 0x4010004,
 12424  	            0xc00000: 0x4000104,
 12425  	            0xd00000: 0x10000,
 12426  	            0xe00000: 0x4,
 12427  	            0xf00000: 0x100,
 12428  	            0x80000: 0x4010100,
 12429  	            0x180000: 0x4010004,
 12430  	            0x280000: 0x0,
 12431  	            0x380000: 0x4000100,
 12432  	            0x480000: 0x4000004,
 12433  	            0x580000: 0x10000,
 12434  	            0x680000: 0x10004,
 12435  	            0x780000: 0x104,
 12436  	            0x880000: 0x4,
 12437  	            0x980000: 0x100,
 12438  	            0xa80000: 0x4010000,
 12439  	            0xb80000: 0x10104,
 12440  	            0xc80000: 0x10100,
 12441  	            0xd80000: 0x4000104,
 12442  	            0xe80000: 0x4010104,
 12443  	            0xf80000: 0x4000000,
 12444  	            0x1000000: 0x4010100,
 12445  	            0x1100000: 0x10004,
 12446  	            0x1200000: 0x10000,
 12447  	            0x1300000: 0x4000100,
 12448  	            0x1400000: 0x100,
 12449  	            0x1500000: 0x4010104,
 12450  	            0x1600000: 0x4000004,
 12451  	            0x1700000: 0x0,
 12452  	            0x1800000: 0x4000104,
 12453  	            0x1900000: 0x4000000,
 12454  	            0x1a00000: 0x4,
 12455  	            0x1b00000: 0x10100,
 12456  	            0x1c00000: 0x4010000,
 12457  	            0x1d00000: 0x104,
 12458  	            0x1e00000: 0x10104,
 12459  	            0x1f00000: 0x4010004,
 12460  	            0x1080000: 0x4000000,
 12461  	            0x1180000: 0x104,
 12462  	            0x1280000: 0x4010100,
 12463  	            0x1380000: 0x0,
 12464  	            0x1480000: 0x10004,
 12465  	            0x1580000: 0x4000100,
 12466  	            0x1680000: 0x100,
 12467  	            0x1780000: 0x4010004,
 12468  	            0x1880000: 0x10000,
 12469  	            0x1980000: 0x4010104,
 12470  	            0x1a80000: 0x10104,
 12471  	            0x1b80000: 0x4000004,
 12472  	            0x1c80000: 0x4000104,
 12473  	            0x1d80000: 0x4010000,
 12474  	            0x1e80000: 0x4,
 12475  	            0x1f80000: 0x10100
 12476  	        },
 12477  	        {
 12478  	            0x0: 0x80401000,
 12479  	            0x10000: 0x80001040,
 12480  	            0x20000: 0x401040,
 12481  	            0x30000: 0x80400000,
 12482  	            0x40000: 0x0,
 12483  	            0x50000: 0x401000,
 12484  	            0x60000: 0x80000040,
 12485  	            0x70000: 0x400040,
 12486  	            0x80000: 0x80000000,
 12487  	            0x90000: 0x400000,
 12488  	            0xa0000: 0x40,
 12489  	            0xb0000: 0x80001000,
 12490  	            0xc0000: 0x80400040,
 12491  	            0xd0000: 0x1040,
 12492  	            0xe0000: 0x1000,
 12493  	            0xf0000: 0x80401040,
 12494  	            0x8000: 0x80001040,
 12495  	            0x18000: 0x40,
 12496  	            0x28000: 0x80400040,
 12497  	            0x38000: 0x80001000,
 12498  	            0x48000: 0x401000,
 12499  	            0x58000: 0x80401040,
 12500  	            0x68000: 0x0,
 12501  	            0x78000: 0x80400000,
 12502  	            0x88000: 0x1000,
 12503  	            0x98000: 0x80401000,
 12504  	            0xa8000: 0x400000,
 12505  	            0xb8000: 0x1040,
 12506  	            0xc8000: 0x80000000,
 12507  	            0xd8000: 0x400040,
 12508  	            0xe8000: 0x401040,
 12509  	            0xf8000: 0x80000040,
 12510  	            0x100000: 0x400040,
 12511  	            0x110000: 0x401000,
 12512  	            0x120000: 0x80000040,
 12513  	            0x130000: 0x0,
 12514  	            0x140000: 0x1040,
 12515  	            0x150000: 0x80400040,
 12516  	            0x160000: 0x80401000,
 12517  	            0x170000: 0x80001040,
 12518  	            0x180000: 0x80401040,
 12519  	            0x190000: 0x80000000,
 12520  	            0x1a0000: 0x80400000,
 12521  	            0x1b0000: 0x401040,
 12522  	            0x1c0000: 0x80001000,
 12523  	            0x1d0000: 0x400000,
 12524  	            0x1e0000: 0x40,
 12525  	            0x1f0000: 0x1000,
 12526  	            0x108000: 0x80400000,
 12527  	            0x118000: 0x80401040,
 12528  	            0x128000: 0x0,
 12529  	            0x138000: 0x401000,
 12530  	            0x148000: 0x400040,
 12531  	            0x158000: 0x80000000,
 12532  	            0x168000: 0x80001040,
 12533  	            0x178000: 0x40,
 12534  	            0x188000: 0x80000040,
 12535  	            0x198000: 0x1000,
 12536  	            0x1a8000: 0x80001000,
 12537  	            0x1b8000: 0x80400040,
 12538  	            0x1c8000: 0x1040,
 12539  	            0x1d8000: 0x80401000,
 12540  	            0x1e8000: 0x400000,
 12541  	            0x1f8000: 0x401040
 12542  	        },
 12543  	        {
 12544  	            0x0: 0x80,
 12545  	            0x1000: 0x1040000,
 12546  	            0x2000: 0x40000,
 12547  	            0x3000: 0x20000000,
 12548  	            0x4000: 0x20040080,
 12549  	            0x5000: 0x1000080,
 12550  	            0x6000: 0x21000080,
 12551  	            0x7000: 0x40080,
 12552  	            0x8000: 0x1000000,
 12553  	            0x9000: 0x20040000,
 12554  	            0xa000: 0x20000080,
 12555  	            0xb000: 0x21040080,
 12556  	            0xc000: 0x21040000,
 12557  	            0xd000: 0x0,
 12558  	            0xe000: 0x1040080,
 12559  	            0xf000: 0x21000000,
 12560  	            0x800: 0x1040080,
 12561  	            0x1800: 0x21000080,
 12562  	            0x2800: 0x80,
 12563  	            0x3800: 0x1040000,
 12564  	            0x4800: 0x40000,
 12565  	            0x5800: 0x20040080,
 12566  	            0x6800: 0x21040000,
 12567  	            0x7800: 0x20000000,
 12568  	            0x8800: 0x20040000,
 12569  	            0x9800: 0x0,
 12570  	            0xa800: 0x21040080,
 12571  	            0xb800: 0x1000080,
 12572  	            0xc800: 0x20000080,
 12573  	            0xd800: 0x21000000,
 12574  	            0xe800: 0x1000000,
 12575  	            0xf800: 0x40080,
 12576  	            0x10000: 0x40000,
 12577  	            0x11000: 0x80,
 12578  	            0x12000: 0x20000000,
 12579  	            0x13000: 0x21000080,
 12580  	            0x14000: 0x1000080,
 12581  	            0x15000: 0x21040000,
 12582  	            0x16000: 0x20040080,
 12583  	            0x17000: 0x1000000,
 12584  	            0x18000: 0x21040080,
 12585  	            0x19000: 0x21000000,
 12586  	            0x1a000: 0x1040000,
 12587  	            0x1b000: 0x20040000,
 12588  	            0x1c000: 0x40080,
 12589  	            0x1d000: 0x20000080,
 12590  	            0x1e000: 0x0,
 12591  	            0x1f000: 0x1040080,
 12592  	            0x10800: 0x21000080,
 12593  	            0x11800: 0x1000000,
 12594  	            0x12800: 0x1040000,
 12595  	            0x13800: 0x20040080,
 12596  	            0x14800: 0x20000000,
 12597  	            0x15800: 0x1040080,
 12598  	            0x16800: 0x80,
 12599  	            0x17800: 0x21040000,
 12600  	            0x18800: 0x40080,
 12601  	            0x19800: 0x21040080,
 12602  	            0x1a800: 0x0,
 12603  	            0x1b800: 0x21000000,
 12604  	            0x1c800: 0x1000080,
 12605  	            0x1d800: 0x40000,
 12606  	            0x1e800: 0x20040000,
 12607  	            0x1f800: 0x20000080
 12608  	        },
 12609  	        {
 12610  	            0x0: 0x10000008,
 12611  	            0x100: 0x2000,
 12612  	            0x200: 0x10200000,
 12613  	            0x300: 0x10202008,
 12614  	            0x400: 0x10002000,
 12615  	            0x500: 0x200000,
 12616  	            0x600: 0x200008,
 12617  	            0x700: 0x10000000,
 12618  	            0x800: 0x0,
 12619  	            0x900: 0x10002008,
 12620  	            0xa00: 0x202000,
 12621  	            0xb00: 0x8,
 12622  	            0xc00: 0x10200008,
 12623  	            0xd00: 0x202008,
 12624  	            0xe00: 0x2008,
 12625  	            0xf00: 0x10202000,
 12626  	            0x80: 0x10200000,
 12627  	            0x180: 0x10202008,
 12628  	            0x280: 0x8,
 12629  	            0x380: 0x200000,
 12630  	            0x480: 0x202008,
 12631  	            0x580: 0x10000008,
 12632  	            0x680: 0x10002000,
 12633  	            0x780: 0x2008,
 12634  	            0x880: 0x200008,
 12635  	            0x980: 0x2000,
 12636  	            0xa80: 0x10002008,
 12637  	            0xb80: 0x10200008,
 12638  	            0xc80: 0x0,
 12639  	            0xd80: 0x10202000,
 12640  	            0xe80: 0x202000,
 12641  	            0xf80: 0x10000000,
 12642  	            0x1000: 0x10002000,
 12643  	            0x1100: 0x10200008,
 12644  	            0x1200: 0x10202008,
 12645  	            0x1300: 0x2008,
 12646  	            0x1400: 0x200000,
 12647  	            0x1500: 0x10000000,
 12648  	            0x1600: 0x10000008,
 12649  	            0x1700: 0x202000,
 12650  	            0x1800: 0x202008,
 12651  	            0x1900: 0x0,
 12652  	            0x1a00: 0x8,
 12653  	            0x1b00: 0x10200000,
 12654  	            0x1c00: 0x2000,
 12655  	            0x1d00: 0x10002008,
 12656  	            0x1e00: 0x10202000,
 12657  	            0x1f00: 0x200008,
 12658  	            0x1080: 0x8,
 12659  	            0x1180: 0x202000,
 12660  	            0x1280: 0x200000,
 12661  	            0x1380: 0x10000008,
 12662  	            0x1480: 0x10002000,
 12663  	            0x1580: 0x2008,
 12664  	            0x1680: 0x10202008,
 12665  	            0x1780: 0x10200000,
 12666  	            0x1880: 0x10202000,
 12667  	            0x1980: 0x10200008,
 12668  	            0x1a80: 0x2000,
 12669  	            0x1b80: 0x202008,
 12670  	            0x1c80: 0x200008,
 12671  	            0x1d80: 0x0,
 12672  	            0x1e80: 0x10000000,
 12673  	            0x1f80: 0x10002008
 12674  	        },
 12675  	        {
 12676  	            0x0: 0x100000,
 12677  	            0x10: 0x2000401,
 12678  	            0x20: 0x400,
 12679  	            0x30: 0x100401,
 12680  	            0x40: 0x2100401,
 12681  	            0x50: 0x0,
 12682  	            0x60: 0x1,
 12683  	            0x70: 0x2100001,
 12684  	            0x80: 0x2000400,
 12685  	            0x90: 0x100001,
 12686  	            0xa0: 0x2000001,
 12687  	            0xb0: 0x2100400,
 12688  	            0xc0: 0x2100000,
 12689  	            0xd0: 0x401,
 12690  	            0xe0: 0x100400,
 12691  	            0xf0: 0x2000000,
 12692  	            0x8: 0x2100001,
 12693  	            0x18: 0x0,
 12694  	            0x28: 0x2000401,
 12695  	            0x38: 0x2100400,
 12696  	            0x48: 0x100000,
 12697  	            0x58: 0x2000001,
 12698  	            0x68: 0x2000000,
 12699  	            0x78: 0x401,
 12700  	            0x88: 0x100401,
 12701  	            0x98: 0x2000400,
 12702  	            0xa8: 0x2100000,
 12703  	            0xb8: 0x100001,
 12704  	            0xc8: 0x400,
 12705  	            0xd8: 0x2100401,
 12706  	            0xe8: 0x1,
 12707  	            0xf8: 0x100400,
 12708  	            0x100: 0x2000000,
 12709  	            0x110: 0x100000,
 12710  	            0x120: 0x2000401,
 12711  	            0x130: 0x2100001,
 12712  	            0x140: 0x100001,
 12713  	            0x150: 0x2000400,
 12714  	            0x160: 0x2100400,
 12715  	            0x170: 0x100401,
 12716  	            0x180: 0x401,
 12717  	            0x190: 0x2100401,
 12718  	            0x1a0: 0x100400,
 12719  	            0x1b0: 0x1,
 12720  	            0x1c0: 0x0,
 12721  	            0x1d0: 0x2100000,
 12722  	            0x1e0: 0x2000001,
 12723  	            0x1f0: 0x400,
 12724  	            0x108: 0x100400,
 12725  	            0x118: 0x2000401,
 12726  	            0x128: 0x2100001,
 12727  	            0x138: 0x1,
 12728  	            0x148: 0x2000000,
 12729  	            0x158: 0x100000,
 12730  	            0x168: 0x401,
 12731  	            0x178: 0x2100400,
 12732  	            0x188: 0x2000001,
 12733  	            0x198: 0x2100000,
 12734  	            0x1a8: 0x0,
 12735  	            0x1b8: 0x2100401,
 12736  	            0x1c8: 0x100401,
 12737  	            0x1d8: 0x400,
 12738  	            0x1e8: 0x2000400,
 12739  	            0x1f8: 0x100001
 12740  	        },
 12741  	        {
 12742  	            0x0: 0x8000820,
 12743  	            0x1: 0x20000,
 12744  	            0x2: 0x8000000,
 12745  	            0x3: 0x20,
 12746  	            0x4: 0x20020,
 12747  	            0x5: 0x8020820,
 12748  	            0x6: 0x8020800,
 12749  	            0x7: 0x800,
 12750  	            0x8: 0x8020000,
 12751  	            0x9: 0x8000800,
 12752  	            0xa: 0x20800,
 12753  	            0xb: 0x8020020,
 12754  	            0xc: 0x820,
 12755  	            0xd: 0x0,
 12756  	            0xe: 0x8000020,
 12757  	            0xf: 0x20820,
 12758  	            0x80000000: 0x800,
 12759  	            0x80000001: 0x8020820,
 12760  	            0x80000002: 0x8000820,
 12761  	            0x80000003: 0x8000000,
 12762  	            0x80000004: 0x8020000,
 12763  	            0x80000005: 0x20800,
 12764  	            0x80000006: 0x20820,
 12765  	            0x80000007: 0x20,
 12766  	            0x80000008: 0x8000020,
 12767  	            0x80000009: 0x820,
 12768  	            0x8000000a: 0x20020,
 12769  	            0x8000000b: 0x8020800,
 12770  	            0x8000000c: 0x0,
 12771  	            0x8000000d: 0x8020020,
 12772  	            0x8000000e: 0x8000800,
 12773  	            0x8000000f: 0x20000,
 12774  	            0x10: 0x20820,
 12775  	            0x11: 0x8020800,
 12776  	            0x12: 0x20,
 12777  	            0x13: 0x800,
 12778  	            0x14: 0x8000800,
 12779  	            0x15: 0x8000020,
 12780  	            0x16: 0x8020020,
 12781  	            0x17: 0x20000,
 12782  	            0x18: 0x0,
 12783  	            0x19: 0x20020,
 12784  	            0x1a: 0x8020000,
 12785  	            0x1b: 0x8000820,
 12786  	            0x1c: 0x8020820,
 12787  	            0x1d: 0x20800,
 12788  	            0x1e: 0x820,
 12789  	            0x1f: 0x8000000,
 12790  	            0x80000010: 0x20000,
 12791  	            0x80000011: 0x800,
 12792  	            0x80000012: 0x8020020,
 12793  	            0x80000013: 0x20820,
 12794  	            0x80000014: 0x20,
 12795  	            0x80000015: 0x8020000,
 12796  	            0x80000016: 0x8000000,
 12797  	            0x80000017: 0x8000820,
 12798  	            0x80000018: 0x8020820,
 12799  	            0x80000019: 0x8000020,
 12800  	            0x8000001a: 0x8000800,
 12801  	            0x8000001b: 0x0,
 12802  	            0x8000001c: 0x20800,
 12803  	            0x8000001d: 0x820,
 12804  	            0x8000001e: 0x20020,
 12805  	            0x8000001f: 0x8020800
 12806  	        }
 12807  	    ];
 12808  
 12809  	    // Masks that select the SBOX input
 12810  	    var SBOX_MASK = [
 12811  	        0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
 12812  	        0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
 12813  	    ];
 12814  
 12815  	    /**
 12816  	     * DES block cipher algorithm.
 12817  	     */
 12818  	    var DES = C_algo.DES = BlockCipher.extend({
 12819  	        _doReset: function () {
 12820  	            // Shortcuts
 12821  	            var key = this._key;
 12822  	            var keyWords = key.words;
 12823  
 12824  	            // Select 56 bits according to PC1
 12825  	            var keyBits = [];
 12826  	            for (var i = 0; i < 56; i++) {
 12827  	                var keyBitPos = PC1[i] - 1;
 12828  	                keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
 12829  	            }
 12830  
 12831  	            // Assemble 16 subkeys
 12832  	            var subKeys = this._subKeys = [];
 12833  	            for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
 12834  	                // Create subkey
 12835  	                var subKey = subKeys[nSubKey] = [];
 12836  
 12837  	                // Shortcut
 12838  	                var bitShift = BIT_SHIFTS[nSubKey];
 12839  
 12840  	                // Select 48 bits according to PC2
 12841  	                for (var i = 0; i < 24; i++) {
 12842  	                    // Select from the left 28 key bits
 12843  	                    subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
 12844  
 12845  	                    // Select from the right 28 key bits
 12846  	                    subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
 12847  	                }
 12848  
 12849  	                // Since each subkey is applied to an expanded 32-bit input,
 12850  	                // the subkey can be broken into 8 values scaled to 32-bits,
 12851  	                // which allows the key to be used without expansion
 12852  	                subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
 12853  	                for (var i = 1; i < 7; i++) {
 12854  	                    subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
 12855  	                }
 12856  	                subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
 12857  	            }
 12858  
 12859  	            // Compute inverse subkeys
 12860  	            var invSubKeys = this._invSubKeys = [];
 12861  	            for (var i = 0; i < 16; i++) {
 12862  	                invSubKeys[i] = subKeys[15 - i];
 12863  	            }
 12864  	        },
 12865  
 12866  	        encryptBlock: function (M, offset) {
 12867  	            this._doCryptBlock(M, offset, this._subKeys);
 12868  	        },
 12869  
 12870  	        decryptBlock: function (M, offset) {
 12871  	            this._doCryptBlock(M, offset, this._invSubKeys);
 12872  	        },
 12873  
 12874  	        _doCryptBlock: function (M, offset, subKeys) {
 12875  	            // Get input
 12876  	            this._lBlock = M[offset];
 12877  	            this._rBlock = M[offset + 1];
 12878  
 12879  	            // Initial permutation
 12880  	            exchangeLR.call(this, 4,  0x0f0f0f0f);
 12881  	            exchangeLR.call(this, 16, 0x0000ffff);
 12882  	            exchangeRL.call(this, 2,  0x33333333);
 12883  	            exchangeRL.call(this, 8,  0x00ff00ff);
 12884  	            exchangeLR.call(this, 1,  0x55555555);
 12885  
 12886  	            // Rounds
 12887  	            for (var round = 0; round < 16; round++) {
 12888  	                // Shortcuts
 12889  	                var subKey = subKeys[round];
 12890  	                var lBlock = this._lBlock;
 12891  	                var rBlock = this._rBlock;
 12892  
 12893  	                // Feistel function
 12894  	                var f = 0;
 12895  	                for (var i = 0; i < 8; i++) {
 12896  	                    f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
 12897  	                }
 12898  	                this._lBlock = rBlock;
 12899  	                this._rBlock = lBlock ^ f;
 12900  	            }
 12901  
 12902  	            // Undo swap from last round
 12903  	            var t = this._lBlock;
 12904  	            this._lBlock = this._rBlock;
 12905  	            this._rBlock = t;
 12906  
 12907  	            // Final permutation
 12908  	            exchangeLR.call(this, 1,  0x55555555);
 12909  	            exchangeRL.call(this, 8,  0x00ff00ff);
 12910  	            exchangeRL.call(this, 2,  0x33333333);
 12911  	            exchangeLR.call(this, 16, 0x0000ffff);
 12912  	            exchangeLR.call(this, 4,  0x0f0f0f0f);
 12913  
 12914  	            // Set output
 12915  	            M[offset] = this._lBlock;
 12916  	            M[offset + 1] = this._rBlock;
 12917  	        },
 12918  
 12919  	        keySize: 64/32,
 12920  
 12921  	        ivSize: 64/32,
 12922  
 12923  	        blockSize: 64/32
 12924  	    });
 12925  
 12926  	    // Swap bits across the left and right words
 12927  	    function exchangeLR(offset, mask) {
 12928  	        var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
 12929  	        this._rBlock ^= t;
 12930  	        this._lBlock ^= t << offset;
 12931  	    }
 12932  
 12933  	    function exchangeRL(offset, mask) {
 12934  	        var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
 12935  	        this._lBlock ^= t;
 12936  	        this._rBlock ^= t << offset;
 12937  	    }
 12938  
 12939  	    /**
 12940  	     * Shortcut functions to the cipher's object interface.
 12941  	     *
 12942  	     * @example
 12943  	     *
 12944  	     *     var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
 12945  	     *     var plaintext  = CryptoJS.DES.decrypt(ciphertext, key, cfg);
 12946  	     */
 12947  	    C.DES = BlockCipher._createHelper(DES);
 12948  
 12949  	    /**
 12950  	     * Triple-DES block cipher algorithm.
 12951  	     */
 12952  	    var TripleDES = C_algo.TripleDES = BlockCipher.extend({
 12953  	        _doReset: function () {
 12954  	            // Shortcuts
 12955  	            var key = this._key;
 12956  	            var keyWords = key.words;
 12957  
 12958  	            // Create DES instances
 12959  	            this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
 12960  	            this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
 12961  	            this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
 12962  	        },
 12963  
 12964  	        encryptBlock: function (M, offset) {
 12965  	            this._des1.encryptBlock(M, offset);
 12966  	            this._des2.decryptBlock(M, offset);
 12967  	            this._des3.encryptBlock(M, offset);
 12968  	        },
 12969  
 12970  	        decryptBlock: function (M, offset) {
 12971  	            this._des3.decryptBlock(M, offset);
 12972  	            this._des2.encryptBlock(M, offset);
 12973  	            this._des1.decryptBlock(M, offset);
 12974  	        },
 12975  
 12976  	        keySize: 192/32,
 12977  
 12978  	        ivSize: 64/32,
 12979  
 12980  	        blockSize: 64/32
 12981  	    });
 12982  
 12983  	    /**
 12984  	     * Shortcut functions to the cipher's object interface.
 12985  	     *
 12986  	     * @example
 12987  	     *
 12988  	     *     var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
 12989  	     *     var plaintext  = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
 12990  	     */
 12991  	    C.TripleDES = BlockCipher._createHelper(TripleDES);
 12992  	}());
 12993  
 12994  
 12995  	return CryptoJS.TripleDES;
 12996  
 12997  }));
 12998  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],84:[function(require,module,exports){
 12999  ;(function (root, factory) {
 13000  	if (typeof exports === "object") {
 13001  		// CommonJS
 13002  		module.exports = exports = factory(require("./core"));
 13003  	}
 13004  	else if (typeof define === "function" && define.amd) {
 13005  		// AMD
 13006  		define(["./core"], factory);
 13007  	}
 13008  	else {
 13009  		// Global (browser)
 13010  		factory(root.CryptoJS);
 13011  	}
 13012  }(this, function (CryptoJS) {
 13013  
 13014  	(function (undefined) {
 13015  	    // Shortcuts
 13016  	    var C = CryptoJS;
 13017  	    var C_lib = C.lib;
 13018  	    var Base = C_lib.Base;
 13019  	    var X32WordArray = C_lib.WordArray;
 13020  
 13021  	    /**
 13022  	     * x64 namespace.
 13023  	     */
 13024  	    var C_x64 = C.x64 = {};
 13025  
 13026  	    /**
 13027  	     * A 64-bit word.
 13028  	     */
 13029  	    var X64Word = C_x64.Word = Base.extend({
 13030  	        /**
 13031  	         * Initializes a newly created 64-bit word.
 13032  	         *
 13033  	         * @param {number} high The high 32 bits.
 13034  	         * @param {number} low The low 32 bits.
 13035  	         *
 13036  	         * @example
 13037  	         *
 13038  	         *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
 13039  	         */
 13040  	        init: function (high, low) {
 13041  	            this.high = high;
 13042  	            this.low = low;
 13043  	        }
 13044  
 13045  	        /**
 13046  	         * Bitwise NOTs this word.
 13047  	         *
 13048  	         * @return {X64Word} A new x64-Word object after negating.
 13049  	         *
 13050  	         * @example
 13051  	         *
 13052  	         *     var negated = x64Word.not();
 13053  	         */
 13054  	        // not: function () {
 13055  	            // var high = ~this.high;
 13056  	            // var low = ~this.low;
 13057  
 13058  	            // return X64Word.create(high, low);
 13059  	        // },
 13060  
 13061  	        /**
 13062  	         * Bitwise ANDs this word with the passed word.
 13063  	         *
 13064  	         * @param {X64Word} word The x64-Word to AND with this word.
 13065  	         *
 13066  	         * @return {X64Word} A new x64-Word object after ANDing.
 13067  	         *
 13068  	         * @example
 13069  	         *
 13070  	         *     var anded = x64Word.and(anotherX64Word);
 13071  	         */
 13072  	        // and: function (word) {
 13073  	            // var high = this.high & word.high;
 13074  	            // var low = this.low & word.low;
 13075  
 13076  	            // return X64Word.create(high, low);
 13077  	        // },
 13078  
 13079  	        /**
 13080  	         * Bitwise ORs this word with the passed word.
 13081  	         *
 13082  	         * @param {X64Word} word The x64-Word to OR with this word.
 13083  	         *
 13084  	         * @return {X64Word} A new x64-Word object after ORing.
 13085  	         *
 13086  	         * @example
 13087  	         *
 13088  	         *     var ored = x64Word.or(anotherX64Word);
 13089  	         */
 13090  	        // or: function (word) {
 13091  	            // var high = this.high | word.high;
 13092  	            // var low = this.low | word.low;
 13093  
 13094  	            // return X64Word.create(high, low);
 13095  	        // },
 13096  
 13097  	        /**
 13098  	         * Bitwise XORs this word with the passed word.
 13099  	         *
 13100  	         * @param {X64Word} word The x64-Word to XOR with this word.
 13101  	         *
 13102  	         * @return {X64Word} A new x64-Word object after XORing.
 13103  	         *
 13104  	         * @example
 13105  	         *
 13106  	         *     var xored = x64Word.xor(anotherX64Word);
 13107  	         */
 13108  	        // xor: function (word) {
 13109  	            // var high = this.high ^ word.high;
 13110  	            // var low = this.low ^ word.low;
 13111  
 13112  	            // return X64Word.create(high, low);
 13113  	        // },
 13114  
 13115  	        /**
 13116  	         * Shifts this word n bits to the left.
 13117  	         *
 13118  	         * @param {number} n The number of bits to shift.
 13119  	         *
 13120  	         * @return {X64Word} A new x64-Word object after shifting.
 13121  	         *
 13122  	         * @example
 13123  	         *
 13124  	         *     var shifted = x64Word.shiftL(25);
 13125  	         */
 13126  	        // shiftL: function (n) {
 13127  	            // if (n < 32) {
 13128  	                // var high = (this.high << n) | (this.low >>> (32 - n));
 13129  	                // var low = this.low << n;
 13130  	            // } else {
 13131  	                // var high = this.low << (n - 32);
 13132  	                // var low = 0;
 13133  	            // }
 13134  
 13135  	            // return X64Word.create(high, low);
 13136  	        // },
 13137  
 13138  	        /**
 13139  	         * Shifts this word n bits to the right.
 13140  	         *
 13141  	         * @param {number} n The number of bits to shift.
 13142  	         *
 13143  	         * @return {X64Word} A new x64-Word object after shifting.
 13144  	         *
 13145  	         * @example
 13146  	         *
 13147  	         *     var shifted = x64Word.shiftR(7);
 13148  	         */
 13149  	        // shiftR: function (n) {
 13150  	            // if (n < 32) {
 13151  	                // var low = (this.low >>> n) | (this.high << (32 - n));
 13152  	                // var high = this.high >>> n;
 13153  	            // } else {
 13154  	                // var low = this.high >>> (n - 32);
 13155  	                // var high = 0;
 13156  	            // }
 13157  
 13158  	            // return X64Word.create(high, low);
 13159  	        // },
 13160  
 13161  	        /**
 13162  	         * Rotates this word n bits to the left.
 13163  	         *
 13164  	         * @param {number} n The number of bits to rotate.
 13165  	         *
 13166  	         * @return {X64Word} A new x64-Word object after rotating.
 13167  	         *
 13168  	         * @example
 13169  	         *
 13170  	         *     var rotated = x64Word.rotL(25);
 13171  	         */
 13172  	        // rotL: function (n) {
 13173  	            // return this.shiftL(n).or(this.shiftR(64 - n));
 13174  	        // },
 13175  
 13176  	        /**
 13177  	         * Rotates this word n bits to the right.
 13178  	         *
 13179  	         * @param {number} n The number of bits to rotate.
 13180  	         *
 13181  	         * @return {X64Word} A new x64-Word object after rotating.
 13182  	         *
 13183  	         * @example
 13184  	         *
 13185  	         *     var rotated = x64Word.rotR(7);
 13186  	         */
 13187  	        // rotR: function (n) {
 13188  	            // return this.shiftR(n).or(this.shiftL(64 - n));
 13189  	        // },
 13190  
 13191  	        /**
 13192  	         * Adds this word with the passed word.
 13193  	         *
 13194  	         * @param {X64Word} word The x64-Word to add with this word.
 13195  	         *
 13196  	         * @return {X64Word} A new x64-Word object after adding.
 13197  	         *
 13198  	         * @example
 13199  	         *
 13200  	         *     var added = x64Word.add(anotherX64Word);
 13201  	         */
 13202  	        // add: function (word) {
 13203  	            // var low = (this.low + word.low) | 0;
 13204  	            // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
 13205  	            // var high = (this.high + word.high + carry) | 0;
 13206  
 13207  	            // return X64Word.create(high, low);
 13208  	        // }
 13209  	    });
 13210  
 13211  	    /**
 13212  	     * An array of 64-bit words.
 13213  	     *
 13214  	     * @property {Array} words The array of CryptoJS.x64.Word objects.
 13215  	     * @property {number} sigBytes The number of significant bytes in this word array.
 13216  	     */
 13217  	    var X64WordArray = C_x64.WordArray = Base.extend({
 13218  	        /**
 13219  	         * Initializes a newly created word array.
 13220  	         *
 13221  	         * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
 13222  	         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
 13223  	         *
 13224  	         * @example
 13225  	         *
 13226  	         *     var wordArray = CryptoJS.x64.WordArray.create();
 13227  	         *
 13228  	         *     var wordArray = CryptoJS.x64.WordArray.create([
 13229  	         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 13230  	         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 13231  	         *     ]);
 13232  	         *
 13233  	         *     var wordArray = CryptoJS.x64.WordArray.create([
 13234  	         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 13235  	         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 13236  	         *     ], 10);
 13237  	         */
 13238  	        init: function (words, sigBytes) {
 13239  	            words = this.words = words || [];
 13240  
 13241  	            if (sigBytes != undefined) {
 13242  	                this.sigBytes = sigBytes;
 13243  	            } else {
 13244  	                this.sigBytes = words.length * 8;
 13245  	            }
 13246  	        },
 13247  
 13248  	        /**
 13249  	         * Converts this 64-bit word array to a 32-bit word array.
 13250  	         *
 13251  	         * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
 13252  	         *
 13253  	         * @example
 13254  	         *
 13255  	         *     var x32WordArray = x64WordArray.toX32();
 13256  	         */
 13257  	        toX32: function () {
 13258  	            // Shortcuts
 13259  	            var x64Words = this.words;
 13260  	            var x64WordsLength = x64Words.length;
 13261  
 13262  	            // Convert
 13263  	            var x32Words = [];
 13264  	            for (var i = 0; i < x64WordsLength; i++) {
 13265  	                var x64Word = x64Words[i];
 13266  	                x32Words.push(x64Word.high);
 13267  	                x32Words.push(x64Word.low);
 13268  	            }
 13269  
 13270  	            return X32WordArray.create(x32Words, this.sigBytes);
 13271  	        },
 13272  
 13273  	        /**
 13274  	         * Creates a copy of this word array.
 13275  	         *
 13276  	         * @return {X64WordArray} The clone.
 13277  	         *
 13278  	         * @example
 13279  	         *
 13280  	         *     var clone = x64WordArray.clone();
 13281  	         */
 13282  	        clone: function () {
 13283  	            var clone = Base.clone.call(this);
 13284  
 13285  	            // Clone "words" array
 13286  	            var words = clone.words = this.words.slice(0);
 13287  
 13288  	            // Clone each X64Word object
 13289  	            var wordsLength = words.length;
 13290  	            for (var i = 0; i < wordsLength; i++) {
 13291  	                words[i] = words[i].clone();
 13292  	            }
 13293  
 13294  	            return clone;
 13295  	        }
 13296  	    });
 13297  	}());
 13298  
 13299  
 13300  	return CryptoJS;
 13301  
 13302  }));
 13303  },{"./core":53}],85:[function(require,module,exports){
 13304  /*! https://mths.be/utf8js v2.1.2 by @mathias */
 13305  ;(function(root) {
 13306  
 13307  	// Detect free variables `exports`
 13308  	var freeExports = typeof exports == 'object' && exports;
 13309  
 13310  	// Detect free variable `module`
 13311  	var freeModule = typeof module == 'object' && module &&
 13312  		module.exports == freeExports && module;
 13313  
 13314  	// Detect free variable `global`, from Node.js or Browserified code,
 13315  	// and use it as `root`
 13316  	var freeGlobal = typeof global == 'object' && global;
 13317  	if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
 13318  		root = freeGlobal;
 13319  	}
 13320  
 13321  	/*--------------------------------------------------------------------------*/
 13322  
 13323  	var stringFromCharCode = String.fromCharCode;
 13324  
 13325  	// Taken from https://mths.be/punycode
 13326  	function ucs2decode(string) {
 13327  		var output = [];
 13328  		var counter = 0;
 13329  		var length = string.length;
 13330  		var value;
 13331  		var extra;
 13332  		while (counter < length) {
 13333  			value = string.charCodeAt(counter++);
 13334  			if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
 13335  				// high surrogate, and there is a next character
 13336  				extra = string.charCodeAt(counter++);
 13337  				if ((extra & 0xFC00) == 0xDC00) { // low surrogate
 13338  					output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
 13339  				} else {
 13340  					// unmatched surrogate; only append this code unit, in case the next
 13341  					// code unit is the high surrogate of a surrogate pair
 13342  					output.push(value);
 13343  					counter--;
 13344  				}
 13345  			} else {
 13346  				output.push(value);
 13347  			}
 13348  		}
 13349  		return output;
 13350  	}
 13351  
 13352  	// Taken from https://mths.be/punycode
 13353  	function ucs2encode(array) {
 13354  		var length = array.length;
 13355  		var index = -1;
 13356  		var value;
 13357  		var output = '';
 13358  		while (++index < length) {
 13359  			value = array[index];
 13360  			if (value > 0xFFFF) {
 13361  				value -= 0x10000;
 13362  				output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
 13363  				value = 0xDC00 | value & 0x3FF;
 13364  			}
 13365  			output += stringFromCharCode(value);
 13366  		}
 13367  		return output;
 13368  	}
 13369  
 13370  	function checkScalarValue(codePoint) {
 13371  		if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
 13372  			throw Error(
 13373  				'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
 13374  				' is not a scalar value'
 13375  			);
 13376  		}
 13377  	}
 13378  	/*--------------------------------------------------------------------------*/
 13379  
 13380  	function createByte(codePoint, shift) {
 13381  		return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
 13382  	}
 13383  
 13384  	function encodeCodePoint(codePoint) {
 13385  		if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
 13386  			return stringFromCharCode(codePoint);
 13387  		}
 13388  		var symbol = '';
 13389  		if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
 13390  			symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
 13391  		}
 13392  		else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
 13393  			checkScalarValue(codePoint);
 13394  			symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
 13395  			symbol += createByte(codePoint, 6);
 13396  		}
 13397  		else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
 13398  			symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
 13399  			symbol += createByte(codePoint, 12);
 13400  			symbol += createByte(codePoint, 6);
 13401  		}
 13402  		symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
 13403  		return symbol;
 13404  	}
 13405  
 13406  	function utf8encode(string) {
 13407  		var codePoints = ucs2decode(string);
 13408  		var length = codePoints.length;
 13409  		var index = -1;
 13410  		var codePoint;
 13411  		var byteString = '';
 13412  		while (++index < length) {
 13413  			codePoint = codePoints[index];
 13414  			byteString += encodeCodePoint(codePoint);
 13415  		}
 13416  		return byteString;
 13417  	}
 13418  
 13419  	/*--------------------------------------------------------------------------*/
 13420  
 13421  	function readContinuationByte() {
 13422  		if (byteIndex >= byteCount) {
 13423  			throw Error('Invalid byte index');
 13424  		}
 13425  
 13426  		var continuationByte = byteArray[byteIndex] & 0xFF;
 13427  		byteIndex++;
 13428  
 13429  		if ((continuationByte & 0xC0) == 0x80) {
 13430  			return continuationByte & 0x3F;
 13431  		}
 13432  
 13433  		// If we end up here, it’s not a continuation byte
 13434  		throw Error('Invalid continuation byte');
 13435  	}
 13436  
 13437  	function decodeSymbol() {
 13438  		var byte1;
 13439  		var byte2;
 13440  		var byte3;
 13441  		var byte4;
 13442  		var codePoint;
 13443  
 13444  		if (byteIndex > byteCount) {
 13445  			throw Error('Invalid byte index');
 13446  		}
 13447  
 13448  		if (byteIndex == byteCount) {
 13449  			return false;
 13450  		}
 13451  
 13452  		// Read first byte
 13453  		byte1 = byteArray[byteIndex] & 0xFF;
 13454  		byteIndex++;
 13455  
 13456  		// 1-byte sequence (no continuation bytes)
 13457  		if ((byte1 & 0x80) == 0) {
 13458  			return byte1;
 13459  		}
 13460  
 13461  		// 2-byte sequence
 13462  		if ((byte1 & 0xE0) == 0xC0) {
 13463  			byte2 = readContinuationByte();
 13464  			codePoint = ((byte1 & 0x1F) << 6) | byte2;
 13465  			if (codePoint >= 0x80) {
 13466  				return codePoint;
 13467  			} else {
 13468  				throw Error('Invalid continuation byte');
 13469  			}
 13470  		}
 13471  
 13472  		// 3-byte sequence (may include unpaired surrogates)
 13473  		if ((byte1 & 0xF0) == 0xE0) {
 13474  			byte2 = readContinuationByte();
 13475  			byte3 = readContinuationByte();
 13476  			codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
 13477  			if (codePoint >= 0x0800) {
 13478  				checkScalarValue(codePoint);
 13479  				return codePoint;
 13480  			} else {
 13481  				throw Error('Invalid continuation byte');
 13482  			}
 13483  		}
 13484  
 13485  		// 4-byte sequence
 13486  		if ((byte1 & 0xF8) == 0xF0) {
 13487  			byte2 = readContinuationByte();
 13488  			byte3 = readContinuationByte();
 13489  			byte4 = readContinuationByte();
 13490  			codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
 13491  				(byte3 << 0x06) | byte4;
 13492  			if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
 13493  				return codePoint;
 13494  			}
 13495  		}
 13496  
 13497  		throw Error('Invalid UTF-8 detected');
 13498  	}
 13499  
 13500  	var byteArray;
 13501  	var byteCount;
 13502  	var byteIndex;
 13503  	function utf8decode(byteString) {
 13504  		byteArray = ucs2decode(byteString);
 13505  		byteCount = byteArray.length;
 13506  		byteIndex = 0;
 13507  		var codePoints = [];
 13508  		var tmp;
 13509  		while ((tmp = decodeSymbol()) !== false) {
 13510  			codePoints.push(tmp);
 13511  		}
 13512  		return ucs2encode(codePoints);
 13513  	}
 13514  
 13515  	/*--------------------------------------------------------------------------*/
 13516  
 13517  	var utf8 = {
 13518  		'version': '2.1.2',
 13519  		'encode': utf8encode,
 13520  		'decode': utf8decode
 13521  	};
 13522  
 13523  	// Some AMD build optimizers, like r.js, check for specific condition patterns
 13524  	// like the following:
 13525  	if (
 13526  		typeof define == 'function' &&
 13527  		typeof define.amd == 'object' &&
 13528  		define.amd
 13529  	) {
 13530  		define(function() {
 13531  			return utf8;
 13532  		});
 13533  	}	else if (freeExports && !freeExports.nodeType) {
 13534  		if (freeModule) { // in Node.js or RingoJS v0.8.0+
 13535  			freeModule.exports = utf8;
 13536  		} else { // in Narwhal or RingoJS v0.7.0-
 13537  			var object = {};
 13538  			var hasOwnProperty = object.hasOwnProperty;
 13539  			for (var key in utf8) {
 13540  				hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
 13541  			}
 13542  		}
 13543  	} else { // in Rhino or a web browser
 13544  		root.utf8 = utf8;
 13545  	}
 13546  
 13547  }(this));
 13548  
 13549  },{}],86:[function(require,module,exports){
 13550  module.exports = XMLHttpRequest;
 13551  
 13552  },{}],"bignumber.js":[function(require,module,exports){
 13553  'use strict';
 13554  
 13555  module.exports = BigNumber; // jshint ignore:line
 13556  
 13557  
 13558  },{}],"web3":[function(require,module,exports){
 13559  var Web3 = require('./lib/web3');
 13560  
 13561  // dont override global variable
 13562  if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
 13563      window.Web3 = Web3;
 13564  }
 13565  
 13566  module.exports = Web3;
 13567  
 13568  },{"./lib/web3":22}]},{},["web3"])
 13569  //# sourceMappingURL=web3-light.js.map