Guest User

Untitled

a guest
Feb 11th, 2016
1,017
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.  
  3.  // ---------------------------------------------------------------
  4.  //
  5.  // Hello, NXT + BTC WarpWallet friend!
  6.  //
  7.  // If you are saving an offline copy of this file
  8.  // and would like your salt always pre-filled for
  9.  // convenience, assign the default value here. You
  10.  // don't have to stick to the email format in that case.
  11.  //
  12.  // A salt shouldn't make you lazy with your passphrase, of course.
  13.  //
  14.  //   @maxtaco and @malgorithms
  15.  //
  16.  // ---------------------------------------------------------------
  17.  
  18.  var SALT_DEFAULT = null; // assign a string and save this file.
  19.  
  20. //Inject warp wallet html form into nxt login screen
  21. jQuery('#remember_account_container').before(' <form id="warp-form"> <input id="passphrase" placeholder="Warp Pass" /> <input id="salt" placeholder="Optional Salt" /><button type="button" id="btn-submit">Generate Warp Login</button><div class="progress-form"> <div class="bar"> <span class="progress-scrypt"></span> <span class="progress-pbkdf2"></span> </div> </div> <div class="output-form"> <input id="public-address"> <input id="private-key"> <input id="combined-key"><button type="button" id="warp-login">Login with Warp</button> </div> </form> ');
  22.  
  23. //Inject CSS into head for Warp Wallet form
  24. $("<style>")
  25. .prop("type", "text/css")
  26. .html("\
  27.  #warp-form { margin: 0 0 15px; }\
  28.  #warp-form button { display: block; margin: 9px auto; background: #008FBB; color: #fff; font-weight: bold; border: 2px solid #fff; }\
  29.  #warp-form input { background: #005473; border-radius: 9px; border: 2px solid #FFF; font-size: 10px; width: 180px; padding: 3px; color: #fff;  }\
  30.  #warp-form .progress-form { width: 360px; margin: 0 auto; background: #fff; }\
  31.  #warp-form .bar { background: #005473; line-height: 25px; color: #fff; min-width:130px; font-size: 9px; }\
  32.  #warp-form .progress-pbkdf2 { position: absolute; }\
  33.  #warp-form .output-form { display: none; margin: 9px 0; }\
  34.  #warp-form .output-form:before { display: block; margin: 0 0 9px; color: #fff; content:'Bitcoin Public & Private key combined to form NXT passphrase.' }\
  35.  #warp-form .output-form #combined-key { display: block; margin: 9px auto; }\
  36. ")
  37. .appendTo("head");
  38.  
  39.  
  40.  
  41. //show hide warp form on change
  42. jQuery('#warp-form').hide();
  43. jQuery('#loginButtons').on('click ', function () {
  44.      jQuery('#warp-form').toggle();
  45. });
  46. jQuery('#warp-login').click(function () {
  47.   NRS.login(1,$('#combined-key').val())
  48.  
  49.   //add warp BTC public address to NXT user panel
  50.   wbtc = jQuery('#public-address').val();
  51.   jQuery('#sidebar_account_id').after('<div id="warp-btc" style="text-align: center; margin: 12px 0; font-size: 11px; word-break: break-all; padding: 5px; background: #fff; ">Bitcoin Address: <a href="https://blockchain.info/address/'+ wbtc +'" target="_blank">'+ wbtc +'</a></div>');
  52. });
  53.  
  54.  
  55.  
  56. </script>
  57.  
  58. <script type="text/javascript">
  59. window.params  = {
  60.   "N"        : 18,
  61.   "p"        : 1,
  62.   "r"        : 8,
  63.   "dkLen"    : 32,
  64.   "pbkdf2c"  : 65536
  65. }
  66. ;
  67. window.package = {
  68.   "name": "warpwallet",
  69.   "version": "1.0.7",
  70.   "description": "Open Source JavaScript Client-Side Bitcoin Wallet Generator Using scrypt",
  71.   "dependencies": {
  72.     "brew": "*",
  73.     "browserify": "*",
  74.     "colors": "*",
  75.     "iced-coffee-script": "^1.7.1-f",
  76.     "iced-error": "*",
  77.     "iced-runtime": "^1.0.1",
  78.     "iced-test": "*",
  79.     "iced-utils": ">=0.1.1",
  80.     "icsify": "*",
  81.     "keybase-bitcoin": ">=0.0.0",
  82.     "triplesec": "keybase/triplesec#header_v3"
  83.   },
  84.   "repository": {
  85.     "type": "git",
  86.     "url": "git://github.com/keybase/warpwallet"
  87.   },
  88.   "keywords": [
  89.     "bitcoin address wallet generator"
  90.   ],
  91.   "author": "",
  92.   "license": "",
  93.   "bugs": {
  94.     "url": "https://github.com/keybase/warpwallet/issues"
  95.   }
  96. }
  97. ;
  98. </script><script type="text/javascript">
  99. (function() {
  100.   var Warper;
  101.  
  102.   Warper = (function() {
  103.     function Warper() {
  104.       this.check_compatibility();
  105.       this.attach_ux();
  106.       if (window.SALT_DEFAULT != null) {
  107.         $('#salt').val(window.SALT_DEFAULT);
  108.         $('#salt').attr('disabled', true);
  109.         $('.salt-label').text('Prefilled salt');
  110.       }
  111.     }
  112.  
  113.     Warper.prototype.check_compatibility = function() {
  114.       if (typeof Int32Array === "undefined" || Int32Array === null) {
  115.         return $('.form-container').html('<p>\n  Sorry, but your browser is too old to run WarpWallet, which requires Int32Array support.\n</p>');
  116.       }
  117.     };
  118.  
  119.     Warper.prototype.attach_ux = function() {
  120.       $('#btn-submit').on('click', (function(_this) {
  121.         return function() {
  122.           return _this.click_submit();
  123.         };
  124.       })(this));
  125.       $('#btn-reset').on('click', (function(_this) {
  126.         return function() {
  127.           return _this.click_reset();
  128.         };
  129.       })(this));
  130.       $('#salt').on('change', (function(_this) {
  131.         return function() {
  132.           return _this.salt_change();
  133.         };
  134.       })(this));
  135.       $('#salt').on('keyup', (function(_this) {
  136.         return function() {
  137.           return _this.salt_change();
  138.         };
  139.       })(this));
  140.       $('#checkbox-salt-confirm').on('click', (function(_this) {
  141.         return function() {
  142.           return _this.any_change();
  143.         };
  144.       })(this));
  145.       $('#passphrase').on('change', (function(_this) {
  146.         return function() {
  147.           return _this.any_change();
  148.         };
  149.       })(this));
  150.       $('#passphrase').on('keyup', (function(_this) {
  151.         return function() {
  152.           return _this.any_change();
  153.         };
  154.       })(this));
  155.       $('#public-address').on('click', function() {
  156.         return $(this).select();
  157.       });
  158.       $('#private-key').on('click', function() {
  159.         return $(this).select();
  160.       });
  161.       return $('.what-salt').on('click', (function(_this) {
  162.         return function() {
  163.           return $('.salt-explanation').toggle();
  164.         };
  165.       })(this));
  166.     };
  167.  
  168.     Warper.prototype.any_change = function() {
  169.       var chk, err, pp, salt, warn;
  170.       $('.progress-form').hide();
  171.       $('#private-key').val('');
  172.       $('#public-address').val('');
  173.       $('#btn-submit').attr('disabled', false).show().html('Generate Warp Login');
  174.       pp = $('#passphrase').val();
  175.       salt = $('#salt').val();
  176.       chk = $('#checkbox-salt-confirm').is(":checked");
  177.       err = null;
  178.       warn = null;
  179. /* duckx
  180.       if (!pp.length) {
  181.         err = "Please enter a passphrase";
  182.       } else if ((salt != null ? salt.length : void 0) && !this.salt_ok()) {
  183.         err = "Fix your salt";
  184.       //} else if ((salt != null ? salt.length : void 0) && (!chk) && (window.SALT_DEFAULT == null)) {
  185.         //err = "Confirm your salt";
  186.       } else if (pp.length < 12) {
  187.         warn = "Consider a larger passphrase";
  188.       }
  189.       if (err) {
  190.         $('#btn-submit').attr('disabled', true).html(err);
  191.       } else if (warn) {
  192.         $('#btn-submit').attr('disabled', false).html(warn);
  193.       } else {
  194.         $('#btn-submit').attr('disabled', false).html("Generate");
  195.       }
  196. */
  197.       $('.output-form').hide();
  198.       $('#public-address-qr').html('');
  199.       return $('#private-key-qr').html('');
  200.     };
  201.  
  202.     Warper.prototype.commas = function(n) {
  203.       while (/(\d+)(\d{3})/.test(n.toString())) {
  204.         n = n.toString().replace(/(\d+)(\d{3})/, '$1,$2');
  205.       }
  206.       return n;
  207.     };
  208.  
  209.     Warper.prototype.salt_ok = function() {
  210.       var salt;
  211.       salt = $('#salt').val();
  212.       //return (salt.match(/^[\S]+@[\S]+\.[\S]+$/)) || (window.SALT_DEFAULT != null);
  213.       return (salt.length) || (window.SALT_DEFAULT != null);
  214.     };
  215.  
  216.     Warper.prototype.salt_change = function() {
  217.       var salt;
  218.       salt = $('#salt').val();
  219.       $('#checkbox-salt-confirm').attr('checked', false);
  220.       if (!salt.length) {
  221.         $('.salt-confirm').hide();
  222.       }
  223.       /*
  224.       if (window.SALT_DEFAULT != null) {
  225.         $('.salt-confirm').hide();
  226.       } else if (this.salt_ok()) {
  227.         $('.salt-confirm').show();
  228.         $('.salt-summary').text(salt);
  229.       } else {
  230.         $('.salt-confirm').hide();
  231.       }
  232.       */
  233.       return this.any_change();
  234.     };
  235.  
  236.     Warper.prototype.progress_hook = function(o) {
  237.       var w;
  238.       if (o.what === 'scrypt') {
  239.         w = (o.i / o.total) * 50;
  240.         $('.progress-form .bar').css('width', "" + w + "%");
  241.         return $('.progress-form .bar .progress-scrypt').html("scrypt " + (this.commas(o.i)) + " of " + (this.commas(o.total)));
  242.       } else if (o.what === 'pbkdf2') {
  243.         w = 50 + (o.i / o.total) * 50;
  244.         $('.progress-form .bar').css('width', "" + w + "%");
  245.         return $('.progress-form .bar .progress-pbkdf2').html("&nbsp; pbkdf2 " + (this.commas(o.i)) + " of " + (this.commas(o.total)));
  246.       }
  247.     };
  248.  
  249.     Warper.prototype.click_reset = function() {
  250.       $('#btn-submit').attr('disabled', false).show().html('Please enter a passphrase');
  251.       $('#passphrase, #public-address, #private-key').val('');
  252.       if (window.SALT_DEFAULT == null) {
  253.         $('#salt').val('');
  254.       }
  255.       $('#checkbox-salt-confirm').attr('checked', false);
  256.       $('.salt-summary').html('');
  257.       $('.salt-confirm').hide();
  258.       $('.progress-form').hide();
  259.       $('.output-form').hide();
  260.       $('#public-address-qr').html('');
  261.       return $('#private-key-qr').html('');
  262.     };
  263.  
  264.     /*Warper.prototype.write_qrs = function(pub, priv) {
  265.       var params;
  266.       params = {
  267.         width: 256,
  268.         height: 256,
  269.         colorLight: "#f8f8f4",
  270.         correctLevel: QRCode.CorrectLevel.H
  271.       };
  272.       (new QRCode("public-address-qr", params)).makeCode(pub);
  273.       return (new QRCode("private-key-qr", params)).makeCode(priv);
  274.     }; --duckx */
  275.  
  276.     Warper.prototype.click_submit = function() {
  277.       $('#btn-submit').attr('disabled', true).html('Running...');
  278.       $('#btn-reset').attr('disabled', true).html('Running...');
  279.       $('#passphrase, #salt, checkbox-salt-confirm').attr('disabled', true);
  280.       $('.progress-pbkdf2, .progress-scrypt').html('');
  281.       $('.progress-form').show();
  282.       return warpwallet.run({
  283.         passphrase: $('#passphrase').val(),
  284.         salt: $('#salt').val(),
  285.         progress_hook: (function(_this) {
  286.           return function(o) {
  287.             return _this.progress_hook(o);
  288.           };
  289.         })(this),
  290.         params: window.params
  291.       }, (function(_this) {
  292.         return function(res) {
  293.           $('#passphrase, #checkbox-salt-confirm').attr('disabled', false);
  294.           if (window.SALT_DEFAULT == null) {
  295.             $('#salt').attr('disabled', false);
  296.           }
  297.           $('.progress-form').hide();
  298.           $('.output-form').show();
  299.           $('#btn-submit').hide();
  300.           $('#btn-reset').attr('disabled', false).html('Clear &amp; reset');
  301.           $('#public-address').val(res["public"]);
  302.           $('#private-key').val(res["private"]);
  303.           $('#combined-key').val(res["public"] + res["private"]);
  304.           console.log(res["private"]); //duckx
  305.           console.log($("#salt").val()); //duckx
  306.  
  307.             //_this.write_qrs(res["public"], res["private"]);
  308.           return console.log;
  309.         };
  310.       })(this));
  311.     };
  312.  
  313.     return Warper;
  314.  
  315.   })();
  316.  
  317.   $(function() {
  318.     return new Warper();
  319.   });
  320.  
  321. }).call(this);
  322.  
  323. </script><script type="text/javascript">
  324. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.warpwallet = f()}})(function(){var define,module,exports;return (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){
  325. (function (global){
  326. /*!
  327.  * The buffer module from node.js, for the browser.
  328.  *
  329.  * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  330.  * @license  MIT
  331.  */
  332. /* eslint-disable no-proto */
  333.  
  334. var base64 = require('base64-js')
  335. var ieee754 = require('ieee754')
  336. var isArray = require('is-array')
  337.  
  338. exports.Buffer = Buffer
  339. exports.SlowBuffer = SlowBuffer
  340. exports.INSPECT_MAX_BYTES = 50
  341. Buffer.poolSize = 8192 // not used by this implementation
  342.  
  343. var rootParent = {}
  344.  
  345. /**
  346.  * If `Buffer.TYPED_ARRAY_SUPPORT`:
  347.  *   === true    Use Uint8Array implementation (fastest)
  348.  *   === false   Use Object implementation (most compatible, even IE6)
  349.  *
  350.  * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  351.  * Opera 11.6+, iOS 4.2+.
  352.  *
  353.  * Due to various browser bugs, sometimes the Object implementation will be used even
  354.  * when the browser supports typed arrays.
  355.  *
  356.  * Note:
  357.  *
  358.  *   - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  359.  *     See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  360.  *
  361.  *   - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
  362.  *     on objects.
  363.  *
  364.  *   - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  365.  *
  366.  *   - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  367.  *     incorrect length in some situations.
  368.  
  369.  * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  370.  * get the Object implementation, which is slower but behaves correctly.
  371.  */
  372. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  373.   ? global.TYPED_ARRAY_SUPPORT
  374.   : typedArraySupport()
  375.  
  376. function typedArraySupport () {
  377.   function Bar () {}
  378.   try {
  379.     var arr = new Uint8Array(1)
  380.     arr.foo = function () { return 42 }
  381.     arr.constructor = Bar
  382.     return arr.foo() === 42 && // typed array instances can be augmented
  383.         arr.constructor === Bar && // constructor can be set
  384.         typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  385.         arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  386.   } catch (e) {
  387.     return false
  388.   }
  389. }
  390.  
  391. function kMaxLength () {
  392.   return Buffer.TYPED_ARRAY_SUPPORT
  393.     ? 0x7fffffff
  394.     : 0x3fffffff
  395. }
  396.  
  397. /**
  398.  * Class: Buffer
  399.  * =============
  400.  *
  401.  * The Buffer constructor returns instances of `Uint8Array` that are augmented
  402.  * with function properties for all the node `Buffer` API functions. We use
  403.  * `Uint8Array` so that square bracket notation works as expected -- it returns
  404.  * a single octet.
  405.  *
  406.  * By augmenting the instances, we can avoid modifying the `Uint8Array`
  407.  * prototype.
  408.  */
  409. function Buffer (arg) {
  410.   if (!(this instanceof Buffer)) {
  411.     // Avoid going through an ArgumentsAdaptorTrampoline in the common case.
  412.     if (arguments.length > 1) return new Buffer(arg, arguments[1])
  413.     return new Buffer(arg)
  414.   }
  415.  
  416.   this.length = 0
  417.   this.parent = undefined
  418.  
  419.   // Common case.
  420.   if (typeof arg === 'number') {
  421.     return fromNumber(this, arg)
  422.   }
  423.  
  424.   // Slightly less common case.
  425.   if (typeof arg === 'string') {
  426.     return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
  427.   }
  428.  
  429.   // Unusual.
  430.   return fromObject(this, arg)
  431. }
  432.  
  433. function fromNumber (that, length) {
  434.   that = allocate(that, length < 0 ? 0 : checked(length) | 0)
  435.   if (!Buffer.TYPED_ARRAY_SUPPORT) {
  436.     for (var i = 0; i < length; i++) {
  437.       that[i] = 0
  438.     }
  439.   }
  440.   return that
  441. }
  442.  
  443. function fromString (that, string, encoding) {
  444.   if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
  445.  
  446.   // Assumption: byteLength() return value is always < kMaxLength.
  447.   var length = byteLength(string, encoding) | 0
  448.   that = allocate(that, length)
  449.  
  450.   that.write(string, encoding)
  451.   return that
  452. }
  453.  
  454. function fromObject (that, object) {
  455.   if (Buffer.isBuffer(object)) return fromBuffer(that, object)
  456.  
  457.   if (isArray(object)) return fromArray(that, object)
  458.  
  459.   if (object == null) {
  460.     throw new TypeError('must start with number, buffer, array or string')
  461.   }
  462.  
  463.   if (typeof ArrayBuffer !== 'undefined') {
  464.     if (object.buffer instanceof ArrayBuffer) {
  465.       return fromTypedArray(that, object)
  466.     }
  467.     if (object instanceof ArrayBuffer) {
  468.       return fromArrayBuffer(that, object)
  469.     }
  470.   }
  471.  
  472.   if (object.length) return fromArrayLike(that, object)
  473.  
  474.   return fromJsonObject(that, object)
  475. }
  476.  
  477. function fromBuffer (that, buffer) {
  478.   var length = checked(buffer.length) | 0
  479.   that = allocate(that, length)
  480.   buffer.copy(that, 0, 0, length)
  481.   return that
  482. }
  483.  
  484. function fromArray (that, array) {
  485.   var length = checked(array.length) | 0
  486.   that = allocate(that, length)
  487.   for (var i = 0; i < length; i += 1) {
  488.     that[i] = array[i] & 255
  489.   }
  490.   return that
  491. }
  492.  
  493. // Duplicate of fromArray() to keep fromArray() monomorphic.
  494. function fromTypedArray (that, array) {
  495.   var length = checked(array.length) | 0
  496.   that = allocate(that, length)
  497.   // Truncating the elements is probably not what people expect from typed
  498.   // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
  499.   // of the old Buffer constructor.
  500.   for (var i = 0; i < length; i += 1) {
  501.     that[i] = array[i] & 255
  502.   }
  503.   return that
  504. }
  505.  
  506. function fromArrayBuffer (that, array) {
  507.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  508.     // Return an augmented `Uint8Array` instance, for best performance
  509.     array.byteLength
  510.     that = Buffer._augment(new Uint8Array(array))
  511.   } else {
  512.     // Fallback: Return an object instance of the Buffer class
  513.     that = fromTypedArray(that, new Uint8Array(array))
  514.   }
  515.   return that
  516. }
  517.  
  518. function fromArrayLike (that, array) {
  519.   var length = checked(array.length) | 0
  520.   that = allocate(that, length)
  521.   for (var i = 0; i < length; i += 1) {
  522.     that[i] = array[i] & 255
  523.   }
  524.   return that
  525. }
  526.  
  527. // Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
  528. // Returns a zero-length buffer for inputs that don't conform to the spec.
  529. function fromJsonObject (that, object) {
  530.   var array
  531.   var length = 0
  532.  
  533.   if (object.type === 'Buffer' && isArray(object.data)) {
  534.     array = object.data
  535.     length = checked(array.length) | 0
  536.   }
  537.   that = allocate(that, length)
  538.  
  539.   for (var i = 0; i < length; i += 1) {
  540.     that[i] = array[i] & 255
  541.   }
  542.   return that
  543. }
  544.  
  545. if (Buffer.TYPED_ARRAY_SUPPORT) {
  546.   Buffer.prototype.__proto__ = Uint8Array.prototype
  547.   Buffer.__proto__ = Uint8Array
  548. }
  549.  
  550. function allocate (that, length) {
  551.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  552.     // Return an augmented `Uint8Array` instance, for best performance
  553.     that = Buffer._augment(new Uint8Array(length))
  554.     that.__proto__ = Buffer.prototype
  555.   } else {
  556.     // Fallback: Return an object instance of the Buffer class
  557.     that.length = length
  558.     that._isBuffer = true
  559.   }
  560.  
  561.   var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
  562.   if (fromPool) that.parent = rootParent
  563.  
  564.   return that
  565. }
  566.  
  567. function checked (length) {
  568.   // Note: cannot use `length < kMaxLength` here because that fails when
  569.   // length is NaN (which is otherwise coerced to zero.)
  570.   if (length >= kMaxLength()) {
  571.     throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  572.                          'size: 0x' + kMaxLength().toString(16) + ' bytes')
  573.   }
  574.   return length | 0
  575. }
  576.  
  577. function SlowBuffer (subject, encoding) {
  578.   if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
  579.  
  580.   var buf = new Buffer(subject, encoding)
  581.   delete buf.parent
  582.   return buf
  583. }
  584.  
  585. Buffer.isBuffer = function isBuffer (b) {
  586.   return !!(b != null && b._isBuffer)
  587. }
  588.  
  589. Buffer.compare = function compare (a, b) {
  590.   if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  591.     throw new TypeError('Arguments must be Buffers')
  592.   }
  593.  
  594.   if (a === b) return 0
  595.  
  596.   var x = a.length
  597.   var y = b.length
  598.  
  599.   var i = 0
  600.   var len = Math.min(x, y)
  601.   while (i < len) {
  602.     if (a[i] !== b[i]) break
  603.  
  604.     ++i
  605.   }
  606.  
  607.   if (i !== len) {
  608.     x = a[i]
  609.     y = b[i]
  610.   }
  611.  
  612.   if (x < y) return -1
  613.   if (y < x) return 1
  614.   return 0
  615. }
  616.  
  617. Buffer.isEncoding = function isEncoding (encoding) {
  618.   switch (String(encoding).toLowerCase()) {
  619.     case 'hex':
  620.     case 'utf8':
  621.     case 'utf-8':
  622.     case 'ascii':
  623.     case 'binary':
  624.     case 'base64':
  625.     case 'raw':
  626.     case 'ucs2':
  627.     case 'ucs-2':
  628.     case 'utf16le':
  629.     case 'utf-16le':
  630.       return true
  631.     default:
  632.       return false
  633.   }
  634. }
  635.  
  636. Buffer.concat = function concat (list, length) {
  637.   if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
  638.  
  639.   if (list.length === 0) {
  640.     return new Buffer(0)
  641.   }
  642.  
  643.   var i
  644.   if (length === undefined) {
  645.     length = 0
  646.     for (i = 0; i < list.length; i++) {
  647.       length += list[i].length
  648.     }
  649.   }
  650.  
  651.   var buf = new Buffer(length)
  652.   var pos = 0
  653.   for (i = 0; i < list.length; i++) {
  654.     var item = list[i]
  655.     item.copy(buf, pos)
  656.     pos += item.length
  657.   }
  658.   return buf
  659. }
  660.  
  661. function byteLength (string, encoding) {
  662.   if (typeof string !== 'string') string = '' + string
  663.  
  664.   var len = string.length
  665.   if (len === 0) return 0
  666.  
  667.   // Use a for loop to avoid recursion
  668.   var loweredCase = false
  669.   for (;;) {
  670.     switch (encoding) {
  671.       case 'ascii':
  672.       case 'binary':
  673.       // Deprecated
  674.       case 'raw':
  675.       case 'raws':
  676.         return len
  677.       case 'utf8':
  678.       case 'utf-8':
  679.         return utf8ToBytes(string).length
  680.       case 'ucs2':
  681.       case 'ucs-2':
  682.       case 'utf16le':
  683.       case 'utf-16le':
  684.         return len * 2
  685.       case 'hex':
  686.         return len >>> 1
  687.       case 'base64':
  688.         return base64ToBytes(string).length
  689.       default:
  690.         if (loweredCase) return utf8ToBytes(string).length // assume utf8
  691.         encoding = ('' + encoding).toLowerCase()
  692.         loweredCase = true
  693.     }
  694.   }
  695. }
  696. Buffer.byteLength = byteLength
  697.  
  698. // pre-set for values that may exist in the future
  699. Buffer.prototype.length = undefined
  700. Buffer.prototype.parent = undefined
  701.  
  702. function slowToString (encoding, start, end) {
  703.   var loweredCase = false
  704.  
  705.   start = start | 0
  706.   end = end === undefined || end === Infinity ? this.length : end | 0
  707.  
  708.   if (!encoding) encoding = 'utf8'
  709.   if (start < 0) start = 0
  710.   if (end > this.length) end = this.length
  711.   if (end <= start) return ''
  712.  
  713.   while (true) {
  714.     switch (encoding) {
  715.       case 'hex':
  716.         return hexSlice(this, start, end)
  717.  
  718.       case 'utf8':
  719.       case 'utf-8':
  720.         return utf8Slice(this, start, end)
  721.  
  722.       case 'ascii':
  723.         return asciiSlice(this, start, end)
  724.  
  725.       case 'binary':
  726.         return binarySlice(this, start, end)
  727.  
  728.       case 'base64':
  729.         return base64Slice(this, start, end)
  730.  
  731.       case 'ucs2':
  732.       case 'ucs-2':
  733.       case 'utf16le':
  734.       case 'utf-16le':
  735.         return utf16leSlice(this, start, end)
  736.  
  737.       default:
  738.         if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  739.         encoding = (encoding + '').toLowerCase()
  740.         loweredCase = true
  741.     }
  742.   }
  743. }
  744.  
  745. Buffer.prototype.toString = function toString () {
  746.   var length = this.length | 0
  747.   if (length === 0) return ''
  748.   if (arguments.length === 0) return utf8Slice(this, 0, length)
  749.   return slowToString.apply(this, arguments)
  750. }
  751.  
  752. Buffer.prototype.equals = function equals (b) {
  753.   if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  754.   if (this === b) return true
  755.   return Buffer.compare(this, b) === 0
  756. }
  757.  
  758. Buffer.prototype.inspect = function inspect () {
  759.   var str = ''
  760.   var max = exports.INSPECT_MAX_BYTES
  761.   if (this.length > 0) {
  762.     str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  763.     if (this.length > max) str += ' ... '
  764.   }
  765.   return '<Buffer ' + str + '>'
  766. }
  767.  
  768. Buffer.prototype.compare = function compare (b) {
  769.   if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  770.   if (this === b) return 0
  771.   return Buffer.compare(this, b)
  772. }
  773.  
  774. Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
  775.   if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
  776.   else if (byteOffset < -0x80000000) byteOffset = -0x80000000
  777.   byteOffset >>= 0
  778.  
  779.   if (this.length === 0) return -1
  780.   if (byteOffset >= this.length) return -1
  781.  
  782.   // Negative offsets start from the end of the buffer
  783.   if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
  784.  
  785.   if (typeof val === 'string') {
  786.     if (val.length === 0) return -1 // special case: looking for empty string always fails
  787.     return String.prototype.indexOf.call(this, val, byteOffset)
  788.   }
  789.   if (Buffer.isBuffer(val)) {
  790.     return arrayIndexOf(this, val, byteOffset)
  791.   }
  792.   if (typeof val === 'number') {
  793.     if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
  794.       return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
  795.     }
  796.     return arrayIndexOf(this, [ val ], byteOffset)
  797.   }
  798.  
  799.   function arrayIndexOf (arr, val, byteOffset) {
  800.     var foundIndex = -1
  801.     for (var i = 0; byteOffset + i < arr.length; i++) {
  802.       if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
  803.         if (foundIndex === -1) foundIndex = i
  804.         if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
  805.       } else {
  806.         foundIndex = -1
  807.       }
  808.     }
  809.     return -1
  810.   }
  811.  
  812.   throw new TypeError('val must be string, number or Buffer')
  813. }
  814.  
  815. // `get` is deprecated
  816. Buffer.prototype.get = function get (offset) {
  817.   console.log('.get() is deprecated. Access using array indexes instead.')
  818.   return this.readUInt8(offset)
  819. }
  820.  
  821. // `set` is deprecated
  822. Buffer.prototype.set = function set (v, offset) {
  823.   console.log('.set() is deprecated. Access using array indexes instead.')
  824.   return this.writeUInt8(v, offset)
  825. }
  826.  
  827. function hexWrite (buf, string, offset, length) {
  828.   offset = Number(offset) || 0
  829.   var remaining = buf.length - offset
  830.   if (!length) {
  831.     length = remaining
  832.   } else {
  833.     length = Number(length)
  834.     if (length > remaining) {
  835.       length = remaining
  836.     }
  837.   }
  838.  
  839.   // must be an even number of digits
  840.   var strLen = string.length
  841.   if (strLen % 2 !== 0) throw new Error('Invalid hex string')
  842.  
  843.   if (length > strLen / 2) {
  844.     length = strLen / 2
  845.   }
  846.   for (var i = 0; i < length; i++) {
  847.     var parsed = parseInt(string.substr(i * 2, 2), 16)
  848.     if (isNaN(parsed)) throw new Error('Invalid hex string')
  849.     buf[offset + i] = parsed
  850.   }
  851.   return i
  852. }
  853.  
  854. function utf8Write (buf, string, offset, length) {
  855.   return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  856. }
  857.  
  858. function asciiWrite (buf, string, offset, length) {
  859.   return blitBuffer(asciiToBytes(string), buf, offset, length)
  860. }
  861.  
  862. function binaryWrite (buf, string, offset, length) {
  863.   return asciiWrite(buf, string, offset, length)
  864. }
  865.  
  866. function base64Write (buf, string, offset, length) {
  867.   return blitBuffer(base64ToBytes(string), buf, offset, length)
  868. }
  869.  
  870. function ucs2Write (buf, string, offset, length) {
  871.   return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  872. }
  873.  
  874. Buffer.prototype.write = function write (string, offset, length, encoding) {
  875.   // Buffer#write(string)
  876.   if (offset === undefined) {
  877.     encoding = 'utf8'
  878.     length = this.length
  879.     offset = 0
  880.   // Buffer#write(string, encoding)
  881.   } else if (length === undefined && typeof offset === 'string') {
  882.     encoding = offset
  883.     length = this.length
  884.     offset = 0
  885.   // Buffer#write(string, offset[, length][, encoding])
  886.   } else if (isFinite(offset)) {
  887.     offset = offset | 0
  888.     if (isFinite(length)) {
  889.       length = length | 0
  890.       if (encoding === undefined) encoding = 'utf8'
  891.     } else {
  892.       encoding = length
  893.       length = undefined
  894.     }
  895.   // legacy write(string, encoding, offset, length) - remove in v0.13
  896.   } else {
  897.     var swap = encoding
  898.     encoding = offset
  899.     offset = length | 0
  900.     length = swap
  901.   }
  902.  
  903.   var remaining = this.length - offset
  904.   if (length === undefined || length > remaining) length = remaining
  905.  
  906.   if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  907.     throw new RangeError('attempt to write outside buffer bounds')
  908.   }
  909.  
  910.   if (!encoding) encoding = 'utf8'
  911.  
  912.   var loweredCase = false
  913.   for (;;) {
  914.     switch (encoding) {
  915.       case 'hex':
  916.         return hexWrite(this, string, offset, length)
  917.  
  918.       case 'utf8':
  919.       case 'utf-8':
  920.         return utf8Write(this, string, offset, length)
  921.  
  922.       case 'ascii':
  923.         return asciiWrite(this, string, offset, length)
  924.  
  925.       case 'binary':
  926.         return binaryWrite(this, string, offset, length)
  927.  
  928.       case 'base64':
  929.         // Warning: maxLength not taken into account in base64Write
  930.         return base64Write(this, string, offset, length)
  931.  
  932.       case 'ucs2':
  933.       case 'ucs-2':
  934.       case 'utf16le':
  935.       case 'utf-16le':
  936.         return ucs2Write(this, string, offset, length)
  937.  
  938.       default:
  939.         if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  940.         encoding = ('' + encoding).toLowerCase()
  941.         loweredCase = true
  942.     }
  943.   }
  944. }
  945.  
  946. Buffer.prototype.toJSON = function toJSON () {
  947.   return {
  948.     type: 'Buffer',
  949.     data: Array.prototype.slice.call(this._arr || this, 0)
  950.   }
  951. }
  952.  
  953. function base64Slice (buf, start, end) {
  954.   if (start === 0 && end === buf.length) {
  955.     return base64.fromByteArray(buf)
  956.   } else {
  957.     return base64.fromByteArray(buf.slice(start, end))
  958.   }
  959. }
  960.  
  961. function utf8Slice (buf, start, end) {
  962.   end = Math.min(buf.length, end)
  963.   var res = []
  964.  
  965.   var i = start
  966.   while (i < end) {
  967.     var firstByte = buf[i]
  968.     var codePoint = null
  969.     var bytesPerSequence = (firstByte > 0xEF) ? 4
  970.       : (firstByte > 0xDF) ? 3
  971.       : (firstByte > 0xBF) ? 2
  972.       : 1
  973.  
  974.     if (i + bytesPerSequence <= end) {
  975.       var secondByte, thirdByte, fourthByte, tempCodePoint
  976.  
  977.       switch (bytesPerSequence) {
  978.         case 1:
  979.           if (firstByte < 0x80) {
  980.             codePoint = firstByte
  981.           }
  982.           break
  983.         case 2:
  984.           secondByte = buf[i + 1]
  985.           if ((secondByte & 0xC0) === 0x80) {
  986.             tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  987.             if (tempCodePoint > 0x7F) {
  988.               codePoint = tempCodePoint
  989.             }
  990.           }
  991.           break
  992.         case 3:
  993.           secondByte = buf[i + 1]
  994.           thirdByte = buf[i + 2]
  995.           if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  996.             tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  997.             if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  998.               codePoint = tempCodePoint
  999.             }
  1000.           }
  1001.           break
  1002.         case 4:
  1003.           secondByte = buf[i + 1]
  1004.           thirdByte = buf[i + 2]
  1005.           fourthByte = buf[i + 3]
  1006.           if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  1007.             tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  1008.             if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  1009.               codePoint = tempCodePoint
  1010.             }
  1011.           }
  1012.       }
  1013.     }
  1014.  
  1015.     if (codePoint === null) {
  1016.       // we did not generate a valid codePoint so insert a
  1017.       // replacement char (U+FFFD) and advance only 1 byte
  1018.       codePoint = 0xFFFD
  1019.       bytesPerSequence = 1
  1020.     } else if (codePoint > 0xFFFF) {
  1021.       // encode to utf16 (surrogate pair dance)
  1022.       codePoint -= 0x10000
  1023.       res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  1024.       codePoint = 0xDC00 | codePoint & 0x3FF
  1025.     }
  1026.  
  1027.     res.push(codePoint)
  1028.     i += bytesPerSequence
  1029.   }
  1030.  
  1031.   return decodeCodePointsArray(res)
  1032. }
  1033.  
  1034. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  1035. // the lowest limit is Chrome, with 0x10000 args.
  1036. // We go 1 magnitude less, for safety
  1037. var MAX_ARGUMENTS_LENGTH = 0x1000
  1038.  
  1039. function decodeCodePointsArray (codePoints) {
  1040.   var len = codePoints.length
  1041.   if (len <= MAX_ARGUMENTS_LENGTH) {
  1042.     return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  1043.   }
  1044.  
  1045.   // Decode in chunks to avoid "call stack size exceeded".
  1046.   var res = ''
  1047.   var i = 0
  1048.   while (i < len) {
  1049.     res += String.fromCharCode.apply(
  1050.       String,
  1051.       codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  1052.     )
  1053.   }
  1054.   return res
  1055. }
  1056.  
  1057. function asciiSlice (buf, start, end) {
  1058.   var ret = ''
  1059.   end = Math.min(buf.length, end)
  1060.  
  1061.   for (var i = start; i < end; i++) {
  1062.     ret += String.fromCharCode(buf[i] & 0x7F)
  1063.   }
  1064.   return ret
  1065. }
  1066.  
  1067. function binarySlice (buf, start, end) {
  1068.   var ret = ''
  1069.   end = Math.min(buf.length, end)
  1070.  
  1071.   for (var i = start; i < end; i++) {
  1072.     ret += String.fromCharCode(buf[i])
  1073.   }
  1074.   return ret
  1075. }
  1076.  
  1077. function hexSlice (buf, start, end) {
  1078.   var len = buf.length
  1079.  
  1080.   if (!start || start < 0) start = 0
  1081.   if (!end || end < 0 || end > len) end = len
  1082.  
  1083.   var out = ''
  1084.   for (var i = start; i < end; i++) {
  1085.     out += toHex(buf[i])
  1086.   }
  1087.   return out
  1088. }
  1089.  
  1090. function utf16leSlice (buf, start, end) {
  1091.   var bytes = buf.slice(start, end)
  1092.   var res = ''
  1093.   for (var i = 0; i < bytes.length; i += 2) {
  1094.     res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  1095.   }
  1096.   return res
  1097. }
  1098.  
  1099. Buffer.prototype.slice = function slice (start, end) {
  1100.   var len = this.length
  1101.   start = ~~start
  1102.   end = end === undefined ? len : ~~end
  1103.  
  1104.   if (start < 0) {
  1105.     start += len
  1106.     if (start < 0) start = 0
  1107.   } else if (start > len) {
  1108.     start = len
  1109.   }
  1110.  
  1111.   if (end < 0) {
  1112.     end += len
  1113.     if (end < 0) end = 0
  1114.   } else if (end > len) {
  1115.     end = len
  1116.   }
  1117.  
  1118.   if (end < start) end = start
  1119.  
  1120.   var newBuf
  1121.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  1122.     newBuf = Buffer._augment(this.subarray(start, end))
  1123.   } else {
  1124.     var sliceLen = end - start
  1125.     newBuf = new Buffer(sliceLen, undefined)
  1126.     for (var i = 0; i < sliceLen; i++) {
  1127.       newBuf[i] = this[i + start]
  1128.     }
  1129.   }
  1130.  
  1131.   if (newBuf.length) newBuf.parent = this.parent || this
  1132.  
  1133.   return newBuf
  1134. }
  1135.  
  1136. /*
  1137.  * Need to make sure that buffer isn't trying to write out of bounds.
  1138.  */
  1139. function checkOffset (offset, ext, length) {
  1140.   if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  1141.   if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  1142. }
  1143.  
  1144. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  1145.   offset = offset | 0
  1146.   byteLength = byteLength | 0
  1147.   if (!noAssert) checkOffset(offset, byteLength, this.length)
  1148.  
  1149.   var val = this[offset]
  1150.   var mul = 1
  1151.   var i = 0
  1152.   while (++i < byteLength && (mul *= 0x100)) {
  1153.     val += this[offset + i] * mul
  1154.   }
  1155.  
  1156.   return val
  1157. }
  1158.  
  1159. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  1160.   offset = offset | 0
  1161.   byteLength = byteLength | 0
  1162.   if (!noAssert) {
  1163.     checkOffset(offset, byteLength, this.length)
  1164.   }
  1165.  
  1166.   var val = this[offset + --byteLength]
  1167.   var mul = 1
  1168.   while (byteLength > 0 && (mul *= 0x100)) {
  1169.     val += this[offset + --byteLength] * mul
  1170.   }
  1171.  
  1172.   return val
  1173. }
  1174.  
  1175. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  1176.   if (!noAssert) checkOffset(offset, 1, this.length)
  1177.   return this[offset]
  1178. }
  1179.  
  1180. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  1181.   if (!noAssert) checkOffset(offset, 2, this.length)
  1182.   return this[offset] | (this[offset + 1] << 8)
  1183. }
  1184.  
  1185. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  1186.   if (!noAssert) checkOffset(offset, 2, this.length)
  1187.   return (this[offset] << 8) | this[offset + 1]
  1188. }
  1189.  
  1190. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  1191.   if (!noAssert) checkOffset(offset, 4, this.length)
  1192.  
  1193.   return ((this[offset]) |
  1194.       (this[offset + 1] << 8) |
  1195.       (this[offset + 2] << 16)) +
  1196.       (this[offset + 3] * 0x1000000)
  1197. }
  1198.  
  1199. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  1200.   if (!noAssert) checkOffset(offset, 4, this.length)
  1201.  
  1202.   return (this[offset] * 0x1000000) +
  1203.     ((this[offset + 1] << 16) |
  1204.     (this[offset + 2] << 8) |
  1205.     this[offset + 3])
  1206. }
  1207.  
  1208. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  1209.   offset = offset | 0
  1210.   byteLength = byteLength | 0
  1211.   if (!noAssert) checkOffset(offset, byteLength, this.length)
  1212.  
  1213.   var val = this[offset]
  1214.   var mul = 1
  1215.   var i = 0
  1216.   while (++i < byteLength && (mul *= 0x100)) {
  1217.     val += this[offset + i] * mul
  1218.   }
  1219.   mul *= 0x80
  1220.  
  1221.   if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1222.  
  1223.   return val
  1224. }
  1225.  
  1226. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  1227.   offset = offset | 0
  1228.   byteLength = byteLength | 0
  1229.   if (!noAssert) checkOffset(offset, byteLength, this.length)
  1230.  
  1231.   var i = byteLength
  1232.   var mul = 1
  1233.   var val = this[offset + --i]
  1234.   while (i > 0 && (mul *= 0x100)) {
  1235.     val += this[offset + --i] * mul
  1236.   }
  1237.   mul *= 0x80
  1238.  
  1239.   if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1240.  
  1241.   return val
  1242. }
  1243.  
  1244. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  1245.   if (!noAssert) checkOffset(offset, 1, this.length)
  1246.   if (!(this[offset] & 0x80)) return (this[offset])
  1247.   return ((0xff - this[offset] + 1) * -1)
  1248. }
  1249.  
  1250. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  1251.   if (!noAssert) checkOffset(offset, 2, this.length)
  1252.   var val = this[offset] | (this[offset + 1] << 8)
  1253.   return (val & 0x8000) ? val | 0xFFFF0000 : val
  1254. }
  1255.  
  1256. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  1257.   if (!noAssert) checkOffset(offset, 2, this.length)
  1258.   var val = this[offset + 1] | (this[offset] << 8)
  1259.   return (val & 0x8000) ? val | 0xFFFF0000 : val
  1260. }
  1261.  
  1262. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  1263.   if (!noAssert) checkOffset(offset, 4, this.length)
  1264.  
  1265.   return (this[offset]) |
  1266.     (this[offset + 1] << 8) |
  1267.     (this[offset + 2] << 16) |
  1268.     (this[offset + 3] << 24)
  1269. }
  1270.  
  1271. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  1272.   if (!noAssert) checkOffset(offset, 4, this.length)
  1273.  
  1274.   return (this[offset] << 24) |
  1275.     (this[offset + 1] << 16) |
  1276.     (this[offset + 2] << 8) |
  1277.     (this[offset + 3])
  1278. }
  1279.  
  1280. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  1281.   if (!noAssert) checkOffset(offset, 4, this.length)
  1282.   return ieee754.read(this, offset, true, 23, 4)
  1283. }
  1284.  
  1285. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  1286.   if (!noAssert) checkOffset(offset, 4, this.length)
  1287.   return ieee754.read(this, offset, false, 23, 4)
  1288. }
  1289.  
  1290. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  1291.   if (!noAssert) checkOffset(offset, 8, this.length)
  1292.   return ieee754.read(this, offset, true, 52, 8)
  1293. }
  1294.  
  1295. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  1296.   if (!noAssert) checkOffset(offset, 8, this.length)
  1297.   return ieee754.read(this, offset, false, 52, 8)
  1298. }
  1299.  
  1300. function checkInt (buf, value, offset, ext, max, min) {
  1301.   if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
  1302.   if (value > max || value < min) throw new RangeError('value is out of bounds')
  1303.   if (offset + ext > buf.length) throw new RangeError('index out of range')
  1304. }
  1305.  
  1306. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  1307.   value = +value
  1308.   offset = offset | 0
  1309.   byteLength = byteLength | 0
  1310.   if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
  1311.  
  1312.   var mul = 1
  1313.   var i = 0
  1314.   this[offset] = value & 0xFF
  1315.   while (++i < byteLength && (mul *= 0x100)) {
  1316.     this[offset + i] = (value / mul) & 0xFF
  1317.   }
  1318.  
  1319.   return offset + byteLength
  1320. }
  1321.  
  1322. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  1323.   value = +value
  1324.   offset = offset | 0
  1325.   byteLength = byteLength | 0
  1326.   if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
  1327.  
  1328.   var i = byteLength - 1
  1329.   var mul = 1
  1330.   this[offset + i] = value & 0xFF
  1331.   while (--i >= 0 && (mul *= 0x100)) {
  1332.     this[offset + i] = (value / mul) & 0xFF
  1333.   }
  1334.  
  1335.   return offset + byteLength
  1336. }
  1337.  
  1338. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  1339.   value = +value
  1340.   offset = offset | 0
  1341.   if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  1342.   if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1343.   this[offset] = (value & 0xff)
  1344.   return offset + 1
  1345. }
  1346.  
  1347. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  1348.   if (value < 0) value = 0xffff + value + 1
  1349.   for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
  1350.     buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  1351.       (littleEndian ? i : 1 - i) * 8
  1352.   }
  1353. }
  1354.  
  1355. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  1356.   value = +value
  1357.   offset = offset | 0
  1358.   if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1359.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  1360.     this[offset] = (value & 0xff)
  1361.     this[offset + 1] = (value >>> 8)
  1362.   } else {
  1363.     objectWriteUInt16(this, value, offset, true)
  1364.   }
  1365.   return offset + 2
  1366. }
  1367.  
  1368. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  1369.   value = +value
  1370.   offset = offset | 0
  1371.   if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1372.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  1373.     this[offset] = (value >>> 8)
  1374.     this[offset + 1] = (value & 0xff)
  1375.   } else {
  1376.     objectWriteUInt16(this, value, offset, false)
  1377.   }
  1378.   return offset + 2
  1379. }
  1380.  
  1381. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  1382.   if (value < 0) value = 0xffffffff + value + 1
  1383.   for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
  1384.     buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  1385.   }
  1386. }
  1387.  
  1388. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  1389.   value = +value
  1390.   offset = offset | 0
  1391.   if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1392.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  1393.     this[offset + 3] = (value >>> 24)
  1394.     this[offset + 2] = (value >>> 16)
  1395.     this[offset + 1] = (value >>> 8)
  1396.     this[offset] = (value & 0xff)
  1397.   } else {
  1398.     objectWriteUInt32(this, value, offset, true)
  1399.   }
  1400.   return offset + 4
  1401. }
  1402.  
  1403. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  1404.   value = +value
  1405.   offset = offset | 0
  1406.   if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1407.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  1408.     this[offset] = (value >>> 24)
  1409.     this[offset + 1] = (value >>> 16)
  1410.     this[offset + 2] = (value >>> 8)
  1411.     this[offset + 3] = (value & 0xff)
  1412.   } else {
  1413.     objectWriteUInt32(this, value, offset, false)
  1414.   }
  1415.   return offset + 4
  1416. }
  1417.  
  1418. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  1419.   value = +value
  1420.   offset = offset | 0
  1421.   if (!noAssert) {
  1422.     var limit = Math.pow(2, 8 * byteLength - 1)
  1423.  
  1424.     checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1425.   }
  1426.  
  1427.   var i = 0
  1428.   var mul = 1
  1429.   var sub = value < 0 ? 1 : 0
  1430.   this[offset] = value & 0xFF
  1431.   while (++i < byteLength && (mul *= 0x100)) {
  1432.     this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1433.   }
  1434.  
  1435.   return offset + byteLength
  1436. }
  1437.  
  1438. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  1439.   value = +value
  1440.   offset = offset | 0
  1441.   if (!noAssert) {
  1442.     var limit = Math.pow(2, 8 * byteLength - 1)
  1443.  
  1444.     checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1445.   }
  1446.  
  1447.   var i = byteLength - 1
  1448.   var mul = 1
  1449.   var sub = value < 0 ? 1 : 0
  1450.   this[offset + i] = value & 0xFF
  1451.   while (--i >= 0 && (mul *= 0x100)) {
  1452.     this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1453.   }
  1454.  
  1455.   return offset + byteLength
  1456. }
  1457.  
  1458. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  1459.   value = +value
  1460.   offset = offset | 0
  1461.   if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  1462.   if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1463.   if (value < 0) value = 0xff + value + 1
  1464.   this[offset] = (value & 0xff)
  1465.   return offset + 1
  1466. }
  1467.  
  1468. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  1469.   value = +value
  1470.   offset = offset | 0
  1471.   if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1472.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  1473.     this[offset] = (value & 0xff)
  1474.     this[offset + 1] = (value >>> 8)
  1475.   } else {
  1476.     objectWriteUInt16(this, value, offset, true)
  1477.   }
  1478.   return offset + 2
  1479. }
  1480.  
  1481. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  1482.   value = +value
  1483.   offset = offset | 0
  1484.   if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1485.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  1486.     this[offset] = (value >>> 8)
  1487.     this[offset + 1] = (value & 0xff)
  1488.   } else {
  1489.     objectWriteUInt16(this, value, offset, false)
  1490.   }
  1491.   return offset + 2
  1492. }
  1493.  
  1494. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  1495.   value = +value
  1496.   offset = offset | 0
  1497.   if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1498.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  1499.     this[offset] = (value & 0xff)
  1500.     this[offset + 1] = (value >>> 8)
  1501.     this[offset + 2] = (value >>> 16)
  1502.     this[offset + 3] = (value >>> 24)
  1503.   } else {
  1504.     objectWriteUInt32(this, value, offset, true)
  1505.   }
  1506.   return offset + 4
  1507. }
  1508.  
  1509. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  1510.   value = +value
  1511.   offset = offset | 0
  1512.   if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1513.   if (value < 0) value = 0xffffffff + value + 1
  1514.   if (Buffer.TYPED_ARRAY_SUPPORT) {
  1515.     this[offset] = (value >>> 24)
  1516.     this[offset + 1] = (value >>> 16)
  1517.     this[offset + 2] = (value >>> 8)
  1518.     this[offset + 3] = (value & 0xff)
  1519.   } else {
  1520.     objectWriteUInt32(this, value, offset, false)
  1521.   }
  1522.   return offset + 4
  1523. }
  1524.  
  1525. function checkIEEE754 (buf, value, offset, ext, max, min) {
  1526.   if (value > max || value < min) throw new RangeError('value is out of bounds')
  1527.   if (offset + ext > buf.length) throw new RangeError('index out of range')
  1528.   if (offset < 0) throw new RangeError('index out of range')
  1529. }
  1530.  
  1531. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  1532.   if (!noAssert) {
  1533.     checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  1534.   }
  1535.   ieee754.write(buf, value, offset, littleEndian, 23, 4)
  1536.   return offset + 4
  1537. }
  1538.  
  1539. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  1540.   return writeFloat(this, value, offset, true, noAssert)
  1541. }
  1542.  
  1543. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  1544.   return writeFloat(this, value, offset, false, noAssert)
  1545. }
  1546.  
  1547. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  1548.   if (!noAssert) {
  1549.     checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  1550.   }
  1551.   ieee754.write(buf, value, offset, littleEndian, 52, 8)
  1552.   return offset + 8
  1553. }
  1554.  
  1555. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  1556.   return writeDouble(this, value, offset, true, noAssert)
  1557. }
  1558.  
  1559. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  1560.   return writeDouble(this, value, offset, false, noAssert)
  1561. }
  1562.  
  1563. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  1564. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  1565.   if (!start) start = 0
  1566.   if (!end && end !== 0) end = this.length
  1567.   if (targetStart >= target.length) targetStart = target.length
  1568.   if (!targetStart) targetStart = 0
  1569.   if (end > 0 && end < start) end = start
  1570.  
  1571.   // Copy 0 bytes; we're done
  1572.   if (end === start) return 0
  1573.   if (target.length === 0 || this.length === 0) return 0
  1574.  
  1575.   // Fatal error conditions
  1576.   if (targetStart < 0) {
  1577.     throw new RangeError('targetStart out of bounds')
  1578.   }
  1579.   if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  1580.   if (end < 0) throw new RangeError('sourceEnd out of bounds')
  1581.  
  1582.   // Are we oob?
  1583.   if (end > this.length) end = this.length
  1584.   if (target.length - targetStart < end - start) {
  1585.     end = target.length - targetStart + start
  1586.   }
  1587.  
  1588.   var len = end - start
  1589.   var i
  1590.  
  1591.   if (this === target && start < targetStart && targetStart < end) {
  1592.     // descending copy from end
  1593.     for (i = len - 1; i >= 0; i--) {
  1594.       target[i + targetStart] = this[i + start]
  1595.     }
  1596.   } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  1597.     // ascending copy from start
  1598.     for (i = 0; i < len; i++) {
  1599.       target[i + targetStart] = this[i + start]
  1600.     }
  1601.   } else {
  1602.     target._set(this.subarray(start, start + len), targetStart)
  1603.   }
  1604.  
  1605.   return len
  1606. }
  1607.  
  1608. // fill(value, start=0, end=buffer.length)
  1609. Buffer.prototype.fill = function fill (value, start, end) {
  1610.   if (!value) value = 0
  1611.   if (!start) start = 0
  1612.   if (!end) end = this.length
  1613.  
  1614.   if (end < start) throw new RangeError('end < start')
  1615.  
  1616.   // Fill 0 bytes; we're done
  1617.   if (end === start) return
  1618.   if (this.length === 0) return
  1619.  
  1620.   if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
  1621.   if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
  1622.  
  1623.   var i
  1624.   if (typeof value === 'number') {
  1625.     for (i = start; i < end; i++) {
  1626.       this[i] = value
  1627.     }
  1628.   } else {
  1629.     var bytes = utf8ToBytes(value.toString())
  1630.     var len = bytes.length
  1631.     for (i = start; i < end; i++) {
  1632.       this[i] = bytes[i % len]
  1633.     }
  1634.   }
  1635.  
  1636.   return this
  1637. }
  1638.  
  1639. /**
  1640.  * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
  1641.  * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
  1642.  */
  1643. Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
  1644.   if (typeof Uint8Array !== 'undefined') {
  1645.     if (Buffer.TYPED_ARRAY_SUPPORT) {
  1646.       return (new Buffer(this)).buffer
  1647.     } else {
  1648.       var buf = new Uint8Array(this.length)
  1649.       for (var i = 0, len = buf.length; i < len; i += 1) {
  1650.         buf[i] = this[i]
  1651.       }
  1652.       return buf.buffer
  1653.     }
  1654.   } else {
  1655.     throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
  1656.   }
  1657. }
  1658.  
  1659. // HELPER FUNCTIONS
  1660. // ================
  1661.  
  1662. var BP = Buffer.prototype
  1663.  
  1664. /**
  1665.  * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
  1666.  */
  1667. Buffer._augment = function _augment (arr) {
  1668.   arr.constructor = Buffer
  1669.   arr._isBuffer = true
  1670.  
  1671.   // save reference to original Uint8Array set method before overwriting
  1672.   arr._set = arr.set
  1673.  
  1674.   // deprecated
  1675.   arr.get = BP.get
  1676.   arr.set = BP.set
  1677.  
  1678.   arr.write = BP.write
  1679.   arr.toString = BP.toString
  1680.   arr.toLocaleString = BP.toString
  1681.   arr.toJSON = BP.toJSON
  1682.   arr.equals = BP.equals
  1683.   arr.compare = BP.compare
  1684.   arr.indexOf = BP.indexOf
  1685.   arr.copy = BP.copy
  1686.   arr.slice = BP.slice
  1687.   arr.readUIntLE = BP.readUIntLE
  1688.   arr.readUIntBE = BP.readUIntBE
  1689.   arr.readUInt8 = BP.readUInt8
  1690.   arr.readUInt16LE = BP.readUInt16LE
  1691.   arr.readUInt16BE = BP.readUInt16BE
  1692.   arr.readUInt32LE = BP.readUInt32LE
  1693.   arr.readUInt32BE = BP.readUInt32BE
  1694.   arr.readIntLE = BP.readIntLE
  1695.   arr.readIntBE = BP.readIntBE
  1696.   arr.readInt8 = BP.readInt8
  1697.   arr.readInt16LE = BP.readInt16LE
  1698.   arr.readInt16BE = BP.readInt16BE
  1699.   arr.readInt32LE = BP.readInt32LE
  1700.   arr.readInt32BE = BP.readInt32BE
  1701.   arr.readFloatLE = BP.readFloatLE
  1702.   arr.readFloatBE = BP.readFloatBE
  1703.   arr.readDoubleLE = BP.readDoubleLE
  1704.   arr.readDoubleBE = BP.readDoubleBE
  1705.   arr.writeUInt8 = BP.writeUInt8
  1706.   arr.writeUIntLE = BP.writeUIntLE
  1707.   arr.writeUIntBE = BP.writeUIntBE
  1708.   arr.writeUInt16LE = BP.writeUInt16LE
  1709.   arr.writeUInt16BE = BP.writeUInt16BE
  1710.   arr.writeUInt32LE = BP.writeUInt32LE
  1711.   arr.writeUInt32BE = BP.writeUInt32BE
  1712.   arr.writeIntLE = BP.writeIntLE
  1713.   arr.writeIntBE = BP.writeIntBE
  1714.   arr.writeInt8 = BP.writeInt8
  1715.   arr.writeInt16LE = BP.writeInt16LE
  1716.   arr.writeInt16BE = BP.writeInt16BE
  1717.   arr.writeInt32LE = BP.writeInt32LE
  1718.   arr.writeInt32BE = BP.writeInt32BE
  1719.   arr.writeFloatLE = BP.writeFloatLE
  1720.   arr.writeFloatBE = BP.writeFloatBE
  1721.   arr.writeDoubleLE = BP.writeDoubleLE
  1722.   arr.writeDoubleBE = BP.writeDoubleBE
  1723.   arr.fill = BP.fill
  1724.   arr.inspect = BP.inspect
  1725.   arr.toArrayBuffer = BP.toArrayBuffer
  1726.  
  1727.   return arr
  1728. }
  1729.  
  1730. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  1731.  
  1732. function base64clean (str) {
  1733.   // Node strips out invalid characters like \n and \t from the string, base64-js does not
  1734.   str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  1735.   // Node converts strings with length < 2 to ''
  1736.   if (str.length < 2) return ''
  1737.   // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  1738.   while (str.length % 4 !== 0) {
  1739.     str = str + '='
  1740.   }
  1741.   return str
  1742. }
  1743.  
  1744. function stringtrim (str) {
  1745.   if (str.trim) return str.trim()
  1746.   return str.replace(/^\s+|\s+$/g, '')
  1747. }
  1748.  
  1749. function toHex (n) {
  1750.   if (n < 16) return '0' + n.toString(16)
  1751.   return n.toString(16)
  1752. }
  1753.  
  1754. function utf8ToBytes (string, units) {
  1755.   units = units || Infinity
  1756.   var codePoint
  1757.   var length = string.length
  1758.   var leadSurrogate = null
  1759.   var bytes = []
  1760.  
  1761.   for (var i = 0; i < length; i++) {
  1762.     codePoint = string.charCodeAt(i)
  1763.  
  1764.     // is surrogate component
  1765.     if (codePoint > 0xD7FF && codePoint < 0xE000) {
  1766.       // last char was a lead
  1767.       if (!leadSurrogate) {
  1768.         // no lead yet
  1769.         if (codePoint > 0xDBFF) {
  1770.           // unexpected trail
  1771.           if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1772.           continue
  1773.         } else if (i + 1 === length) {
  1774.           // unpaired lead
  1775.           if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1776.           continue
  1777.         }
  1778.  
  1779.         // valid lead
  1780.         leadSurrogate = codePoint
  1781.  
  1782.         continue
  1783.       }
  1784.  
  1785.       // 2 leads in a row
  1786.       if (codePoint < 0xDC00) {
  1787.         if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1788.         leadSurrogate = codePoint
  1789.         continue
  1790.       }
  1791.  
  1792.       // valid surrogate pair
  1793.       codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
  1794.     } else if (leadSurrogate) {
  1795.       // valid bmp char, but last char was a lead
  1796.       if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1797.     }
  1798.  
  1799.     leadSurrogate = null
  1800.  
  1801.     // encode utf8
  1802.     if (codePoint < 0x80) {
  1803.       if ((units -= 1) < 0) break
  1804.       bytes.push(codePoint)
  1805.     } else if (codePoint < 0x800) {
  1806.       if ((units -= 2) < 0) break
  1807.       bytes.push(
  1808.         codePoint >> 0x6 | 0xC0,
  1809.         codePoint & 0x3F | 0x80
  1810.       )
  1811.     } else if (codePoint < 0x10000) {
  1812.       if ((units -= 3) < 0) break
  1813.       bytes.push(
  1814.         codePoint >> 0xC | 0xE0,
  1815.         codePoint >> 0x6 & 0x3F | 0x80,
  1816.         codePoint & 0x3F | 0x80
  1817.       )
  1818.     } else if (codePoint < 0x110000) {
  1819.       if ((units -= 4) < 0) break
  1820.       bytes.push(
  1821.         codePoint >> 0x12 | 0xF0,
  1822.         codePoint >> 0xC & 0x3F | 0x80,
  1823.         codePoint >> 0x6 & 0x3F | 0x80,
  1824.         codePoint & 0x3F | 0x80
  1825.       )
  1826.     } else {
  1827.       throw new Error('Invalid code point')
  1828.     }
  1829.   }
  1830.  
  1831.   return bytes
  1832. }
  1833.  
  1834. function asciiToBytes (str) {
  1835.   var byteArray = []
  1836.   for (var i = 0; i < str.length; i++) {
  1837.     // Node's code seems to be doing this and not & 0x7F..
  1838.     byteArray.push(str.charCodeAt(i) & 0xFF)
  1839.   }
  1840.   return byteArray
  1841. }
  1842.  
  1843. function utf16leToBytes (str, units) {
  1844.   var c, hi, lo
  1845.   var byteArray = []
  1846.   for (var i = 0; i < str.length; i++) {
  1847.     if ((units -= 2) < 0) break
  1848.  
  1849.     c = str.charCodeAt(i)
  1850.     hi = c >> 8
  1851.     lo = c % 256
  1852.     byteArray.push(lo)
  1853.     byteArray.push(hi)
  1854.   }
  1855.  
  1856.   return byteArray
  1857. }
  1858.  
  1859. function base64ToBytes (str) {
  1860.   return base64.toByteArray(base64clean(str))
  1861. }
  1862.  
  1863. function blitBuffer (src, dst, offset, length) {
  1864.   for (var i = 0; i < length; i++) {
  1865.     if ((i + offset >= dst.length) || (i >= src.length)) break
  1866.     dst[i + offset] = src[i]
  1867.   }
  1868.   return i
  1869. }
  1870.  
  1871. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  1872. },{"base64-js":2,"ieee754":3,"is-array":4}],2:[function(require,module,exports){
  1873. var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  1874.  
  1875. ;(function (exports) {
  1876.     'use strict';
  1877.  
  1878.   var Arr = (typeof Uint8Array !== 'undefined')
  1879.     ? Uint8Array
  1880.     : Array
  1881.  
  1882.     var PLUS   = '+'.charCodeAt(0)
  1883.     var SLASH  = '/'.charCodeAt(0)
  1884.     var NUMBER = '0'.charCodeAt(0)
  1885.     var LOWER  = 'a'.charCodeAt(0)
  1886.     var UPPER  = 'A'.charCodeAt(0)
  1887.     var PLUS_URL_SAFE = '-'.charCodeAt(0)
  1888.     var SLASH_URL_SAFE = '_'.charCodeAt(0)
  1889.  
  1890.     function decode (elt) {
  1891.         var code = elt.charCodeAt(0)
  1892.         if (code === PLUS ||
  1893.             code === PLUS_URL_SAFE)
  1894.             return 62 // '+'
  1895.         if (code === SLASH ||
  1896.             code === SLASH_URL_SAFE)
  1897.             return 63 // '/'
  1898.         if (code < NUMBER)
  1899.             return -1 //no match
  1900.         if (code < NUMBER + 10)
  1901.             return code - NUMBER + 26 + 26
  1902.         if (code < UPPER + 26)
  1903.             return code - UPPER
  1904.         if (code < LOWER + 26)
  1905.             return code - LOWER + 26
  1906.     }
  1907.  
  1908.     function b64ToByteArray (b64) {
  1909.         var i, j, l, tmp, placeHolders, arr
  1910.  
  1911.         if (b64.length % 4 > 0) {
  1912.             throw new Error('Invalid string. Length must be a multiple of 4')
  1913.         }
  1914.  
  1915.         // the number of equal signs (place holders)
  1916.         // if there are two placeholders, than the two characters before it
  1917.         // represent one byte
  1918.         // if there is only one, then the three characters before it represent 2 bytes
  1919.         // this is just a cheap hack to not do indexOf twice
  1920.         var len = b64.length
  1921.         placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
  1922.  
  1923.         // base64 is 4/3 + up to two characters of the original data
  1924.         arr = new Arr(b64.length * 3 / 4 - placeHolders)
  1925.  
  1926.         // if there are placeholders, only get up to the last complete 4 chars
  1927.         l = placeHolders > 0 ? b64.length - 4 : b64.length
  1928.  
  1929.         var L = 0
  1930.  
  1931.         function push (v) {
  1932.             arr[L++] = v
  1933.         }
  1934.  
  1935.         for (i = 0, j = 0; i < l; i += 4, j += 3) {
  1936.             tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
  1937.             push((tmp & 0xFF0000) >> 16)
  1938.             push((tmp & 0xFF00) >> 8)
  1939.             push(tmp & 0xFF)
  1940.         }
  1941.  
  1942.         if (placeHolders === 2) {
  1943.             tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
  1944.             push(tmp & 0xFF)
  1945.         } else if (placeHolders === 1) {
  1946.             tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
  1947.             push((tmp >> 8) & 0xFF)
  1948.             push(tmp & 0xFF)
  1949.         }
  1950.  
  1951.         return arr
  1952.     }
  1953.  
  1954.     function uint8ToBase64 (uint8) {
  1955.         var i,
  1956.             extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
  1957.             output = "",
  1958.             temp, length
  1959.  
  1960.         function encode (num) {
  1961.             return lookup.charAt(num)
  1962.         }
  1963.  
  1964.         function tripletToBase64 (num) {
  1965.             return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
  1966.         }
  1967.  
  1968.         // go through the array every three bytes, we'll deal with trailing stuff later
  1969.         for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
  1970.             temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  1971.             output += tripletToBase64(temp)
  1972.         }
  1973.  
  1974.         // pad the end with zeros, but make sure to not forget the extra bytes
  1975.         switch (extraBytes) {
  1976.             case 1:
  1977.                 temp = uint8[uint8.length - 1]
  1978.                 output += encode(temp >> 2)
  1979.                 output += encode((temp << 4) & 0x3F)
  1980.                 output += '=='
  1981.                 break
  1982.             case 2:
  1983.                 temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
  1984.                 output += encode(temp >> 10)
  1985.                 output += encode((temp >> 4) & 0x3F)
  1986.                 output += encode((temp << 2) & 0x3F)
  1987.                 output += '='
  1988.                 break
  1989.         }
  1990.  
  1991.         return output
  1992.     }
  1993.  
  1994.     exports.toByteArray = b64ToByteArray
  1995.     exports.fromByteArray = uint8ToBase64
  1996. }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
  1997.  
  1998. },{}],3:[function(require,module,exports){
  1999. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  2000.   var e, m
  2001.   var eLen = nBytes * 8 - mLen - 1
  2002.   var eMax = (1 << eLen) - 1
  2003.   var eBias = eMax >> 1
  2004.   var nBits = -7
  2005.   var i = isLE ? (nBytes - 1) : 0
  2006.   var d = isLE ? -1 : 1
  2007.   var s = buffer[offset + i]
  2008.  
  2009.   i += d
  2010.  
  2011.   e = s & ((1 << (-nBits)) - 1)
  2012.   s >>= (-nBits)
  2013.   nBits += eLen
  2014.   for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  2015.  
  2016.   m = e & ((1 << (-nBits)) - 1)
  2017.   e >>= (-nBits)
  2018.   nBits += mLen
  2019.   for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  2020.  
  2021.   if (e === 0) {
  2022.     e = 1 - eBias
  2023.   } else if (e === eMax) {
  2024.     return m ? NaN : ((s ? -1 : 1) * Infinity)
  2025.   } else {
  2026.     m = m + Math.pow(2, mLen)
  2027.     e = e - eBias
  2028.   }
  2029.   return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  2030. }
  2031.  
  2032. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  2033.   var e, m, c
  2034.   var eLen = nBytes * 8 - mLen - 1
  2035.   var eMax = (1 << eLen) - 1
  2036.   var eBias = eMax >> 1
  2037.   var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  2038.   var i = isLE ? 0 : (nBytes - 1)
  2039.   var d = isLE ? 1 : -1
  2040.   var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  2041.  
  2042.   value = Math.abs(value)
  2043.  
  2044.   if (isNaN(value) || value === Infinity) {
  2045.     m = isNaN(value) ? 1 : 0
  2046.     e = eMax
  2047.   } else {
  2048.     e = Math.floor(Math.log(value) / Math.LN2)
  2049.     if (value * (c = Math.pow(2, -e)) < 1) {
  2050.       e--
  2051.       c *= 2
  2052.     }
  2053.     if (e + eBias >= 1) {
  2054.       value += rt / c
  2055.     } else {
  2056.       value += rt * Math.pow(2, 1 - eBias)
  2057.     }
  2058.     if (value * c >= 2) {
  2059.       e++
  2060.       c /= 2
  2061.     }
  2062.  
  2063.     if (e + eBias >= eMax) {
  2064.       m = 0
  2065.       e = eMax
  2066.     } else if (e + eBias >= 1) {
  2067.       m = (value * c - 1) * Math.pow(2, mLen)
  2068.       e = e + eBias
  2069.     } else {
  2070.       m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  2071.       e = 0
  2072.     }
  2073.   }
  2074.  
  2075.   for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  2076.  
  2077.   e = (e << mLen) | m
  2078.   eLen += mLen
  2079.   for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  2080.  
  2081.   buffer[offset + i - d] |= s * 128
  2082. }
  2083.  
  2084. },{}],4:[function(require,module,exports){
  2085.  
  2086. /**
  2087.  * isArray
  2088.  */
  2089.  
  2090. var isArray = Array.isArray;
  2091.  
  2092. /**
  2093.  * toString
  2094.  */
  2095.  
  2096. var str = Object.prototype.toString;
  2097.  
  2098. /**
  2099.  * Whether or not the given `val`
  2100.  * is an array.
  2101.  *
  2102.  * example:
  2103.  *
  2104.  *        isArray([]);
  2105.  *        // > true
  2106.  *        isArray(arguments);
  2107.  *        // > false
  2108.  *        isArray('');
  2109.  *        // > false
  2110.  *
  2111.  * @param {mixed} val
  2112.  * @return {bool}
  2113.  */
  2114.  
  2115. module.exports = isArray || function (val) {
  2116.   return !! val && '[object Array]' == str.call(val);
  2117. };
  2118.  
  2119. },{}],5:[function(require,module,exports){
  2120. if (typeof Object.create === 'function') {
  2121.   // implementation from standard node.js 'util' module
  2122.   module.exports = function inherits(ctor, superCtor) {
  2123.     ctor.super_ = superCtor
  2124.     ctor.prototype = Object.create(superCtor.prototype, {
  2125.       constructor: {
  2126.         value: ctor,
  2127.         enumerable: false,
  2128.         writable: true,
  2129.         configurable: true
  2130.       }
  2131.     });
  2132.   };
  2133. } else {
  2134.   // old school shim for old browsers
  2135.   module.exports = function inherits(ctor, superCtor) {
  2136.     ctor.super_ = superCtor
  2137.     var TempCtor = function () {}
  2138.     TempCtor.prototype = superCtor.prototype
  2139.     ctor.prototype = new TempCtor()
  2140.     ctor.prototype.constructor = ctor
  2141.   }
  2142. }
  2143.  
  2144. },{}],6:[function(require,module,exports){
  2145. // shim for using process in browser
  2146.  
  2147. var process = module.exports = {};
  2148. var queue = [];
  2149. var draining = false;
  2150. var currentQueue;
  2151. var queueIndex = -1;
  2152.  
  2153. function cleanUpNextTick() {
  2154.     draining = false;
  2155.     if (currentQueue.length) {
  2156.         queue = currentQueue.concat(queue);
  2157.     } else {
  2158.         queueIndex = -1;
  2159.     }
  2160.     if (queue.length) {
  2161.         drainQueue();
  2162.     }
  2163. }
  2164.  
  2165. function drainQueue() {
  2166.     if (draining) {
  2167.         return;
  2168.     }
  2169.     var timeout = setTimeout(cleanUpNextTick);
  2170.     draining = true;
  2171.  
  2172.     var len = queue.length;
  2173.     while(len) {
  2174.         currentQueue = queue;
  2175.         queue = [];
  2176.         while (++queueIndex < len) {
  2177.             if (currentQueue) {
  2178.                 currentQueue[queueIndex].run();
  2179.             }
  2180.         }
  2181.         queueIndex = -1;
  2182.         len = queue.length;
  2183.     }
  2184.     currentQueue = null;
  2185.     draining = false;
  2186.     clearTimeout(timeout);
  2187. }
  2188.  
  2189. process.nextTick = function (fun) {
  2190.     var args = new Array(arguments.length - 1);
  2191.     if (arguments.length > 1) {
  2192.         for (var i = 1; i < arguments.length; i++) {
  2193.             args[i - 1] = arguments[i];
  2194.         }
  2195.     }
  2196.     queue.push(new Item(fun, args));
  2197.     if (queue.length === 1 && !draining) {
  2198.         setTimeout(drainQueue, 0);
  2199.     }
  2200. };
  2201.  
  2202. // v8 likes predictible objects
  2203. function Item(fun, array) {
  2204.     this.fun = fun;
  2205.     this.array = array;
  2206. }
  2207. Item.prototype.run = function () {
  2208.     this.fun.apply(null, this.array);
  2209. };
  2210. process.title = 'browser';
  2211. process.browser = true;
  2212. process.env = {};
  2213. process.argv = [];
  2214. process.version = ''; // empty string to avoid regexp issues
  2215. process.versions = {};
  2216.  
  2217. function noop() {}
  2218.  
  2219. process.on = noop;
  2220. process.addListener = noop;
  2221. process.once = noop;
  2222. process.off = noop;
  2223. process.removeListener = noop;
  2224. process.removeAllListeners = noop;
  2225. process.emit = noop;
  2226.  
  2227. process.binding = function (name) {
  2228.     throw new Error('process.binding is not supported');
  2229. };
  2230.  
  2231. process.cwd = function () { return '/' };
  2232. process.chdir = function (dir) {
  2233.     throw new Error('process.chdir is not supported');
  2234. };
  2235. process.umask = function() { return 0; };
  2236.  
  2237. },{}],7:[function(require,module,exports){
  2238. module.exports = function isBuffer(arg) {
  2239.   return arg && typeof arg === 'object'
  2240.     && typeof arg.copy === 'function'
  2241.     && typeof arg.fill === 'function'
  2242.     && typeof arg.readUInt8 === 'function';
  2243. }
  2244. },{}],8:[function(require,module,exports){
  2245. (function (process,global){
  2246. // Copyright Joyent, Inc. and other Node contributors.
  2247. //
  2248. // Permission is hereby granted, free of charge, to any person obtaining a
  2249. // copy of this software and associated documentation files (the
  2250. // "Software"), to deal in the Software without restriction, including
  2251. // without limitation the rights to use, copy, modify, merge, publish,
  2252. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2253. // persons to whom the Software is furnished to do so, subject to the
  2254. // following conditions:
  2255. //
  2256. // The above copyright notice and this permission notice shall be included
  2257. // in all copies or substantial portions of the Software.
  2258. //
  2259. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2260. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2261. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2262. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2263. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2264. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2265. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2266.  
  2267. var formatRegExp = /%[sdj%]/g;
  2268. exports.format = function(f) {
  2269.   if (!isString(f)) {
  2270.     var objects = [];
  2271.     for (var i = 0; i < arguments.length; i++) {
  2272.       objects.push(inspect(arguments[i]));
  2273.     }
  2274.     return objects.join(' ');
  2275.   }
  2276.  
  2277.   var i = 1;
  2278.   var args = arguments;
  2279.   var len = args.length;
  2280.   var str = String(f).replace(formatRegExp, function(x) {
  2281.     if (x === '%%') return '%';
  2282.     if (i >= len) return x;
  2283.     switch (x) {
  2284.       case '%s': return String(args[i++]);
  2285.       case '%d': return Number(args[i++]);
  2286.       case '%j':
  2287.         try {
  2288.           return JSON.stringify(args[i++]);
  2289.         } catch (_) {
  2290.           return '[Circular]';
  2291.         }
  2292.       default:
  2293.         return x;
  2294.     }
  2295.   });
  2296.   for (var x = args[i]; i < len; x = args[++i]) {
  2297.     if (isNull(x) || !isObject(x)) {
  2298.       str += ' ' + x;
  2299.     } else {
  2300.       str += ' ' + inspect(x);
  2301.     }
  2302.   }
  2303.   return str;
  2304. };
  2305.  
  2306.  
  2307. // Mark that a method should not be used.
  2308. // Returns a modified function which warns once by default.
  2309. // If --no-deprecation is set, then it is a no-op.
  2310. exports.deprecate = function(fn, msg) {
  2311.   // Allow for deprecating things in the process of starting up.
  2312.   if (isUndefined(global.process)) {
  2313.     return function() {
  2314.       return exports.deprecate(fn, msg).apply(this, arguments);
  2315.     };
  2316.   }
  2317.  
  2318.   if (process.noDeprecation === true) {
  2319.     return fn;
  2320.   }
  2321.  
  2322.   var warned = false;
  2323.   function deprecated() {
  2324.     if (!warned) {
  2325.       if (process.throwDeprecation) {
  2326.         throw new Error(msg);
  2327.       } else if (process.traceDeprecation) {
  2328.         console.trace(msg);
  2329.       } else {
  2330.         console.error(msg);
  2331.       }
  2332.       warned = true;
  2333.     }
  2334.     return fn.apply(this, arguments);
  2335.   }
  2336.  
  2337.   return deprecated;
  2338. };
  2339.  
  2340.  
  2341. var debugs = {};
  2342. var debugEnviron;
  2343. exports.debuglog = function(set) {
  2344.   if (isUndefined(debugEnviron))
  2345.     debugEnviron = process.env.NODE_DEBUG || '';
  2346.   set = set.toUpperCase();
  2347.   if (!debugs[set]) {
  2348.     if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  2349.       var pid = process.pid;
  2350.       debugs[set] = function() {
  2351.         var msg = exports.format.apply(exports, arguments);
  2352.         console.error('%s %d: %s', set, pid, msg);
  2353.       };
  2354.     } else {
  2355.       debugs[set] = function() {};
  2356.     }
  2357.   }
  2358.   return debugs[set];
  2359. };
  2360.  
  2361.  
  2362. /**
  2363.  * Echos the value of a value. Trys to print the value out
  2364.  * in the best way possible given the different types.
  2365.  *
  2366.  * @param {Object} obj The object to print out.
  2367.  * @param {Object} opts Optional options object that alters the output.
  2368.  */
  2369. /* legacy: obj, showHidden, depth, colors*/
  2370. function inspect(obj, opts) {
  2371.   // default options
  2372.   var ctx = {
  2373.     seen: [],
  2374.     stylize: stylizeNoColor
  2375.   };
  2376.   // legacy...
  2377.   if (arguments.length >= 3) ctx.depth = arguments[2];
  2378.   if (arguments.length >= 4) ctx.colors = arguments[3];
  2379.   if (isBoolean(opts)) {
  2380.     // legacy...
  2381.     ctx.showHidden = opts;
  2382.   } else if (opts) {
  2383.     // got an "options" object
  2384.     exports._extend(ctx, opts);
  2385.   }
  2386.   // set default options
  2387.   if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  2388.   if (isUndefined(ctx.depth)) ctx.depth = 2;
  2389.   if (isUndefined(ctx.colors)) ctx.colors = false;
  2390.   if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  2391.   if (ctx.colors) ctx.stylize = stylizeWithColor;
  2392.   return formatValue(ctx, obj, ctx.depth);
  2393. }
  2394. exports.inspect = inspect;
  2395.  
  2396.  
  2397. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  2398. inspect.colors = {
  2399.   'bold' : [1, 22],
  2400.   'italic' : [3, 23],
  2401.   'underline' : [4, 24],
  2402.   'inverse' : [7, 27],
  2403.   'white' : [37, 39],
  2404.   'grey' : [90, 39],
  2405.   'black' : [30, 39],
  2406.   'blue' : [34, 39],
  2407.   'cyan' : [36, 39],
  2408.   'green' : [32, 39],
  2409.   'magenta' : [35, 39],
  2410.   'red' : [31, 39],
  2411.   'yellow' : [33, 39]
  2412. };
  2413.  
  2414. // Don't use 'blue' not visible on cmd.exe
  2415. inspect.styles = {
  2416.   'special': 'cyan',
  2417.   'number': 'yellow',
  2418.   'boolean': 'yellow',
  2419.   'undefined': 'grey',
  2420.   'null': 'bold',
  2421.   'string': 'green',
  2422.   'date': 'magenta',
  2423.   // "name": intentionally not styling
  2424.   'regexp': 'red'
  2425. };
  2426.  
  2427.  
  2428. function stylizeWithColor(str, styleType) {
  2429.   var style = inspect.styles[styleType];
  2430.  
  2431.   if (style) {
  2432.     return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  2433.            '\u001b[' + inspect.colors[style][1] + 'm';
  2434.   } else {
  2435.     return str;
  2436.   }
  2437. }
  2438.  
  2439.  
  2440. function stylizeNoColor(str, styleType) {
  2441.   return str;
  2442. }
  2443.  
  2444.  
  2445. function arrayToHash(array) {
  2446.   var hash = {};
  2447.  
  2448.   array.forEach(function(val, idx) {
  2449.     hash[val] = true;
  2450.   });
  2451.  
  2452.   return hash;
  2453. }
  2454.  
  2455.  
  2456. function formatValue(ctx, value, recurseTimes) {
  2457.   // Provide a hook for user-specified inspect functions.
  2458.   // Check that value is an object with an inspect function on it
  2459.   if (ctx.customInspect &&
  2460.       value &&
  2461.       isFunction(value.inspect) &&
  2462.       // Filter out the util module, it's inspect function is special
  2463.       value.inspect !== exports.inspect &&
  2464.       // Also filter out any prototype objects using the circular check.
  2465.       !(value.constructor && value.constructor.prototype === value)) {
  2466.     var ret = value.inspect(recurseTimes, ctx);
  2467.     if (!isString(ret)) {
  2468.       ret = formatValue(ctx, ret, recurseTimes);
  2469.     }
  2470.     return ret;
  2471.   }
  2472.  
  2473.   // Primitive types cannot have properties
  2474.   var primitive = formatPrimitive(ctx, value);
  2475.   if (primitive) {
  2476.     return primitive;
  2477.   }
  2478.  
  2479.   // Look up the keys of the object.
  2480.   var keys = Object.keys(value);
  2481.   var visibleKeys = arrayToHash(keys);
  2482.  
  2483.   if (ctx.showHidden) {
  2484.     keys = Object.getOwnPropertyNames(value);
  2485.   }
  2486.  
  2487.   // IE doesn't make error fields non-enumerable
  2488.   // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  2489.   if (isError(value)
  2490.       && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  2491.     return formatError(value);
  2492.   }
  2493.  
  2494.   // Some type of object without properties can be shortcutted.
  2495.   if (keys.length === 0) {
  2496.     if (isFunction(value)) {
  2497.       var name = value.name ? ': ' + value.name : '';
  2498.       return ctx.stylize('[Function' + name + ']', 'special');
  2499.     }
  2500.     if (isRegExp(value)) {
  2501.       return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  2502.     }
  2503.     if (isDate(value)) {
  2504.       return ctx.stylize(Date.prototype.toString.call(value), 'date');
  2505.     }
  2506.     if (isError(value)) {
  2507.       return formatError(value);
  2508.     }
  2509.   }
  2510.  
  2511.   var base = '', array = false, braces = ['{', '}'];
  2512.  
  2513.   // Make Array say that they are Array
  2514.   if (isArray(value)) {
  2515.     array = true;
  2516.     braces = ['[', ']'];
  2517.   }
  2518.  
  2519.   // Make functions say that they are functions
  2520.   if (isFunction(value)) {
  2521.     var n = value.name ? ': ' + value.name : '';
  2522.     base = ' [Function' + n + ']';
  2523.   }
  2524.  
  2525.   // Make RegExps say that they are RegExps
  2526.   if (isRegExp(value)) {
  2527.     base = ' ' + RegExp.prototype.toString.call(value);
  2528.   }
  2529.  
  2530.   // Make dates with properties first say the date
  2531.   if (isDate(value)) {
  2532.     base = ' ' + Date.prototype.toUTCString.call(value);
  2533.   }
  2534.  
  2535.   // Make error with message first say the error
  2536.   if (isError(value)) {
  2537.     base = ' ' + formatError(value);
  2538.   }
  2539.  
  2540.   if (keys.length === 0 && (!array || value.length == 0)) {
  2541.     return braces[0] + base + braces[1];
  2542.   }
  2543.  
  2544.   if (recurseTimes < 0) {
  2545.     if (isRegExp(value)) {
  2546.       return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  2547.     } else {
  2548.       return ctx.stylize('[Object]', 'special');
  2549.     }
  2550.   }
  2551.  
  2552.   ctx.seen.push(value);
  2553.  
  2554.   var output;
  2555.   if (array) {
  2556.     output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  2557.   } else {
  2558.     output = keys.map(function(key) {
  2559.       return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  2560.     });
  2561.   }
  2562.  
  2563.   ctx.seen.pop();
  2564.  
  2565.   return reduceToSingleString(output, base, braces);
  2566. }
  2567.  
  2568.  
  2569. function formatPrimitive(ctx, value) {
  2570.   if (isUndefined(value))
  2571.     return ctx.stylize('undefined', 'undefined');
  2572.   if (isString(value)) {
  2573.     var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  2574.                                              .replace(/'/g, "\\'")
  2575.                                              .replace(/\\"/g, '"') + '\'';
  2576.     return ctx.stylize(simple, 'string');
  2577.   }
  2578.   if (isNumber(value))
  2579.     return ctx.stylize('' + value, 'number');
  2580.   if (isBoolean(value))
  2581.     return ctx.stylize('' + value, 'boolean');
  2582.   // For some reason typeof null is "object", so special case here.
  2583.   if (isNull(value))
  2584.     return ctx.stylize('null', 'null');
  2585. }
  2586.  
  2587.  
  2588. function formatError(value) {
  2589.   return '[' + Error.prototype.toString.call(value) + ']';
  2590. }
  2591.  
  2592.  
  2593. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  2594.   var output = [];
  2595.   for (var i = 0, l = value.length; i < l; ++i) {
  2596.     if (hasOwnProperty(value, String(i))) {
  2597.       output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  2598.           String(i), true));
  2599.     } else {
  2600.       output.push('');
  2601.     }
  2602.   }
  2603.   keys.forEach(function(key) {
  2604.     if (!key.match(/^\d+$/)) {
  2605.       output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  2606.           key, true));
  2607.     }
  2608.   });
  2609.   return output;
  2610. }
  2611.  
  2612.  
  2613. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  2614.   var name, str, desc;
  2615.   desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  2616.   if (desc.get) {
  2617.     if (desc.set) {
  2618.       str = ctx.stylize('[Getter/Setter]', 'special');
  2619.     } else {
  2620.       str = ctx.stylize('[Getter]', 'special');
  2621.     }
  2622.   } else {
  2623.     if (desc.set) {
  2624.       str = ctx.stylize('[Setter]', 'special');
  2625.     }
  2626.   }
  2627.   if (!hasOwnProperty(visibleKeys, key)) {
  2628.     name = '[' + key + ']';
  2629.   }
  2630.   if (!str) {
  2631.     if (ctx.seen.indexOf(desc.value) < 0) {
  2632.       if (isNull(recurseTimes)) {
  2633.         str = formatValue(ctx, desc.value, null);
  2634.       } else {
  2635.         str = formatValue(ctx, desc.value, recurseTimes - 1);
  2636.       }
  2637.       if (str.indexOf('\n') > -1) {
  2638.         if (array) {
  2639.           str = str.split('\n').map(function(line) {
  2640.             return '  ' + line;
  2641.           }).join('\n').substr(2);
  2642.         } else {
  2643.           str = '\n' + str.split('\n').map(function(line) {
  2644.             return '   ' + line;
  2645.           }).join('\n');
  2646.         }
  2647.       }
  2648.     } else {
  2649.       str = ctx.stylize('[Circular]', 'special');
  2650.     }
  2651.   }
  2652.   if (isUndefined(name)) {
  2653.     if (array && key.match(/^\d+$/)) {
  2654.       return str;
  2655.     }
  2656.     name = JSON.stringify('' + key);
  2657.     if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  2658.       name = name.substr(1, name.length - 2);
  2659.       name = ctx.stylize(name, 'name');
  2660.     } else {
  2661.       name = name.replace(/'/g, "\\'")
  2662.                  .replace(/\\"/g, '"')
  2663.                  .replace(/(^"|"$)/g, "'");
  2664.       name = ctx.stylize(name, 'string');
  2665.     }
  2666.   }
  2667.  
  2668.   return name + ': ' + str;
  2669. }
  2670.  
  2671.  
  2672. function reduceToSingleString(output, base, braces) {
  2673.   var numLinesEst = 0;
  2674.   var length = output.reduce(function(prev, cur) {
  2675.     numLinesEst++;
  2676.     if (cur.indexOf('\n') >= 0) numLinesEst++;
  2677.     return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  2678.   }, 0);
  2679.  
  2680.   if (length > 60) {
  2681.     return braces[0] +
  2682.            (base === '' ? '' : base + '\n ') +
  2683.            ' ' +
  2684.            output.join(',\n  ') +
  2685.            ' ' +
  2686.            braces[1];
  2687.   }
  2688.  
  2689.   return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  2690. }
  2691.  
  2692.  
  2693. // NOTE: These type checking functions intentionally don't use `instanceof`
  2694. // because it is fragile and can be easily faked with `Object.create()`.
  2695. function isArray(ar) {
  2696.   return Array.isArray(ar);
  2697. }
  2698. exports.isArray = isArray;
  2699.  
  2700. function isBoolean(arg) {
  2701.   return typeof arg === 'boolean';
  2702. }
  2703. exports.isBoolean = isBoolean;
  2704.  
  2705. function isNull(arg) {
  2706.   return arg === null;
  2707. }
  2708. exports.isNull = isNull;
  2709.  
  2710. function isNullOrUndefined(arg) {
  2711.   return arg == null;
  2712. }
  2713. exports.isNullOrUndefined = isNullOrUndefined;
  2714.  
  2715. function isNumber(arg) {
  2716.   return typeof arg === 'number';
  2717. }
  2718. exports.isNumber = isNumber;
  2719.  
  2720. function isString(arg) {
  2721.   return typeof arg === 'string';
  2722. }
  2723. exports.isString = isString;
  2724.  
  2725. function isSymbol(arg) {
  2726.   return typeof arg === 'symbol';
  2727. }
  2728. exports.isSymbol = isSymbol;
  2729.  
  2730. function isUndefined(arg) {
  2731.   return arg === void 0;
  2732. }
  2733. exports.isUndefined = isUndefined;
  2734.  
  2735. function isRegExp(re) {
  2736.   return isObject(re) && objectToString(re) === '[object RegExp]';
  2737. }
  2738. exports.isRegExp = isRegExp;
  2739.  
  2740. function isObject(arg) {
  2741.   return typeof arg === 'object' && arg !== null;
  2742. }
  2743. exports.isObject = isObject;
  2744.  
  2745. function isDate(d) {
  2746.   return isObject(d) && objectToString(d) === '[object Date]';
  2747. }
  2748. exports.isDate = isDate;
  2749.  
  2750. function isError(e) {
  2751.   return isObject(e) &&
  2752.       (objectToString(e) === '[object Error]' || e instanceof Error);
  2753. }
  2754. exports.isError = isError;
  2755.  
  2756. function isFunction(arg) {
  2757.   return typeof arg === 'function';
  2758. }
  2759. exports.isFunction = isFunction;
  2760.  
  2761. function isPrimitive(arg) {
  2762.   return arg === null ||
  2763.          typeof arg === 'boolean' ||
  2764.          typeof arg === 'number' ||
  2765.          typeof arg === 'string' ||
  2766.          typeof arg === 'symbol' ||  // ES6 symbol
  2767.          typeof arg === 'undefined';
  2768. }
  2769. exports.isPrimitive = isPrimitive;
  2770.  
  2771. exports.isBuffer = require('./support/isBuffer');
  2772.  
  2773. function objectToString(o) {
  2774.   return Object.prototype.toString.call(o);
  2775. }
  2776.  
  2777.  
  2778. function pad(n) {
  2779.   return n < 10 ? '0' + n.toString(10) : n.toString(10);
  2780. }
  2781.  
  2782.  
  2783. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  2784.               'Oct', 'Nov', 'Dec'];
  2785.  
  2786. // 26 Feb 16:19:34
  2787. function timestamp() {
  2788.   var d = new Date();
  2789.   var time = [pad(d.getHours()),
  2790.               pad(d.getMinutes()),
  2791.               pad(d.getSeconds())].join(':');
  2792.   return [d.getDate(), months[d.getMonth()], time].join(' ');
  2793. }
  2794.  
  2795.  
  2796. // log is just a thin wrapper to console.log that prepends a timestamp
  2797. exports.log = function() {
  2798.   console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  2799. };
  2800.  
  2801.  
  2802. /**
  2803.  * Inherit the prototype methods from one constructor into another.
  2804.  *
  2805.  * The Function.prototype.inherits from lang.js rewritten as a standalone
  2806.  * function (not on Function.prototype). NOTE: If this file is to be loaded
  2807.  * during bootstrapping this function needs to be rewritten using some native
  2808.  * functions as prototype setup using normal JavaScript does not work as
  2809.  * expected during bootstrapping (see mirror.js in r114903).
  2810.  *
  2811.  * @param {function} ctor Constructor function which needs to inherit the
  2812.  *     prototype.
  2813.  * @param {function} superCtor Constructor function to inherit prototype from.
  2814.  */
  2815. exports.inherits = require('inherits');
  2816.  
  2817. exports._extend = function(origin, add) {
  2818.   // Don't do anything if add isn't an object
  2819.   if (!add || !isObject(add)) return origin;
  2820.  
  2821.   var keys = Object.keys(add);
  2822.   var i = keys.length;
  2823.   while (i--) {
  2824.     origin[keys[i]] = add[keys[i]];
  2825.   }
  2826.   return origin;
  2827. };
  2828.  
  2829. function hasOwnProperty(obj, prop) {
  2830.   return Object.prototype.hasOwnProperty.call(obj, prop);
  2831. }
  2832.  
  2833. }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  2834. },{"./support/isBuffer":7,"_process":6,"inherits":5}],9:[function(require,module,exports){
  2835. // Generated by IcedCoffeeScript 1.7.1-g
  2836. (function() {
  2837.   exports.transform = function(x, options) {
  2838.     return x.icedTransform(options);
  2839.   };
  2840.  
  2841.   exports.runtime = require('iced-runtime');
  2842.  
  2843. }).call(this);
  2844.  
  2845. },{"iced-runtime":13}],10:[function(require,module,exports){
  2846. // Generated by IcedCoffeeScript 1.7.1-c
  2847. (function() {
  2848.   var BaseError, Canceler, EscErr, EscOk, c_to_camel, ipush, make_error_klass, make_errors, make_esc, to_lower, util,
  2849.     __slice = [].slice;
  2850.  
  2851.   util = require('util');
  2852.  
  2853.   exports.BaseError = BaseError = function(msg, constructor) {
  2854.     Error.captureStackTrace(this, this.constructor);
  2855.     return this.message = msg || 'Error';
  2856.   };
  2857.  
  2858.   util.inherits(BaseError, Error);
  2859.  
  2860.   BaseError.prototype.name = "BaseError";
  2861.  
  2862.   to_lower = function(s) {
  2863.     return s[0].toUpperCase() + s.slice(1).toLowerCase();
  2864.   };
  2865.  
  2866.   c_to_camel = function(s) {
  2867.     var p;
  2868.     return ((function() {
  2869.       var _i, _len, _ref, _results;
  2870.       _ref = s.split(/_/);
  2871.       _results = [];
  2872.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  2873.         p = _ref[_i];
  2874.         _results.push(to_lower(p));
  2875.       }
  2876.       return _results;
  2877.     })()).join('');
  2878.   };
  2879.  
  2880.   make_error_klass = function(k, code, default_msg) {
  2881.     var ctor;
  2882.     ctor = function(msg) {
  2883.       BaseError.call(this, msg || default_msg, this.constructor);
  2884.       this.istack = [];
  2885.       this.code = code;
  2886.       return this;
  2887.     };
  2888.     util.inherits(ctor, BaseError);
  2889.     ctor.prototype.name = k;
  2890.     ctor.prototype.inspect = function() {
  2891.       return "[" + k + ": " + this.message + " (code " + this.code + ")]";
  2892.     };
  2893.     return ctor;
  2894.   };
  2895.  
  2896.   exports.make_errors = make_errors = function(d) {
  2897.     var enam, errno, k, msg, out, val;
  2898.     out = {
  2899.       msg: {},
  2900.       name: {},
  2901.       code: {}
  2902.     };
  2903.     d.OK = "Success";
  2904.     errno = 100;
  2905.     for (k in d) {
  2906.       msg = d[k];
  2907.       if (k !== "OK") {
  2908.         enam = (c_to_camel(k)) + "Error";
  2909.         val = errno++;
  2910.         out[enam] = make_error_klass(enam, val, msg);
  2911.       } else {
  2912.         val = 0;
  2913.       }
  2914.       out[k] = val;
  2915.       out.msg[k] = out.msg[val] = msg;
  2916.       out.name[k] = out.name[val] = k;
  2917.       out.code[k] = val;
  2918.     }
  2919.     return out;
  2920.   };
  2921.  
  2922.   ipush = function(e, msg) {
  2923.     if (msg != null) {
  2924.       if (e.istack == null) {
  2925.         e.istack = [];
  2926.       }
  2927.       return e.istack.push(msg);
  2928.     }
  2929.   };
  2930.  
  2931.   exports.make_esc = make_esc = function(gcb, where) {
  2932.     return function(lcb) {
  2933.       return function() {
  2934.         var args, err;
  2935.         err = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
  2936.         if (err == null) {
  2937.           return lcb.apply(null, args);
  2938.         } else if (!gcb.__esc) {
  2939.           gcb.__esc = true;
  2940.           ipush(err, where);
  2941.           return gcb(err);
  2942.         }
  2943.       };
  2944.     };
  2945.   };
  2946.  
  2947.   exports.EscOk = EscOk = (function() {
  2948.     function EscOk(gcb, where) {
  2949.       this.gcb = gcb;
  2950.       this.where = where;
  2951.     }
  2952.  
  2953.     EscOk.prototype.bailout = function() {
  2954.       var t;
  2955.       if (this.gcb) {
  2956.         t = this.gcb;
  2957.         this.gcb = null;
  2958.         return t(false);
  2959.       }
  2960.     };
  2961.  
  2962.     EscOk.prototype.check_ok = function(cb) {
  2963.       return (function(_this) {
  2964.         return function() {
  2965.           var args, ok;
  2966.           ok = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
  2967.           if (!ok) {
  2968.             return _this.bailout();
  2969.           } else {
  2970.             return cb.apply(null, args);
  2971.           }
  2972.         };
  2973.       })(this);
  2974.     };
  2975.  
  2976.     EscOk.prototype.check_err = function(cb) {
  2977.       return (function(_this) {
  2978.         return function() {
  2979.           var args, err;
  2980.           err = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
  2981.           if (err != null) {
  2982.             ipush(err, _this.where);
  2983.             return _this.bailout();
  2984.           } else {
  2985.             return cb.apply(null, args);
  2986.           }
  2987.         };
  2988.       })(this);
  2989.     };
  2990.  
  2991.     EscOk.prototype.check_non_null = function(cb) {
  2992.       return (function(_this) {
  2993.         return function() {
  2994.           var args;
  2995.           args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  2996.           if (args[0] == null) {
  2997.             return _this.bailout();
  2998.           } else {
  2999.             return cb.apply(null, args);
  3000.           }
  3001.         };
  3002.       })(this);
  3003.     };
  3004.  
  3005.     return EscOk;
  3006.  
  3007.   })();
  3008.  
  3009.   exports.EscErr = EscErr = (function() {
  3010.     function EscErr(gcb, where) {
  3011.       this.gcb = gcb;
  3012.       this.where = where;
  3013.     }
  3014.  
  3015.     EscErr.prototype.finish = function(err) {
  3016.       var t;
  3017.       if (this.gcb) {
  3018.         t = this.gcb;
  3019.         this.gcb = null;
  3020.         return t(err);
  3021.       }
  3022.     };
  3023.  
  3024.     EscErr.prototype.check_ok = function(cb, eclass, emsg) {
  3025.       if (eclass == null) {
  3026.         eclass = Error;
  3027.       }
  3028.       if (emsg == null) {
  3029.         emsg = null;
  3030.       }
  3031.       return function() {
  3032.         var args, err, ok;
  3033.         ok = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
  3034.         if (!ok) {
  3035.           err = new eclass(emsg);
  3036.           ipush(err, this.where);
  3037.           return this.finish(err);
  3038.         } else {
  3039.           return cb.apply(null, args);
  3040.         }
  3041.       };
  3042.     };
  3043.  
  3044.     EscErr.prototype.check_err = function(cb) {
  3045.       return function() {
  3046.         var args, err;
  3047.         err = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
  3048.         if (err != null) {
  3049.           ipush(err, this.where);
  3050.           return this.finish(err);
  3051.         } else {
  3052.           return cb.apply(null, args);
  3053.         }
  3054.       };
  3055.     };
  3056.  
  3057.     return EscErr;
  3058.  
  3059.   })();
  3060.  
  3061.   exports.Canceler = Canceler = (function() {
  3062.     function Canceler(klass) {
  3063.       this.klass = klass != null ? klass : Error;
  3064.       this._canceled = false;
  3065.     }
  3066.  
  3067.     Canceler.prototype.is_canceled = function() {
  3068.       return this._canceled;
  3069.     };
  3070.  
  3071.     Canceler.prototype.is_ok = function() {
  3072.       return !this._canceled;
  3073.     };
  3074.  
  3075.     Canceler.prototype.cancel = function() {
  3076.       return this._canceled = true;
  3077.     };
  3078.  
  3079.     Canceler.prototype.err = function() {
  3080.       if (this._canceled) {
  3081.         return new this.klass("Aborted");
  3082.       } else {
  3083.         return null;
  3084.       }
  3085.     };
  3086.  
  3087.     return Canceler;
  3088.  
  3089.   })();
  3090.  
  3091.   exports.chain = function(cb, f) {
  3092.     return function() {
  3093.       var args;
  3094.       args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  3095.       return f(function() {
  3096.         return cb.apply(null, args);
  3097.       });
  3098.     };
  3099.   };
  3100.  
  3101.   exports.chain_err = function(cb, f) {
  3102.     return function() {
  3103.       var args0;
  3104.       args0 = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  3105.       return f(function() {
  3106.         var args1;
  3107.         args1 = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  3108.         return cb.apply(null, ((args1[0] != null) && !(args0[0] != null) ? args1 : args0));
  3109.       });
  3110.     };
  3111.   };
  3112.  
  3113. }).call(this);
  3114.  
  3115.  
  3116.  
  3117. },{"util":8}],11:[function(require,module,exports){
  3118. // Generated by IcedCoffeeScript 108.0.8
  3119. (function() {
  3120.   module.exports = {
  3121.     k: "__iced_k",
  3122.     k_noop: "__iced_k_noop",
  3123.     param: "__iced_p_",
  3124.     ns: "iced",
  3125.     runtime: "runtime",
  3126.     Deferrals: "Deferrals",
  3127.     deferrals: "__iced_deferrals",
  3128.     fulfill: "_fulfill",
  3129.     b_while: "_break",
  3130.     t_while: "_while",
  3131.     c_while: "_continue",
  3132.     n_while: "_next",
  3133.     n_arg: "__iced_next_arg",
  3134.     defer_method: "defer",
  3135.     slot: "__slot",
  3136.     assign_fn: "assign_fn",
  3137.     autocb: "autocb",
  3138.     retslot: "ret",
  3139.     trace: "__iced_trace",
  3140.     passed_deferral: "__iced_passed_deferral",
  3141.     findDeferral: "findDeferral",
  3142.     lineno: "lineno",
  3143.     parent: "parent",
  3144.     filename: "filename",
  3145.     funcname: "funcname",
  3146.     catchExceptions: 'catchExceptions',
  3147.     runtime_modes: ["node", "inline", "window", "none", "browserify", "interp"],
  3148.     trampoline: "trampoline",
  3149.     context: "context",
  3150.     defer_arg: "__iced_defer_"
  3151.   };
  3152.  
  3153. }).call(this);
  3154.  
  3155. },{}],12:[function(require,module,exports){
  3156. // Generated by IcedCoffeeScript 108.0.8
  3157. (function() {
  3158.   var C, Pipeliner, iced, __iced_k, __iced_k_noop, _iand, _ior, _timeout,
  3159.     __slice = [].slice;
  3160.  
  3161.   __iced_k = __iced_k_noop = function() {};
  3162.  
  3163.   C = require('./const');
  3164.  
  3165.   exports.iced = iced = require('./runtime');
  3166.  
  3167.   _timeout = function(cb, t, res, tmp) {
  3168.     var arr, rv, which, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  3169.     __iced_k = __iced_k_noop;
  3170.     ___iced_passed_deferral = iced.findDeferral(arguments);
  3171.     rv = new iced.Rendezvous;
  3172.     tmp[0] = rv.id(true).defer({
  3173.       assign_fn: (function(_this) {
  3174.         return function() {
  3175.           return function() {
  3176.             return arr = __slice.call(arguments, 0);
  3177.           };
  3178.         };
  3179.       })(this)(),
  3180.       lineno: 20,
  3181.       context: __iced_deferrals
  3182.     });
  3183.     setTimeout(rv.id(false).defer({
  3184.       lineno: 21,
  3185.       context: __iced_deferrals
  3186.     }), t);
  3187.     (function(_this) {
  3188.       return (function(__iced_k) {
  3189.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  3190.           parent: ___iced_passed_deferral,
  3191.           filename: "/Users/max/src/iced/iced-runtime/src/library.iced"
  3192.         });
  3193.         rv.wait(__iced_deferrals.defer({
  3194.           assign_fn: (function() {
  3195.             return function() {
  3196.               return which = arguments[0];
  3197.             };
  3198.           })(),
  3199.           lineno: 22
  3200.         }));
  3201.         __iced_deferrals._fulfill();
  3202.       });
  3203.     })(this)((function(_this) {
  3204.       return function() {
  3205.         if (res) {
  3206.           res[0] = which;
  3207.         }
  3208.         return cb.apply(null, arr);
  3209.       };
  3210.     })(this));
  3211.   };
  3212.  
  3213.   exports.timeout = function(cb, t, res) {
  3214.     var tmp;
  3215.     tmp = [];
  3216.     _timeout(cb, t, res, tmp);
  3217.     return tmp[0];
  3218.   };
  3219.  
  3220.   _iand = function(cb, res, tmp) {
  3221.     var ok, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  3222.     __iced_k = __iced_k_noop;
  3223.     ___iced_passed_deferral = iced.findDeferral(arguments);
  3224.     (function(_this) {
  3225.       return (function(__iced_k) {
  3226.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  3227.           parent: ___iced_passed_deferral,
  3228.           filename: "/Users/max/src/iced/iced-runtime/src/library.iced"
  3229.         });
  3230.         tmp[0] = __iced_deferrals.defer({
  3231.           assign_fn: (function() {
  3232.             return function() {
  3233.               return ok = arguments[0];
  3234.             };
  3235.           })(),
  3236.           lineno: 39
  3237.         });
  3238.         __iced_deferrals._fulfill();
  3239.       });
  3240.     })(this)((function(_this) {
  3241.       return function() {
  3242.         if (!ok) {
  3243.           res[0] = false;
  3244.         }
  3245.         return cb();
  3246.       };
  3247.     })(this));
  3248.   };
  3249.  
  3250.   exports.iand = function(cb, res) {
  3251.     var tmp;
  3252.     tmp = [];
  3253.     _iand(cb, res, tmp);
  3254.     return tmp[0];
  3255.   };
  3256.  
  3257.   _ior = function(cb, res, tmp) {
  3258.     var ok, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  3259.     __iced_k = __iced_k_noop;
  3260.     ___iced_passed_deferral = iced.findDeferral(arguments);
  3261.     (function(_this) {
  3262.       return (function(__iced_k) {
  3263.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  3264.           parent: ___iced_passed_deferral,
  3265.           filename: "/Users/max/src/iced/iced-runtime/src/library.iced"
  3266.         });
  3267.         tmp[0] = __iced_deferrals.defer({
  3268.           assign_fn: (function() {
  3269.             return function() {
  3270.               return ok = arguments[0];
  3271.             };
  3272.           })(),
  3273.           lineno: 58
  3274.         });
  3275.         __iced_deferrals._fulfill();
  3276.       });
  3277.     })(this)((function(_this) {
  3278.       return function() {
  3279.         if (ok) {
  3280.           res[0] = true;
  3281.         }
  3282.         return cb();
  3283.       };
  3284.     })(this));
  3285.   };
  3286.  
  3287.   exports.ior = function(cb, res) {
  3288.     var tmp;
  3289.     tmp = [];
  3290.     _ior(cb, res, tmp);
  3291.     return tmp[0];
  3292.   };
  3293.  
  3294.   exports.Pipeliner = Pipeliner = (function() {
  3295.     function Pipeliner(window, delay) {
  3296.       this.window = window || 1;
  3297.       this.delay = delay || 0;
  3298.       this.queue = [];
  3299.       this.n_out = 0;
  3300.       this.cb = null;
  3301.       this[C.deferrals] = this;
  3302.       this["defer"] = this._defer;
  3303.     }
  3304.  
  3305.     Pipeliner.prototype.waitInQueue = function(cb) {
  3306.       var ___iced_passed_deferral, __iced_deferrals, __iced_k;
  3307.       __iced_k = __iced_k_noop;
  3308.       ___iced_passed_deferral = iced.findDeferral(arguments);
  3309.       (function(_this) {
  3310.         return (function(__iced_k) {
  3311.           var _while;
  3312.           _while = function(__iced_k) {
  3313.             var _break, _continue, _next;
  3314.             _break = __iced_k;
  3315.             _continue = function() {
  3316.               return iced.trampoline(function() {
  3317.                 return _while(__iced_k);
  3318.               });
  3319.             };
  3320.             _next = _continue;
  3321.             if (!(_this.n_out >= _this.window)) {
  3322.               return _break();
  3323.             } else {
  3324.               (function(__iced_k) {
  3325.                 __iced_deferrals = new iced.Deferrals(__iced_k, {
  3326.                   parent: ___iced_passed_deferral,
  3327.                   filename: "/Users/max/src/iced/iced-runtime/src/library.iced",
  3328.                   funcname: "Pipeliner.waitInQueue"
  3329.                 });
  3330.                 _this.cb = __iced_deferrals.defer({
  3331.                   lineno: 100
  3332.                 });
  3333.                 __iced_deferrals._fulfill();
  3334.               })(_next);
  3335.             }
  3336.           };
  3337.           _while(__iced_k);
  3338.         });
  3339.       })(this)((function(_this) {
  3340.         return function() {
  3341.           _this.n_out++;
  3342.           (function(__iced_k) {
  3343.             if (_this.delay) {
  3344.               (function(__iced_k) {
  3345.                 __iced_deferrals = new iced.Deferrals(__iced_k, {
  3346.                   parent: ___iced_passed_deferral,
  3347.                   filename: "/Users/max/src/iced/iced-runtime/src/library.iced",
  3348.                   funcname: "Pipeliner.waitInQueue"
  3349.                 });
  3350.                 setTimeout(__iced_deferrals.defer({
  3351.                   lineno: 108
  3352.                 }), _this.delay);
  3353.                 __iced_deferrals._fulfill();
  3354.               })(__iced_k);
  3355.             } else {
  3356.               return __iced_k();
  3357.             }
  3358.           })(function() {
  3359.             return cb();
  3360.           });
  3361.         };
  3362.       })(this));
  3363.     };
  3364.  
  3365.     Pipeliner.prototype.__defer = function(out, deferArgs) {
  3366.       var tmp, voidCb, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  3367.       __iced_k = __iced_k_noop;
  3368.       ___iced_passed_deferral = iced.findDeferral(arguments);
  3369.       (function(_this) {
  3370.         return (function(__iced_k) {
  3371.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  3372.             parent: ___iced_passed_deferral,
  3373.             filename: "/Users/max/src/iced/iced-runtime/src/library.iced",
  3374.             funcname: "Pipeliner.__defer"
  3375.           });
  3376.           voidCb = __iced_deferrals.defer({
  3377.             lineno: 122
  3378.           });
  3379.           out[0] = function() {
  3380.             var args, _ref;
  3381.             args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  3382.             if ((_ref = deferArgs.assign_fn) != null) {
  3383.               _ref.apply(null, args);
  3384.             }
  3385.             return voidCb();
  3386.           };
  3387.           __iced_deferrals._fulfill();
  3388.         });
  3389.       })(this)((function(_this) {
  3390.         return function() {
  3391.           _this.n_out--;
  3392.           if (_this.cb) {
  3393.             tmp = _this.cb;
  3394.             _this.cb = null;
  3395.             return tmp();
  3396.           }
  3397.         };
  3398.       })(this));
  3399.     };
  3400.  
  3401.     Pipeliner.prototype._defer = function(deferArgs) {
  3402.       var tmp;
  3403.       tmp = [];
  3404.       this.__defer(tmp, deferArgs);
  3405.       return tmp[0];
  3406.     };
  3407.  
  3408.     Pipeliner.prototype.flush = function(autocb) {
  3409.       var ___iced_passed_deferral, __iced_k, _while;
  3410.       __iced_k = autocb;
  3411.       ___iced_passed_deferral = iced.findDeferral(arguments);
  3412.       _while = (function(_this) {
  3413.         var __iced_deferrals;
  3414.         return function(__iced_k) {
  3415.           var _break, _continue, _next;
  3416.           _break = __iced_k;
  3417.           _continue = function() {
  3418.             return iced.trampoline(function() {
  3419.               return _while(__iced_k);
  3420.             });
  3421.           };
  3422.           _next = _continue;
  3423.           if (!_this.n_out) {
  3424.             return _break();
  3425.           } else {
  3426.             (function(__iced_k) {
  3427.               __iced_deferrals = new iced.Deferrals(__iced_k, {
  3428.                 parent: ___iced_passed_deferral,
  3429.                 filename: "/Users/max/src/iced/iced-runtime/src/library.iced",
  3430.                 funcname: "Pipeliner.flush"
  3431.               });
  3432.               _this.cb = __iced_deferrals.defer({
  3433.                 lineno: 151
  3434.               });
  3435.               __iced_deferrals._fulfill();
  3436.             })(_next);
  3437.           }
  3438.         };
  3439.       })(this);
  3440.       _while(__iced_k);
  3441.     };
  3442.  
  3443.     return Pipeliner;
  3444.  
  3445.   })();
  3446.  
  3447. }).call(this);
  3448.  
  3449. },{"./const":11,"./runtime":14}],13:[function(require,module,exports){
  3450. // Generated by IcedCoffeeScript 108.0.8
  3451. (function() {
  3452.   var k, mod, mods, v, _i, _len;
  3453.  
  3454.   exports["const"] = require('./const');
  3455.  
  3456.   mods = [require('./runtime'), require('./library')];
  3457.  
  3458.   for (_i = 0, _len = mods.length; _i < _len; _i++) {
  3459.     mod = mods[_i];
  3460.     for (k in mod) {
  3461.       v = mod[k];
  3462.       exports[k] = v;
  3463.     }
  3464.   }
  3465.  
  3466. }).call(this);
  3467.  
  3468. },{"./const":11,"./library":12,"./runtime":14}],14:[function(require,module,exports){
  3469. (function (process){
  3470. // Generated by IcedCoffeeScript 108.0.8
  3471. (function() {
  3472.   var C, Deferrals, Rendezvous, exceptionHandler, findDeferral, make_defer_return, stackWalk, tick_counter, trampoline, warn, __active_trace, __c, _trace_to_string,
  3473.     __slice = [].slice;
  3474.  
  3475.   C = require('./const');
  3476.  
  3477.   make_defer_return = function(obj, defer_args, id, trace_template, multi) {
  3478.     var k, ret, trace, v;
  3479.     trace = {};
  3480.     for (k in trace_template) {
  3481.       v = trace_template[k];
  3482.       trace[k] = v;
  3483.     }
  3484.     trace[C.lineno] = defer_args != null ? defer_args[C.lineno] : void 0;
  3485.     ret = function() {
  3486.       var inner_args, o, _ref;
  3487.       inner_args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  3488.       if (defer_args != null) {
  3489.         if ((_ref = defer_args.assign_fn) != null) {
  3490.           _ref.apply(null, inner_args);
  3491.         }
  3492.       }
  3493.       if (obj) {
  3494.         o = obj;
  3495.         if (!multi) {
  3496.           obj = null;
  3497.         }
  3498.         return o._fulfill(id, trace);
  3499.       } else {
  3500.         return warn("overused deferral at " + (_trace_to_string(trace)));
  3501.       }
  3502.     };
  3503.     ret[C.trace] = trace;
  3504.     return ret;
  3505.   };
  3506.  
  3507.   __c = 0;
  3508.  
  3509.   tick_counter = function(mod) {
  3510.     __c++;
  3511.     if ((__c % mod) === 0) {
  3512.       __c = 0;
  3513.       return true;
  3514.     } else {
  3515.       return false;
  3516.     }
  3517.   };
  3518.  
  3519.   __active_trace = null;
  3520.  
  3521.   _trace_to_string = function(tr) {
  3522.     var fn;
  3523.     fn = tr[C.funcname] || "<anonymous>";
  3524.     return "" + fn + " (" + tr[C.filename] + ":" + (tr[C.lineno] + 1) + ")";
  3525.   };
  3526.  
  3527.   warn = function(m) {
  3528.     return typeof console !== "undefined" && console !== null ? console.error("ICED warning: " + m) : void 0;
  3529.   };
  3530.  
  3531.   exports.trampoline = trampoline = function(fn) {
  3532.     if (!tick_counter(500)) {
  3533.       return fn();
  3534.     } else if ((typeof process !== "undefined" && process !== null ? process.nextTick : void 0) != null) {
  3535.       return process.nextTick(fn);
  3536.     } else {
  3537.       return setTimeout(fn);
  3538.     }
  3539.   };
  3540.  
  3541.   exports.Deferrals = Deferrals = (function() {
  3542.     function Deferrals(k, trace) {
  3543.       this.trace = trace;
  3544.       this.continuation = k;
  3545.       this.count = 1;
  3546.       this.ret = null;
  3547.     }
  3548.  
  3549.     Deferrals.prototype._call = function(trace) {
  3550.       var c;
  3551.       if (this.continuation) {
  3552.         __active_trace = trace;
  3553.         c = this.continuation;
  3554.         this.continuation = null;
  3555.         return c(this.ret);
  3556.       } else {
  3557.         return warn("Entered dead await at " + (_trace_to_string(trace)));
  3558.       }
  3559.     };
  3560.  
  3561.     Deferrals.prototype._fulfill = function(id, trace) {
  3562.       if (--this.count > 0) {
  3563.  
  3564.       } else {
  3565.         return trampoline(((function(_this) {
  3566.           return function() {
  3567.             return _this._call(trace);
  3568.           };
  3569.         })(this)));
  3570.       }
  3571.     };
  3572.  
  3573.     Deferrals.prototype.defer = function(args) {
  3574.       var self;
  3575.       this.count++;
  3576.       self = this;
  3577.       return make_defer_return(self, args, null, this.trace);
  3578.     };
  3579.  
  3580.     return Deferrals;
  3581.  
  3582.   })();
  3583.  
  3584.   exports.findDeferral = findDeferral = function(args) {
  3585.     var a, _i, _len;
  3586.     for (_i = 0, _len = args.length; _i < _len; _i++) {
  3587.       a = args[_i];
  3588.       if (a != null ? a[C.trace] : void 0) {
  3589.         return a;
  3590.       }
  3591.     }
  3592.     return null;
  3593.   };
  3594.  
  3595.   exports.Rendezvous = Rendezvous = (function() {
  3596.     var RvId;
  3597.  
  3598.     function Rendezvous() {
  3599.       this.completed = [];
  3600.       this.waiters = [];
  3601.       this.defer_id = 0;
  3602.     }
  3603.  
  3604.     RvId = (function() {
  3605.       function RvId(rv, id, multi) {
  3606.         this.rv = rv;
  3607.         this.id = id;
  3608.         this.multi = multi;
  3609.       }
  3610.  
  3611.       RvId.prototype.defer = function(defer_args) {
  3612.         return this.rv._defer_with_id(this.id, defer_args, this.multi);
  3613.       };
  3614.  
  3615.       return RvId;
  3616.  
  3617.     })();
  3618.  
  3619.     Rendezvous.prototype.wait = function(cb) {
  3620.       var x;
  3621.       if (this.completed.length) {
  3622.         x = this.completed.shift();
  3623.         return cb(x);
  3624.       } else {
  3625.         return this.waiters.push(cb);
  3626.       }
  3627.     };
  3628.  
  3629.     Rendezvous.prototype.defer = function(defer_args) {
  3630.       var id;
  3631.       id = this.defer_id++;
  3632.       return this._defer_with_id(id, defer_args);
  3633.     };
  3634.  
  3635.     Rendezvous.prototype.id = function(i, multi) {
  3636.       multi = !!multi;
  3637.       return new RvId(this, i, multi);
  3638.     };
  3639.  
  3640.     Rendezvous.prototype._fulfill = function(id, trace) {
  3641.       var cb;
  3642.       if (this.waiters.length) {
  3643.         cb = this.waiters.shift();
  3644.         return cb(id);
  3645.       } else {
  3646.         return this.completed.push(id);
  3647.       }
  3648.     };
  3649.  
  3650.     Rendezvous.prototype._defer_with_id = function(id, defer_args, multi) {
  3651.       this.count++;
  3652.       return make_defer_return(this, defer_args, id, {}, multi);
  3653.     };
  3654.  
  3655.     return Rendezvous;
  3656.  
  3657.   })();
  3658.  
  3659.   exports.stackWalk = stackWalk = function(cb) {
  3660.     var line, ret, tr, _ref;
  3661.     ret = [];
  3662.     tr = cb ? cb[C.trace] : __active_trace;
  3663.     while (tr) {
  3664.       line = "   at " + (_trace_to_string(tr));
  3665.       ret.push(line);
  3666.       tr = tr != null ? (_ref = tr[C.parent]) != null ? _ref[C.trace] : void 0 : void 0;
  3667.     }
  3668.     return ret;
  3669.   };
  3670.  
  3671.   exports.exceptionHandler = exceptionHandler = function(err, logger) {
  3672.     var stack;
  3673.     if (!logger) {
  3674.       logger = console.error;
  3675.     }
  3676.     logger(err.stack);
  3677.     stack = stackWalk();
  3678.     if (stack.length) {
  3679.       logger("Iced 'stack' trace (w/ real line numbers):");
  3680.       return logger(stack.join("\n"));
  3681.     }
  3682.   };
  3683.  
  3684.   exports.catchExceptions = function(logger) {
  3685.     return typeof process !== "undefined" && process !== null ? process.on('uncaughtException', function(err) {
  3686.       exceptionHandler(err, logger);
  3687.       return process.exit(1);
  3688.     }) : void 0;
  3689.   };
  3690.  
  3691. }).call(this);
  3692.  
  3693. }).call(this,require('_process'))
  3694. },{"./const":11,"_process":6}],15:[function(require,module,exports){
  3695.  
  3696. var lib = require('./lib/lib.js');
  3697.  
  3698. // This is actually the one function that we expose.  The rest
  3699. // isn't ready to use, yet.
  3700. exports.generate = function(buffer) {
  3701.     var a = new Array(buffer.length);
  3702.     var i;
  3703.     for (i = 0; i < buffer.length; i++) {
  3704.         a[i] = buffer.readUInt8(i);
  3705.     }
  3706.     var key = new lib.Bitcoin.ECKey(a);
  3707.     var ret = {
  3708.         "public"  : key.getBitcoinAddress(),
  3709.         "private" : key.getBitcoinWalletImportFormat()
  3710.     };
  3711.     return ret;
  3712. };
  3713.  
  3714. },{"./lib/lib.js":16}],16:[function(require,module,exports){
  3715.  
  3716. var Crypto = exports.Crypto = {};
  3717. var Bitcoin = exports.Bitcoin = {};
  3718. // Array.prototype.map function is in the public domain.
  3719. // Production steps of ECMA-262, Edition 5, 15.4.4.19  
  3720. // Reference: http://es5.github.com/#x15.4.4.19  
  3721. if (!Array.prototype.map) {
  3722.     Array.prototype.map = function (callback, thisArg) {
  3723.         var T, A, k;
  3724.         if (this == null) {
  3725.             throw new TypeError(" this is null or not defined");
  3726.         }
  3727.         // 1. Let O be the result of calling ToObject passing the |this| value as the argument.  
  3728.         var O = Object(this);
  3729.         // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".  
  3730.         // 3. Let len be ToUint32(lenValue).  
  3731.         var len = O.length >>> 0;
  3732.         // 4. If IsCallable(callback) is false, throw a TypeError exception.  
  3733.         // See: http://es5.github.com/#x9.11  
  3734.         if ({}.toString.call(callback) != "[object Function]") {
  3735.             throw new TypeError(callback + " is not a function");
  3736.         }
  3737.         // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.  
  3738.         if (thisArg) {
  3739.             T = thisArg;
  3740.         }
  3741.         // 6. Let A be a new array created as if by the expression new Array(len) where Array is  
  3742.         // the standard built-in constructor with that name and len is the value of len.  
  3743.         A = new Array(len);
  3744.         // 7. Let k be 0  
  3745.         k = 0;
  3746.         // 8. Repeat, while k < len  
  3747.         while (k < len) {
  3748.             var kValue, mappedValue;
  3749.             // a. Let Pk be ToString(k).  
  3750.             //   This is implicit for LHS operands of the in operator  
  3751.             // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.  
  3752.             //   This step can be combined with c  
  3753.             // c. If kPresent is true, then  
  3754.             if (k in O) {
  3755.                 // i. Let kValue be the result of calling the Get internal method of O with argument Pk.  
  3756.                 kValue = O[k];
  3757.                 // ii. Let mappedValue be the result of calling the Call internal method of callback  
  3758.                 // with T as the this value and argument list containing kValue, k, and O.  
  3759.                 mappedValue = callback.call(T, kValue, k, O);
  3760.                 // iii. Call the DefineOwnProperty internal method of A with arguments  
  3761.                 // Pk, Property Descriptor {Value: mappedValue, Writable: true, Enumerable: true, Configurable: true},  
  3762.                 // and false.  
  3763.                 // In browsers that support Object.defineProperty, use the following:  
  3764.                 // Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });  
  3765.                 // For best browser support, use the following:  
  3766.                 A[k] = mappedValue;
  3767.             }
  3768.             // d. Increase k by 1.  
  3769.             k++;
  3770.         }
  3771.         // 9. return A  
  3772.         return A;
  3773.     };
  3774. }/*!
  3775. * Basic JavaScript BN library - subset useful for RSA encryption. v1.3
  3776. *
  3777. * Copyright (c) 2005  Tom Wu
  3778. * All Rights Reserved.
  3779. * BSD License
  3780. * http://www-cs-students.stanford.edu/~tjw/jsbn/LICENSE
  3781. *
  3782. * Copyright Stephan Thomas
  3783. * Copyright bitaddress.org
  3784. */
  3785.  
  3786.  
  3787. (function (x) {
  3788.  
  3789.     // (public) Constructor function of Global BigInteger object
  3790.     var BigInteger = x.BigInteger = function BigInteger(a, b, c) {
  3791.         if (a != null)
  3792.             if ("number" == typeof a) this.fromNumber(a, b, c);
  3793.             else if (b == null && "string" != typeof a) this.fromString(a, 256);
  3794.             else this.fromString(a, b);
  3795.     };
  3796.  
  3797.     // Bits per digit
  3798.     var dbits;
  3799.  
  3800.     // JavaScript engine analysis
  3801.     var canary = 0xdeadbeefcafe;
  3802.     var j_lm = ((canary & 0xffffff) == 0xefcafe);
  3803.  
  3804.     // return new, unset BigInteger
  3805.     function nbi() { return new BigInteger(null); }
  3806.  
  3807.     // am: Compute w_j += (x*this_i), propagate carries,
  3808.     // c is initial carry, returns final carry.
  3809.     // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
  3810.     // We need to select the fastest one that works in this environment.
  3811.  
  3812.     // am1: use a single mult and divide to get the high bits,
  3813.     // max digit bits should be 26 because
  3814.     // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
  3815.     function am1(i, x, w, j, c, n) {
  3816.         while (--n >= 0) {
  3817.             var v = x * this[i++] + w[j] + c;
  3818.             c = Math.floor(v / 0x4000000);
  3819.             w[j++] = v & 0x3ffffff;
  3820.         }
  3821.         return c;
  3822.     }
  3823.     // am2 avoids a big mult-and-extract completely.
  3824.     // Max digit bits should be <= 30 because we do bitwise ops
  3825.     // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
  3826.     function am2(i, x, w, j, c, n) {
  3827.         var xl = x & 0x7fff, xh = x >> 15;
  3828.         while (--n >= 0) {
  3829.             var l = this[i] & 0x7fff;
  3830.             var h = this[i++] >> 15;
  3831.             var m = xh * l + h * xl;
  3832.             l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff);
  3833.             c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30);
  3834.             w[j++] = l & 0x3fffffff;
  3835.         }
  3836.         return c;
  3837.     }
  3838.     // Alternately, set max digit bits to 28 since some
  3839.     // browsers slow down when dealing with 32-bit numbers.
  3840.     function am3(i, x, w, j, c, n) {
  3841.         var xl = x & 0x3fff, xh = x >> 14;
  3842.         while (--n >= 0) {
  3843.             var l = this[i] & 0x3fff;
  3844.             var h = this[i++] >> 14;
  3845.             var m = xh * l + h * xl;
  3846.             l = xl * l + ((m & 0x3fff) << 14) + w[j] + c;
  3847.             c = (l >> 28) + (m >> 14) + xh * h;
  3848.             w[j++] = l & 0xfffffff;
  3849.         }
  3850.         return c;
  3851.     }
  3852.  
  3853.     // Hardcode this for modern browsers
  3854.     BigInteger.prototype.am = am3;
  3855.     dbits = 28;
  3856.  
  3857.     BigInteger.prototype.DB = dbits;
  3858.     BigInteger.prototype.DM = ((1 << dbits) - 1);
  3859.     BigInteger.prototype.DV = (1 << dbits);
  3860.  
  3861.     var BI_FP = 52;
  3862.     BigInteger.prototype.FV = Math.pow(2, BI_FP);
  3863.     BigInteger.prototype.F1 = BI_FP - dbits;
  3864.     BigInteger.prototype.F2 = 2 * dbits - BI_FP;
  3865.  
  3866.     // Digit conversions
  3867.     var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
  3868.     var BI_RC = new Array();
  3869.     var rr, vv;
  3870.     rr = "0".charCodeAt(0);
  3871.     for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
  3872.     rr = "a".charCodeAt(0);
  3873.     for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
  3874.     rr = "A".charCodeAt(0);
  3875.     for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
  3876.  
  3877.     function int2char(n) { return BI_RM.charAt(n); }
  3878.     function intAt(s, i) {
  3879.         var c = BI_RC[s.charCodeAt(i)];
  3880.         return (c == null) ? -1 : c;
  3881.     }
  3882.  
  3883.  
  3884.  
  3885.     // return bigint initialized to value
  3886.     function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
  3887.  
  3888.  
  3889.     // returns bit length of the integer x
  3890.     function nbits(x) {
  3891.         var r = 1, t;
  3892.         if ((t = x >>> 16) != 0) { x = t; r += 16; }
  3893.         if ((t = x >> 8) != 0) { x = t; r += 8; }
  3894.         if ((t = x >> 4) != 0) { x = t; r += 4; }
  3895.         if ((t = x >> 2) != 0) { x = t; r += 2; }
  3896.         if ((t = x >> 1) != 0) { x = t; r += 1; }
  3897.         return r;
  3898.     }
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.  
  3905.  
  3906.     // (protected) copy this to r
  3907.     BigInteger.prototype.copyTo = function (r) {
  3908.         for (var i = this.t - 1; i >= 0; --i) r[i] = this[i];
  3909.         r.t = this.t;
  3910.         r.s = this.s;
  3911.     };
  3912.  
  3913.  
  3914.     // (protected) set from integer value x, -DV <= x < DV
  3915.     BigInteger.prototype.fromInt = function (x) {
  3916.         this.t = 1;
  3917.         this.s = (x < 0) ? -1 : 0;
  3918.         if (x > 0) this[0] = x;
  3919.         else if (x < -1) this[0] = x + DV;
  3920.         else this.t = 0;
  3921.     };
  3922.  
  3923.     // (protected) set from string and radix
  3924.     BigInteger.prototype.fromString = function (s, b) {
  3925.         var k;
  3926.         if (b == 16) k = 4;
  3927.         else if (b == 8) k = 3;
  3928.         else if (b == 256) k = 8; // byte array
  3929.         else if (b == 2) k = 1;
  3930.         else if (b == 32) k = 5;
  3931.         else if (b == 4) k = 2;
  3932.         else { this.fromRadix(s, b); return; }
  3933.         this.t = 0;
  3934.         this.s = 0;
  3935.         var i = s.length, mi = false, sh = 0;
  3936.         while (--i >= 0) {
  3937.             var x = (k == 8) ? s[i] & 0xff : intAt(s, i);
  3938.             if (x < 0) {
  3939.                 if (s.charAt(i) == "-") mi = true;
  3940.                 continue;
  3941.             }
  3942.             mi = false;
  3943.             if (sh == 0)
  3944.                 this[this.t++] = x;
  3945.             else if (sh + k > this.DB) {
  3946.                 this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh;
  3947.                 this[this.t++] = (x >> (this.DB - sh));
  3948.             }
  3949.             else
  3950.                 this[this.t - 1] |= x << sh;
  3951.             sh += k;
  3952.             if (sh >= this.DB) sh -= this.DB;
  3953.         }
  3954.         if (k == 8 && (s[0] & 0x80) != 0) {
  3955.             this.s = -1;
  3956.             if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh;
  3957.         }
  3958.         this.clamp();
  3959.         if (mi) BigInteger.ZERO.subTo(this, this);
  3960.     };
  3961.  
  3962.  
  3963.     // (protected) clamp off excess high words
  3964.     BigInteger.prototype.clamp = function () {
  3965.         var c = this.s & this.DM;
  3966.         while (this.t > 0 && this[this.t - 1] == c) --this.t;
  3967.     };
  3968.  
  3969.     // (protected) r = this << n*DB
  3970.     BigInteger.prototype.dlShiftTo = function (n, r) {
  3971.         var i;
  3972.         for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i];
  3973.         for (i = n - 1; i >= 0; --i) r[i] = 0;
  3974.         r.t = this.t + n;
  3975.         r.s = this.s;
  3976.     };
  3977.  
  3978.     // (protected) r = this >> n*DB
  3979.     BigInteger.prototype.drShiftTo = function (n, r) {
  3980.         for (var i = n; i < this.t; ++i) r[i - n] = this[i];
  3981.         r.t = Math.max(this.t - n, 0);
  3982.         r.s = this.s;
  3983.     };
  3984.  
  3985.  
  3986.     // (protected) r = this << n
  3987.     BigInteger.prototype.lShiftTo = function (n, r) {
  3988.         var bs = n % this.DB;
  3989.         var cbs = this.DB - bs;
  3990.         var bm = (1 << cbs) - 1;
  3991.         var ds = Math.floor(n / this.DB), c = (this.s << bs) & this.DM, i;
  3992.         for (i = this.t - 1; i >= 0; --i) {
  3993.             r[i + ds + 1] = (this[i] >> cbs) | c;
  3994.             c = (this[i] & bm) << bs;
  3995.         }
  3996.         for (i = ds - 1; i >= 0; --i) r[i] = 0;
  3997.         r[ds] = c;
  3998.         r.t = this.t + ds + 1;
  3999.         r.s = this.s;
  4000.         r.clamp();
  4001.     };
  4002.  
  4003.  
  4004.     // (protected) r = this >> n
  4005.     BigInteger.prototype.rShiftTo = function (n, r) {
  4006.         r.s = this.s;
  4007.         var ds = Math.floor(n / this.DB);
  4008.         if (ds >= this.t) { r.t = 0; return; }
  4009.         var bs = n % this.DB;
  4010.         var cbs = this.DB - bs;
  4011.         var bm = (1 << bs) - 1;
  4012.         r[0] = this[ds] >> bs;
  4013.         for (var i = ds + 1; i < this.t; ++i) {
  4014.             r[i - ds - 1] |= (this[i] & bm) << cbs;
  4015.             r[i - ds] = this[i] >> bs;
  4016.         }
  4017.         if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs;
  4018.         r.t = this.t - ds;
  4019.         r.clamp();
  4020.     };
  4021.  
  4022.  
  4023.     // (protected) r = this - a
  4024.     BigInteger.prototype.subTo = function (a, r) {
  4025.         var i = 0, c = 0, m = Math.min(a.t, this.t);
  4026.         while (i < m) {
  4027.             c += this[i] - a[i];
  4028.             r[i++] = c & this.DM;
  4029.             c >>= this.DB;
  4030.         }
  4031.         if (a.t < this.t) {
  4032.             c -= a.s;
  4033.             while (i < this.t) {
  4034.                 c += this[i];
  4035.                 r[i++] = c & this.DM;
  4036.                 c >>= this.DB;
  4037.             }
  4038.             c += this.s;
  4039.         }
  4040.         else {
  4041.             c += this.s;
  4042.             while (i < a.t) {
  4043.                 c -= a[i];
  4044.                 r[i++] = c & this.DM;
  4045.                 c >>= this.DB;
  4046.             }
  4047.             c -= a.s;
  4048.         }
  4049.         r.s = (c < 0) ? -1 : 0;
  4050.         if (c < -1) r[i++] = this.DV + c;
  4051.         else if (c > 0) r[i++] = c;
  4052.         r.t = i;
  4053.         r.clamp();
  4054.     };
  4055.  
  4056.  
  4057.     // (protected) r = this * a, r != this,a (HAC 14.12)
  4058.     // "this" should be the larger one if appropriate.
  4059.     BigInteger.prototype.multiplyTo = function (a, r) {
  4060.         var x = this.abs(), y = a.abs();
  4061.         var i = x.t;
  4062.         r.t = i + y.t;
  4063.         while (--i >= 0) r[i] = 0;
  4064.         for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t);
  4065.         r.s = 0;
  4066.         r.clamp();
  4067.         if (this.s != a.s) BigInteger.ZERO.subTo(r, r);
  4068.     };
  4069.  
  4070.  
  4071.     // (protected) r = this^2, r != this (HAC 14.16)
  4072.     BigInteger.prototype.squareTo = function (r) {
  4073.         var x = this.abs();
  4074.         var i = r.t = 2 * x.t;
  4075.         while (--i >= 0) r[i] = 0;
  4076.         for (i = 0; i < x.t - 1; ++i) {
  4077.             var c = x.am(i, x[i], r, 2 * i, 0, 1);
  4078.             if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {
  4079.                 r[i + x.t] -= x.DV;
  4080.                 r[i + x.t + 1] = 1;
  4081.             }
  4082.         }
  4083.         if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1);
  4084.         r.s = 0;
  4085.         r.clamp();
  4086.     };
  4087.  
  4088.  
  4089.  
  4090.     // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
  4091.     // r != q, this != m.  q or r may be null.
  4092.     BigInteger.prototype.divRemTo = function (m, q, r) {
  4093.         var pm = m.abs();
  4094.         if (pm.t <= 0) return;
  4095.         var pt = this.abs();
  4096.         if (pt.t < pm.t) {
  4097.             if (q != null) q.fromInt(0);
  4098.             if (r != null) this.copyTo(r);
  4099.             return;
  4100.         }
  4101.         if (r == null) r = nbi();
  4102.         var y = nbi(), ts = this.s, ms = m.s;
  4103.         var nsh = this.DB - nbits(pm[pm.t - 1]); // normalize modulus
  4104.         if (nsh > 0) { pm.lShiftTo(nsh, y); pt.lShiftTo(nsh, r); }
  4105.         else { pm.copyTo(y); pt.copyTo(r); }
  4106.         var ys = y.t;
  4107.         var y0 = y[ys - 1];
  4108.         if (y0 == 0) return;
  4109.         var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0);
  4110.         var d1 = this.FV / yt, d2 = (1 << this.F1) / yt, e = 1 << this.F2;
  4111.         var i = r.t, j = i - ys, t = (q == null) ? nbi() : q;
  4112.         y.dlShiftTo(j, t);
  4113.         if (r.compareTo(t) >= 0) {
  4114.             r[r.t++] = 1;
  4115.             r.subTo(t, r);
  4116.         }
  4117.         BigInteger.ONE.dlShiftTo(ys, t);
  4118.         t.subTo(y, y); // "negative" y so we can replace sub with am later
  4119.         while (y.t < ys) y[y.t++] = 0;
  4120.         while (--j >= 0) {
  4121.             // Estimate quotient digit
  4122.             var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2);
  4123.             if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) {  // Try it out
  4124.                 y.dlShiftTo(j, t);
  4125.                 r.subTo(t, r);
  4126.                 while (r[i] < --qd) r.subTo(t, r);
  4127.             }
  4128.         }
  4129.         if (q != null) {
  4130.             r.drShiftTo(ys, q);
  4131.             if (ts != ms) BigInteger.ZERO.subTo(q, q);
  4132.         }
  4133.         r.t = ys;
  4134.         r.clamp();
  4135.         if (nsh > 0) r.rShiftTo(nsh, r); // Denormalize remainder
  4136.         if (ts < 0) BigInteger.ZERO.subTo(r, r);
  4137.     };
  4138.  
  4139.  
  4140.     // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
  4141.     // justification:
  4142.     //         xy == 1 (mod m)
  4143.     //         xy =  1+km
  4144.     //   xy(2-xy) = (1+km)(1-km)
  4145.     // x[y(2-xy)] = 1-k^2m^2
  4146.     // x[y(2-xy)] == 1 (mod m^2)
  4147.     // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
  4148.     // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
  4149.     // JS multiply "overflows" differently from C/C++, so care is needed here.
  4150.     BigInteger.prototype.invDigit = function () {
  4151.         if (this.t < 1) return 0;
  4152.         var x = this[0];
  4153.         if ((x & 1) == 0) return 0;
  4154.         var y = x & 3;  // y == 1/x mod 2^2
  4155.         y = (y * (2 - (x & 0xf) * y)) & 0xf; // y == 1/x mod 2^4
  4156.         y = (y * (2 - (x & 0xff) * y)) & 0xff; // y == 1/x mod 2^8
  4157.         y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff; // y == 1/x mod 2^16
  4158.         // last step - calculate inverse mod DV directly;
  4159.         // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
  4160.         y = (y * (2 - x * y % this.DV)) % this.DV;  // y == 1/x mod 2^dbits
  4161.         // we really want the negative inverse, and -DV < y < DV
  4162.         return (y > 0) ? this.DV - y : -y;
  4163.     };
  4164.  
  4165.  
  4166.     // (protected) true iff this is even
  4167.     BigInteger.prototype.isEven = function () { return ((this.t > 0) ? (this[0] & 1) : this.s) == 0; };
  4168.  
  4169.  
  4170.     // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
  4171.     BigInteger.prototype.exp = function (e, z) {
  4172.         if (e > 0xffffffff || e < 1) return BigInteger.ONE;
  4173.         var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e) - 1;
  4174.         g.copyTo(r);
  4175.         while (--i >= 0) {
  4176.             z.sqrTo(r, r2);
  4177.             if ((e & (1 << i)) > 0) z.mulTo(r2, g, r);
  4178.             else { var t = r; r = r2; r2 = t; }
  4179.         }
  4180.         return z.revert(r);
  4181.     };
  4182.  
  4183.  
  4184.     // (public) return string representation in given radix
  4185.     BigInteger.prototype.toString = function (b) {
  4186.         if (this.s < 0) return "-" + this.negate().toString(b);
  4187.         var k;
  4188.         if (b == 16) k = 4;
  4189.         else if (b == 8) k = 3;
  4190.         else if (b == 2) k = 1;
  4191.         else if (b == 32) k = 5;
  4192.         else if (b == 4) k = 2;
  4193.         else return this.toRadix(b);
  4194.         var km = (1 << k) - 1, d, m = false, r = "", i = this.t;
  4195.         var p = this.DB - (i * this.DB) % k;
  4196.         if (i-- > 0) {
  4197.             if (p < this.DB && (d = this[i] >> p) > 0) { m = true; r = int2char(d); }
  4198.             while (i >= 0) {
  4199.                 if (p < k) {
  4200.                     d = (this[i] & ((1 << p) - 1)) << (k - p);
  4201.                     d |= this[--i] >> (p += this.DB - k);
  4202.                 }
  4203.                 else {
  4204.                     d = (this[i] >> (p -= k)) & km;
  4205.                     if (p <= 0) { p += this.DB; --i; }
  4206.                 }
  4207.                 if (d > 0) m = true;
  4208.                 if (m) r += int2char(d);
  4209.             }
  4210.         }
  4211.         return m ? r : "0";
  4212.     };
  4213.  
  4214.  
  4215.     // (public) -this
  4216.     BigInteger.prototype.negate = function () { var r = nbi(); BigInteger.ZERO.subTo(this, r); return r; };
  4217.  
  4218.     // (public) |this|
  4219.     BigInteger.prototype.abs = function () { return (this.s < 0) ? this.negate() : this; };
  4220.  
  4221.     // (public) return + if this > a, - if this < a, 0 if equal
  4222.     BigInteger.prototype.compareTo = function (a) {
  4223.         var r = this.s - a.s;
  4224.         if (r != 0) return r;
  4225.         var i = this.t;
  4226.         r = i - a.t;
  4227.         if (r != 0) return (this.s < 0) ? -r : r;
  4228.         while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r;
  4229.         return 0;
  4230.     }
  4231.  
  4232.     // (public) return the number of bits in "this"
  4233.     BigInteger.prototype.bitLength = function () {
  4234.         if (this.t <= 0) return 0;
  4235.         return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM));
  4236.     };
  4237.  
  4238.     // (public) this mod a
  4239.     BigInteger.prototype.mod = function (a) {
  4240.         var r = nbi();
  4241.         this.abs().divRemTo(a, null, r);
  4242.         if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r);
  4243.         return r;
  4244.     }
  4245.  
  4246.     // (public) this^e % m, 0 <= e < 2^32
  4247.     BigInteger.prototype.modPowInt = function (e, m) {
  4248.         var z;
  4249.         if (e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
  4250.         return this.exp(e, z);
  4251.     };
  4252.  
  4253.     // "constants"
  4254.     BigInteger.ZERO = nbv(0);
  4255.     BigInteger.ONE = nbv(1);
  4256.  
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.  
  4263.     // Copyright (c) 2005-2009  Tom Wu
  4264.     // All Rights Reserved.
  4265.     // See "LICENSE" for details.
  4266.     // Extended JavaScript BN functions, required for RSA private ops.
  4267.     // Version 1.1: new BigInteger("0", 10) returns "proper" zero
  4268.     // Version 1.2: square() API, isProbablePrime fix
  4269.  
  4270.  
  4271.     // return index of lowest 1-bit in x, x < 2^31
  4272.     function lbit(x) {
  4273.         if (x == 0) return -1;
  4274.         var r = 0;
  4275.         if ((x & 0xffff) == 0) { x >>= 16; r += 16; }
  4276.         if ((x & 0xff) == 0) { x >>= 8; r += 8; }
  4277.         if ((x & 0xf) == 0) { x >>= 4; r += 4; }
  4278.         if ((x & 3) == 0) { x >>= 2; r += 2; }
  4279.         if ((x & 1) == 0) ++r;
  4280.         return r;
  4281.     }
  4282.  
  4283.     // return number of 1 bits in x
  4284.     function cbit(x) {
  4285.         var r = 0;
  4286.         while (x != 0) { x &= x - 1; ++r; }
  4287.         return r;
  4288.     }
  4289.  
  4290.     var lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
  4291.     var lplim = (1 << 26) / lowprimes[lowprimes.length - 1];
  4292.  
  4293.  
  4294.  
  4295.     // (protected) return x s.t. r^x < DV
  4296.     BigInteger.prototype.chunkSize = function (r) { return Math.floor(Math.LN2 * this.DB / Math.log(r)); };
  4297.  
  4298.     // (protected) convert to radix string
  4299.     BigInteger.prototype.toRadix = function (b) {
  4300.         if (b == null) b = 10;
  4301.         if (this.signum() == 0 || b < 2 || b > 36) return "0";
  4302.         var cs = this.chunkSize(b);
  4303.         var a = Math.pow(b, cs);
  4304.         var d = nbv(a), y = nbi(), z = nbi(), r = "";
  4305.         this.divRemTo(d, y, z);
  4306.         while (y.signum() > 0) {
  4307.             r = (a + z.intValue()).toString(b).substr(1) + r;
  4308.             y.divRemTo(d, y, z);
  4309.         }
  4310.         return z.intValue().toString(b) + r;
  4311.     };
  4312.  
  4313.     // (protected) convert from radix string
  4314.     BigInteger.prototype.fromRadix = function (s, b) {
  4315.         this.fromInt(0);
  4316.         if (b == null) b = 10;
  4317.         var cs = this.chunkSize(b);
  4318.         var d = Math.pow(b, cs), mi = false, j = 0, w = 0;
  4319.         for (var i = 0; i < s.length; ++i) {
  4320.             var x = intAt(s, i);
  4321.             if (x < 0) {
  4322.                 if (s.charAt(i) == "-" && this.signum() == 0) mi = true;
  4323.                 continue;
  4324.             }
  4325.             w = b * w + x;
  4326.             if (++j >= cs) {
  4327.                 this.dMultiply(d);
  4328.                 this.dAddOffset(w, 0);
  4329.                 j = 0;
  4330.                 w = 0;
  4331.             }
  4332.         }
  4333.         if (j > 0) {
  4334.             this.dMultiply(Math.pow(b, j));
  4335.             this.dAddOffset(w, 0);
  4336.         }
  4337.         if (mi) BigInteger.ZERO.subTo(this, this);
  4338.     };
  4339.  
  4340.     // (protected) alternate constructor
  4341.     BigInteger.prototype.fromNumber = function (a, b, c) {
  4342.         if ("number" == typeof b) {
  4343.             // new BigInteger(int,int,RNG)
  4344.             if (a < 2) this.fromInt(1);
  4345.             else {
  4346.                 this.fromNumber(a, c);
  4347.                 if (!this.testBit(a - 1))   // force MSB set
  4348.                     this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this);
  4349.                 if (this.isEven()) this.dAddOffset(1, 0); // force odd
  4350.                 while (!this.isProbablePrime(b)) {
  4351.                     this.dAddOffset(2, 0);
  4352.                     if (this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a - 1), this);
  4353.                 }
  4354.             }
  4355.         }
  4356.         else {
  4357.             // new BigInteger(int,RNG)
  4358.             var x = new Array(), t = a & 7;
  4359.             x.length = (a >> 3) + 1;
  4360.             b.nextBytes(x);
  4361.             if (t > 0) x[0] &= ((1 << t) - 1); else x[0] = 0;
  4362.             this.fromString(x, 256);
  4363.         }
  4364.     };
  4365.  
  4366.     // (protected) r = this op a (bitwise)
  4367.     BigInteger.prototype.bitwiseTo = function (a, op, r) {
  4368.         var i, f, m = Math.min(a.t, this.t);
  4369.         for (i = 0; i < m; ++i) r[i] = op(this[i], a[i]);
  4370.         if (a.t < this.t) {
  4371.             f = a.s & this.DM;
  4372.             for (i = m; i < this.t; ++i) r[i] = op(this[i], f);
  4373.             r.t = this.t;
  4374.         }
  4375.         else {
  4376.             f = this.s & this.DM;
  4377.             for (i = m; i < a.t; ++i) r[i] = op(f, a[i]);
  4378.             r.t = a.t;
  4379.         }
  4380.         r.s = op(this.s, a.s);
  4381.         r.clamp();
  4382.     };
  4383.  
  4384.     // (protected) this op (1<<n)
  4385.     BigInteger.prototype.changeBit = function (n, op) {
  4386.         var r = BigInteger.ONE.shiftLeft(n);
  4387.         this.bitwiseTo(r, op, r);
  4388.         return r;
  4389.     };
  4390.  
  4391.     // (protected) r = this + a
  4392.     BigInteger.prototype.addTo = function (a, r) {
  4393.         var i = 0, c = 0, m = Math.min(a.t, this.t);
  4394.         while (i < m) {
  4395.             c += this[i] + a[i];
  4396.             r[i++] = c & this.DM;
  4397.             c >>= this.DB;
  4398.         }
  4399.         if (a.t < this.t) {
  4400.             c += a.s;
  4401.             while (i < this.t) {
  4402.                 c += this[i];
  4403.                 r[i++] = c & this.DM;
  4404.                 c >>= this.DB;
  4405.             }
  4406.             c += this.s;
  4407.         }
  4408.         else {
  4409.             c += this.s;
  4410.             while (i < a.t) {
  4411.                 c += a[i];
  4412.                 r[i++] = c & this.DM;
  4413.                 c >>= this.DB;
  4414.             }
  4415.             c += a.s;
  4416.         }
  4417.         r.s = (c < 0) ? -1 : 0;
  4418.         if (c > 0) r[i++] = c;
  4419.         else if (c < -1) r[i++] = this.DV + c;
  4420.         r.t = i;
  4421.         r.clamp();
  4422.     };
  4423.  
  4424.     // (protected) this *= n, this >= 0, 1 < n < DV
  4425.     BigInteger.prototype.dMultiply = function (n) {
  4426.         this[this.t] = this.am(0, n - 1, this, 0, 0, this.t);
  4427.         ++this.t;
  4428.         this.clamp();
  4429.     };
  4430.  
  4431.     // (protected) this += n << w words, this >= 0
  4432.     BigInteger.prototype.dAddOffset = function (n, w) {
  4433.         if (n == 0) return;
  4434.         while (this.t <= w) this[this.t++] = 0;
  4435.         this[w] += n;
  4436.         while (this[w] >= this.DV) {
  4437.             this[w] -= this.DV;
  4438.             if (++w >= this.t) this[this.t++] = 0;
  4439.             ++this[w];
  4440.         }
  4441.     };
  4442.  
  4443.     // (protected) r = lower n words of "this * a", a.t <= n
  4444.     // "this" should be the larger one if appropriate.
  4445.     BigInteger.prototype.multiplyLowerTo = function (a, n, r) {
  4446.         var i = Math.min(this.t + a.t, n);
  4447.         r.s = 0; // assumes a,this >= 0
  4448.         r.t = i;
  4449.         while (i > 0) r[--i] = 0;
  4450.         var j;
  4451.         for (j = r.t - this.t; i < j; ++i) r[i + this.t] = this.am(0, a[i], r, i, 0, this.t);
  4452.         for (j = Math.min(a.t, n); i < j; ++i) this.am(0, a[i], r, i, 0, n - i);
  4453.         r.clamp();
  4454.     };
  4455.  
  4456.  
  4457.     // (protected) r = "this * a" without lower n words, n > 0
  4458.     // "this" should be the larger one if appropriate.
  4459.     BigInteger.prototype.multiplyUpperTo = function (a, n, r) {
  4460.         --n;
  4461.         var i = r.t = this.t + a.t - n;
  4462.         r.s = 0; // assumes a,this >= 0
  4463.         while (--i >= 0) r[i] = 0;
  4464.         for (i = Math.max(n - this.t, 0); i < a.t; ++i)
  4465.             r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n);
  4466.         r.clamp();
  4467.         r.drShiftTo(1, r);
  4468.     };
  4469.  
  4470.     // (protected) this % n, n < 2^26
  4471.     BigInteger.prototype.modInt = function (n) {
  4472.         if (n <= 0) return 0;
  4473.         var d = this.DV % n, r = (this.s < 0) ? n - 1 : 0;
  4474.         if (this.t > 0)
  4475.             if (d == 0) r = this[0] % n;
  4476.             else for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n;
  4477.         return r;
  4478.     };
  4479.  
  4480.  
  4481.     // (protected) true if probably prime (HAC 4.24, Miller-Rabin)
  4482.     BigInteger.prototype.millerRabin = function (t) {
  4483.         var n1 = this.subtract(BigInteger.ONE);
  4484.         var k = n1.getLowestSetBit();
  4485.         if (k <= 0) return false;
  4486.         var r = n1.shiftRight(k);
  4487.         t = (t + 1) >> 1;
  4488.         if (t > lowprimes.length) t = lowprimes.length;
  4489.         var a = nbi();
  4490.         for (var i = 0; i < t; ++i) {
  4491.             //Pick bases at random, instead of starting at 2
  4492.             a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]);
  4493.             var y = a.modPow(r, this);
  4494.             if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
  4495.                 var j = 1;
  4496.                 while (j++ < k && y.compareTo(n1) != 0) {
  4497.                     y = y.modPowInt(2, this);
  4498.                     if (y.compareTo(BigInteger.ONE) == 0) return false;
  4499.                 }
  4500.                 if (y.compareTo(n1) != 0) return false;
  4501.             }
  4502.         }
  4503.         return true;
  4504.     };
  4505.  
  4506.  
  4507.  
  4508.     // (public)
  4509.     BigInteger.prototype.clone = function () { var r = nbi(); this.copyTo(r); return r; };
  4510.  
  4511.     // (public) return value as integer
  4512.     BigInteger.prototype.intValue = function () {
  4513.         if (this.s < 0) {
  4514.             if (this.t == 1) return this[0] - this.DV;
  4515.             else if (this.t == 0) return -1;
  4516.         }
  4517.         else if (this.t == 1) return this[0];
  4518.         else if (this.t == 0) return 0;
  4519.         // assumes 16 < DB < 32
  4520.         return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0];
  4521.     };
  4522.  
  4523.  
  4524.     // (public) return value as byte
  4525.     BigInteger.prototype.byteValue = function () { return (this.t == 0) ? this.s : (this[0] << 24) >> 24; };
  4526.  
  4527.     // (public) return value as short (assumes DB>=16)
  4528.     BigInteger.prototype.shortValue = function () { return (this.t == 0) ? this.s : (this[0] << 16) >> 16; };
  4529.  
  4530.     // (public) 0 if this == 0, 1 if this > 0
  4531.     BigInteger.prototype.signum = function () {
  4532.         if (this.s < 0) return -1;
  4533.         else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
  4534.         else return 1;
  4535.     };
  4536.  
  4537.  
  4538.     // (public) convert to bigendian byte array
  4539.     BigInteger.prototype.toByteArray = function () {
  4540.         var i = this.t, r = new Array();
  4541.         r[0] = this.s;
  4542.         var p = this.DB - (i * this.DB) % 8, d, k = 0;
  4543.         if (i-- > 0) {
  4544.             if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p)
  4545.                 r[k++] = d | (this.s << (this.DB - p));
  4546.             while (i >= 0) {
  4547.                 if (p < 8) {
  4548.                     d = (this[i] & ((1 << p) - 1)) << (8 - p);
  4549.                     d |= this[--i] >> (p += this.DB - 8);
  4550.                 }
  4551.                 else {
  4552.                     d = (this[i] >> (p -= 8)) & 0xff;
  4553.                     if (p <= 0) { p += this.DB; --i; }
  4554.                 }
  4555.                 if ((d & 0x80) != 0) d |= -256;
  4556.                 if (k == 0 && (this.s & 0x80) != (d & 0x80)) ++k;
  4557.                 if (k > 0 || d != this.s) r[k++] = d;
  4558.             }
  4559.         }
  4560.         return r;
  4561.     };
  4562.  
  4563.     BigInteger.prototype.equals = function (a) { return (this.compareTo(a) == 0); };
  4564.     BigInteger.prototype.min = function (a) { return (this.compareTo(a) < 0) ? this : a; };
  4565.     BigInteger.prototype.max = function (a) { return (this.compareTo(a) > 0) ? this : a; };
  4566.  
  4567.     // (public) this & a
  4568.     function op_and(x, y) { return x & y; }
  4569.     BigInteger.prototype.and = function (a) { var r = nbi(); this.bitwiseTo(a, op_and, r); return r; };
  4570.  
  4571.     // (public) this | a
  4572.     function op_or(x, y) { return x | y; }
  4573.     BigInteger.prototype.or = function (a) { var r = nbi(); this.bitwiseTo(a, op_or, r); return r; };
  4574.  
  4575.     // (public) this ^ a
  4576.     function op_xor(x, y) { return x ^ y; }
  4577.     BigInteger.prototype.xor = function (a) { var r = nbi(); this.bitwiseTo(a, op_xor, r); return r; };
  4578.  
  4579.     // (public) this & ~a
  4580.     function op_andnot(x, y) { return x & ~y; }
  4581.     BigInteger.prototype.andNot = function (a) { var r = nbi(); this.bitwiseTo(a, op_andnot, r); return r; };
  4582.  
  4583.     // (public) ~this
  4584.     BigInteger.prototype.not = function () {
  4585.         var r = nbi();
  4586.         for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i];
  4587.         r.t = this.t;
  4588.         r.s = ~this.s;
  4589.         return r;
  4590.     };
  4591.  
  4592.     // (public) this << n
  4593.     BigInteger.prototype.shiftLeft = function (n) {
  4594.         var r = nbi();
  4595.         if (n < 0) this.rShiftTo(-n, r); else this.lShiftTo(n, r);
  4596.         return r;
  4597.     };
  4598.  
  4599.     // (public) this >> n
  4600.     BigInteger.prototype.shiftRight = function (n) {
  4601.         var r = nbi();
  4602.         if (n < 0) this.lShiftTo(-n, r); else this.rShiftTo(n, r);
  4603.         return r;
  4604.     };
  4605.  
  4606.     // (public) returns index of lowest 1-bit (or -1 if none)
  4607.     BigInteger.prototype.getLowestSetBit = function () {
  4608.         for (var i = 0; i < this.t; ++i)
  4609.             if (this[i] != 0) return i * this.DB + lbit(this[i]);
  4610.         if (this.s < 0) return this.t * this.DB;
  4611.         return -1;
  4612.     };
  4613.  
  4614.     // (public) return number of set bits
  4615.     BigInteger.prototype.bitCount = function () {
  4616.         var r = 0, x = this.s & this.DM;
  4617.         for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x);
  4618.         return r;
  4619.     };
  4620.  
  4621.     // (public) true iff nth bit is set
  4622.     BigInteger.prototype.testBit = function (n) {
  4623.         var j = Math.floor(n / this.DB);
  4624.         if (j >= this.t) return (this.s != 0);
  4625.         return ((this[j] & (1 << (n % this.DB))) != 0);
  4626.     };
  4627.  
  4628.     // (public) this | (1<<n)
  4629.     BigInteger.prototype.setBit = function (n) { return this.changeBit(n, op_or); };
  4630.     // (public) this & ~(1<<n)
  4631.     BigInteger.prototype.clearBit = function (n) { return this.changeBit(n, op_andnot); };
  4632.     // (public) this ^ (1<<n)
  4633.     BigInteger.prototype.flipBit = function (n) { return this.changeBit(n, op_xor); };
  4634.     // (public) this + a
  4635.     BigInteger.prototype.add = function (a) { var r = nbi(); this.addTo(a, r); return r; };
  4636.     // (public) this - a
  4637.     BigInteger.prototype.subtract = function (a) { var r = nbi(); this.subTo(a, r); return r; };
  4638.     // (public) this * a
  4639.     BigInteger.prototype.multiply = function (a) { var r = nbi(); this.multiplyTo(a, r); return r; };
  4640.     // (public) this / a
  4641.     BigInteger.prototype.divide = function (a) { var r = nbi(); this.divRemTo(a, r, null); return r; };
  4642.     // (public) this % a
  4643.     BigInteger.prototype.remainder = function (a) { var r = nbi(); this.divRemTo(a, null, r); return r; };
  4644.     // (public) [this/a,this%a]
  4645.     BigInteger.prototype.divideAndRemainder = function (a) {
  4646.         var q = nbi(), r = nbi();
  4647.         this.divRemTo(a, q, r);
  4648.         return new Array(q, r);
  4649.     };
  4650.  
  4651.     // (public) this^e % m (HAC 14.85)
  4652.     BigInteger.prototype.modPow = function (e, m) {
  4653.         var i = e.bitLength(), k, r = nbv(1), z;
  4654.         if (i <= 0) return r;
  4655.         else if (i < 18) k = 1;
  4656.         else if (i < 48) k = 3;
  4657.         else if (i < 144) k = 4;
  4658.         else if (i < 768) k = 5;
  4659.         else k = 6;
  4660.         if (i < 8)
  4661.             z = new Classic(m);
  4662.         else if (m.isEven())
  4663.             z = new Barrett(m);
  4664.         else
  4665.             z = new Montgomery(m);
  4666.  
  4667.         // precomputation
  4668.         var g = new Array(), n = 3, k1 = k - 1, km = (1 << k) - 1;
  4669.         g[1] = z.convert(this);
  4670.         if (k > 1) {
  4671.             var g2 = nbi();
  4672.             z.sqrTo(g[1], g2);
  4673.             while (n <= km) {
  4674.                 g[n] = nbi();
  4675.                 z.mulTo(g2, g[n - 2], g[n]);
  4676.                 n += 2;
  4677.             }
  4678.         }
  4679.  
  4680.         var j = e.t - 1, w, is1 = true, r2 = nbi(), t;
  4681.         i = nbits(e[j]) - 1;
  4682.         while (j >= 0) {
  4683.             if (i >= k1) w = (e[j] >> (i - k1)) & km;
  4684.             else {
  4685.                 w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i);
  4686.                 if (j > 0) w |= e[j - 1] >> (this.DB + i - k1);
  4687.             }
  4688.  
  4689.             n = k;
  4690.             while ((w & 1) == 0) { w >>= 1; --n; }
  4691.             if ((i -= n) < 0) { i += this.DB; --j; }
  4692.             if (is1) {  // ret == 1, don't bother squaring or multiplying it
  4693.                 g[w].copyTo(r);
  4694.                 is1 = false;
  4695.             }
  4696.             else {
  4697.                 while (n > 1) { z.sqrTo(r, r2); z.sqrTo(r2, r); n -= 2; }
  4698.                 if (n > 0) z.sqrTo(r, r2); else { t = r; r = r2; r2 = t; }
  4699.                 z.mulTo(r2, g[w], r);
  4700.             }
  4701.  
  4702.             while (j >= 0 && (e[j] & (1 << i)) == 0) {
  4703.                 z.sqrTo(r, r2); t = r; r = r2; r2 = t;
  4704.                 if (--i < 0) { i = this.DB - 1; --j; }
  4705.             }
  4706.         }
  4707.         return z.revert(r);
  4708.     };
  4709.  
  4710.     // (public) 1/this % m (HAC 14.61)
  4711.     BigInteger.prototype.modInverse = function (m) {
  4712.         var ac = m.isEven();
  4713.         if ((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
  4714.         var u = m.clone(), v = this.clone();
  4715.         var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
  4716.         while (u.signum() != 0) {
  4717.             while (u.isEven()) {
  4718.                 u.rShiftTo(1, u);
  4719.                 if (ac) {
  4720.                     if (!a.isEven() || !b.isEven()) { a.addTo(this, a); b.subTo(m, b); }
  4721.                     a.rShiftTo(1, a);
  4722.                 }
  4723.                 else if (!b.isEven()) b.subTo(m, b);
  4724.                 b.rShiftTo(1, b);
  4725.             }
  4726.             while (v.isEven()) {
  4727.                 v.rShiftTo(1, v);
  4728.                 if (ac) {
  4729.                     if (!c.isEven() || !d.isEven()) { c.addTo(this, c); d.subTo(m, d); }
  4730.                     c.rShiftTo(1, c);
  4731.                 }
  4732.                 else if (!d.isEven()) d.subTo(m, d);
  4733.                 d.rShiftTo(1, d);
  4734.             }
  4735.             if (u.compareTo(v) >= 0) {
  4736.                 u.subTo(v, u);
  4737.                 if (ac) a.subTo(c, a);
  4738.                 b.subTo(d, b);
  4739.             }
  4740.             else {
  4741.                 v.subTo(u, v);
  4742.                 if (ac) c.subTo(a, c);
  4743.                 d.subTo(b, d);
  4744.             }
  4745.         }
  4746.         if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
  4747.         if (d.compareTo(m) >= 0) return d.subtract(m);
  4748.         if (d.signum() < 0) d.addTo(m, d); else return d;
  4749.         if (d.signum() < 0) return d.add(m); else return d;
  4750.     };
  4751.  
  4752.  
  4753.     // (public) this^e
  4754.     BigInteger.prototype.pow = function (e) { return this.exp(e, new NullExp()); };
  4755.  
  4756.     // (public) gcd(this,a) (HAC 14.54)
  4757.     BigInteger.prototype.gcd = function (a) {
  4758.         var x = (this.s < 0) ? this.negate() : this.clone();
  4759.         var y = (a.s < 0) ? a.negate() : a.clone();
  4760.         if (x.compareTo(y) < 0) { var t = x; x = y; y = t; }
  4761.         var i = x.getLowestSetBit(), g = y.getLowestSetBit();
  4762.         if (g < 0) return x;
  4763.         if (i < g) g = i;
  4764.         if (g > 0) {
  4765.             x.rShiftTo(g, x);
  4766.             y.rShiftTo(g, y);
  4767.         }
  4768.         while (x.signum() > 0) {
  4769.             if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x);
  4770.             if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y);
  4771.             if (x.compareTo(y) >= 0) {
  4772.                 x.subTo(y, x);
  4773.                 x.rShiftTo(1, x);
  4774.             }
  4775.             else {
  4776.                 y.subTo(x, y);
  4777.                 y.rShiftTo(1, y);
  4778.             }
  4779.         }
  4780.         if (g > 0) y.lShiftTo(g, y);
  4781.         return y;
  4782.     };
  4783.  
  4784.     // (public) test primality with certainty >= 1-.5^t
  4785.     BigInteger.prototype.isProbablePrime = function (t) {
  4786.         var i, x = this.abs();
  4787.         if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {
  4788.             for (i = 0; i < lowprimes.length; ++i)
  4789.                 if (x[0] == lowprimes[i]) return true;
  4790.             return false;
  4791.         }
  4792.         if (x.isEven()) return false;
  4793.         i = 1;
  4794.         while (i < lowprimes.length) {
  4795.             var m = lowprimes[i], j = i + 1;
  4796.             while (j < lowprimes.length && m < lplim) m *= lowprimes[j++];
  4797.             m = x.modInt(m);
  4798.             while (i < j) if (m % lowprimes[i++] == 0) return false;
  4799.         }
  4800.         return x.millerRabin(t);
  4801.     };
  4802.  
  4803.  
  4804.     // JSBN-specific extension
  4805.  
  4806.     // (public) this^2
  4807.     BigInteger.prototype.square = function () { var r = nbi(); this.squareTo(r); return r; };
  4808.  
  4809.  
  4810.     // NOTE: BigInteger interfaces not implemented in jsbn:
  4811.     // BigInteger(int signum, byte[] magnitude)
  4812.     // double doubleValue()
  4813.     // float floatValue()
  4814.     // int hashCode()
  4815.     // long longValue()
  4816.     // static BigInteger valueOf(long val)
  4817.  
  4818.  
  4819.  
  4820.     // Copyright Stephan Thomas (start) --- //
  4821.     // https://raw.github.com/bitcoinjs/bitcoinjs-lib/07f9d55ccb6abd962efb6befdd37671f85ea4ff9/src/util.js
  4822.     // BigInteger monkey patching
  4823.     BigInteger.valueOf = nbv;
  4824.  
  4825.     /**
  4826.     * Returns a byte array representation of the big integer.
  4827.     *
  4828.     * This returns the absolute of the contained value in big endian
  4829.     * form. A value of zero results in an empty array.
  4830.     */
  4831.     BigInteger.prototype.toByteArrayUnsigned = function () {
  4832.         var ba = this.abs().toByteArray();
  4833.         if (ba.length) {
  4834.             if (ba[0] == 0) {
  4835.                 ba = ba.slice(1);
  4836.             }
  4837.             return ba.map(function (v) {
  4838.                 return (v < 0) ? v + 256 : v;
  4839.             });
  4840.         } else {
  4841.             // Empty array, nothing to do
  4842.             return ba;
  4843.         }
  4844.     };
  4845.  
  4846.     /**
  4847.     * Turns a byte array into a big integer.
  4848.     *
  4849.     * This function will interpret a byte array as a big integer in big
  4850.     * endian notation and ignore leading zeros.
  4851.     */
  4852.     BigInteger.fromByteArrayUnsigned = function (ba) {
  4853.         if (!ba.length) {
  4854.             return ba.valueOf(0);
  4855.         } else if (ba[0] & 0x80) {
  4856.             // Prepend a zero so the BigInteger class doesn't mistake this
  4857.             // for a negative integer.
  4858.             return new BigInteger([0].concat(ba));
  4859.         } else {
  4860.             return new BigInteger(ba);
  4861.         }
  4862.     };
  4863.  
  4864.     /**
  4865.     * Converts big integer to signed byte representation.
  4866.     *
  4867.     * The format for this value uses a the most significant bit as a sign
  4868.     * bit. If the most significant bit is already occupied by the
  4869.     * absolute value, an extra byte is prepended and the sign bit is set
  4870.     * there.
  4871.     *
  4872.     * Examples:
  4873.     *
  4874.     *      0 =>     0x00
  4875.     *      1 =>     0x01
  4876.     *     -1 =>     0x81
  4877.     *    127 =>     0x7f
  4878.     *   -127 =>     0xff
  4879.     *    128 =>   0x0080
  4880.     *   -128 =>   0x8080
  4881.     *    255 =>   0x00ff
  4882.     *   -255 =>   0x80ff
  4883.     *  16300 =>   0x3fac
  4884.     * -16300 =>   0xbfac
  4885.     *  62300 => 0x00f35c
  4886.     * -62300 => 0x80f35c
  4887.     */
  4888.     BigInteger.prototype.toByteArraySigned = function () {
  4889.         var val = this.abs().toByteArrayUnsigned();
  4890.         var neg = this.compareTo(BigInteger.ZERO) < 0;
  4891.  
  4892.         if (neg) {
  4893.             if (val[0] & 0x80) {
  4894.                 val.unshift(0x80);
  4895.             } else {
  4896.                 val[0] |= 0x80;
  4897.             }
  4898.         } else {
  4899.             if (val[0] & 0x80) {
  4900.                 val.unshift(0x00);
  4901.             }
  4902.         }
  4903.  
  4904.         return val;
  4905.     };
  4906.  
  4907.     /**
  4908.     * Parse a signed big integer byte representation.
  4909.     *
  4910.     * For details on the format please see BigInteger.toByteArraySigned.
  4911.     */
  4912.     BigInteger.fromByteArraySigned = function (ba) {
  4913.         // Check for negative value
  4914.         if (ba[0] & 0x80) {
  4915.             // Remove sign bit
  4916.             ba[0] &= 0x7f;
  4917.  
  4918.             return BigInteger.fromByteArrayUnsigned(ba).negate();
  4919.         } else {
  4920.             return BigInteger.fromByteArrayUnsigned(ba);
  4921.         }
  4922.     };
  4923.     // Copyright Stephan Thomas (end) --- //
  4924.  
  4925.  
  4926.  
  4927.  
  4928.     // ****** REDUCTION ******* //
  4929.  
  4930.     // Modular reduction using "classic" algorithm
  4931.     function Classic(m) { this.m = m; }
  4932.     Classic.prototype.convert = function (x) {
  4933.         if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
  4934.         else return x;
  4935.     };
  4936.     Classic.prototype.revert = function (x) { return x; };
  4937.     Classic.prototype.reduce = function (x) { x.divRemTo(this.m, null, x); };
  4938.     Classic.prototype.mulTo = function (x, y, r) { x.multiplyTo(y, r); this.reduce(r); };
  4939.     Classic.prototype.sqrTo = function (x, r) { x.squareTo(r); this.reduce(r); };
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.     // Montgomery reduction
  4946.     function Montgomery(m) {
  4947.         this.m = m;
  4948.         this.mp = m.invDigit();
  4949.         this.mpl = this.mp & 0x7fff;
  4950.         this.mph = this.mp >> 15;
  4951.         this.um = (1 << (m.DB - 15)) - 1;
  4952.         this.mt2 = 2 * m.t;
  4953.     }
  4954.     // xR mod m
  4955.     Montgomery.prototype.convert = function (x) {
  4956.         var r = nbi();
  4957.         x.abs().dlShiftTo(this.m.t, r);
  4958.         r.divRemTo(this.m, null, r);
  4959.         if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r);
  4960.         return r;
  4961.     }
  4962.     // x/R mod m
  4963.     Montgomery.prototype.revert = function (x) {
  4964.         var r = nbi();
  4965.         x.copyTo(r);
  4966.         this.reduce(r);
  4967.         return r;
  4968.     };
  4969.     // x = x/R mod m (HAC 14.32)
  4970.     Montgomery.prototype.reduce = function (x) {
  4971.         while (x.t <= this.mt2) // pad x so am has enough room later
  4972.             x[x.t++] = 0;
  4973.         for (var i = 0; i < this.m.t; ++i) {
  4974.             // faster way of calculating u0 = x[i]*mp mod DV
  4975.             var j = x[i] & 0x7fff;
  4976.             var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM;
  4977.             // use am to combine the multiply-shift-add into one call
  4978.             j = i + this.m.t;
  4979.             x[j] += this.m.am(0, u0, x, i, 0, this.m.t);
  4980.             // propagate carry
  4981.             while (x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
  4982.         }
  4983.         x.clamp();
  4984.         x.drShiftTo(this.m.t, x);
  4985.         if (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
  4986.     };
  4987.     // r = "xy/R mod m"; x,y != r
  4988.     Montgomery.prototype.mulTo = function (x, y, r) { x.multiplyTo(y, r); this.reduce(r); };
  4989.     // r = "x^2/R mod m"; x != r
  4990.     Montgomery.prototype.sqrTo = function (x, r) { x.squareTo(r); this.reduce(r); };
  4991.  
  4992.  
  4993.  
  4994.  
  4995.  
  4996.     // A "null" reducer
  4997.     function NullExp() { }
  4998.     NullExp.prototype.convert = function (x) { return x; };
  4999.     NullExp.prototype.revert = function (x) { return x; };
  5000.     NullExp.prototype.mulTo = function (x, y, r) { x.multiplyTo(y, r); };
  5001.     NullExp.prototype.sqrTo = function (x, r) { x.squareTo(r); };
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.     // Barrett modular reduction
  5008.     function Barrett(m) {
  5009.         // setup Barrett
  5010.         this.r2 = nbi();
  5011.         this.q3 = nbi();
  5012.         BigInteger.ONE.dlShiftTo(2 * m.t, this.r2);
  5013.         this.mu = this.r2.divide(m);
  5014.         this.m = m;
  5015.     }
  5016.     Barrett.prototype.convert = function (x) {
  5017.         if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m);
  5018.         else if (x.compareTo(this.m) < 0) return x;
  5019.         else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
  5020.     };
  5021.     Barrett.prototype.revert = function (x) { return x; };
  5022.     // x = x mod m (HAC 14.42)
  5023.     Barrett.prototype.reduce = function (x) {
  5024.         x.drShiftTo(this.m.t - 1, this.r2);
  5025.         if (x.t > this.m.t + 1) { x.t = this.m.t + 1; x.clamp(); }
  5026.         this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3);
  5027.         this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2);
  5028.         while (x.compareTo(this.r2) < 0) x.dAddOffset(1, this.m.t + 1);
  5029.         x.subTo(this.r2, x);
  5030.         while (x.compareTo(this.m) >= 0) x.subTo(this.m, x);
  5031.     };
  5032.     // r = x*y mod m; x,y != r
  5033.     Barrett.prototype.mulTo = function (x, y, r) { x.multiplyTo(y, r); this.reduce(r); };
  5034.     // r = x^2 mod m; x != r
  5035.     Barrett.prototype.sqrTo = function (x, r) { x.squareTo(r); this.reduce(r); };
  5036.  
  5037. })(exports);
  5038.  
  5039. var BigInteger = exports.BigInteger;
  5040. /*!
  5041. * Crypto-JS v2.5.4  Crypto.js
  5042. * http://code.google.com/p/crypto-js/
  5043. * Copyright (c) 2009-2013, Jeff Mott. All rights reserved.
  5044. * http://code.google.com/p/crypto-js/wiki/License
  5045. */
  5046.  
  5047. (function (Crypto) {
  5048.  
  5049.     var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  5050.  
  5051.     // Crypto utilities
  5052.     var util = Crypto.util = {
  5053.  
  5054.         // Bit-wise rotate left
  5055.         rotl: function (n, b) {
  5056.             return (n << b) | (n >>> (32 - b));
  5057.         },
  5058.  
  5059.         // Bit-wise rotate right
  5060.         rotr: function (n, b) {
  5061.             return (n << (32 - b)) | (n >>> b);
  5062.         },
  5063.  
  5064.         // Swap big-endian to little-endian and vice versa
  5065.         endian: function (n) {
  5066.  
  5067.             // If number given, swap endian
  5068.             if (n.constructor == Number) {
  5069.                 return util.rotl(n, 8) & 0x00FF00FF |
  5070.             util.rotl(n, 24) & 0xFF00FF00;
  5071.             }
  5072.  
  5073.             // Else, assume array and swap all items
  5074.             for (var i = 0; i < n.length; i++)
  5075.                 n[i] = util.endian(n[i]);
  5076.             return n;
  5077.  
  5078.         },
  5079.  
  5080.         // Generate an array of any length of random bytes
  5081.         randomBytes: function (n) {
  5082.             for (var bytes = []; n > 0; n--)
  5083.                 bytes.push(Math.floor(Math.random() * 256));
  5084.             return bytes;
  5085.         },
  5086.  
  5087.         // Convert a byte array to big-endian 32-bit words
  5088.         bytesToWords: function (bytes) {
  5089.             for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
  5090.                 words[b >>> 5] |= (bytes[i] & 0xFF) << (24 - b % 32);
  5091.             return words;
  5092.         },
  5093.  
  5094.         // Convert big-endian 32-bit words to a byte array
  5095.         wordsToBytes: function (words) {
  5096.             for (var bytes = [], b = 0; b < words.length * 32; b += 8)
  5097.                 bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
  5098.             return bytes;
  5099.         },
  5100.  
  5101.         // Convert a byte array to a hex string
  5102.         bytesToHex: function (bytes) {
  5103.             for (var hex = [], i = 0; i < bytes.length; i++) {
  5104.                 hex.push((bytes[i] >>> 4).toString(16));
  5105.                 hex.push((bytes[i] & 0xF).toString(16));
  5106.             }
  5107.             return hex.join("");
  5108.         },
  5109.  
  5110.         // Convert a hex string to a byte array
  5111.         hexToBytes: function (hex) {
  5112.             for (var bytes = [], c = 0; c < hex.length; c += 2)
  5113.                 bytes.push(parseInt(hex.substr(c, 2), 16));
  5114.             return bytes;
  5115.         },
  5116.  
  5117.         // Convert a byte array to a base-64 string
  5118.         bytesToBase64: function (bytes) {
  5119.             for (var base64 = [], i = 0; i < bytes.length; i += 3) {
  5120.                 var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
  5121.                 for (var j = 0; j < 4; j++) {
  5122.                     if (i * 8 + j * 6 <= bytes.length * 8)
  5123.                         base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
  5124.                     else base64.push("=");
  5125.                 }
  5126.             }
  5127.  
  5128.             return base64.join("");
  5129.         },
  5130.  
  5131.         // Convert a base-64 string to a byte array
  5132.         base64ToBytes: function (base64) {
  5133.             // Remove non-base-64 characters
  5134.             base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
  5135.  
  5136.             for (var bytes = [], i = 0, imod4 = 0; i < base64.length; imod4 = ++i % 4) {
  5137.                 if (imod4 == 0) continue;
  5138.                 bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2)) |
  5139.                 (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));
  5140.             }
  5141.  
  5142.             return bytes;
  5143.         }
  5144.  
  5145.     };
  5146.  
  5147.     // Crypto character encodings
  5148.     var charenc = Crypto.charenc = {};
  5149.  
  5150.     // UTF-8 encoding
  5151.     var UTF8 = charenc.UTF8 = {
  5152.  
  5153.         // Convert a string to a byte array
  5154.         stringToBytes: function (str) {
  5155.             return Binary.stringToBytes(unescape(encodeURIComponent(str)));
  5156.         },
  5157.  
  5158.         // Convert a byte array to a string
  5159.         bytesToString: function (bytes) {
  5160.             return decodeURIComponent(escape(Binary.bytesToString(bytes)));
  5161.         }
  5162.  
  5163.     };
  5164.  
  5165.     // Binary encoding
  5166.     var Binary = charenc.Binary = {
  5167.  
  5168.         // Convert a string to a byte array
  5169.         stringToBytes: function (str) {
  5170.             for (var bytes = [], i = 0; i < str.length; i++)
  5171.                 bytes.push(str.charCodeAt(i) & 0xFF);
  5172.             return bytes;
  5173.         },
  5174.  
  5175.         // Convert a byte array to a string
  5176.         bytesToString: function (bytes) {
  5177.             for (var str = [], i = 0; i < bytes.length; i++)
  5178.                 str.push(String.fromCharCode(bytes[i]));
  5179.             return str.join("");
  5180.         }
  5181.  
  5182.     };
  5183.  
  5184. })(Crypto);
  5185. /*!
  5186. * Crypto-JS v2.0.0  RIPEMD-160
  5187. * http://code.google.com/p/crypto-js/
  5188. * Copyright (c) 2009, Jeff Mott. All rights reserved.
  5189. * http://code.google.com/p/crypto-js/wiki/License
  5190. *
  5191. * A JavaScript implementation of the RIPEMD-160 Algorithm
  5192. * Version 2.2 Copyright Jeremy Lin, Paul Johnston 2000 - 2009.
  5193. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  5194. * Distributed under the BSD License
  5195. * See http://pajhome.org.uk/crypt/md5 for details.
  5196. * Also http://www.ocf.berkeley.edu/~jjlin/jsotp/
  5197. * Ported to Crypto-JS by Stefan Thomas.
  5198. */
  5199.  
  5200. (function (Crypto) {
  5201.     // Shortcuts
  5202.     var C = Crypto,
  5203.     util = C.util,
  5204.     charenc = C.charenc,
  5205.     UTF8 = charenc.UTF8,
  5206.     Binary = charenc.Binary;
  5207.  
  5208.     // Convert a byte array to little-endian 32-bit words
  5209.     util.bytesToLWords = function (bytes) {
  5210.  
  5211.         var output = Array(bytes.length >> 2);
  5212.         for (var i = 0; i < output.length; i++)
  5213.             output[i] = 0;
  5214.         for (var i = 0; i < bytes.length * 8; i += 8)
  5215.             output[i >> 5] |= (bytes[i / 8] & 0xFF) << (i % 32);
  5216.         return output;
  5217.     };
  5218.  
  5219.     // Convert little-endian 32-bit words to a byte array
  5220.     util.lWordsToBytes = function (words) {
  5221.         var output = [];
  5222.         for (var i = 0; i < words.length * 32; i += 8)
  5223.             output.push((words[i >> 5] >>> (i % 32)) & 0xff);
  5224.         return output;
  5225.     };
  5226.  
  5227.     // Public API
  5228.     var RIPEMD160 = C.RIPEMD160 = function (message, options) {
  5229.         var digestbytes = util.lWordsToBytes(RIPEMD160._rmd160(message));
  5230.         return options && options.asBytes ? digestbytes :
  5231.             options && options.asString ? Binary.bytesToString(digestbytes) :
  5232.             util.bytesToHex(digestbytes);
  5233.     };
  5234.  
  5235.     // The core
  5236.     RIPEMD160._rmd160 = function (message) {
  5237.         // Convert to byte array
  5238.         if (message.constructor == String) message = UTF8.stringToBytes(message);
  5239.  
  5240.         var x = util.bytesToLWords(message),
  5241.             len = message.length * 8;
  5242.  
  5243.         /* append padding */
  5244.         x[len >> 5] |= 0x80 << (len % 32);
  5245.         x[(((len + 64) >>> 9) << 4) + 14] = len;
  5246.  
  5247.         var h0 = 0x67452301;
  5248.         var h1 = 0xefcdab89;
  5249.         var h2 = 0x98badcfe;
  5250.         var h3 = 0x10325476;
  5251.         var h4 = 0xc3d2e1f0;
  5252.  
  5253.         for (var i = 0; i < x.length; i += 16) {
  5254.             var T;
  5255.             var A1 = h0, B1 = h1, C1 = h2, D1 = h3, E1 = h4;
  5256.             var A2 = h0, B2 = h1, C2 = h2, D2 = h3, E2 = h4;
  5257.             for (var j = 0; j <= 79; ++j) {
  5258.                 T = safe_add(A1, rmd160_f(j, B1, C1, D1));
  5259.                 T = safe_add(T, x[i + rmd160_r1[j]]);
  5260.                 T = safe_add(T, rmd160_K1(j));
  5261.                 T = safe_add(bit_rol(T, rmd160_s1[j]), E1);
  5262.                 A1 = E1; E1 = D1; D1 = bit_rol(C1, 10); C1 = B1; B1 = T;
  5263.                 T = safe_add(A2, rmd160_f(79 - j, B2, C2, D2));
  5264.                 T = safe_add(T, x[i + rmd160_r2[j]]);
  5265.                 T = safe_add(T, rmd160_K2(j));
  5266.                 T = safe_add(bit_rol(T, rmd160_s2[j]), E2);
  5267.                 A2 = E2; E2 = D2; D2 = bit_rol(C2, 10); C2 = B2; B2 = T;
  5268.             }
  5269.             T = safe_add(h1, safe_add(C1, D2));
  5270.             h1 = safe_add(h2, safe_add(D1, E2));
  5271.             h2 = safe_add(h3, safe_add(E1, A2));
  5272.             h3 = safe_add(h4, safe_add(A1, B2));
  5273.             h4 = safe_add(h0, safe_add(B1, C2));
  5274.             h0 = T;
  5275.         }
  5276.         return [h0, h1, h2, h3, h4];
  5277.     }
  5278.  
  5279.     function rmd160_f(j, x, y, z) {
  5280.         return (0 <= j && j <= 15) ? (x ^ y ^ z) :
  5281.             (16 <= j && j <= 31) ? (x & y) | (~x & z) :
  5282.             (32 <= j && j <= 47) ? (x | ~y) ^ z :
  5283.             (48 <= j && j <= 63) ? (x & z) | (y & ~z) :
  5284.             (64 <= j && j <= 79) ? x ^ (y | ~z) :
  5285.             "rmd160_f: j out of range";
  5286.     }
  5287.     function rmd160_K1(j) {
  5288.         return (0 <= j && j <= 15) ? 0x00000000 :
  5289.             (16 <= j && j <= 31) ? 0x5a827999 :
  5290.             (32 <= j && j <= 47) ? 0x6ed9eba1 :
  5291.             (48 <= j && j <= 63) ? 0x8f1bbcdc :
  5292.             (64 <= j && j <= 79) ? 0xa953fd4e :
  5293.             "rmd160_K1: j out of range";
  5294.     }
  5295.     function rmd160_K2(j) {
  5296.         return (0 <= j && j <= 15) ? 0x50a28be6 :
  5297.             (16 <= j && j <= 31) ? 0x5c4dd124 :
  5298.             (32 <= j && j <= 47) ? 0x6d703ef3 :
  5299.             (48 <= j && j <= 63) ? 0x7a6d76e9 :
  5300.             (64 <= j && j <= 79) ? 0x00000000 :
  5301.             "rmd160_K2: j out of range";
  5302.     }
  5303.     var rmd160_r1 = [
  5304.         0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  5305.         7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  5306.         3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  5307.         1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  5308.         4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
  5309.     ];
  5310.     var rmd160_r2 = [
  5311.         5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  5312.         6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  5313.         15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  5314.         8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  5315.         12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
  5316.     ];
  5317.     var rmd160_s1 = [
  5318.         11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  5319.         7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  5320.         11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  5321.         11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  5322.         9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
  5323.     ];
  5324.     var rmd160_s2 = [
  5325.         8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  5326.         9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  5327.         9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  5328.         15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  5329.         8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
  5330.     ];
  5331.  
  5332.     /*
  5333.     * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  5334.     * to work around bugs in some JS interpreters.
  5335.     */
  5336.     function safe_add(x, y) {
  5337.         var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  5338.         var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  5339.         return (msw << 16) | (lsw & 0xFFFF);
  5340.     }
  5341.  
  5342.     /*
  5343.     * Bitwise rotate a 32-bit number to the left.
  5344.     */
  5345.     function bit_rol(num, cnt) {
  5346.         return (num << cnt) | (num >>> (32 - cnt));
  5347.     }
  5348. })(Crypto);/*!
  5349. * Crypto-JS v2.5.4  SHA256.js
  5350. * http://code.google.com/p/crypto-js/
  5351. * Copyright (c) 2009-2013, Jeff Mott. All rights reserved.
  5352. * http://code.google.com/p/crypto-js/wiki/License
  5353. */
  5354. (function (Crypto) {
  5355.  
  5356.     // Shortcuts
  5357.     var C = Crypto,
  5358.         util = C.util,
  5359.         charenc = C.charenc,
  5360.         UTF8 = charenc.UTF8,
  5361.         Binary = charenc.Binary;
  5362.  
  5363.     // Constants
  5364.     var K = [0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
  5365.         0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
  5366.         0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
  5367.         0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
  5368.         0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
  5369.         0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
  5370.         0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
  5371.         0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
  5372.         0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
  5373.         0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
  5374.         0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
  5375.         0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
  5376.         0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
  5377.         0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
  5378.         0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
  5379.         0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2];
  5380.  
  5381.     // Public API
  5382.     var SHA256 = C.SHA256 = function (message, options) {
  5383.         var digestbytes = util.wordsToBytes(SHA256._sha256(message));
  5384.         return options && options.asBytes ? digestbytes :
  5385.         options && options.asString ? Binary.bytesToString(digestbytes) :
  5386.         util.bytesToHex(digestbytes);
  5387.     };
  5388.  
  5389.     // The core
  5390.     SHA256._sha256 = function (message) {
  5391.  
  5392.         // Convert to byte array
  5393.         if (message.constructor == String) message = UTF8.stringToBytes(message);
  5394.         /* else, assume byte array already */
  5395.  
  5396.         var m = util.bytesToWords(message),
  5397.         l = message.length * 8,
  5398.         H = [0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
  5399.                 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19],
  5400.         w = [],
  5401.         a, b, c, d, e, f, g, h, i, j,
  5402.         t1, t2;
  5403.  
  5404.         // Padding
  5405.         m[l >> 5] |= 0x80 << (24 - l % 32);
  5406.         m[((l + 64 >> 9) << 4) + 15] = l;
  5407.  
  5408.         for (var i = 0; i < m.length; i += 16) {
  5409.  
  5410.             a = H[0];
  5411.             b = H[1];
  5412.             c = H[2];
  5413.             d = H[3];
  5414.             e = H[4];
  5415.             f = H[5];
  5416.             g = H[6];
  5417.             h = H[7];
  5418.  
  5419.             for (var j = 0; j < 64; j++) {
  5420.  
  5421.                 if (j < 16) w[j] = m[j + i];
  5422.                 else {
  5423.  
  5424.                     var gamma0x = w[j - 15],
  5425.                 gamma1x = w[j - 2],
  5426.                 gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
  5427.                             ((gamma0x << 14) | (gamma0x >>> 18)) ^
  5428.                             (gamma0x >>> 3),
  5429.                 gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
  5430.                             ((gamma1x << 13) | (gamma1x >>> 19)) ^
  5431.                             (gamma1x >>> 10);
  5432.  
  5433.                     w[j] = gamma0 + (w[j - 7] >>> 0) +
  5434.                     gamma1 + (w[j - 16] >>> 0);
  5435.  
  5436.                 }
  5437.  
  5438.                 var ch = e & f ^ ~e & g,
  5439.             maj = a & b ^ a & c ^ b & c,
  5440.             sigma0 = ((a << 30) | (a >>> 2)) ^
  5441.                         ((a << 19) | (a >>> 13)) ^
  5442.                         ((a << 10) | (a >>> 22)),
  5443.             sigma1 = ((e << 26) | (e >>> 6)) ^
  5444.                         ((e << 21) | (e >>> 11)) ^
  5445.                         ((e << 7) | (e >>> 25));
  5446.  
  5447.  
  5448.                 t1 = (h >>> 0) + sigma1 + ch + (K[j]) + (w[j] >>> 0);
  5449.                 t2 = sigma0 + maj;
  5450.  
  5451.                 h = g;
  5452.                 g = f;
  5453.                 f = e;
  5454.                 e = (d + t1) >>> 0;
  5455.                 d = c;
  5456.                 c = b;
  5457.                 b = a;
  5458.                 a = (t1 + t2) >>> 0;
  5459.  
  5460.             }
  5461.  
  5462.             H[0] += a;
  5463.             H[1] += b;
  5464.             H[2] += c;
  5465.             H[3] += d;
  5466.             H[4] += e;
  5467.             H[5] += f;
  5468.             H[6] += g;
  5469.             H[7] += h;
  5470.  
  5471.         }
  5472.  
  5473.         return H;
  5474.  
  5475.     };
  5476.  
  5477.     // Package private blocksize
  5478.     SHA256._blocksize = 16;
  5479.  
  5480.     SHA256._digestsize = 32;
  5481.  
  5482. })(Crypto);//https://raw.github.com/bitcoinjs/bitcoinjs-lib/faa10f0f6a1fff0b9a99fffb9bc30cee33b17212/src/ecdsa.js
  5483. /*!
  5484. * Basic Javascript Elliptic Curve implementation
  5485. * Ported loosely from BouncyCastle's Java EC code
  5486. * Only Fp curves implemented for now
  5487. *
  5488. * Copyright Tom Wu, bitaddress.org  BSD License.
  5489. * http://www-cs-students.stanford.edu/~tjw/jsbn/LICENSE
  5490. */
  5491. (function (exports) {
  5492.  
  5493.     // Constructor function of Global EllipticCurve object
  5494.     var ec = exports.EllipticCurve = function () { };
  5495.  
  5496.     // ----------------
  5497.     // ECFieldElementFp constructor
  5498.     // q instanceof BigInteger
  5499.     // x instanceof BigInteger
  5500.     ec.FieldElementFp = function (q, x) {
  5501.         this.x = x;
  5502.         // TODO if(x.compareTo(q) >= 0) error
  5503.         this.q = q;
  5504.     };
  5505.  
  5506.     ec.FieldElementFp.prototype.equals = function (other) {
  5507.         if (other == this) return true;
  5508.         return (this.q.equals(other.q) && this.x.equals(other.x));
  5509.     };
  5510.  
  5511.     ec.FieldElementFp.prototype.toBigInteger = function () {
  5512.         return this.x;
  5513.     };
  5514.  
  5515.     ec.FieldElementFp.prototype.negate = function () {
  5516.         return new ec.FieldElementFp(this.q, this.x.negate().mod(this.q));
  5517.     };
  5518.  
  5519.     ec.FieldElementFp.prototype.add = function (b) {
  5520.         return new ec.FieldElementFp(this.q, this.x.add(b.toBigInteger()).mod(this.q));
  5521.     };
  5522.  
  5523.     ec.FieldElementFp.prototype.subtract = function (b) {
  5524.         return new ec.FieldElementFp(this.q, this.x.subtract(b.toBigInteger()).mod(this.q));
  5525.     };
  5526.  
  5527.     ec.FieldElementFp.prototype.multiply = function (b) {
  5528.         return new ec.FieldElementFp(this.q, this.x.multiply(b.toBigInteger()).mod(this.q));
  5529.     };
  5530.  
  5531.     ec.FieldElementFp.prototype.square = function () {
  5532.         return new ec.FieldElementFp(this.q, this.x.square().mod(this.q));
  5533.     };
  5534.  
  5535.     ec.FieldElementFp.prototype.divide = function (b) {
  5536.         return new ec.FieldElementFp(this.q, this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q));
  5537.     };
  5538.  
  5539.     ec.FieldElementFp.prototype.getByteLength = function () {
  5540.         return Math.floor((this.toBigInteger().bitLength() + 7) / 8);
  5541.     };
  5542.  
  5543.     // D.1.4 91
  5544.     /**
  5545.     * return a sqrt root - the routine verifies that the calculation
  5546.     * returns the right value - if none exists it returns null.
  5547.     *
  5548.     * Copyright (c) 2000 - 2011 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)
  5549.     * Ported to JavaScript by bitaddress.org
  5550.     */
  5551.     ec.FieldElementFp.prototype.sqrt = function () {
  5552.         throw new Error("this feature is disabled since we don't have a randomness source");
  5553.         if (!this.q.testBit(0)) throw new Error("even value of q");
  5554.  
  5555.         // p mod 4 == 3
  5556.         if (this.q.testBit(1)) {
  5557.             // z = g^(u+1) + p, p = 4u + 3
  5558.             var z = new ec.FieldElementFp(this.q, this.x.modPow(this.q.shiftRight(2).add(BigInteger.ONE), this.q));
  5559.             return z.square().equals(this) ? z : null;
  5560.         }
  5561.  
  5562.         // p mod 4 == 1
  5563.         var qMinusOne = this.q.subtract(BigInteger.ONE);
  5564.         var legendreExponent = qMinusOne.shiftRight(1);
  5565.         if (!(this.x.modPow(legendreExponent, this.q).equals(BigInteger.ONE))) return null;
  5566.         var u = qMinusOne.shiftRight(2);
  5567.         var k = u.shiftLeft(1).add(BigInteger.ONE);
  5568.         var Q = this.x;
  5569.         var fourQ = Q.shiftLeft(2).mod(this.q);
  5570.         var U, V;
  5571.  
  5572.         do {
  5573.             var rand = new SecureRandom();
  5574.             var P;
  5575.             do {
  5576.                 P = new BigInteger(this.q.bitLength(), rand);
  5577.             }
  5578.             while (P.compareTo(this.q) >= 0 || !(P.multiply(P).subtract(fourQ).modPow(legendreExponent, this.q).equals(qMinusOne)));
  5579.  
  5580.             var result = ec.FieldElementFp.fastLucasSequence(this.q, P, Q, k);
  5581.  
  5582.             U = result[0];
  5583.             V = result[1];
  5584.             if (V.multiply(V).mod(this.q).equals(fourQ)) {
  5585.                 // Integer division by 2, mod q
  5586.                 if (V.testBit(0)) {
  5587.                     V = V.add(this.q);
  5588.                 }
  5589.                 V = V.shiftRight(1);
  5590.                 return new ec.FieldElementFp(this.q, V);
  5591.             }
  5592.         }
  5593.         while (U.equals(BigInteger.ONE) || U.equals(qMinusOne));
  5594.  
  5595.         return null;
  5596.     };
  5597.  
  5598.     /*
  5599.     * Copyright (c) 2000 - 2011 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)
  5600.     * Ported to JavaScript by bitaddress.org
  5601.     */
  5602.     ec.FieldElementFp.fastLucasSequence = function (p, P, Q, k) {
  5603.         // TODO Research and apply "common-multiplicand multiplication here"
  5604.  
  5605.         var n = k.bitLength();
  5606.         var s = k.getLowestSetBit();
  5607.         var Uh = BigInteger.ONE;
  5608.         var Vl = BigInteger.TWO;
  5609.         var Vh = P;
  5610.         var Ql = BigInteger.ONE;
  5611.         var Qh = BigInteger.ONE;
  5612.  
  5613.         for (var j = n - 1; j >= s + 1; --j) {
  5614.             Ql = Ql.multiply(Qh).mod(p);
  5615.             if (k.testBit(j)) {
  5616.                 Qh = Ql.multiply(Q).mod(p);
  5617.                 Uh = Uh.multiply(Vh).mod(p);
  5618.                 Vl = Vh.multiply(Vl).subtract(P.multiply(Ql)).mod(p);
  5619.                 Vh = Vh.multiply(Vh).subtract(Qh.shiftLeft(1)).mod(p);
  5620.             }
  5621.             else {
  5622.                 Qh = Ql;
  5623.                 Uh = Uh.multiply(Vl).subtract(Ql).mod(p);
  5624.                 Vh = Vh.multiply(Vl).subtract(P.multiply(Ql)).mod(p);
  5625.                 Vl = Vl.multiply(Vl).subtract(Ql.shiftLeft(1)).mod(p);
  5626.             }
  5627.         }
  5628.  
  5629.         Ql = Ql.multiply(Qh).mod(p);
  5630.         Qh = Ql.multiply(Q).mod(p);
  5631.         Uh = Uh.multiply(Vl).subtract(Ql).mod(p);
  5632.         Vl = Vh.multiply(Vl).subtract(P.multiply(Ql)).mod(p);
  5633.         Ql = Ql.multiply(Qh).mod(p);
  5634.  
  5635.         for (var j = 1; j <= s; ++j) {
  5636.             Uh = Uh.multiply(Vl).mod(p);
  5637.             Vl = Vl.multiply(Vl).subtract(Ql.shiftLeft(1)).mod(p);
  5638.             Ql = Ql.multiply(Ql).mod(p);
  5639.         }
  5640.  
  5641.         return [Uh, Vl];
  5642.     };
  5643.  
  5644.     // ----------------
  5645.     // ECPointFp constructor
  5646.     ec.PointFp = function (curve, x, y, z, compressed) {
  5647.         this.curve = curve;
  5648.         this.x = x;
  5649.         this.y = y;
  5650.         // Projective coordinates: either zinv == null or z * zinv == 1
  5651.         // z and zinv are just BigIntegers, not fieldElements
  5652.         if (z == null) {
  5653.             this.z = BigInteger.ONE;
  5654.         }
  5655.         else {
  5656.             this.z = z;
  5657.         }
  5658.         this.zinv = null;
  5659.         // compression flag
  5660.         this.compressed = !!compressed;
  5661.     };
  5662.  
  5663.     ec.PointFp.prototype.getX = function () {
  5664.         if (this.zinv == null) {
  5665.             this.zinv = this.z.modInverse(this.curve.q);
  5666.         }
  5667.         return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q));
  5668.     };
  5669.  
  5670.     ec.PointFp.prototype.getY = function () {
  5671.         if (this.zinv == null) {
  5672.             this.zinv = this.z.modInverse(this.curve.q);
  5673.         }
  5674.         return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q));
  5675.     };
  5676.  
  5677.     ec.PointFp.prototype.equals = function (other) {
  5678.         if (other == this) return true;
  5679.         if (this.isInfinity()) return other.isInfinity();
  5680.         if (other.isInfinity()) return this.isInfinity();
  5681.         var u, v;
  5682.         // u = Y2 * Z1 - Y1 * Z2
  5683.         u = other.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(other.z)).mod(this.curve.q);
  5684.         if (!u.equals(BigInteger.ZERO)) return false;
  5685.         // v = X2 * Z1 - X1 * Z2
  5686.         v = other.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(other.z)).mod(this.curve.q);
  5687.         return v.equals(BigInteger.ZERO);
  5688.     };
  5689.  
  5690.     ec.PointFp.prototype.isInfinity = function () {
  5691.         if ((this.x == null) && (this.y == null)) return true;
  5692.         return this.z.equals(BigInteger.ZERO) && !this.y.toBigInteger().equals(BigInteger.ZERO);
  5693.     };
  5694.  
  5695.     ec.PointFp.prototype.negate = function () {
  5696.         return new ec.PointFp(this.curve, this.x, this.y.negate(), this.z);
  5697.     };
  5698.  
  5699.     ec.PointFp.prototype.add = function (b) {
  5700.         if (this.isInfinity()) return b;
  5701.         if (b.isInfinity()) return this;
  5702.  
  5703.         // u = Y2 * Z1 - Y1 * Z2
  5704.         var u = b.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(b.z)).mod(this.curve.q);
  5705.         // v = X2 * Z1 - X1 * Z2
  5706.         var v = b.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(b.z)).mod(this.curve.q);
  5707.  
  5708.  
  5709.         if (BigInteger.ZERO.equals(v)) {
  5710.             if (BigInteger.ZERO.equals(u)) {
  5711.                 return this.twice(); // this == b, so double
  5712.             }
  5713.             return this.curve.getInfinity(); // this = -b, so infinity
  5714.         }
  5715.  
  5716.         var THREE = new BigInteger("3");
  5717.         var x1 = this.x.toBigInteger();
  5718.         var y1 = this.y.toBigInteger();
  5719.         var x2 = b.x.toBigInteger();
  5720.         var y2 = b.y.toBigInteger();
  5721.  
  5722.         var v2 = v.square();
  5723.         var v3 = v2.multiply(v);
  5724.         var x1v2 = x1.multiply(v2);
  5725.         var zu2 = u.square().multiply(this.z);
  5726.  
  5727.         // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3)
  5728.         var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.q);
  5729.         // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3
  5730.         var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.q);
  5731.         // z3 = v^3 * z1 * z2
  5732.         var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.q);
  5733.  
  5734.         return new ec.PointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3);
  5735.     };
  5736.  
  5737.     ec.PointFp.prototype.twice = function () {
  5738.         if (this.isInfinity()) return this;
  5739.         if (this.y.toBigInteger().signum() == 0) return this.curve.getInfinity();
  5740.  
  5741.         // TODO: optimized handling of constants
  5742.         var THREE = new BigInteger("3");
  5743.         var x1 = this.x.toBigInteger();
  5744.         var y1 = this.y.toBigInteger();
  5745.  
  5746.         var y1z1 = y1.multiply(this.z);
  5747.         var y1sqz1 = y1z1.multiply(y1).mod(this.curve.q);
  5748.         var a = this.curve.a.toBigInteger();
  5749.  
  5750.         // w = 3 * x1^2 + a * z1^2
  5751.         var w = x1.square().multiply(THREE);
  5752.         if (!BigInteger.ZERO.equals(a)) {
  5753.             w = w.add(this.z.square().multiply(a));
  5754.         }
  5755.         w = w.mod(this.curve.q);
  5756.         // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1)
  5757.         var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.q);
  5758.         // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3
  5759.         var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.square().multiply(w)).mod(this.curve.q);
  5760.         // z3 = 8 * (y1 * z1)^3
  5761.         var z3 = y1z1.square().multiply(y1z1).shiftLeft(3).mod(this.curve.q);
  5762.  
  5763.         return new ec.PointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3);
  5764.     };
  5765.  
  5766.     // Simple NAF (Non-Adjacent Form) multiplication algorithm
  5767.     // TODO: modularize the multiplication algorithm
  5768.     ec.PointFp.prototype.multiply = function (k) {
  5769.         if (this.isInfinity()) return this;
  5770.         if (k.signum() == 0) return this.curve.getInfinity();
  5771.  
  5772.         var e = k;
  5773.         var h = e.multiply(new BigInteger("3"));
  5774.  
  5775.         var neg = this.negate();
  5776.         var R = this;
  5777.  
  5778.         var i;
  5779.         for (i = h.bitLength() - 2; i > 0; --i) {
  5780.             R = R.twice();
  5781.  
  5782.             var hBit = h.testBit(i);
  5783.             var eBit = e.testBit(i);
  5784.  
  5785.             if (hBit != eBit) {
  5786.                 R = R.add(hBit ? this : neg);
  5787.             }
  5788.         }
  5789.  
  5790.         return R;
  5791.     };
  5792.  
  5793.     // Compute this*j + x*k (simultaneous multiplication)
  5794.     ec.PointFp.prototype.multiplyTwo = function (j, x, k) {
  5795.         var i;
  5796.         if (j.bitLength() > k.bitLength())
  5797.             i = j.bitLength() - 1;
  5798.         else
  5799.             i = k.bitLength() - 1;
  5800.  
  5801.         var R = this.curve.getInfinity();
  5802.         var both = this.add(x);
  5803.         while (i >= 0) {
  5804.             R = R.twice();
  5805.             if (j.testBit(i)) {
  5806.                 if (k.testBit(i)) {
  5807.                     R = R.add(both);
  5808.                 }
  5809.                 else {
  5810.                     R = R.add(this);
  5811.                 }
  5812.             }
  5813.             else {
  5814.                 if (k.testBit(i)) {
  5815.                     R = R.add(x);
  5816.                 }
  5817.             }
  5818.             --i;
  5819.         }
  5820.  
  5821.         return R;
  5822.     };
  5823.  
  5824.     // patched by bitaddress.org and Casascius for use with Bitcoin.ECKey
  5825.     // patched by coretechs to support compressed public keys
  5826.     ec.PointFp.prototype.getEncoded = function (compressed) {
  5827.         var x = this.getX().toBigInteger();
  5828.         var y = this.getY().toBigInteger();
  5829.         var len = 32; // integerToBytes will zero pad if integer is less than 32 bytes. 32 bytes length is required by the Bitcoin protocol.
  5830.         var enc = ec.integerToBytes(x, len);
  5831.  
  5832.         // when compressed prepend byte depending if y point is even or odd
  5833.         if (compressed) {
  5834.             if (y.isEven()) {
  5835.                 enc.unshift(0x02);
  5836.             }
  5837.             else {
  5838.                 enc.unshift(0x03);
  5839.             }
  5840.         }
  5841.         else {
  5842.             enc.unshift(0x04);
  5843.             enc = enc.concat(ec.integerToBytes(y, len)); // uncompressed public key appends the bytes of the y point
  5844.         }
  5845.         return enc;
  5846.     };
  5847.  
  5848.     ec.PointFp.decodeFrom = function (curve, enc) {
  5849.         var type = enc[0];
  5850.         var dataLen = enc.length - 1;
  5851.  
  5852.         // Extract x and y as byte arrays
  5853.         var xBa = enc.slice(1, 1 + dataLen / 2);
  5854.         var yBa = enc.slice(1 + dataLen / 2, 1 + dataLen);
  5855.  
  5856.         // Prepend zero byte to prevent interpretation as negative integer
  5857.         xBa.unshift(0);
  5858.         yBa.unshift(0);
  5859.  
  5860.         // Convert to BigIntegers
  5861.         var x = new BigInteger(xBa);
  5862.         var y = new BigInteger(yBa);
  5863.  
  5864.         // Return point
  5865.         return new ec.PointFp(curve, curve.fromBigInteger(x), curve.fromBigInteger(y));
  5866.     };
  5867.  
  5868.     ec.PointFp.prototype.add2D = function (b) {
  5869.         if (this.isInfinity()) return b;
  5870.         if (b.isInfinity()) return this;
  5871.  
  5872.         if (this.x.equals(b.x)) {
  5873.             if (this.y.equals(b.y)) {
  5874.                 // this = b, i.e. this must be doubled
  5875.                 return this.twice();
  5876.             }
  5877.             // this = -b, i.e. the result is the point at infinity
  5878.             return this.curve.getInfinity();
  5879.         }
  5880.  
  5881.         var x_x = b.x.subtract(this.x);
  5882.         var y_y = b.y.subtract(this.y);
  5883.         var gamma = y_y.divide(x_x);
  5884.  
  5885.         var x3 = gamma.square().subtract(this.x).subtract(b.x);
  5886.         var y3 = gamma.multiply(this.x.subtract(x3)).subtract(this.y);
  5887.  
  5888.         return new ec.PointFp(this.curve, x3, y3);
  5889.     };
  5890.  
  5891.     ec.PointFp.prototype.twice2D = function () {
  5892.         if (this.isInfinity()) return this;
  5893.         if (this.y.toBigInteger().signum() == 0) {
  5894.             // if y1 == 0, then (x1, y1) == (x1, -y1)
  5895.             // and hence this = -this and thus 2(x1, y1) == infinity
  5896.             return this.curve.getInfinity();
  5897.         }
  5898.  
  5899.         var TWO = this.curve.fromBigInteger(BigInteger.valueOf(2));
  5900.         var THREE = this.curve.fromBigInteger(BigInteger.valueOf(3));
  5901.         var gamma = this.x.square().multiply(THREE).add(this.curve.a).divide(this.y.multiply(TWO));
  5902.  
  5903.         var x3 = gamma.square().subtract(this.x.multiply(TWO));
  5904.         var y3 = gamma.multiply(this.x.subtract(x3)).subtract(this.y);
  5905.  
  5906.         return new ec.PointFp(this.curve, x3, y3);
  5907.     };
  5908.  
  5909.     ec.PointFp.prototype.multiply2D = function (k) {
  5910.         if (this.isInfinity()) return this;
  5911.         if (k.signum() == 0) return this.curve.getInfinity();
  5912.  
  5913.         var e = k;
  5914.         var h = e.multiply(new BigInteger("3"));
  5915.  
  5916.         var neg = this.negate();
  5917.         var R = this;
  5918.  
  5919.         var i;
  5920.         for (i = h.bitLength() - 2; i > 0; --i) {
  5921.             R = R.twice();
  5922.  
  5923.             var hBit = h.testBit(i);
  5924.             var eBit = e.testBit(i);
  5925.  
  5926.             if (hBit != eBit) {
  5927.                 R = R.add2D(hBit ? this : neg);
  5928.             }
  5929.         }
  5930.  
  5931.         return R;
  5932.     };
  5933.  
  5934.     ec.PointFp.prototype.isOnCurve = function () {
  5935.         var x = this.getX().toBigInteger();
  5936.         var y = this.getY().toBigInteger();
  5937.         var a = this.curve.getA().toBigInteger();
  5938.         var b = this.curve.getB().toBigInteger();
  5939.         var n = this.curve.getQ();
  5940.         var lhs = y.multiply(y).mod(n);
  5941.         var rhs = x.multiply(x).multiply(x).add(a.multiply(x)).add(b).mod(n);
  5942.         return lhs.equals(rhs);
  5943.     };
  5944.  
  5945.     ec.PointFp.prototype.toString = function () {
  5946.         return '(' + this.getX().toBigInteger().toString() + ',' + this.getY().toBigInteger().toString() + ')';
  5947.     };
  5948.  
  5949.     /**
  5950.     * Validate an elliptic curve point.
  5951.     *
  5952.     * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive
  5953.     */
  5954.     ec.PointFp.prototype.validate = function () {
  5955.         var n = this.curve.getQ();
  5956.  
  5957.         // Check Q != O
  5958.         if (this.isInfinity()) {
  5959.             throw new Error("Point is at infinity.");
  5960.         }
  5961.  
  5962.         // Check coordinate bounds
  5963.         var x = this.getX().toBigInteger();
  5964.         var y = this.getY().toBigInteger();
  5965.         if (x.compareTo(BigInteger.ONE) < 0 || x.compareTo(n.subtract(BigInteger.ONE)) > 0) {
  5966.             throw new Error('x coordinate out of bounds');
  5967.         }
  5968.         if (y.compareTo(BigInteger.ONE) < 0 || y.compareTo(n.subtract(BigInteger.ONE)) > 0) {
  5969.             throw new Error('y coordinate out of bounds');
  5970.         }
  5971.  
  5972.         // Check y^2 = x^3 + ax + b (mod n)
  5973.         if (!this.isOnCurve()) {
  5974.             throw new Error("Point is not on the curve.");
  5975.         }
  5976.  
  5977.         // Check nQ = 0 (Q is a scalar multiple of G)
  5978.         if (this.multiply(n).isInfinity()) {
  5979.             // TODO: This check doesn't work - fix.
  5980.             throw new Error("Point is not a scalar multiple of G.");
  5981.         }
  5982.  
  5983.         return true;
  5984.     };
  5985.  
  5986.  
  5987.  
  5988.  
  5989.     // ----------------
  5990.     // ECCurveFp constructor
  5991.     ec.CurveFp = function (q, a, b) {
  5992.         this.q = q;
  5993.         this.a = this.fromBigInteger(a);
  5994.         this.b = this.fromBigInteger(b);
  5995.         this.infinity = new ec.PointFp(this, null, null);
  5996.     }
  5997.  
  5998.     ec.CurveFp.prototype.getQ = function () {
  5999.         return this.q;
  6000.     };
  6001.  
  6002.     ec.CurveFp.prototype.getA = function () {
  6003.         return this.a;
  6004.     };
  6005.  
  6006.     ec.CurveFp.prototype.getB = function () {
  6007.         return this.b;
  6008.     };
  6009.  
  6010.     ec.CurveFp.prototype.equals = function (other) {
  6011.         if (other == this) return true;
  6012.         return (this.q.equals(other.q) && this.a.equals(other.a) && this.b.equals(other.b));
  6013.     };
  6014.  
  6015.     ec.CurveFp.prototype.getInfinity = function () {
  6016.         return this.infinity;
  6017.     };
  6018.  
  6019.     ec.CurveFp.prototype.fromBigInteger = function (x) {
  6020.         return new ec.FieldElementFp(this.q, x);
  6021.     };
  6022.  
  6023.     // for now, work with hex strings because they're easier in JS
  6024.     // compressed support added by bitaddress.org
  6025.     ec.CurveFp.prototype.decodePointHex = function (s) {
  6026.         var firstByte = parseInt(s.substr(0, 2), 16);
  6027.         switch (firstByte) { // first byte
  6028.             case 0:
  6029.                 return this.infinity;
  6030.             case 2: // compressed
  6031.             case 3: // compressed
  6032.                 var yTilde = firstByte & 1;
  6033.                 var xHex = s.substr(2, s.length - 2);
  6034.                 var X1 = new BigInteger(xHex, 16);
  6035.                 return this.decompressPoint(yTilde, X1);
  6036.             case 4: // uncompressed
  6037.             case 6: // hybrid
  6038.             case 7: // hybrid
  6039.                 var len = (s.length - 2) / 2;
  6040.                 var xHex = s.substr(2, len);
  6041.                 var yHex = s.substr(len + 2, len);
  6042.  
  6043.                 return new ec.PointFp(this,
  6044.                     this.fromBigInteger(new BigInteger(xHex, 16)),
  6045.                     this.fromBigInteger(new BigInteger(yHex, 16)));
  6046.  
  6047.             default: // unsupported
  6048.                 return null;
  6049.         }
  6050.     };
  6051.  
  6052.     /*
  6053.     * Copyright (c) 2000 - 2011 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)
  6054.     * Ported to JavaScript by bitaddress.org
  6055.     *
  6056.     * Number yTilde
  6057.     * BigInteger X1
  6058.     */
  6059.     ec.CurveFp.prototype.decompressPoint = function (yTilde, X1) {
  6060.         var x = this.fromBigInteger(X1);
  6061.         var alpha = x.multiply(x.square().add(this.getA())).add(this.getB());
  6062.         var beta = alpha.sqrt();
  6063.         // if we can't find a sqrt we haven't got a point on the curve - run!
  6064.         if (beta == null) throw new Error("Invalid point compression");
  6065.         var betaValue = beta.toBigInteger();
  6066.         var bit0 = betaValue.testBit(0) ? 1 : 0;
  6067.         if (bit0 != yTilde) {
  6068.             // Use the other root
  6069.             beta = this.fromBigInteger(this.getQ().subtract(betaValue));
  6070.         }
  6071.         return new ec.PointFp(this, x, beta, null, true);
  6072.     };
  6073.  
  6074.  
  6075.     ec.fromHex = function (s) { return new BigInteger(s, 16); };
  6076.  
  6077.     ec.integerToBytes = function (i, len) {
  6078.         var bytes = i.toByteArrayUnsigned();
  6079.         if (len < bytes.length) {
  6080.             bytes = bytes.slice(bytes.length - len);
  6081.         } else while (len > bytes.length) {
  6082.             bytes.unshift(0);
  6083.         }
  6084.         return bytes;
  6085.     };
  6086.  
  6087.  
  6088.     // Named EC curves
  6089.     // ----------------
  6090.     // X9ECParameters constructor
  6091.     ec.X9Parameters = function (curve, g, n, h) {
  6092.         this.curve = curve;
  6093.         this.g = g;
  6094.         this.n = n;
  6095.         this.h = h;
  6096.     }
  6097.     ec.X9Parameters.prototype.getCurve = function () { return this.curve; };
  6098.     ec.X9Parameters.prototype.getG = function () { return this.g; };
  6099.     ec.X9Parameters.prototype.getN = function () { return this.n; };
  6100.     ec.X9Parameters.prototype.getH = function () { return this.h; };
  6101.  
  6102.     // secp256k1 is the Curve used by Bitcoin
  6103.     ec.secNamedCurves = {
  6104.         // used by Bitcoin
  6105.         "secp256k1": function () {
  6106.             // p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1
  6107.             var p = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
  6108.             var a = BigInteger.ZERO;
  6109.             var b = ec.fromHex("7");
  6110.             var n = ec.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");
  6111.             var h = BigInteger.ONE;
  6112.             var curve = new ec.CurveFp(p, a, b);
  6113.             var G = curve.decodePointHex("04"
  6114.                     + "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"
  6115.                     + "483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8");
  6116.             return new ec.X9Parameters(curve, G, n, h);
  6117.         }
  6118.     };
  6119.  
  6120.     // secp256k1 called by Bitcoin's ECKEY
  6121.     ec.getSECCurveByName = function (name) {
  6122.         if (ec.secNamedCurves[name] == undefined) return null;
  6123.         return ec.secNamedCurves[name]();
  6124.     }
  6125. })(exports);
  6126.  
  6127. var EllipticCurve = exports.EllipticCurve;//https://raw.github.com/bitcoinjs/bitcoinjs-lib/09e8c6e184d6501a0c2c59d73ca64db5c0d3eb95/src/address.js
  6128. // See here for license information: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/LICENSE
  6129. (function (Bitcoin) {
  6130.     Bitcoin.Address = function (bytes) {
  6131.         if ("string" == typeof bytes) {
  6132.             bytes = Bitcoin.Address.decodeString(bytes);
  6133.         }
  6134.         this.hash = bytes;
  6135.         this.version = Bitcoin.Address.networkVersion;
  6136.     };
  6137.  
  6138.     Bitcoin.Address.networkVersion = 0x00; // mainnet
  6139.  
  6140.     /**
  6141.     * Serialize this object as a standard Bitcoin address.
  6142.     *
  6143.     * Returns the address as a base58-encoded string in the standardized format.
  6144.     */
  6145.     Bitcoin.Address.prototype.toString = function () {
  6146.         // Get a copy of the hash
  6147.         var hash = this.hash.slice(0);
  6148.  
  6149.         // Version
  6150.         hash.unshift(this.version);
  6151.         var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
  6152.         var bytes = hash.concat(checksum.slice(0, 4));
  6153.         return Bitcoin.Base58.encode(bytes);
  6154.     };
  6155.  
  6156.     Bitcoin.Address.prototype.getHashBase64 = function () {
  6157.         return Crypto.util.bytesToBase64(this.hash);
  6158.     };
  6159.  
  6160.     /**
  6161.     * Parse a Bitcoin address contained in a string.
  6162.     */
  6163.     Bitcoin.Address.decodeString = function (string) {
  6164.         var bytes = Bitcoin.Base58.decode(string);
  6165.         var hash = bytes.slice(0, 21);
  6166.         var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
  6167.  
  6168.         if (checksum[0] != bytes[21] ||
  6169.                 checksum[1] != bytes[22] ||
  6170.                 checksum[2] != bytes[23] ||
  6171.                 checksum[3] != bytes[24]) {
  6172.             throw "Checksum validation failed!";
  6173.         }
  6174.  
  6175.         var version = hash.shift();
  6176.  
  6177.         if (version != 0) {
  6178.             throw "Version " + version + " not supported!";
  6179.         }
  6180.  
  6181.         return hash;
  6182.     };
  6183. })(Bitcoin);
  6184. //https://raw.github.com/bitcoinjs/bitcoinjs-lib/c952aaeb3ee472e3776655b8ea07299ebed702c7/src/base58.js
  6185. // See here for license information: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/LICENSE
  6186. (function (Bitcoin) {
  6187.     Bitcoin.Base58 = {
  6188.         alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",
  6189.         validRegex: /^[1-9A-HJ-NP-Za-km-z]+$/,
  6190.         base: BigInteger.valueOf(58),
  6191.  
  6192.         /**
  6193.         * Convert a byte array to a base58-encoded string.
  6194.         *
  6195.         * Written by Mike Hearn for BitcoinJ.
  6196.         *   Copyright (c) 2011 Google Inc.
  6197.         *
  6198.         * Ported to JavaScript by Stefan Thomas.
  6199.         */
  6200.         encode: function (input) {
  6201.             var bi = BigInteger.fromByteArrayUnsigned(input);
  6202.             var chars = [];
  6203.  
  6204.             while (bi.compareTo(B58.base) >= 0) {
  6205.                 var mod = bi.mod(B58.base);
  6206.                 chars.unshift(B58.alphabet[mod.intValue()]);
  6207.                 bi = bi.subtract(mod).divide(B58.base);
  6208.             }
  6209.             chars.unshift(B58.alphabet[bi.intValue()]);
  6210.  
  6211.             // Convert leading zeros too.
  6212.             for (var i = 0; i < input.length; i++) {
  6213.                 if (input[i] == 0x00) {
  6214.                     chars.unshift(B58.alphabet[0]);
  6215.                 } else break;
  6216.             }
  6217.  
  6218.             return chars.join('');
  6219.         },
  6220.  
  6221.         /**
  6222.         * Convert a base58-encoded string to a byte array.
  6223.         *
  6224.         * Written by Mike Hearn for BitcoinJ.
  6225.         *   Copyright (c) 2011 Google Inc.
  6226.         *
  6227.         * Ported to JavaScript by Stefan Thomas.
  6228.         */
  6229.         decode: function (input) {
  6230.             var bi = BigInteger.valueOf(0);
  6231.             var leadingZerosNum = 0;
  6232.             for (var i = input.length - 1; i >= 0; i--) {
  6233.                 var alphaIndex = B58.alphabet.indexOf(input[i]);
  6234.                 if (alphaIndex < 0) {
  6235.                     throw "Invalid character";
  6236.                 }
  6237.                 bi = bi.add(BigInteger.valueOf(alphaIndex)
  6238.                                 .multiply(B58.base.pow(input.length - 1 - i)));
  6239.  
  6240.                 // This counts leading zero bytes
  6241.                 if (input[i] == "1") leadingZerosNum++;
  6242.                 else leadingZerosNum = 0;
  6243.             }
  6244.             var bytes = bi.toByteArrayUnsigned();
  6245.  
  6246.             // Add leading zeros
  6247.             while (leadingZerosNum-- > 0) bytes.unshift(0);
  6248.  
  6249.             return bytes;
  6250.         }
  6251.     };
  6252.  
  6253.     var B58 = Bitcoin.Base58;
  6254. })(Bitcoin);
  6255. //https://raw.github.com/pointbiz/bitcoinjs-lib/9b2f94a028a7bc9bed94e0722563e9ff1d8e8db8/src/eckey.js
  6256. // See here for license information: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/LICENSE
  6257. (function (Bitcoin) {
  6258.     Bitcoin.ECKey = (function () {
  6259.         var ecparams = EllipticCurve.getSECCurveByName("secp256k1");
  6260.  
  6261.         var ECKey = function (input) {
  6262.             if (input instanceof BigInteger) {
  6263.                 // Input is a private key value
  6264.                 this.priv = input;
  6265.             } else if (Bitcoin.Util.isArray(input)) {
  6266.                 // Prepend zero byte to prevent interpretation as negative integer
  6267.                 this.priv = BigInteger.fromByteArrayUnsigned(input);
  6268.             } else if ("string" == typeof input) {
  6269.                 var bytes = null;
  6270.                 if (ECKey.isWalletImportFormat(input)) {
  6271.                     bytes = ECKey.decodeWalletImportFormat(input);
  6272.                 } else if (ECKey.isCompressedWalletImportFormat(input)) {
  6273.                     bytes = ECKey.decodeCompressedWalletImportFormat(input);
  6274.                     this.compressed = true;
  6275.                 } else if (ECKey.isMiniFormat(input)) {
  6276.                     bytes = Crypto.SHA256(input, { asBytes: true });
  6277.                 } else if (ECKey.isHexFormat(input)) {
  6278.                     bytes = Crypto.util.hexToBytes(input);
  6279.                 } else if (ECKey.isBase64Format(input)) {
  6280.                     bytes = Crypto.util.base64ToBytes(input);
  6281.                 }
  6282.                
  6283.                 if (ECKey.isBase6Format(input)) {
  6284.                     this.priv = new BigInteger(input, 6);
  6285.                 } else if (bytes == null || bytes.length != 32) {
  6286.                     this.priv = null;
  6287.                 } else {
  6288.                     // Prepend zero byte to prevent interpretation as negative integer
  6289.                     this.priv = BigInteger.fromByteArrayUnsigned(bytes);
  6290.                 }
  6291.             } else {
  6292.                 throw new Error("no plausible constructor behavior");  
  6293.             }
  6294.  
  6295.             this.compressed = (this.compressed == undefined) ? !!ECKey.compressByDefault : this.compressed;
  6296.         };
  6297.  
  6298.         ECKey.privateKeyPrefix = 0x80; // mainnet 0x80    testnet 0xEF
  6299.  
  6300.         /**
  6301.         * Whether public keys should be returned compressed by default.
  6302.         */
  6303.         ECKey.compressByDefault = false;
  6304.  
  6305.         /**
  6306.         * Set whether the public key should be returned compressed or not.
  6307.         */
  6308.         ECKey.prototype.setCompressed = function (v) {
  6309.             this.compressed = !!v;
  6310.             if (this.pubPoint) this.pubPoint.compressed = this.compressed;
  6311.             return this;
  6312.         };
  6313.  
  6314.         /*
  6315.         * Return public key as a byte array in DER encoding
  6316.         */
  6317.         ECKey.prototype.getPub = function () {
  6318.             if (this.compressed) {
  6319.                 if (this.pubComp) return this.pubComp;
  6320.                 return this.pubComp = this.getPubPoint().getEncoded(1);
  6321.             } else {
  6322.                 if (this.pubUncomp) return this.pubUncomp;
  6323.                 return this.pubUncomp = this.getPubPoint().getEncoded(0);
  6324.             }
  6325.         };
  6326.  
  6327.         /**
  6328.         * Return public point as ECPoint object.
  6329.         */
  6330.         ECKey.prototype.getPubPoint = function () {
  6331.             if (!this.pubPoint) {
  6332.                 this.pubPoint = ecparams.getG().multiply(this.priv);
  6333.                 this.pubPoint.compressed = this.compressed;
  6334.             }
  6335.             return this.pubPoint;
  6336.         };
  6337.  
  6338.         ECKey.prototype.getPubKeyHex = function () {
  6339.             if (this.compressed) {
  6340.                 if (this.pubKeyHexComp) return this.pubKeyHexComp;
  6341.                 return this.pubKeyHexComp = Crypto.util.bytesToHex(this.getPub()).toString().toUpperCase();
  6342.             } else {
  6343.                 if (this.pubKeyHexUncomp) return this.pubKeyHexUncomp;
  6344.                 return this.pubKeyHexUncomp = Crypto.util.bytesToHex(this.getPub()).toString().toUpperCase();
  6345.             }
  6346.         };
  6347.  
  6348.         /**
  6349.         * Get the pubKeyHash for this key.
  6350.         *
  6351.         * This is calculated as RIPE160(SHA256([encoded pubkey])) and returned as
  6352.         * a byte array.
  6353.         */
  6354.         ECKey.prototype.getPubKeyHash = function () {
  6355.             if (this.compressed) {
  6356.                 if (this.pubKeyHashComp) return this.pubKeyHashComp;
  6357.                 return this.pubKeyHashComp = Bitcoin.Util.sha256ripe160(this.getPub());
  6358.             } else {
  6359.                 if (this.pubKeyHashUncomp) return this.pubKeyHashUncomp;
  6360.                 return this.pubKeyHashUncomp = Bitcoin.Util.sha256ripe160(this.getPub());
  6361.             }
  6362.         };
  6363.  
  6364.         ECKey.prototype.getBitcoinAddress = function () {
  6365.             var hash = this.getPubKeyHash();
  6366.             var addr = new Bitcoin.Address(hash);
  6367.             return addr.toString();
  6368.         };
  6369.  
  6370.         /*
  6371.         * Takes a public point as a hex string or byte array
  6372.         */
  6373.         ECKey.prototype.setPub = function (pub) {
  6374.             // byte array
  6375.             if (Bitcoin.Util.isArray(pub)) {
  6376.                 pub = Crypto.util.bytesToHex(pub).toString().toUpperCase();
  6377.             }
  6378.             var ecPoint = ecparams.getCurve().decodePointHex(pub);
  6379.             this.setCompressed(ecPoint.compressed);
  6380.             this.pubPoint = ecPoint;
  6381.             return this;
  6382.         };
  6383.  
  6384.         // Sipa Private Key Wallet Import Format
  6385.         ECKey.prototype.getBitcoinWalletImportFormat = function () {
  6386.             var bytes = this.getBitcoinPrivateKeyByteArray();
  6387.             bytes.unshift(ECKey.privateKeyPrefix); // prepend 0x80 byte
  6388.             if (this.compressed) bytes.push(0x01); // append 0x01 byte for compressed format
  6389.             var checksum = Crypto.SHA256(Crypto.SHA256(bytes, { asBytes: true }), { asBytes: true });
  6390.             bytes = bytes.concat(checksum.slice(0, 4));
  6391.             var privWif = Bitcoin.Base58.encode(bytes);
  6392.             return privWif;
  6393.         };
  6394.  
  6395.         // Private Key Hex Format
  6396.         ECKey.prototype.getBitcoinHexFormat = function () {
  6397.             return Crypto.util.bytesToHex(this.getBitcoinPrivateKeyByteArray()).toString().toUpperCase();
  6398.         };
  6399.  
  6400.         // Private Key Base64 Format
  6401.         ECKey.prototype.getBitcoinBase64Format = function () {
  6402.             return Crypto.util.bytesToBase64(this.getBitcoinPrivateKeyByteArray());
  6403.         };
  6404.  
  6405.         ECKey.prototype.getBitcoinPrivateKeyByteArray = function () {
  6406.             // Get a copy of private key as a byte array
  6407.             var bytes = this.priv.toByteArrayUnsigned();
  6408.             // zero pad if private key is less than 32 bytes
  6409.             while (bytes.length < 32) bytes.unshift(0x00);
  6410.             return bytes;
  6411.         };
  6412.  
  6413.         ECKey.prototype.toString = function (format) {
  6414.             format = format || "";
  6415.             if (format.toString().toLowerCase() == "base64" || format.toString().toLowerCase() == "b64") {
  6416.                 return this.getBitcoinBase64Format();
  6417.             }
  6418.             // Wallet Import Format
  6419.             else if (format.toString().toLowerCase() == "wif") {
  6420.                 return this.getBitcoinWalletImportFormat();
  6421.             }
  6422.             else {
  6423.                 return this.getBitcoinHexFormat();
  6424.             }
  6425.         };
  6426.  
  6427.         /**
  6428.         * Parse a wallet import format private key contained in a string.
  6429.         */
  6430.         ECKey.decodeWalletImportFormat = function (privStr) {
  6431.             var bytes = Bitcoin.Base58.decode(privStr);
  6432.             var hash = bytes.slice(0, 33);
  6433.             var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
  6434.             if (checksum[0] != bytes[33] ||
  6435.                         checksum[1] != bytes[34] ||
  6436.                         checksum[2] != bytes[35] ||
  6437.                         checksum[3] != bytes[36]) {
  6438.                 throw "Checksum validation failed!";
  6439.             }
  6440.             var version = hash.shift();
  6441.             if (version != ECKey.privateKeyPrefix) {
  6442.                 throw "Version " + version + " not supported!";
  6443.             }
  6444.             return hash;
  6445.         };
  6446.  
  6447.         /**
  6448.         * Parse a compressed wallet import format private key contained in a string.
  6449.         */
  6450.         ECKey.decodeCompressedWalletImportFormat = function (privStr) {
  6451.             var bytes = Bitcoin.Base58.decode(privStr);
  6452.             var hash = bytes.slice(0, 34);
  6453.             var checksum = Crypto.SHA256(Crypto.SHA256(hash, { asBytes: true }), { asBytes: true });
  6454.             if (checksum[0] != bytes[34] ||
  6455.                         checksum[1] != bytes[35] ||
  6456.                         checksum[2] != bytes[36] ||
  6457.                         checksum[3] != bytes[37]) {
  6458.                 throw "Checksum validation failed!";
  6459.             }
  6460.             var version = hash.shift();
  6461.             if (version != ECKey.privateKeyPrefix) {
  6462.                 throw "Version " + version + " not supported!";
  6463.             }
  6464.             hash.pop();
  6465.             return hash;
  6466.         };
  6467.  
  6468.         // 64 characters [0-9A-F]
  6469.         ECKey.isHexFormat = function (key) {
  6470.             key = key.toString();
  6471.             return /^[A-Fa-f0-9]{64}$/.test(key);
  6472.         };
  6473.  
  6474.         // 51 characters base58, always starts with a '5'
  6475.         ECKey.isWalletImportFormat = function (key) {
  6476.             key = key.toString();
  6477.             return (ECKey.privateKeyPrefix == 0x80) ?
  6478.                                 (/^5[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$/.test(key)) :
  6479.                                 (/^9[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$/.test(key));
  6480.         };
  6481.  
  6482.         // 52 characters base58
  6483.         ECKey.isCompressedWalletImportFormat = function (key) {
  6484.             key = key.toString();
  6485.             return (ECKey.privateKeyPrefix == 0x80) ?
  6486.                                 (/^[LK][123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(key)) :
  6487.                                 (/^c[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(key));
  6488.         };
  6489.  
  6490.         // 44 characters
  6491.         ECKey.isBase64Format = function (key) {
  6492.             key = key.toString();
  6493.             return (/^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789=+\/]{44}$/.test(key));
  6494.         };
  6495.  
  6496.         // 99 characters, 1=1, if using dice convert 6 to 0
  6497.         ECKey.isBase6Format = function (key) {
  6498.             key = key.toString();
  6499.             return (/^[012345]{99}$/.test(key));
  6500.         };
  6501.  
  6502.         // 22, 26 or 30 characters, always starts with an 'S'
  6503.         ECKey.isMiniFormat = function (key) {
  6504.             key = key.toString();
  6505.             var validChars22 = /^S[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21}$/.test(key);
  6506.             var validChars26 = /^S[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{25}$/.test(key);
  6507.             var validChars30 = /^S[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{29}$/.test(key);
  6508.             var testBytes = Crypto.SHA256(key + "?", { asBytes: true });
  6509.  
  6510.             return ((testBytes[0] === 0x00 || testBytes[0] === 0x01) && (validChars22 || validChars26 || validChars30));
  6511.         };
  6512.  
  6513.         return ECKey;
  6514.     })();
  6515. })(Bitcoin);//https://raw.github.com/bitcoinjs/bitcoinjs-lib/09e8c6e184d6501a0c2c59d73ca64db5c0d3eb95/src/util.js
  6516. // See here for license information: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/LICENSE
  6517. // Bitcoin utility functions
  6518. (function (Bitcoin) {
  6519.     Bitcoin.Util = {
  6520.         /**
  6521.         * Cross-browser compatibility version of Array.isArray.
  6522.         */
  6523.         isArray: Array.isArray || function (o) {
  6524.             return Object.prototype.toString.call(o) === '[object Array]';
  6525.         },
  6526.         /**
  6527.         * Create an array of a certain length filled with a specific value.
  6528.         */
  6529.         makeFilledArray: function (len, val) {
  6530.             var array = [];
  6531.             var i = 0;
  6532.             while (i < len) {
  6533.                 array[i++] = val;
  6534.             }
  6535.             return array;
  6536.         },
  6537.         /**
  6538.         * Turn an integer into a "var_int".
  6539.         *
  6540.         * "var_int" is a variable length integer used by Bitcoin's binary format.
  6541.         *
  6542.         * Returns a byte array.
  6543.         */
  6544.         numToVarInt: function (i) {
  6545.             if (i < 0xfd) {
  6546.                 // unsigned char
  6547.                 return [i];
  6548.             } else if (i <= 1 << 16) {
  6549.                 // unsigned short (LE)
  6550.                 return [0xfd, i >>> 8, i & 255];
  6551.             } else if (i <= 1 << 32) {
  6552.                 // unsigned int (LE)
  6553.                 return [0xfe].concat(Crypto.util.wordsToBytes([i]));
  6554.             } else {
  6555.                 // unsigned long long (LE)
  6556.                 return [0xff].concat(Crypto.util.wordsToBytes([i >>> 32, i]));
  6557.             }
  6558.         },
  6559.         /**
  6560.         * Parse a Bitcoin value byte array, returning a BigInteger.
  6561.         */
  6562.         valueToBigInt: function (valueBuffer) {
  6563.             if (valueBuffer instanceof BigInteger) return valueBuffer;
  6564.  
  6565.             // Prepend zero byte to prevent interpretation as negative integer
  6566.             return BigInteger.fromByteArrayUnsigned(valueBuffer);
  6567.         },
  6568.         /**
  6569.         * Format a Bitcoin value as a string.
  6570.         *
  6571.         * Takes a BigInteger or byte-array and returns that amount of Bitcoins in a
  6572.         * nice standard formatting.
  6573.         *
  6574.         * Examples:
  6575.         * 12.3555
  6576.         * 0.1234
  6577.         * 900.99998888
  6578.         * 34.00
  6579.         */
  6580.         formatValue: function (valueBuffer) {
  6581.             var value = this.valueToBigInt(valueBuffer).toString();
  6582.             var integerPart = value.length > 8 ? value.substr(0, value.length - 8) : '0';
  6583.             var decimalPart = value.length > 8 ? value.substr(value.length - 8) : value;
  6584.             while (decimalPart.length < 8) decimalPart = "0" + decimalPart;
  6585.             decimalPart = decimalPart.replace(/0*$/, '');
  6586.             while (decimalPart.length < 2) decimalPart += "0";
  6587.             return integerPart + "." + decimalPart;
  6588.         },
  6589.         /**
  6590.         * Parse a floating point string as a Bitcoin value.
  6591.         *
  6592.         * Keep in mind that parsing user input is messy. You should always display
  6593.         * the parsed value back to the user to make sure we understood his input
  6594.         * correctly.
  6595.         */
  6596.         parseValue: function (valueString) {
  6597.             // TODO: Detect other number formats (e.g. comma as decimal separator)
  6598.             var valueComp = valueString.split('.');
  6599.             var integralPart = valueComp[0];
  6600.             var fractionalPart = valueComp[1] || "0";
  6601.             while (fractionalPart.length < 8) fractionalPart += "0";
  6602.             fractionalPart = fractionalPart.replace(/^0+/g, '');
  6603.             var value = BigInteger.valueOf(parseInt(integralPart));
  6604.             value = value.multiply(BigInteger.valueOf(100000000));
  6605.             value = value.add(BigInteger.valueOf(parseInt(fractionalPart)));
  6606.             return value;
  6607.         },
  6608.         /**
  6609.         * Calculate RIPEMD160(SHA256(data)).
  6610.         *
  6611.         * Takes an arbitrary byte array as inputs and returns the hash as a byte
  6612.         * array.
  6613.         */
  6614.         sha256ripe160: function (data) {
  6615.             return Crypto.RIPEMD160(Crypto.SHA256(data, { asBytes: true }), { asBytes: true });
  6616.         },
  6617.         // double sha256
  6618.         dsha256: function (data) {
  6619.             return Crypto.SHA256(Crypto.SHA256(data, { asBytes: true }), { asBytes: true });
  6620.         }
  6621.     };
  6622. })(Bitcoin);
  6623. },{}],17:[function(require,module,exports){
  6624. // Generated by IcedCoffeeScript 1.6.3-g
  6625. (function() {
  6626.   var AES, BlockCipher, G, Global, scrub_vec,
  6627.     __hasProp = {}.hasOwnProperty,
  6628.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  6629.  
  6630.  
  6631.  
  6632.   BlockCipher = require('./algbase').BlockCipher;
  6633.  
  6634.   scrub_vec = require('./util').scrub_vec;
  6635.  
  6636.   Global = (function() {
  6637.     function Global() {
  6638.       var i;
  6639.       this.SBOX = [];
  6640.       this.INV_SBOX = [];
  6641.       this.SUB_MIX = (function() {
  6642.         var _i, _results;
  6643.         _results = [];
  6644.         for (i = _i = 0; _i < 4; i = ++_i) {
  6645.           _results.push([]);
  6646.         }
  6647.         return _results;
  6648.       })();
  6649.       this.INV_SUB_MIX = (function() {
  6650.         var _i, _results;
  6651.         _results = [];
  6652.         for (i = _i = 0; _i < 4; i = ++_i) {
  6653.           _results.push([]);
  6654.         }
  6655.         return _results;
  6656.       })();
  6657.       this.init();
  6658.       this.RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  6659.     }
  6660.  
  6661.     Global.prototype.init = function() {
  6662.       var d, i, sx, t, x, x2, x4, x8, xi, _i;
  6663.       d = (function() {
  6664.         var _i, _results;
  6665.         _results = [];
  6666.         for (i = _i = 0; _i < 256; i = ++_i) {
  6667.           if (i < 128) {
  6668.             _results.push(i << 1);
  6669.           } else {
  6670.             _results.push((i << 1) ^ 0x11b);
  6671.           }
  6672.         }
  6673.         return _results;
  6674.       })();
  6675.       x = 0;
  6676.       xi = 0;
  6677.       for (i = _i = 0; _i < 256; i = ++_i) {
  6678.         sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  6679.         sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  6680.         this.SBOX[x] = sx;
  6681.         this.INV_SBOX[sx] = x;
  6682.         x2 = d[x];
  6683.         x4 = d[x2];
  6684.         x8 = d[x4];
  6685.         t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  6686.         this.SUB_MIX[0][x] = (t << 24) | (t >>> 8);
  6687.         this.SUB_MIX[1][x] = (t << 16) | (t >>> 16);
  6688.         this.SUB_MIX[2][x] = (t << 8) | (t >>> 24);
  6689.         this.SUB_MIX[3][x] = t;
  6690.         t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  6691.         this.INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8);
  6692.         this.INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16);
  6693.         this.INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24);
  6694.         this.INV_SUB_MIX[3][sx] = t;
  6695.         if (x === 0) {
  6696.           x = xi = 1;
  6697.         } else {
  6698.           x = x2 ^ d[d[d[x8 ^ x2]]];
  6699.           xi ^= d[d[xi]];
  6700.         }
  6701.       }
  6702.       return true;
  6703.     };
  6704.  
  6705.     return Global;
  6706.  
  6707.   })();
  6708.  
  6709.   G = new Global();
  6710.  
  6711.   AES = (function(_super) {
  6712.     __extends(AES, _super);
  6713.  
  6714.     AES.blockSize = 4 * 4;
  6715.  
  6716.     AES.prototype.blockSize = AES.blockSize;
  6717.  
  6718.     AES.keySize = 256 / 8;
  6719.  
  6720.     AES.prototype.keySize = AES.keySize;
  6721.  
  6722.     AES.ivSize = AES.blockSize;
  6723.  
  6724.     AES.prototype.ivSize = AES.ivSize;
  6725.  
  6726.     function AES(key) {
  6727.       this._key = key.clone();
  6728.       this._doReset();
  6729.     }
  6730.  
  6731.     AES.prototype._doReset = function() {
  6732.       var invKsRow, keySize, keyWords, ksRow, ksRows, t, _i, _j;
  6733.       keyWords = this._key.words;
  6734.       keySize = this._key.sigBytes / 4;
  6735.       this._nRounds = keySize + 6;
  6736.       ksRows = (this._nRounds + 1) * 4;
  6737.       this._keySchedule = [];
  6738.       for (ksRow = _i = 0; 0 <= ksRows ? _i < ksRows : _i > ksRows; ksRow = 0 <= ksRows ? ++_i : --_i) {
  6739.         this._keySchedule[ksRow] = ksRow < keySize ? keyWords[ksRow] : (t = this._keySchedule[ksRow - 1], (ksRow % keySize) === 0 ? (t = (t << 8) | (t >>> 24), t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff], t ^= G.RCON[(ksRow / keySize) | 0] << 24) : keySize > 6 && ksRow % keySize === 4 ? t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff] : void 0, this._keySchedule[ksRow - keySize] ^ t);
  6740.       }
  6741.       this._invKeySchedule = [];
  6742.       for (invKsRow = _j = 0; 0 <= ksRows ? _j < ksRows : _j > ksRows; invKsRow = 0 <= ksRows ? ++_j : --_j) {
  6743.         ksRow = ksRows - invKsRow;
  6744.         t = this._keySchedule[ksRow - (invKsRow % 4 ? 0 : 4)];
  6745.         this._invKeySchedule[invKsRow] = invKsRow < 4 || ksRow <= 4 ? t : G.INV_SUB_MIX[0][G.SBOX[t >>> 24]] ^ G.INV_SUB_MIX[1][G.SBOX[(t >>> 16) & 0xff]] ^ G.INV_SUB_MIX[2][G.SBOX[(t >>> 8) & 0xff]] ^ G.INV_SUB_MIX[3][G.SBOX[t & 0xff]];
  6746.       }
  6747.       return true;
  6748.     };
  6749.  
  6750.     AES.prototype.encryptBlock = function(M, offset) {
  6751.       if (offset == null) {
  6752.         offset = 0;
  6753.       }
  6754.       return this._doCryptBlock(M, offset, this._keySchedule, G.SUB_MIX, G.SBOX);
  6755.     };
  6756.  
  6757.     AES.prototype.decryptBlock = function(M, offset) {
  6758.       var _ref, _ref1;
  6759.       if (offset == null) {
  6760.         offset = 0;
  6761.       }
  6762.       _ref = [M[offset + 3], M[offset + 1]], M[offset + 1] = _ref[0], M[offset + 3] = _ref[1];
  6763.       this._doCryptBlock(M, offset, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX);
  6764.       return _ref1 = [M[offset + 3], M[offset + 1]], M[offset + 1] = _ref1[0], M[offset + 3] = _ref1[1], _ref1;
  6765.     };
  6766.  
  6767.     AES.prototype.scrub = function() {
  6768.       scrub_vec(this._keySchedule);
  6769.       scrub_vec(this._invKeySchedule);
  6770.       return this._key.scrub();
  6771.     };
  6772.  
  6773.     AES.prototype._doCryptBlock = function(M, offset, keySchedule, SUB_MIX, SBOX) {
  6774.       var ksRow, round, s0, s1, s2, s3, t0, t1, t2, t3, _i, _ref;
  6775.       s0 = M[offset] ^ keySchedule[0];
  6776.       s1 = M[offset + 1] ^ keySchedule[1];
  6777.       s2 = M[offset + 2] ^ keySchedule[2];
  6778.       s3 = M[offset + 3] ^ keySchedule[3];
  6779.       ksRow = 4;
  6780.       for (round = _i = 1, _ref = this._nRounds; 1 <= _ref ? _i < _ref : _i > _ref; round = 1 <= _ref ? ++_i : --_i) {
  6781.         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++];
  6782.         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++];
  6783.         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++];
  6784.         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++];
  6785.         s0 = t0;
  6786.         s1 = t1;
  6787.         s2 = t2;
  6788.         s3 = t3;
  6789.       }
  6790.       t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  6791.       t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  6792.       t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  6793.       t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  6794.       M[offset] = t0;
  6795.       M[offset + 1] = t1;
  6796.       M[offset + 2] = t2;
  6797.       return M[offset + 3] = t3;
  6798.     };
  6799.  
  6800.     return AES;
  6801.  
  6802.   })(BlockCipher);
  6803.  
  6804.   exports.AES = AES;
  6805.  
  6806. }).call(this);
  6807.  
  6808. },{"./algbase":18,"./util":37}],18:[function(require,module,exports){
  6809. // Generated by IcedCoffeeScript 1.6.3-g
  6810. (function() {
  6811.   var BlockCipher, BufferedBlockAlgorithm, Hasher, StreamCipher, WordArray, util,
  6812.     __hasProp = {}.hasOwnProperty,
  6813.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  6814.  
  6815.  
  6816.  
  6817.   WordArray = require('./wordarray').WordArray;
  6818.  
  6819.   util = require('./util');
  6820.  
  6821.   BufferedBlockAlgorithm = (function() {
  6822.     BufferedBlockAlgorithm.prototype._minBufferSize = 0;
  6823.  
  6824.     function BufferedBlockAlgorithm() {
  6825.       this.reset();
  6826.     }
  6827.  
  6828.     BufferedBlockAlgorithm.prototype.reset = function() {
  6829.       this._data = new WordArray();
  6830.       return this._nDataBytes = 0;
  6831.     };
  6832.  
  6833.     BufferedBlockAlgorithm.prototype._append = function(data) {
  6834.       this._data.concat(data);
  6835.       return this._nDataBytes += data.sigBytes;
  6836.     };
  6837.  
  6838.     BufferedBlockAlgorithm.prototype._process = function(doFlush) {
  6839.       var blockSizeBytes, data, dataSigBytes, dataWords, nBlocksReady, nBytesReady, nWordsReady, offset, processedWords, _i, _ref;
  6840.       data = this._data;
  6841.       dataWords = data.words;
  6842.       dataSigBytes = data.sigBytes;
  6843.       blockSizeBytes = this.blockSize * 4;
  6844.       nBlocksReady = dataSigBytes / blockSizeBytes;
  6845.       if (doFlush) {
  6846.         nBlocksReady = Math.ceil(nBlocksReady);
  6847.       } else {
  6848.         nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  6849.       }
  6850.       nWordsReady = nBlocksReady * this.blockSize;
  6851.       nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  6852.       if (nWordsReady) {
  6853.         for (offset = _i = 0, _ref = this.blockSize; _ref > 0 ? _i < nWordsReady : _i > nWordsReady; offset = _i += _ref) {
  6854.           this._doProcessBlock(dataWords, offset);
  6855.         }
  6856.         processedWords = dataWords.splice(0, nWordsReady);
  6857.         data.sigBytes -= nBytesReady;
  6858.       }
  6859.       return new WordArray(processedWords, nBytesReady);
  6860.     };
  6861.  
  6862.     BufferedBlockAlgorithm.prototype.copy_to = function(out) {
  6863.       out._data = this._data.clone();
  6864.       return out._nDataBytes = this._nDataBytes;
  6865.     };
  6866.  
  6867.     BufferedBlockAlgorithm.prototype.clone = function() {
  6868.       var obj;
  6869.       obj = new BufferedBlockAlgorithm();
  6870.       this.copy_to(obj);
  6871.       return obj;
  6872.     };
  6873.  
  6874.     return BufferedBlockAlgorithm;
  6875.  
  6876.   })();
  6877.  
  6878.   Hasher = (function(_super) {
  6879.     __extends(Hasher, _super);
  6880.  
  6881.     function Hasher() {
  6882.       Hasher.__super__.constructor.call(this);
  6883.     }
  6884.  
  6885.     Hasher.prototype.reset = function() {
  6886.       Hasher.__super__.reset.call(this);
  6887.       this._doReset();
  6888.       return this;
  6889.     };
  6890.  
  6891.     Hasher.prototype.update = function(messageUpdate) {
  6892.       this._append(messageUpdate);
  6893.       this._process();
  6894.       return this;
  6895.     };
  6896.  
  6897.     Hasher.prototype.finalize = function(messageUpdate) {
  6898.       if (messageUpdate) {
  6899.         this._append(messageUpdate);
  6900.       }
  6901.       return this._doFinalize();
  6902.     };
  6903.  
  6904.     Hasher.prototype.bufhash = function(input) {
  6905.       var out, wa_in, wa_out;
  6906.       wa_in = WordArray.from_buffer(input);
  6907.       wa_out = this.finalize(wa_in);
  6908.       out = wa_out.to_buffer();
  6909.       wa_in.scrub();
  6910.       wa_out.scrub();
  6911.       return out;
  6912.     };
  6913.  
  6914.     return Hasher;
  6915.  
  6916.   })(BufferedBlockAlgorithm);
  6917.  
  6918.   exports.BlockCipher = BlockCipher = (function() {
  6919.     function BlockCipher(key) {}
  6920.  
  6921.     BlockCipher.prototype.encryptBlock = function(M, offset) {};
  6922.  
  6923.     return BlockCipher;
  6924.  
  6925.   })();
  6926.  
  6927.   StreamCipher = (function() {
  6928.     function StreamCipher() {}
  6929.  
  6930.     StreamCipher.prototype.encryptBlock = function(word_array, dst_offset) {
  6931.       var n_words, pad;
  6932.       if (dst_offset == null) {
  6933.         dst_offset = 0;
  6934.       }
  6935.       pad = this.get_pad();
  6936.       n_words = Math.min(word_array.words.length - dst_offset, this.bsiw);
  6937.       word_array.xor(pad, {
  6938.         dst_offset: dst_offset,
  6939.         n_words: n_words
  6940.       });
  6941.       pad.scrub();
  6942.       return this.bsiw;
  6943.     };
  6944.  
  6945.     StreamCipher.prototype.encrypt = function(word_array) {
  6946.       var i, _i, _ref, _ref1;
  6947.       for (i = _i = 0, _ref = word_array.words.length, _ref1 = this.bsiw; _ref1 > 0 ? _i < _ref : _i > _ref; i = _i += _ref1) {
  6948.         this.encryptBlock(word_array, i);
  6949.       }
  6950.       return word_array;
  6951.     };
  6952.  
  6953.     StreamCipher.prototype.bulk_encrypt = function(_arg, cb) {
  6954.       var async_args, input, progress_hook, slice_args, what,
  6955.         _this = this;
  6956.       input = _arg.input, progress_hook = _arg.progress_hook, what = _arg.what;
  6957.       slice_args = {
  6958.         update: function(lo, hi) {
  6959.           var i, _i, _ref, _results;
  6960.           _results = [];
  6961.           for (i = _i = lo, _ref = _this.bsiw; _ref > 0 ? _i < hi : _i > hi; i = _i += _ref) {
  6962.             _results.push(_this.encryptBlock(input, i));
  6963.           }
  6964.           return _results;
  6965.         },
  6966.         finalize: function() {
  6967.           return input;
  6968.         },
  6969.         default_n: this.bsiw * 1024
  6970.       };
  6971.       async_args = {
  6972.         progress_hook: progress_hook,
  6973.         cb: cb,
  6974.         what: what
  6975.       };
  6976.       return util.bulk(input.sigBytes, slice_args, async_args);
  6977.     };
  6978.  
  6979.     return StreamCipher;
  6980.  
  6981.   })();
  6982.  
  6983.   exports.BlockCipher = BlockCipher;
  6984.  
  6985.   exports.Hasher = Hasher;
  6986.  
  6987.   exports.BufferedBlockAlgorithm = BufferedBlockAlgorithm;
  6988.  
  6989.   exports.StreamCipher = StreamCipher;
  6990.  
  6991. }).call(this);
  6992.  
  6993. },{"./util":37,"./wordarray":38}],19:[function(require,module,exports){
  6994. // Generated by IcedCoffeeScript 1.6.3-g
  6995. (function() {
  6996.   var CombineBase, Concat, HMAC, SHA3, SHA512, WordArray, XOR, bulk_sign, _ref,
  6997.     __hasProp = {}.hasOwnProperty,
  6998.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  6999.  
  7000.  
  7001.  
  7002.   _ref = require('./hmac'), HMAC = _ref.HMAC, bulk_sign = _ref.bulk_sign;
  7003.  
  7004.   SHA512 = require('./sha512').SHA512;
  7005.  
  7006.   SHA3 = require('./sha3').SHA3;
  7007.  
  7008.   WordArray = require('./wordarray').WordArray;
  7009.  
  7010.   CombineBase = (function() {
  7011.     function CombineBase() {
  7012.       this.hasherBlockSize = this.hashers[0].hasherBlockSize;
  7013.       this.hasherBlockSizeBytes = this.hasherBlockSize * 4;
  7014.       this.reset();
  7015.     }
  7016.  
  7017.     CombineBase.prototype.reset = function() {
  7018.       var h, _i, _len, _ref1;
  7019.       _ref1 = this.hashers;
  7020.       for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  7021.         h = _ref1[_i];
  7022.         h.reset();
  7023.       }
  7024.       return this;
  7025.     };
  7026.  
  7027.     CombineBase.prototype.update = function(w) {
  7028.       var h, _i, _len, _ref1;
  7029.       _ref1 = this.hashers;
  7030.       for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  7031.         h = _ref1[_i];
  7032.         h.update(w);
  7033.       }
  7034.       return this;
  7035.     };
  7036.  
  7037.     CombineBase.prototype.scrub = function() {
  7038.       var h, _i, _len, _ref1;
  7039.       _ref1 = this.hashers;
  7040.       for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  7041.         h = _ref1[_i];
  7042.         h.scrub();
  7043.       }
  7044.       return this;
  7045.     };
  7046.  
  7047.     CombineBase.prototype.finalize = function(w) {
  7048.       var h, hashes, out, _i, _len, _ref1;
  7049.       hashes = (function() {
  7050.         var _i, _len, _ref1, _results;
  7051.         _ref1 = this.hashers;
  7052.         _results = [];
  7053.         for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  7054.           h = _ref1[_i];
  7055.           _results.push(h.finalize(w));
  7056.         }
  7057.         return _results;
  7058.       }).call(this);
  7059.       out = hashes[0];
  7060.       _ref1 = hashes.slice(1);
  7061.       for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  7062.         h = _ref1[_i];
  7063.         this._coalesce(out, h);
  7064.         h.scrub();
  7065.       }
  7066.       return out;
  7067.     };
  7068.  
  7069.     return CombineBase;
  7070.  
  7071.   })();
  7072.  
  7073.   Concat = (function(_super) {
  7074.     __extends(Concat, _super);
  7075.  
  7076.     function Concat(key, klasses) {
  7077.       var hm, i, klass, subkey, subkeys;
  7078.       if (klasses == null) {
  7079.         klasses = [SHA512, SHA3];
  7080.       }
  7081.       subkeys = key.split(klasses.length);
  7082.       this.hashers = (function() {
  7083.         var _i, _len, _results;
  7084.         _results = [];
  7085.         for (i = _i = 0, _len = klasses.length; _i < _len; i = ++_i) {
  7086.           klass = klasses[i];
  7087.           subkey = subkeys[i];
  7088.           hm = new HMAC(subkey, klass);
  7089.           subkey.scrub();
  7090.           _results.push(hm);
  7091.         }
  7092.         return _results;
  7093.       })();
  7094.       Concat.__super__.constructor.call(this);
  7095.     }
  7096.  
  7097.     Concat.get_output_size = function() {
  7098.       return SHA512.output_size + SHA3.output_size;
  7099.     };
  7100.  
  7101.     Concat.prototype._coalesce = function(out, h) {
  7102.       return out.concat(h);
  7103.     };
  7104.  
  7105.     Concat.prototype.get_output_size = function() {
  7106.       var h, tot, _i, _len, _ref1;
  7107.       tot = 0;
  7108.       _ref1 = this.hashers;
  7109.       for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  7110.         h = _ref1[_i];
  7111.         tot += h.get_output_size();
  7112.       }
  7113.       return tot;
  7114.     };
  7115.  
  7116.     Concat.sign = function(_arg) {
  7117.       var input, key;
  7118.       key = _arg.key, input = _arg.input;
  7119.       return (new Concat(key)).finalize(input);
  7120.     };
  7121.  
  7122.     Concat.bulk_sign = function(args, cb) {
  7123.       args.klass = Concat;
  7124.       args.what = "HMAC-SHA512-SHA3";
  7125.       return bulk_sign(args, cb);
  7126.     };
  7127.  
  7128.     return Concat;
  7129.  
  7130.   })(CombineBase);
  7131.  
  7132.   XOR = (function(_super) {
  7133.     __extends(XOR, _super);
  7134.  
  7135.     function XOR(key, klasses) {
  7136.       var klass;
  7137.       if (klasses == null) {
  7138.         klasses = [SHA512, SHA3];
  7139.       }
  7140.       this.hashers = (function() {
  7141.         var _i, _len, _results;
  7142.         _results = [];
  7143.         for (_i = 0, _len = klasses.length; _i < _len; _i++) {
  7144.           klass = klasses[_i];
  7145.           _results.push(new HMAC(key, klass));
  7146.         }
  7147.         return _results;
  7148.       })();
  7149.       XOR.__super__.constructor.call(this);
  7150.     }
  7151.  
  7152.     XOR.prototype.reset = function() {
  7153.       var h, i, _i, _len, _ref1;
  7154.       XOR.__super__.reset.call(this);
  7155.       _ref1 = this.hashers;
  7156.       for (i = _i = 0, _len = _ref1.length; _i < _len; i = ++_i) {
  7157.         h = _ref1[i];
  7158.         h.update(new WordArray([i]));
  7159.       }
  7160.       return this;
  7161.     };
  7162.  
  7163.     XOR.get_output_size = function() {
  7164.       return Math.max(SHA512.output_size, SHA3.output_size);
  7165.     };
  7166.  
  7167.     XOR.prototype._coalesce = function(out, h) {
  7168.       return out.xor(h, {});
  7169.     };
  7170.  
  7171.     XOR.prototype.get_output_size = function() {
  7172.       var h;
  7173.       return Math.max.apply(Math, (function() {
  7174.         var _i, _len, _ref1, _results;
  7175.         _ref1 = this.hashers;
  7176.         _results = [];
  7177.         for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  7178.           h = _ref1[_i];
  7179.           _results.push(h.get_output_size());
  7180.         }
  7181.         return _results;
  7182.       }).call(this));
  7183.     };
  7184.  
  7185.     XOR.sign = function(_arg) {
  7186.       var input, key;
  7187.       key = _arg.key, input = _arg.input;
  7188.       return (new XOR(key)).finalize(input);
  7189.     };
  7190.  
  7191.     XOR.bulk_sign = function(arg, cb) {
  7192.       arg.klass = XOR;
  7193.       arg.what = "HMAC-SHA512-XOR-SHA3";
  7194.       return bulk_sign(arg, cb);
  7195.     };
  7196.  
  7197.     return XOR;
  7198.  
  7199.   })(CombineBase);
  7200.  
  7201.   exports.Concat = Concat;
  7202.  
  7203.   exports.XOR = XOR;
  7204.  
  7205. }).call(this);
  7206.  
  7207. },{"./hmac":24,"./sha3":34,"./sha512":35,"./wordarray":38}],20:[function(require,module,exports){
  7208. // Generated by IcedCoffeeScript 1.6.3-g
  7209. (function() {
  7210.   var Cipher, Counter, StreamCipher, WordArray, bulk_encrypt, encrypt, iced, __iced_k, __iced_k_noop,
  7211.     __hasProp = {}.hasOwnProperty,
  7212.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  7213.  
  7214.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  7215.   __iced_k = __iced_k_noop = function() {};
  7216.  
  7217.   WordArray = require('./wordarray').WordArray;
  7218.  
  7219.   StreamCipher = require('./algbase').StreamCipher;
  7220.  
  7221.   Counter = (function() {
  7222.     Counter.prototype.WORD_MAX = 0xffffffff;
  7223.  
  7224.     function Counter(_arg) {
  7225.       var i, len, value;
  7226.       value = _arg.value, len = _arg.len;
  7227.       this._value = value != null ? value.clone() : (len == null ? len = 2 : void 0, new WordArray((function() {
  7228.         var _i, _results;
  7229.         _results = [];
  7230.         for (i = _i = 0; 0 <= len ? _i < len : _i > len; i = 0 <= len ? ++_i : --_i) {
  7231.           _results.push(0);
  7232.         }
  7233.         return _results;
  7234.       })()));
  7235.     }
  7236.  
  7237.     Counter.prototype.inc = function() {
  7238.       var go, i;
  7239.       go = true;
  7240.       i = this._value.words.length - 1;
  7241.       while (go && i >= 0) {
  7242.         if ((++this._value.words[i]) > Counter.WORD_MAX) {
  7243.           this._value.words[i] = 0;
  7244.         } else {
  7245.           go = false;
  7246.         }
  7247.         i--;
  7248.       }
  7249.       return this;
  7250.     };
  7251.  
  7252.     Counter.prototype.inc_le = function() {
  7253.       var go, i;
  7254.       go = true;
  7255.       i = 0;
  7256.       while (go && i < this._value.words.length) {
  7257.         if ((++this._value.words[i]) > Counter.WORD_MAX) {
  7258.           this._value.words[i] = 0;
  7259.         } else {
  7260.           go = false;
  7261.         }
  7262.         i++;
  7263.       }
  7264.       return this;
  7265.     };
  7266.  
  7267.     Counter.prototype.get = function() {
  7268.       return this._value;
  7269.     };
  7270.  
  7271.     Counter.prototype.copy = function() {
  7272.       return this._value.clone();
  7273.     };
  7274.  
  7275.     return Counter;
  7276.  
  7277.   })();
  7278.  
  7279.   Cipher = (function(_super) {
  7280.     __extends(Cipher, _super);
  7281.  
  7282.     function Cipher(_arg) {
  7283.       this.block_cipher = _arg.block_cipher, this.iv = _arg.iv;
  7284.       Cipher.__super__.constructor.call(this);
  7285.       this.bsiw = this.block_cipher.blockSize / 4;
  7286.       if (!(this.iv.sigBytes === this.block_cipher.blockSize)) {
  7287.         throw new Error("IV is wrong length (" + this.iv.sigBytes + ")");
  7288.       }
  7289.       this.ctr = new Counter({
  7290.         value: this.iv
  7291.       });
  7292.     }
  7293.  
  7294.     Cipher.prototype.scrub = function() {
  7295.       return this.block_cipher.scrub();
  7296.     };
  7297.  
  7298.     Cipher.prototype.get_pad = function() {
  7299.       var pad;
  7300.       pad = this.ctr.copy();
  7301.       this.ctr.inc();
  7302.       this.block_cipher.encryptBlock(pad.words);
  7303.       return pad;
  7304.     };
  7305.  
  7306.     return Cipher;
  7307.  
  7308.   })(StreamCipher);
  7309.  
  7310.   encrypt = function(_arg) {
  7311.     var block_cipher, cipher, input, iv, ret;
  7312.     block_cipher = _arg.block_cipher, iv = _arg.iv, input = _arg.input;
  7313.     cipher = new Cipher({
  7314.       block_cipher: block_cipher,
  7315.       iv: iv
  7316.     });
  7317.     ret = cipher.encrypt(input);
  7318.     cipher.scrub();
  7319.     return ret;
  7320.   };
  7321.  
  7322.   bulk_encrypt = function(_arg, cb) {
  7323.     var block_cipher, cipher, input, iv, progress_hook, ret, what, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  7324.       _this = this;
  7325.     __iced_k = __iced_k_noop;
  7326.     ___iced_passed_deferral = iced.findDeferral(arguments);
  7327.     block_cipher = _arg.block_cipher, iv = _arg.iv, input = _arg.input, progress_hook = _arg.progress_hook, what = _arg.what;
  7328.     cipher = new Cipher({
  7329.       block_cipher: block_cipher,
  7330.       iv: iv
  7331.     });
  7332.     (function(__iced_k) {
  7333.       __iced_deferrals = new iced.Deferrals(__iced_k, {
  7334.         parent: ___iced_passed_deferral,
  7335.         filename: "src/ctr.iced",
  7336.         funcname: "bulk_encrypt"
  7337.       });
  7338.       cipher.bulk_encrypt({
  7339.         input: input,
  7340.         progress_hook: progress_hook,
  7341.         what: what
  7342.       }, __iced_deferrals.defer({
  7343.         assign_fn: (function() {
  7344.           return function() {
  7345.             return ret = arguments[0];
  7346.           };
  7347.         })(),
  7348.         lineno: 121
  7349.       }));
  7350.       __iced_deferrals._fulfill();
  7351.     })(function() {
  7352.       return cb(ret);
  7353.     });
  7354.   };
  7355.  
  7356.   exports.Counter = Counter;
  7357.  
  7358.   exports.Cipher = Cipher;
  7359.  
  7360.   exports.encrypt = encrypt;
  7361.  
  7362.   exports.bulk_encrypt = bulk_encrypt;
  7363.  
  7364. }).call(this);
  7365.  
  7366. },{"./algbase":18,"./wordarray":38,"iced-coffee-script/lib/coffee-script/iced":9}],21:[function(require,module,exports){
  7367. // Generated by IcedCoffeeScript 1.6.3-g
  7368. (function() {
  7369.   var AES, Base, Concat, Decryptor, SHA512, Salsa20, TwoFish, V, WordArray, ctr, decrypt, iced, make_esc, salsa20, __iced_k, __iced_k_noop, _ref,
  7370.     __hasProp = {}.hasOwnProperty,
  7371.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  7372.  
  7373.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  7374.   __iced_k = __iced_k_noop = function() {};
  7375.  
  7376.   WordArray = require('./wordarray').WordArray;
  7377.  
  7378.   salsa20 = require('./salsa20');
  7379.  
  7380.   AES = require('./aes').AES;
  7381.  
  7382.   TwoFish = require('./twofish').TwoFish;
  7383.  
  7384.   ctr = require('./ctr');
  7385.  
  7386.   Concat = require('./combine').Concat;
  7387.  
  7388.   SHA512 = require('./sha512').SHA512;
  7389.  
  7390.   Salsa20 = require('./salsa20').Salsa20;
  7391.  
  7392.   _ref = require('./enc'), Base = _ref.Base, V = _ref.V;
  7393.  
  7394.   make_esc = require('iced-error').make_esc;
  7395.  
  7396.   Decryptor = (function(_super) {
  7397.     __extends(Decryptor, _super);
  7398.  
  7399.     function Decryptor(_arg) {
  7400.       var enc, key;
  7401.       key = _arg.key, enc = _arg.enc;
  7402.       Decryptor.__super__.constructor.call(this, {
  7403.         key: key
  7404.       });
  7405.       if (enc != null) {
  7406.         this.key = enc.key;
  7407.         this.derived_keys = enc.derived_keys;
  7408.       }
  7409.     }
  7410.  
  7411.     Decryptor.prototype.read_header = function(cb) {
  7412.       var err, wa;
  7413.       err = (wa = this.ct.unshift(2)) == null ? new Error("Ciphertext underrun in header") : (this.version = V[wa.words[1]]) == null ? new Error("bad header; couldn't find a good version (got " + wa.words[1] + ")") : wa.words[0] !== this.version.header[0] ? new Error("Bad header: unrecognized magic value") : null;
  7414.       return cb(err);
  7415.     };
  7416.  
  7417.     Decryptor.prototype.verify_sig = function(key, cb) {
  7418.       var computed, err, received, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  7419.         _this = this;
  7420.       __iced_k = __iced_k_noop;
  7421.       ___iced_passed_deferral = iced.findDeferral(arguments);
  7422.       (function(__iced_k) {
  7423.         if ((received = _this.ct.unshift(Concat.get_output_size() / 4)) == null) {
  7424.           return __iced_k(err = new Error("Ciphertext underrun in signature"));
  7425.         } else {
  7426.           (function(__iced_k) {
  7427.             __iced_deferrals = new iced.Deferrals(__iced_k, {
  7428.               parent: ___iced_passed_deferral,
  7429.               filename: "src/dec.iced",
  7430.               funcname: "Decryptor.verify_sig"
  7431.             });
  7432.             _this.sign({
  7433.               input: _this.ct,
  7434.               key: key,
  7435.               salt: _this.salt
  7436.             }, __iced_deferrals.defer({
  7437.               assign_fn: (function() {
  7438.                 return function() {
  7439.                   err = arguments[0];
  7440.                   return computed = arguments[1];
  7441.                 };
  7442.               })(),
  7443.               lineno: 63
  7444.             }));
  7445.             __iced_deferrals._fulfill();
  7446.           })(function() {
  7447.             return __iced_k(err = err != null ? err : received.equal(computed) ? null : new Error('Signature mismatch or bad decryption key'));
  7448.           });
  7449.         }
  7450.       })(function() {
  7451.         return cb(err);
  7452.       });
  7453.     };
  7454.  
  7455.     Decryptor.prototype.unshift_iv = function(n_bytes, which, cb) {
  7456.       var err, iv;
  7457.       err = (iv = this.ct.unshift(n_bytes / 4)) != null ? null : new Error("Ciphertext underrun in " + which);
  7458.       return cb(err, iv);
  7459.     };
  7460.  
  7461.     Decryptor.prototype.read_salt = function(cb) {
  7462.       var err;
  7463.       err = (this.salt = this.ct.unshift(this.version.salt_size / 4)) == null ? new Error("Ciphertext underrrun in read_salt") : null;
  7464.       return cb(err);
  7465.     };
  7466.  
  7467.     Decryptor.prototype.generate_keys = function(_arg, cb) {
  7468.       var err, keys, progress_hook, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  7469.         _this = this;
  7470.       __iced_k = __iced_k_noop;
  7471.       ___iced_passed_deferral = iced.findDeferral(arguments);
  7472.       progress_hook = _arg.progress_hook;
  7473.       (function(__iced_k) {
  7474.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  7475.           parent: ___iced_passed_deferral,
  7476.           filename: "src/dec.iced",
  7477.           funcname: "Decryptor.generate_keys"
  7478.         });
  7479.         _this.kdf({
  7480.           salt: _this.salt,
  7481.           progress_hook: progress_hook
  7482.         }, __iced_deferrals.defer({
  7483.           assign_fn: (function() {
  7484.             return function() {
  7485.               err = arguments[0];
  7486.               return keys = arguments[1];
  7487.             };
  7488.           })(),
  7489.           lineno: 114
  7490.         }));
  7491.         __iced_deferrals._fulfill();
  7492.       })(function() {
  7493.         return cb(err, keys);
  7494.       });
  7495.     };
  7496.  
  7497.     Decryptor.prototype.run = function(_arg, cb) {
  7498.       var ct1, ct2, data, esc, iv, progress_hook, pt, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  7499.         _this = this;
  7500.       __iced_k = __iced_k_noop;
  7501.       ___iced_passed_deferral = iced.findDeferral(arguments);
  7502.       data = _arg.data, progress_hook = _arg.progress_hook;
  7503.       esc = make_esc(cb, "Decryptor::run");
  7504.       this.ct = WordArray.from_buffer(data);
  7505.       (function(__iced_k) {
  7506.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  7507.           parent: ___iced_passed_deferral,
  7508.           filename: "src/dec.iced",
  7509.           funcname: "Decryptor.run"
  7510.         });
  7511.         _this.read_header(esc(__iced_deferrals.defer({
  7512.           lineno: 141
  7513.         })));
  7514.         __iced_deferrals._fulfill();
  7515.       })(function() {
  7516.         (function(__iced_k) {
  7517.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  7518.             parent: ___iced_passed_deferral,
  7519.             filename: "src/dec.iced",
  7520.             funcname: "Decryptor.run"
  7521.           });
  7522.           _this.read_salt(esc(__iced_deferrals.defer({
  7523.             lineno: 142
  7524.           })));
  7525.           __iced_deferrals._fulfill();
  7526.         })(function() {
  7527.           (function(__iced_k) {
  7528.             __iced_deferrals = new iced.Deferrals(__iced_k, {
  7529.               parent: ___iced_passed_deferral,
  7530.               filename: "src/dec.iced",
  7531.               funcname: "Decryptor.run"
  7532.             });
  7533.             _this.generate_keys({
  7534.               progress_hook: progress_hook
  7535.             }, esc(__iced_deferrals.defer({
  7536.               assign_fn: (function(__slot_1) {
  7537.                 return function() {
  7538.                   return __slot_1.keys = arguments[0];
  7539.                 };
  7540.               })(_this),
  7541.               lineno: 143
  7542.             })));
  7543.             __iced_deferrals._fulfill();
  7544.           })(function() {
  7545.             (function(__iced_k) {
  7546.               __iced_deferrals = new iced.Deferrals(__iced_k, {
  7547.                 parent: ___iced_passed_deferral,
  7548.                 filename: "src/dec.iced",
  7549.                 funcname: "Decryptor.run"
  7550.               });
  7551.               _this.verify_sig(_this.keys.hmac, esc(__iced_deferrals.defer({
  7552.                 lineno: 144
  7553.               })));
  7554.               __iced_deferrals._fulfill();
  7555.             })(function() {
  7556.               (function(__iced_k) {
  7557.                 __iced_deferrals = new iced.Deferrals(__iced_k, {
  7558.                   parent: ___iced_passed_deferral,
  7559.                   filename: "src/dec.iced",
  7560.                   funcname: "Decryptor.run"
  7561.                 });
  7562.                 _this.unshift_iv(AES.ivSize, "AES", esc(__iced_deferrals.defer({
  7563.                   assign_fn: (function() {
  7564.                     return function() {
  7565.                       return iv = arguments[0];
  7566.                     };
  7567.                   })(),
  7568.                   lineno: 145
  7569.                 })));
  7570.                 __iced_deferrals._fulfill();
  7571.               })(function() {
  7572.                 (function(__iced_k) {
  7573.                   __iced_deferrals = new iced.Deferrals(__iced_k, {
  7574.                     parent: ___iced_passed_deferral,
  7575.                     filename: "src/dec.iced",
  7576.                     funcname: "Decryptor.run"
  7577.                   });
  7578.                   _this.run_aes({
  7579.                     iv: iv,
  7580.                     input: _this.ct,
  7581.                     key: _this.keys.aes,
  7582.                     progress_hook: progress_hook
  7583.                   }, esc(__iced_deferrals.defer({
  7584.                     assign_fn: (function() {
  7585.                       return function() {
  7586.                         return ct2 = arguments[0];
  7587.                       };
  7588.                     })(),
  7589.                     lineno: 146
  7590.                   })));
  7591.                   __iced_deferrals._fulfill();
  7592.                 })(function() {
  7593.                   (function(__iced_k) {
  7594.                     __iced_deferrals = new iced.Deferrals(__iced_k, {
  7595.                       parent: ___iced_passed_deferral,
  7596.                       filename: "src/dec.iced",
  7597.                       funcname: "Decryptor.run"
  7598.                     });
  7599.                     _this.unshift_iv(TwoFish.ivSize, "2fish", esc(__iced_deferrals.defer({
  7600.                       assign_fn: (function() {
  7601.                         return function() {
  7602.                           return iv = arguments[0];
  7603.                         };
  7604.                       })(),
  7605.                       lineno: 147
  7606.                     })));
  7607.                     __iced_deferrals._fulfill();
  7608.                   })(function() {
  7609.                     (function(__iced_k) {
  7610.                       __iced_deferrals = new iced.Deferrals(__iced_k, {
  7611.                         parent: ___iced_passed_deferral,
  7612.                         filename: "src/dec.iced",
  7613.                         funcname: "Decryptor.run"
  7614.                       });
  7615.                       _this.run_twofish({
  7616.                         iv: iv,
  7617.                         input: _this.ct,
  7618.                         key: _this.keys.twofish,
  7619.                         progress_hook: progress_hook
  7620.                       }, esc(__iced_deferrals.defer({
  7621.                         assign_fn: (function() {
  7622.                           return function() {
  7623.                             return ct1 = arguments[0];
  7624.                           };
  7625.                         })(),
  7626.                         lineno: 148
  7627.                       })));
  7628.                       __iced_deferrals._fulfill();
  7629.                     })(function() {
  7630.                       (function(__iced_k) {
  7631.                         __iced_deferrals = new iced.Deferrals(__iced_k, {
  7632.                           parent: ___iced_passed_deferral,
  7633.                           filename: "src/dec.iced",
  7634.                           funcname: "Decryptor.run"
  7635.                         });
  7636.                         _this.unshift_iv(Salsa20.ivSize, "Salsa", esc(__iced_deferrals.defer({
  7637.                           assign_fn: (function() {
  7638.                             return function() {
  7639.                               return iv = arguments[0];
  7640.                             };
  7641.                           })(),
  7642.                           lineno: 149
  7643.                         })));
  7644.                         __iced_deferrals._fulfill();
  7645.                       })(function() {
  7646.                         (function(__iced_k) {
  7647.                           __iced_deferrals = new iced.Deferrals(__iced_k, {
  7648.                             parent: ___iced_passed_deferral,
  7649.                             filename: "src/dec.iced",
  7650.                             funcname: "Decryptor.run"
  7651.                           });
  7652.                           _this.run_salsa20({
  7653.                             iv: iv,
  7654.                             input: _this.ct,
  7655.                             key: _this.keys.salsa20,
  7656.                             output_iv: false,
  7657.                             progress_hook: progress_hook
  7658.                           }, esc(__iced_deferrals.defer({
  7659.                             assign_fn: (function() {
  7660.                               return function() {
  7661.                                 return pt = arguments[0];
  7662.                               };
  7663.                             })(),
  7664.                             lineno: 150
  7665.                           })));
  7666.                           __iced_deferrals._fulfill();
  7667.                         })(function() {
  7668.                           return cb(null, pt.to_buffer());
  7669.                         });
  7670.                       });
  7671.                     });
  7672.                   });
  7673.                 });
  7674.               });
  7675.             });
  7676.           });
  7677.         });
  7678.       });
  7679.     };
  7680.  
  7681.     return Decryptor;
  7682.  
  7683.   })(Base);
  7684.  
  7685.   decrypt = function(_arg, cb) {
  7686.     var data, dec, err, key, progress_hook, pt, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  7687.       _this = this;
  7688.     __iced_k = __iced_k_noop;
  7689.     ___iced_passed_deferral = iced.findDeferral(arguments);
  7690.     key = _arg.key, data = _arg.data, progress_hook = _arg.progress_hook;
  7691.     dec = new Decryptor({
  7692.       key: key
  7693.     });
  7694.     (function(__iced_k) {
  7695.       __iced_deferrals = new iced.Deferrals(__iced_k, {
  7696.         parent: ___iced_passed_deferral,
  7697.         filename: "src/dec.iced",
  7698.         funcname: "decrypt"
  7699.       });
  7700.       dec.run({
  7701.         data: data,
  7702.         progress_hook: progress_hook
  7703.       }, __iced_deferrals.defer({
  7704.         assign_fn: (function() {
  7705.           return function() {
  7706.             err = arguments[0];
  7707.             return pt = arguments[1];
  7708.           };
  7709.         })(),
  7710.         lineno: 168
  7711.       }));
  7712.       __iced_deferrals._fulfill();
  7713.     })(function() {
  7714.       dec.scrub();
  7715.       return cb(err, pt);
  7716.     });
  7717.   };
  7718.  
  7719.   exports.Decryptor = Decryptor;
  7720.  
  7721.   exports.decrypt = decrypt;
  7722.  
  7723. }).call(this);
  7724.  
  7725. },{"./aes":17,"./combine":19,"./ctr":20,"./enc":23,"./salsa20":29,"./sha512":35,"./twofish":36,"./wordarray":38,"iced-coffee-script/lib/coffee-script/iced":9,"iced-error":10}],22:[function(require,module,exports){
  7726. (function (Buffer){
  7727. // Generated by IcedCoffeeScript 1.6.3-g
  7728. (function() {
  7729.   var ADRBG, DRBG, Lock, WordArray, XOR, hmac, iced, sha3, sha512, __iced_k, __iced_k_noop;
  7730.  
  7731.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  7732.   __iced_k = __iced_k_noop = function() {};
  7733.  
  7734.   hmac = require('./hmac');
  7735.  
  7736.   XOR = require('./combine').XOR;
  7737.  
  7738.   sha512 = require('./sha512');
  7739.  
  7740.   sha3 = require('./sha3');
  7741.  
  7742.   WordArray = require('./wordarray').WordArray;
  7743.  
  7744.   Lock = require('./lock').Lock;
  7745.  
  7746.   DRBG = (function() {
  7747.     function DRBG(entropy, personalization_string, hmac_func) {
  7748.       this.hmac = hmac_func || hmac.sign;
  7749.       this.security_strength = 256;
  7750.       entropy = this.check_entropy(entropy);
  7751.       personalization_string || (personalization_string = new WordArray([]));
  7752.       this._instantiate(entropy, personalization_string);
  7753.     }
  7754.  
  7755.     DRBG.prototype.check_entropy = function(entropy, reseed) {
  7756.       if (reseed == null) {
  7757.         reseed = false;
  7758.       }
  7759.       if ((entropy.sigBytes * 8 * 2) < ((reseed ? 2 : 3) * this.security_strength)) {
  7760.         throw new Error("entropy must be at least " + (1.5 * this.security_strength) + " bits.");
  7761.       }
  7762.       return entropy;
  7763.     };
  7764.  
  7765.     DRBG.prototype._hmac = function(key, input) {
  7766.       return this.hmac({
  7767.         key: key,
  7768.         input: input
  7769.       });
  7770.     };
  7771.  
  7772.     DRBG.prototype._update = function(provided_data) {
  7773.       var V, V_in;
  7774.       V = new WordArray([0], 1);
  7775.       if (provided_data != null) {
  7776.         V = V.concat(provided_data);
  7777.       }
  7778.       V_in = this.V.clone().concat(V);
  7779.       this.K = this._hmac(this.K, V_in);
  7780.       V_in.scrub();
  7781.       V.scrub();
  7782.       this.V = this._hmac(this.K, this.V);
  7783.       if (provided_data != null) {
  7784.         V_in = this.V.clone().concat(new WordArray([1 << 24], 1)).concat(provided_data);
  7785.         this.K = this._hmac(this.K, V_in);
  7786.         V_in.scrub();
  7787.         this.V = this._hmac(this.K, this.V);
  7788.       }
  7789.       return provided_data != null ? provided_data.scrub() : void 0;
  7790.     };
  7791.  
  7792.     DRBG.prototype._instantiate = function(entropy, personalization_string) {
  7793.       var i, n, seed_material;
  7794.       seed_material = entropy.concat(personalization_string);
  7795.       n = 64;
  7796.       this.K = WordArray.from_buffer(new Buffer((function() {
  7797.         var _i, _results;
  7798.         _results = [];
  7799.         for (i = _i = 0; 0 <= n ? _i < n : _i > n; i = 0 <= n ? ++_i : --_i) {
  7800.           _results.push(0);
  7801.         }
  7802.         return _results;
  7803.       })()));
  7804.       this.V = WordArray.from_buffer(new Buffer((function() {
  7805.         var _i, _results;
  7806.         _results = [];
  7807.         for (i = _i = 0; 0 <= n ? _i < n : _i > n; i = 0 <= n ? ++_i : --_i) {
  7808.           _results.push(1);
  7809.         }
  7810.         return _results;
  7811.       })()));
  7812.       this._update(seed_material);
  7813.       entropy.scrub();
  7814.       return this.reseed_counter = 1;
  7815.     };
  7816.  
  7817.     DRBG.prototype.reseed = function(entropy) {
  7818.       this._update(this.check_entropy(entropy, true));
  7819.       return this.reseed_counter = 1;
  7820.     };
  7821.  
  7822.     DRBG.prototype.generate = function(num_bytes) {
  7823.       var i, tmp, _ref;
  7824.       if ((num_bytes * 8) > 7500) {
  7825.         throw new Error("generate cannot generate > 7500 bits in 1 call.");
  7826.       }
  7827.       if (this.reseed_counter >= 10000) {
  7828.         throw new Error("Need a reseed!");
  7829.       }
  7830.       tmp = [];
  7831.       i = 0;
  7832.       while ((tmp.length === 0) || (tmp.length * tmp[0].length * 4) < num_bytes) {
  7833.         this.V = this._hmac(this.K, this.V);
  7834.         tmp.push(this.V.words);
  7835.       }
  7836.       this._update();
  7837.       this.reseed_counter += 1;
  7838.       return (new WordArray((_ref = []).concat.apply(_ref, tmp))).truncate(num_bytes);
  7839.     };
  7840.  
  7841.     return DRBG;
  7842.  
  7843.   })();
  7844.  
  7845.   ADRBG = (function() {
  7846.     function ADRBG(gen_seed, hmac) {
  7847.       this.gen_seed = gen_seed;
  7848.       this.hmac = hmac;
  7849.       this.drbg = null;
  7850.       this.lock = new Lock();
  7851.     }
  7852.  
  7853.     ADRBG.prototype.generate = function(n, cb) {
  7854.       var ret, seed, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  7855.         _this = this;
  7856.       __iced_k = __iced_k_noop;
  7857.       ___iced_passed_deferral = iced.findDeferral(arguments);
  7858.       (function(__iced_k) {
  7859.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  7860.           parent: ___iced_passed_deferral,
  7861.           filename: "src/drbg.iced",
  7862.           funcname: "ADRBG.generate"
  7863.         });
  7864.         _this.lock.acquire(__iced_deferrals.defer({
  7865.           lineno: 148
  7866.         }));
  7867.         __iced_deferrals._fulfill();
  7868.       })(function() {
  7869.         (function(__iced_k) {
  7870.           if (_this.drbg == null) {
  7871.             (function(__iced_k) {
  7872.               __iced_deferrals = new iced.Deferrals(__iced_k, {
  7873.                 parent: ___iced_passed_deferral,
  7874.                 filename: "src/drbg.iced",
  7875.                 funcname: "ADRBG.generate"
  7876.               });
  7877.               _this.gen_seed(256, __iced_deferrals.defer({
  7878.                 assign_fn: (function() {
  7879.                   return function() {
  7880.                     return seed = arguments[0];
  7881.                   };
  7882.                 })(),
  7883.                 lineno: 150
  7884.               }));
  7885.               __iced_deferrals._fulfill();
  7886.             })(function() {
  7887.               return __iced_k(_this.drbg = new DRBG(seed, null, _this.hmac));
  7888.             });
  7889.           } else {
  7890.             return __iced_k();
  7891.           }
  7892.         })(function() {
  7893.           (function(__iced_k) {
  7894.             if (_this.drbg.reseed_counter > 100) {
  7895.               (function(__iced_k) {
  7896.                 __iced_deferrals = new iced.Deferrals(__iced_k, {
  7897.                   parent: ___iced_passed_deferral,
  7898.                   filename: "src/drbg.iced",
  7899.                   funcname: "ADRBG.generate"
  7900.                 });
  7901.                 _this.gen_seed(256, __iced_deferrals.defer({
  7902.                   assign_fn: (function() {
  7903.                     return function() {
  7904.                       return seed = arguments[0];
  7905.                     };
  7906.                   })(),
  7907.                   lineno: 153
  7908.                 }));
  7909.                 __iced_deferrals._fulfill();
  7910.               })(function() {
  7911.                 return __iced_k(_this.drbg.reseed(seed));
  7912.               });
  7913.             } else {
  7914.               return __iced_k();
  7915.             }
  7916.           })(function() {
  7917.             ret = _this.drbg.generate(n);
  7918.             _this.lock.release();
  7919.             return cb(ret);
  7920.           });
  7921.         });
  7922.       });
  7923.     };
  7924.  
  7925.     return ADRBG;
  7926.  
  7927.   })();
  7928.  
  7929.   exports.DRBG = DRBG;
  7930.  
  7931.   exports.ADRBG = ADRBG;
  7932.  
  7933. }).call(this);
  7934.  
  7935. }).call(this,require("buffer").Buffer)
  7936. },{"./combine":19,"./hmac":24,"./lock":25,"./sha3":34,"./sha512":35,"./wordarray":38,"buffer":1,"iced-coffee-script/lib/coffee-script/iced":9}],23:[function(require,module,exports){
  7937. // Generated by IcedCoffeeScript 1.6.3-g
  7938. (function() {
  7939.   var AES, Base, Concat, Encryptor, HMAC_SHA256, PBKDF2, SHA512, Scrypt, TwoFish, V, WordArray, XOR, ctr, encrypt, iced, make_esc, prng, salsa20, util, __iced_k, __iced_k_noop, _ref,
  7940.     __hasProp = {}.hasOwnProperty,
  7941.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  7942.  
  7943.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  7944.   __iced_k = __iced_k_noop = function() {};
  7945.  
  7946.   WordArray = require('./wordarray').WordArray;
  7947.  
  7948.   salsa20 = require('./salsa20');
  7949.  
  7950.   AES = require('./aes').AES;
  7951.  
  7952.   TwoFish = require('./twofish').TwoFish;
  7953.  
  7954.   ctr = require('./ctr');
  7955.  
  7956.   _ref = require('./combine'), XOR = _ref.XOR, Concat = _ref.Concat;
  7957.  
  7958.   SHA512 = require('./sha512').SHA512;
  7959.  
  7960.   PBKDF2 = require('./pbkdf2').PBKDF2;
  7961.  
  7962.   Scrypt = require('./scrypt').Scrypt;
  7963.  
  7964.   util = require('./util');
  7965.  
  7966.   prng = require('./prng');
  7967.  
  7968.   make_esc = require('iced-error').make_esc;
  7969.  
  7970.   HMAC_SHA256 = require('./hmac').HMAC_SHA256;
  7971.  
  7972.   V = {
  7973.     "1": {
  7974.       header: [0x1c94d7de, 1],
  7975.       salt_size: 8,
  7976.       xsalsa20_rev: true,
  7977.       kdf: {
  7978.         klass: PBKDF2,
  7979.         opts: {
  7980.           c: 1024,
  7981.           klass: XOR
  7982.         }
  7983.       },
  7984.       hmac_key_size: 768 / 8
  7985.     },
  7986.     "2": {
  7987.       header: [0x1c94d7de, 2],
  7988.       salt_size: 16,
  7989.       xsalsa20_rev: true,
  7990.       kdf: {
  7991.         klass: Scrypt,
  7992.         opts: {
  7993.           c: 64,
  7994.           klass: XOR,
  7995.           N: 12,
  7996.           r: 8,
  7997.           p: 1
  7998.         }
  7999.       },
  8000.       hmac_key_size: 768 / 8
  8001.     },
  8002.     "3": {
  8003.       header: [0x1c94d7de, 3],
  8004.       salt_size: 16,
  8005.       xsalsa20_rev: false,
  8006.       kdf: {
  8007.         klass: Scrypt,
  8008.         opts: {
  8009.           c: 1,
  8010.           klass: HMAC_SHA256,
  8011.           N: 16,
  8012.           r: 8,
  8013.           p: 1
  8014.         }
  8015.       },
  8016.       hmac_key_size: 768 / 8
  8017.     }
  8018.   };
  8019.  
  8020.   Base = (function() {
  8021.     function Base(_arg) {
  8022.       var key, version;
  8023.       key = _arg.key, version = _arg.version;
  8024.       this.version = V[version != null ? version : 1];
  8025.       if (this.version == null) {
  8026.         throw new Error("unknown version: " + version);
  8027.       }
  8028.       this.set_key(key);
  8029.       this.derived_keys = {};
  8030.     }
  8031.  
  8032.     Base.prototype.kdf = function(_arg, cb) {
  8033.       var args, dkLen, end, extra_keymaterial, i, k, key, keys, len, lens, order, progress_hook, raw, salt, salt_hex, v, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8034.         _this = this;
  8035.       __iced_k = __iced_k_noop;
  8036.       ___iced_passed_deferral = iced.findDeferral(arguments);
  8037.       salt = _arg.salt, extra_keymaterial = _arg.extra_keymaterial, progress_hook = _arg.progress_hook;
  8038.       (function(__iced_k) {
  8039.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  8040.           parent: ___iced_passed_deferral,
  8041.           filename: "src/enc.iced",
  8042.           funcname: "Base.kdf"
  8043.         });
  8044.         _this._check_scrubbed(_this.key, "in KDF", cb, __iced_deferrals.defer({
  8045.           lineno: 90
  8046.         }));
  8047.         __iced_deferrals._fulfill();
  8048.       })(function() {
  8049.         salt_hex = salt.to_hex();
  8050.         key = _this.key.clone();
  8051.         (function(__iced_k) {
  8052.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  8053.             parent: ___iced_passed_deferral,
  8054.             filename: "src/enc.iced",
  8055.             funcname: "Base.kdf"
  8056.           });
  8057.           _this._check_scrubbed(key, "KDF", cb, __iced_deferrals.defer({
  8058.             lineno: 98
  8059.           }));
  8060.           __iced_deferrals._fulfill();
  8061.         })(function() {
  8062.           (function(__iced_k) {
  8063.             if ((keys = _this.derived_keys[salt_hex]) == null) {
  8064.               _this._kdf = new _this.version.kdf.klass(_this.version.kdf.opts);
  8065.               lens = {
  8066.                 hmac: _this.version.hmac_key_size,
  8067.                 aes: AES.keySize,
  8068.                 twofish: TwoFish.keySize,
  8069.                 salsa20: salsa20.Salsa20.keySize
  8070.               };
  8071.               order = ['hmac', 'aes', 'twofish', 'salsa20'];
  8072.               dkLen = extra_keymaterial || 0;
  8073.               for (k in lens) {
  8074.                 v = lens[k];
  8075.                 dkLen += v;
  8076.               }
  8077.               args = {
  8078.                 dkLen: dkLen,
  8079.                 key: key,
  8080.                 progress_hook: progress_hook,
  8081.                 salt: salt
  8082.               };
  8083.               (function(__iced_k) {
  8084.                 __iced_deferrals = new iced.Deferrals(__iced_k, {
  8085.                   parent: ___iced_passed_deferral,
  8086.                   filename: "src/enc.iced",
  8087.                   funcname: "Base.kdf"
  8088.                 });
  8089.                 _this._kdf.run(args, __iced_deferrals.defer({
  8090.                   assign_fn: (function() {
  8091.                     return function() {
  8092.                       return raw = arguments[0];
  8093.                     };
  8094.                   })(),
  8095.                   lineno: 117
  8096.                 }));
  8097.                 __iced_deferrals._fulfill();
  8098.               })(function() {
  8099.                 var _i, _len;
  8100.                 keys = {};
  8101.                 i = 0;
  8102.                 for (_i = 0, _len = order.length; _i < _len; _i++) {
  8103.                   k = order[_i];
  8104.                   v = lens[k];
  8105.                   len = v / 4;
  8106.                   end = i + len;
  8107.                   keys[k] = new WordArray(raw.words.slice(i, end));
  8108.                   i = end;
  8109.                 }
  8110.                 keys.extra = (new WordArray(raw.words.slice(end))).to_buffer();
  8111.                 return __iced_k(_this.derived_keys[salt_hex] = keys);
  8112.               });
  8113.             } else {
  8114.               return __iced_k();
  8115.             }
  8116.           })(function() {
  8117.             return cb(null, keys);
  8118.           });
  8119.         });
  8120.       });
  8121.     };
  8122.  
  8123.     Base.prototype.set_key = function(key) {
  8124.       var wakey;
  8125.       if (key != null) {
  8126.         wakey = WordArray.from_buffer(key);
  8127.         if (!this.key || !this.key.equal(wakey)) {
  8128.           this.scrub();
  8129.           return this.key = wakey;
  8130.         }
  8131.       } else {
  8132.         return this.scrub();
  8133.       }
  8134.     };
  8135.  
  8136.     Base.prototype._check_scrubbed = function(key, where, ecb, okcb) {
  8137.       if ((key != null) && !key.is_scrubbed()) {
  8138.         return okcb();
  8139.       } else {
  8140.         return ecb(new Error("" + where + ": Failed due to scrubbed key!"), null);
  8141.       }
  8142.     };
  8143.  
  8144.     Base.prototype.sign = function(_arg, cb) {
  8145.       var input, key, out, progress_hook, salt, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8146.         _this = this;
  8147.       __iced_k = __iced_k_noop;
  8148.       ___iced_passed_deferral = iced.findDeferral(arguments);
  8149.       input = _arg.input, key = _arg.key, salt = _arg.salt, progress_hook = _arg.progress_hook;
  8150.       (function(__iced_k) {
  8151.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  8152.           parent: ___iced_passed_deferral,
  8153.           filename: "src/enc.iced",
  8154.           funcname: "Base.sign"
  8155.         });
  8156.         _this._check_scrubbed(key, "HMAC", cb, __iced_deferrals.defer({
  8157.           lineno: 175
  8158.         }));
  8159.         __iced_deferrals._fulfill();
  8160.       })(function() {
  8161.         input = (new WordArray(_this.version.header)).concat(salt).concat(input);
  8162.         (function(__iced_k) {
  8163.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  8164.             parent: ___iced_passed_deferral,
  8165.             filename: "src/enc.iced",
  8166.             funcname: "Base.sign"
  8167.           });
  8168.           Concat.bulk_sign({
  8169.             key: key,
  8170.             input: input,
  8171.             progress_hook: progress_hook
  8172.           }, __iced_deferrals.defer({
  8173.             assign_fn: (function() {
  8174.               return function() {
  8175.                 return out = arguments[0];
  8176.               };
  8177.             })(),
  8178.             lineno: 177
  8179.           }));
  8180.           __iced_deferrals._fulfill();
  8181.         })(function() {
  8182.           input.scrub();
  8183.           return cb(null, out);
  8184.         });
  8185.       });
  8186.     };
  8187.  
  8188.     Base.prototype.run_salsa20 = function(_arg, cb) {
  8189.       var args, ct, input, iv, key, output_iv, progress_hook, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8190.         _this = this;
  8191.       __iced_k = __iced_k_noop;
  8192.       ___iced_passed_deferral = iced.findDeferral(arguments);
  8193.       input = _arg.input, key = _arg.key, iv = _arg.iv, output_iv = _arg.output_iv, progress_hook = _arg.progress_hook;
  8194.       (function(__iced_k) {
  8195.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  8196.           parent: ___iced_passed_deferral,
  8197.           filename: "src/enc.iced",
  8198.           funcname: "Base.run_salsa20"
  8199.         });
  8200.         _this._check_scrubbed(key, "Salsa20", cb, __iced_deferrals.defer({
  8201.           lineno: 193
  8202.         }));
  8203.         __iced_deferrals._fulfill();
  8204.       })(function() {
  8205.         args = {
  8206.           input: input,
  8207.           progress_hook: progress_hook,
  8208.           key: key,
  8209.           iv: iv
  8210.         };
  8211.         if (_this.version.xsalsa20_rev) {
  8212.           args.key = key.clone().endian_reverse();
  8213.           args.iv = iv.clone().endian_reverse();
  8214.         }
  8215.         (function(__iced_k) {
  8216.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  8217.             parent: ___iced_passed_deferral,
  8218.             filename: "src/enc.iced",
  8219.             funcname: "Base.run_salsa20"
  8220.           });
  8221.           salsa20.bulk_encrypt(args, __iced_deferrals.defer({
  8222.             assign_fn: (function() {
  8223.               return function() {
  8224.                 return ct = arguments[0];
  8225.               };
  8226.             })(),
  8227.             lineno: 205
  8228.           }));
  8229.           __iced_deferrals._fulfill();
  8230.         })(function() {
  8231.           if (output_iv) {
  8232.             ct = iv.clone().concat(ct);
  8233.           }
  8234.           if (_this.version.xsalsa20_rev) {
  8235.             args.key.scrub();
  8236.             args.iv.scrub();
  8237.           }
  8238.           return cb(null, ct);
  8239.         });
  8240.       });
  8241.     };
  8242.  
  8243.     Base.prototype.run_twofish = function(_arg, cb) {
  8244.       var block_cipher, ct, input, iv, key, progress_hook, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8245.         _this = this;
  8246.       __iced_k = __iced_k_noop;
  8247.       ___iced_passed_deferral = iced.findDeferral(arguments);
  8248.       input = _arg.input, key = _arg.key, iv = _arg.iv, progress_hook = _arg.progress_hook;
  8249.       (function(__iced_k) {
  8250.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  8251.           parent: ___iced_passed_deferral,
  8252.           filename: "src/enc.iced",
  8253.           funcname: "Base.run_twofish"
  8254.         });
  8255.         _this._check_scrubbed(key, "TwoFish", cb, __iced_deferrals.defer({
  8256.           lineno: 228
  8257.         }));
  8258.         __iced_deferrals._fulfill();
  8259.       })(function() {
  8260.         block_cipher = new TwoFish(key);
  8261.         (function(__iced_k) {
  8262.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  8263.             parent: ___iced_passed_deferral,
  8264.             filename: "src/enc.iced",
  8265.             funcname: "Base.run_twofish"
  8266.           });
  8267.           ctr.bulk_encrypt({
  8268.             block_cipher: block_cipher,
  8269.             iv: iv,
  8270.             input: input,
  8271.             progress_hook: progress_hook,
  8272.             what: "twofish"
  8273.           }, __iced_deferrals.defer({
  8274.             assign_fn: (function() {
  8275.               return function() {
  8276.                 return ct = arguments[0];
  8277.               };
  8278.             })(),
  8279.             lineno: 230
  8280.           }));
  8281.           __iced_deferrals._fulfill();
  8282.         })(function() {
  8283.           block_cipher.scrub();
  8284.           return cb(null, iv.clone().concat(ct));
  8285.         });
  8286.       });
  8287.     };
  8288.  
  8289.     Base.prototype.run_aes = function(_arg, cb) {
  8290.       var block_cipher, ct, input, iv, key, progress_hook, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8291.         _this = this;
  8292.       __iced_k = __iced_k_noop;
  8293.       ___iced_passed_deferral = iced.findDeferral(arguments);
  8294.       input = _arg.input, key = _arg.key, iv = _arg.iv, progress_hook = _arg.progress_hook;
  8295.       (function(__iced_k) {
  8296.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  8297.           parent: ___iced_passed_deferral,
  8298.           filename: "src/enc.iced",
  8299.           funcname: "Base.run_aes"
  8300.         });
  8301.         _this._check_scrubbed(key, "AES", cb, __iced_deferrals.defer({
  8302.           lineno: 245
  8303.         }));
  8304.         __iced_deferrals._fulfill();
  8305.       })(function() {
  8306.         block_cipher = new AES(key);
  8307.         (function(__iced_k) {
  8308.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  8309.             parent: ___iced_passed_deferral,
  8310.             filename: "src/enc.iced",
  8311.             funcname: "Base.run_aes"
  8312.           });
  8313.           ctr.bulk_encrypt({
  8314.             block_cipher: block_cipher,
  8315.             iv: iv,
  8316.             input: input,
  8317.             progress_hook: progress_hook,
  8318.             what: "aes"
  8319.           }, __iced_deferrals.defer({
  8320.             assign_fn: (function() {
  8321.               return function() {
  8322.                 return ct = arguments[0];
  8323.               };
  8324.             })(),
  8325.             lineno: 247
  8326.           }));
  8327.           __iced_deferrals._fulfill();
  8328.         })(function() {
  8329.           block_cipher.scrub();
  8330.           return cb(null, iv.clone().concat(ct));
  8331.         });
  8332.       });
  8333.     };
  8334.  
  8335.     Base.prototype.scrub = function() {
  8336.       var key, key_ring, salt, _i, _len, _ref1;
  8337.       if (this.key != null) {
  8338.         this.key.scrub();
  8339.       }
  8340.       if (this.derived_keys != null) {
  8341.         _ref1 = this.derived_keys;
  8342.         for (salt in _ref1) {
  8343.           key_ring = _ref1[salt];
  8344.           for (_i = 0, _len = key_ring.length; _i < _len; _i++) {
  8345.             key = key_ring[_i];
  8346.             key.scrub();
  8347.           }
  8348.         }
  8349.       }
  8350.       this.derived_keys = {};
  8351.       if (this.salt != null) {
  8352.         this.salt.scrub();
  8353.       }
  8354.       this.salt = null;
  8355.       return this.key = null;
  8356.     };
  8357.  
  8358.     return Base;
  8359.  
  8360.   })();
  8361.  
  8362.   Encryptor = (function(_super) {
  8363.     __extends(Encryptor, _super);
  8364.  
  8365.     function Encryptor(_arg) {
  8366.       var key, rng, version;
  8367.       key = _arg.key, rng = _arg.rng, version = _arg.version;
  8368.       Encryptor.__super__.constructor.call(this, {
  8369.         key: key,
  8370.         version: version
  8371.       });
  8372.       this.rng = rng || prng.generate;
  8373.     }
  8374.  
  8375.     Encryptor.prototype.pick_random_ivs = function(_arg, cb) {
  8376.       var iv_lens, ivs, k, progress_hook, v, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8377.         _this = this;
  8378.       __iced_k = __iced_k_noop;
  8379.       ___iced_passed_deferral = iced.findDeferral(arguments);
  8380.       progress_hook = _arg.progress_hook;
  8381.       iv_lens = {
  8382.         aes: AES.ivSize,
  8383.         twofish: TwoFish.ivSize,
  8384.         salsa20: salsa20.Salsa20.ivSize
  8385.       };
  8386.       ivs = {};
  8387.       (function(__iced_k) {
  8388.         var _i, _k, _keys, _ref1, _results, _while;
  8389.         _ref1 = iv_lens;
  8390.         _keys = (function() {
  8391.           var _results1;
  8392.           _results1 = [];
  8393.           for (_k in _ref1) {
  8394.             _results1.push(_k);
  8395.           }
  8396.           return _results1;
  8397.         })();
  8398.         _i = 0;
  8399.         _results = [];
  8400.         _while = function(__iced_k) {
  8401.           var _break, _continue, _next;
  8402.           _break = function() {
  8403.             return __iced_k(_results);
  8404.           };
  8405.           _continue = function() {
  8406.             return iced.trampoline(function() {
  8407.               ++_i;
  8408.               return _while(__iced_k);
  8409.             });
  8410.           };
  8411.           _next = function(__iced_next_arg) {
  8412.             _results.push(__iced_next_arg);
  8413.             return _continue();
  8414.           };
  8415.           if (!(_i < _keys.length)) {
  8416.             return _break();
  8417.           } else {
  8418.             k = _keys[_i];
  8419.             v = _ref1[k];
  8420.             (function(__iced_k) {
  8421.               __iced_deferrals = new iced.Deferrals(__iced_k, {
  8422.                 parent: ___iced_passed_deferral,
  8423.                 filename: "src/enc.iced",
  8424.                 funcname: "Encryptor.pick_random_ivs"
  8425.               });
  8426.               _this.rng(v, __iced_deferrals.defer({
  8427.                 assign_fn: (function(__slot_1, __slot_2) {
  8428.                   return function() {
  8429.                     return __slot_1[__slot_2] = arguments[0];
  8430.                   };
  8431.                 })(ivs, k),
  8432.                 lineno: 349
  8433.               }));
  8434.               __iced_deferrals._fulfill();
  8435.             })(_next);
  8436.           }
  8437.         };
  8438.         _while(__iced_k);
  8439.       })(function() {
  8440.         return cb(ivs);
  8441.       });
  8442.     };
  8443.  
  8444.     Encryptor.prototype.resalt = function(_arg, cb) {
  8445.       var err, extra_keymaterial, progress_hook, salt, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8446.         _this = this;
  8447.       __iced_k = __iced_k_noop;
  8448.       ___iced_passed_deferral = iced.findDeferral(arguments);
  8449.       salt = _arg.salt, extra_keymaterial = _arg.extra_keymaterial, progress_hook = _arg.progress_hook;
  8450.       err = null;
  8451.       (function(__iced_k) {
  8452.         if (salt == null) {
  8453.           (function(__iced_k) {
  8454.             __iced_deferrals = new iced.Deferrals(__iced_k, {
  8455.               parent: ___iced_passed_deferral,
  8456.               filename: "src/enc.iced",
  8457.               funcname: "Encryptor.resalt"
  8458.             });
  8459.             _this.rng(_this.version.salt_size, __iced_deferrals.defer({
  8460.               assign_fn: (function(__slot_1) {
  8461.                 return function() {
  8462.                   return __slot_1.salt = arguments[0];
  8463.                 };
  8464.               })(_this),
  8465.               lineno: 365
  8466.             }));
  8467.             __iced_deferrals._fulfill();
  8468.           })(__iced_k);
  8469.         } else {
  8470.           return __iced_k(salt.length !== _this.version.salt_size ? err = new Error("Need a salt of exactly " + _this.version.salt_size + " bytes (got " + salt.length + ")") : _this.salt = WordArray.alloc(salt));
  8471.         }
  8472.       })(function() {
  8473.         (function(__iced_k) {
  8474.           if (err == null) {
  8475.             (function(__iced_k) {
  8476.               __iced_deferrals = new iced.Deferrals(__iced_k, {
  8477.                 parent: ___iced_passed_deferral,
  8478.                 filename: "src/enc.iced",
  8479.                 funcname: "Encryptor.resalt"
  8480.               });
  8481.               _this.kdf({
  8482.                 extra_keymaterial: extra_keymaterial,
  8483.                 progress_hook: progress_hook,
  8484.                 salt: _this.salt
  8485.               }, __iced_deferrals.defer({
  8486.                 assign_fn: (function(__slot_1) {
  8487.                   return function() {
  8488.                     err = arguments[0];
  8489.                     return __slot_1.keys = arguments[1];
  8490.                   };
  8491.                 })(_this),
  8492.                 lineno: 371
  8493.               }));
  8494.               __iced_deferrals._fulfill();
  8495.             })(__iced_k);
  8496.           } else {
  8497.             return __iced_k();
  8498.           }
  8499.         })(function() {
  8500.           return cb(err, _this.keys);
  8501.         });
  8502.       });
  8503.     };
  8504.  
  8505.     Encryptor.prototype.run = function(_arg, cb) {
  8506.       var ct1, ct2, ct3, data, esc, extra_keymaterial, ivs, progress_hook, pt, ret, salt, sig, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8507.         _this = this;
  8508.       __iced_k = __iced_k_noop;
  8509.       ___iced_passed_deferral = iced.findDeferral(arguments);
  8510.       data = _arg.data, salt = _arg.salt, extra_keymaterial = _arg.extra_keymaterial, progress_hook = _arg.progress_hook;
  8511.       esc = make_esc(cb, "Encryptor::run");
  8512.       (function(__iced_k) {
  8513.         if ((salt != null) || (_this.salt == null)) {
  8514.           (function(__iced_k) {
  8515.             __iced_deferrals = new iced.Deferrals(__iced_k, {
  8516.               parent: ___iced_passed_deferral,
  8517.               filename: "src/enc.iced",
  8518.               funcname: "Encryptor.run"
  8519.             });
  8520.             _this.resalt({
  8521.               salt: salt,
  8522.               extra_keymaterial: extra_keymaterial,
  8523.               progress_hook: progress_hook
  8524.             }, esc(__iced_deferrals.defer({
  8525.               lineno: 402
  8526.             })));
  8527.             __iced_deferrals._fulfill();
  8528.           })(__iced_k);
  8529.         } else {
  8530.           return __iced_k();
  8531.         }
  8532.       })(function() {
  8533.         (function(__iced_k) {
  8534.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  8535.             parent: ___iced_passed_deferral,
  8536.             filename: "src/enc.iced",
  8537.             funcname: "Encryptor.run"
  8538.           });
  8539.           _this.pick_random_ivs({
  8540.             progress_hook: progress_hook
  8541.           }, __iced_deferrals.defer({
  8542.             assign_fn: (function() {
  8543.               return function() {
  8544.                 return ivs = arguments[0];
  8545.               };
  8546.             })(),
  8547.             lineno: 403
  8548.           }));
  8549.           __iced_deferrals._fulfill();
  8550.         })(function() {
  8551.           pt = WordArray.from_buffer(data);
  8552.           (function(__iced_k) {
  8553.             __iced_deferrals = new iced.Deferrals(__iced_k, {
  8554.               parent: ___iced_passed_deferral,
  8555.               filename: "src/enc.iced",
  8556.               funcname: "Encryptor.run"
  8557.             });
  8558.             _this.run_salsa20({
  8559.               input: pt,
  8560.               key: _this.keys.salsa20,
  8561.               progress_hook: progress_hook,
  8562.               iv: ivs.salsa20,
  8563.               output_iv: true
  8564.             }, esc(__iced_deferrals.defer({
  8565.               assign_fn: (function() {
  8566.                 return function() {
  8567.                   return ct1 = arguments[0];
  8568.                 };
  8569.               })(),
  8570.               lineno: 405
  8571.             })));
  8572.             __iced_deferrals._fulfill();
  8573.           })(function() {
  8574.             (function(__iced_k) {
  8575.               __iced_deferrals = new iced.Deferrals(__iced_k, {
  8576.                 parent: ___iced_passed_deferral,
  8577.                 filename: "src/enc.iced",
  8578.                 funcname: "Encryptor.run"
  8579.               });
  8580.               _this.run_twofish({
  8581.                 input: ct1,
  8582.                 key: _this.keys.twofish,
  8583.                 progress_hook: progress_hook,
  8584.                 iv: ivs.twofish
  8585.               }, esc(__iced_deferrals.defer({
  8586.                 assign_fn: (function() {
  8587.                   return function() {
  8588.                     return ct2 = arguments[0];
  8589.                   };
  8590.                 })(),
  8591.                 lineno: 406
  8592.               })));
  8593.               __iced_deferrals._fulfill();
  8594.             })(function() {
  8595.               (function(__iced_k) {
  8596.                 __iced_deferrals = new iced.Deferrals(__iced_k, {
  8597.                   parent: ___iced_passed_deferral,
  8598.                   filename: "src/enc.iced",
  8599.                   funcname: "Encryptor.run"
  8600.                 });
  8601.                 _this.run_aes({
  8602.                   input: ct2,
  8603.                   key: _this.keys.aes,
  8604.                   progress_hook: progress_hook,
  8605.                   iv: ivs.aes
  8606.                 }, esc(__iced_deferrals.defer({
  8607.                   assign_fn: (function() {
  8608.                     return function() {
  8609.                       return ct3 = arguments[0];
  8610.                     };
  8611.                   })(),
  8612.                   lineno: 407
  8613.                 })));
  8614.                 __iced_deferrals._fulfill();
  8615.               })(function() {
  8616.                 (function(__iced_k) {
  8617.                   __iced_deferrals = new iced.Deferrals(__iced_k, {
  8618.                     parent: ___iced_passed_deferral,
  8619.                     filename: "src/enc.iced",
  8620.                     funcname: "Encryptor.run"
  8621.                   });
  8622.                   _this.sign({
  8623.                     input: ct3,
  8624.                     key: _this.keys.hmac,
  8625.                     progress_hook: progress_hook,
  8626.                     salt: _this.salt
  8627.                   }, esc(__iced_deferrals.defer({
  8628.                     assign_fn: (function() {
  8629.                       return function() {
  8630.                         return sig = arguments[0];
  8631.                       };
  8632.                     })(),
  8633.                     lineno: 408
  8634.                   })));
  8635.                   __iced_deferrals._fulfill();
  8636.                 })(function() {
  8637.                   ret = (new WordArray(_this.version.header)).concat(_this.salt).concat(sig).concat(ct3).to_buffer();
  8638.                   util.scrub_buffer(data);
  8639.                   return cb(null, ret);
  8640.                 });
  8641.               });
  8642.             });
  8643.           });
  8644.         });
  8645.       });
  8646.     };
  8647.  
  8648.     return Encryptor;
  8649.  
  8650.   })(Base);
  8651.  
  8652.   encrypt = function(_arg, cb) {
  8653.     var data, enc, err, key, progress_hook, ret, rng, version, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8654.       _this = this;
  8655.     __iced_k = __iced_k_noop;
  8656.     ___iced_passed_deferral = iced.findDeferral(arguments);
  8657.     key = _arg.key, data = _arg.data, rng = _arg.rng, progress_hook = _arg.progress_hook, version = _arg.version;
  8658.     enc = new Encryptor({
  8659.       key: key,
  8660.       rng: rng,
  8661.       version: version
  8662.     });
  8663.     (function(__iced_k) {
  8664.       __iced_deferrals = new iced.Deferrals(__iced_k, {
  8665.         parent: ___iced_passed_deferral,
  8666.         filename: "src/enc.iced",
  8667.         funcname: "encrypt"
  8668.       });
  8669.       enc.run({
  8670.         data: data,
  8671.         progress_hook: progress_hook
  8672.       }, __iced_deferrals.defer({
  8673.         assign_fn: (function() {
  8674.           return function() {
  8675.             err = arguments[0];
  8676.             return ret = arguments[1];
  8677.           };
  8678.         })(),
  8679.         lineno: 436
  8680.       }));
  8681.       __iced_deferrals._fulfill();
  8682.     })(function() {
  8683.       enc.scrub();
  8684.       return cb(err, ret);
  8685.     });
  8686.   };
  8687.  
  8688.   exports.V = V;
  8689.  
  8690.   exports.encrypt = encrypt;
  8691.  
  8692.   exports.Base = Base;
  8693.  
  8694.   exports.Encryptor = Encryptor;
  8695.  
  8696. }).call(this);
  8697.  
  8698. },{"./aes":17,"./combine":19,"./ctr":20,"./hmac":24,"./pbkdf2":27,"./prng":28,"./salsa20":29,"./scrypt":30,"./sha512":35,"./twofish":36,"./util":37,"./wordarray":38,"iced-coffee-script/lib/coffee-script/iced":9,"iced-error":10}],24:[function(require,module,exports){
  8699. // Generated by IcedCoffeeScript 1.6.3-g
  8700. (function() {
  8701.   var HMAC, HMAC_SHA256, SHA256, SHA512, bulk_sign, iced, sign, util, __iced_k, __iced_k_noop,
  8702.     __hasProp = {}.hasOwnProperty,
  8703.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  8704.  
  8705.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  8706.   __iced_k = __iced_k_noop = function() {};
  8707.  
  8708.   SHA512 = require('./sha512').SHA512;
  8709.  
  8710.   SHA256 = require('./sha256').SHA256;
  8711.  
  8712.   util = require('./util');
  8713.  
  8714.   HMAC = (function() {
  8715.     HMAC.outputSize = 512 / 8;
  8716.  
  8717.     HMAC.prototype.outputSize = HMAC.outputSize;
  8718.  
  8719.     function HMAC(key, klass) {
  8720.       var i, _i, _ref;
  8721.       if (klass == null) {
  8722.         klass = SHA512;
  8723.       }
  8724.       this.key = key.clone();
  8725.       this.hasher = new klass();
  8726.       this.hasherBlockSize = this.hasher.blockSize;
  8727.       this.hasherBlockSizeBytes = this.hasherBlockSize * 4;
  8728.       if (this.key.sigBytes > this.hasherBlockSizeBytes) {
  8729.         this.key = this.hasher.finalize(this.key);
  8730.       }
  8731.       this.key.clamp();
  8732.       this._oKey = this.key.clone();
  8733.       this._iKey = this.key.clone();
  8734.       for (i = _i = 0, _ref = this.hasherBlockSize; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
  8735.         this._oKey.words[i] ^= 0x5c5c5c5c;
  8736.         this._iKey.words[i] ^= 0x36363636;
  8737.       }
  8738.       this._oKey.sigBytes = this._iKey.sigBytes = this.hasherBlockSizeBytes;
  8739.       this.reset();
  8740.     }
  8741.  
  8742.     HMAC.prototype.get_output_size = function() {
  8743.       return this.hasher.output_size;
  8744.     };
  8745.  
  8746.     HMAC.prototype.reset = function() {
  8747.       return this.hasher.reset().update(this._iKey);
  8748.     };
  8749.  
  8750.     HMAC.prototype.update = function(wa) {
  8751.       this.hasher.update(wa);
  8752.       return this;
  8753.     };
  8754.  
  8755.     HMAC.prototype.finalize = function(wa) {
  8756.       var innerHash, innerHash2, out;
  8757.       innerHash = this.hasher.finalize(wa);
  8758.       this.hasher.reset();
  8759.       innerHash2 = this._oKey.clone().concat(innerHash);
  8760.       out = this.hasher.finalize(innerHash2);
  8761.       innerHash.scrub();
  8762.       innerHash2.scrub();
  8763.       return out;
  8764.     };
  8765.  
  8766.     HMAC.prototype.scrub = function() {
  8767.       this.key.scrub();
  8768.       this._iKey.scrub();
  8769.       return this._oKey.scrub();
  8770.     };
  8771.  
  8772.     return HMAC;
  8773.  
  8774.   })();
  8775.  
  8776.   sign = function(_arg) {
  8777.     var eng, hash_class, input, key, out;
  8778.     key = _arg.key, input = _arg.input, hash_class = _arg.hash_class;
  8779.     eng = new HMAC(key, hash_class);
  8780.     out = eng.finalize(input.clamp());
  8781.     eng.scrub();
  8782.     return out;
  8783.   };
  8784.  
  8785.   bulk_sign = function(_arg, cb) {
  8786.     var eng, input, key, klass, progress_hook, res, slice_args, what, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8787.       _this = this;
  8788.     __iced_k = __iced_k_noop;
  8789.     ___iced_passed_deferral = iced.findDeferral(arguments);
  8790.     key = _arg.key, input = _arg.input, progress_hook = _arg.progress_hook, klass = _arg.klass, what = _arg.what;
  8791.     klass || (klass = HMAC);
  8792.     what || (what = "hmac_sha512");
  8793.     eng = new klass(key);
  8794.     input.clamp();
  8795.     slice_args = {
  8796.       update: function(lo, hi) {
  8797.         return eng.update(input.slice(lo, hi));
  8798.       },
  8799.       finalize: function() {
  8800.         return eng.finalize();
  8801.       },
  8802.       default_n: eng.hasherBlockSize * 1000
  8803.     };
  8804.     (function(__iced_k) {
  8805.       __iced_deferrals = new iced.Deferrals(__iced_k, {
  8806.         parent: ___iced_passed_deferral,
  8807.         filename: "src/hmac.iced",
  8808.         funcname: "bulk_sign"
  8809.       });
  8810.       util.bulk(input.sigBytes, slice_args, {
  8811.         what: what,
  8812.         progress_hook: progress_hook,
  8813.         cb: __iced_deferrals.defer({
  8814.           assign_fn: (function() {
  8815.             return function() {
  8816.               return res = arguments[0];
  8817.             };
  8818.           })(),
  8819.           lineno: 137
  8820.         })
  8821.       });
  8822.       __iced_deferrals._fulfill();
  8823.     })(function() {
  8824.       eng.scrub();
  8825.       return cb(res);
  8826.     });
  8827.   };
  8828.  
  8829.   exports.HMAC_SHA256 = HMAC_SHA256 = (function(_super) {
  8830.     __extends(HMAC_SHA256, _super);
  8831.  
  8832.     function HMAC_SHA256(key) {
  8833.       HMAC_SHA256.__super__.constructor.call(this, key, SHA256);
  8834.     }
  8835.  
  8836.     return HMAC_SHA256;
  8837.  
  8838.   })(HMAC);
  8839.  
  8840.   exports.HMAC = HMAC;
  8841.  
  8842.   exports.sign = sign;
  8843.  
  8844.   exports.bulk_sign = bulk_sign;
  8845.  
  8846. }).call(this);
  8847.  
  8848. },{"./sha256":33,"./sha512":35,"./util":37,"iced-coffee-script/lib/coffee-script/iced":9}],25:[function(require,module,exports){
  8849. // Generated by IcedCoffeeScript 1.6.3-g
  8850. (function() {
  8851.   var Lock, NamedLock, Table, iced, __iced_k, __iced_k_noop,
  8852.     __hasProp = {}.hasOwnProperty,
  8853.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  8854.  
  8855.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  8856.   __iced_k = __iced_k_noop = function() {};
  8857.  
  8858.   Lock = (function() {
  8859.     function Lock() {
  8860.       this._open = true;
  8861.       this._waiters = [];
  8862.     }
  8863.  
  8864.     Lock.prototype.acquire = function(cb) {
  8865.       if (this._open) {
  8866.         this._open = false;
  8867.         return cb();
  8868.       } else {
  8869.         return this._waiters.push(cb);
  8870.       }
  8871.     };
  8872.  
  8873.     Lock.prototype.release = function() {
  8874.       var w;
  8875.       if (this._waiters.length) {
  8876.         w = this._waiters.shift();
  8877.         return w();
  8878.       } else {
  8879.         return this._open = true;
  8880.       }
  8881.     };
  8882.  
  8883.     Lock.prototype.open = function() {
  8884.       return this._open;
  8885.     };
  8886.  
  8887.     return Lock;
  8888.  
  8889.   })();
  8890.  
  8891.   NamedLock = (function(_super) {
  8892.     __extends(NamedLock, _super);
  8893.  
  8894.     function NamedLock(tab, name) {
  8895.       this.tab = tab;
  8896.       this.name = name;
  8897.       NamedLock.__super__.constructor.call(this);
  8898.       this.refs = 0;
  8899.     }
  8900.  
  8901.     NamedLock.prototype.incref = function() {
  8902.       return ++this.refs;
  8903.     };
  8904.  
  8905.     NamedLock.prototype.decref = function() {
  8906.       return --this.refs;
  8907.     };
  8908.  
  8909.     NamedLock.prototype.release = function() {
  8910.       NamedLock.__super__.release.call(this);
  8911.       if (this.decref() === 0) {
  8912.         return delete this.tab[this.name];
  8913.       }
  8914.     };
  8915.  
  8916.     return NamedLock;
  8917.  
  8918.   })(Lock);
  8919.  
  8920.   Table = (function() {
  8921.     function Table() {
  8922.       this.locks = {};
  8923.     }
  8924.  
  8925.     Table.prototype.create = function(name) {
  8926.       var l;
  8927.       l = new NamedLock(this, name);
  8928.       return this.locks[name] = l;
  8929.     };
  8930.  
  8931.     Table.prototype.acquire = function(name, cb, wait) {
  8932.       var l, was_open, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  8933.         _this = this;
  8934.       __iced_k = __iced_k_noop;
  8935.       ___iced_passed_deferral = iced.findDeferral(arguments);
  8936.       l = this.locks[name] || this.create(name);
  8937.       was_open = l._open;
  8938.       l.incref();
  8939.       (function(__iced_k) {
  8940.         if (wait || l._open) {
  8941.           (function(__iced_k) {
  8942.             __iced_deferrals = new iced.Deferrals(__iced_k, {
  8943.               parent: ___iced_passed_deferral,
  8944.               filename: "src/lock.iced",
  8945.               funcname: "Table.acquire"
  8946.             });
  8947.             l.acquire(__iced_deferrals.defer({
  8948.               lineno: 68
  8949.             }));
  8950.             __iced_deferrals._fulfill();
  8951.           })(__iced_k);
  8952.         } else {
  8953.           return __iced_k(l = null);
  8954.         }
  8955.       })(function() {
  8956.         return cb(l, was_open);
  8957.       });
  8958.     };
  8959.  
  8960.     Table.prototype.lookup = function(name) {
  8961.       return this.locks[name];
  8962.     };
  8963.  
  8964.     return Table;
  8965.  
  8966.   })();
  8967.  
  8968.   exports.Lock = Lock;
  8969.  
  8970.   exports.Table = Table;
  8971.  
  8972. }).call(this);
  8973.  
  8974. },{"iced-coffee-script/lib/coffee-script/iced":9}],26:[function(require,module,exports){
  8975. (function (Buffer){
  8976. // Generated by IcedCoffeeScript 1.6.3-g
  8977. (function() {
  8978.   var k, v, _ref, _ref1;
  8979.  
  8980.  
  8981.  
  8982.   _ref = require('./enc');
  8983.   for (k in _ref) {
  8984.     v = _ref[k];
  8985.     exports[k] = v;
  8986.   }
  8987.  
  8988.   _ref1 = require('./dec');
  8989.   for (k in _ref1) {
  8990.     v = _ref1[k];
  8991.     exports[k] = v;
  8992.   }
  8993.  
  8994.   exports.prng = require('./prng');
  8995.  
  8996.   exports.Buffer = Buffer;
  8997.  
  8998.   exports.WordArray = require('./wordarray').WordArray;
  8999.  
  9000.   exports.util = require('./util');
  9001.  
  9002.   exports.ciphers = {
  9003.     AES: require('./aes').AES,
  9004.     TwoFish: require('./twofish').TwoFish
  9005.   };
  9006.  
  9007.   exports.hash = {
  9008.     SHA1: require('./sha1').SHA1,
  9009.     SHA224: require('./sha224').SHA224,
  9010.     SHA256: require('./sha256').SHA256,
  9011.     SHA512: require('./sha512').SHA512,
  9012.     SHA3: require('./sha3').SHA3
  9013.   };
  9014.  
  9015.   exports.scrypt = require('./scrypt').scrypt;
  9016.  
  9017.   exports.pbkdf2 = require('./pbkdf2').pbkdf2;
  9018.  
  9019.   exports.HMAC_SHA256 = require('./hmac').HMAC_SHA256;
  9020.  
  9021. }).call(this);
  9022.  
  9023. }).call(this,require("buffer").Buffer)
  9024. },{"./aes":17,"./dec":21,"./enc":23,"./hmac":24,"./pbkdf2":27,"./prng":28,"./scrypt":30,"./sha1":31,"./sha224":32,"./sha256":33,"./sha3":34,"./sha512":35,"./twofish":36,"./util":37,"./wordarray":38,"buffer":1}],27:[function(require,module,exports){
  9025. // Generated by IcedCoffeeScript 1.6.3-g
  9026. (function() {
  9027.   var HMAC, PBKDF2, WordArray, iced, pbkdf2, util, __iced_k, __iced_k_noop;
  9028.  
  9029.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  9030.   __iced_k = __iced_k_noop = function() {};
  9031.  
  9032.   HMAC = require('./hmac').HMAC;
  9033.  
  9034.   WordArray = require('./wordarray').WordArray;
  9035.  
  9036.   util = require('./util');
  9037.  
  9038.   PBKDF2 = (function() {
  9039.     function PBKDF2(_arg) {
  9040.       this.klass = _arg.klass, this.c = _arg.c;
  9041.       this.c || (this.c = 1024);
  9042.       this.klass || (this.klass = HMAC);
  9043.     }
  9044.  
  9045.     PBKDF2.prototype._PRF = function(input) {
  9046.       this.prf.reset();
  9047.       return this.prf.finalize(input);
  9048.     };
  9049.  
  9050.     PBKDF2.prototype._gen_T_i = function(_arg, cb) {
  9051.       var U, i, progress_hook, ret, salt, seed, stop, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  9052.         _this = this;
  9053.       __iced_k = __iced_k_noop;
  9054.       ___iced_passed_deferral = iced.findDeferral(arguments);
  9055.       salt = _arg.salt, i = _arg.i, progress_hook = _arg.progress_hook;
  9056.       progress_hook(0);
  9057.       seed = salt.clone().concat(new WordArray([i]));
  9058.       U = this._PRF(seed);
  9059.       ret = U.clone();
  9060.       i = 1;
  9061.       (function(__iced_k) {
  9062.         var _results, _while;
  9063.         _results = [];
  9064.         _while = function(__iced_k) {
  9065.           var _break, _continue, _next;
  9066.           _break = function() {
  9067.             return __iced_k(_results);
  9068.           };
  9069.           _continue = function() {
  9070.             return iced.trampoline(function() {
  9071.               return _while(__iced_k);
  9072.             });
  9073.           };
  9074.           _next = function(__iced_next_arg) {
  9075.             _results.push(__iced_next_arg);
  9076.             return _continue();
  9077.           };
  9078.           if (!(i < _this.c)) {
  9079.             return _break();
  9080.           } else {
  9081.             stop = Math.min(_this.c, i + 128);
  9082.             while (i < stop) {
  9083.               U = _this._PRF(U);
  9084.               ret.xor(U, {});
  9085.               i++;
  9086.             }
  9087.             progress_hook(i);
  9088.             (function(__iced_k) {
  9089.               __iced_deferrals = new iced.Deferrals(__iced_k, {
  9090.                 parent: ___iced_passed_deferral,
  9091.                 filename: "src/pbkdf2.iced",
  9092.                 funcname: "PBKDF2._gen_T_i"
  9093.               });
  9094.               util.default_delay(0, 0, __iced_deferrals.defer({
  9095.                 lineno: 57
  9096.               }));
  9097.               __iced_deferrals._fulfill();
  9098.             })(function() {
  9099.               return _next(null);
  9100.             });
  9101.           }
  9102.         };
  9103.         _while(__iced_k);
  9104.       })(function() {
  9105.         progress_hook(i);
  9106.         return cb(ret);
  9107.       });
  9108.     };
  9109.  
  9110.     PBKDF2.prototype.run = function(_arg, cb) {
  9111.       var bs, dkLen, flat, i, key, n, ph, progress_hook, salt, tmp, tph, words, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  9112.         _this = this;
  9113.       __iced_k = __iced_k_noop;
  9114.       ___iced_passed_deferral = iced.findDeferral(arguments);
  9115.       key = _arg.key, salt = _arg.salt, dkLen = _arg.dkLen, progress_hook = _arg.progress_hook;
  9116.       this.prf = new this.klass(key);
  9117.       bs = this.prf.get_output_size();
  9118.       n = Math.ceil(dkLen / bs);
  9119.       words = [];
  9120.       tph = null;
  9121.       ph = function(block) {
  9122.         return function(iter) {
  9123.           return typeof progress_hook === "function" ? progress_hook({
  9124.             what: "pbkdf2",
  9125.             total: n * _this.c,
  9126.             i: block * _this.c + iter
  9127.           }) : void 0;
  9128.         };
  9129.       };
  9130.       ph(0)(0);
  9131.       (function(__iced_k) {
  9132.         var _i, _results, _while;
  9133.         i = 1;
  9134.         _results = [];
  9135.         _while = function(__iced_k) {
  9136.           var _break, _continue, _next;
  9137.           _break = function() {
  9138.             return __iced_k(_results);
  9139.           };
  9140.           _continue = function() {
  9141.             return iced.trampoline(function() {
  9142.               ++i;
  9143.               return _while(__iced_k);
  9144.             });
  9145.           };
  9146.           _next = function(__iced_next_arg) {
  9147.             _results.push(__iced_next_arg);
  9148.             return _continue();
  9149.           };
  9150.           if (!(i <= n)) {
  9151.             return _break();
  9152.           } else {
  9153.  
  9154.             (function(__iced_k) {
  9155.               __iced_deferrals = new iced.Deferrals(__iced_k, {
  9156.                 parent: ___iced_passed_deferral,
  9157.                 filename: "src/pbkdf2.iced",
  9158.                 funcname: "PBKDF2.run"
  9159.               });
  9160.               _this._gen_T_i({
  9161.                 salt: salt,
  9162.                 i: i,
  9163.                 progress_hook: ph(i - 1)
  9164.               }, __iced_deferrals.defer({
  9165.                 assign_fn: (function() {
  9166.                   return function() {
  9167.                     return tmp = arguments[0];
  9168.                   };
  9169.                 })(),
  9170.                 lineno: 80
  9171.               }));
  9172.               __iced_deferrals._fulfill();
  9173.             })(function() {
  9174.               return _next(words.push(tmp.words));
  9175.             });
  9176.           }
  9177.         };
  9178.         _while(__iced_k);
  9179.       })(function() {
  9180.         var _ref;
  9181.         ph(n)(0);
  9182.         flat = (_ref = []).concat.apply(_ref, words);
  9183.         key.scrub();
  9184.         _this.prf.scrub();
  9185.         _this.prf = null;
  9186.         return cb(new WordArray(flat, dkLen));
  9187.       });
  9188.     };
  9189.  
  9190.     return PBKDF2;
  9191.  
  9192.   })();
  9193.  
  9194.   pbkdf2 = function(_arg, cb) {
  9195.     var c, dkLen, eng, key, klass, out, progress_hook, salt, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  9196.       _this = this;
  9197.     __iced_k = __iced_k_noop;
  9198.     ___iced_passed_deferral = iced.findDeferral(arguments);
  9199.     key = _arg.key, salt = _arg.salt, klass = _arg.klass, c = _arg.c, dkLen = _arg.dkLen, progress_hook = _arg.progress_hook;
  9200.     eng = new PBKDF2({
  9201.       klass: klass,
  9202.       c: c
  9203.     });
  9204.     (function(__iced_k) {
  9205.       __iced_deferrals = new iced.Deferrals(__iced_k, {
  9206.         parent: ___iced_passed_deferral,
  9207.         filename: "src/pbkdf2.iced",
  9208.         funcname: "pbkdf2"
  9209.       });
  9210.       eng.run({
  9211.         key: key,
  9212.         salt: salt,
  9213.         dkLen: dkLen,
  9214.         progress_hook: progress_hook
  9215.       }, __iced_deferrals.defer({
  9216.         assign_fn: (function() {
  9217.           return function() {
  9218.             return out = arguments[0];
  9219.           };
  9220.         })(),
  9221.         lineno: 106
  9222.       }));
  9223.       __iced_deferrals._fulfill();
  9224.     })(function() {
  9225.       return cb(out);
  9226.     });
  9227.   };
  9228.  
  9229.   exports.pbkdf2 = pbkdf2;
  9230.  
  9231.   exports.PBKDF2 = PBKDF2;
  9232.  
  9233. }).call(this);
  9234.  
  9235. },{"./hmac":24,"./util":37,"./wordarray":38,"iced-coffee-script/lib/coffee-script/iced":9}],28:[function(require,module,exports){
  9236. (function (Buffer){
  9237. // Generated by IcedCoffeeScript 1.6.3-g
  9238. (function() {
  9239.   var ADRBG, PRNG, WordArray, XOR, browser_rng, e, generate, iced, more_entropy, native_rng, rng, util, __iced_k, __iced_k_noop, _native_rng, _prng, _ref;
  9240.  
  9241.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  9242.   __iced_k = __iced_k_noop = function() {};
  9243.  
  9244.   more_entropy = require('more-entropy');
  9245.  
  9246.   ADRBG = require('./drbg').ADRBG;
  9247.  
  9248.   WordArray = require('./wordarray').WordArray;
  9249.  
  9250.   XOR = require('./combine').XOR;
  9251.  
  9252.   util = require('./util');
  9253.  
  9254.   browser_rng = function(n) {
  9255.     var v;
  9256.     v = new Uint8Array(n);
  9257.     window.crypto.getRandomValues(v);
  9258.     return new Buffer(v);
  9259.   };
  9260.  
  9261.   if ((typeof window !== "undefined" && window !== null ? (_ref = window.crypto) != null ? _ref.getRandomValues : void 0 : void 0) != null) {
  9262.     _native_rng = browser_rng;
  9263.   } else {
  9264.     try {
  9265.       rng = require('cry' + 'pto').rng;
  9266.       if (rng != null) {
  9267.         _native_rng = rng;
  9268.       }
  9269.     } catch (_error) {
  9270.       e = _error;
  9271.     }
  9272.   }
  9273.  
  9274.   native_rng = function(x) {
  9275.     if (_native_rng == null) {
  9276.       throw new Error('No rng found; tried requiring "crypto" and window.crypto');
  9277.     }
  9278.     return _native_rng(x);
  9279.   };
  9280.  
  9281.   PRNG = (function() {
  9282.     function PRNG() {
  9283.       var _this = this;
  9284.       this.meg = new more_entropy.Generator();
  9285.       this.adrbg = new ADRBG((function(n, cb) {
  9286.         return _this.gen_seed(n, cb);
  9287.       }), XOR.sign);
  9288.     }
  9289.  
  9290.     PRNG.prototype.now_to_buffer = function() {
  9291.       var buf, d, ms, s;
  9292.       d = Date.now();
  9293.       ms = d % 1000;
  9294.       s = Math.floor(d / 1000);
  9295.       buf = new Buffer(8);
  9296.       buf.writeUInt32BE(s, 0);
  9297.       buf.writeUInt32BE(ms, 4);
  9298.       return buf;
  9299.     };
  9300.  
  9301.     PRNG.prototype.gen_seed = function(nbits, cb) {
  9302.       var b, bufs, cat, nbytes, wa, words, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  9303.         _this = this;
  9304.       __iced_k = __iced_k_noop;
  9305.       ___iced_passed_deferral = iced.findDeferral(arguments);
  9306.       nbytes = nbits / 8;
  9307.       bufs = [];
  9308.       bufs.push(this.now_to_buffer());
  9309.       (function(__iced_k) {
  9310.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  9311.           parent: ___iced_passed_deferral,
  9312.           filename: "src/prng.iced",
  9313.           funcname: "PRNG.gen_seed"
  9314.         });
  9315.         _this.meg.generate(nbits, __iced_deferrals.defer({
  9316.           assign_fn: (function() {
  9317.             return function() {
  9318.               return words = arguments[0];
  9319.             };
  9320.           })(),
  9321.           lineno: 76
  9322.         }));
  9323.         __iced_deferrals._fulfill();
  9324.       })(function() {
  9325.         var _i, _len;
  9326.         bufs.push(_this.now_to_buffer());
  9327.         bufs.push(new Buffer(words));
  9328.         bufs.push(native_rng(nbytes));
  9329.         bufs.push(_this.now_to_buffer());
  9330.         cat = Buffer.concat(bufs);
  9331.         wa = WordArray.from_buffer(cat);
  9332.         util.scrub_buffer(cat);
  9333.         for (_i = 0, _len = bufs.length; _i < _len; _i++) {
  9334.           b = bufs[_i];
  9335.           util.scrub_buffer(b);
  9336.         }
  9337.         return cb(wa);
  9338.       });
  9339.     };
  9340.  
  9341.     PRNG.prototype.generate = function(n, cb) {
  9342.       return this.adrbg.generate(n, cb);
  9343.     };
  9344.  
  9345.     return PRNG;
  9346.  
  9347.   })();
  9348.  
  9349.   _prng = null;
  9350.  
  9351.   generate = function(n, cb) {
  9352.     if (_prng == null) {
  9353.       _prng = new PRNG();
  9354.     }
  9355.     return _prng.generate(n, cb);
  9356.   };
  9357.  
  9358.   exports.PRNG = PRNG;
  9359.  
  9360.   exports.generate = generate;
  9361.  
  9362.   exports.native_rng = native_rng;
  9363.  
  9364. }).call(this);
  9365.  
  9366. }).call(this,require("buffer").Buffer)
  9367. },{"./combine":19,"./drbg":22,"./util":37,"./wordarray":38,"buffer":1,"iced-coffee-script/lib/coffee-script/iced":9,"more-entropy":40}],29:[function(require,module,exports){
  9368. (function (Buffer){
  9369. // Generated by IcedCoffeeScript 1.6.3-g
  9370. (function() {
  9371.   var Cipher, Counter, Salsa20, Salsa20Core, Salsa20InnerCore, Salsa20WordStream, StreamCipher, WordArray, asum, bulk_encrypt, encrypt, endian_reverse, fixup_uint32, iced, util, __iced_k, __iced_k_noop, _ref, _ref1, _ref2,
  9372.     __hasProp = {}.hasOwnProperty,
  9373.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  9374.  
  9375.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  9376.   __iced_k = __iced_k_noop = function() {};
  9377.  
  9378.   _ref = require('./wordarray'), endian_reverse = _ref.endian_reverse, WordArray = _ref.WordArray;
  9379.  
  9380.   Counter = require('./ctr').Counter;
  9381.  
  9382.   fixup_uint32 = require('./util').fixup_uint32;
  9383.  
  9384.   StreamCipher = require('./algbase').StreamCipher;
  9385.  
  9386.   util = require('./util');
  9387.  
  9388.   asum = function(out, v) {
  9389.     var e, i, _i, _len;
  9390.     for (i = _i = 0, _len = v.length; _i < _len; i = ++_i) {
  9391.       e = v[i];
  9392.       out[i] += e;
  9393.     }
  9394.     return false;
  9395.   };
  9396.  
  9397.   Salsa20InnerCore = (function() {
  9398.     function Salsa20InnerCore(rounds) {
  9399.       this.rounds = rounds;
  9400.     }
  9401.  
  9402.     Salsa20InnerCore.prototype._core = function(v) {
  9403.       "use asm";
  9404.       var i, u, x0, x1, x10, x11, x12, x13, x14, x15, x2, x3, x4, x5, x6, x7, x8, x9, _i, _ref1;
  9405.       x0 = v[0], x1 = v[1], x2 = v[2], x3 = v[3], x4 = v[4], x5 = v[5], x6 = v[6], x7 = v[7], x8 = v[8], x9 = v[9], x10 = v[10], x11 = v[11], x12 = v[12], x13 = v[13], x14 = v[14], x15 = v[15];
  9406.       for (i = _i = 0, _ref1 = this.rounds; _i < _ref1; i = _i += 2) {
  9407.         u = (x0 + x12) | 0;
  9408.         x4 ^= (u << 7) | (u >>> 25);
  9409.         u = (x4 + x0) | 0;
  9410.         x8 ^= (u << 9) | (u >>> 23);
  9411.         u = (x8 + x4) | 0;
  9412.         x12 ^= (u << 13) | (u >>> 19);
  9413.         u = (x12 + x8) | 0;
  9414.         x0 ^= (u << 18) | (u >>> 14);
  9415.         u = (x5 + x1) | 0;
  9416.         x9 ^= (u << 7) | (u >>> 25);
  9417.         u = (x9 + x5) | 0;
  9418.         x13 ^= (u << 9) | (u >>> 23);
  9419.         u = (x13 + x9) | 0;
  9420.         x1 ^= (u << 13) | (u >>> 19);
  9421.         u = (x1 + x13) | 0;
  9422.         x5 ^= (u << 18) | (u >>> 14);
  9423.         u = (x10 + x6) | 0;
  9424.         x14 ^= (u << 7) | (u >>> 25);
  9425.         u = (x14 + x10) | 0;
  9426.         x2 ^= (u << 9) | (u >>> 23);
  9427.         u = (x2 + x14) | 0;
  9428.         x6 ^= (u << 13) | (u >>> 19);
  9429.         u = (x6 + x2) | 0;
  9430.         x10 ^= (u << 18) | (u >>> 14);
  9431.         u = (x15 + x11) | 0;
  9432.         x3 ^= (u << 7) | (u >>> 25);
  9433.         u = (x3 + x15) | 0;
  9434.         x7 ^= (u << 9) | (u >>> 23);
  9435.         u = (x7 + x3) | 0;
  9436.         x11 ^= (u << 13) | (u >>> 19);
  9437.         u = (x11 + x7) | 0;
  9438.         x15 ^= (u << 18) | (u >>> 14);
  9439.         u = (x0 + x3) | 0;
  9440.         x1 ^= (u << 7) | (u >>> 25);
  9441.         u = (x1 + x0) | 0;
  9442.         x2 ^= (u << 9) | (u >>> 23);
  9443.         u = (x2 + x1) | 0;
  9444.         x3 ^= (u << 13) | (u >>> 19);
  9445.         u = (x3 + x2) | 0;
  9446.         x0 ^= (u << 18) | (u >>> 14);
  9447.         u = (x5 + x4) | 0;
  9448.         x6 ^= (u << 7) | (u >>> 25);
  9449.         u = (x6 + x5) | 0;
  9450.         x7 ^= (u << 9) | (u >>> 23);
  9451.         u = (x7 + x6) | 0;
  9452.         x4 ^= (u << 13) | (u >>> 19);
  9453.         u = (x4 + x7) | 0;
  9454.         x5 ^= (u << 18) | (u >>> 14);
  9455.         u = (x10 + x9) | 0;
  9456.         x11 ^= (u << 7) | (u >>> 25);
  9457.         u = (x11 + x10) | 0;
  9458.         x8 ^= (u << 9) | (u >>> 23);
  9459.         u = (x8 + x11) | 0;
  9460.         x9 ^= (u << 13) | (u >>> 19);
  9461.         u = (x9 + x8) | 0;
  9462.         x10 ^= (u << 18) | (u >>> 14);
  9463.         u = (x15 + x14) | 0;
  9464.         x12 ^= (u << 7) | (u >>> 25);
  9465.         u = (x12 + x15) | 0;
  9466.         x13 ^= (u << 9) | (u >>> 23);
  9467.         u = (x13 + x12) | 0;
  9468.         x14 ^= (u << 13) | (u >>> 19);
  9469.         u = (x14 + x13) | 0;
  9470.         x15 ^= (u << 18) | (u >>> 14);
  9471.       }
  9472.       return [x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15];
  9473.     };
  9474.  
  9475.     return Salsa20InnerCore;
  9476.  
  9477.   })();
  9478.  
  9479.   Salsa20Core = (function(_super) {
  9480.     __extends(Salsa20Core, _super);
  9481.  
  9482.     Salsa20Core.prototype.sigma = WordArray.from_buffer_le(new Buffer("expand 32-byte k"));
  9483.  
  9484.     Salsa20Core.prototype.tau = WordArray.from_buffer_le(new Buffer("expand 16-byte k"));
  9485.  
  9486.     Salsa20Core.blockSize = 64;
  9487.  
  9488.     Salsa20Core.prototype.blockSize = Salsa20Core.blockSize;
  9489.  
  9490.     Salsa20Core.keySize = 32;
  9491.  
  9492.     Salsa20Core.prototype.keySize = Salsa20Core.keySize;
  9493.  
  9494.     Salsa20Core.ivSize = 192 / 8;
  9495.  
  9496.     Salsa20Core.prototype.ivSize = Salsa20Core.ivSize;
  9497.  
  9498.     function Salsa20Core(key, nonce) {
  9499.       var _ref1;
  9500.       Salsa20Core.__super__.constructor.call(this, 20);
  9501.       this.key = key.clone().endian_reverse();
  9502.       this.nonce = nonce.clone().endian_reverse();
  9503.       if (!(((this.key.sigBytes === 16) && (this.nonce.sigBytes === 8)) || ((this.key.sigBytes === 32) && ((_ref1 = this.nonce.sigBytes) === 8 || _ref1 === 24)))) {
  9504.         throw new Error("Bad key/nonce lengths");
  9505.       }
  9506.       if (this.nonce.sigBytes === 24) {
  9507.         this.xsalsa_setup();
  9508.       }
  9509.       this.input = this.key_iv_setup(this.nonce, this.key);
  9510.       this._reset();
  9511.     }
  9512.  
  9513.     Salsa20Core.prototype.scrub = function() {
  9514.       this.key.scrub();
  9515.       this.nonce.scrub();
  9516.       return util.scrub_vec(this.input);
  9517.     };
  9518.  
  9519.     Salsa20Core.prototype.xsalsa_setup = function() {
  9520.       var n0, n1;
  9521.       n0 = new WordArray(this.nonce.words.slice(0, 4));
  9522.       this.nonce = n1 = new WordArray(this.nonce.words.slice(4));
  9523.       return this.key = this.hsalsa20(n0, this.key);
  9524.     };
  9525.  
  9526.     Salsa20Core.prototype.hsalsa20 = function(nonce, key) {
  9527.       var i, indexes, input, v;
  9528.       input = this.key_iv_setup(nonce, key);
  9529.       input[8] = nonce.words[2];
  9530.       input[9] = nonce.words[3];
  9531.       v = this._core(input);
  9532.       indexes = [0, 5, 10, 15, 6, 7, 8, 9];
  9533.       v = (function() {
  9534.         var _i, _len, _results;
  9535.         _results = [];
  9536.         for (_i = 0, _len = indexes.length; _i < _len; _i++) {
  9537.           i = indexes[_i];
  9538.           _results.push(fixup_uint32(v[i]));
  9539.         }
  9540.         return _results;
  9541.       })();
  9542.       util.scrub_vec(input);
  9543.       return new WordArray(v);
  9544.     };
  9545.  
  9546.     Salsa20Core.prototype.key_iv_setup = function(nonce, key) {
  9547.       var A, C, i, out, _i, _j, _k, _ref1;
  9548.       out = [];
  9549.       for (i = _i = 0; _i < 4; i = ++_i) {
  9550.         out[i + 1] = key.words[i];
  9551.       }
  9552.       _ref1 = key.sigBytes === 32 ? [this.sigma, key.words.slice(4)] : [this.tau, key.words], C = _ref1[0], A = _ref1[1];
  9553.       for (i = _j = 0; _j < 4; i = ++_j) {
  9554.         out[i + 11] = A[i];
  9555.       }
  9556.       for (i = _k = 0; _k < 4; i = ++_k) {
  9557.         out[i * 5] = C.words[i];
  9558.       }
  9559.       out[6] = nonce.words[0];
  9560.       out[7] = nonce.words[1];
  9561.       return out;
  9562.     };
  9563.  
  9564.     Salsa20Core.prototype.counter_setup = function() {
  9565.       this.input[8] = this.counter.get().words[0];
  9566.       return this.input[9] = this.counter.get().words[1];
  9567.     };
  9568.  
  9569.     Salsa20Core.prototype._reset = function() {
  9570.       return this.counter = new Counter({
  9571.         len: 2
  9572.       });
  9573.     };
  9574.  
  9575.     Salsa20Core.prototype._generateBlock = function() {
  9576.       var v;
  9577.       this.counter_setup();
  9578.       v = this._core(this.input);
  9579.       asum(v, this.input);
  9580.       this.counter.inc_le();
  9581.       return v;
  9582.     };
  9583.  
  9584.     return Salsa20Core;
  9585.  
  9586.   })(Salsa20InnerCore);
  9587.  
  9588.   exports.Salsa20WordStream = Salsa20WordStream = (function(_super) {
  9589.     __extends(Salsa20WordStream, _super);
  9590.  
  9591.     function Salsa20WordStream() {
  9592.       _ref1 = Salsa20WordStream.__super__.constructor.apply(this, arguments);
  9593.       return _ref1;
  9594.     }
  9595.  
  9596.     Salsa20WordStream.prototype._reset = function() {
  9597.       return Salsa20WordStream.__super__._reset.call(this);
  9598.     };
  9599.  
  9600.     Salsa20WordStream.prototype.getWordArray = function(nbytes) {
  9601.       var blocks, i, nblocks, w, words, _i, _len, _ref2;
  9602.       if ((nbytes == null) || nbytes === this.blockSize) {
  9603.         words = this._generateBlock();
  9604.       } else {
  9605.         nblocks = Math.ceil(nbytes / this.blockSize);
  9606.         blocks = (function() {
  9607.           var _i, _results;
  9608.           _results = [];
  9609.           for (i = _i = 0; 0 <= nblocks ? _i < nblocks : _i > nblocks; i = 0 <= nblocks ? ++_i : --_i) {
  9610.             _results.push(this._generateBlock());
  9611.           }
  9612.           return _results;
  9613.         }).call(this);
  9614.         words = (_ref2 = []).concat.apply(_ref2, blocks);
  9615.       }
  9616.       for (i = _i = 0, _len = words.length; _i < _len; i = ++_i) {
  9617.         w = words[i];
  9618.         words[i] = endian_reverse(w);
  9619.       }
  9620.       return new WordArray(words, nbytes);
  9621.     };
  9622.  
  9623.     return Salsa20WordStream;
  9624.  
  9625.   })(Salsa20Core);
  9626.  
  9627.   exports.Salsa20 = Salsa20 = (function(_super) {
  9628.     __extends(Salsa20, _super);
  9629.  
  9630.     function Salsa20() {
  9631.       _ref2 = Salsa20.__super__.constructor.apply(this, arguments);
  9632.       return _ref2;
  9633.     }
  9634.  
  9635.     Salsa20.prototype._reset = function() {
  9636.       Salsa20.__super__._reset.call(this);
  9637.       return this._i = this.blockSize;
  9638.     };
  9639.  
  9640.     Salsa20.prototype.getBytes = function(needed) {
  9641.       var bsz, n, v;
  9642.       if (needed == null) {
  9643.         needed = this.blockSize;
  9644.       }
  9645.       v = [];
  9646.       bsz = this.blockSize;
  9647.       if ((this._i === bsz) && (needed === bsz)) {
  9648.         return this._generateBlockBuffer();
  9649.       } else {
  9650.         while (needed > 0) {
  9651.           if (this._i === bsz) {
  9652.             this._generateBlockBuffer();
  9653.             this._i = 0;
  9654.           }
  9655.           n = Math.min(needed, bsz - this._i);
  9656.           v.push((n === bsz ? this._buf : this._buf.slice(this._i, this._i + n)));
  9657.           this._i += n;
  9658.           needed -= n;
  9659.         }
  9660.         return Buffer.concat(v);
  9661.       }
  9662.     };
  9663.  
  9664.     Salsa20.prototype._generateBlockBuffer = function() {
  9665.       var e, i, v, _i, _len;
  9666.       this._buf = new Buffer(this.blockSize);
  9667.       v = this._generateBlock();
  9668.       for (i = _i = 0, _len = v.length; _i < _len; i = ++_i) {
  9669.         e = v[i];
  9670.         this._buf.writeUInt32LE(fixup_uint32(e), i * 4);
  9671.       }
  9672.       return this._buf;
  9673.     };
  9674.  
  9675.     return Salsa20;
  9676.  
  9677.   })(Salsa20Core);
  9678.  
  9679.   exports.Cipher = Cipher = (function(_super) {
  9680.     __extends(Cipher, _super);
  9681.  
  9682.     function Cipher(_arg) {
  9683.       var iv, key;
  9684.       key = _arg.key, iv = _arg.iv;
  9685.       Cipher.__super__.constructor.call(this);
  9686.       this.salsa = new Salsa20WordStream(key, iv);
  9687.       this.bsiw = this.salsa.blockSize / 4;
  9688.     }
  9689.  
  9690.     Cipher.prototype.scrub = function() {
  9691.       return this.salsa.scrub();
  9692.     };
  9693.  
  9694.     Cipher.prototype.get_pad = function() {
  9695.       var pad;
  9696.       pad = this.salsa.getWordArray();
  9697.       return pad;
  9698.     };
  9699.  
  9700.     return Cipher;
  9701.  
  9702.   })(StreamCipher);
  9703.  
  9704.   exports.encrypt = encrypt = function(_arg) {
  9705.     var cipher, input, iv, key, ret;
  9706.     key = _arg.key, iv = _arg.iv, input = _arg.input;
  9707.     cipher = new Cipher({
  9708.       key: key,
  9709.       iv: iv
  9710.     });
  9711.     ret = cipher.encrypt(input);
  9712.     cipher.scrub();
  9713.     return ret;
  9714.   };
  9715.  
  9716.   exports.bulk_encrypt = bulk_encrypt = function(_arg, cb) {
  9717.     var cipher, input, iv, key, progress_hook, ret, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  9718.       _this = this;
  9719.     __iced_k = __iced_k_noop;
  9720.     ___iced_passed_deferral = iced.findDeferral(arguments);
  9721.     key = _arg.key, iv = _arg.iv, input = _arg.input, progress_hook = _arg.progress_hook;
  9722.     cipher = new Cipher({
  9723.       key: key,
  9724.       iv: iv
  9725.     });
  9726.     (function(__iced_k) {
  9727.       __iced_deferrals = new iced.Deferrals(__iced_k, {
  9728.         parent: ___iced_passed_deferral,
  9729.         filename: "src/salsa20.iced",
  9730.         funcname: "bulk_encrypt"
  9731.       });
  9732.       cipher.bulk_encrypt({
  9733.         input: input,
  9734.         progress_hook: progress_hook,
  9735.         what: "salsa20"
  9736.       }, __iced_deferrals.defer({
  9737.         assign_fn: (function() {
  9738.           return function() {
  9739.             return ret = arguments[0];
  9740.           };
  9741.         })(),
  9742.         lineno: 257
  9743.       }));
  9744.       __iced_deferrals._fulfill();
  9745.     })(function() {
  9746.       cipher.scrub();
  9747.       return cb(ret);
  9748.     });
  9749.   };
  9750.  
  9751.   exports.Salsa20InnerCore = Salsa20InnerCore;
  9752.  
  9753.   exports.endian_reverse = endian_reverse;
  9754.  
  9755.   exports.asum = asum;
  9756.  
  9757. }).call(this);
  9758.  
  9759. }).call(this,require("buffer").Buffer)
  9760. },{"./algbase":18,"./ctr":20,"./util":37,"./wordarray":38,"buffer":1,"iced-coffee-script/lib/coffee-script/iced":9}],30:[function(require,module,exports){
  9761. // Generated by IcedCoffeeScript 1.6.3-g
  9762. (function() {
  9763.   var HMAC_SHA256, Salsa20InnerCore, Scrypt, WordArray, blkcpy, blkxor, default_delay, endian_reverse, fixup_uint32, iced, pbkdf2, scrub_vec, scrypt, ui8a_to_buffer, v_endian_reverse, __iced_k, __iced_k_noop, _ref, _ref1, _ref2;
  9764.  
  9765.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  9766.   __iced_k = __iced_k_noop = function() {};
  9767.  
  9768.   HMAC_SHA256 = require('./hmac').HMAC_SHA256;
  9769.  
  9770.   pbkdf2 = require('./pbkdf2').pbkdf2;
  9771.  
  9772.   _ref = require('./salsa20'), endian_reverse = _ref.endian_reverse, Salsa20InnerCore = _ref.Salsa20InnerCore;
  9773.  
  9774.   _ref1 = require('./wordarray'), ui8a_to_buffer = _ref1.ui8a_to_buffer, WordArray = _ref1.WordArray;
  9775.  
  9776.   _ref2 = require('./util'), fixup_uint32 = _ref2.fixup_uint32, default_delay = _ref2.default_delay, scrub_vec = _ref2.scrub_vec;
  9777.  
  9778.   blkcpy = function(D, S, d_offset, s_offset, len) {
  9779.     "use asm";
  9780.     var end, i, j;
  9781.     j = (d_offset << 4) | 0;
  9782.     i = (s_offset << 4) | 0;
  9783.     end = (i + (len << 4)) | 0;
  9784.     while (i < end) {
  9785.       D[j] = S[i];
  9786.       D[j + 1] = S[i + 1];
  9787.       D[j + 2] = S[i + 2];
  9788.       D[j + 3] = S[i + 3];
  9789.       D[j + 4] = S[i + 4];
  9790.       D[j + 5] = S[i + 5];
  9791.       D[j + 6] = S[i + 6];
  9792.       D[j + 7] = S[i + 7];
  9793.       D[j + 8] = S[i + 8];
  9794.       D[j + 9] = S[i + 9];
  9795.       D[j + 10] = S[i + 10];
  9796.       D[j + 11] = S[i + 11];
  9797.       D[j + 12] = S[i + 12];
  9798.       D[j + 13] = S[i + 13];
  9799.       D[j + 14] = S[i + 14];
  9800.       D[j + 15] = S[i + 15];
  9801.       i += 16;
  9802.       j += 16;
  9803.     }
  9804.     return true;
  9805.   };
  9806.  
  9807.   blkxor = function(D, S, s_offset, len) {
  9808.     "use asm";
  9809.     var i, j;
  9810.     len = (len << 4) | 0;
  9811.     i = 0;
  9812.     j = (s_offset << 4) | 0;
  9813.     while (i < len) {
  9814.       D[i] ^= S[j];
  9815.       D[i + 1] ^= S[j + 1];
  9816.       D[i + 2] ^= S[j + 2];
  9817.       D[i + 3] ^= S[j + 3];
  9818.       D[i + 4] ^= S[j + 4];
  9819.       D[i + 5] ^= S[j + 5];
  9820.       D[i + 6] ^= S[j + 6];
  9821.       D[i + 7] ^= S[j + 7];
  9822.       D[i + 8] ^= S[j + 8];
  9823.       D[i + 9] ^= S[j + 9];
  9824.       D[i + 10] ^= S[j + 10];
  9825.       D[i + 11] ^= S[j + 11];
  9826.       D[i + 12] ^= S[j + 12];
  9827.       D[i + 13] ^= S[j + 13];
  9828.       D[i + 14] ^= S[j + 14];
  9829.       D[i + 15] ^= S[j + 15];
  9830.       i += 16;
  9831.       j += 16;
  9832.     }
  9833.     return true;
  9834.   };
  9835.  
  9836.   v_endian_reverse = function(v) {
  9837.     var e, i, _i, _len;
  9838.     for (i = _i = 0, _len = v.length; _i < _len; i = ++_i) {
  9839.       e = v[i];
  9840.       v[i] = endian_reverse(e);
  9841.     }
  9842.     return true;
  9843.   };
  9844.  
  9845.   Scrypt = (function() {
  9846.     function Scrypt(_arg) {
  9847.       var N, c, c0, c1;
  9848.       N = _arg.N, this.r = _arg.r, this.p = _arg.p, c = _arg.c, c0 = _arg.c0, c1 = _arg.c1, this.klass = _arg.klass;
  9849.       this.N || (this.N = 1 << (N || 10));
  9850.       this.r || (this.r = 16);
  9851.       this.p || (this.p = 2);
  9852.       this.c0 = c0 || c || 1;
  9853.       this.c1 = c1 || c || 1;
  9854.       this.klass || (this.klass = HMAC_SHA256);
  9855.       this.X16_tmp = new Int32Array(0x10);
  9856.       this.s20ic = new Salsa20InnerCore(8);
  9857.     }
  9858.  
  9859.     Scrypt.prototype.salsa20_8 = function(B) {
  9860.       var X, i, x, _i, _len;
  9861.       X = this.s20ic._core(B);
  9862.       for (i = _i = 0, _len = X.length; _i < _len; i = ++_i) {
  9863.         x = X[i];
  9864.         B[i] += x;
  9865.       }
  9866.       return true;
  9867.     };
  9868.  
  9869.     Scrypt.prototype.pbkdf2 = function(_arg, cb) {
  9870.       var c, dkLen, key, progress_hook, salt, wa, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  9871.         _this = this;
  9872.       __iced_k = __iced_k_noop;
  9873.       ___iced_passed_deferral = iced.findDeferral(arguments);
  9874.       key = _arg.key, salt = _arg.salt, dkLen = _arg.dkLen, progress_hook = _arg.progress_hook, c = _arg.c;
  9875.       (function(__iced_k) {
  9876.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  9877.           parent: ___iced_passed_deferral,
  9878.           filename: "src/scrypt.iced",
  9879.           funcname: "Scrypt.pbkdf2"
  9880.         });
  9881.         pbkdf2({
  9882.           key: key,
  9883.           salt: salt,
  9884.           c: c,
  9885.           dkLen: dkLen,
  9886.           klass: _this.klass,
  9887.           progress_hook: progress_hook
  9888.         }, __iced_deferrals.defer({
  9889.           assign_fn: (function() {
  9890.             return function() {
  9891.               return wa = arguments[0];
  9892.             };
  9893.           })(),
  9894.           lineno: 103
  9895.         }));
  9896.         __iced_deferrals._fulfill();
  9897.       })(function() {
  9898.         return cb(wa);
  9899.       });
  9900.     };
  9901.  
  9902.     Scrypt.prototype.blockmix_salsa8 = function(B, Y) {
  9903.       var X, i, _i, _j, _k, _ref3, _ref4, _ref5;
  9904.       X = this.X16_tmp;
  9905.       blkcpy(X, B, 0, 2 * this.r - 1, 1);
  9906.       for (i = _i = 0, _ref3 = 2 * this.r; 0 <= _ref3 ? _i < _ref3 : _i > _ref3; i = 0 <= _ref3 ? ++_i : --_i) {
  9907.         blkxor(X, B, i, 1);
  9908.         this.salsa20_8(X);
  9909.         blkcpy(Y, X, i, 0, 1);
  9910.       }
  9911.       for (i = _j = 0, _ref4 = this.r; 0 <= _ref4 ? _j < _ref4 : _j > _ref4; i = 0 <= _ref4 ? ++_j : --_j) {
  9912.         blkcpy(B, Y, i, i * 2, 1);
  9913.       }
  9914.       for (i = _k = 0, _ref5 = this.r; 0 <= _ref5 ? _k < _ref5 : _k > _ref5; i = 0 <= _ref5 ? ++_k : --_k) {
  9915.         blkcpy(B, Y, i + this.r, i * 2 + 1, 1);
  9916.       }
  9917.       return true;
  9918.     };
  9919.  
  9920.     Scrypt.prototype.smix = function(_arg, cb) {
  9921.       var B, V, X, XY, Y, i, j, lim, progress_hook, stop, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  9922.         _this = this;
  9923.       __iced_k = __iced_k_noop;
  9924.       ___iced_passed_deferral = iced.findDeferral(arguments);
  9925.       B = _arg.B, V = _arg.V, XY = _arg.XY, progress_hook = _arg.progress_hook;
  9926.       X = XY;
  9927.       lim = 2 * this.r;
  9928.       Y = XY.subarray(0x10 * lim);
  9929.       blkcpy(X, B, 0, 0, lim);
  9930.       i = 0;
  9931.       (function(__iced_k) {
  9932.         var _results, _while;
  9933.         _results = [];
  9934.         _while = function(__iced_k) {
  9935.           var _break, _continue, _next;
  9936.           _break = function() {
  9937.             return __iced_k(_results);
  9938.           };
  9939.           _continue = function() {
  9940.             return iced.trampoline(function() {
  9941.               return _while(__iced_k);
  9942.             });
  9943.           };
  9944.           _next = function(__iced_next_arg) {
  9945.             _results.push(__iced_next_arg);
  9946.             return _continue();
  9947.           };
  9948.           if (!(i < _this.N)) {
  9949.             return _break();
  9950.           } else {
  9951.             stop = Math.min(_this.N, i + 2048);
  9952.             while (i < stop) {
  9953.               blkcpy(V, X, lim * i, 0, lim);
  9954.               _this.blockmix_salsa8(X, Y);
  9955.               i++;
  9956.             }
  9957.             if (typeof progress_hook === "function") {
  9958.               progress_hook(i);
  9959.             }
  9960.             (function(__iced_k) {
  9961.               __iced_deferrals = new iced.Deferrals(__iced_k, {
  9962.                 parent: ___iced_passed_deferral,
  9963.                 filename: "src/scrypt.iced",
  9964.                 funcname: "Scrypt.smix"
  9965.               });
  9966.               default_delay(0, 0, __iced_deferrals.defer({
  9967.                 lineno: 156
  9968.               }));
  9969.               __iced_deferrals._fulfill();
  9970.             })(_next);
  9971.           }
  9972.         };
  9973.         _while(__iced_k);
  9974.       })(function() {
  9975.         i = 0;
  9976.         (function(__iced_k) {
  9977.           var _results, _while;
  9978.           _results = [];
  9979.           _while = function(__iced_k) {
  9980.             var _break, _continue, _next;
  9981.             _break = function() {
  9982.               return __iced_k(_results);
  9983.             };
  9984.             _continue = function() {
  9985.               return iced.trampoline(function() {
  9986.                 return _while(__iced_k);
  9987.               });
  9988.             };
  9989.             _next = function(__iced_next_arg) {
  9990.               _results.push(__iced_next_arg);
  9991.               return _continue();
  9992.             };
  9993.             if (!(i < _this.N)) {
  9994.               return _break();
  9995.             } else {
  9996.               stop = Math.min(_this.N, i + 256);
  9997.               while (i < stop) {
  9998.                 j = fixup_uint32(X[0x10 * (lim - 1)]) & (_this.N - 1);
  9999.                 blkxor(X, V, j * lim, lim);
  10000.                 _this.blockmix_salsa8(X, Y);
  10001.                 i++;
  10002.               }
  10003.               if (typeof progress_hook === "function") {
  10004.                 progress_hook(i + _this.N);
  10005.               }
  10006.               (function(__iced_k) {
  10007.                 __iced_deferrals = new iced.Deferrals(__iced_k, {
  10008.                   parent: ___iced_passed_deferral,
  10009.                   filename: "src/scrypt.iced",
  10010.                   funcname: "Scrypt.smix"
  10011.                 });
  10012.                 default_delay(0, 0, __iced_deferrals.defer({
  10013.                   lineno: 173
  10014.                 }));
  10015.                 __iced_deferrals._fulfill();
  10016.               })(_next);
  10017.             }
  10018.           };
  10019.           _while(__iced_k);
  10020.         })(function() {
  10021.           blkcpy(B, X, 0, 0, lim);
  10022.           return cb();
  10023.         });
  10024.       });
  10025.     };
  10026.  
  10027.     Scrypt.prototype.run = function(_arg, cb) {
  10028.       var B, MAX, V, XY, dkLen, err, j, key, lph, out, progress_hook, ret, salt, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  10029.         _this = this;
  10030.       __iced_k = __iced_k_noop;
  10031.       ___iced_passed_deferral = iced.findDeferral(arguments);
  10032.       key = _arg.key, salt = _arg.salt, dkLen = _arg.dkLen, progress_hook = _arg.progress_hook;
  10033.       MAX = 0xffffffff;
  10034.       err = ret = null;
  10035.       err = dkLen > MAX ? err = new Error("asked for too much data") : this.r * this.p >= (1 << 30) ? new Error("r & p are too big") : (this.r > MAX / 128 / this.p) || (this.r > MAX / 256) || (this.N > MAX / 128 / this.r) ? new Error("N is too big") : null;
  10036.       XY = new Int32Array(64 * this.r);
  10037.       V = new Int32Array(32 * this.r * this.N);
  10038.       lph = function(o) {
  10039.         o.what += " (pass 1)";
  10040.         return typeof progress_hook === "function" ? progress_hook(o) : void 0;
  10041.       };
  10042.       (function(__iced_k) {
  10043.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  10044.           parent: ___iced_passed_deferral,
  10045.           filename: "src/scrypt.iced",
  10046.           funcname: "Scrypt.run"
  10047.         });
  10048.         _this.pbkdf2({
  10049.           key: key.clone(),
  10050.           salt: salt,
  10051.           dkLen: 128 * _this.r * _this.p,
  10052.           c: _this.c0,
  10053.           progress_hook: lph
  10054.         }, __iced_deferrals.defer({
  10055.           assign_fn: (function() {
  10056.             return function() {
  10057.               return B = arguments[0];
  10058.             };
  10059.           })(),
  10060.           lineno: 204
  10061.         }));
  10062.         __iced_deferrals._fulfill();
  10063.       })(function() {
  10064.         B = new Int32Array(B.words);
  10065.         v_endian_reverse(B);
  10066.         lph = function(j) {
  10067.           return function(i) {
  10068.             return typeof progress_hook === "function" ? progress_hook({
  10069.               i: i + j * _this.N * 2,
  10070.               what: "scrypt",
  10071.               total: _this.p * _this.N * 2
  10072.             }) : void 0;
  10073.           };
  10074.         };
  10075.         (function(__iced_k) {
  10076.           var _i, _results, _while;
  10077.           j = 0;
  10078.           _results = [];
  10079.           _while = function(__iced_k) {
  10080.             var _break, _continue, _next;
  10081.             _break = function() {
  10082.               return __iced_k(_results);
  10083.             };
  10084.             _continue = function() {
  10085.               return iced.trampoline(function() {
  10086.                 ++j;
  10087.                 return _while(__iced_k);
  10088.               });
  10089.             };
  10090.             _next = function(__iced_next_arg) {
  10091.               _results.push(__iced_next_arg);
  10092.               return _continue();
  10093.             };
  10094.             if (!(j < _this.p)) {
  10095.               return _break();
  10096.             } else {
  10097.  
  10098.               (function(__iced_k) {
  10099.                 __iced_deferrals = new iced.Deferrals(__iced_k, {
  10100.                   parent: ___iced_passed_deferral,
  10101.                   filename: "src/scrypt.iced",
  10102.                   funcname: "Scrypt.run"
  10103.                 });
  10104.                 _this.smix({
  10105.                   B: B.subarray(32 * _this.r * j),
  10106.                   V: V,
  10107.                   XY: XY,
  10108.                   progress_hook: lph(j)
  10109.                 }, __iced_deferrals.defer({
  10110.                   lineno: 211
  10111.                 }));
  10112.                 __iced_deferrals._fulfill();
  10113.               })(_next);
  10114.             }
  10115.           };
  10116.           _while(__iced_k);
  10117.         })(function() {
  10118.           v_endian_reverse(B);
  10119.           lph = function(o) {
  10120.             o.what += " (pass 2)";
  10121.             return typeof progress_hook === "function" ? progress_hook(o) : void 0;
  10122.           };
  10123.           (function(__iced_k) {
  10124.             __iced_deferrals = new iced.Deferrals(__iced_k, {
  10125.               parent: ___iced_passed_deferral,
  10126.               filename: "src/scrypt.iced",
  10127.               funcname: "Scrypt.run"
  10128.             });
  10129.             _this.pbkdf2({
  10130.               key: key,
  10131.               salt: WordArray.from_i32a(B),
  10132.               dkLen: dkLen,
  10133.               c: _this.c1,
  10134.               progress_hook: lph
  10135.             }, __iced_deferrals.defer({
  10136.               assign_fn: (function() {
  10137.                 return function() {
  10138.                   return out = arguments[0];
  10139.                 };
  10140.               })(),
  10141.               lineno: 219
  10142.             }));
  10143.             __iced_deferrals._fulfill();
  10144.           })(function() {
  10145.             scrub_vec(XY);
  10146.             scrub_vec(V);
  10147.             scrub_vec(B);
  10148.             key.scrub();
  10149.             return cb(out);
  10150.           });
  10151.         });
  10152.       });
  10153.     };
  10154.  
  10155.     return Scrypt;
  10156.  
  10157.   })();
  10158.  
  10159.   scrypt = function(_arg, cb) {
  10160.     var N, c, c0, c1, dkLen, eng, key, klass, p, progress_hook, r, salt, wa, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  10161.       _this = this;
  10162.     __iced_k = __iced_k_noop;
  10163.     ___iced_passed_deferral = iced.findDeferral(arguments);
  10164.     key = _arg.key, salt = _arg.salt, r = _arg.r, N = _arg.N, p = _arg.p, c0 = _arg.c0, c1 = _arg.c1, c = _arg.c, klass = _arg.klass, progress_hook = _arg.progress_hook, dkLen = _arg.dkLen;
  10165.     eng = new Scrypt({
  10166.       r: r,
  10167.       N: N,
  10168.       p: p,
  10169.       c: c,
  10170.       c0: c0,
  10171.       c1: c1,
  10172.       klass: klass
  10173.     });
  10174.     (function(__iced_k) {
  10175.       __iced_deferrals = new iced.Deferrals(__iced_k, {
  10176.         parent: ___iced_passed_deferral,
  10177.         filename: "src/scrypt.iced",
  10178.         funcname: "scrypt"
  10179.       });
  10180.       eng.run({
  10181.         key: key,
  10182.         salt: salt,
  10183.         progress_hook: progress_hook,
  10184.         dkLen: dkLen
  10185.       }, __iced_deferrals.defer({
  10186.         assign_fn: (function() {
  10187.           return function() {
  10188.             return wa = arguments[0];
  10189.           };
  10190.         })(),
  10191.         lineno: 249
  10192.       }));
  10193.       __iced_deferrals._fulfill();
  10194.     })(function() {
  10195.       return cb(wa);
  10196.     });
  10197.   };
  10198.  
  10199.   exports.Scrypt = Scrypt;
  10200.  
  10201.   exports.scrypt = scrypt;
  10202.  
  10203.   exports.v_endian_reverse = v_endian_reverse;
  10204.  
  10205. }).call(this);
  10206.  
  10207. },{"./hmac":24,"./pbkdf2":27,"./salsa20":29,"./util":37,"./wordarray":38,"iced-coffee-script/lib/coffee-script/iced":9}],31:[function(require,module,exports){
  10208. // Generated by IcedCoffeeScript 1.6.3-g
  10209. (function() {
  10210.   var Hasher, SHA1, W, WordArray, transform, _ref,
  10211.     __hasProp = {}.hasOwnProperty,
  10212.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  10213.  
  10214.  
  10215.  
  10216.   WordArray = require('./wordarray').WordArray;
  10217.  
  10218.   Hasher = require('./algbase').Hasher;
  10219.  
  10220.   W = [];
  10221.  
  10222.   SHA1 = (function(_super) {
  10223.     __extends(SHA1, _super);
  10224.  
  10225.     function SHA1() {
  10226.       _ref = SHA1.__super__.constructor.apply(this, arguments);
  10227.       return _ref;
  10228.     }
  10229.  
  10230.     SHA1.blockSize = 512 / 32;
  10231.  
  10232.     SHA1.prototype.blockSize = SHA1.blockSize;
  10233.  
  10234.     SHA1.output_size = 20;
  10235.  
  10236.     SHA1.prototype.output_size = SHA1.output_size;
  10237.  
  10238.     SHA1.prototype._doReset = function() {
  10239.       return this._hash = new WordArray([0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]);
  10240.     };
  10241.  
  10242.     SHA1.prototype._doProcessBlock = function(M, offset) {
  10243.       var H, a, b, c, d, e, i, n, t, _i;
  10244.       H = this._hash.words;
  10245.       a = H[0];
  10246.       b = H[1];
  10247.       c = H[2];
  10248.       d = H[3];
  10249.       e = H[4];
  10250.       for (i = _i = 0; _i < 80; i = ++_i) {
  10251.         if (i < 16) {
  10252.           W[i] = M[offset + i] | 0;
  10253.         } else {
  10254.           n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
  10255.           W[i] = (n << 1) | (n >>> 31);
  10256.         }
  10257.         t = ((a << 5) | (a >>> 27)) + e + W[i];
  10258.         if (i < 20) {
  10259.           t += ((b & c) | (~b & d)) + 0x5a827999;
  10260.         } else if (i < 40) {
  10261.           t += (b ^ c ^ d) + 0x6ed9eba1;
  10262.         } else if (i < 60) {
  10263.           t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
  10264.         } else {
  10265.           t += (b ^ c ^ d) - 0x359d3e2a;
  10266.         }
  10267.         e = d;
  10268.         d = c;
  10269.         c = (b << 30) | (b >>> 2);
  10270.         b = a;
  10271.         a = t;
  10272.       }
  10273.       H[0] = (H[0] + a) | 0;
  10274.       H[1] = (H[1] + b) | 0;
  10275.       H[2] = (H[2] + c) | 0;
  10276.       H[3] = (H[3] + d) | 0;
  10277.       return H[4] = (H[4] + e) | 0;
  10278.     };
  10279.  
  10280.     SHA1.prototype._doFinalize = function() {
  10281.       var data, dataWords, nBitsLeft, nBitsTotal;
  10282.       data = this._data;
  10283.       dataWords = data.words;
  10284.       nBitsTotal = this._nDataBytes * 8;
  10285.       nBitsLeft = data.sigBytes * 8;
  10286.       dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  10287.       dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  10288.       dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  10289.       data.sigBytes = dataWords.length * 4;
  10290.       this._process();
  10291.       return this._hash;
  10292.     };
  10293.  
  10294.     SHA1.prototype.copy_to = function(obj) {
  10295.       SHA1.__super__.copy_to.call(this, obj);
  10296.       return obj._hash = this._hash.clone();
  10297.     };
  10298.  
  10299.     SHA1.prototype.clone = function() {
  10300.       var out;
  10301.       out = new SHA1();
  10302.       this.copy_to(out);
  10303.       return out;
  10304.     };
  10305.  
  10306.     return SHA1;
  10307.  
  10308.   })(Hasher);
  10309.  
  10310.   transform = transform = function(x) {
  10311.     var out;
  10312.     out = (new SHA1).finalize(x);
  10313.     x.scrub();
  10314.     return out;
  10315.   };
  10316.  
  10317.   exports.SHA1 = SHA1;
  10318.  
  10319.   exports.transform = transform;
  10320.  
  10321. }).call(this);
  10322.  
  10323. },{"./algbase":18,"./wordarray":38}],32:[function(require,module,exports){
  10324. // Generated by IcedCoffeeScript 1.6.3-g
  10325. (function() {
  10326.   var SHA224, SHA256, WordArray, transform, _ref,
  10327.     __hasProp = {}.hasOwnProperty,
  10328.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  10329.  
  10330.  
  10331.  
  10332.   WordArray = require('./wordarray').WordArray;
  10333.  
  10334.   SHA256 = require('./sha256').SHA256;
  10335.  
  10336.   SHA224 = (function(_super) {
  10337.     __extends(SHA224, _super);
  10338.  
  10339.     function SHA224() {
  10340.       _ref = SHA224.__super__.constructor.apply(this, arguments);
  10341.       return _ref;
  10342.     }
  10343.  
  10344.     SHA224.prototype._doReset = function() {
  10345.       return this._hash = new WordArray([0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4]);
  10346.     };
  10347.  
  10348.     SHA224.prototype._doFinalize = function() {
  10349.       var hash;
  10350.       hash = SHA224.__super__._doFinalize.call(this);
  10351.       hash.sigBytes -= 4;
  10352.       return hash;
  10353.     };
  10354.  
  10355.     SHA224.prototype.clone = function() {
  10356.       var out;
  10357.       out = new SHA224();
  10358.       this.copy_to(out);
  10359.       return out;
  10360.     };
  10361.  
  10362.     return SHA224;
  10363.  
  10364.   })(SHA256);
  10365.  
  10366.   transform = function(x) {
  10367.     var out;
  10368.     out = (new SHA224).finalize(x);
  10369.     x.scrub();
  10370.     return out;
  10371.   };
  10372.  
  10373.   exports.SHA224 = SHA224;
  10374.  
  10375.   exports.transform = transform;
  10376.  
  10377. }).call(this);
  10378.  
  10379. },{"./sha256":33,"./wordarray":38}],33:[function(require,module,exports){
  10380. // Generated by IcedCoffeeScript 1.6.3-g
  10381. (function() {
  10382.   var Global, Hasher, SHA256, WordArray, glbl, transform, _ref,
  10383.     __hasProp = {}.hasOwnProperty,
  10384.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  10385.  
  10386.  
  10387.  
  10388.   WordArray = require('./wordarray').WordArray;
  10389.  
  10390.   Hasher = require('./algbase').Hasher;
  10391.  
  10392.   Global = (function() {
  10393.     function Global() {
  10394.       this.H = [];
  10395.       this.K = [];
  10396.       this.W = [];
  10397.       this.init();
  10398.     }
  10399.  
  10400.     Global.prototype.isPrime = function(n) {
  10401.       var f, sqn, _i;
  10402.       if (n === 2 || n === 3 || n === 5 || n === 7) {
  10403.         return true;
  10404.       }
  10405.       if (n === 1 || n === 4 || n === 6 || n === 8 || n === 9) {
  10406.         return false;
  10407.       }
  10408.       sqn = Math.ceil(Math.sqrt(n));
  10409.       for (f = _i = 2; 2 <= sqn ? _i <= sqn : _i >= sqn; f = 2 <= sqn ? ++_i : --_i) {
  10410.         if ((n % f) === 0) {
  10411.           return false;
  10412.         }
  10413.       }
  10414.       return true;
  10415.     };
  10416.  
  10417.     Global.prototype.getFractionalBits = function(n) {
  10418.       return ((n - (n | 0)) * 0x100000000) | 0;
  10419.     };
  10420.  
  10421.     Global.prototype.init = function() {
  10422.       var n, nPrime, _results;
  10423.       n = 2;
  10424.       nPrime = 0;
  10425.       _results = [];
  10426.       while (nPrime < 64) {
  10427.         if (this.isPrime(n)) {
  10428.           if (nPrime < 8) {
  10429.             this.H[nPrime] = this.getFractionalBits(Math.pow(n, 1 / 2));
  10430.           }
  10431.           this.K[nPrime] = this.getFractionalBits(Math.pow(n, 1 / 3));
  10432.           nPrime++;
  10433.         }
  10434.         _results.push(n++);
  10435.       }
  10436.       return _results;
  10437.     };
  10438.  
  10439.     return Global;
  10440.  
  10441.   })();
  10442.  
  10443.   glbl = new Global();
  10444.  
  10445.   SHA256 = (function(_super) {
  10446.     __extends(SHA256, _super);
  10447.  
  10448.     function SHA256() {
  10449.       _ref = SHA256.__super__.constructor.apply(this, arguments);
  10450.       return _ref;
  10451.     }
  10452.  
  10453.     SHA256.blockSize = 512 / 32;
  10454.  
  10455.     SHA256.prototype.blockSize = SHA256.blockSize;
  10456.  
  10457.     SHA256.output_size = 256 / 8;
  10458.  
  10459.     SHA256.prototype.output_size = SHA256.output_size;
  10460.  
  10461.     SHA256.prototype._doReset = function() {
  10462.       return this._hash = new WordArray(glbl.H.slice(0));
  10463.     };
  10464.  
  10465.     SHA256.prototype.get_output_size = function() {
  10466.       return this.output_size;
  10467.     };
  10468.  
  10469.     SHA256.prototype._doProcessBlock = function(M, offset) {
  10470.       var H, K, W, a, b, c, ch, d, e, f, g, gamma0, gamma0x, gamma1, gamma1x, h, i, maj, sigma0, sigma1, t1, t2, _i;
  10471.       H = this._hash.words;
  10472.       W = glbl.W;
  10473.       K = glbl.K;
  10474.       a = H[0];
  10475.       b = H[1];
  10476.       c = H[2];
  10477.       d = H[3];
  10478.       e = H[4];
  10479.       f = H[5];
  10480.       g = H[6];
  10481.       h = H[7];
  10482.       for (i = _i = 0; _i < 64; i = ++_i) {
  10483.         if (i < 16) {
  10484.           W[i] = M[offset + i] | 0;
  10485.         } else {
  10486.           gamma0x = W[i - 15];
  10487.           gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^ ((gamma0x << 14) | (gamma0x >>> 18)) ^ (gamma0x >>> 3);
  10488.           gamma1x = W[i - 2];
  10489.           gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^ ((gamma1x << 13) | (gamma1x >>> 19)) ^ (gamma1x >>> 10);
  10490.           W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
  10491.         }
  10492.         ch = (e & f) ^ (~e & g);
  10493.         maj = (a & b) ^ (a & c) ^ (b & c);
  10494.         sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
  10495.         sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
  10496.         t1 = h + sigma1 + ch + K[i] + W[i];
  10497.         t2 = sigma0 + maj;
  10498.         h = g;
  10499.         g = f;
  10500.         f = e;
  10501.         e = (d + t1) | 0;
  10502.         d = c;
  10503.         c = b;
  10504.         b = a;
  10505.         a = (t1 + t2) | 0;
  10506.       }
  10507.       H[0] = (H[0] + a) | 0;
  10508.       H[1] = (H[1] + b) | 0;
  10509.       H[2] = (H[2] + c) | 0;
  10510.       H[3] = (H[3] + d) | 0;
  10511.       H[4] = (H[4] + e) | 0;
  10512.       H[5] = (H[5] + f) | 0;
  10513.       H[6] = (H[6] + g) | 0;
  10514.       return H[7] = (H[7] + h) | 0;
  10515.     };
  10516.  
  10517.     SHA256.prototype._doFinalize = function() {
  10518.       var data, dataWords, nBitsLeft, nBitsTotal;
  10519.       data = this._data;
  10520.       dataWords = data.words;
  10521.       nBitsTotal = this._nDataBytes * 8;
  10522.       nBitsLeft = data.sigBytes * 8;
  10523.       dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  10524.       dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  10525.       dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  10526.       data.sigBytes = dataWords.length * 4;
  10527.       this._process();
  10528.       return this._hash;
  10529.     };
  10530.  
  10531.     SHA256.prototype.scrub = function() {
  10532.       return this._hash.scrub();
  10533.     };
  10534.  
  10535.     SHA256.prototype.copy_to = function(obj) {
  10536.       SHA256.__super__.copy_to.call(this, obj);
  10537.       return obj._hash = this._hash.clone();
  10538.     };
  10539.  
  10540.     SHA256.prototype.clone = function() {
  10541.       var out;
  10542.       out = new SHA256();
  10543.       this.copy_to(out);
  10544.       return out;
  10545.     };
  10546.  
  10547.     return SHA256;
  10548.  
  10549.   })(Hasher);
  10550.  
  10551.   transform = function(x) {
  10552.     var out;
  10553.     out = (new SHA256).finalize(x);
  10554.     x.scrub();
  10555.     return out;
  10556.   };
  10557.  
  10558.   exports.SHA256 = SHA256;
  10559.  
  10560.   exports.transform = transform;
  10561.  
  10562. }).call(this);
  10563.  
  10564. },{"./algbase":18,"./wordarray":38}],34:[function(require,module,exports){
  10565. // Generated by IcedCoffeeScript 1.6.3-g
  10566. (function() {
  10567.   var Global, Hasher, SHA3, WordArray, X64Word, X64WordArray, glbl, _ref, _ref1,
  10568.     __hasProp = {}.hasOwnProperty,
  10569.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  10570.  
  10571.  
  10572.  
  10573.   _ref = require('./wordarray'), WordArray = _ref.WordArray, X64Word = _ref.X64Word, X64WordArray = _ref.X64WordArray;
  10574.  
  10575.   Hasher = require('./algbase').Hasher;
  10576.  
  10577.   Global = (function() {
  10578.     function Global() {
  10579.       this.RHO_OFFSETS = [];
  10580.       this.PI_INDEXES = [];
  10581.       this.ROUND_CONSTANTS = [];
  10582.       this.T = [];
  10583.       this.compute_rho_offsets();
  10584.       this.compute_pi_indexes();
  10585.       this.compute_round_constants();
  10586.       this.make_reusables();
  10587.     }
  10588.  
  10589.     Global.prototype.compute_rho_offsets = function() {
  10590.       var newX, newY, t, x, y, _i, _results;
  10591.       x = 1;
  10592.       y = 0;
  10593.       _results = [];
  10594.       for (t = _i = 0; _i < 24; t = ++_i) {
  10595.         this.RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
  10596.         newX = y % 5;
  10597.         newY = (2 * x + 3 * y) % 5;
  10598.         x = newX;
  10599.         _results.push(y = newY);
  10600.       }
  10601.       return _results;
  10602.     };
  10603.  
  10604.     Global.prototype.compute_pi_indexes = function() {
  10605.       var x, y, _i, _results;
  10606.       _results = [];
  10607.       for (x = _i = 0; _i < 5; x = ++_i) {
  10608.         _results.push((function() {
  10609.           var _j, _results1;
  10610.           _results1 = [];
  10611.           for (y = _j = 0; _j < 5; y = ++_j) {
  10612.             _results1.push(this.PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5);
  10613.           }
  10614.           return _results1;
  10615.         }).call(this));
  10616.       }
  10617.       return _results;
  10618.     };
  10619.  
  10620.     Global.prototype.compute_round_constants = function() {
  10621.       var LFSR, bitPosition, i, j, roundConstantLsw, roundConstantMsw, _i, _j, _results;
  10622.       LFSR = 0x01;
  10623.       _results = [];
  10624.       for (i = _i = 0; _i < 24; i = ++_i) {
  10625.         roundConstantMsw = 0;
  10626.         roundConstantLsw = 0;
  10627.         for (j = _j = 0; _j < 7; j = ++_j) {
  10628.           if (LFSR & 0x01) {
  10629.             bitPosition = (1 << j) - 1;
  10630.             if (bitPosition < 32) {
  10631.               roundConstantLsw ^= 1 << bitPosition;
  10632.             } else {
  10633.               roundConstantMsw ^= 1 << (bitPosition - 32);
  10634.             }
  10635.           }
  10636.           if (LFSR & 0x80) {
  10637.             LFSR = (LFSR << 1) ^ 0x71;
  10638.           } else {
  10639.             LFSR <<= 1;
  10640.           }
  10641.         }
  10642.         _results.push(this.ROUND_CONSTANTS[i] = new X64Word(roundConstantMsw, roundConstantLsw));
  10643.       }
  10644.       return _results;
  10645.     };
  10646.  
  10647.     Global.prototype.make_reusables = function() {
  10648.       var i;
  10649.       return this.T = (function() {
  10650.         var _i, _results;
  10651.         _results = [];
  10652.         for (i = _i = 0; _i < 25; i = ++_i) {
  10653.           _results.push(new X64Word(0, 0));
  10654.         }
  10655.         return _results;
  10656.       })();
  10657.     };
  10658.  
  10659.     return Global;
  10660.  
  10661.   })();
  10662.  
  10663.   glbl = new Global();
  10664.  
  10665.   exports.SHA3 = SHA3 = (function(_super) {
  10666.     __extends(SHA3, _super);
  10667.  
  10668.     function SHA3() {
  10669.       _ref1 = SHA3.__super__.constructor.apply(this, arguments);
  10670.       return _ref1;
  10671.     }
  10672.  
  10673.     SHA3.outputLength = 512;
  10674.  
  10675.     SHA3.prototype.outputLength = SHA3.outputLength;
  10676.  
  10677.     SHA3.blockSize = (1600 - 2 * SHA3.outputLength) / 32;
  10678.  
  10679.     SHA3.prototype.blockSize = SHA3.blockSize;
  10680.  
  10681.     SHA3.output_size = SHA3.outputLength / 8;
  10682.  
  10683.     SHA3.prototype.output_size = SHA3.output_size;
  10684.  
  10685.     SHA3.prototype._doReset = function() {
  10686.       var i;
  10687.       return this._state = (function() {
  10688.         var _i, _results;
  10689.         _results = [];
  10690.         for (i = _i = 0; _i < 25; i = ++_i) {
  10691.           _results.push(new X64Word(0, 0));
  10692.         }
  10693.         return _results;
  10694.       })();
  10695.     };
  10696.  
  10697.     SHA3.prototype._doProcessBlock = function(M, offset) {
  10698.       var G, M2i, M2i1, T0, TLane, TPiLane, Tx, Tx1, Tx1Lane, Tx1Lsw, Tx1Msw, Tx2Lane, Tx4, i, lane, laneIndex, laneLsw, laneMsw, nBlockSizeLanes, rhoOffset, round, roundConstant, state, state0, tLsw, tMsw, x, y, _i, _j, _k, _l, _m, _n, _o, _p, _q, _results;
  10699.       G = glbl;
  10700.       state = this._state;
  10701.       nBlockSizeLanes = this.blockSize / 2;
  10702.       for (i = _i = 0; 0 <= nBlockSizeLanes ? _i < nBlockSizeLanes : _i > nBlockSizeLanes; i = 0 <= nBlockSizeLanes ? ++_i : --_i) {
  10703.         M2i = M[offset + 2 * i];
  10704.         M2i1 = M[offset + 2 * i + 1];
  10705.         M2i = (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) | (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00);
  10706.         M2i1 = (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) | (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00);
  10707.         lane = state[i];
  10708.         lane.high ^= M2i1;
  10709.         lane.low ^= M2i;
  10710.       }
  10711.       _results = [];
  10712.       for (round = _j = 0; _j < 24; round = ++_j) {
  10713.         for (x = _k = 0; _k < 5; x = ++_k) {
  10714.           tMsw = tLsw = 0;
  10715.           for (y = _l = 0; _l < 5; y = ++_l) {
  10716.             lane = state[x + 5 * y];
  10717.             tMsw ^= lane.high;
  10718.             tLsw ^= lane.low;
  10719.           }
  10720.           Tx = G.T[x];
  10721.           Tx.high = tMsw;
  10722.           Tx.low = tLsw;
  10723.         }
  10724.         for (x = _m = 0; _m < 5; x = ++_m) {
  10725.           Tx4 = G.T[(x + 4) % 5];
  10726.           Tx1 = G.T[(x + 1) % 5];
  10727.           Tx1Msw = Tx1.high;
  10728.           Tx1Lsw = Tx1.low;
  10729.           tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
  10730.           tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
  10731.           for (y = _n = 0; _n < 5; y = ++_n) {
  10732.             lane = state[x + 5 * y];
  10733.             lane.high ^= tMsw;
  10734.             lane.low ^= tLsw;
  10735.           }
  10736.         }
  10737.         for (laneIndex = _o = 1; _o < 25; laneIndex = ++_o) {
  10738.           lane = state[laneIndex];
  10739.           laneMsw = lane.high;
  10740.           laneLsw = lane.low;
  10741.           rhoOffset = G.RHO_OFFSETS[laneIndex];
  10742.           if (rhoOffset < 32) {
  10743.             tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
  10744.             tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
  10745.           } else {
  10746.             tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
  10747.             tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
  10748.           }
  10749.           TPiLane = G.T[G.PI_INDEXES[laneIndex]];
  10750.           TPiLane.high = tMsw;
  10751.           TPiLane.low = tLsw;
  10752.         }
  10753.         T0 = G.T[0];
  10754.         state0 = state[0];
  10755.         T0.high = state0.high;
  10756.         T0.low = state0.low;
  10757.         for (x = _p = 0; _p < 5; x = ++_p) {
  10758.           for (y = _q = 0; _q < 5; y = ++_q) {
  10759.             laneIndex = x + 5 * y;
  10760.             lane = state[laneIndex];
  10761.             TLane = G.T[laneIndex];
  10762.             Tx1Lane = G.T[((x + 1) % 5) + 5 * y];
  10763.             Tx2Lane = G.T[((x + 2) % 5) + 5 * y];
  10764.             lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
  10765.             lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
  10766.           }
  10767.         }
  10768.         lane = state[0];
  10769.         roundConstant = G.ROUND_CONSTANTS[round];
  10770.         lane.high ^= roundConstant.high;
  10771.         _results.push(lane.low ^= roundConstant.low);
  10772.       }
  10773.       return _results;
  10774.     };
  10775.  
  10776.     SHA3.prototype._doFinalize = function() {
  10777.       var blockSizeBits, data, dataWords, hashWords, i, lane, laneLsw, laneMsw, nBitsLeft, nBitsTotal, outputLengthBytes, outputLengthLanes, state, _i;
  10778.       data = this._data;
  10779.       dataWords = data.words;
  10780.       nBitsTotal = this._nDataBytes * 8;
  10781.       nBitsLeft = data.sigBytes * 8;
  10782.       blockSizeBits = this.blockSize * 32;
  10783.       dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
  10784.       dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
  10785.       data.sigBytes = dataWords.length * 4;
  10786.       this._process();
  10787.       state = this._state;
  10788.       outputLengthBytes = this.outputLength / 8;
  10789.       outputLengthLanes = outputLengthBytes / 8;
  10790.       hashWords = [];
  10791.       for (i = _i = 0; 0 <= outputLengthLanes ? _i < outputLengthLanes : _i > outputLengthLanes; i = 0 <= outputLengthLanes ? ++_i : --_i) {
  10792.         lane = state[i];
  10793.         laneMsw = lane.high;
  10794.         laneLsw = lane.low;
  10795.         laneMsw = (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) | (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00);
  10796.         laneLsw = (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) | (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00);
  10797.         hashWords.push(laneLsw);
  10798.         hashWords.push(laneMsw);
  10799.       }
  10800.       return new WordArray(hashWords, outputLengthBytes);
  10801.     };
  10802.  
  10803.     SHA3.prototype.copy_to = function(obj) {
  10804.       var s;
  10805.       SHA3.__super__.copy_to.call(this, obj);
  10806.       return obj._state = (function() {
  10807.         var _i, _len, _ref2, _results;
  10808.         _ref2 = this._state;
  10809.         _results = [];
  10810.         for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
  10811.           s = _ref2[_i];
  10812.           _results.push(s.clone());
  10813.         }
  10814.         return _results;
  10815.       }).call(this);
  10816.     };
  10817.  
  10818.     SHA3.prototype.scrub = function() {};
  10819.  
  10820.     SHA3.prototype.clone = function() {
  10821.       var out;
  10822.       out = new SHA3();
  10823.       this.copy_to(out);
  10824.       return out;
  10825.     };
  10826.  
  10827.     return SHA3;
  10828.  
  10829.   })(Hasher);
  10830.  
  10831.   exports.transform = function(x) {
  10832.     var out;
  10833.     out = (new SHA3).finalize(x);
  10834.     x.scrub();
  10835.     return out;
  10836.   };
  10837.  
  10838. }).call(this);
  10839.  
  10840. },{"./algbase":18,"./wordarray":38}],35:[function(require,module,exports){
  10841. // Generated by IcedCoffeeScript 1.6.3-g
  10842. (function() {
  10843.   var Global, Hasher, SHA512, X64Word, X64WordArray, glbl, _ref, _ref1,
  10844.     __hasProp = {}.hasOwnProperty,
  10845.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  10846.  
  10847.  
  10848.  
  10849.   _ref = require('./wordarray'), X64Word = _ref.X64Word, X64WordArray = _ref.X64WordArray;
  10850.  
  10851.   Hasher = require('./algbase').Hasher;
  10852.  
  10853.   Global = (function() {
  10854.     Global.prototype.convert = function(raw) {
  10855.       var i, _i, _ref1, _results;
  10856.       _results = [];
  10857.       for (i = _i = 0, _ref1 = raw.length; _i < _ref1; i = _i += 2) {
  10858.         _results.push(new X64Word(raw[i], raw[i + 1]));
  10859.       }
  10860.       return _results;
  10861.     };
  10862.  
  10863.     function Global() {
  10864.       var i;
  10865.       this.K = this.convert([0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817]);
  10866.       this.I = new X64WordArray(this.convert([0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1, 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179]));
  10867.       this.W = (function() {
  10868.         var _i, _results;
  10869.         _results = [];
  10870.         for (i = _i = 0; _i < 80; i = ++_i) {
  10871.           _results.push(new X64Word(0, 0));
  10872.         }
  10873.         return _results;
  10874.       })();
  10875.     }
  10876.  
  10877.     return Global;
  10878.  
  10879.   })();
  10880.  
  10881.   glbl = new Global();
  10882.  
  10883.   exports.SHA512 = SHA512 = (function(_super) {
  10884.     __extends(SHA512, _super);
  10885.  
  10886.     function SHA512() {
  10887.       _ref1 = SHA512.__super__.constructor.apply(this, arguments);
  10888.       return _ref1;
  10889.     }
  10890.  
  10891.     SHA512.blockSize = 1024 / 32;
  10892.  
  10893.     SHA512.prototype.blockSize = SHA512.blockSize;
  10894.  
  10895.     SHA512.output_size = 512 / 8;
  10896.  
  10897.     SHA512.prototype.output_size = SHA512.output_size;
  10898.  
  10899.     SHA512.prototype._doReset = function() {
  10900.       return this._hash = glbl.I.clone();
  10901.     };
  10902.  
  10903.     SHA512.prototype._doProcessBlock = function(M, offset) {
  10904.       var H, H0, H0h, H0l, H1, H1h, H1l, H2, H2h, H2l, H3, H3h, H3l, H4, H4h, H4l, H5, H5h, H5l, H6, H6h, H6l, H7, H7h, H7l, Ki, Kih, Kil, W, Wi, Wi16, Wi16h, Wi16l, Wi7, Wi7h, Wi7l, Wih, Wil, ah, al, bh, bl, ch, chh, chl, cl, dh, dl, eh, el, fh, fl, gamma0h, gamma0l, gamma0x, gamma0xh, gamma0xl, gamma1h, gamma1l, gamma1x, gamma1xh, gamma1xl, gh, gl, hh, hl, i, majh, majl, sigma0h, sigma0l, sigma1h, sigma1l, t1h, t1l, t2h, t2l, _i;
  10905.       H = this._hash.words;
  10906.       W = glbl.W;
  10907.       H0 = H[0];
  10908.       H1 = H[1];
  10909.       H2 = H[2];
  10910.       H3 = H[3];
  10911.       H4 = H[4];
  10912.       H5 = H[5];
  10913.       H6 = H[6];
  10914.       H7 = H[7];
  10915.       H0h = H0.high;
  10916.       H0l = H0.low;
  10917.       H1h = H1.high;
  10918.       H1l = H1.low;
  10919.       H2h = H2.high;
  10920.       H2l = H2.low;
  10921.       H3h = H3.high;
  10922.       H3l = H3.low;
  10923.       H4h = H4.high;
  10924.       H4l = H4.low;
  10925.       H5h = H5.high;
  10926.       H5l = H5.low;
  10927.       H6h = H6.high;
  10928.       H6l = H6.low;
  10929.       H7h = H7.high;
  10930.       H7l = H7.low;
  10931.       ah = H0h;
  10932.       al = H0l;
  10933.       bh = H1h;
  10934.       bl = H1l;
  10935.       ch = H2h;
  10936.       cl = H2l;
  10937.       dh = H3h;
  10938.       dl = H3l;
  10939.       eh = H4h;
  10940.       el = H4l;
  10941.       fh = H5h;
  10942.       fl = H5l;
  10943.       gh = H6h;
  10944.       gl = H6l;
  10945.       hh = H7h;
  10946.       hl = H7l;
  10947.       for (i = _i = 0; _i < 80; i = ++_i) {
  10948.         Wi = W[i];
  10949.         if (i < 16) {
  10950.           Wih = Wi.high = M[offset + i * 2] | 0;
  10951.           Wil = Wi.low = M[offset + i * 2 + 1] | 0;
  10952.         } else {
  10953.           gamma0x = W[i - 15];
  10954.           gamma0xh = gamma0x.high;
  10955.           gamma0xl = gamma0x.low;
  10956.           gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
  10957.           gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
  10958.           gamma1x = W[i - 2];
  10959.           gamma1xh = gamma1x.high;
  10960.           gamma1xl = gamma1x.low;
  10961.           gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
  10962.           gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
  10963.           Wi7 = W[i - 7];
  10964.           Wi7h = Wi7.high;
  10965.           Wi7l = Wi7.low;
  10966.           Wi16 = W[i - 16];
  10967.           Wi16h = Wi16.high;
  10968.           Wi16l = Wi16.low;
  10969.           Wil = gamma0l + Wi7l;
  10970.           Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
  10971.           Wil = Wil + gamma1l;
  10972.           Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
  10973.           Wil = Wil + Wi16l;
  10974.           Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
  10975.           Wi.high = Wih;
  10976.           Wi.low = Wil;
  10977.         }
  10978.         chh = (eh & fh) ^ (~eh & gh);
  10979.         chl = (el & fl) ^ (~el & gl);
  10980.         majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
  10981.         majl = (al & bl) ^ (al & cl) ^ (bl & cl);
  10982.         sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
  10983.         sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
  10984.         sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
  10985.         sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
  10986.         Ki = glbl.K[i];
  10987.         Kih = Ki.high;
  10988.         Kil = Ki.low;
  10989.         t1l = hl + sigma1l;
  10990.         t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
  10991.         t1l = t1l + chl;
  10992.         t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
  10993.         t1l = t1l + Kil;
  10994.         t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
  10995.         t1l = t1l + Wil;
  10996.         t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
  10997.         t2l = sigma0l + majl;
  10998.         t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
  10999.         hh = gh;
  11000.         hl = gl;
  11001.         gh = fh;
  11002.         gl = fl;
  11003.         fh = eh;
  11004.         fl = el;
  11005.         el = (dl + t1l) | 0;
  11006.         eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
  11007.         dh = ch;
  11008.         dl = cl;
  11009.         ch = bh;
  11010.         cl = bl;
  11011.         bh = ah;
  11012.         bl = al;
  11013.         al = (t1l + t2l) | 0;
  11014.         ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
  11015.       }
  11016.       H0l = H0.low = H0l + al;
  11017.       H0.high = H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0);
  11018.       H1l = H1.low = H1l + bl;
  11019.       H1.high = H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0);
  11020.       H2l = H2.low = H2l + cl;
  11021.       H2.high = H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0);
  11022.       H3l = H3.low = H3l + dl;
  11023.       H3.high = H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0);
  11024.       H4l = H4.low = H4l + el;
  11025.       H4.high = H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0);
  11026.       H5l = H5.low = H5l + fl;
  11027.       H5.high = H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0);
  11028.       H6l = H6.low = H6l + gl;
  11029.       H6.high = H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0);
  11030.       H7l = H7.low = H7l + hl;
  11031.       return H7.high = H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0);
  11032.     };
  11033.  
  11034.     SHA512.prototype._doFinalize = function() {
  11035.       var dataWords, nBitsLeft, nBitsTotal;
  11036.       dataWords = this._data.words;
  11037.       nBitsTotal = this._nDataBytes * 8;
  11038.       nBitsLeft = this._data.sigBytes * 8;
  11039.       dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  11040.       dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
  11041.       dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
  11042.       this._data.sigBytes = dataWords.length * 4;
  11043.       this._process();
  11044.       return this._hash.toX32();
  11045.     };
  11046.  
  11047.     SHA512.prototype.copy_to = function(obj) {
  11048.       SHA512.__super__.copy_to.call(this, obj);
  11049.       return obj._hash = this._hash.clone();
  11050.     };
  11051.  
  11052.     SHA512.prototype.clone = function() {
  11053.       var out;
  11054.       out = new SHA512();
  11055.       this.copy_to(out);
  11056.       return out;
  11057.     };
  11058.  
  11059.     return SHA512;
  11060.  
  11061.   })(Hasher);
  11062.  
  11063.   exports.transform = function(x) {
  11064.     var out;
  11065.     out = (new SHA512).finalize(x);
  11066.     x.scrub();
  11067.     return out;
  11068.   };
  11069.  
  11070. }).call(this);
  11071.  
  11072. },{"./algbase":18,"./wordarray":38}],36:[function(require,module,exports){
  11073. // Generated by IcedCoffeeScript 1.6.3-g
  11074. (function() {
  11075.   var BlockCipher, G, Global, TwoFish, scrub_vec,
  11076.     __hasProp = {}.hasOwnProperty,
  11077.     __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  11078.  
  11079.  
  11080.  
  11081.   BlockCipher = require('./algbase').BlockCipher;
  11082.  
  11083.   scrub_vec = require('./util').scrub_vec;
  11084.  
  11085.   Global = (function() {
  11086.     function Global() {
  11087.       this.P = [[0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, 0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, 0xF2, 0xD0, 0x8B, 0x30, 0x84, 0x54, 0xDF, 0x23, 0x19, 0x5B, 0x3D, 0x59, 0xF3, 0xAE, 0xA2, 0x82, 0x63, 0x01, 0x83, 0x2E, 0xD9, 0x51, 0x9B, 0x7C, 0xA6, 0xEB, 0xA5, 0xBE, 0x16, 0x0C, 0xE3, 0x61, 0xC0, 0x8C, 0x3A, 0xF5, 0x73, 0x2C, 0x25, 0x0B, 0xBB, 0x4E, 0x89, 0x6B, 0x53, 0x6A, 0xB4, 0xF1, 0xE1, 0xE6, 0xBD, 0x45, 0xE2, 0xF4, 0xB6, 0x66, 0xCC, 0x95, 0x03, 0x56, 0xD4, 0x1C, 0x1E, 0xD7, 0xFB, 0xC3, 0x8E, 0xB5, 0xE9, 0xCF, 0xBF, 0xBA, 0xEA, 0x77, 0x39, 0xAF, 0x33, 0xC9, 0x62, 0x71, 0x81, 0x79, 0x09, 0xAD, 0x24, 0xCD, 0xF9, 0xD8, 0xE5, 0xC5, 0xB9, 0x4D, 0x44, 0x08, 0x86, 0xE7, 0xA1, 0x1D, 0xAA, 0xED, 0x06, 0x70, 0xB2, 0xD2, 0x41, 0x7B, 0xA0, 0x11, 0x31, 0xC2, 0x27, 0x90, 0x20, 0xF6, 0x60, 0xFF, 0x96, 0x5C, 0xB1, 0xAB, 0x9E, 0x9C, 0x52, 0x1B, 0x5F, 0x93, 0x0A, 0xEF, 0x91, 0x85, 0x49, 0xEE, 0x2D, 0x4F, 0x8F, 0x3B, 0x47, 0x87, 0x6D, 0x46, 0xD6, 0x3E, 0x69, 0x64, 0x2A, 0xCE, 0xCB, 0x2F, 0xFC, 0x97, 0x05, 0x7A, 0xAC, 0x7F, 0xD5, 0x1A, 0x4B, 0x0E, 0xA7, 0x5A, 0x28, 0x14, 0x3F, 0x29, 0x88, 0x3C, 0x4C, 0x02, 0xB8, 0xDA, 0xB0, 0x17, 0x55, 0x1F, 0x8A, 0x7D, 0x57, 0xC7, 0x8D, 0x74, 0xB7, 0xC4, 0x9F, 0x72, 0x7E, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34, 0x6E, 0x50, 0xDE, 0x68, 0x65, 0xBC, 0xDB, 0xF8, 0xC8, 0xA8, 0x2B, 0x40, 0xDC, 0xFE, 0x32, 0xA4, 0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, 0x6F, 0x9D, 0x36, 0x42, 0x4A, 0x5E, 0xC1, 0xE0], [0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, 0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, 0x5E, 0xBA, 0xAE, 0x5B, 0x8A, 0x00, 0xBC, 0x9D, 0x6D, 0xC1, 0xB1, 0x0E, 0x80, 0x5D, 0xD2, 0xD5, 0xA0, 0x84, 0x07, 0x14, 0xB5, 0x90, 0x2C, 0xA3, 0xB2, 0x73, 0x4C, 0x54, 0x92, 0x74, 0x36, 0x51, 0x38, 0xB0, 0xBD, 0x5A, 0xFC, 0x60, 0x62, 0x96, 0x6C, 0x42, 0xF7, 0x10, 0x7C, 0x28, 0x27, 0x8C, 0x13, 0x95, 0x9C, 0xC7, 0x24, 0x46, 0x3B, 0x70, 0xCA, 0xE3, 0x85, 0xCB, 0x11, 0xD0, 0x93, 0xB8, 0xA6, 0x83, 0x20, 0xFF, 0x9F, 0x77, 0xC3, 0xCC, 0x03, 0x6F, 0x08, 0xBF, 0x40, 0xE7, 0x2B, 0xE2, 0x79, 0x0C, 0xAA, 0x82, 0x41, 0x3A, 0xEA, 0xB9, 0xE4, 0x9A, 0xA4, 0x97, 0x7E, 0xDA, 0x7A, 0x17, 0x66, 0x94, 0xA1, 0x1D, 0x3D, 0xF0, 0xDE, 0xB3, 0x0B, 0x72, 0xA7, 0x1C, 0xEF, 0xD1, 0x53, 0x3E, 0x8F, 0x33, 0x26, 0x5F, 0xEC, 0x76, 0x2A, 0x49, 0x81, 0x88, 0xEE, 0x21, 0xC4, 0x1A, 0xEB, 0xD9, 0xC5, 0x39, 0x99, 0xCD, 0xAD, 0x31, 0x8B, 0x01, 0x18, 0x23, 0xDD, 0x1F, 0x4E, 0x2D, 0xF9, 0x48, 0x4F, 0xF2, 0x65, 0x8E, 0x78, 0x5C, 0x58, 0x19, 0x8D, 0xE5, 0x98, 0x57, 0x67, 0x7F, 0x05, 0x64, 0xAF, 0x63, 0xB6, 0xFE, 0xF5, 0xB7, 0x3C, 0xA5, 0xCE, 0xE9, 0x68, 0x44, 0xE0, 0x4D, 0x43, 0x69, 0x29, 0x2E, 0xAC, 0x15, 0x59, 0xA8, 0x0A, 0x9E, 0x6E, 0x47, 0xDF, 0x34, 0x35, 0x6A, 0xCF, 0xDC, 0x22, 0xC9, 0xC0, 0x9B, 0x89, 0xD4, 0xED, 0xAB, 0x12, 0xA2, 0x0D, 0x52, 0xBB, 0x02, 0x2F, 0xA9, 0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, 0x16, 0x25, 0x86, 0x56, 0x55, 0x09, 0xBE, 0x91]];
  11088.       this.P_00 = 1;
  11089.       this.P_01 = 0;
  11090.       this.P_02 = 0;
  11091.       this.P_03 = 1;
  11092.       this.P_04 = 1;
  11093.       this.P_10 = 0;
  11094.       this.P_11 = 0;
  11095.       this.P_12 = 1;
  11096.       this.P_13 = 1;
  11097.       this.P_14 = 0;
  11098.       this.P_20 = 1;
  11099.       this.P_21 = 1;
  11100.       this.P_22 = 0;
  11101.       this.P_23 = 0;
  11102.       this.P_24 = 0;
  11103.       this.P_30 = 0;
  11104.       this.P_31 = 1;
  11105.       this.P_32 = 1;
  11106.       this.P_33 = 0;
  11107.       this.P_34 = 1;
  11108.       this.GF256_FDBK = 0x169;
  11109.       this.GF256_FDBK_2 = this.GF256_FDBK / 2;
  11110.       this.GF256_FDBK_4 = this.GF256_FDBK / 4;
  11111.       this.RS_GF_FDBK = 0x14D;
  11112.       this.SK_STEP = 0x02020202;
  11113.       this.SK_BUMP = 0x01010101;
  11114.       this.SK_ROTL = 9;
  11115.     }
  11116.  
  11117.     return Global;
  11118.  
  11119.   })();
  11120.  
  11121.   G = new Global();
  11122.  
  11123.   exports.TwoFish = TwoFish = (function(_super) {
  11124.     __extends(TwoFish, _super);
  11125.  
  11126.     TwoFish.blockSize = 4 * 4;
  11127.  
  11128.     TwoFish.prototype.blockSize = TwoFish.blockSize;
  11129.  
  11130.     TwoFish.keySize = 256 / 8;
  11131.  
  11132.     TwoFish.prototype.keySize = TwoFish.keySize;
  11133.  
  11134.     TwoFish.ivSize = TwoFish.blockSize;
  11135.  
  11136.     TwoFish.prototype.ivSize = TwoFish.ivSize;
  11137.  
  11138.     function TwoFish(key) {
  11139.       this._key = key.clone();
  11140.       this.gMDS0 = [];
  11141.       this.gMDS1 = [];
  11142.       this.gMDS2 = [];
  11143.       this.gMDS3 = [];
  11144.       this.gSubKeys = [];
  11145.       this.gSBox = [];
  11146.       this.k64Cnt = 0;
  11147.       this._doReset();
  11148.     }
  11149.  
  11150.     TwoFish.prototype.getByte = function(x, n) {
  11151.       return (x >>> (n * 8)) & 0xFF;
  11152.     };
  11153.  
  11154.     TwoFish.prototype.switchEndianness = function(word) {
  11155.       return ((word & 0xff) << 24) | (((word >> 8) & 0xff) << 16) | (((word >> 16) & 0xff) << 8) | ((word >> 24) & 0xff);
  11156.     };
  11157.  
  11158.     TwoFish.prototype.LFSR1 = function(x) {
  11159.       return (x >> 1) ^ ((x & 0x01) !== 0 ? G.GF256_FDBK_2 : 0);
  11160.     };
  11161.  
  11162.     TwoFish.prototype.LFSR2 = function(x) {
  11163.       return (x >> 2) ^ ((x & 0x02) !== 0 ? G.GF256_FDBK_2 : 0) ^ ((x & 0x01) !== 0 ? G.GF256_FDBK_4 : 0);
  11164.     };
  11165.  
  11166.     TwoFish.prototype.Mx_X = function(x) {
  11167.       return x ^ this.LFSR2(x);
  11168.     };
  11169.  
  11170.     TwoFish.prototype.Mx_Y = function(x) {
  11171.       return x ^ this.LFSR1(x) ^ this.LFSR2(x);
  11172.     };
  11173.  
  11174.     TwoFish.prototype.RS_rem = function(x) {
  11175.       var b, g2, g3;
  11176.       b = (x >>> 24) & 0xff;
  11177.       g2 = ((b << 1) ^ ((b & 0x80) !== 0 ? G.RS_GF_FDBK : 0)) & 0xff;
  11178.       g3 = ((b >>> 1) ^ ((b & 0x01) !== 0 ? G.RS_GF_FDBK >>> 1 : 0)) ^ g2;
  11179.       return (x << 8) ^ (g3 << 24) ^ (g2 << 16) ^ (g3 << 8) ^ b;
  11180.     };
  11181.  
  11182.     TwoFish.prototype.RS_MDS_Encode = function(k0, k1) {
  11183.       var i, r, _i, _j;
  11184.       r = k1;
  11185.       for (i = _i = 0; _i < 4; i = ++_i) {
  11186.         r = this.RS_rem(r);
  11187.       }
  11188.       r ^= k0;
  11189.       for (i = _j = 0; _j < 4; i = ++_j) {
  11190.         r = this.RS_rem(r);
  11191.       }
  11192.       return r;
  11193.     };
  11194.  
  11195.     TwoFish.prototype.F32 = function(x, k32) {
  11196.       var b0, b1, b2, b3, k0, k1, k2, k3, m, res;
  11197.       b0 = this.getByte(x, 0);
  11198.       b1 = this.getByte(x, 1);
  11199.       b2 = this.getByte(x, 2);
  11200.       b3 = this.getByte(x, 3);
  11201.       k0 = k32[0];
  11202.       k1 = k32[1];
  11203.       k2 = k32[2];
  11204.       k3 = k32[3];
  11205.       m = this.k64Cnt & 3;
  11206.       res = m === 1 ? this.gMDS0[(G.P[G.P_01][b0] & 0xff) ^ this.getByte(k0, 0)] ^ this.gMDS1[(G.P[G.P_11][b1] & 0xff) ^ this.getByte(k0, 1)] ^ this.gMDS2[(G.P[G.P_21][b2] & 0xff) ^ this.getByte(k0, 2)] ^ this.gMDS3[(G.P[G.P_31][b3] & 0xff) ^ this.getByte(k0, 3)] : (m === 0 ? (b0 = (G.P[G.P_04][b0] & 0xff) ^ this.getByte(k3, 0), b1 = (G.P[G.P_14][b1] & 0xff) ^ this.getByte(k3, 1), b2 = (G.P[G.P_24][b2] & 0xff) ^ this.getByte(k3, 2), b3 = (G.P[G.P_34][b3] & 0xff) ^ this.getByte(k3, 3)) : void 0, m === 0 || m === 3 ? (b0 = (G.P[G.P_03][b0] & 0xff) ^ this.getByte(k2, 0), b1 = (G.P[G.P_13][b1] & 0xff) ^ this.getByte(k2, 1), b2 = (G.P[G.P_23][b2] & 0xff) ^ this.getByte(k2, 2), b3 = (G.P[G.P_33][b3] & 0xff) ^ this.getByte(k2, 3)) : void 0, this.gMDS0[(G.P[G.P_01][(G.P[G.P_02][b0] & 0xff) ^ this.getByte(k1, 0)] & 0xff) ^ this.getByte(k0, 0)] ^ this.gMDS1[(G.P[G.P_11][(G.P[G.P_12][b1] & 0xff) ^ this.getByte(k1, 1)] & 0xff) ^ this.getByte(k0, 1)] ^ this.gMDS2[(G.P[G.P_21][(G.P[G.P_22][b2] & 0xff) ^ this.getByte(k1, 2)] & 0xff) ^ this.getByte(k0, 2)] ^ this.gMDS3[(G.P[G.P_31][(G.P[G.P_32][b3] & 0xff) ^ this.getByte(k1, 3)] & 0xff) ^ this.getByte(k0, 3)]);
  11207.       return res;
  11208.     };
  11209.  
  11210.     TwoFish.prototype.Fe32_0 = function(x) {
  11211.       return this.gSBox[0x000 + 2 * (x & 0xff)] ^ this.gSBox[0x001 + 2 * ((x >>> 8) & 0xff)] ^ this.gSBox[0x200 + 2 * ((x >>> 16) & 0xff)] ^ this.gSBox[0x201 + 2 * ((x >>> 24) & 0xff)];
  11212.     };
  11213.  
  11214.     TwoFish.prototype.Fe32_3 = function(x) {
  11215.       return this.gSBox[0x000 + 2 * ((x >>> 24) & 0xff)] ^ this.gSBox[0x001 + 2 * (x & 0xff)] ^ this.gSBox[0x200 + 2 * ((x >>> 8) & 0xff)] ^ this.gSBox[0x201 + 2 * ((x >>> 16) & 0xff)];
  11216.     };
  11217.  
  11218.     TwoFish.prototype._doReset = function() {
  11219.       var A, B, b0, b1, b2, b3, i, j, k0, k1, k2, k3, k32e, k32o, m, m1, mX, mY, p, q, sBoxKeys, _i, _j, _k, _l, _ref, _ref1, _results;
  11220.       k32e = [];
  11221.       k32o = [];
  11222.       sBoxKeys = [];
  11223.       m1 = [];
  11224.       mX = [];
  11225.       mY = [];
  11226.       this.k64Cnt = this._key.words.length / 2;
  11227.       if (this.k64Cnt < 1) {
  11228.         throw "Key size less than 64 bits";
  11229.       }
  11230.       if (this.k64Cnt > 4) {
  11231.         throw "Key size larger than 256 bits";
  11232.       }
  11233.       for (i = _i = 0; _i < 256; i = ++_i) {
  11234.         j = G.P[0][i] & 0xff;
  11235.         m1[0] = j;
  11236.         mX[0] = this.Mx_X(j) & 0xff;
  11237.         mY[0] = this.Mx_Y(j) & 0xff;
  11238.         j = G.P[1][i] & 0xff;
  11239.         m1[1] = j;
  11240.         mX[1] = this.Mx_X(j) & 0xff;
  11241.         mY[1] = this.Mx_Y(j) & 0xff;
  11242.         this.gMDS0[i] = m1[G.P_00] | mX[G.P_00] << 8 | mY[G.P_00] << 16 | mY[G.P_00] << 24;
  11243.         this.gMDS1[i] = mY[G.P_10] | mY[G.P_10] << 8 | mX[G.P_10] << 16 | m1[G.P_10] << 24;
  11244.         this.gMDS2[i] = mX[G.P_20] | mY[G.P_20] << 8 | m1[G.P_20] << 16 | mY[G.P_20] << 24;
  11245.         this.gMDS3[i] = mX[G.P_30] | m1[G.P_30] << 8 | mY[G.P_30] << 16 | mX[G.P_30] << 24;
  11246.       }
  11247.       for (i = _j = 0, _ref = this.k64Cnt; 0 <= _ref ? _j < _ref : _j > _ref; i = 0 <= _ref ? ++_j : --_j) {
  11248.         p = i * 2;
  11249.         k32e[i] = this.switchEndianness(this._key.words[p]);
  11250.         k32o[i] = this.switchEndianness(this._key.words[p + 1]);
  11251.         sBoxKeys[this.k64Cnt - 1 - i] = this.RS_MDS_Encode(k32e[i], k32o[i]);
  11252.       }
  11253.       for (i = _k = 0, _ref1 = 40 / 2; 0 <= _ref1 ? _k < _ref1 : _k > _ref1; i = 0 <= _ref1 ? ++_k : --_k) {
  11254.         q = i * G.SK_STEP;
  11255.         A = this.F32(q, k32e);
  11256.         B = this.F32(q + G.SK_BUMP, k32o);
  11257.         B = B << 8 | B >>> 24;
  11258.         A += B;
  11259.         this.gSubKeys[i * 2] = A;
  11260.         A += B;
  11261.         this.gSubKeys[i * 2 + 1] = A << G.SK_ROTL | A >>> (32 - G.SK_ROTL);
  11262.       }
  11263.       k0 = sBoxKeys[0];
  11264.       k1 = sBoxKeys[1];
  11265.       k2 = sBoxKeys[2];
  11266.       k3 = sBoxKeys[3];
  11267.       this.gSBox = [];
  11268.       _results = [];
  11269.       for (i = _l = 0; _l < 256; i = ++_l) {
  11270.         b0 = b1 = b2 = b3 = i;
  11271.         m = this.k64Cnt & 3;
  11272.         if (m === 1) {
  11273.           this.gSBox[i * 2] = this.gMDS0[(G.P[G.P_01][b0] & 0xff) ^ this.getByte(k0, 0)];
  11274.           this.gSBox[i * 2 + 1] = this.gMDS1[(G.P[G.P_11][b1] & 0xff) ^ this.getByte(k0, 1)];
  11275.           this.gSBox[i * 2 + 0x200] = this.gMDS2[(G.P[G.P_21][b2] & 0xff) ^ this.getByte(k0, 2)];
  11276.           _results.push(this.gSBox[i * 2 + 0x201] = this.gMDS3[(G.P[G.P_31][b3] & 0xff) ^ this.getByte(k0, 3)]);
  11277.         } else {
  11278.           if (m === 0) {
  11279.             b0 = (G.P[G.P_04][b0] & 0xff) ^ this.getByte(k3, 0);
  11280.             b1 = (G.P[G.P_14][b1] & 0xff) ^ this.getByte(k3, 1);
  11281.             b2 = (G.P[G.P_24][b2] & 0xff) ^ this.getByte(k3, 2);
  11282.             b3 = (G.P[G.P_34][b3] & 0xff) ^ this.getByte(k3, 3);
  11283.           }
  11284.           if (m === 0 || m === 3) {
  11285.             b0 = (G.P[G.P_03][b0] & 0xff) ^ this.getByte(k2, 0);
  11286.             b1 = (G.P[G.P_13][b1] & 0xff) ^ this.getByte(k2, 1);
  11287.             b2 = (G.P[G.P_23][b2] & 0xff) ^ this.getByte(k2, 2);
  11288.             b3 = (G.P[G.P_33][b3] & 0xff) ^ this.getByte(k2, 3);
  11289.           }
  11290.           this.gSBox[i * 2] = this.gMDS0[(G.P[G.P_01][(G.P[G.P_02][b0] & 0xff) ^ this.getByte(k1, 0)] & 0xff) ^ this.getByte(k0, 0)];
  11291.           this.gSBox[i * 2 + 1] = this.gMDS1[(G.P[G.P_11][(G.P[G.P_12][b1] & 0xff) ^ this.getByte(k1, 1)] & 0xff) ^ this.getByte(k0, 1)];
  11292.           this.gSBox[i * 2 + 0x200] = this.gMDS2[(G.P[G.P_21][(G.P[G.P_22][b2] & 0xff) ^ this.getByte(k1, 2)] & 0xff) ^ this.getByte(k0, 2)];
  11293.           _results.push(this.gSBox[i * 2 + 0x201] = this.gMDS3[(G.P[G.P_31][(G.P[G.P_32][b3] & 0xff) ^ this.getByte(k1, 3)] & 0xff) ^ this.getByte(k0, 3)]);
  11294.         }
  11295.       }
  11296.       return _results;
  11297.     };
  11298.  
  11299.     TwoFish.prototype.scrub = function() {
  11300.       scrub_vec(this.gSubKeys);
  11301.       scrub_vec(this.gSBox);
  11302.       return this._key.scrub();
  11303.     };
  11304.  
  11305.     TwoFish.prototype.decryptBlock = function(M, offset) {
  11306.       var k, r, t0, t1, x0, x1, x2, x3, _i;
  11307.       if (offset == null) {
  11308.         offset = 0;
  11309.       }
  11310.       x2 = this.switchEndianness(M[offset]) ^ this.gSubKeys[4];
  11311.       x3 = this.switchEndianness(M[offset + 1]) ^ this.gSubKeys[5];
  11312.       x0 = this.switchEndianness(M[offset + 2]) ^ this.gSubKeys[6];
  11313.       x1 = this.switchEndianness(M[offset + 3]) ^ this.gSubKeys[7];
  11314.       k = 8 + 2 * 16 - 1;
  11315.       for (r = _i = 0; _i < 16; r = _i += 2) {
  11316.         t0 = this.Fe32_0(x2);
  11317.         t1 = this.Fe32_3(x3);
  11318.         x1 ^= t0 + 2 * t1 + this.gSubKeys[k--];
  11319.         x0 = (x0 << 1 | x0 >>> 31) ^ (t0 + t1 + this.gSubKeys[k--]);
  11320.         x1 = x1 >>> 1 | x1 << 31;
  11321.         t0 = this.Fe32_0(x0);
  11322.         t1 = this.Fe32_3(x1);
  11323.         x3 ^= t0 + 2 * t1 + this.gSubKeys[k--];
  11324.         x2 = (x2 << 1 | x2 >>> 31) ^ (t0 + t1 + this.gSubKeys[k--]);
  11325.         x3 = x3 >>> 1 | x3 << 31;
  11326.       }
  11327.       M[offset] = this.switchEndianness(x0 ^ this.gSubKeys[0]);
  11328.       M[offset + 1] = this.switchEndianness(x1 ^ this.gSubKeys[1]);
  11329.       M[offset + 2] = this.switchEndianness(x2 ^ this.gSubKeys[2]);
  11330.       return M[offset + 3] = this.switchEndianness(x3 ^ this.gSubKeys[3]);
  11331.     };
  11332.  
  11333.     TwoFish.prototype.encryptBlock = function(M, offset) {
  11334.       var k, r, t0, t1, x0, x1, x2, x3, _i;
  11335.       if (offset == null) {
  11336.         offset = 0;
  11337.       }
  11338.       x0 = this.switchEndianness(M[offset]) ^ this.gSubKeys[0];
  11339.       x1 = this.switchEndianness(M[offset + 1]) ^ this.gSubKeys[1];
  11340.       x2 = this.switchEndianness(M[offset + 2]) ^ this.gSubKeys[2];
  11341.       x3 = this.switchEndianness(M[offset + 3]) ^ this.gSubKeys[3];
  11342.       k = 8;
  11343.       for (r = _i = 0; _i < 16; r = _i += 2) {
  11344.         t0 = this.Fe32_0(x0);
  11345.         t1 = this.Fe32_3(x1);
  11346.         x2 ^= t0 + t1 + this.gSubKeys[k++];
  11347.         x2 = x2 >>> 1 | x2 << 31;
  11348.         x3 = (x3 << 1 | x3 >>> 31) ^ (t0 + 2 * t1 + this.gSubKeys[k++]);
  11349.         t0 = this.Fe32_0(x2);
  11350.         t1 = this.Fe32_3(x3);
  11351.         x0 ^= t0 + t1 + this.gSubKeys[k++];
  11352.         x0 = x0 >>> 1 | x0 << 31;
  11353.         x1 = (x1 << 1 | x1 >>> 31) ^ (t0 + 2 * t1 + this.gSubKeys[k++]);
  11354.       }
  11355.       M[offset] = this.switchEndianness(x2 ^ this.gSubKeys[4]);
  11356.       M[offset + 1] = this.switchEndianness(x3 ^ this.gSubKeys[5]);
  11357.       M[offset + 2] = this.switchEndianness(x0 ^ this.gSubKeys[6]);
  11358.       return M[offset + 3] = this.switchEndianness(x1 ^ this.gSubKeys[7]);
  11359.     };
  11360.  
  11361.     return TwoFish;
  11362.  
  11363.   })(BlockCipher);
  11364.  
  11365. }).call(this);
  11366.  
  11367. },{"./algbase":18,"./util":37}],37:[function(require,module,exports){
  11368. // Generated by IcedCoffeeScript 1.6.3-g
  11369. (function() {
  11370.   var default_delay, iced, uint_max, __iced_k, __iced_k_noop;
  11371.  
  11372.   iced = require('iced-coffee-script/lib/coffee-script/iced').runtime;
  11373.   __iced_k = __iced_k_noop = function() {};
  11374.  
  11375.   uint_max = Math.pow(2, 32);
  11376.  
  11377.   exports.fixup_uint32 = function(x) {
  11378.     var ret, x_pos;
  11379.     ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x;
  11380.     return ret;
  11381.   };
  11382.  
  11383.   exports.scrub_buffer = function(b) {
  11384.     var i, n_full_words;
  11385.     n_full_words = b.length >> 2;
  11386.     i = 0;
  11387.     while (i < n_full_words) {
  11388.       b.writeUInt32LE(0, i);
  11389.       i += 4;
  11390.     }
  11391.     while (i < b.length) {
  11392.       b.writeUInt8(0, i);
  11393.       i++;
  11394.     }
  11395.     return false;
  11396.   };
  11397.  
  11398.   exports.scrub_vec = function(v) {
  11399.     var i, _i, _ref;
  11400.     for (i = _i = 0, _ref = v.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
  11401.       v[i] = 0;
  11402.     }
  11403.     return false;
  11404.   };
  11405.  
  11406.   exports.default_delay = default_delay = function(i, n, cb) {
  11407.     var ___iced_passed_deferral, __iced_deferrals, __iced_k,
  11408.       _this = this;
  11409.     __iced_k = __iced_k_noop;
  11410.     ___iced_passed_deferral = iced.findDeferral(arguments);
  11411.     (function(__iced_k) {
  11412.       if (typeof setImmediate !== "undefined" && setImmediate !== null) {
  11413.         (function(__iced_k) {
  11414.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  11415.             parent: ___iced_passed_deferral,
  11416.             filename: "src/util.iced",
  11417.             funcname: "default_delay"
  11418.           });
  11419.           setImmediate(__iced_deferrals.defer({
  11420.             lineno: 37
  11421.           }));
  11422.           __iced_deferrals._fulfill();
  11423.         })(__iced_k);
  11424.       } else {
  11425.         (function(__iced_k) {
  11426.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  11427.             parent: ___iced_passed_deferral,
  11428.             filename: "src/util.iced",
  11429.             funcname: "default_delay"
  11430.           });
  11431.           setTimeout(__iced_deferrals.defer({
  11432.             lineno: 39
  11433.           }), 1);
  11434.           __iced_deferrals._fulfill();
  11435.         })(__iced_k);
  11436.       }
  11437.     })(function() {
  11438.       return cb();
  11439.     });
  11440.   };
  11441.  
  11442.   exports.bulk = function(n_input_bytes, _arg, _arg1) {
  11443.     var call_ph, cb, default_n, delay, finalize, i, left, n, n_words, progress_hook, ret, total_words, update, what, ___iced_passed_deferral, __iced_deferrals, __iced_k,
  11444.       _this = this;
  11445.     __iced_k = __iced_k_noop;
  11446.     ___iced_passed_deferral = iced.findDeferral(arguments);
  11447.     update = _arg.update, finalize = _arg.finalize, default_n = _arg.default_n;
  11448.     delay = _arg1.delay, n = _arg1.n, cb = _arg1.cb, what = _arg1.what, progress_hook = _arg1.progress_hook;
  11449.     i = 0;
  11450.     left = 0;
  11451.     total_words = Math.ceil(n_input_bytes / 4);
  11452.     delay || (delay = default_delay);
  11453.     n || (n = default_n);
  11454.     call_ph = function(i) {
  11455.       return typeof progress_hook === "function" ? progress_hook({
  11456.         what: what,
  11457.         i: i,
  11458.         total: total_words
  11459.       }) : void 0;
  11460.     };
  11461.     call_ph(0);
  11462.     (function(__iced_k) {
  11463.       var _results, _while;
  11464.       _results = [];
  11465.       _while = function(__iced_k) {
  11466.         var _break, _continue, _next;
  11467.         _break = function() {
  11468.           return __iced_k(_results);
  11469.         };
  11470.         _continue = function() {
  11471.           return iced.trampoline(function() {
  11472.             return _while(__iced_k);
  11473.           });
  11474.         };
  11475.         _next = function(__iced_next_arg) {
  11476.           _results.push(__iced_next_arg);
  11477.           return _continue();
  11478.         };
  11479.         if (!((left = total_words - i) > 0)) {
  11480.           return _break();
  11481.         } else {
  11482.           n_words = Math.min(n, left);
  11483.           update(i, i + n_words);
  11484.           call_ph(i);
  11485.           (function(__iced_k) {
  11486.             __iced_deferrals = new iced.Deferrals(__iced_k, {
  11487.               parent: ___iced_passed_deferral,
  11488.               filename: "src/util.iced",
  11489.               funcname: "bulk"
  11490.             });
  11491.             delay(i, total_words, __iced_deferrals.defer({
  11492.               lineno: 73
  11493.             }));
  11494.             __iced_deferrals._fulfill();
  11495.           })(function() {
  11496.             return _next(i += n_words);
  11497.           });
  11498.         }
  11499.       };
  11500.       _while(__iced_k);
  11501.     })(function() {
  11502.       call_ph(total_words);
  11503.       ret = finalize();
  11504.       return cb(ret);
  11505.     });
  11506.   };
  11507.  
  11508. }).call(this);
  11509.  
  11510. },{"iced-coffee-script/lib/coffee-script/iced":9}],38:[function(require,module,exports){
  11511. (function (Buffer){
  11512. // Generated by IcedCoffeeScript 1.6.3-g
  11513. (function() {
  11514.   var WordArray, X64Word, X64WordArray, buffer_to_ui8a, endian_reverse, ui8a_to_buffer, util;
  11515.  
  11516.  
  11517.  
  11518.   util = require('./util');
  11519.  
  11520.   buffer_to_ui8a = function(b) {
  11521.     var i, ret, _i, _ref;
  11522.     ret = new Uint8Array(b.length);
  11523.     for (i = _i = 0, _ref = b.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
  11524.       ret[i] = b.readUInt8(i);
  11525.     }
  11526.     return ret;
  11527.   };
  11528.  
  11529.   ui8a_to_buffer = function(v) {
  11530.     var i, ret, _i, _ref;
  11531.     ret = new Buffer(v.length);
  11532.     for (i = _i = 0, _ref = v.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
  11533.       ret.writeUInt8(v[i], i);
  11534.     }
  11535.     return ret;
  11536.   };
  11537.  
  11538.   endian_reverse = function(x) {
  11539.     return ((x >>> 24) & 0xff) | (((x >>> 16) & 0xff) << 8) | (((x >>> 8) & 0xff) << 16) | ((x & 0xff) << 24);
  11540.   };
  11541.  
  11542.   exports.WordArray = WordArray = (function() {
  11543.     function WordArray(words, sigBytes) {
  11544.       this.words = words || [];
  11545.       this.sigBytes = sigBytes != null ? sigBytes : this.words.length * 4;
  11546.     }
  11547.  
  11548.     WordArray.prototype.concat = function(wordArray) {
  11549.       var i, thatByte, thatSigBytes, thatWords, _i;
  11550.       thatWords = wordArray.words;
  11551.       thatSigBytes = wordArray.sigBytes;
  11552.       this.clamp();
  11553.       if (this.sigBytes % 4) {
  11554.         for (i = _i = 0; 0 <= thatSigBytes ? _i < thatSigBytes : _i > thatSigBytes; i = 0 <= thatSigBytes ? ++_i : --_i) {
  11555.           thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  11556.           this.words[(this.sigBytes + i) >>> 2] |= thatByte << (24 - ((this.sigBytes + i) % 4) * 8);
  11557.         }
  11558.       } else {
  11559.         this.words = this.words.concat(thatWords);
  11560.       }
  11561.       this.sigBytes += thatSigBytes;
  11562.       return this;
  11563.     };
  11564.  
  11565.     WordArray.prototype.clamp = function() {
  11566.       this.words[this.sigBytes >>> 2] &= 0xffffffff << (32 - (this.sigBytes % 4) * 8);
  11567.       this.words.length = Math.ceil(this.sigBytes / 4);
  11568.       return this;
  11569.     };
  11570.  
  11571.     WordArray.prototype.clone = function() {
  11572.       return new WordArray(this.words.slice(0), this.sigBytes);
  11573.     };
  11574.  
  11575.     WordArray.prototype.to_buffer = function() {
  11576.       var ch, out, p, w, _i, _len, _ref;
  11577.       out = new Buffer(this.sigBytes);
  11578.       p = 0;
  11579.       _ref = this.words;
  11580.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  11581.         w = _ref[_i];
  11582.         if (!((this.sigBytes - p) >= 4)) {
  11583.           continue;
  11584.         }
  11585.         w = util.fixup_uint32(w);
  11586.         out.writeUInt32BE(w, p);
  11587.         p += 4;
  11588.       }
  11589.       while (p < this.sigBytes) {
  11590.         ch = (this.words[p >>> 2] >>> (24 - (p % 4) * 8)) & 0xff;
  11591.         out.writeUInt8(ch, p);
  11592.         p++;
  11593.       }
  11594.       return out;
  11595.     };
  11596.  
  11597.     WordArray.prototype.endian_reverse = function() {
  11598.       var i, w, _i, _len, _ref;
  11599.       _ref = this.words;
  11600.       for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
  11601.         w = _ref[i];
  11602.         this.words[i] = endian_reverse(w);
  11603.       }
  11604.       return this;
  11605.     };
  11606.  
  11607.     WordArray.prototype.split = function(n) {
  11608.       var i, out, sz;
  11609.       if (!(((this.sigBytes % 4) === 0) && ((this.words.length % n) === 0))) {
  11610.         throw new Error("bad key alignment");
  11611.       }
  11612.       sz = this.words.length / n;
  11613.       out = (function() {
  11614.         var _i, _ref, _results;
  11615.         _results = [];
  11616.         for (i = _i = 0, _ref = this.words.length; sz > 0 ? _i < _ref : _i > _ref; i = _i += sz) {
  11617.           _results.push(new WordArray(this.words.slice(i, i + sz)));
  11618.         }
  11619.         return _results;
  11620.       }).call(this);
  11621.       return out;
  11622.     };
  11623.  
  11624.     WordArray.prototype.to_utf8 = function() {
  11625.       return this.to_buffer().toString('utf8');
  11626.     };
  11627.  
  11628.     WordArray.prototype.to_hex = function() {
  11629.       return this.to_buffer().toString('hex');
  11630.     };
  11631.  
  11632.     WordArray.prototype.to_ui8a = function() {
  11633.       return buffer_to_ui8a(this.to_buffer());
  11634.     };
  11635.  
  11636.     WordArray.alloc = function(b) {
  11637.       if (Buffer.isBuffer(b)) {
  11638.         return WordArray.from_buffer(b);
  11639.       } else if ((typeof b === 'object') && (b instanceof WordArray)) {
  11640.         return b;
  11641.       } else if (typeof b === 'string') {
  11642.         return WordArray.from_hex(b);
  11643.       } else {
  11644.         return null;
  11645.       }
  11646.     };
  11647.  
  11648.     WordArray.from_buffer = function(b) {
  11649.       var ch, last, p, words;
  11650.       words = [];
  11651.       p = 0;
  11652.       while ((b.length - p) >= 4) {
  11653.         words.push(b.readUInt32BE(p));
  11654.         p += 4;
  11655.       }
  11656.       if (p < b.length) {
  11657.         last = 0;
  11658.         while (p < b.length) {
  11659.           ch = b.readUInt8(p);
  11660.           last |= ch << (24 - (p % 4) * 8);
  11661.           p++;
  11662.         }
  11663.         last = util.fixup_uint32(last);
  11664.         words.push(last);
  11665.       }
  11666.       return new WordArray(words, b.length);
  11667.     };
  11668.  
  11669.     WordArray.from_buffer_le = function(b) {
  11670.       var ch, last, p, words;
  11671.       words = [];
  11672.       p = 0;
  11673.       while ((b.length - p) >= 4) {
  11674.         words.push(b.readUInt32LE(p));
  11675.         p += 4;
  11676.       }
  11677.       if (p < b.length) {
  11678.         last = 0;
  11679.         while (p < b.length) {
  11680.           ch = b.readUInt8(p);
  11681.           last |= ch << ((p % 4) * 8);
  11682.           p++;
  11683.         }
  11684.         last = util.fixup_uint32(last);
  11685.         words.push(last);
  11686.       }
  11687.       return new WordArray(words, b.length);
  11688.     };
  11689.  
  11690.     WordArray.from_utf8 = function(s) {
  11691.       return WordArray.from_buffer(new Buffer(s, 'utf8'));
  11692.     };
  11693.  
  11694.     WordArray.from_utf8_le = function(s) {
  11695.       return WordArray.from_buffer_le(new Buffer(s, 'utf8'));
  11696.     };
  11697.  
  11698.     WordArray.from_hex = function(s) {
  11699.       return WordArray.from_buffer(new Buffer(s, 'hex'));
  11700.     };
  11701.  
  11702.     WordArray.from_hex_le = function(s) {
  11703.       return WordArray.from_buffer_le(new Buffer(s, 'hex'));
  11704.     };
  11705.  
  11706.     WordArray.from_ui8a = function(v) {
  11707.       return WordArray.from_buffer(ui8a_to_buffer(v));
  11708.     };
  11709.  
  11710.     WordArray.from_i32a = function(v) {
  11711.       return new WordArray(Array.apply([], v));
  11712.     };
  11713.  
  11714.     WordArray.prototype.equal = function(wa) {
  11715.       var i, ret, w, _i, _len, _ref;
  11716.       ret = true;
  11717.       if (wa.sigBytes !== this.sigBytes) {
  11718.         ret = false;
  11719.       } else {
  11720.         _ref = this.words;
  11721.         for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
  11722.           w = _ref[i];
  11723.           if (util.fixup_uint32(w) !== util.fixup_uint32(wa.words[i])) {
  11724.             ret = false;
  11725.           }
  11726.         }
  11727.       }
  11728.       return ret;
  11729.     };
  11730.  
  11731.     WordArray.prototype.xor = function(wa2, _arg) {
  11732.       var dst_offset, i, n_words, src_offset, tmp, _i;
  11733.       dst_offset = _arg.dst_offset, src_offset = _arg.src_offset, n_words = _arg.n_words;
  11734.       if (!dst_offset) {
  11735.         dst_offset = 0;
  11736.       }
  11737.       if (!src_offset) {
  11738.         src_offset = 0;
  11739.       }
  11740.       if (n_words == null) {
  11741.         n_words = wa2.words.length - src_offset;
  11742.       }
  11743.       if (this.words.length < dst_offset + n_words) {
  11744.         throw new Error("dest range exceeded (" + this.words.length + " < " + (dst_offset + n_words) + ")");
  11745.       }
  11746.       if (wa2.words.length < src_offset + n_words) {
  11747.         throw new Error("source range exceeded");
  11748.       }
  11749.       for (i = _i = 0; 0 <= n_words ? _i < n_words : _i > n_words; i = 0 <= n_words ? ++_i : --_i) {
  11750.         tmp = this.words[dst_offset + i] ^ wa2.words[src_offset + i];
  11751.         this.words[dst_offset + i] = util.fixup_uint32(tmp);
  11752.       }
  11753.       return this;
  11754.     };
  11755.  
  11756.     WordArray.prototype.truncate = function(n_bytes) {
  11757.       var n_words;
  11758.       if (!(n_bytes <= this.sigBytes)) {
  11759.         throw new Error("Cannot truncate: " + n_bytes + " > " + this.sigBytes);
  11760.       }
  11761.       n_words = Math.ceil(n_bytes / 4);
  11762.       return new WordArray(this.words.slice(0, n_words), n_bytes);
  11763.     };
  11764.  
  11765.     WordArray.prototype.unshift = function(n_words) {
  11766.       var ret;
  11767.       if (this.words.length >= n_words) {
  11768.         ret = this.words.splice(0, n_words);
  11769.         this.sigBytes -= n_words * 4;
  11770.         return new WordArray(ret);
  11771.       } else {
  11772.         return null;
  11773.       }
  11774.     };
  11775.  
  11776.     WordArray.prototype.is_scrubbed = function() {
  11777.       var w, _i, _len, _ref;
  11778.       _ref = this.words;
  11779.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  11780.         w = _ref[_i];
  11781.         if (w !== 0) {
  11782.           return false;
  11783.         }
  11784.       }
  11785.       return true;
  11786.     };
  11787.  
  11788.     WordArray.prototype.scrub = function() {
  11789.       return util.scrub_vec(this.words);
  11790.     };
  11791.  
  11792.     WordArray.prototype.slice = function(low, hi) {
  11793.       var n, sb;
  11794.       n = this.words.length;
  11795.       if (!((low < hi) && (hi <= n))) {
  11796.         throw new Error("Bad WordArray slice [" + low + "," + hi + ")] when only " + n + " avail");
  11797.       }
  11798.       sb = (hi - low) * 4;
  11799.       if (hi === n) {
  11800.         sb -= n * 4 - this.sigBytes;
  11801.       }
  11802.       return new WordArray(this.words.slice(low, hi), sb);
  11803.     };
  11804.  
  11805.     return WordArray;
  11806.  
  11807.   })();
  11808.  
  11809.   exports.X64Word = X64Word = (function() {
  11810.     function X64Word(high, low) {
  11811.       this.high = high;
  11812.       this.low = low;
  11813.     }
  11814.  
  11815.     X64Word.prototype.clone = function() {
  11816.       return new X64Word(this.high, this.low);
  11817.     };
  11818.  
  11819.     return X64Word;
  11820.  
  11821.   })();
  11822.  
  11823.   exports.X64WordArray = X64WordArray = (function() {
  11824.     function X64WordArray(words, sigBytes) {
  11825.       this.sigBytes = sigBytes;
  11826.       this.words = words || [];
  11827.       if (!this.sigBytes) {
  11828.         this.sigBytes = this.words.length * 8;
  11829.       }
  11830.     }
  11831.  
  11832.     X64WordArray.prototype.toX32 = function() {
  11833.       var v, w, _i, _len, _ref;
  11834.       v = [];
  11835.       _ref = this.words;
  11836.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  11837.         w = _ref[_i];
  11838.         v.push(w.high);
  11839.         v.push(w.low);
  11840.       }
  11841.       return new WordArray(v, this.sigBytes);
  11842.     };
  11843.  
  11844.     X64WordArray.prototype.clone = function() {
  11845.       var w;
  11846.       return new X64WordArray((function() {
  11847.         var _i, _len, _ref, _results;
  11848.         _ref = this.words;
  11849.         _results = [];
  11850.         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  11851.           w = _ref[_i];
  11852.           _results.push(w.clone());
  11853.         }
  11854.         return _results;
  11855.       }).call(this), this.sigBytes);
  11856.     };
  11857.  
  11858.     return X64WordArray;
  11859.  
  11860.   })();
  11861.  
  11862.   exports.buffer_to_ui8a = buffer_to_ui8a;
  11863.  
  11864.   exports.ui8a_to_buffer = ui8a_to_buffer;
  11865.  
  11866.   exports.endian_reverse = endian_reverse;
  11867.  
  11868. }).call(this);
  11869.  
  11870. }).call(this,require("buffer").Buffer)
  11871. },{"./util":37,"buffer":1}],39:[function(require,module,exports){
  11872. // Generated by IcedCoffeeScript 1.7.1-f
  11873. (function() {
  11874.   var Generator, iced, __iced_k, __iced_k_noop;
  11875.  
  11876.   iced = require('iced-runtime');
  11877.   __iced_k = __iced_k_noop = function() {};
  11878.  
  11879.   Generator = Generator = (function() {
  11880.     function Generator(opts) {
  11881.       opts = opts || {};
  11882.       this.lazy_loop_delay = opts.lazy_loop_delay || 30;
  11883.       this.loop_delay = opts.loop_delay || 5;
  11884.       this.work_min = opts.work_min || 1;
  11885.       this.auto_stop_bits = opts.auto_stop_bits || 4096;
  11886.       this.max_bits_per_delta = opts.max_bits_per_delta || 4;
  11887.       this.auto_stop = opts.auto_stop ? opts.auto_stop : true;
  11888.       this.entropies = [];
  11889.       this.running = true;
  11890.       this.is_generating = false;
  11891.       this.timer_race_loop();
  11892.     }
  11893.  
  11894.     Generator.prototype.generate = function(bits_wanted, cb) {
  11895.       var e, harvested_bits, res, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  11896.       __iced_k = __iced_k_noop;
  11897.       ___iced_passed_deferral = iced.findDeferral(arguments);
  11898.       this.is_generating = true;
  11899.       if (!this.running) {
  11900.         this.resume();
  11901.       }
  11902.       harvested_bits = 0;
  11903.       res = [];
  11904.       (function(_this) {
  11905.         return (function(__iced_k) {
  11906.           var _results, _while;
  11907.           _results = [];
  11908.           _while = function(__iced_k) {
  11909.             var _break, _continue, _next;
  11910.             _break = function() {
  11911.               return __iced_k(_results);
  11912.             };
  11913.             _continue = function() {
  11914.               return iced.trampoline(function() {
  11915.                 return _while(__iced_k);
  11916.               });
  11917.             };
  11918.             _next = function(__iced_next_arg) {
  11919.               _results.push(__iced_next_arg);
  11920.               return _continue();
  11921.             };
  11922.             if (!(harvested_bits < bits_wanted)) {
  11923.               return _break();
  11924.             } else {
  11925.               (function(__iced_k) {
  11926.                 if (_this.entropies.length) {
  11927.                   e = _this.entropies.splice(0, 1)[0];
  11928.                   harvested_bits += e[1];
  11929.                   return __iced_k(res.push(e[0]));
  11930.                 } else {
  11931.                   (function(__iced_k) {
  11932.                     __iced_deferrals = new iced.Deferrals(__iced_k, {
  11933.                       parent: ___iced_passed_deferral,
  11934.                       filename: "/Users/chris/git/more-entropy/src/generator.iced",
  11935.                       funcname: "Generator.generate"
  11936.                     });
  11937.                     _this.delay(__iced_deferrals.defer({
  11938.                       lineno: 28
  11939.                     }));
  11940.                     __iced_deferrals._fulfill();
  11941.                   })(__iced_k);
  11942.                 }
  11943.               })(_next);
  11944.             }
  11945.           };
  11946.           _while(__iced_k);
  11947.         });
  11948.       })(this)((function(_this) {
  11949.         return function() {
  11950.           if (_this.auto_stop) {
  11951.             _this.stop();
  11952.           }
  11953.           _this.is_generating = false;
  11954.           return cb(res);
  11955.         };
  11956.       })(this));
  11957.     };
  11958.  
  11959.     Generator.prototype.stop = function() {
  11960.       return this.running = false;
  11961.     };
  11962.  
  11963.     Generator.prototype.resume = function() {
  11964.       this.running = true;
  11965.       return this.timer_race_loop();
  11966.     };
  11967.  
  11968.     Generator.prototype.reset = function() {
  11969.       this.entropies = [];
  11970.       return this.total_bits = 0;
  11971.     };
  11972.  
  11973.     Generator.prototype.count_unused_bits = function() {
  11974.       var bits, e, _i, _len, _ref;
  11975.       bits = 0;
  11976.       _ref = this.entropies;
  11977.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  11978.         e = _ref[_i];
  11979.         bits += e[1];
  11980.       }
  11981.       return bits;
  11982.     };
  11983.  
  11984.     Generator.prototype.delay = function(cb) {
  11985.       var delay, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  11986.       __iced_k = __iced_k_noop;
  11987.       ___iced_passed_deferral = iced.findDeferral(arguments);
  11988.       delay = this.is_generating ? this.loop_delay : this.lazy_loop_delay;
  11989.       (function(_this) {
  11990.         return (function(__iced_k) {
  11991.           __iced_deferrals = new iced.Deferrals(__iced_k, {
  11992.             parent: ___iced_passed_deferral,
  11993.             filename: "/Users/chris/git/more-entropy/src/generator.iced",
  11994.             funcname: "Generator.delay"
  11995.           });
  11996.           setTimeout(__iced_deferrals.defer({
  11997.             lineno: 50
  11998.           }), delay);
  11999.           __iced_deferrals._fulfill();
  12000.         });
  12001.       })(this)((function(_this) {
  12002.         return function() {
  12003.           return cb();
  12004.         };
  12005.       })(this));
  12006.     };
  12007.  
  12008.     Generator.prototype.timer_race_loop = function() {
  12009.       var ___iced_passed_deferral, __iced_k, _results, _while;
  12010.       __iced_k = __iced_k_noop;
  12011.       ___iced_passed_deferral = iced.findDeferral(arguments);
  12012.       this._last_count = null;
  12013.       _results = [];
  12014.       _while = (function(_this) {
  12015.         var count, delta, entropy, v, __iced_deferrals;
  12016.         return function(__iced_k) {
  12017.           var _break, _continue, _next;
  12018.           _break = function() {
  12019.             return __iced_k(_results);
  12020.           };
  12021.           _continue = function() {
  12022.             return iced.trampoline(function() {
  12023.               return _while(__iced_k);
  12024.             });
  12025.           };
  12026.           _next = function(__iced_next_arg) {
  12027.             _results.push(__iced_next_arg);
  12028.             return _continue();
  12029.           };
  12030.           if (!_this.running) {
  12031.             return _break();
  12032.           } else {
  12033.             if (_this.count_unused_bits() < _this.auto_stop_bits) {
  12034.               count = _this.millisecond_count();
  12035.               if ((_this._last_count != null) && (delta = count - _this._last_count)) {
  12036.                 entropy = Math.floor(_this.log_2(Math.abs(delta)));
  12037.                 entropy = Math.min(_this.max_bits_per_delta, entropy);
  12038.                 v = [delta, entropy];
  12039.                 _this.entropies.push(v);
  12040.               }
  12041.               _this._last_count = count;
  12042.             }
  12043.             (function(__iced_k) {
  12044.               __iced_deferrals = new iced.Deferrals(__iced_k, {
  12045.                 parent: ___iced_passed_deferral,
  12046.                 filename: "/Users/chris/git/more-entropy/src/generator.iced",
  12047.                 funcname: "Generator.timer_race_loop"
  12048.               });
  12049.               _this.delay(__iced_deferrals.defer({
  12050.                 lineno: 64
  12051.               }));
  12052.               __iced_deferrals._fulfill();
  12053.             })(_next);
  12054.           }
  12055.         };
  12056.       })(this);
  12057.       _while(__iced_k);
  12058.     };
  12059.  
  12060.     Generator.prototype.log_2 = function(x) {
  12061.       return Math.log(x) / Math.LN2;
  12062.     };
  12063.  
  12064.     Generator.prototype.millisecond_count = function() {
  12065.       var d, i, x;
  12066.       d = Date.now();
  12067.       i = x = 0;
  12068.       while (Date.now() < d + this.work_min + 1) {
  12069.         i++;
  12070.         x = Math.sin(Math.sqrt(Math.log(i + x)));
  12071.       }
  12072.       return i;
  12073.     };
  12074.  
  12075.     return Generator;
  12076.  
  12077.   })();
  12078.  
  12079.   if (typeof window !== "undefined" && window !== null) {
  12080.     window.Generator = Generator;
  12081.   }
  12082.  
  12083.   if (typeof exports !== "undefined" && exports !== null) {
  12084.     exports.Generator = Generator;
  12085.   }
  12086.  
  12087. }).call(this);
  12088.  
  12089. },{"iced-runtime":13}],40:[function(require,module,exports){
  12090. // Generated by IcedCoffeeScript 1.7.1-c
  12091. (function() {
  12092.   exports.Generator = require('../lib/generator').Generator;
  12093.  
  12094. }).call(this);
  12095.  
  12096. },{"../lib/generator":39}],41:[function(require,module,exports){
  12097. (function (Buffer){
  12098. var HMAC_SHA256, WordArray, from_utf8, generate, iced, params, pbkdf2, run, scrypt, util, __iced_k, __iced_k_noop, _ref;
  12099.  
  12100. iced = require('iced-runtime');
  12101. __iced_k = __iced_k_noop = function() {};
  12102.  
  12103. _ref = require('triplesec'), scrypt = _ref.scrypt, pbkdf2 = _ref.pbkdf2, HMAC_SHA256 = _ref.HMAC_SHA256, WordArray = _ref.WordArray, util = _ref.util;
  12104.  
  12105. generate = require('keybase-bitcoin').generate;
  12106.  
  12107. params = require('../json/params.json');
  12108.  
  12109. from_utf8 = function(s, i) {
  12110.   var b, b2, ret;
  12111.   b = new Buffer(s, 'utf8');
  12112.   b2 = Buffer.concat([b, new Buffer([i])]);
  12113.   ret = WordArray.from_buffer(b2);
  12114.   util.scrub_buffer(b);
  12115.   util.scrub_buffer(b2);
  12116.   return ret;
  12117. };
  12118.  
  12119. exports.run = run = function(_arg, cb) {
  12120.   var d, d2, k, obj, out, passphrase, progress_hook, s1, s2, salt, seed_final, seeds, v, ___iced_passed_deferral, __iced_deferrals, __iced_k;
  12121.   __iced_k = __iced_k_noop;
  12122.   ___iced_passed_deferral = iced.findDeferral(arguments);
  12123.   passphrase = _arg.passphrase, salt = _arg.salt, progress_hook = _arg.progress_hook;
  12124.   d = {};
  12125.   seeds = [];
  12126.   for (k in params) {
  12127.     v = params[k];
  12128.     d[k] = v;
  12129.   }
  12130.   d.key = from_utf8(passphrase, 1);
  12131.   d.salt = from_utf8(salt, 1);
  12132.   d.progress_hook = progress_hook;
  12133.   (function(_this) {
  12134.     return (function(__iced_k) {
  12135.       __iced_deferrals = new iced.Deferrals(__iced_k, {
  12136.         parent: ___iced_passed_deferral
  12137.       });
  12138.       scrypt(d, __iced_deferrals.defer({
  12139.         assign_fn: (function() {
  12140.           return function() {
  12141.             return s1 = arguments[0];
  12142.           };
  12143.         })(),
  12144.         lineno: 26
  12145.       }));
  12146.       __iced_deferrals._fulfill();
  12147.     });
  12148.   })(this)((function(_this) {
  12149.     return function() {
  12150.       seeds.push(s1.to_buffer());
  12151.       d2 = {
  12152.         key: from_utf8(passphrase, 2),
  12153.         salt: from_utf8(salt, 2),
  12154.         c: params.pbkdf2c,
  12155.         dkLen: params.dkLen,
  12156.         progress_hook: progress_hook,
  12157.         klass: HMAC_SHA256
  12158.       };
  12159.       (function(__iced_k) {
  12160.         __iced_deferrals = new iced.Deferrals(__iced_k, {
  12161.           parent: ___iced_passed_deferral
  12162.         });
  12163.         pbkdf2(d2, __iced_deferrals.defer({
  12164.           assign_fn: (function() {
  12165.             return function() {
  12166.               return s2 = arguments[0];
  12167.             };
  12168.           })(),
  12169.           lineno: 38
  12170.         }));
  12171.         __iced_deferrals._fulfill();
  12172.       })(function() {
  12173.         var _i, _len, _ref1;
  12174.         seeds.push(s2.to_buffer());
  12175.         s1.xor(s2, {});
  12176.         seed_final = s1.to_buffer();
  12177.         seeds.push(seed_final);
  12178.         _ref1 = [s1, s2, d.key, d2.key];
  12179.         for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
  12180.           obj = _ref1[_i];
  12181.           obj.scrub();
  12182.         }
  12183.         out = generate(seed_final);
  12184.         out.seeds = seeds;
  12185.         return cb(out);
  12186.       });
  12187.     };
  12188.   })(this));
  12189. };
  12190.  
  12191. }).call(this,require("buffer").Buffer)
  12192. },{"../json/params.json":42,"buffer":1,"iced-runtime":13,"keybase-bitcoin":15,"triplesec":26}],42:[function(require,module,exports){
  12193. module.exports={
  12194.   "N"        : 18,
  12195.   "p"        : 1,
  12196.   "r"        : 8,
  12197.   "dkLen"    : 32,
  12198.   "pbkdf2c"  : 65536
  12199. }
  12200.  
  12201. },{}]},{},[41])(41)
  12202. });
  12203. </script>
Add Comment
Please, Sign In to add comment