[
  {
    "path": ".gitignore",
    "content": "node_modules\r\n"
  },
  {
    "path": "CryptoKitties/cryptokitties.sol",
    "content": "// CryptoKitties Source code\r\n// Copied from: https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code\r\n\r\npragma solidity ^0.4.11;\r\n\r\n/**\r\n * @title Ownable\r\n * @dev The Ownable contract has an owner address, and provides basic authorization control\r\n * functions, this simplifies the implementation of \"user permissions\".\r\n */\r\ncontract Ownable {\r\n  address public owner;\r\n\r\n\r\n  /**\r\n   * @dev The Ownable constructor sets the original `owner` of the contract to the sender\r\n   * account.\r\n   */\r\n  function Ownable() {\r\n    owner = msg.sender;\r\n  }\r\n\r\n\r\n  /**\r\n   * @dev Throws if called by any account other than the owner.\r\n   */\r\n  modifier onlyOwner() {\r\n    require(msg.sender == owner);\r\n    _;\r\n  }\r\n\r\n\r\n  /**\r\n   * @dev Allows the current owner to transfer control of the contract to a newOwner.\r\n   * @param newOwner The address to transfer ownership to.\r\n   */\r\n  function transferOwnership(address newOwner) onlyOwner {\r\n    if (newOwner != address(0)) {\r\n      owner = newOwner;\r\n    }\r\n  }\r\n\r\n}\r\n\r\n\r\n\r\n/// @title Interface for contracts conforming to ERC-721: Non-Fungible Tokens\r\n/// @author Dieter Shirley <dete@axiomzen.co> (https://github.com/dete)\r\ncontract ERC721 {\r\n    // Required methods\r\n    function totalSupply() public view returns (uint256 total);\r\n    function balanceOf(address _owner) public view returns (uint256 balance);\r\n    function ownerOf(uint256 _tokenId) external view returns (address owner);\r\n    function approve(address _to, uint256 _tokenId) external;\r\n    function transfer(address _to, uint256 _tokenId) external;\r\n    function transferFrom(address _from, address _to, uint256 _tokenId) external;\r\n\r\n    // Events\r\n    event Transfer(address from, address to, uint256 tokenId);\r\n    event Approval(address owner, address approved, uint256 tokenId);\r\n\r\n    // Optional\r\n    // function name() public view returns (string name);\r\n    // function symbol() public view returns (string symbol);\r\n    // function tokensOfOwner(address _owner) external view returns (uint256[] tokenIds);\r\n    // function tokenMetadata(uint256 _tokenId, string _preferredTransport) public view returns (string infoUrl);\r\n\r\n    // ERC-165 Compatibility (https://github.com/ethereum/EIPs/issues/165)\r\n    function supportsInterface(bytes4 _interfaceID) external view returns (bool);\r\n}\r\n\r\n\r\n// // Auction wrapper functions\r\n\r\n\r\n// Auction wrapper functions\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/// @title SEKRETOOOO\r\ncontract GeneScienceInterface {\r\n    /// @dev simply a boolean to indicate this is the contract we expect to be\r\n    function isGeneScience() public pure returns (bool);\r\n\r\n    /// @dev given genes of kitten 1 & 2, return a genetic combination - may have a random factor\r\n    /// @param genes1 genes of mom\r\n    /// @param genes2 genes of sire\r\n    /// @return the genes that are supposed to be passed down the child\r\n    function mixGenes(uint256 genes1, uint256 genes2, uint256 targetBlock) public returns (uint256);\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/// @title A facet of KittyCore that manages special access privileges.\r\n/// @author Axiom Zen (https://www.axiomzen.co)\r\n/// @dev See the KittyCore contract documentation to understand how the various contract facets are arranged.\r\ncontract KittyAccessControl {\r\n    // This facet controls access control for CryptoKitties. There are four roles managed here:\r\n    //\r\n    //     - The CEO: The CEO can reassign other roles and change the addresses of our dependent smart\r\n    //         contracts. It is also the only role that can unpause the smart contract. It is initially\r\n    //         set to the address that created the smart contract in the KittyCore constructor.\r\n    //\r\n    //     - The CFO: The CFO can withdraw funds from KittyCore and its auction contracts.\r\n    //\r\n    //     - The COO: The COO can release gen0 kitties to auction, and mint promo cats.\r\n    //\r\n    // It should be noted that these roles are distinct without overlap in their access abilities, the\r\n    // abilities listed for each role above are exhaustive. In particular, while the CEO can assign any\r\n    // address to any role, the CEO address itself doesn't have the ability to act in those roles. This\r\n    // restriction is intentional so that we aren't tempted to use the CEO address frequently out of\r\n    // convenience. The less we use an address, the less likely it is that we somehow compromise the\r\n    // account.\r\n\r\n    /// @dev Emited when contract is upgraded - See README.md for updgrade plan\r\n    event ContractUpgrade(address newContract);\r\n\r\n    // The addresses of the accounts (or contracts) that can execute actions within each roles.\r\n    address public ceoAddress;\r\n    address public cfoAddress;\r\n    address public cooAddress;\r\n\r\n    // @dev Keeps track whether the contract is paused. When that is true, most actions are blocked\r\n    bool public paused = false;\r\n\r\n    /// @dev Access modifier for CEO-only functionality\r\n    modifier onlyCEO() {\r\n        require(msg.sender == ceoAddress);\r\n        _;\r\n    }\r\n\r\n    /// @dev Access modifier for CFO-only functionality\r\n    modifier onlyCFO() {\r\n        require(msg.sender == cfoAddress);\r\n        _;\r\n    }\r\n\r\n    /// @dev Access modifier for COO-only functionality\r\n    modifier onlyCOO() {\r\n        require(msg.sender == cooAddress);\r\n        _;\r\n    }\r\n\r\n    modifier onlyCLevel() {\r\n        require(\r\n            msg.sender == cooAddress ||\r\n            msg.sender == ceoAddress ||\r\n            msg.sender == cfoAddress\r\n        );\r\n        _;\r\n    }\r\n\r\n    /// @dev Assigns a new address to act as the CEO. Only available to the current CEO.\r\n    /// @param _newCEO The address of the new CEO\r\n    function setCEO(address _newCEO) external onlyCEO {\r\n        require(_newCEO != address(0));\r\n\r\n        ceoAddress = _newCEO;\r\n    }\r\n\r\n    /// @dev Assigns a new address to act as the CFO. Only available to the current CEO.\r\n    /// @param _newCFO The address of the new CFO\r\n    function setCFO(address _newCFO) external onlyCEO {\r\n        require(_newCFO != address(0));\r\n\r\n        cfoAddress = _newCFO;\r\n    }\r\n\r\n    /// @dev Assigns a new address to act as the COO. Only available to the current CEO.\r\n    /// @param _newCOO The address of the new COO\r\n    function setCOO(address _newCOO) external onlyCEO {\r\n        require(_newCOO != address(0));\r\n\r\n        cooAddress = _newCOO;\r\n    }\r\n\r\n    /*** Pausable functionality adapted from OpenZeppelin ***/\r\n\r\n    /// @dev Modifier to allow actions only when the contract IS NOT paused\r\n    modifier whenNotPaused() {\r\n        require(!paused);\r\n        _;\r\n    }\r\n\r\n    /// @dev Modifier to allow actions only when the contract IS paused\r\n    modifier whenPaused {\r\n        require(paused);\r\n        _;\r\n    }\r\n\r\n    /// @dev Called by any \"C-level\" role to pause the contract. Used only when\r\n    ///  a bug or exploit is detected and we need to limit damage.\r\n    function pause() external onlyCLevel whenNotPaused {\r\n        paused = true;\r\n    }\r\n\r\n    /// @dev Unpauses the smart contract. Can only be called by the CEO, since\r\n    ///  one reason we may pause the contract is when CFO or COO accounts are\r\n    ///  compromised.\r\n    /// @notice This is public rather than external so it can be called by\r\n    ///  derived contracts.\r\n    function unpause() public onlyCEO whenPaused {\r\n        // can't unpause if contract was upgraded\r\n        paused = false;\r\n    }\r\n}\r\n\r\n\r\n\r\n\r\n/// @title Base contract for CryptoKitties. Holds all common structs, events and base variables.\r\n/// @author Axiom Zen (https://www.axiomzen.co)\r\n/// @dev See the KittyCore contract documentation to understand how the various contract facets are arranged.\r\ncontract KittyBase is KittyAccessControl {\r\n    /*** EVENTS ***/\r\n\r\n    /// @dev The Birth event is fired whenever a new kitten comes into existence. This obviously\r\n    ///  includes any time a cat is created through the giveBirth method, but it is also called\r\n    ///  when a new gen0 cat is created.\r\n    event Birth(address owner, uint256 kittyId, uint256 matronId, uint256 sireId, uint256 genes);\r\n\r\n    /// @dev Transfer event as defined in current draft of ERC721. Emitted every time a kitten\r\n    ///  ownership is assigned, including births.\r\n    event Transfer(address from, address to, uint256 tokenId);\r\n\r\n    /*** DATA TYPES ***/\r\n\r\n    /// @dev The main Kitty struct. Every cat in CryptoKitties is represented by a copy\r\n    ///  of this structure, so great care was taken to ensure that it fits neatly into\r\n    ///  exactly two 256-bit words. Note that the order of the members in this structure\r\n    ///  is important because of the byte-packing rules used by Ethereum.\r\n    ///  Ref: http://solidity.readthedocs.io/en/develop/miscellaneous.html\r\n    struct Kitty {\r\n        // The Kitty's genetic code is packed into these 256-bits, the format is\r\n        // sooper-sekret! A cat's genes never change.\r\n        uint256 genes;\r\n\r\n        // The timestamp from the block when this cat came into existence.\r\n        uint64 birthTime;\r\n\r\n        // The minimum timestamp after which this cat can engage in breeding\r\n        // activities again. This same timestamp is used for the pregnancy\r\n        // timer (for matrons) as well as the siring cooldown.\r\n        uint64 cooldownEndBlock;\r\n\r\n        // The ID of the parents of this kitty, set to 0 for gen0 cats.\r\n        // Note that using 32-bit unsigned integers limits us to a \"mere\"\r\n        // 4 billion cats. This number might seem small until you realize\r\n        // that Ethereum currently has a limit of about 500 million\r\n        // transactions per year! So, this definitely won't be a problem\r\n        // for several years (even as Ethereum learns to scale).\r\n        uint32 matronId;\r\n        uint32 sireId;\r\n\r\n        // Set to the ID of the sire cat for matrons that are pregnant,\r\n        // zero otherwise. A non-zero value here is how we know a cat\r\n        // is pregnant. Used to retrieve the genetic material for the new\r\n        // kitten when the birth transpires.\r\n        uint32 siringWithId;\r\n\r\n        // Set to the index in the cooldown array (see below) that represents\r\n        // the current cooldown duration for this Kitty. This starts at zero\r\n        // for gen0 cats, and is initialized to floor(generation/2) for others.\r\n        // Incremented by one for each successful breeding action, regardless\r\n        // of whether this cat is acting as matron or sire.\r\n        uint16 cooldownIndex;\r\n\r\n        // The \"generation number\" of this cat. Cats minted by the CK contract\r\n        // for sale are called \"gen0\" and have a generation number of 0. The\r\n        // generation number of all other cats is the larger of the two generation\r\n        // numbers of their parents, plus one.\r\n        // (i.e. max(matron.generation, sire.generation) + 1)\r\n        uint16 generation;\r\n    }\r\n\r\n    /*** CONSTANTS ***/\r\n\r\n    /// @dev A lookup table indicating the cooldown duration after any successful\r\n    ///  breeding action, called \"pregnancy time\" for matrons and \"siring cooldown\"\r\n    ///  for sires. Designed such that the cooldown roughly doubles each time a cat\r\n    ///  is bred, encouraging owners not to just keep breeding the same cat over\r\n    ///  and over again. Caps out at one week (a cat can breed an unbounded number\r\n    ///  of times, and the maximum cooldown is always seven days).\r\n    uint32[14] public cooldowns = [\r\n        uint32(1 minutes),\r\n        uint32(2 minutes),\r\n        uint32(5 minutes),\r\n        uint32(10 minutes),\r\n        uint32(30 minutes),\r\n        uint32(1 hours),\r\n        uint32(2 hours),\r\n        uint32(4 hours),\r\n        uint32(8 hours),\r\n        uint32(16 hours),\r\n        uint32(1 days),\r\n        uint32(2 days),\r\n        uint32(4 days),\r\n        uint32(7 days)\r\n    ];\r\n\r\n    // An approximation of currently how many seconds are in between blocks.\r\n    uint256 public secondsPerBlock = 15;\r\n\r\n    /*** STORAGE ***/\r\n\r\n    /// @dev An array containing the Kitty struct for all Kitties in existence. The ID\r\n    ///  of each cat is actually an index into this array. Note that ID 0 is a negacat,\r\n    ///  the unKitty, the mythical beast that is the parent of all gen0 cats. A bizarre\r\n    ///  creature that is both matron and sire... to itself! Has an invalid genetic code.\r\n    ///  In other words, cat ID 0 is invalid... ;-)\r\n    Kitty[] kitties;\r\n\r\n    /// @dev A mapping from cat IDs to the address that owns them. All cats have\r\n    ///  some valid owner address, even gen0 cats are created with a non-zero owner.\r\n    mapping (uint256 => address) public kittyIndexToOwner;\r\n\r\n    // @dev A mapping from owner address to count of tokens that address owns.\r\n    //  Used internally inside balanceOf() to resolve ownership count.\r\n    mapping (address => uint256) ownershipTokenCount;\r\n\r\n    /// @dev A mapping from KittyIDs to an address that has been approved to call\r\n    ///  transferFrom(). Each Kitty can only have one approved address for transfer\r\n    ///  at any time. A zero value means no approval is outstanding.\r\n    mapping (uint256 => address) public kittyIndexToApproved;\r\n\r\n    /// @dev A mapping from KittyIDs to an address that has been approved to use\r\n    ///  this Kitty for siring via breedWith(). Each Kitty can only have one approved\r\n    ///  address for siring at any time. A zero value means no approval is outstanding.\r\n    mapping (uint256 => address) public sireAllowedToAddress;\r\n\r\n    /// @dev The address of the ClockAuction contract that handles sales of Kitties. This\r\n    ///  same contract handles both peer-to-peer sales as well as the gen0 sales which are\r\n    ///  initiated every 15 minutes.\r\n    SaleClockAuction public saleAuction;\r\n\r\n    /// @dev The address of a custom ClockAuction subclassed contract that handles siring\r\n    ///  auctions. Needs to be separate from saleAuction because the actions taken on success\r\n    ///  after a sales and siring auction are quite different.\r\n    SiringClockAuction public siringAuction;\r\n\r\n    /// @dev Assigns ownership of a specific Kitty to an address.\r\n    function _transfer(address _from, address _to, uint256 _tokenId) internal {\r\n        // Since the number of kittens is capped to 2^32 we can't overflow this\r\n        ownershipTokenCount[_to]++;\r\n        // transfer ownership\r\n        kittyIndexToOwner[_tokenId] = _to;\r\n        // When creating new kittens _from is 0x0, but we can't account that address.\r\n        if (_from != address(0)) {\r\n            ownershipTokenCount[_from]--;\r\n            // once the kitten is transferred also clear sire allowances\r\n            delete sireAllowedToAddress[_tokenId];\r\n            // clear any previously approved ownership exchange\r\n            delete kittyIndexToApproved[_tokenId];\r\n        }\r\n        // Emit the transfer event.\r\n        Transfer(_from, _to, _tokenId);\r\n    }\r\n\r\n    /// @dev An internal method that creates a new kitty and stores it. This\r\n    ///  method doesn't do any checking and should only be called when the\r\n    ///  input data is known to be valid. Will generate both a Birth event\r\n    ///  and a Transfer event.\r\n    /// @param _matronId The kitty ID of the matron of this cat (zero for gen0)\r\n    /// @param _sireId The kitty ID of the sire of this cat (zero for gen0)\r\n    /// @param _generation The generation number of this cat, must be computed by caller.\r\n    /// @param _genes The kitty's genetic code.\r\n    /// @param _owner The inital owner of this cat, must be non-zero (except for the unKitty, ID 0)\r\n    function _createKitty(\r\n        uint256 _matronId,\r\n        uint256 _sireId,\r\n        uint256 _generation,\r\n        uint256 _genes,\r\n        address _owner\r\n    )\r\n        internal\r\n        returns (uint)\r\n    {\r\n        // These requires are not strictly necessary, our calling code should make\r\n        // sure that these conditions are never broken. However! _createKitty() is already\r\n        // an expensive call (for storage), and it doesn't hurt to be especially careful\r\n        // to ensure our data structures are always valid.\r\n        require(_matronId == uint256(uint32(_matronId)));\r\n        require(_sireId == uint256(uint32(_sireId)));\r\n        require(_generation == uint256(uint16(_generation)));\r\n\r\n        // New kitty starts with the same cooldown as parent gen/2\r\n        uint16 cooldownIndex = uint16(_generation / 2);\r\n        if (cooldownIndex > 13) {\r\n            cooldownIndex = 13;\r\n        }\r\n\r\n        Kitty memory _kitty = Kitty({\r\n            genes: _genes,\r\n            birthTime: uint64(now),\r\n            cooldownEndBlock: 0,\r\n            matronId: uint32(_matronId),\r\n            sireId: uint32(_sireId),\r\n            siringWithId: 0,\r\n            cooldownIndex: cooldownIndex,\r\n            generation: uint16(_generation)\r\n        });\r\n        uint256 newKittenId = kitties.push(_kitty) - 1;\r\n\r\n        // It's probably never going to happen, 4 billion cats is A LOT, but\r\n        // let's just be 100% sure we never let this happen.\r\n        require(newKittenId == uint256(uint32(newKittenId)));\r\n\r\n        // emit the birth event\r\n        Birth(\r\n            _owner,\r\n            newKittenId,\r\n            uint256(_kitty.matronId),\r\n            uint256(_kitty.sireId),\r\n            _kitty.genes\r\n        );\r\n\r\n        // This will assign ownership, and also emit the Transfer event as\r\n        // per ERC721 draft\r\n        _transfer(0, _owner, newKittenId);\r\n\r\n        return newKittenId;\r\n    }\r\n\r\n    // Any C-level can fix how many seconds per blocks are currently observed.\r\n    function setSecondsPerBlock(uint256 secs) external onlyCLevel {\r\n        require(secs < cooldowns[0]);\r\n        secondsPerBlock = secs;\r\n    }\r\n}\r\n\r\n\r\n\r\n\r\n\r\n/// @title The external contract that is responsible for generating metadata for the kitties,\r\n///  it has one function that will return the data as bytes.\r\ncontract ERC721Metadata {\r\n    /// @dev Given a token Id, returns a byte array that is supposed to be converted into string.\r\n    function getMetadata(uint256 _tokenId, string) public view returns (bytes32[4] buffer, uint256 count) {\r\n        if (_tokenId == 1) {\r\n            buffer[0] = \"Hello World! :D\";\r\n            count = 15;\r\n        } else if (_tokenId == 2) {\r\n            buffer[0] = \"I would definitely choose a medi\";\r\n            buffer[1] = \"um length string.\";\r\n            count = 49;\r\n        } else if (_tokenId == 3) {\r\n            buffer[0] = \"Lorem ipsum dolor sit amet, mi e\";\r\n            buffer[1] = \"st accumsan dapibus augue lorem,\";\r\n            buffer[2] = \" tristique vestibulum id, libero\";\r\n            buffer[3] = \" suscipit varius sapien aliquam.\";\r\n            count = 128;\r\n        }\r\n    }\r\n}\r\n\r\n\r\n/// @title The facet of the CryptoKitties core contract that manages ownership, ERC-721 (draft) compliant.\r\n/// @author Axiom Zen (https://www.axiomzen.co)\r\n/// @dev Ref: https://github.com/ethereum/EIPs/issues/721\r\n///  See the KittyCore contract documentation to understand how the various contract facets are arranged.\r\ncontract KittyOwnership is KittyBase, ERC721 {\r\n\r\n    /// @notice Name and symbol of the non fungible token, as defined in ERC721.\r\n    string public constant name = \"CryptoKitties\";\r\n    string public constant symbol = \"CK\";\r\n\r\n    // The contract that will return kitty metadata\r\n    ERC721Metadata public erc721Metadata;\r\n\r\n    bytes4 constant InterfaceSignature_ERC165 =\r\n        bytes4(keccak256('supportsInterface(bytes4)'));\r\n\r\n    bytes4 constant InterfaceSignature_ERC721 =\r\n        bytes4(keccak256('name()')) ^\r\n        bytes4(keccak256('symbol()')) ^\r\n        bytes4(keccak256('totalSupply()')) ^\r\n        bytes4(keccak256('balanceOf(address)')) ^\r\n        bytes4(keccak256('ownerOf(uint256)')) ^\r\n        bytes4(keccak256('approve(address,uint256)')) ^\r\n        bytes4(keccak256('transfer(address,uint256)')) ^\r\n        bytes4(keccak256('transferFrom(address,address,uint256)')) ^\r\n        bytes4(keccak256('tokensOfOwner(address)')) ^\r\n        bytes4(keccak256('tokenMetadata(uint256,string)'));\r\n\r\n    /// @notice Introspection interface as per ERC-165 (https://github.com/ethereum/EIPs/issues/165).\r\n    ///  Returns true for any standardized interfaces implemented by this contract. We implement\r\n    ///  ERC-165 (obviously!) and ERC-721.\r\n    function supportsInterface(bytes4 _interfaceID) external view returns (bool)\r\n    {\r\n        // DEBUG ONLY\r\n        //require((InterfaceSignature_ERC165 == 0x01ffc9a7) && (InterfaceSignature_ERC721 == 0x9a20483d));\r\n\r\n        return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721));\r\n    }\r\n\r\n    /// @dev Set the address of the sibling contract that tracks metadata.\r\n    ///  CEO only.\r\n    function setMetadataAddress(address _contractAddress) public onlyCEO {\r\n        erc721Metadata = ERC721Metadata(_contractAddress);\r\n    }\r\n\r\n    // Internal utility functions: These functions all assume that their input arguments\r\n    // are valid. We leave it to public methods to sanitize their inputs and follow\r\n    // the required logic.\r\n\r\n    /// @dev Checks if a given address is the current owner of a particular Kitty.\r\n    /// @param _claimant the address we are validating against.\r\n    /// @param _tokenId kitten id, only valid when > 0\r\n    function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {\r\n        return kittyIndexToOwner[_tokenId] == _claimant;\r\n    }\r\n\r\n    /// @dev Checks if a given address currently has transferApproval for a particular Kitty.\r\n    /// @param _claimant the address we are confirming kitten is approved for.\r\n    /// @param _tokenId kitten id, only valid when > 0\r\n    function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) {\r\n        return kittyIndexToApproved[_tokenId] == _claimant;\r\n    }\r\n\r\n    /// @dev Marks an address as being approved for transferFrom(), overwriting any previous\r\n    ///  approval. Setting _approved to address(0) clears all transfer approval.\r\n    ///  NOTE: _approve() does NOT send the Approval event. This is intentional because\r\n    ///  _approve() and transferFrom() are used together for putting Kitties on auction, and\r\n    ///  there is no value in spamming the log with Approval events in that case.\r\n    function _approve(uint256 _tokenId, address _approved) internal {\r\n        kittyIndexToApproved[_tokenId] = _approved;\r\n    }\r\n\r\n    /// @notice Returns the number of Kitties owned by a specific address.\r\n    /// @param _owner The owner address to check.\r\n    /// @dev Required for ERC-721 compliance\r\n    function balanceOf(address _owner) public view returns (uint256 count) {\r\n        return ownershipTokenCount[_owner];\r\n    }\r\n\r\n    /// @notice Transfers a Kitty to another address. If transferring to a smart\r\n    ///  contract be VERY CAREFUL to ensure that it is aware of ERC-721 (or\r\n    ///  CryptoKitties specifically) or your Kitty may be lost forever. Seriously.\r\n    /// @param _to The address of the recipient, can be a user or contract.\r\n    /// @param _tokenId The ID of the Kitty to transfer.\r\n    /// @dev Required for ERC-721 compliance.\r\n    function transfer(\r\n        address _to,\r\n        uint256 _tokenId\r\n    )\r\n        external\r\n        whenNotPaused\r\n    {\r\n        // Safety check to prevent against an unexpected 0x0 default.\r\n        require(_to != address(0));\r\n        // Disallow transfers to this contract to prevent accidental misuse.\r\n        // The contract should never own any kitties (except very briefly\r\n        // after a gen0 cat is created and before it goes on auction).\r\n        require(_to != address(this));\r\n        // Disallow transfers to the auction contracts to prevent accidental\r\n        // misuse. Auction contracts should only take ownership of kitties\r\n        // through the allow + transferFrom flow.\r\n        require(_to != address(saleAuction));\r\n        require(_to != address(siringAuction));\r\n\r\n        // You can only send your own cat.\r\n        require(_owns(msg.sender, _tokenId));\r\n\r\n        // Reassign ownership, clear pending approvals, emit Transfer event.\r\n        _transfer(msg.sender, _to, _tokenId);\r\n    }\r\n\r\n    /// @notice Grant another address the right to transfer a specific Kitty via\r\n    ///  transferFrom(). This is the preferred flow for transfering NFTs to contracts.\r\n    /// @param _to The address to be granted transfer approval. Pass address(0) to\r\n    ///  clear all approvals.\r\n    /// @param _tokenId The ID of the Kitty that can be transferred if this call succeeds.\r\n    /// @dev Required for ERC-721 compliance.\r\n    function approve(\r\n        address _to,\r\n        uint256 _tokenId\r\n    )\r\n        external\r\n        whenNotPaused\r\n    {\r\n        // Only an owner can grant transfer approval.\r\n        require(_owns(msg.sender, _tokenId));\r\n\r\n        // Register the approval (replacing any previous approval).\r\n        _approve(_tokenId, _to);\r\n\r\n        // Emit approval event.\r\n        Approval(msg.sender, _to, _tokenId);\r\n    }\r\n\r\n    /// @notice Transfer a Kitty owned by another address, for which the calling address\r\n    ///  has previously been granted transfer approval by the owner.\r\n    /// @param _from The address that owns the Kitty to be transfered.\r\n    /// @param _to The address that should take ownership of the Kitty. Can be any address,\r\n    ///  including the caller.\r\n    /// @param _tokenId The ID of the Kitty to be transferred.\r\n    /// @dev Required for ERC-721 compliance.\r\n    function transferFrom(\r\n        address _from,\r\n        address _to,\r\n        uint256 _tokenId\r\n    )\r\n        external\r\n        whenNotPaused\r\n    {\r\n        // Safety check to prevent against an unexpected 0x0 default.\r\n        require(_to != address(0));\r\n        // Disallow transfers to this contract to prevent accidental misuse.\r\n        // The contract should never own any kitties (except very briefly\r\n        // after a gen0 cat is created and before it goes on auction).\r\n        require(_to != address(this));\r\n        // Check for approval and valid ownership\r\n        require(_approvedFor(msg.sender, _tokenId));\r\n        require(_owns(_from, _tokenId));\r\n\r\n        // Reassign ownership (also clears pending approvals and emits Transfer event).\r\n        _transfer(_from, _to, _tokenId);\r\n    }\r\n\r\n    /// @notice Returns the total number of Kitties currently in existence.\r\n    /// @dev Required for ERC-721 compliance.\r\n    function totalSupply() public view returns (uint) {\r\n        return kitties.length - 1;\r\n    }\r\n\r\n    /// @notice Returns the address currently assigned ownership of a given Kitty.\r\n    /// @dev Required for ERC-721 compliance.\r\n    function ownerOf(uint256 _tokenId)\r\n        external\r\n        view\r\n        returns (address owner)\r\n    {\r\n        owner = kittyIndexToOwner[_tokenId];\r\n\r\n        require(owner != address(0));\r\n    }\r\n\r\n    /// @notice Returns a list of all Kitty IDs assigned to an address.\r\n    /// @param _owner The owner whose Kitties we are interested in.\r\n    /// @dev This method MUST NEVER be called by smart contract code. First, it's fairly\r\n    ///  expensive (it walks the entire Kitty array looking for cats belonging to owner),\r\n    ///  but it also returns a dynamic array, which is only supported for web3 calls, and\r\n    ///  not contract-to-contract calls.\r\n    function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {\r\n        uint256 tokenCount = balanceOf(_owner);\r\n\r\n        if (tokenCount == 0) {\r\n            // Return an empty array\r\n            return new uint256[](0);\r\n        } else {\r\n            uint256[] memory result = new uint256[](tokenCount);\r\n            uint256 totalCats = totalSupply();\r\n            uint256 resultIndex = 0;\r\n\r\n            // We count on the fact that all cats have IDs starting at 1 and increasing\r\n            // sequentially up to the totalCat count.\r\n            uint256 catId;\r\n\r\n            for (catId = 1; catId <= totalCats; catId++) {\r\n                if (kittyIndexToOwner[catId] == _owner) {\r\n                    result[resultIndex] = catId;\r\n                    resultIndex++;\r\n                }\r\n            }\r\n\r\n            return result;\r\n        }\r\n    }\r\n\r\n    /// @dev Adapted from memcpy() by @arachnid (Nick Johnson <arachnid@notdot.net>)\r\n    ///  This method is licenced under the Apache License.\r\n    ///  Ref: https://github.com/Arachnid/solidity-stringutils/blob/2f6ca9accb48ae14c66f1437ec50ed19a0616f78/strings.sol\r\n    function _memcpy(uint _dest, uint _src, uint _len) private view {\r\n        // Copy word-length chunks while possible\r\n        for(; _len >= 32; _len -= 32) {\r\n            assembly {\r\n                mstore(_dest, mload(_src))\r\n            }\r\n            _dest += 32;\r\n            _src += 32;\r\n        }\r\n\r\n        // Copy remaining bytes\r\n        uint256 mask = 256 ** (32 - _len) - 1;\r\n        assembly {\r\n            let srcpart := and(mload(_src), not(mask))\r\n            let destpart := and(mload(_dest), mask)\r\n            mstore(_dest, or(destpart, srcpart))\r\n        }\r\n    }\r\n\r\n    /// @dev Adapted from toString(slice) by @arachnid (Nick Johnson <arachnid@notdot.net>)\r\n    ///  This method is licenced under the Apache License.\r\n    ///  Ref: https://github.com/Arachnid/solidity-stringutils/blob/2f6ca9accb48ae14c66f1437ec50ed19a0616f78/strings.sol\r\n    function _toString(bytes32[4] _rawBytes, uint256 _stringLength) private view returns (string) {\r\n        var outputString = new string(_stringLength);\r\n        uint256 outputPtr;\r\n        uint256 bytesPtr;\r\n\r\n        assembly {\r\n            outputPtr := add(outputString, 32)\r\n            bytesPtr := _rawBytes\r\n        }\r\n\r\n        _memcpy(outputPtr, bytesPtr, _stringLength);\r\n\r\n        return outputString;\r\n    }\r\n\r\n    /// @notice Returns a URI pointing to a metadata package for this token conforming to\r\n    ///  ERC-721 (https://github.com/ethereum/EIPs/issues/721)\r\n    /// @param _tokenId The ID number of the Kitty whose metadata should be returned.\r\n    function tokenMetadata(uint256 _tokenId, string _preferredTransport) external view returns (string infoUrl) {\r\n        require(erc721Metadata != address(0));\r\n        bytes32[4] memory buffer;\r\n        uint256 count;\r\n        (buffer, count) = erc721Metadata.getMetadata(_tokenId, _preferredTransport);\r\n\r\n        return _toString(buffer, count);\r\n    }\r\n}\r\n\r\n\r\n\r\n/// @title A facet of KittyCore that manages Kitty siring, gestation, and birth.\r\n/// @author Axiom Zen (https://www.axiomzen.co)\r\n/// @dev See the KittyCore contract documentation to understand how the various contract facets are arranged.\r\ncontract KittyBreeding is KittyOwnership {\r\n\r\n    /// @dev The Pregnant event is fired when two cats successfully breed and the pregnancy\r\n    ///  timer begins for the matron.\r\n    event Pregnant(address owner, uint256 matronId, uint256 sireId, uint256 cooldownEndBlock);\r\n\r\n    /// @notice The minimum payment required to use breedWithAuto(). This fee goes towards\r\n    ///  the gas cost paid by whatever calls giveBirth(), and can be dynamically updated by\r\n    ///  the COO role as the gas price changes.\r\n    uint256 public autoBirthFee = 2 finney;\r\n\r\n    // Keeps track of number of pregnant kitties.\r\n    uint256 public pregnantKitties;\r\n\r\n    /// @dev The address of the sibling contract that is used to implement the sooper-sekret\r\n    ///  genetic combination algorithm.\r\n    GeneScienceInterface public geneScience;\r\n\r\n    /// @dev Update the address of the genetic contract, can only be called by the CEO.\r\n    /// @param _address An address of a GeneScience contract instance to be used from this point forward.\r\n    function setGeneScienceAddress(address _address) external onlyCEO {\r\n        GeneScienceInterface candidateContract = GeneScienceInterface(_address);\r\n\r\n        // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117\r\n        require(candidateContract.isGeneScience());\r\n\r\n        // Set the new contract address\r\n        geneScience = candidateContract;\r\n    }\r\n\r\n    /// @dev Checks that a given kitten is able to breed. Requires that the\r\n    ///  current cooldown is finished (for sires) and also checks that there is\r\n    ///  no pending pregnancy.\r\n    function _isReadyToBreed(Kitty _kit) internal view returns (bool) {\r\n        // In addition to checking the cooldownEndBlock, we also need to check to see if\r\n        // the cat has a pending birth; there can be some period of time between the end\r\n        // of the pregnacy timer and the birth event.\r\n        return (_kit.siringWithId == 0) && (_kit.cooldownEndBlock <= uint64(block.number));\r\n    }\r\n\r\n    /// @dev Check if a sire has authorized breeding with this matron. True if both sire\r\n    ///  and matron have the same owner, or if the sire has given siring permission to\r\n    ///  the matron's owner (via approveSiring()).\r\n    function _isSiringPermitted(uint256 _sireId, uint256 _matronId) internal view returns (bool) {\r\n        address matronOwner = kittyIndexToOwner[_matronId];\r\n        address sireOwner = kittyIndexToOwner[_sireId];\r\n\r\n        // Siring is okay if they have same owner, or if the matron's owner was given\r\n        // permission to breed with this sire.\r\n        return (matronOwner == sireOwner || sireAllowedToAddress[_sireId] == matronOwner);\r\n    }\r\n\r\n    /// @dev Set the cooldownEndTime for the given Kitty, based on its current cooldownIndex.\r\n    ///  Also increments the cooldownIndex (unless it has hit the cap).\r\n    /// @param _kitten A reference to the Kitty in storage which needs its timer started.\r\n    function _triggerCooldown(Kitty storage _kitten) internal {\r\n        // Compute an estimation of the cooldown time in blocks (based on current cooldownIndex).\r\n        _kitten.cooldownEndBlock = uint64((cooldowns[_kitten.cooldownIndex]/secondsPerBlock) + block.number);\r\n\r\n        // Increment the breeding count, clamping it at 13, which is the length of the\r\n        // cooldowns array. We could check the array size dynamically, but hard-coding\r\n        // this as a constant saves gas. Yay, Solidity!\r\n        if (_kitten.cooldownIndex < 13) {\r\n            _kitten.cooldownIndex += 1;\r\n        }\r\n    }\r\n\r\n    /// @notice Grants approval to another user to sire with one of your Kitties.\r\n    /// @param _addr The address that will be able to sire with your Kitty. Set to\r\n    ///  address(0) to clear all siring approvals for this Kitty.\r\n    /// @param _sireId A Kitty that you own that _addr will now be able to sire with.\r\n    function approveSiring(address _addr, uint256 _sireId)\r\n        external\r\n        whenNotPaused\r\n    {\r\n        require(_owns(msg.sender, _sireId));\r\n        sireAllowedToAddress[_sireId] = _addr;\r\n    }\r\n\r\n    /// @dev Updates the minimum payment required for calling giveBirthAuto(). Can only\r\n    ///  be called by the COO address. (This fee is used to offset the gas cost incurred\r\n    ///  by the autobirth daemon).\r\n    function setAutoBirthFee(uint256 val) external onlyCOO {\r\n        autoBirthFee = val;\r\n    }\r\n\r\n    /// @dev Checks to see if a given Kitty is pregnant and (if so) if the gestation\r\n    ///  period has passed.\r\n    function _isReadyToGiveBirth(Kitty _matron) private view returns (bool) {\r\n        return (_matron.siringWithId != 0) && (_matron.cooldownEndBlock <= uint64(block.number));\r\n    }\r\n\r\n    /// @notice Checks that a given kitten is able to breed (i.e. it is not pregnant or\r\n    ///  in the middle of a siring cooldown).\r\n    /// @param _kittyId reference the id of the kitten, any user can inquire about it\r\n    function isReadyToBreed(uint256 _kittyId)\r\n        public\r\n        view\r\n        returns (bool)\r\n    {\r\n        require(_kittyId > 0);\r\n        Kitty storage kit = kitties[_kittyId];\r\n        return _isReadyToBreed(kit);\r\n    }\r\n\r\n    /// @dev Checks whether a kitty is currently pregnant.\r\n    /// @param _kittyId reference the id of the kitten, any user can inquire about it\r\n    function isPregnant(uint256 _kittyId)\r\n        public\r\n        view\r\n        returns (bool)\r\n    {\r\n        require(_kittyId > 0);\r\n        // A kitty is pregnant if and only if this field is set\r\n        return kitties[_kittyId].siringWithId != 0;\r\n    }\r\n\r\n    /// @dev Internal check to see if a given sire and matron are a valid mating pair. DOES NOT\r\n    ///  check ownership permissions (that is up to the caller).\r\n    /// @param _matron A reference to the Kitty struct of the potential matron.\r\n    /// @param _matronId The matron's ID.\r\n    /// @param _sire A reference to the Kitty struct of the potential sire.\r\n    /// @param _sireId The sire's ID\r\n    function _isValidMatingPair(\r\n        Kitty storage _matron,\r\n        uint256 _matronId,\r\n        Kitty storage _sire,\r\n        uint256 _sireId\r\n    )\r\n        private\r\n        view\r\n        returns(bool)\r\n    {\r\n        // A Kitty can't breed with itself!\r\n        if (_matronId == _sireId) {\r\n            return false;\r\n        }\r\n\r\n        // Kitties can't breed with their parents.\r\n        if (_matron.matronId == _sireId || _matron.sireId == _sireId) {\r\n            return false;\r\n        }\r\n        if (_sire.matronId == _matronId || _sire.sireId == _matronId) {\r\n            return false;\r\n        }\r\n\r\n        // We can short circuit the sibling check (below) if either cat is\r\n        // gen zero (has a matron ID of zero).\r\n        if (_sire.matronId == 0 || _matron.matronId == 0) {\r\n            return true;\r\n        }\r\n\r\n        // Kitties can't breed with full or half siblings.\r\n        if (_sire.matronId == _matron.matronId || _sire.matronId == _matron.sireId) {\r\n            return false;\r\n        }\r\n        if (_sire.sireId == _matron.matronId || _sire.sireId == _matron.sireId) {\r\n            return false;\r\n        }\r\n\r\n        // Everything seems cool! Let's get DTF.\r\n        return true;\r\n    }\r\n\r\n    /// @dev Internal check to see if a given sire and matron are a valid mating pair for\r\n    ///  breeding via auction (i.e. skips ownership and siring approval checks).\r\n    function _canBreedWithViaAuction(uint256 _matronId, uint256 _sireId)\r\n        internal\r\n        view\r\n        returns (bool)\r\n    {\r\n        Kitty storage matron = kitties[_matronId];\r\n        Kitty storage sire = kitties[_sireId];\r\n        return _isValidMatingPair(matron, _matronId, sire, _sireId);\r\n    }\r\n\r\n    /// @notice Checks to see if two cats can breed together, including checks for\r\n    ///  ownership and siring approvals. Does NOT check that both cats are ready for\r\n    ///  breeding (i.e. breedWith could still fail until the cooldowns are finished).\r\n    ///  TODO: Shouldn't this check pregnancy and cooldowns?!?\r\n    /// @param _matronId The ID of the proposed matron.\r\n    /// @param _sireId The ID of the proposed sire.\r\n    function canBreedWith(uint256 _matronId, uint256 _sireId)\r\n        external\r\n        view\r\n        returns(bool)\r\n    {\r\n        require(_matronId > 0);\r\n        require(_sireId > 0);\r\n        Kitty storage matron = kitties[_matronId];\r\n        Kitty storage sire = kitties[_sireId];\r\n        return _isValidMatingPair(matron, _matronId, sire, _sireId) &&\r\n            _isSiringPermitted(_sireId, _matronId);\r\n    }\r\n\r\n    /// @dev Internal utility function to initiate breeding, assumes that all breeding\r\n    ///  requirements have been checked.\r\n    function _breedWith(uint256 _matronId, uint256 _sireId) internal {\r\n        // Grab a reference to the Kitties from storage.\r\n        Kitty storage sire = kitties[_sireId];\r\n        Kitty storage matron = kitties[_matronId];\r\n\r\n        // Mark the matron as pregnant, keeping track of who the sire is.\r\n        matron.siringWithId = uint32(_sireId);\r\n\r\n        // Trigger the cooldown for both parents.\r\n        _triggerCooldown(sire);\r\n        _triggerCooldown(matron);\r\n\r\n        // Clear siring permission for both parents. This may not be strictly necessary\r\n        // but it's likely to avoid confusion!\r\n        delete sireAllowedToAddress[_matronId];\r\n        delete sireAllowedToAddress[_sireId];\r\n\r\n        // Every time a kitty gets pregnant, counter is incremented.\r\n        pregnantKitties++;\r\n\r\n        // Emit the pregnancy event.\r\n        Pregnant(kittyIndexToOwner[_matronId], _matronId, _sireId, matron.cooldownEndBlock);\r\n    }\r\n\r\n    /// @notice Breed a Kitty you own (as matron) with a sire that you own, or for which you\r\n    ///  have previously been given Siring approval. Will either make your cat pregnant, or will\r\n    ///  fail entirely. Requires a pre-payment of the fee given out to the first caller of giveBirth()\r\n    /// @param _matronId The ID of the Kitty acting as matron (will end up pregnant if successful)\r\n    /// @param _sireId The ID of the Kitty acting as sire (will begin its siring cooldown if successful)\r\n    function breedWithAuto(uint256 _matronId, uint256 _sireId)\r\n        external\r\n        payable\r\n        whenNotPaused\r\n    {\r\n        // Checks for payment.\r\n        require(msg.value >= autoBirthFee);\r\n\r\n        // Caller must own the matron.\r\n        require(_owns(msg.sender, _matronId));\r\n\r\n        // Neither sire nor matron are allowed to be on auction during a normal\r\n        // breeding operation, but we don't need to check that explicitly.\r\n        // For matron: The caller of this function can't be the owner of the matron\r\n        //   because the owner of a Kitty on auction is the auction house, and the\r\n        //   auction house will never call breedWith().\r\n        // For sire: Similarly, a sire on auction will be owned by the auction house\r\n        //   and the act of transferring ownership will have cleared any oustanding\r\n        //   siring approval.\r\n        // Thus we don't need to spend gas explicitly checking to see if either cat\r\n        // is on auction.\r\n\r\n        // Check that matron and sire are both owned by caller, or that the sire\r\n        // has given siring permission to caller (i.e. matron's owner).\r\n        // Will fail for _sireId = 0\r\n        require(_isSiringPermitted(_sireId, _matronId));\r\n\r\n        // Grab a reference to the potential matron\r\n        Kitty storage matron = kitties[_matronId];\r\n\r\n        // Make sure matron isn't pregnant, or in the middle of a siring cooldown\r\n        require(_isReadyToBreed(matron));\r\n\r\n        // Grab a reference to the potential sire\r\n        Kitty storage sire = kitties[_sireId];\r\n\r\n        // Make sure sire isn't pregnant, or in the middle of a siring cooldown\r\n        require(_isReadyToBreed(sire));\r\n\r\n        // Test that these cats are a valid mating pair.\r\n        require(_isValidMatingPair(\r\n            matron,\r\n            _matronId,\r\n            sire,\r\n            _sireId\r\n        ));\r\n\r\n        // All checks passed, kitty gets pregnant!\r\n        _breedWith(_matronId, _sireId);\r\n    }\r\n\r\n    /// @notice Have a pregnant Kitty give birth!\r\n    /// @param _matronId A Kitty ready to give birth.\r\n    /// @return The Kitty ID of the new kitten.\r\n    /// @dev Looks at a given Kitty and, if pregnant and if the gestation period has passed,\r\n    ///  combines the genes of the two parents to create a new kitten. The new Kitty is assigned\r\n    ///  to the current owner of the matron. Upon successful completion, both the matron and the\r\n    ///  new kitten will be ready to breed again. Note that anyone can call this function (if they\r\n    ///  are willing to pay the gas!), but the new kitten always goes to the mother's owner.\r\n    function giveBirth(uint256 _matronId)\r\n        external\r\n        whenNotPaused\r\n        returns(uint256)\r\n    {\r\n        // Grab a reference to the matron in storage.\r\n        Kitty storage matron = kitties[_matronId];\r\n\r\n        // Check that the matron is a valid cat.\r\n        require(matron.birthTime != 0);\r\n\r\n        // Check that the matron is pregnant, and that its time has come!\r\n        require(_isReadyToGiveBirth(matron));\r\n\r\n        // Grab a reference to the sire in storage.\r\n        uint256 sireId = matron.siringWithId;\r\n        Kitty storage sire = kitties[sireId];\r\n\r\n        // Determine the higher generation number of the two parents\r\n        uint16 parentGen = matron.generation;\r\n        if (sire.generation > matron.generation) {\r\n            parentGen = sire.generation;\r\n        }\r\n\r\n        // Call the sooper-sekret gene mixing operation.\r\n        uint256 childGenes = geneScience.mixGenes(matron.genes, sire.genes, matron.cooldownEndBlock - 1);\r\n\r\n        // Make the new kitten!\r\n        address owner = kittyIndexToOwner[_matronId];\r\n        uint256 kittenId = _createKitty(_matronId, matron.siringWithId, parentGen + 1, childGenes, owner);\r\n\r\n        // Clear the reference to sire from the matron (REQUIRED! Having siringWithId\r\n        // set is what marks a matron as being pregnant.)\r\n        delete matron.siringWithId;\r\n\r\n        // Every time a kitty gives birth counter is decremented.\r\n        pregnantKitties--;\r\n\r\n        // Send the balance fee to the person who made birth happen.\r\n        msg.sender.send(autoBirthFee);\r\n\r\n        // return the new kitten's ID\r\n        return kittenId;\r\n    }\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/// @title Auction Core\r\n/// @dev Contains models, variables, and internal methods for the auction.\r\n/// @notice We omit a fallback function to prevent accidental sends to this contract.\r\ncontract ClockAuctionBase {\r\n\r\n    // Represents an auction on an NFT\r\n    struct Auction {\r\n        // Current owner of NFT\r\n        address seller;\r\n        // Price (in wei) at beginning of auction\r\n        uint128 startingPrice;\r\n        // Price (in wei) at end of auction\r\n        uint128 endingPrice;\r\n        // Duration (in seconds) of auction\r\n        uint64 duration;\r\n        // Time when auction started\r\n        // NOTE: 0 if this auction has been concluded\r\n        uint64 startedAt;\r\n    }\r\n\r\n    // Reference to contract tracking NFT ownership\r\n    ERC721 public nonFungibleContract;\r\n\r\n    // Cut owner takes on each auction, measured in basis points (1/100 of a percent).\r\n    // Values 0-10,000 map to 0%-100%\r\n    uint256 public ownerCut;\r\n\r\n    // Map from token ID to their corresponding auction.\r\n    mapping (uint256 => Auction) tokenIdToAuction;\r\n\r\n    event AuctionCreated(uint256 tokenId, uint256 startingPrice, uint256 endingPrice, uint256 duration);\r\n    event AuctionSuccessful(uint256 tokenId, uint256 totalPrice, address winner);\r\n    event AuctionCancelled(uint256 tokenId);\r\n\r\n    /// @dev Returns true if the claimant owns the token.\r\n    /// @param _claimant - Address claiming to own the token.\r\n    /// @param _tokenId - ID of token whose ownership to verify.\r\n    function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {\r\n        return (nonFungibleContract.ownerOf(_tokenId) == _claimant);\r\n    }\r\n\r\n    /// @dev Escrows the NFT, assigning ownership to this contract.\r\n    /// Throws if the escrow fails.\r\n    /// @param _owner - Current owner address of token to escrow.\r\n    /// @param _tokenId - ID of token whose approval to verify.\r\n    function _escrow(address _owner, uint256 _tokenId) internal {\r\n        // it will throw if transfer fails\r\n        nonFungibleContract.transferFrom(_owner, this, _tokenId);\r\n    }\r\n\r\n    /// @dev Transfers an NFT owned by this contract to another address.\r\n    /// Returns true if the transfer succeeds.\r\n    /// @param _receiver - Address to transfer NFT to.\r\n    /// @param _tokenId - ID of token to transfer.\r\n    function _transfer(address _receiver, uint256 _tokenId) internal {\r\n        // it will throw if transfer fails\r\n        nonFungibleContract.transfer(_receiver, _tokenId);\r\n    }\r\n\r\n    /// @dev Adds an auction to the list of open auctions. Also fires the\r\n    ///  AuctionCreated event.\r\n    /// @param _tokenId The ID of the token to be put on auction.\r\n    /// @param _auction Auction to add.\r\n    function _addAuction(uint256 _tokenId, Auction _auction) internal {\r\n        // Require that all auctions have a duration of\r\n        // at least one minute. (Keeps our math from getting hairy!)\r\n        require(_auction.duration >= 1 minutes);\r\n\r\n        tokenIdToAuction[_tokenId] = _auction;\r\n\r\n        AuctionCreated(\r\n            uint256(_tokenId),\r\n            uint256(_auction.startingPrice),\r\n            uint256(_auction.endingPrice),\r\n            uint256(_auction.duration)\r\n        );\r\n    }\r\n\r\n    /// @dev Cancels an auction unconditionally.\r\n    function _cancelAuction(uint256 _tokenId, address _seller) internal {\r\n        _removeAuction(_tokenId);\r\n        _transfer(_seller, _tokenId);\r\n        AuctionCancelled(_tokenId);\r\n    }\r\n\r\n    /// @dev Computes the price and transfers winnings.\r\n    /// Does NOT transfer ownership of token.\r\n    function _bid(uint256 _tokenId, uint256 _bidAmount)\r\n        internal\r\n        returns (uint256)\r\n    {\r\n        // Get a reference to the auction struct\r\n        Auction storage auction = tokenIdToAuction[_tokenId];\r\n\r\n        // Explicitly check that this auction is currently live.\r\n        // (Because of how Ethereum mappings work, we can't just count\r\n        // on the lookup above failing. An invalid _tokenId will just\r\n        // return an auction object that is all zeros.)\r\n        require(_isOnAuction(auction));\r\n\r\n        // Check that the bid is greater than or equal to the current price\r\n        uint256 price = _currentPrice(auction);\r\n        require(_bidAmount >= price);\r\n\r\n        // Grab a reference to the seller before the auction struct\r\n        // gets deleted.\r\n        address seller = auction.seller;\r\n\r\n        // The bid is good! Remove the auction before sending the fees\r\n        // to the sender so we can't have a reentrancy attack.\r\n        _removeAuction(_tokenId);\r\n\r\n        // Transfer proceeds to seller (if there are any!)\r\n        if (price > 0) {\r\n            // Calculate the auctioneer's cut.\r\n            // (NOTE: _computeCut() is guaranteed to return a\r\n            // value <= price, so this subtraction can't go negative.)\r\n            uint256 auctioneerCut = _computeCut(price);\r\n            uint256 sellerProceeds = price - auctioneerCut;\r\n\r\n            // NOTE: Doing a transfer() in the middle of a complex\r\n            // method like this is generally discouraged because of\r\n            // reentrancy attacks and DoS attacks if the seller is\r\n            // a contract with an invalid fallback function. We explicitly\r\n            // guard against reentrancy attacks by removing the auction\r\n            // before calling transfer(), and the only thing the seller\r\n            // can DoS is the sale of their own asset! (And if it's an\r\n            // accident, they can call cancelAuction(). )\r\n            seller.transfer(sellerProceeds);\r\n        }\r\n\r\n        // Calculate any excess funds included with the bid. If the excess\r\n        // is anything worth worrying about, transfer it back to bidder.\r\n        // NOTE: We checked above that the bid amount is greater than or\r\n        // equal to the price so this cannot underflow.\r\n        uint256 bidExcess = _bidAmount - price;\r\n\r\n        // Return the funds. Similar to the previous transfer, this is\r\n        // not susceptible to a re-entry attack because the auction is\r\n        // removed before any transfers occur.\r\n        msg.sender.transfer(bidExcess);\r\n\r\n        // Tell the world!\r\n        AuctionSuccessful(_tokenId, price, msg.sender);\r\n\r\n        return price;\r\n    }\r\n\r\n    /// @dev Removes an auction from the list of open auctions.\r\n    /// @param _tokenId - ID of NFT on auction.\r\n    function _removeAuction(uint256 _tokenId) internal {\r\n        delete tokenIdToAuction[_tokenId];\r\n    }\r\n\r\n    /// @dev Returns true if the NFT is on auction.\r\n    /// @param _auction - Auction to check.\r\n    function _isOnAuction(Auction storage _auction) internal view returns (bool) {\r\n        return (_auction.startedAt > 0);\r\n    }\r\n\r\n    /// @dev Returns current price of an NFT on auction. Broken into two\r\n    ///  functions (this one, that computes the duration from the auction\r\n    ///  structure, and the other that does the price computation) so we\r\n    ///  can easily test that the price computation works correctly.\r\n    function _currentPrice(Auction storage _auction)\r\n        internal\r\n        view\r\n        returns (uint256)\r\n    {\r\n        uint256 secondsPassed = 0;\r\n\r\n        // A bit of insurance against negative values (or wraparound).\r\n        // Probably not necessary (since Ethereum guarnatees that the\r\n        // now variable doesn't ever go backwards).\r\n        if (now > _auction.startedAt) {\r\n            secondsPassed = now - _auction.startedAt;\r\n        }\r\n\r\n        return _computeCurrentPrice(\r\n            _auction.startingPrice,\r\n            _auction.endingPrice,\r\n            _auction.duration,\r\n            secondsPassed\r\n        );\r\n    }\r\n\r\n    /// @dev Computes the current price of an auction. Factored out\r\n    ///  from _currentPrice so we can run extensive unit tests.\r\n    ///  When testing, make this function public and turn on\r\n    ///  `Current price computation` test suite.\r\n    function _computeCurrentPrice(\r\n        uint256 _startingPrice,\r\n        uint256 _endingPrice,\r\n        uint256 _duration,\r\n        uint256 _secondsPassed\r\n    )\r\n        internal\r\n        pure\r\n        returns (uint256)\r\n    {\r\n        // NOTE: We don't use SafeMath (or similar) in this function because\r\n        //  all of our public functions carefully cap the maximum values for\r\n        //  time (at 64-bits) and currency (at 128-bits). _duration is\r\n        //  also known to be non-zero (see the require() statement in\r\n        //  _addAuction())\r\n        if (_secondsPassed >= _duration) {\r\n            // We've reached the end of the dynamic pricing portion\r\n            // of the auction, just return the end price.\r\n            return _endingPrice;\r\n        } else {\r\n            // Starting price can be higher than ending price (and often is!), so\r\n            // this delta can be negative.\r\n            int256 totalPriceChange = int256(_endingPrice) - int256(_startingPrice);\r\n\r\n            // This multiplication can't overflow, _secondsPassed will easily fit within\r\n            // 64-bits, and totalPriceChange will easily fit within 128-bits, their product\r\n            // will always fit within 256-bits.\r\n            int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration);\r\n\r\n            // currentPriceChange can be negative, but if so, will have a magnitude\r\n            // less that _startingPrice. Thus, this result will always end up positive.\r\n            int256 currentPrice = int256(_startingPrice) + currentPriceChange;\r\n\r\n            return uint256(currentPrice);\r\n        }\r\n    }\r\n\r\n    /// @dev Computes owner's cut of a sale.\r\n    /// @param _price - Sale price of NFT.\r\n    function _computeCut(uint256 _price) internal view returns (uint256) {\r\n        // NOTE: We don't use SafeMath (or similar) in this function because\r\n        //  all of our entry functions carefully cap the maximum values for\r\n        //  currency (at 128-bits), and ownerCut <= 10000 (see the require()\r\n        //  statement in the ClockAuction constructor). The result of this\r\n        //  function is always guaranteed to be <= _price.\r\n        return _price * ownerCut / 10000;\r\n    }\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * @title Pausable\r\n * @dev Base contract which allows children to implement an emergency stop mechanism.\r\n */\r\ncontract Pausable is Ownable {\r\n  event Pause();\r\n  event Unpause();\r\n\r\n  bool public paused = false;\r\n\r\n\r\n  /**\r\n   * @dev modifier to allow actions only when the contract IS paused\r\n   */\r\n  modifier whenNotPaused() {\r\n    require(!paused);\r\n    _;\r\n  }\r\n\r\n  /**\r\n   * @dev modifier to allow actions only when the contract IS NOT paused\r\n   */\r\n  modifier whenPaused {\r\n    require(paused);\r\n    _;\r\n  }\r\n\r\n  /**\r\n   * @dev called by the owner to pause, triggers stopped state\r\n   */\r\n  function pause() onlyOwner whenNotPaused returns (bool) {\r\n    paused = true;\r\n    Pause();\r\n    return true;\r\n  }\r\n\r\n  /**\r\n   * @dev called by the owner to unpause, returns to normal state\r\n   */\r\n  function unpause() onlyOwner whenPaused returns (bool) {\r\n    paused = false;\r\n    Unpause();\r\n    return true;\r\n  }\r\n}\r\n\r\n\r\n/// @title Clock auction for non-fungible tokens.\r\n/// @notice We omit a fallback function to prevent accidental sends to this contract.\r\ncontract ClockAuction is Pausable, ClockAuctionBase {\r\n\r\n    /// @dev The ERC-165 interface signature for ERC-721.\r\n    ///  Ref: https://github.com/ethereum/EIPs/issues/165\r\n    ///  Ref: https://github.com/ethereum/EIPs/issues/721\r\n    bytes4 constant InterfaceSignature_ERC721 = bytes4(0x9a20483d);\r\n\r\n    /// @dev Constructor creates a reference to the NFT ownership contract\r\n    ///  and verifies the owner cut is in the valid range.\r\n    /// @param _nftAddress - address of a deployed contract implementing\r\n    ///  the Nonfungible Interface.\r\n    /// @param _cut - percent cut the owner takes on each auction, must be\r\n    ///  between 0-10,000.\r\n    function ClockAuction(address _nftAddress, uint256 _cut) public {\r\n        require(_cut <= 10000);\r\n        ownerCut = _cut;\r\n\r\n        ERC721 candidateContract = ERC721(_nftAddress);\r\n        require(candidateContract.supportsInterface(InterfaceSignature_ERC721));\r\n        nonFungibleContract = candidateContract;\r\n    }\r\n\r\n    /// @dev Remove all Ether from the contract, which is the owner's cuts\r\n    ///  as well as any Ether sent directly to the contract address.\r\n    ///  Always transfers to the NFT contract, but can be called either by\r\n    ///  the owner or the NFT contract.\r\n    function withdrawBalance() external {\r\n        address nftAddress = address(nonFungibleContract);\r\n\r\n        require(\r\n            msg.sender == owner ||\r\n            msg.sender == nftAddress\r\n        );\r\n        // We are using this boolean method to make sure that even if one fails it will still work\r\n        bool res = nftAddress.send(this.balance);\r\n    }\r\n\r\n    /// @dev Creates and begins a new auction.\r\n    /// @param _tokenId - ID of token to auction, sender must be owner.\r\n    /// @param _startingPrice - Price of item (in wei) at beginning of auction.\r\n    /// @param _endingPrice - Price of item (in wei) at end of auction.\r\n    /// @param _duration - Length of time to move between starting\r\n    ///  price and ending price (in seconds).\r\n    /// @param _seller - Seller, if not the message sender\r\n    function createAuction(\r\n        uint256 _tokenId,\r\n        uint256 _startingPrice,\r\n        uint256 _endingPrice,\r\n        uint256 _duration,\r\n        address _seller\r\n    )\r\n        external\r\n        whenNotPaused\r\n    {\r\n        // Sanity check that no inputs overflow how many bits we've allocated\r\n        // to store them in the auction struct.\r\n        require(_startingPrice == uint256(uint128(_startingPrice)));\r\n        require(_endingPrice == uint256(uint128(_endingPrice)));\r\n        require(_duration == uint256(uint64(_duration)));\r\n\r\n        require(_owns(msg.sender, _tokenId));\r\n        _escrow(msg.sender, _tokenId);\r\n        Auction memory auction = Auction(\r\n            _seller,\r\n            uint128(_startingPrice),\r\n            uint128(_endingPrice),\r\n            uint64(_duration),\r\n            uint64(now)\r\n        );\r\n        _addAuction(_tokenId, auction);\r\n    }\r\n\r\n    /// @dev Bids on an open auction, completing the auction and transferring\r\n    ///  ownership of the NFT if enough Ether is supplied.\r\n    /// @param _tokenId - ID of token to bid on.\r\n    function bid(uint256 _tokenId)\r\n        external\r\n        payable\r\n        whenNotPaused\r\n    {\r\n        // _bid will throw if the bid or funds transfer fails\r\n        _bid(_tokenId, msg.value);\r\n        _transfer(msg.sender, _tokenId);\r\n    }\r\n\r\n    /// @dev Cancels an auction that hasn't been won yet.\r\n    ///  Returns the NFT to original owner.\r\n    /// @notice This is a state-modifying function that can\r\n    ///  be called while the contract is paused.\r\n    /// @param _tokenId - ID of token on auction\r\n    function cancelAuction(uint256 _tokenId)\r\n        external\r\n    {\r\n        Auction storage auction = tokenIdToAuction[_tokenId];\r\n        require(_isOnAuction(auction));\r\n        address seller = auction.seller;\r\n        require(msg.sender == seller);\r\n        _cancelAuction(_tokenId, seller);\r\n    }\r\n\r\n    /// @dev Cancels an auction when the contract is paused.\r\n    ///  Only the owner may do this, and NFTs are returned to\r\n    ///  the seller. This should only be used in emergencies.\r\n    /// @param _tokenId - ID of the NFT on auction to cancel.\r\n    function cancelAuctionWhenPaused(uint256 _tokenId)\r\n        whenPaused\r\n        onlyOwner\r\n        external\r\n    {\r\n        Auction storage auction = tokenIdToAuction[_tokenId];\r\n        require(_isOnAuction(auction));\r\n        _cancelAuction(_tokenId, auction.seller);\r\n    }\r\n\r\n    /// @dev Returns auction info for an NFT on auction.\r\n    /// @param _tokenId - ID of NFT on auction.\r\n    function getAuction(uint256 _tokenId)\r\n        external\r\n        view\r\n        returns\r\n    (\r\n        address seller,\r\n        uint256 startingPrice,\r\n        uint256 endingPrice,\r\n        uint256 duration,\r\n        uint256 startedAt\r\n    ) {\r\n        Auction storage auction = tokenIdToAuction[_tokenId];\r\n        require(_isOnAuction(auction));\r\n        return (\r\n            auction.seller,\r\n            auction.startingPrice,\r\n            auction.endingPrice,\r\n            auction.duration,\r\n            auction.startedAt\r\n        );\r\n    }\r\n\r\n    /// @dev Returns the current price of an auction.\r\n    /// @param _tokenId - ID of the token price we are checking.\r\n    function getCurrentPrice(uint256 _tokenId)\r\n        external\r\n        view\r\n        returns (uint256)\r\n    {\r\n        Auction storage auction = tokenIdToAuction[_tokenId];\r\n        require(_isOnAuction(auction));\r\n        return _currentPrice(auction);\r\n    }\r\n\r\n}\r\n\r\n\r\n/// @title Reverse auction modified for siring\r\n/// @notice We omit a fallback function to prevent accidental sends to this contract.\r\ncontract SiringClockAuction is ClockAuction {\r\n\r\n    // @dev Sanity check that allows us to ensure that we are pointing to the\r\n    //  right auction in our setSiringAuctionAddress() call.\r\n    bool public isSiringClockAuction = true;\r\n\r\n    // Delegate constructor\r\n    function SiringClockAuction(address _nftAddr, uint256 _cut) public\r\n        ClockAuction(_nftAddr, _cut) {}\r\n\r\n    /// @dev Creates and begins a new auction. Since this function is wrapped,\r\n    /// require sender to be KittyCore contract.\r\n    /// @param _tokenId - ID of token to auction, sender must be owner.\r\n    /// @param _startingPrice - Price of item (in wei) at beginning of auction.\r\n    /// @param _endingPrice - Price of item (in wei) at end of auction.\r\n    /// @param _duration - Length of auction (in seconds).\r\n    /// @param _seller - Seller, if not the message sender\r\n    function createAuction(\r\n        uint256 _tokenId,\r\n        uint256 _startingPrice,\r\n        uint256 _endingPrice,\r\n        uint256 _duration,\r\n        address _seller\r\n    )\r\n        external\r\n    {\r\n        // Sanity check that no inputs overflow how many bits we've allocated\r\n        // to store them in the auction struct.\r\n        require(_startingPrice == uint256(uint128(_startingPrice)));\r\n        require(_endingPrice == uint256(uint128(_endingPrice)));\r\n        require(_duration == uint256(uint64(_duration)));\r\n\r\n        require(msg.sender == address(nonFungibleContract));\r\n        _escrow(_seller, _tokenId);\r\n        Auction memory auction = Auction(\r\n            _seller,\r\n            uint128(_startingPrice),\r\n            uint128(_endingPrice),\r\n            uint64(_duration),\r\n            uint64(now)\r\n        );\r\n        _addAuction(_tokenId, auction);\r\n    }\r\n\r\n    /// @dev Places a bid for siring. Requires the sender\r\n    /// is the KittyCore contract because all bid methods\r\n    /// should be wrapped. Also returns the kitty to the\r\n    /// seller rather than the winner.\r\n    function bid(uint256 _tokenId)\r\n        external\r\n        payable\r\n    {\r\n        require(msg.sender == address(nonFungibleContract));\r\n        address seller = tokenIdToAuction[_tokenId].seller;\r\n        // _bid checks that token ID is valid and will throw if bid fails\r\n        _bid(_tokenId, msg.value);\r\n        // We transfer the kitty back to the seller, the winner will get\r\n        // the offspring\r\n        _transfer(seller, _tokenId);\r\n    }\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n/// @title Clock auction modified for sale of kitties\r\n/// @notice We omit a fallback function to prevent accidental sends to this contract.\r\ncontract SaleClockAuction is ClockAuction {\r\n\r\n    // @dev Sanity check that allows us to ensure that we are pointing to the\r\n    //  right auction in our setSaleAuctionAddress() call.\r\n    bool public isSaleClockAuction = true;\r\n\r\n    // Tracks last 5 sale price of gen0 kitty sales\r\n    uint256 public gen0SaleCount;\r\n    uint256[5] public lastGen0SalePrices;\r\n\r\n    // Delegate constructor\r\n    function SaleClockAuction(address _nftAddr, uint256 _cut) public\r\n        ClockAuction(_nftAddr, _cut) {}\r\n\r\n    /// @dev Creates and begins a new auction.\r\n    /// @param _tokenId - ID of token to auction, sender must be owner.\r\n    /// @param _startingPrice - Price of item (in wei) at beginning of auction.\r\n    /// @param _endingPrice - Price of item (in wei) at end of auction.\r\n    /// @param _duration - Length of auction (in seconds).\r\n    /// @param _seller - Seller, if not the message sender\r\n    function createAuction(\r\n        uint256 _tokenId,\r\n        uint256 _startingPrice,\r\n        uint256 _endingPrice,\r\n        uint256 _duration,\r\n        address _seller\r\n    )\r\n        external\r\n    {\r\n        // Sanity check that no inputs overflow how many bits we've allocated\r\n        // to store them in the auction struct.\r\n        require(_startingPrice == uint256(uint128(_startingPrice)));\r\n        require(_endingPrice == uint256(uint128(_endingPrice)));\r\n        require(_duration == uint256(uint64(_duration)));\r\n\r\n        require(msg.sender == address(nonFungibleContract));\r\n        _escrow(_seller, _tokenId);\r\n        Auction memory auction = Auction(\r\n            _seller,\r\n            uint128(_startingPrice),\r\n            uint128(_endingPrice),\r\n            uint64(_duration),\r\n            uint64(now)\r\n        );\r\n        _addAuction(_tokenId, auction);\r\n    }\r\n\r\n    /// @dev Updates lastSalePrice if seller is the nft contract\r\n    /// Otherwise, works the same as default bid method.\r\n    function bid(uint256 _tokenId)\r\n        external\r\n        payable\r\n    {\r\n        // _bid verifies token ID size\r\n        address seller = tokenIdToAuction[_tokenId].seller;\r\n        uint256 price = _bid(_tokenId, msg.value);\r\n        _transfer(msg.sender, _tokenId);\r\n\r\n        // If not a gen0 auction, exit\r\n        if (seller == address(nonFungibleContract)) {\r\n            // Track gen0 sale prices\r\n            lastGen0SalePrices[gen0SaleCount % 5] = price;\r\n            gen0SaleCount++;\r\n        }\r\n    }\r\n\r\n    function averageGen0SalePrice() external view returns (uint256) {\r\n        uint256 sum = 0;\r\n        for (uint256 i = 0; i < 5; i++) {\r\n            sum += lastGen0SalePrices[i];\r\n        }\r\n        return sum / 5;\r\n    }\r\n\r\n}\r\n\r\n\r\n/// @title Handles creating auctions for sale and siring of kitties.\r\n///  This wrapper of ReverseAuction exists only so that users can create\r\n///  auctions with only one transaction.\r\ncontract KittyAuction is KittyBreeding {\r\n\r\n    // @notice The auction contract variables are defined in KittyBase to allow\r\n    //  us to refer to them in KittyOwnership to prevent accidental transfers.\r\n    // `saleAuction` refers to the auction for gen0 and p2p sale of kitties.\r\n    // `siringAuction` refers to the auction for siring rights of kitties.\r\n\r\n    /// @dev Sets the reference to the sale auction.\r\n    /// @param _address - Address of sale contract.\r\n    function setSaleAuctionAddress(address _address) external onlyCEO {\r\n        SaleClockAuction candidateContract = SaleClockAuction(_address);\r\n\r\n        // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117\r\n        require(candidateContract.isSaleClockAuction());\r\n\r\n        // Set the new contract address\r\n        saleAuction = candidateContract;\r\n    }\r\n\r\n    /// @dev Sets the reference to the siring auction.\r\n    /// @param _address - Address of siring contract.\r\n    function setSiringAuctionAddress(address _address) external onlyCEO {\r\n        SiringClockAuction candidateContract = SiringClockAuction(_address);\r\n\r\n        // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117\r\n        require(candidateContract.isSiringClockAuction());\r\n\r\n        // Set the new contract address\r\n        siringAuction = candidateContract;\r\n    }\r\n\r\n    /// @dev Put a kitty up for auction.\r\n    ///  Does some ownership trickery to create auctions in one tx.\r\n    function createSaleAuction(\r\n        uint256 _kittyId,\r\n        uint256 _startingPrice,\r\n        uint256 _endingPrice,\r\n        uint256 _duration\r\n    )\r\n        external\r\n        whenNotPaused\r\n    {\r\n        // Auction contract checks input sizes\r\n        // If kitty is already on any auction, this will throw\r\n        // because it will be owned by the auction contract.\r\n        require(_owns(msg.sender, _kittyId));\r\n        // Ensure the kitty is not pregnant to prevent the auction\r\n        // contract accidentally receiving ownership of the child.\r\n        // NOTE: the kitty IS allowed to be in a cooldown.\r\n        require(!isPregnant(_kittyId));\r\n        _approve(_kittyId, saleAuction);\r\n        // Sale auction throws if inputs are invalid and clears\r\n        // transfer and sire approval after escrowing the kitty.\r\n        saleAuction.createAuction(\r\n            _kittyId,\r\n            _startingPrice,\r\n            _endingPrice,\r\n            _duration,\r\n            msg.sender\r\n        );\r\n    }\r\n\r\n    /// @dev Put a kitty up for auction to be sire.\r\n    ///  Performs checks to ensure the kitty can be sired, then\r\n    ///  delegates to reverse auction.\r\n    function createSiringAuction(\r\n        uint256 _kittyId,\r\n        uint256 _startingPrice,\r\n        uint256 _endingPrice,\r\n        uint256 _duration\r\n    )\r\n        external\r\n        whenNotPaused\r\n    {\r\n        // Auction contract checks input sizes\r\n        // If kitty is already on any auction, this will throw\r\n        // because it will be owned by the auction contract.\r\n        require(_owns(msg.sender, _kittyId));\r\n        require(isReadyToBreed(_kittyId));\r\n        _approve(_kittyId, siringAuction);\r\n        // Siring auction throws if inputs are invalid and clears\r\n        // transfer and sire approval after escrowing the kitty.\r\n        siringAuction.createAuction(\r\n            _kittyId,\r\n            _startingPrice,\r\n            _endingPrice,\r\n            _duration,\r\n            msg.sender\r\n        );\r\n    }\r\n\r\n    /// @dev Completes a siring auction by bidding.\r\n    ///  Immediately breeds the winning matron with the sire on auction.\r\n    /// @param _sireId - ID of the sire on auction.\r\n    /// @param _matronId - ID of the matron owned by the bidder.\r\n    function bidOnSiringAuction(\r\n        uint256 _sireId,\r\n        uint256 _matronId\r\n    )\r\n        external\r\n        payable\r\n        whenNotPaused\r\n    {\r\n        // Auction contract checks input sizes\r\n        require(_owns(msg.sender, _matronId));\r\n        require(isReadyToBreed(_matronId));\r\n        require(_canBreedWithViaAuction(_matronId, _sireId));\r\n\r\n        // Define the current price of the auction.\r\n        uint256 currentPrice = siringAuction.getCurrentPrice(_sireId);\r\n        require(msg.value >= currentPrice + autoBirthFee);\r\n\r\n        // Siring auction will throw if the bid fails.\r\n        siringAuction.bid.value(msg.value - autoBirthFee)(_sireId);\r\n        _breedWith(uint32(_matronId), uint32(_sireId));\r\n    }\r\n\r\n    /// @dev Transfers the balance of the sale auction contract\r\n    /// to the KittyCore contract. We use two-step withdrawal to\r\n    /// prevent two transfer calls in the auction bid function.\r\n    function withdrawAuctionBalances() external onlyCLevel {\r\n        saleAuction.withdrawBalance();\r\n        siringAuction.withdrawBalance();\r\n    }\r\n}\r\n\r\n\r\n/// @title all functions related to creating kittens\r\ncontract KittyMinting is KittyAuction {\r\n\r\n    // Limits the number of cats the contract owner can ever create.\r\n    uint256 public constant PROMO_CREATION_LIMIT = 5000;\r\n    uint256 public constant GEN0_CREATION_LIMIT = 45000;\r\n\r\n    // Constants for gen0 auctions.\r\n    uint256 public constant GEN0_STARTING_PRICE = 10 finney;\r\n    uint256 public constant GEN0_AUCTION_DURATION = 1 days;\r\n\r\n    // Counts the number of cats the contract owner has created.\r\n    uint256 public promoCreatedCount;\r\n    uint256 public gen0CreatedCount;\r\n\r\n    /// @dev we can create promo kittens, up to a limit. Only callable by COO\r\n    /// @param _genes the encoded genes of the kitten to be created, any value is accepted\r\n    /// @param _owner the future owner of the created kittens. Default to contract COO\r\n    function createPromoKitty(uint256 _genes, address _owner) external onlyCOO {\r\n        address kittyOwner = _owner;\r\n        if (kittyOwner == address(0)) {\r\n             kittyOwner = cooAddress;\r\n        }\r\n        require(promoCreatedCount < PROMO_CREATION_LIMIT);\r\n\r\n        promoCreatedCount++;\r\n        _createKitty(0, 0, 0, _genes, kittyOwner);\r\n    }\r\n\r\n    /// @dev Creates a new gen0 kitty with the given genes and\r\n    ///  creates an auction for it.\r\n    function createGen0Auction(uint256 _genes) external onlyCOO {\r\n        require(gen0CreatedCount < GEN0_CREATION_LIMIT);\r\n\r\n        uint256 kittyId = _createKitty(0, 0, 0, _genes, address(this));\r\n        _approve(kittyId, saleAuction);\r\n\r\n        saleAuction.createAuction(\r\n            kittyId,\r\n            _computeNextGen0Price(),\r\n            0,\r\n            GEN0_AUCTION_DURATION,\r\n            address(this)\r\n        );\r\n\r\n        gen0CreatedCount++;\r\n    }\r\n\r\n    /// @dev Computes the next gen0 auction starting price, given\r\n    ///  the average of the past 5 prices + 50%.\r\n    function _computeNextGen0Price() internal view returns (uint256) {\r\n        uint256 avePrice = saleAuction.averageGen0SalePrice();\r\n\r\n        // Sanity check to ensure we don't overflow arithmetic\r\n        require(avePrice == uint256(uint128(avePrice)));\r\n\r\n        uint256 nextPrice = avePrice + (avePrice / 2);\r\n\r\n        // We never auction for less than starting price\r\n        if (nextPrice < GEN0_STARTING_PRICE) {\r\n            nextPrice = GEN0_STARTING_PRICE;\r\n        }\r\n\r\n        return nextPrice;\r\n    }\r\n}\r\n\r\n\r\n/// @title CryptoKitties: Collectible, breedable, and oh-so-adorable cats on the Ethereum blockchain.\r\n/// @author Axiom Zen (https://www.axiomzen.co)\r\n/// @dev The main CryptoKitties contract, keeps track of kittens so they don't wander around and get lost.\r\ncontract KittyCore is KittyMinting {\r\n\r\n    // This is the main CryptoKitties contract. In order to keep our code seperated into logical sections,\r\n    // we've broken it up in two ways. First, we have several seperately-instantiated sibling contracts\r\n    // that handle auctions and our super-top-secret genetic combination algorithm. The auctions are\r\n    // seperate since their logic is somewhat complex and there's always a risk of subtle bugs. By keeping\r\n    // them in their own contracts, we can upgrade them without disrupting the main contract that tracks\r\n    // kitty ownership. The genetic combination algorithm is kept seperate so we can open-source all of\r\n    // the rest of our code without making it _too_ easy for folks to figure out how the genetics work.\r\n    // Don't worry, I'm sure someone will reverse engineer it soon enough!\r\n    //\r\n    // Secondly, we break the core contract into multiple files using inheritence, one for each major\r\n    // facet of functionality of CK. This allows us to keep related code bundled together while still\r\n    // avoiding a single giant file with everything in it. The breakdown is as follows:\r\n    //\r\n    //      - KittyBase: This is where we define the most fundamental code shared throughout the core\r\n    //             functionality. This includes our main data storage, constants and data types, plus\r\n    //             internal functions for managing these items.\r\n    //\r\n    //      - KittyAccessControl: This contract manages the various addresses and constraints for operations\r\n    //             that can be executed only by specific roles. Namely CEO, CFO and COO.\r\n    //\r\n    //      - KittyOwnership: This provides the methods required for basic non-fungible token\r\n    //             transactions, following the draft ERC-721 spec (https://github.com/ethereum/EIPs/issues/721).\r\n    //\r\n    //      - KittyBreeding: This file contains the methods necessary to breed cats together, including\r\n    //             keeping track of siring offers, and relies on an external genetic combination contract.\r\n    //\r\n    //      - KittyAuctions: Here we have the public methods for auctioning or bidding on cats or siring\r\n    //             services. The actual auction functionality is handled in two sibling contracts (one\r\n    //             for sales and one for siring), while auction creation and bidding is mostly mediated\r\n    //             through this facet of the core contract.\r\n    //\r\n    //      - KittyMinting: This final facet contains the functionality we use for creating new gen0 cats.\r\n    //             We can make up to 5000 \"promo\" cats that can be given away (especially important when\r\n    //             the community is new), and all others can only be created and then immediately put up\r\n    //             for auction via an algorithmically determined starting price. Regardless of how they\r\n    //             are created, there is a hard limit of 50k gen0 cats. After that, it's all up to the\r\n    //             community to breed, breed, breed!\r\n\r\n    // Set in case the core contract is broken and an upgrade is required\r\n    address public newContractAddress;\r\n\r\n    /// @notice Creates the main CryptoKitties smart contract instance.\r\n    function KittyCore() public {\r\n        // Starts paused.\r\n        paused = true;\r\n\r\n        // the creator of the contract is the initial CEO\r\n        ceoAddress = msg.sender;\r\n\r\n        // the creator of the contract is also the initial COO\r\n        cooAddress = msg.sender;\r\n\r\n        // start with the mythical kitten 0 - so we don't have generation-0 parent issues\r\n        _createKitty(0, 0, 0, uint256(-1), address(0));\r\n    }\r\n\r\n    /// @dev Used to mark the smart contract as upgraded, in case there is a serious\r\n    ///  breaking bug. This method does nothing but keep track of the new contract and\r\n    ///  emit a message indicating that the new address is set. It's up to clients of this\r\n    ///  contract to update to the new contract address in that case. (This contract will\r\n    ///  be paused indefinitely if such an upgrade takes place.)\r\n    /// @param _v2Address new address\r\n    function setNewAddress(address _v2Address) external onlyCEO whenPaused {\r\n        // See README.md for updgrade plan\r\n        newContractAddress = _v2Address;\r\n        ContractUpgrade(_v2Address);\r\n    }\r\n\r\n    /// @notice No tipping!\r\n    /// @dev Reject all Ether from being sent here, unless it's from one of the\r\n    ///  two auction contracts. (Hopefully, we can prevent user accidents.)\r\n    function() external payable {\r\n        require(\r\n            msg.sender == address(saleAuction) ||\r\n            msg.sender == address(siringAuction)\r\n        );\r\n    }\r\n\r\n    /// @notice Returns all the relevant information about a specific kitty.\r\n    /// @param _id The ID of the kitty of interest.\r\n    function getKitty(uint256 _id)\r\n        external\r\n        view\r\n        returns (\r\n        bool isGestating,\r\n        bool isReady,\r\n        uint256 cooldownIndex,\r\n        uint256 nextActionAt,\r\n        uint256 siringWithId,\r\n        uint256 birthTime,\r\n        uint256 matronId,\r\n        uint256 sireId,\r\n        uint256 generation,\r\n        uint256 genes\r\n    ) {\r\n        Kitty storage kit = kitties[_id];\r\n\r\n        // if this variable is 0 then it's not gestating\r\n        isGestating = (kit.siringWithId != 0);\r\n        isReady = (kit.cooldownEndBlock <= block.number);\r\n        cooldownIndex = uint256(kit.cooldownIndex);\r\n        nextActionAt = uint256(kit.cooldownEndBlock);\r\n        siringWithId = uint256(kit.siringWithId);\r\n        birthTime = uint256(kit.birthTime);\r\n        matronId = uint256(kit.matronId);\r\n        sireId = uint256(kit.sireId);\r\n        generation = uint256(kit.generation);\r\n        genes = kit.genes;\r\n    }\r\n\r\n    /// @dev Override unpause so it requires all external contract addresses\r\n    ///  to be set before contract can be unpaused. Also, we can't have\r\n    ///  newContractAddress set either, because then the contract was upgraded.\r\n    /// @notice This is public rather than external so we can call super.unpause\r\n    ///  without using an expensive CALL.\r\n    function unpause() public onlyCEO whenPaused {\r\n        require(saleAuction != address(0));\r\n        require(siringAuction != address(0));\r\n        require(geneScience != address(0));\r\n        require(newContractAddress == address(0));\r\n\r\n        // Actually unpause the contract.\r\n        super.unpause();\r\n    }\r\n\r\n    // @dev Allows the CFO to capture the balance available to the contract.\r\n    function withdrawBalance() external onlyCFO {\r\n        uint256 balance = this.balance;\r\n        // Subtract all the currently pregnant kittens we have, plus 1 of margin.\r\n        uint256 subtractFees = (pregnantKitties + 1) * autoBirthFee;\r\n\r\n        if (balance > subtractFees) {\r\n            cfoAddress.send(balance - subtractFees);\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "README.md",
    "content": "# Solidity Samples\r\n\r\nSolidity programming language samples, smart contracts for Ethereum.\r\n\r\n## Related Repositories\r\n\r\n- [Aprendiendo Solidity (Spanish)](https://github.com/ajlopez/AprendiendoSolidity)\r\n- [Solidity Compiler](https://github.com/ajlopez/SolidityCompiler)\r\n- [Solidity Decompiler](https://github.com/ajlopez/yasold)\r\n\r\n## References\r\n\r\n- [The Ethereum Project](https://ethereum.org/)\r\n- [Solidity Documentation](http://solidity.readthedocs.io/en/develop/)\r\n- [Truffle Framework](http://truffleframework.com/)\r\n- [OpenZeppelin](https://openzeppelin.org/)\r\n\r\n## Ethereum\r\n\r\n- [The Complete Tutorial On Getting Started With Smart Contracts On Ethereum](https://medium.com/@ricochenx/the-complete-tutorial-on-getting-started-with-smart-contracts-on-ethereum-3ee6c54e84db)\r\n- [What is Ethereum?](https://medium.com/on-the-block/what-is-ethereum-fb6b7c33e21d)\r\n- [Learn Ethereum](https://ethereum.network/learn)\r\n- [The Hitchhikers Guide to Smart Contracts in Ethereum](https://blog.zeppelin.solutions/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05)\r\n- [Programming Ethereum smart contract transactions in JavaScript](https://tokenmarket.net/blog/creating-ethereum-smart-contract-transactions-in-client-side-javascript/)\r\n- [Ethereum Virtual Machine Awesome List](https://github.com/pirapira/awesome-ethereum-virtual-machine)\r\n- [A curated list of awesome Ethereum Resources](http://awesome-ethereum.com/)\r\n- [A Gentle Introduction to Ethereum Programming, Part 1](https://blog.zeppelin.solutions/a-gentle-introduction-to-ethereum-programming-part-1-783cc7796094)\r\n- [A Gentle Introduction to Ethereum Programming, Part 2](https://blog.zeppelin.solutions/a-gentle-introduction-to-ethereum-programming-part-2-7bbf15e1a953)\r\n- [A Gentle Introduction to Ethereum Programming, Part 3](https://blog.zeppelin.solutions/a-gentle-introduction-to-ethereum-programming-part-3-abdd9644d0c2)\r\n- [Ethereum Dev Cheatsheet](https://github.com/beether/ethereum-dev-cheatsheet)\r\n- [CryptoZombies is a free, interactive code school that teaches you to build games on Ethereum](https://cryptozombies.io/)\r\n- [Beether](http://www.beether.net/)\r\n- [Getting started with Ethereum as a developer](https://medium.com/bcgdv-engineering/getting-started-with-ethereum-as-a-developer-af20d78c49f)\r\n- [Getting Started as an Ethereum Web Developer](https://hackernoon.com/getting-started-as-an-ethereum-web-developer-9a2a4ab47baf)\r\n- [A Guide to Gas](https://media.consensys.net/a-guide-to-gas-12b40d03605d)\r\n- [Understanding the ethereum trie](https://easythereentropy.wordpress.com/2014/06/04/understanding-the-ethereum-trie/)\r\n- [Data structure in Ethereum | Episode 1: Recursive Length Prefix (RLP) Encoding/Decoding](https://medium.com/coinmonks/data-structure-in-ethereum-episode-1-recursive-length-prefix-rlp-encoding-decoding-d1016832f919)\r\n- [Data structure in Ethereum | Episode 1+: Compact (Hex-prefix) encoding](https://medium.com/coinmonks/data-structure-in-ethereum-episode-1-compact-hex-prefix-encoding-12558ae02791)\r\n- [Data structure in Ethereum | Episode 2: Radix trie and Merkle trie](https://medium.com/coinmonks/data-structure-in-ethereum-episode-2-radix-trie-and-merkle-trie-d941d0bfd69a)\r\n- [Data structure in Ethereum | Episode 3: Patricia trie](https://medium.com/coinmonks/data-structure-in-ethereum-episode-3-patricia-trie-b7b0ccddd32f)\r\n- [Data structure in Ethereum | Episode 4: Diving into examples](https://medium.com/coinmonks/data-structure-in-ethereum-episode-4-diving-by-examples-f6a4cbd8c329)\r\n- [Skewed Merkle Trees](https://medium.com/codechain/skewed-merkle-tree-259b984acc0c)\r\n- [Ethereum 69: how to set up a fully synced blockchain node in 10 mins](https://medium.freecodecamp.org/ethereum-69-how-to-set-up-a-fully-synced-blockchain-node-in-10-mins-f6318d7aad40)\r\n- [State Channels for Dummies: Part 5](https://medium.com/blockchannel/state-channels-for-dummies-part-5-6238f83f8da3)\r\n- [Ethereum Explained: Merkle Trees, World State, Transactions, and More](https://pegasys.tech/ethereum-explained-merkle-trees-world-state-transactions-and-more/)\r\n- [The 11 Best Sources for Ethereum News and Learning](https://media.consensys.net/the-11-best-sources-for-ethereum-news-and-learning-783ef4803ab0)\r\n- [Improving Smart Contract development with Tenderly and human readable stack traces](https://medium.com/tenderly/improving-smart-contract-development-with-tenderly-and-human-readable-stack-traces-16abfad5dd15)\r\n- [Ethereum Under the Hood: Part-1 (ver 0.1)](https://medium.com/coinmonks/ethereum-under-the-hood-part-i-ver-0-1-4f2fb24b3d68)\r\n- [Ethereum Under the Hood- Part 2 (RLP Encoding)](https://medium.com/coinmonks/ethereum-under-the-hood-part-ii-i-933411deebe1)\r\n- [Ethereum Under The Hood Part 3 (RLP Decoding)](https://medium.com/coinmonks/ethereum-under-the-hood-part-3-rlp-decoding-c0c07f5c0714)\r\n- [A Guide to Gas](https://media.consensys.net/a-guide-to-gas-12b40d03605d)\r\n- [A Definitive List of Ethereum Developer Tools](https://media.consensys.net/an-definitive-list-of-ethereum-developer-tools-2159ce865974)\r\n- [Ethereums EIP 2/4: 15 Second Block Target](https://blog.cotten.io/ethereums-eip-2-4-15-second-block-target-98d4c11017e1)\r\n- [The business of sending transactions on Ethereum](https://medium.com/coinmonks/the-business-of-sending-transactions-on-ethereum-e79fd9a2b88)\r\n- [EVM Evolution Roadmap](https://medium.com/spadebuilders/evm-evolution-roadmap-f8b8e3a73882)\r\n- [Ethereum Yellow Paper Walkthrough: Merkle Trees](https://dzone.com/articles/ethereum-yellow-paper-walkthrough-27)\r\n- [Role Based Access Control for the Ethereum Blockchain](https://hackernoon.com/role-based-access-control-for-the-ethereum-blockchain-bcc9dfbcfe5c)\r\n- [How does Ethereum work, anyway?](https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369)\r\n- [A guide to Ethereums ERC standards](https://news.yahoo.com/guide-ethereum-erc-standards-150024381.html)\r\n- [Diving into Ethereums world state](https://medium.com/cybermiles/diving-into-ethereums-world-state-c893102030ed)\r\n- [The Ethereum Virtual Machine (EVM) Runtime Environment](https://medium.com/0xcode/the-ethereum-virtual-machine-evm-runtime-environment-d7969544d3dd)\r\n- [How does Ethereum work, anyway?](https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369)\r\n- [Mastering The Fundamentals of Ethereum (For New Blockchain Devs) Part III  Wallets, Keys, And Accounts](https://medium.com/@markmuskardin/mastering-the-fundamentals-of-ethereum-for-new-blockchain-devs-part-iii-wallets-keys-and-4cd3175b535b)\r\n- [Ethereum Development Crash Course Part One](https://medium.com/bitfwd/ethereum-development-crash-course-part-one-327dee16878b)\r\n- [Data Convergence  Blockchain  Blockchain Developer Tools](https://medium.com/data-convergence/data-convergence-blockchain-blockchain-developer-tools-8c9e98852251)\r\n\r\n## Solidity\r\n\r\n- [Documentation](http://solidity.readthedocs.io/en/develop/index.html)\r\n- [Learning Solidity (videos)](https://www.youtube.com/watch?v=v_hU0jPtLto&list=PL16WqdAj66SCOdL6XIFbke-XQg2GW_Avg&index=1)\r\n- [Solidity Contracts](http://solidity.readthedocs.io/en/develop/contracts.html)\r\n- [Application Binary Interface Specification](http://solidity.readthedocs.io/en/develop/abi-spec.html#abi)\r\n- [Solidity Baby Steps](https://github.com/fivedogit/solidity-baby-steps)\r\n- [How to initialize an empty array and push items into it?](https://ethereum.stackexchange.com/questions/11533/how-to-initialize-an-empty-array-and-push-items-into-it)\r\n- [What is the memory keyword? What does it do?](https://solidity.readthedocs.io/en/latest/frequently-asked-questions.html#what-is-the-memory-keyword-what-does-it-do)\r\n- [A curated list of awesome Solidity resources, libraries, tools and more](https://github.com/bkrem/awesome-solidity)\r\n- [Solidity REPL](https://github.com/raineorshine/solidity-repl)\r\n- [Remix](https://remix.ethereum.org/#version=soljson-v0.4.18+commit.9cf6e910.js)\r\n- [Interaction between Contracts](https://dappsforbeginners.wordpress.com/tutorials/interactions-between-contracts/)\r\n- [How can I debug a smart contract?](https://ethereum.stackexchange.com/questions/184/how-can-i-debug-a-smart-contract)\r\n- [What is the difference between an internal/external and public/private function in solidity?](https://ethereum.stackexchange.com/questions/32353/what-is-the-difference-between-an-internal-external-and-public-private-function)\r\n- [external vs public best practices](https://ethereum.stackexchange.com/questions/19380/external-vs-public-best-practices)\r\n- [internal keyword in a function definition in Solidity](https://ethereum.stackexchange.com/questions/631/internal-keyword-in-a-function-definition-in-solidity)\r\n- [Doxity Documentation Generator for Solidity](https://github.com/DigixGlobal/doxity)\r\n- [Solidity doc generator](https://github.com/vitiko/solidity-doc)\r\n- [Markdown documentation generator for Solidity](https://github.com/dpilch/solmd)\r\n- [Solidity Common Patterns](http://solidity.readthedocs.io/en/develop/common-patterns.html)\r\n- [Thinking in Solidity](https://blog.cotten.io/thinking-in-solidity-6670c06390a9)\r\n- [Solidity tips and tricks to save gas and reduce bytecode size](https://blog.polymath.network/solidity-tips-and-tricks-to-save-gas-and-reduce-bytecode-size-c44580b218e6)\r\n- [Solidity CRUD- Epilogue](https://medium.com/robhitchens/solidity-crud-epilogue-e563e794fde)\r\n- [Getting Loopy with Solidity](https://blog.b9lab.com/getting-loopy-with-solidity-1d51794622ad)\r\n- [Solidity Collections](https://github.com/ethereum/wiki/wiki/Solidity-Collections)\r\n- [Testing and Code Coverage of Solidity Smart Contracts](https://medium.com/edgefund/testing-and-code-coverage-of-solidity-smart-contracts-660cb6291701\r\n- [Which custom data structures do you use in Solidity?](https://forum.zeppelin.solutions/t/which-custom-data-structures-do-you-use-in-solidity/510)\r\n- [Ethernaut Lvl 0 Walkthrough: ABIs, Web3, and how to abuse them](https://hackernoon.com/ethernaut-lvl-0-walkthrough-abis-web3-and-how-to-abuse-them-d92a8842d71b)\r\n- [Deconstructing a Solidity Contract  Part II: Creation vs. Runtime](https://forum.zeppelin.solutions/t/deconstructing-a-solidity-contract-part-ii-creation-vs-runtime/679)\r\n- [Solidity for Beginners](https://medium.com/swlh/solidity-for-beginners-9b8cb5cb4620)\r\n- [Stack Too Deep- Error in Solidity](https://medium.com/coinmonks/stack-too-deep-error-in-solidity-608d1bd6a1ea)\r\n- [Better Solidity debugging: stack traces are finally here](https://medium.com/nomic-labs-blog/better-solidity-debugging-stack-traces-are-finally-here-dd80a56f92bb)\r\n- [Fixed point math in Solidity](https://medium.com/cementdao/fixed-point-math-in-solidity-616f4508c6e8)\r\n- [Solidity Library for Array of Type Address](https://medium.com/51nodes/solidity-library-for-array-of-type-address-e40c36784ab2)\r\n- [`external` vs `public` best practices](https://ethereum.stackexchange.com/questions/19380/external-vs-public-best-practices)\r\n- [Solidity 0.6: You Might Be Sending Ether Incorrectly](https://medium.com/better-programming/solidity-0-6-you-might-be-sending-ether-all-wrong-1e119e1ffc27)\r\n- [Introduction into Mutation Testing](https://medium.com/swlh/introduction-into-mutation-testing-d6512dc702b0)\r\n- [Math in Solidity (Part 5: Exponent and Logarithm)](https://medium.com/coinmonks/math-in-solidity-part-5-exponent-and-logarithm-9aef8515136e)\r\n- [A brief analysis of the new try/catch functionality in Solidity 0.6](https://forum.openzeppelin.com/t/a-brief-analysis-of-the-new-try-catch-functionality-in-solidity-0-6/2564)\r\n\r\n## Contracts\r\n\r\n- [How to Code Your Own CryptoKitties-Style Game on Ethereum](https://medium.com/loom-network/how-to-code-your-own-cryptokitties-style-game-on-ethereum-7c8ac86a4eb3)\r\n- [How to call a contract method using the eth_call JSON-RPC API](https://ethereum.stackexchange.com/questions/3514/how-to-call-a-contract-method-using-the-eth-call-json-rpc-api)\r\n- [Smart Contract Patterns](https://github.com/cjgdev/smart-contract-patterns)\r\n- [Writing upgradable contracts in Solidity](https://blog.colony.io/writing-upgradeable-contracts-in-solidity-6743f0eecc88)\r\n- [Legal Design Patterns in Smart Contracts](https://medium.com/@billgleim/legal-design-patterns-in-smart-contracts-60916cd9ebd7)\t\r\n- [Mad blockchain science: A 100% upgradeable contract](https://www.reddit.com/r/ethereum/comments/4kt1zp/mad_blockchain_science_a_100_upgradeable_contract/)\r\n- [EVM Assembly Tricks](http://www.swende.se/blog/EVM-Assembly-trick.html)\r\n- [Lottery as a Smart Contract: The Business Logic](https://medium.com/coinmonks/lottery-as-a-smart-contract-the-business-logic-3bd22d3a6c4e)\r\n- [Creating Smart Contracts with Smart Contract](https://medium.com/coinmonks/creating-smart-contracts-with-smart-contract-d54e21d26e00)\r\n- [How to Write Upgradeable Smart Contracts with Truffle 5.0 and ZeppelinOS 2.0](https://paulrberg.com/post/2018/12/30/upgradeable-smart-contracts/)\r\n- [zepcon0 - ZeppelinOS - Upgradeability by Elena Nadolinski](https://www.youtube.com/watch?v=FzmzUHLiutg)\r\n- [Smart Contracts: A Simple Guide  Part 1](https://medium.com/@ShapeShift.io/smart-contracts-a-simple-guide-part-1-fa16a6c201c1)\r\n- [Writing Smart Contracts with Solidity > 0.5](https://medium.com/@rossbulat/writing-solidity-0-5-smart-contracts-101-5efd1ee9f53e)\r\n- [Dapp](https://dapp.tools/dapp/)\r\n- [Compiling and deploying Ethereum Smart Contracts with pure JavaScript](https://medium.com/coinmonks/compiling-and-deploying-ethereum-smart-contracts-with-pure-javascript-4bee3bfe99bb)\r\n- [Crypto Wars](https://github.com/e11-io/crypto-wars-solidity)\r\n- [Paritys Checklist for Secure Smart Contract Development](https://www.parity.io/paritys-checklist-for-secure-smart-contract-development/)\r\n- [A simple blockchain application for data verification](https://hackernoon.com/a-simple-blockchain-application-for-data-verification-c288a64e0d24)\r\n- [Smart contract vs token-based systems](https://medium.com/symbiont-io/smart-contract-vs-token-based-systems-ccdd99af41e3)\r\n- [Smart Contract Explained by Demonstration](https://medium.com/coinmonks/smart-contract-explained-by-demonstration-93b06e938474)\r\n- [How to write a simple token contract in Solidity](https://medium.com/datadriveninvestor/writing-a-simple-token-contract-in-solidity-1c457ab25b1a)\r\n\r\n## Geth\r\n\r\n- [An Introduction to Geth and Running Ethereum Nodes](https://www.sitepoint.com/an-introduction-to-geth-and-running-ethereum-nodes/)\r\n- [Set up an Ethereum development network in two minutes](https://gist.github.com/evertonfraga/9d65a9f3ea399ac138b3e40641accf23)\r\n- [Ethereum : How to setup a local test node with initial ether balance using geth](https://medium.com/@chim/ethereum-how-to-setup-a-local-test-node-with-initial-ether-balance-using-geth-974511ce712)\r\n\r\n## Web3JS\r\n\r\n- [Web3JS 1.x Documentation](http://web3js.readthedocs.io/en/1.0/)\r\n- [New Contract](https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#new-contract)\r\n- [Calling your first Smart Contract function with Web3 and Angular5](https://blog.fundrequest.io/calling-your-first-smart-contract-function-with-web3-and-angular5-aa1bde26a55c)\r\n- [Web3JS 0.2x Documentation](https://github.com/ethereum/wiki/wiki/JavaScript-API)\r\n- [03. Web3.js Tutorial - Attach a GUI to your Ethereum Smart Contract](https://www.youtube.com/watch?v=hcTPjpPvas8)\r\n- [04. Capturing Smart Contract Events in our User Interface (Solidity)](https://www.youtube.com/watch?v=L5Au5DY8eL4)\r\n\r\n## Truffle\r\n\r\n- [Truffle Framework](http://truffleframework.com)\r\n- [Truffle Tutorials](http://truffleframework.com/tutorials)\r\n- [PetShop Tutorial](http://truffleframework.com/tutorials/pet-shop)\r\n- [Building Robust Smart Contracts with OpenZeppelin](http://truffleframework.com/tutorials/robust-smart-contracts-with-openzeppelin)\r\n- [Truffle Boxes](http://truffleframework.com/boxes)\r\n- [How Truffle Works Under the Hood](https://medium.com/heartbankacademy/how-truffle-works-under-the-hood-f1ff6add416c)\r\n- [Debugging Smart Contracts with Truffle Debugger: A Practical Approach](https://medium.com/coinmonks/debugging-smart-contracts-with-truffle-debugger-a-practical-approach-3410e9d20837)\r\n- [Unit Testing: Build a Decentralized Domain Name System on Top of Ethereum](https://hack.bg/blog/tutorials/part-two-unit-testing-build-a-decentralized-domain-name-system-ddns-on-top-of-ethereum/)\r\n- [Introduction to the Truffle Suite and Dapp Development Pipeline](https://medium.com/@rossbulat/introduction-to-the-truffle-suite-and-dapp-development-pipeline-1b33bb8228d4)\r\n- [Test Driven Solidity with Truffle](https://medium.com/@yahya_gis/test-driven-solidity-with-truffle-e4beaa2bd194)\r\n- [Solidity and TDD - How to build a smart contract](https://ilanolkies.com/post/Solidity-and-TDD)\r\n- [Managing Ethereum Smart Contract Events with Drizzle](https://medium.com/truffle-suite/managing-ethereum-smart-contract-events-with-drizzle-58f3f9afbdad)\r\n- [Getting Started with Drizzle and React](https://www.trufflesuite.com/tutorials/getting-started-with-drizzle-and-react)\r\n- [Handy helper functions for Solidity Development with Truffle](https://medium.com/@contacttomnash/handy-helper-functions-for-solidity-development-with-truffle-39d14a371c12)\r\n- [How to Write Complex Truffle Migrations](https://medium.com/better-programming/how-to-write-complex-truffle-migrations-86d4b85d7783)\r\n\r\n## Dapps\r\n\r\n- [Dapps for Beginners](https://dappsforbeginners.wordpress.com)\r\n- [Tips and Tricks for Adding Metamask to Your UI](https://hackernoon.com/tips-and-tricks-for-adding-metamask-to-your-ui-32728b437194)\r\n- [Dip Dapp Doe??Anatomy of an Ethereum distributed fair game (part 1)](https://hackernoon.com/dip-dapp-doe-anatomy-of-an-ethereum-distributed-fair-game-part-1-5ee78980e360)\r\n- [Introducing ZepKit: the easiest way to start your decentralized application](https://blog.zeppelinos.org/introducing-zepkit/)\r\n- [Designing the architecture for your Ethereum application](https://forum.zeppelin.solutions/t/designing-the-architecture-for-your-ethereum-application/534/1)\r\n- [DApp Development for Python Programmers](https://levelup.gitconnected.com/dapps-development-for-python-developers-f52b32b54f28)\r\n\r\n## Explorers\r\n\r\n- [Etherparty Explorer](https://github.com/etherparty/explorer)\r\n\r\n## Tokens\r\n\r\n- [What is An Ethereum Token: The Ultimate Beginners Guide](https://blockgeeks.com/guides/ethereum-token/)\r\n- [ERC20 Token Standard](https://theethereum.wiki/w/index.php/ERC20_Token_Standard)\r\n- [ERC20 Token Standard: A Beginners Guide](https://medium.com/cryptoxtech/erc20-token-standard-a-beginners-guide-5b5f0c87e11f)\r\n- [ERC20](https://en.wikipedia.org/wiki/ERC20)\r\n- [Ethereum's ERC-20 Token Standard Has Been Formalized](https://www.coindesk.com/ethereums-erc-20-token-standard-formalized/)\r\n- [ERC20 Standard Token Explorer](https://etherscan.io/token-search)\r\n- [ERC: Non-fungible Token Standard #721](https://github.com/ethereum/EIPs/issues/721)\r\n- [Ethereum Based Tokens](https://theethereum.wiki/w/index.php/Ethereum_Based_Tokens)\r\n- [Ethereum smart service payment with tokens](https://medium.com/@jgm.orinoco/ethereum-smart-service-payment-with-tokens-60894a79f75c)\r\n- [How To Write A Smart-Contract For Your ICO? An Ultimate guide](https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/)\r\n- [The Innards of an ERC20 Token](https://hackernoon.com/the-innards-of-an-erc20-token-587c29e9b8a1)\r\n\r\n## CryptoKitties\r\n\r\n- [CriptoKitties](https://www.cryptokitties.co/)\r\n- [CriptoKitties White Paper](https://www.dropbox.com/s/a5h3zso545wuqkm/CryptoKitties_WhitePapurr_V2.pdf?dl=0)\r\n- [How to Code Your Own CryptoKitties-Style Game on Ethereum](https://medium.com/loom-network/how-to-code-your-own-cryptokitties-style-game-on-ethereum-7c8ac86a4eb3)\r\n- [CryptoKitties](https://www.cryptokitties.co)\r\n- [CryptoKitties: Collectible and Breedable Cats Empowered by Blockchain Technology](https://www.dropbox.com/s/a5h3zso545wuqkm/CryptoKitties_WhitePapurr_V2.pdf?dl=0)\r\n- [Source Code](https://ethfiddle.com/09YbyJRfiI)\r\n- [Code From EtherScan](https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code)\r\n- [The Inside Story of the CryptoKitties Congestion Crisis](https://media.consensys.net/the-inside-story-of-the-cryptokitties-congestion-crisis-499b35d119cc)\r\n- [Hacking the CryptoKitties Genome](https://hackernoon.com/hacking-the-cryptokitties-genome-1cb3e7dddab3)\r\n- [CryptoKitties, Explained  Mostly](https://medium.com/the-new-york-times/cryptokitties-explained-mostly-d56d70024f36)\r\n\r\n## Zeppelin\r\n\r\n- [How to implement ERC20 supply mechanisms](https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226)\r\n\r\n"
  },
  {
    "path": "exeth/bet/bet.eth",
    "content": "\r\n# retrieve accounts\r\n\r\nmessage \"retrieving accounts...\"\r\naccounts\r\n\r\n# compile contract\r\n# (contracts variable has the compiled contract data)\r\n\r\nmessage \"compiling contract...\"\r\ncompile \"./contracts/bet.sol\"\r\n\r\nmessage \"contract function hashes\"\r\ndump contracts.Bet.evm.methodIdentifiers\r\n\r\ndeploy Bet bet\r\n\r\ndump instances.bet\r\n\r\nmessage \"unknown match amount...\"\r\n\r\ncall bet getMatchAmount(string) \"foo\"\r\nassert result == 0\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"first bet...\"\r\n\r\nset value 1000\r\ninvoke bet bet(string,string) \"foo\" \"bar\"\r\n\r\nset value 0\r\ncall bet getMatchAmount(string) \"foo\"\r\nassert result == 1000\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"second bet...\"\r\n\r\nset value 2000\r\ninvoke bet bet(string,string) \"foo\" \"bar\"\r\n\r\nset value 0\r\ncall bet getMatchAmount(string) \"foo\"\r\nassert result == 3000\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"third bet with second player...\"\r\n\r\nset value 4000\r\nset from accounts[1]\r\ninvoke bet bet(string,string) \"foo\" \"baz\"\r\n\r\nset value 0\r\nset from accounts[0]\r\ncall bet getMatchAmount(string) \"foo\"\r\nassert result == 7000\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"amount of first player...\"\r\n\r\ncall bet getAddressAmount(address,string) accounts[0] \"foo\"\r\nassert result == 3000\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"amount of second player...\"\r\n\r\ncall bet getAddressAmount(address,string) accounts[1] \"foo\"\r\nassert result == 4000\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"amount of third player...\"\r\n\r\ncall bet getAddressAmount(address,string) accounts[2] \"foo\"\r\nassert result == 0\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"amount of first player in unknown match...\"\r\n\r\ncall bet getAddressAmount(address,string) accounts[0] \"unknown\"\r\nassert result == 0\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"amount of match and first result\"\r\n\r\ncall bet getMatchAmount(string,string) \"foo\" \"bar\"\r\nassert result == 3000\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"amount of match and second result\"\r\n\r\ncall bet getMatchAmount(string,string) \"foo\" \"baz\"\r\nassert result == 4000\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"resolve match\"\r\nbalance accounts[0]\r\nmessage \"balance first player before resolve\" result\r\nbalance accounts[1]\r\nmessage \"balance second player before resolve\" result\r\n\r\ninvoke bet resolve(string,string) \"foo\" \"bar\"\r\n\r\nbalance accounts[0]\r\nmessage \"balance first player after resolve\" result\r\nbalance accounts[1]\r\nmessage \"balance second player after resolve\" result\r\n\r\nmessage \"OK\"\r\n\r\nmessage \"done\"\r\n\t\r\n"
  },
  {
    "path": "exeth/bet/contracts/bet.sol",
    "content": "\r\ncontract Bet {\r\n\tstruct Bet {\r\n\t\taddress payable account;\r\n\t\tstring name;\r\n\t\tstring result;\r\n\t\tuint amount;\r\n\t}\r\n\t\r\n\tmapping (string => Bet[]) betsByMatch;\r\n\tmapping (address => Bet[]) betsByAddress;\r\n\t\r\n\tfunction bet(string memory name, string memory result) public payable {\r\n\t\tBet memory b = Bet(msg.sender, name, result, msg.value);\r\n\t\tbetsByAddress[msg.sender].push(b);\r\n\t\tbetsByMatch[name].push(b);\r\n\t}\r\n\t\r\n\tfunction getMatchAmount(string memory name) public view returns (uint) {\r\n\t\tuint result;\r\n\t\t\r\n\t\tBet[] storage bets = betsByMatch[name];\r\n\t\tuint nbets = bets.length;\r\n\t\t\r\n\t\tfor (uint k = 0; k < nbets; k++) {\r\n\t\t\tBet storage b = bets[k];\r\n\t\t\t\r\n\t\t\tresult += b.amount;\r\n\t\t}\r\n\t\t\r\n\t\treturn result;\r\n\t}\r\n\t\r\n\tfunction getMatchAmount(string memory name, string memory result) public view returns (uint) {\r\n\t\tuint amount;\r\n\t\t\r\n\t\tBet[] storage bets = betsByMatch[name];\r\n\t\tuint nbets = bets.length;\r\n\t\tbytes32 kresult = keccak256(abi.encodePacked(result));\r\n\t\t\r\n\t\tfor (uint k = 0; k < nbets; k++) {\r\n\t\t\tBet storage b = bets[k];\r\n\t\t\t\r\n\t\t\tif (keccak256(abi.encodePacked(b.result)) != kresult)\r\n\t\t\t\tcontinue;\r\n\t\t\t\r\n\t\t\tamount += b.amount;\r\n\t\t}\r\n\t\t\r\n\t\treturn amount;\r\n\t}\r\n\t\r\n\tfunction resolve(string memory name, string memory result) public {\r\n\t\tuint total = getMatchAmount(name);\r\n\t\tuint winners = getMatchAmount(name, result);\r\n\t\t\r\n\t\tbytes32 kresult = keccak256(abi.encodePacked(result));\r\n\t\t\r\n\t\tif (winners > 0) {\r\n\t\t\tuint factor = total / winners;\r\n\t\t\t\r\n\t\t\tBet[] storage bets = betsByMatch[name];\r\n\t\t\tuint nbets = bets.length;\r\n\t\t\t\r\n\t\t\tfor (uint k = 0; k < nbets; k++) {\r\n\t\t\t\tBet storage b = bets[k];\r\n\t\t\t\t\r\n\t\t\t\tif (keccak256(abi.encodePacked(b.result)) != kresult)\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\r\n\t\t\t\tb.account.transfer(factor * b.amount);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tbetsByMatch[name].length = 0;\r\n\t\t\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tfunction getAddressAmount(address from, string memory name) public view returns (uint) {\r\n\t\tuint result;\r\n\t\tBet[] storage bs = betsByAddress[from];\r\n\t\tuint nbs = bs.length;\r\n\t\tbytes32 kname = keccak256(abi.encodePacked(name));\r\n\t\t\r\n\t\tfor (uint k = 0; k < nbs; k++) {\r\n\t\t\tBet storage b = bs[k];\r\n\t\t\t\r\n\t\t\tif (keccak256(abi.encodePacked(b.name)) != kname)\r\n\t\t\t\tcontinue;\r\n\t\t\t\t\r\n\t\t\tresult += b.amount;\r\n\t\t}\r\n\t\t\t\r\n\t\treturn result;\r\n\t}\r\n}\r\n\r\n"
  },
  {
    "path": "exeth/blockchain/blockchain.eth",
    "content": "\r\n# retrieve accounts\r\n\r\nmessage \"retrieving accounts...\"\r\naccounts\r\n\r\n# compile contract\r\n# (contracts variable has the compiled contract data)\r\n\r\nmessage \"compiling contract...\"\r\ncompile \"./contracts/blockchain.sol\"\r\n\r\nmessage \"contract function hashes\"\r\ndump contracts.Blockchain.functionHashes\r\n\r\n# deploy instances, using default sender: accounts[0], message default value: 0\r\n# first argument: contract name\r\n# second argument: new instance name\r\n\r\nmessage \"deploy instance...\"\r\ndeploy Blockchain blockchain\r\n\r\n# show instance address\r\n# (instances variable has the instances data)\r\n\r\nmessage \"new instance\" instances.blockchain.address\r\n\r\n# the block with hash 0 is not in the blockchain\r\n\r\nmessage \"check block with hash\" 0\r\ncall blockchain blockInfos(uint256) 0\r\n\r\nassert result.length === 3\r\nassert result[0] == 0\r\nassert result[1] == 0\r\nassert result[2] == 0\r\n\r\n# add a block\r\n\r\nmessage \"adding block with hash 0x0100...\"\r\ninvoke blockchain addBlock(uint32,uint256,uint256) 1 0x0100 0\r\n\r\nmessage \"check block with hash\" 0x0100\r\ncall blockchain blockInfos(uint256) 0x0100\r\n\r\nassert result.length === 3\r\nassert result[0] == 1\r\nassert result[1] == 0x100\r\nassert result[2] == 0\r\n\r\nmessage \"block info\" result\r\n\r\n# add orphan block\r\n\r\nmessage \"adding orphan block...\"\r\ninvoke blockchain addBlock(uint32,uint256,uint256) 3 0x0300 0x0200\r\n\r\nmessage \"check block with hash\" 0x0300\r\ncall blockchain blockInfos(uint256) 0x0300\r\n\r\nassert result.length === 3\r\nassert result[0] == 0\r\nassert result[1] == 0\r\nassert result[2] == 0\r\n\r\nmessage \"block does not exist\"\r\n\r\nmessage \"done\"\r\n"
  },
  {
    "path": "exeth/blockchain/contracts/blockchain.sol",
    "content": "\r\ncontract Blockchain {\r\n\tstruct BlockInfo {\r\n\t\tuint32 number;\r\n\t\tuint hash;\r\n\t\tuint parentHash;\r\n\t}\r\n\t\r\n\tmapping(uint => BlockInfo) public blockInfos;\r\n\t\r\n\tfunction addBlock(uint32 number, uint hash, uint parentHash) public returns (bool) {\r\n\t\tif (blockInfos[hash].hash != 0)\r\n\t\t\treturn false;\r\n\t\t\t\r\n\t\tif (number > 1 && blockInfos[parentHash].hash == 0)\r\n\t\t\treturn false;\r\n\t\t\t\r\n\t\tBlockInfo memory binfo = BlockInfo(number, hash, parentHash);\r\n\t\t\r\n\t\tblockInfos[hash] = binfo;\r\n\t\t\r\n\t\treturn true;\r\n\t}\r\n}\r\n\r\n"
  },
  {
    "path": "exeth/events/build/contracts/Emitter.json",
    "content": "{\n  \"contractName\": \"Emitter\",\n  \"abi\": [\n    {\n      \"anonymous\": false,\n      \"inputs\": [],\n      \"name\": \"BeginEvents\",\n      \"type\": \"event\"\n    },\n    {\n      \"anonymous\": false,\n      \"inputs\": [\n        {\n          \"indexed\": true,\n          \"name\": \"receiver\",\n          \"type\": \"address\"\n        },\n        {\n          \"indexed\": true,\n          \"name\": \"token\",\n          \"type\": \"address\"\n        },\n        {\n          \"indexed\": false,\n          \"name\": \"amount\",\n          \"type\": \"uint256\"\n        }\n      ],\n      \"name\": \"Transfer\",\n      \"type\": \"event\"\n    },\n    {\n      \"anonymous\": false,\n      \"inputs\": [],\n      \"name\": \"EndEvents\",\n      \"type\": \"event\"\n    },\n    {\n      \"constant\": false,\n      \"inputs\": [\n        {\n          \"name\": \"receivers\",\n          \"type\": \"address[]\"\n        },\n        {\n          \"name\": \"tokens\",\n          \"type\": \"address[]\"\n        },\n        {\n          \"name\": \"amounts\",\n          \"type\": \"uint256[]\"\n        }\n      ],\n      \"name\": \"emitEvents\",\n      \"outputs\": [],\n      \"payable\": false,\n      \"stateMutability\": \"nonpayable\",\n      \"type\": \"function\"\n    }\n  ],\n  \"metadata\": \"{\\\"compiler\\\":{\\\"version\\\":\\\"0.5.0+commit.1d4f565a\\\"},\\\"language\\\":\\\"Solidity\\\",\\\"output\\\":{\\\"abi\\\":[{\\\"constant\\\":false,\\\"inputs\\\":[{\\\"name\\\":\\\"receivers\\\",\\\"type\\\":\\\"address[]\\\"},{\\\"name\\\":\\\"tokens\\\",\\\"type\\\":\\\"address[]\\\"},{\\\"name\\\":\\\"amounts\\\",\\\"type\\\":\\\"uint256[]\\\"}],\\\"name\\\":\\\"emitEvents\\\",\\\"outputs\\\":[],\\\"payable\\\":false,\\\"stateMutability\\\":\\\"nonpayable\\\",\\\"type\\\":\\\"function\\\"},{\\\"anonymous\\\":false,\\\"inputs\\\":[],\\\"name\\\":\\\"BeginEvents\\\",\\\"type\\\":\\\"event\\\"},{\\\"anonymous\\\":false,\\\"inputs\\\":[{\\\"indexed\\\":true,\\\"name\\\":\\\"receiver\\\",\\\"type\\\":\\\"address\\\"},{\\\"indexed\\\":true,\\\"name\\\":\\\"token\\\",\\\"type\\\":\\\"address\\\"},{\\\"indexed\\\":false,\\\"name\\\":\\\"amount\\\",\\\"type\\\":\\\"uint256\\\"}],\\\"name\\\":\\\"Transfer\\\",\\\"type\\\":\\\"event\\\"},{\\\"anonymous\\\":false,\\\"inputs\\\":[],\\\"name\\\":\\\"EndEvents\\\",\\\"type\\\":\\\"event\\\"}],\\\"devdoc\\\":{\\\"methods\\\":{}},\\\"userdoc\\\":{\\\"methods\\\":{}}},\\\"settings\\\":{\\\"compilationTarget\\\":{\\\"/C/git/SoliditySamples/exeth/events/contracts/Emitter.sol\\\":\\\"Emitter\\\"},\\\"evmVersion\\\":\\\"byzantium\\\",\\\"libraries\\\":{},\\\"optimizer\\\":{\\\"enabled\\\":false,\\\"runs\\\":200},\\\"remappings\\\":[]},\\\"sources\\\":{\\\"/C/git/SoliditySamples/exeth/events/contracts/Emitter.sol\\\":{\\\"keccak256\\\":\\\"0x5a7d8d2327771f416c2fef21b20b7aad388b7026f17a5bc061528e7ae45f888c\\\",\\\"urls\\\":[\\\"bzzr://d1ab698196751e58ae4b0f7b35590fcdc964cc14b4e47b96e9c3c36a78278090\\\"]}},\\\"version\\\":1}\",\n  \"bytecode\": \"0x608060405234801561001057600080fd5b50610389806100206000396000f3fe608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680637da2938a14610046575b600080fd5b34801561005257600080fd5b506102316004803603606081101561006957600080fd5b810190808035906020019064010000000081111561008657600080fd5b82018360208201111561009857600080fd5b803590602001918460208302840111640100000000831117156100ba57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561011a57600080fd5b82018360208201111561012c57600080fd5b8035906020019184602083028401116401000000008311171561014e57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156101ae57600080fd5b8201836020820111156101c057600080fd5b803590602001918460208302840111640100000000831117156101e257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610233565b005b6000835190507f875d966eda6487c7c1a52ef9d6ec077de2fe63a903c4ed02db0d11f4528a001160405160405180910390a160008090505b8181101561032a57838181518110151561028157fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1685828151811015156102af57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85848151811015156102fe57fe5b906020019060200201516040518082815260200191505060405180910390a3808060010191505061026b565b507f30beee9487f19272cea486f3940e1f4a5ce5d4f4fecb20dbf6979d63e695e5d760405160405180910390a15050505056fea165627a7a72305820650f25b8abd4b8e7f9b4428413d06590d1a55ca48f362990346605239464787c0029\",\n  \"deployedBytecode\": \"0x608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680637da2938a14610046575b600080fd5b34801561005257600080fd5b506102316004803603606081101561006957600080fd5b810190808035906020019064010000000081111561008657600080fd5b82018360208201111561009857600080fd5b803590602001918460208302840111640100000000831117156100ba57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561011a57600080fd5b82018360208201111561012c57600080fd5b8035906020019184602083028401116401000000008311171561014e57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156101ae57600080fd5b8201836020820111156101c057600080fd5b803590602001918460208302840111640100000000831117156101e257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610233565b005b6000835190507f875d966eda6487c7c1a52ef9d6ec077de2fe63a903c4ed02db0d11f4528a001160405160405180910390a160008090505b8181101561032a57838181518110151561028157fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1685828151811015156102af57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85848151811015156102fe57fe5b906020019060200201516040518082815260200191505060405180910390a3808060010191505061026b565b507f30beee9487f19272cea486f3940e1f4a5ce5d4f4fecb20dbf6979d63e695e5d760405160405180910390a15050505056fea165627a7a72305820650f25b8abd4b8e7f9b4428413d06590d1a55ca48f362990346605239464787c0029\",\n  \"sourceMap\": \"2:524:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2:524:0;;;;;;;\",\n  \"deployedSourceMap\": \"2:524:0:-;;;;;;;;;;;;;;;;;;;;;;;;168:355;;8:9:-1;5:2;;;30:1;27;20:12;5:2;168:355:0;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;168:355:0;;;;;;;;;;21:11:-1;8;5:28;2:2;;;46:1;43;36:12;2:2;168:355:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;168:355:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;39:11;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;168:355:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;168:355:0;;;;;;;;;;;;;;;;;21:11:-1;8;5:28;2:2;;;46:1;43;36:12;2:2;168:355:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;168:355:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;39:11;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;168:355:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;168:355:0;;;;;;;;;;;;;;;;;21:11:-1;8;5:28;2:2;;;46:1;43;36:12;2:2;168:355:0;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;168:355:0;;;;;;101:9:-1;95:2;81:12;77:21;67:8;63:36;60:51;39:11;25:12;22:29;11:108;8:2;;;132:1;129;122:12;8:2;168:355:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;93:3;85:6;81:16;74:27;137:4;133:9;126:4;121:3;117:14;113:30;106:37;;169:3;161:6;157:16;147:26;;168:355:0;;;;;;;;;;;;;;;;;;;285:12;300:9;:16;285:31;;342:13;;;;;;;;;;381:6;390:1;381:10;;376:98;397:7;393:1;:11;376:98;;;452:6;459:1;452:9;;;;;;;;;;;;;;;;;;429:45;;438:9;448:1;438:12;;;;;;;;;;;;;;;;;;429:45;;;463:7;471:1;463:10;;;;;;;;;;;;;;;;;;429:45;;;;;;;;;;;;;;;;;;406:3;;;;;;;376:98;;;;504:11;;;;;;;;;;168:355;;;;:::o\",\n  \"source\": \"\\r\\ncontract Emitter {\\r\\n    event BeginEvents();\\r\\n    event Transfer(address indexed receiver, address indexed token, uint256 amount);\\r\\n    event EndEvents();\\r\\n    \\r\\n    function emitEvents(address[] memory receivers, address[] memory tokens, uint256[] memory amounts) public {\\r\\n        uint nevents = receivers.length;\\r\\n        \\r\\n        emit BeginEvents();\\r\\n        \\r\\n        for (uint k = 0; k < nevents; k++)\\r\\n            emit Transfer(receivers[k], tokens[k], amounts[k]);\\r\\n            \\r\\n        emit EndEvents();\\r\\n    }\\r\\n}\",\n  \"sourcePath\": \"C:/git/SoliditySamples/exeth/events/contracts/Emitter.sol\",\n  \"ast\": {\n    \"absolutePath\": \"/C/git/SoliditySamples/exeth/events/contracts/Emitter.sol\",\n    \"exportedSymbols\": {\n      \"Emitter\": [\n        60\n      ]\n    },\n    \"id\": 61,\n    \"nodeType\": \"SourceUnit\",\n    \"nodes\": [\n      {\n        \"baseContracts\": [],\n        \"contractDependencies\": [],\n        \"contractKind\": \"contract\",\n        \"documentation\": null,\n        \"fullyImplemented\": true,\n        \"id\": 60,\n        \"linearizedBaseContracts\": [\n          60\n        ],\n        \"name\": \"Emitter\",\n        \"nodeType\": \"ContractDefinition\",\n        \"nodes\": [\n          {\n            \"anonymous\": false,\n            \"documentation\": null,\n            \"id\": 2,\n            \"name\": \"BeginEvents\",\n            \"nodeType\": \"EventDefinition\",\n            \"parameters\": {\n              \"id\": 1,\n              \"nodeType\": \"ParameterList\",\n              \"parameters\": [],\n              \"src\": \"43:2:0\"\n            },\n            \"src\": \"26:20:0\"\n          },\n          {\n            \"anonymous\": false,\n            \"documentation\": null,\n            \"id\": 10,\n            \"name\": \"Transfer\",\n            \"nodeType\": \"EventDefinition\",\n            \"parameters\": {\n              \"id\": 9,\n              \"nodeType\": \"ParameterList\",\n              \"parameters\": [\n                {\n                  \"constant\": false,\n                  \"id\": 4,\n                  \"indexed\": true,\n                  \"name\": \"receiver\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 10,\n                  \"src\": \"67:24:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"default\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_address\",\n                    \"typeString\": \"address\"\n                  },\n                  \"typeName\": {\n                    \"id\": 3,\n                    \"name\": \"address\",\n                    \"nodeType\": \"ElementaryTypeName\",\n                    \"src\": \"67:7:0\",\n                    \"stateMutability\": \"nonpayable\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_address\",\n                      \"typeString\": \"address\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                },\n                {\n                  \"constant\": false,\n                  \"id\": 6,\n                  \"indexed\": true,\n                  \"name\": \"token\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 10,\n                  \"src\": \"93:21:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"default\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_address\",\n                    \"typeString\": \"address\"\n                  },\n                  \"typeName\": {\n                    \"id\": 5,\n                    \"name\": \"address\",\n                    \"nodeType\": \"ElementaryTypeName\",\n                    \"src\": \"93:7:0\",\n                    \"stateMutability\": \"nonpayable\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_address\",\n                      \"typeString\": \"address\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                },\n                {\n                  \"constant\": false,\n                  \"id\": 8,\n                  \"indexed\": false,\n                  \"name\": \"amount\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 10,\n                  \"src\": \"116:14:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"default\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_uint256\",\n                    \"typeString\": \"uint256\"\n                  },\n                  \"typeName\": {\n                    \"id\": 7,\n                    \"name\": \"uint256\",\n                    \"nodeType\": \"ElementaryTypeName\",\n                    \"src\": \"116:7:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_uint256\",\n                      \"typeString\": \"uint256\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                }\n              ],\n              \"src\": \"66:65:0\"\n            },\n            \"src\": \"52:80:0\"\n          },\n          {\n            \"anonymous\": false,\n            \"documentation\": null,\n            \"id\": 12,\n            \"name\": \"EndEvents\",\n            \"nodeType\": \"EventDefinition\",\n            \"parameters\": {\n              \"id\": 11,\n              \"nodeType\": \"ParameterList\",\n              \"parameters\": [],\n              \"src\": \"153:2:0\"\n            },\n            \"src\": \"138:18:0\"\n          },\n          {\n            \"body\": {\n              \"id\": 58,\n              \"nodeType\": \"Block\",\n              \"src\": \"274:249:0\",\n              \"statements\": [\n                {\n                  \"assignments\": [\n                    25\n                  ],\n                  \"declarations\": [\n                    {\n                      \"constant\": false,\n                      \"id\": 25,\n                      \"name\": \"nevents\",\n                      \"nodeType\": \"VariableDeclaration\",\n                      \"scope\": 58,\n                      \"src\": \"285:12:0\",\n                      \"stateVariable\": false,\n                      \"storageLocation\": \"default\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_uint256\",\n                        \"typeString\": \"uint256\"\n                      },\n                      \"typeName\": {\n                        \"id\": 24,\n                        \"name\": \"uint\",\n                        \"nodeType\": \"ElementaryTypeName\",\n                        \"src\": \"285:4:0\",\n                        \"typeDescriptions\": {\n                          \"typeIdentifier\": \"t_uint256\",\n                          \"typeString\": \"uint256\"\n                        }\n                      },\n                      \"value\": null,\n                      \"visibility\": \"internal\"\n                    }\n                  ],\n                  \"id\": 28,\n                  \"initialValue\": {\n                    \"argumentTypes\": null,\n                    \"expression\": {\n                      \"argumentTypes\": null,\n                      \"id\": 26,\n                      \"name\": \"receivers\",\n                      \"nodeType\": \"Identifier\",\n                      \"overloadedDeclarations\": [],\n                      \"referencedDeclaration\": 15,\n                      \"src\": \"300:9:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_array$_t_address_$dyn_memory_ptr\",\n                        \"typeString\": \"address[] memory\"\n                      }\n                    },\n                    \"id\": 27,\n                    \"isConstant\": false,\n                    \"isLValue\": false,\n                    \"isPure\": false,\n                    \"lValueRequested\": false,\n                    \"memberName\": \"length\",\n                    \"nodeType\": \"MemberAccess\",\n                    \"referencedDeclaration\": null,\n                    \"src\": \"300:16:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_uint256\",\n                      \"typeString\": \"uint256\"\n                    }\n                  },\n                  \"nodeType\": \"VariableDeclarationStatement\",\n                  \"src\": \"285:31:0\"\n                },\n                {\n                  \"eventCall\": {\n                    \"argumentTypes\": null,\n                    \"arguments\": [],\n                    \"expression\": {\n                      \"argumentTypes\": [],\n                      \"id\": 29,\n                      \"name\": \"BeginEvents\",\n                      \"nodeType\": \"Identifier\",\n                      \"overloadedDeclarations\": [],\n                      \"referencedDeclaration\": 2,\n                      \"src\": \"342:11:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_function_event_nonpayable$__$returns$__$\",\n                        \"typeString\": \"function ()\"\n                      }\n                    },\n                    \"id\": 30,\n                    \"isConstant\": false,\n                    \"isLValue\": false,\n                    \"isPure\": false,\n                    \"kind\": \"functionCall\",\n                    \"lValueRequested\": false,\n                    \"names\": [],\n                    \"nodeType\": \"FunctionCall\",\n                    \"src\": \"342:13:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_tuple$__$\",\n                      \"typeString\": \"tuple()\"\n                    }\n                  },\n                  \"id\": 31,\n                  \"nodeType\": \"EmitStatement\",\n                  \"src\": \"337:18:0\"\n                },\n                {\n                  \"body\": {\n                    \"eventCall\": {\n                      \"argumentTypes\": null,\n                      \"arguments\": [\n                        {\n                          \"argumentTypes\": null,\n                          \"baseExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 43,\n                            \"name\": \"receivers\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 15,\n                            \"src\": \"438:9:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_array$_t_address_$dyn_memory_ptr\",\n                              \"typeString\": \"address[] memory\"\n                            }\n                          },\n                          \"id\": 45,\n                          \"indexExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 44,\n                            \"name\": \"k\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 33,\n                            \"src\": \"448:1:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_uint256\",\n                              \"typeString\": \"uint256\"\n                            }\n                          },\n                          \"isConstant\": false,\n                          \"isLValue\": true,\n                          \"isPure\": false,\n                          \"lValueRequested\": false,\n                          \"nodeType\": \"IndexAccess\",\n                          \"src\": \"438:12:0\",\n                          \"typeDescriptions\": {\n                            \"typeIdentifier\": \"t_address\",\n                            \"typeString\": \"address\"\n                          }\n                        },\n                        {\n                          \"argumentTypes\": null,\n                          \"baseExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 46,\n                            \"name\": \"tokens\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 18,\n                            \"src\": \"452:6:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_array$_t_address_$dyn_memory_ptr\",\n                              \"typeString\": \"address[] memory\"\n                            }\n                          },\n                          \"id\": 48,\n                          \"indexExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 47,\n                            \"name\": \"k\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 33,\n                            \"src\": \"459:1:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_uint256\",\n                              \"typeString\": \"uint256\"\n                            }\n                          },\n                          \"isConstant\": false,\n                          \"isLValue\": true,\n                          \"isPure\": false,\n                          \"lValueRequested\": false,\n                          \"nodeType\": \"IndexAccess\",\n                          \"src\": \"452:9:0\",\n                          \"typeDescriptions\": {\n                            \"typeIdentifier\": \"t_address\",\n                            \"typeString\": \"address\"\n                          }\n                        },\n                        {\n                          \"argumentTypes\": null,\n                          \"baseExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 49,\n                            \"name\": \"amounts\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 21,\n                            \"src\": \"463:7:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_array$_t_uint256_$dyn_memory_ptr\",\n                              \"typeString\": \"uint256[] memory\"\n                            }\n                          },\n                          \"id\": 51,\n                          \"indexExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 50,\n                            \"name\": \"k\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 33,\n                            \"src\": \"471:1:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_uint256\",\n                              \"typeString\": \"uint256\"\n                            }\n                          },\n                          \"isConstant\": false,\n                          \"isLValue\": true,\n                          \"isPure\": false,\n                          \"lValueRequested\": false,\n                          \"nodeType\": \"IndexAccess\",\n                          \"src\": \"463:10:0\",\n                          \"typeDescriptions\": {\n                            \"typeIdentifier\": \"t_uint256\",\n                            \"typeString\": \"uint256\"\n                          }\n                        }\n                      ],\n                      \"expression\": {\n                        \"argumentTypes\": [\n                          {\n                            \"typeIdentifier\": \"t_address\",\n                            \"typeString\": \"address\"\n                          },\n                          {\n                            \"typeIdentifier\": \"t_address\",\n                            \"typeString\": \"address\"\n                          },\n                          {\n                            \"typeIdentifier\": \"t_uint256\",\n                            \"typeString\": \"uint256\"\n                          }\n                        ],\n                        \"id\": 42,\n                        \"name\": \"Transfer\",\n                        \"nodeType\": \"Identifier\",\n                        \"overloadedDeclarations\": [],\n                        \"referencedDeclaration\": 10,\n                        \"src\": \"429:8:0\",\n                        \"typeDescriptions\": {\n                          \"typeIdentifier\": \"t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$\",\n                          \"typeString\": \"function (address,address,uint256)\"\n                        }\n                      },\n                      \"id\": 52,\n                      \"isConstant\": false,\n                      \"isLValue\": false,\n                      \"isPure\": false,\n                      \"kind\": \"functionCall\",\n                      \"lValueRequested\": false,\n                      \"names\": [],\n                      \"nodeType\": \"FunctionCall\",\n                      \"src\": \"429:45:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_tuple$__$\",\n                        \"typeString\": \"tuple()\"\n                      }\n                    },\n                    \"id\": 53,\n                    \"nodeType\": \"EmitStatement\",\n                    \"src\": \"424:50:0\"\n                  },\n                  \"condition\": {\n                    \"argumentTypes\": null,\n                    \"commonType\": {\n                      \"typeIdentifier\": \"t_uint256\",\n                      \"typeString\": \"uint256\"\n                    },\n                    \"id\": 38,\n                    \"isConstant\": false,\n                    \"isLValue\": false,\n                    \"isPure\": false,\n                    \"lValueRequested\": false,\n                    \"leftExpression\": {\n                      \"argumentTypes\": null,\n                      \"id\": 36,\n                      \"name\": \"k\",\n                      \"nodeType\": \"Identifier\",\n                      \"overloadedDeclarations\": [],\n                      \"referencedDeclaration\": 33,\n                      \"src\": \"393:1:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_uint256\",\n                        \"typeString\": \"uint256\"\n                      }\n                    },\n                    \"nodeType\": \"BinaryOperation\",\n                    \"operator\": \"<\",\n                    \"rightExpression\": {\n                      \"argumentTypes\": null,\n                      \"id\": 37,\n                      \"name\": \"nevents\",\n                      \"nodeType\": \"Identifier\",\n                      \"overloadedDeclarations\": [],\n                      \"referencedDeclaration\": 25,\n                      \"src\": \"397:7:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_uint256\",\n                        \"typeString\": \"uint256\"\n                      }\n                    },\n                    \"src\": \"393:11:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_bool\",\n                      \"typeString\": \"bool\"\n                    }\n                  },\n                  \"id\": 54,\n                  \"initializationExpression\": {\n                    \"assignments\": [\n                      33\n                    ],\n                    \"declarations\": [\n                      {\n                        \"constant\": false,\n                        \"id\": 33,\n                        \"name\": \"k\",\n                        \"nodeType\": \"VariableDeclaration\",\n                        \"scope\": 54,\n                        \"src\": \"381:6:0\",\n                        \"stateVariable\": false,\n                        \"storageLocation\": \"default\",\n                        \"typeDescriptions\": {\n                          \"typeIdentifier\": \"t_uint256\",\n                          \"typeString\": \"uint256\"\n                        },\n                        \"typeName\": {\n                          \"id\": 32,\n                          \"name\": \"uint\",\n                          \"nodeType\": \"ElementaryTypeName\",\n                          \"src\": \"381:4:0\",\n                          \"typeDescriptions\": {\n                            \"typeIdentifier\": \"t_uint256\",\n                            \"typeString\": \"uint256\"\n                          }\n                        },\n                        \"value\": null,\n                        \"visibility\": \"internal\"\n                      }\n                    ],\n                    \"id\": 35,\n                    \"initialValue\": {\n                      \"argumentTypes\": null,\n                      \"hexValue\": \"30\",\n                      \"id\": 34,\n                      \"isConstant\": false,\n                      \"isLValue\": false,\n                      \"isPure\": true,\n                      \"kind\": \"number\",\n                      \"lValueRequested\": false,\n                      \"nodeType\": \"Literal\",\n                      \"src\": \"390:1:0\",\n                      \"subdenomination\": null,\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_rational_0_by_1\",\n                        \"typeString\": \"int_const 0\"\n                      },\n                      \"value\": \"0\"\n                    },\n                    \"nodeType\": \"VariableDeclarationStatement\",\n                    \"src\": \"381:10:0\"\n                  },\n                  \"loopExpression\": {\n                    \"expression\": {\n                      \"argumentTypes\": null,\n                      \"id\": 40,\n                      \"isConstant\": false,\n                      \"isLValue\": false,\n                      \"isPure\": false,\n                      \"lValueRequested\": false,\n                      \"nodeType\": \"UnaryOperation\",\n                      \"operator\": \"++\",\n                      \"prefix\": false,\n                      \"src\": \"406:3:0\",\n                      \"subExpression\": {\n                        \"argumentTypes\": null,\n                        \"id\": 39,\n                        \"name\": \"k\",\n                        \"nodeType\": \"Identifier\",\n                        \"overloadedDeclarations\": [],\n                        \"referencedDeclaration\": 33,\n                        \"src\": \"406:1:0\",\n                        \"typeDescriptions\": {\n                          \"typeIdentifier\": \"t_uint256\",\n                          \"typeString\": \"uint256\"\n                        }\n                      },\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_uint256\",\n                        \"typeString\": \"uint256\"\n                      }\n                    },\n                    \"id\": 41,\n                    \"nodeType\": \"ExpressionStatement\",\n                    \"src\": \"406:3:0\"\n                  },\n                  \"nodeType\": \"ForStatement\",\n                  \"src\": \"376:98:0\"\n                },\n                {\n                  \"eventCall\": {\n                    \"argumentTypes\": null,\n                    \"arguments\": [],\n                    \"expression\": {\n                      \"argumentTypes\": [],\n                      \"id\": 55,\n                      \"name\": \"EndEvents\",\n                      \"nodeType\": \"Identifier\",\n                      \"overloadedDeclarations\": [],\n                      \"referencedDeclaration\": 12,\n                      \"src\": \"504:9:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_function_event_nonpayable$__$returns$__$\",\n                        \"typeString\": \"function ()\"\n                      }\n                    },\n                    \"id\": 56,\n                    \"isConstant\": false,\n                    \"isLValue\": false,\n                    \"isPure\": false,\n                    \"kind\": \"functionCall\",\n                    \"lValueRequested\": false,\n                    \"names\": [],\n                    \"nodeType\": \"FunctionCall\",\n                    \"src\": \"504:11:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_tuple$__$\",\n                      \"typeString\": \"tuple()\"\n                    }\n                  },\n                  \"id\": 57,\n                  \"nodeType\": \"EmitStatement\",\n                  \"src\": \"499:16:0\"\n                }\n              ]\n            },\n            \"documentation\": null,\n            \"id\": 59,\n            \"implemented\": true,\n            \"kind\": \"function\",\n            \"modifiers\": [],\n            \"name\": \"emitEvents\",\n            \"nodeType\": \"FunctionDefinition\",\n            \"parameters\": {\n              \"id\": 22,\n              \"nodeType\": \"ParameterList\",\n              \"parameters\": [\n                {\n                  \"constant\": false,\n                  \"id\": 15,\n                  \"name\": \"receivers\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 59,\n                  \"src\": \"188:26:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"memory\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_array$_t_address_$dyn_memory_ptr\",\n                    \"typeString\": \"address[]\"\n                  },\n                  \"typeName\": {\n                    \"baseType\": {\n                      \"id\": 13,\n                      \"name\": \"address\",\n                      \"nodeType\": \"ElementaryTypeName\",\n                      \"src\": \"188:7:0\",\n                      \"stateMutability\": \"nonpayable\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_address\",\n                        \"typeString\": \"address\"\n                      }\n                    },\n                    \"id\": 14,\n                    \"length\": null,\n                    \"nodeType\": \"ArrayTypeName\",\n                    \"src\": \"188:9:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_array$_t_address_$dyn_storage_ptr\",\n                      \"typeString\": \"address[]\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                },\n                {\n                  \"constant\": false,\n                  \"id\": 18,\n                  \"name\": \"tokens\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 59,\n                  \"src\": \"216:23:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"memory\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_array$_t_address_$dyn_memory_ptr\",\n                    \"typeString\": \"address[]\"\n                  },\n                  \"typeName\": {\n                    \"baseType\": {\n                      \"id\": 16,\n                      \"name\": \"address\",\n                      \"nodeType\": \"ElementaryTypeName\",\n                      \"src\": \"216:7:0\",\n                      \"stateMutability\": \"nonpayable\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_address\",\n                        \"typeString\": \"address\"\n                      }\n                    },\n                    \"id\": 17,\n                    \"length\": null,\n                    \"nodeType\": \"ArrayTypeName\",\n                    \"src\": \"216:9:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_array$_t_address_$dyn_storage_ptr\",\n                      \"typeString\": \"address[]\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                },\n                {\n                  \"constant\": false,\n                  \"id\": 21,\n                  \"name\": \"amounts\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 59,\n                  \"src\": \"241:24:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"memory\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_array$_t_uint256_$dyn_memory_ptr\",\n                    \"typeString\": \"uint256[]\"\n                  },\n                  \"typeName\": {\n                    \"baseType\": {\n                      \"id\": 19,\n                      \"name\": \"uint256\",\n                      \"nodeType\": \"ElementaryTypeName\",\n                      \"src\": \"241:7:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_uint256\",\n                        \"typeString\": \"uint256\"\n                      }\n                    },\n                    \"id\": 20,\n                    \"length\": null,\n                    \"nodeType\": \"ArrayTypeName\",\n                    \"src\": \"241:9:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_array$_t_uint256_$dyn_storage_ptr\",\n                      \"typeString\": \"uint256[]\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                }\n              ],\n              \"src\": \"187:79:0\"\n            },\n            \"returnParameters\": {\n              \"id\": 23,\n              \"nodeType\": \"ParameterList\",\n              \"parameters\": [],\n              \"src\": \"274:0:0\"\n            },\n            \"scope\": 60,\n            \"src\": \"168:355:0\",\n            \"stateMutability\": \"nonpayable\",\n            \"superFunction\": null,\n            \"visibility\": \"public\"\n          }\n        ],\n        \"scope\": 61,\n        \"src\": \"2:524:0\"\n      }\n    ],\n    \"src\": \"2:524:0\"\n  },\n  \"legacyAST\": {\n    \"absolutePath\": \"/C/git/SoliditySamples/exeth/events/contracts/Emitter.sol\",\n    \"exportedSymbols\": {\n      \"Emitter\": [\n        60\n      ]\n    },\n    \"id\": 61,\n    \"nodeType\": \"SourceUnit\",\n    \"nodes\": [\n      {\n        \"baseContracts\": [],\n        \"contractDependencies\": [],\n        \"contractKind\": \"contract\",\n        \"documentation\": null,\n        \"fullyImplemented\": true,\n        \"id\": 60,\n        \"linearizedBaseContracts\": [\n          60\n        ],\n        \"name\": \"Emitter\",\n        \"nodeType\": \"ContractDefinition\",\n        \"nodes\": [\n          {\n            \"anonymous\": false,\n            \"documentation\": null,\n            \"id\": 2,\n            \"name\": \"BeginEvents\",\n            \"nodeType\": \"EventDefinition\",\n            \"parameters\": {\n              \"id\": 1,\n              \"nodeType\": \"ParameterList\",\n              \"parameters\": [],\n              \"src\": \"43:2:0\"\n            },\n            \"src\": \"26:20:0\"\n          },\n          {\n            \"anonymous\": false,\n            \"documentation\": null,\n            \"id\": 10,\n            \"name\": \"Transfer\",\n            \"nodeType\": \"EventDefinition\",\n            \"parameters\": {\n              \"id\": 9,\n              \"nodeType\": \"ParameterList\",\n              \"parameters\": [\n                {\n                  \"constant\": false,\n                  \"id\": 4,\n                  \"indexed\": true,\n                  \"name\": \"receiver\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 10,\n                  \"src\": \"67:24:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"default\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_address\",\n                    \"typeString\": \"address\"\n                  },\n                  \"typeName\": {\n                    \"id\": 3,\n                    \"name\": \"address\",\n                    \"nodeType\": \"ElementaryTypeName\",\n                    \"src\": \"67:7:0\",\n                    \"stateMutability\": \"nonpayable\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_address\",\n                      \"typeString\": \"address\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                },\n                {\n                  \"constant\": false,\n                  \"id\": 6,\n                  \"indexed\": true,\n                  \"name\": \"token\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 10,\n                  \"src\": \"93:21:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"default\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_address\",\n                    \"typeString\": \"address\"\n                  },\n                  \"typeName\": {\n                    \"id\": 5,\n                    \"name\": \"address\",\n                    \"nodeType\": \"ElementaryTypeName\",\n                    \"src\": \"93:7:0\",\n                    \"stateMutability\": \"nonpayable\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_address\",\n                      \"typeString\": \"address\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                },\n                {\n                  \"constant\": false,\n                  \"id\": 8,\n                  \"indexed\": false,\n                  \"name\": \"amount\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 10,\n                  \"src\": \"116:14:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"default\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_uint256\",\n                    \"typeString\": \"uint256\"\n                  },\n                  \"typeName\": {\n                    \"id\": 7,\n                    \"name\": \"uint256\",\n                    \"nodeType\": \"ElementaryTypeName\",\n                    \"src\": \"116:7:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_uint256\",\n                      \"typeString\": \"uint256\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                }\n              ],\n              \"src\": \"66:65:0\"\n            },\n            \"src\": \"52:80:0\"\n          },\n          {\n            \"anonymous\": false,\n            \"documentation\": null,\n            \"id\": 12,\n            \"name\": \"EndEvents\",\n            \"nodeType\": \"EventDefinition\",\n            \"parameters\": {\n              \"id\": 11,\n              \"nodeType\": \"ParameterList\",\n              \"parameters\": [],\n              \"src\": \"153:2:0\"\n            },\n            \"src\": \"138:18:0\"\n          },\n          {\n            \"body\": {\n              \"id\": 58,\n              \"nodeType\": \"Block\",\n              \"src\": \"274:249:0\",\n              \"statements\": [\n                {\n                  \"assignments\": [\n                    25\n                  ],\n                  \"declarations\": [\n                    {\n                      \"constant\": false,\n                      \"id\": 25,\n                      \"name\": \"nevents\",\n                      \"nodeType\": \"VariableDeclaration\",\n                      \"scope\": 58,\n                      \"src\": \"285:12:0\",\n                      \"stateVariable\": false,\n                      \"storageLocation\": \"default\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_uint256\",\n                        \"typeString\": \"uint256\"\n                      },\n                      \"typeName\": {\n                        \"id\": 24,\n                        \"name\": \"uint\",\n                        \"nodeType\": \"ElementaryTypeName\",\n                        \"src\": \"285:4:0\",\n                        \"typeDescriptions\": {\n                          \"typeIdentifier\": \"t_uint256\",\n                          \"typeString\": \"uint256\"\n                        }\n                      },\n                      \"value\": null,\n                      \"visibility\": \"internal\"\n                    }\n                  ],\n                  \"id\": 28,\n                  \"initialValue\": {\n                    \"argumentTypes\": null,\n                    \"expression\": {\n                      \"argumentTypes\": null,\n                      \"id\": 26,\n                      \"name\": \"receivers\",\n                      \"nodeType\": \"Identifier\",\n                      \"overloadedDeclarations\": [],\n                      \"referencedDeclaration\": 15,\n                      \"src\": \"300:9:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_array$_t_address_$dyn_memory_ptr\",\n                        \"typeString\": \"address[] memory\"\n                      }\n                    },\n                    \"id\": 27,\n                    \"isConstant\": false,\n                    \"isLValue\": false,\n                    \"isPure\": false,\n                    \"lValueRequested\": false,\n                    \"memberName\": \"length\",\n                    \"nodeType\": \"MemberAccess\",\n                    \"referencedDeclaration\": null,\n                    \"src\": \"300:16:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_uint256\",\n                      \"typeString\": \"uint256\"\n                    }\n                  },\n                  \"nodeType\": \"VariableDeclarationStatement\",\n                  \"src\": \"285:31:0\"\n                },\n                {\n                  \"eventCall\": {\n                    \"argumentTypes\": null,\n                    \"arguments\": [],\n                    \"expression\": {\n                      \"argumentTypes\": [],\n                      \"id\": 29,\n                      \"name\": \"BeginEvents\",\n                      \"nodeType\": \"Identifier\",\n                      \"overloadedDeclarations\": [],\n                      \"referencedDeclaration\": 2,\n                      \"src\": \"342:11:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_function_event_nonpayable$__$returns$__$\",\n                        \"typeString\": \"function ()\"\n                      }\n                    },\n                    \"id\": 30,\n                    \"isConstant\": false,\n                    \"isLValue\": false,\n                    \"isPure\": false,\n                    \"kind\": \"functionCall\",\n                    \"lValueRequested\": false,\n                    \"names\": [],\n                    \"nodeType\": \"FunctionCall\",\n                    \"src\": \"342:13:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_tuple$__$\",\n                      \"typeString\": \"tuple()\"\n                    }\n                  },\n                  \"id\": 31,\n                  \"nodeType\": \"EmitStatement\",\n                  \"src\": \"337:18:0\"\n                },\n                {\n                  \"body\": {\n                    \"eventCall\": {\n                      \"argumentTypes\": null,\n                      \"arguments\": [\n                        {\n                          \"argumentTypes\": null,\n                          \"baseExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 43,\n                            \"name\": \"receivers\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 15,\n                            \"src\": \"438:9:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_array$_t_address_$dyn_memory_ptr\",\n                              \"typeString\": \"address[] memory\"\n                            }\n                          },\n                          \"id\": 45,\n                          \"indexExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 44,\n                            \"name\": \"k\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 33,\n                            \"src\": \"448:1:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_uint256\",\n                              \"typeString\": \"uint256\"\n                            }\n                          },\n                          \"isConstant\": false,\n                          \"isLValue\": true,\n                          \"isPure\": false,\n                          \"lValueRequested\": false,\n                          \"nodeType\": \"IndexAccess\",\n                          \"src\": \"438:12:0\",\n                          \"typeDescriptions\": {\n                            \"typeIdentifier\": \"t_address\",\n                            \"typeString\": \"address\"\n                          }\n                        },\n                        {\n                          \"argumentTypes\": null,\n                          \"baseExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 46,\n                            \"name\": \"tokens\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 18,\n                            \"src\": \"452:6:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_array$_t_address_$dyn_memory_ptr\",\n                              \"typeString\": \"address[] memory\"\n                            }\n                          },\n                          \"id\": 48,\n                          \"indexExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 47,\n                            \"name\": \"k\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 33,\n                            \"src\": \"459:1:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_uint256\",\n                              \"typeString\": \"uint256\"\n                            }\n                          },\n                          \"isConstant\": false,\n                          \"isLValue\": true,\n                          \"isPure\": false,\n                          \"lValueRequested\": false,\n                          \"nodeType\": \"IndexAccess\",\n                          \"src\": \"452:9:0\",\n                          \"typeDescriptions\": {\n                            \"typeIdentifier\": \"t_address\",\n                            \"typeString\": \"address\"\n                          }\n                        },\n                        {\n                          \"argumentTypes\": null,\n                          \"baseExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 49,\n                            \"name\": \"amounts\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 21,\n                            \"src\": \"463:7:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_array$_t_uint256_$dyn_memory_ptr\",\n                              \"typeString\": \"uint256[] memory\"\n                            }\n                          },\n                          \"id\": 51,\n                          \"indexExpression\": {\n                            \"argumentTypes\": null,\n                            \"id\": 50,\n                            \"name\": \"k\",\n                            \"nodeType\": \"Identifier\",\n                            \"overloadedDeclarations\": [],\n                            \"referencedDeclaration\": 33,\n                            \"src\": \"471:1:0\",\n                            \"typeDescriptions\": {\n                              \"typeIdentifier\": \"t_uint256\",\n                              \"typeString\": \"uint256\"\n                            }\n                          },\n                          \"isConstant\": false,\n                          \"isLValue\": true,\n                          \"isPure\": false,\n                          \"lValueRequested\": false,\n                          \"nodeType\": \"IndexAccess\",\n                          \"src\": \"463:10:0\",\n                          \"typeDescriptions\": {\n                            \"typeIdentifier\": \"t_uint256\",\n                            \"typeString\": \"uint256\"\n                          }\n                        }\n                      ],\n                      \"expression\": {\n                        \"argumentTypes\": [\n                          {\n                            \"typeIdentifier\": \"t_address\",\n                            \"typeString\": \"address\"\n                          },\n                          {\n                            \"typeIdentifier\": \"t_address\",\n                            \"typeString\": \"address\"\n                          },\n                          {\n                            \"typeIdentifier\": \"t_uint256\",\n                            \"typeString\": \"uint256\"\n                          }\n                        ],\n                        \"id\": 42,\n                        \"name\": \"Transfer\",\n                        \"nodeType\": \"Identifier\",\n                        \"overloadedDeclarations\": [],\n                        \"referencedDeclaration\": 10,\n                        \"src\": \"429:8:0\",\n                        \"typeDescriptions\": {\n                          \"typeIdentifier\": \"t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$\",\n                          \"typeString\": \"function (address,address,uint256)\"\n                        }\n                      },\n                      \"id\": 52,\n                      \"isConstant\": false,\n                      \"isLValue\": false,\n                      \"isPure\": false,\n                      \"kind\": \"functionCall\",\n                      \"lValueRequested\": false,\n                      \"names\": [],\n                      \"nodeType\": \"FunctionCall\",\n                      \"src\": \"429:45:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_tuple$__$\",\n                        \"typeString\": \"tuple()\"\n                      }\n                    },\n                    \"id\": 53,\n                    \"nodeType\": \"EmitStatement\",\n                    \"src\": \"424:50:0\"\n                  },\n                  \"condition\": {\n                    \"argumentTypes\": null,\n                    \"commonType\": {\n                      \"typeIdentifier\": \"t_uint256\",\n                      \"typeString\": \"uint256\"\n                    },\n                    \"id\": 38,\n                    \"isConstant\": false,\n                    \"isLValue\": false,\n                    \"isPure\": false,\n                    \"lValueRequested\": false,\n                    \"leftExpression\": {\n                      \"argumentTypes\": null,\n                      \"id\": 36,\n                      \"name\": \"k\",\n                      \"nodeType\": \"Identifier\",\n                      \"overloadedDeclarations\": [],\n                      \"referencedDeclaration\": 33,\n                      \"src\": \"393:1:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_uint256\",\n                        \"typeString\": \"uint256\"\n                      }\n                    },\n                    \"nodeType\": \"BinaryOperation\",\n                    \"operator\": \"<\",\n                    \"rightExpression\": {\n                      \"argumentTypes\": null,\n                      \"id\": 37,\n                      \"name\": \"nevents\",\n                      \"nodeType\": \"Identifier\",\n                      \"overloadedDeclarations\": [],\n                      \"referencedDeclaration\": 25,\n                      \"src\": \"397:7:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_uint256\",\n                        \"typeString\": \"uint256\"\n                      }\n                    },\n                    \"src\": \"393:11:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_bool\",\n                      \"typeString\": \"bool\"\n                    }\n                  },\n                  \"id\": 54,\n                  \"initializationExpression\": {\n                    \"assignments\": [\n                      33\n                    ],\n                    \"declarations\": [\n                      {\n                        \"constant\": false,\n                        \"id\": 33,\n                        \"name\": \"k\",\n                        \"nodeType\": \"VariableDeclaration\",\n                        \"scope\": 54,\n                        \"src\": \"381:6:0\",\n                        \"stateVariable\": false,\n                        \"storageLocation\": \"default\",\n                        \"typeDescriptions\": {\n                          \"typeIdentifier\": \"t_uint256\",\n                          \"typeString\": \"uint256\"\n                        },\n                        \"typeName\": {\n                          \"id\": 32,\n                          \"name\": \"uint\",\n                          \"nodeType\": \"ElementaryTypeName\",\n                          \"src\": \"381:4:0\",\n                          \"typeDescriptions\": {\n                            \"typeIdentifier\": \"t_uint256\",\n                            \"typeString\": \"uint256\"\n                          }\n                        },\n                        \"value\": null,\n                        \"visibility\": \"internal\"\n                      }\n                    ],\n                    \"id\": 35,\n                    \"initialValue\": {\n                      \"argumentTypes\": null,\n                      \"hexValue\": \"30\",\n                      \"id\": 34,\n                      \"isConstant\": false,\n                      \"isLValue\": false,\n                      \"isPure\": true,\n                      \"kind\": \"number\",\n                      \"lValueRequested\": false,\n                      \"nodeType\": \"Literal\",\n                      \"src\": \"390:1:0\",\n                      \"subdenomination\": null,\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_rational_0_by_1\",\n                        \"typeString\": \"int_const 0\"\n                      },\n                      \"value\": \"0\"\n                    },\n                    \"nodeType\": \"VariableDeclarationStatement\",\n                    \"src\": \"381:10:0\"\n                  },\n                  \"loopExpression\": {\n                    \"expression\": {\n                      \"argumentTypes\": null,\n                      \"id\": 40,\n                      \"isConstant\": false,\n                      \"isLValue\": false,\n                      \"isPure\": false,\n                      \"lValueRequested\": false,\n                      \"nodeType\": \"UnaryOperation\",\n                      \"operator\": \"++\",\n                      \"prefix\": false,\n                      \"src\": \"406:3:0\",\n                      \"subExpression\": {\n                        \"argumentTypes\": null,\n                        \"id\": 39,\n                        \"name\": \"k\",\n                        \"nodeType\": \"Identifier\",\n                        \"overloadedDeclarations\": [],\n                        \"referencedDeclaration\": 33,\n                        \"src\": \"406:1:0\",\n                        \"typeDescriptions\": {\n                          \"typeIdentifier\": \"t_uint256\",\n                          \"typeString\": \"uint256\"\n                        }\n                      },\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_uint256\",\n                        \"typeString\": \"uint256\"\n                      }\n                    },\n                    \"id\": 41,\n                    \"nodeType\": \"ExpressionStatement\",\n                    \"src\": \"406:3:0\"\n                  },\n                  \"nodeType\": \"ForStatement\",\n                  \"src\": \"376:98:0\"\n                },\n                {\n                  \"eventCall\": {\n                    \"argumentTypes\": null,\n                    \"arguments\": [],\n                    \"expression\": {\n                      \"argumentTypes\": [],\n                      \"id\": 55,\n                      \"name\": \"EndEvents\",\n                      \"nodeType\": \"Identifier\",\n                      \"overloadedDeclarations\": [],\n                      \"referencedDeclaration\": 12,\n                      \"src\": \"504:9:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_function_event_nonpayable$__$returns$__$\",\n                        \"typeString\": \"function ()\"\n                      }\n                    },\n                    \"id\": 56,\n                    \"isConstant\": false,\n                    \"isLValue\": false,\n                    \"isPure\": false,\n                    \"kind\": \"functionCall\",\n                    \"lValueRequested\": false,\n                    \"names\": [],\n                    \"nodeType\": \"FunctionCall\",\n                    \"src\": \"504:11:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_tuple$__$\",\n                      \"typeString\": \"tuple()\"\n                    }\n                  },\n                  \"id\": 57,\n                  \"nodeType\": \"EmitStatement\",\n                  \"src\": \"499:16:0\"\n                }\n              ]\n            },\n            \"documentation\": null,\n            \"id\": 59,\n            \"implemented\": true,\n            \"kind\": \"function\",\n            \"modifiers\": [],\n            \"name\": \"emitEvents\",\n            \"nodeType\": \"FunctionDefinition\",\n            \"parameters\": {\n              \"id\": 22,\n              \"nodeType\": \"ParameterList\",\n              \"parameters\": [\n                {\n                  \"constant\": false,\n                  \"id\": 15,\n                  \"name\": \"receivers\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 59,\n                  \"src\": \"188:26:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"memory\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_array$_t_address_$dyn_memory_ptr\",\n                    \"typeString\": \"address[]\"\n                  },\n                  \"typeName\": {\n                    \"baseType\": {\n                      \"id\": 13,\n                      \"name\": \"address\",\n                      \"nodeType\": \"ElementaryTypeName\",\n                      \"src\": \"188:7:0\",\n                      \"stateMutability\": \"nonpayable\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_address\",\n                        \"typeString\": \"address\"\n                      }\n                    },\n                    \"id\": 14,\n                    \"length\": null,\n                    \"nodeType\": \"ArrayTypeName\",\n                    \"src\": \"188:9:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_array$_t_address_$dyn_storage_ptr\",\n                      \"typeString\": \"address[]\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                },\n                {\n                  \"constant\": false,\n                  \"id\": 18,\n                  \"name\": \"tokens\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 59,\n                  \"src\": \"216:23:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"memory\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_array$_t_address_$dyn_memory_ptr\",\n                    \"typeString\": \"address[]\"\n                  },\n                  \"typeName\": {\n                    \"baseType\": {\n                      \"id\": 16,\n                      \"name\": \"address\",\n                      \"nodeType\": \"ElementaryTypeName\",\n                      \"src\": \"216:7:0\",\n                      \"stateMutability\": \"nonpayable\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_address\",\n                        \"typeString\": \"address\"\n                      }\n                    },\n                    \"id\": 17,\n                    \"length\": null,\n                    \"nodeType\": \"ArrayTypeName\",\n                    \"src\": \"216:9:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_array$_t_address_$dyn_storage_ptr\",\n                      \"typeString\": \"address[]\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                },\n                {\n                  \"constant\": false,\n                  \"id\": 21,\n                  \"name\": \"amounts\",\n                  \"nodeType\": \"VariableDeclaration\",\n                  \"scope\": 59,\n                  \"src\": \"241:24:0\",\n                  \"stateVariable\": false,\n                  \"storageLocation\": \"memory\",\n                  \"typeDescriptions\": {\n                    \"typeIdentifier\": \"t_array$_t_uint256_$dyn_memory_ptr\",\n                    \"typeString\": \"uint256[]\"\n                  },\n                  \"typeName\": {\n                    \"baseType\": {\n                      \"id\": 19,\n                      \"name\": \"uint256\",\n                      \"nodeType\": \"ElementaryTypeName\",\n                      \"src\": \"241:7:0\",\n                      \"typeDescriptions\": {\n                        \"typeIdentifier\": \"t_uint256\",\n                        \"typeString\": \"uint256\"\n                      }\n                    },\n                    \"id\": 20,\n                    \"length\": null,\n                    \"nodeType\": \"ArrayTypeName\",\n                    \"src\": \"241:9:0\",\n                    \"typeDescriptions\": {\n                      \"typeIdentifier\": \"t_array$_t_uint256_$dyn_storage_ptr\",\n                      \"typeString\": \"uint256[]\"\n                    }\n                  },\n                  \"value\": null,\n                  \"visibility\": \"internal\"\n                }\n              ],\n              \"src\": \"187:79:0\"\n            },\n            \"returnParameters\": {\n              \"id\": 23,\n              \"nodeType\": \"ParameterList\",\n              \"parameters\": [],\n              \"src\": \"274:0:0\"\n            },\n            \"scope\": 60,\n            \"src\": \"168:355:0\",\n            \"stateMutability\": \"nonpayable\",\n            \"superFunction\": null,\n            \"visibility\": \"public\"\n          }\n        ],\n        \"scope\": 61,\n        \"src\": \"2:524:0\"\n      }\n    ],\n    \"src\": \"2:524:0\"\n  },\n  \"compiler\": {\n    \"name\": \"solc\",\n    \"version\": \"0.5.0+commit.1d4f565a.Emscripten.clang\"\n  },\n  \"networks\": {},\n  \"schemaVersion\": \"3.0.8\",\n  \"updatedAt\": \"2019-08-29T15:25:05.458Z\",\n  \"devdoc\": {\n    \"methods\": {}\n  },\n  \"userdoc\": {\n    \"methods\": {}\n  }\n}"
  },
  {
    "path": "exeth/events/contracts/Emitter.sol",
    "content": "\ncontract Emitter {\n    event BeginEvents();\n    event Cross(address indexed token, address indexed receiver, uint256 amount);\n    event EndEvents();\n    \n    function emitEvents(address[] memory receivers, address[] memory tokens, uint256[] memory amounts) public {\n        uint nevents = receivers.length;\n        \n        emit BeginEvents();\n        \n        for (uint k = 0; k < nevents; k++)\n            emit Transfer(receivers[k], tokens[k], amounts[k]);\n            \n        emit EndEvents();\n    }\n}"
  },
  {
    "path": "exeth/events/truffle-config.js",
    "content": "/*\n * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a \n * function when declaring them. Failure to do so will cause commands to hang. ex:\n * ```\n * mainnet: {\n *     provider: function() { \n *       return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>') \n *     },\n *     network_id: '1',\n *     gas: 4500000,\n *     gasPrice: 10000000000,\n *   },\n */\n\nmodule.exports = {\n  // See <http://truffleframework.com/docs/advanced/configuration>\n  // to customize your Truffle configuration!\n  networks: {\n    development: {\n      host: \"127.0.0.1\",\n      port: 8545,\n      gasPrice: 0,\n      gas: 50000000,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};\n"
  },
  {
    "path": "exeth/federation/contracts/federation.sol",
    "content": "\r\ncontract Federation {\r\n    address[] federators;\r\n    \r\n    event NewFederator(address federator);\r\n\t\r\n    constructor(address[] memory feds) public {\r\n        federators = feds;\r\n    }\r\n\t\r\n\tfunction federationSize() public view returns (uint) {\r\n\t\treturn federators.length;\r\n\t}\r\n\t\r\n\tfunction isFederator(address addr) public view returns(bool) {\r\n\t\tfor (uint16 k; k < federators.length; k++)\r\n\t\t\tif (addr == federators[k])\r\n\t\t\t\treturn true;\r\n\t\t\t\t\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\tfunction addFederator(address addr) public returns (bool) {\r\n\t\tif (isFederator(addr))\r\n\t\t\treturn false;\r\n\t\t\t\r\n\t\tfederators.push(addr);\r\n\t\t\r\n        emit NewFederator(addr);\r\n        \r\n\t\treturn true;\r\n\t}\r\n}\r\n\r\n"
  },
  {
    "path": "exeth/federation/federation.eth",
    "content": "\r\n# retrieve accounts\r\n\r\nmessage \"retrieving accounts...\"\r\naccounts\r\n\r\n# compile contract\r\n# (contracts variable has the compiled contract data)\r\n\r\nmessage \"compiling contract...\"\r\ncompile \"./contracts/federation.sol\"\r\n\r\nmessage \"contract function hashes\"\r\ndump contracts.Federation.evm.methodIdentifiers\r\n\r\n# deploy contract with three accounts\r\n\r\nmessage \"deploy contract with three federators\"\r\ndeploy Federation federation [accounts[0],accounts[1],accounts[2]]\r\n\r\n# federation size\r\n\r\ncall federation federationSize()\r\n\r\nassert result == 3\r\n\r\nmessage \"federation size\" result\r\n\r\n# check federators\r\n\r\nset n 0\r\n\r\nwhile n < accounts.length\r\n\tcall federation isFederator(address) accounts[n]\r\n\r\n\tassert result === (n < 3)\r\n\t\r\n\tset negation result == 0 ? \" not \" : \" \"\r\n\t\r\n\tmessage accounts[n] (\"is\" + negation + \"a federator\")\r\n\r\n\tset n n + 1\r\nend\r\n\r\n# add an account that is a federator\r\n\r\nmessage \"adding an existing federator\"\r\ninvoke federation addFederator(address) accounts[0]\r\n\r\ncall federation federationSize()\r\nassert result == 3\r\n\r\n# add a new federator\r\n\r\nmessage \"adding a new federator\"\r\ninvoke federation addFederator(address) accounts[3]\r\n\r\ncall federation federationSize()\r\nassert result == 4\r\n\r\nmessage \"done\"\r\n\r\n"
  },
  {
    "path": "exeth/simple/.gitignore",
    "content": ""
  },
  {
    "path": "exeth/simple/accounts.eth",
    "content": "\r\n# retrieve accounts from default host (http://localhost:8545)\r\naccounts\r\n\r\n# dump the accounts addresses\r\ndump accounts\r\n\r\nassert accounts\r\nassert accounts.length\r\n\r\n"
  },
  {
    "path": "exeth/simple/balances.eth",
    "content": "\r\n# retrieve accounts from host\r\n\r\naccounts\r\n\r\n# retrieve balances\r\n\r\nset n 0\r\n\r\nwhile n < accounts.length\r\n\tmessage \"account\" accounts[n]\r\n\tbalance accounts[n]\r\n\tmessage \"balance\" parseInt(result)\r\n\tset n n + 1\r\nend\r\n\r\n\r\n"
  },
  {
    "path": "exeth/simple/blocks.eth",
    "content": "\r\n# get the best block number\r\n\r\nblocknumber\r\n\r\nset bbnumber result\r\n\r\nmessage \"best block number\" bbnumber\r\n\r\n# retrieve genesis block\r\nblock 0\r\ndump result\r\n\r\n# retrieve best block\r\nblock bbnumber\r\ndump result\r\n\r\n"
  },
  {
    "path": "exeth/simple/compile.eth",
    "content": "\r\nmessage \"compiling counter.sol\"\r\ncompile \"./contracts/counter.sol\"\r\nmessage \"counter.sol compiled\"\r\n\r\ndump Object.keys(contracts.Counter)\r\ndump contracts.Counter.evm.assembly\r\ndump contracts.Counter.evm.methodIdentifiers\r\n\r\n"
  },
  {
    "path": "exeth/simple/contracts/Methods.sol",
    "content": "\ncontract Methods {\n    uint counter;\n    \n    function add(uint x) public {\n        addToCounter(x);\n        counter++;\n    }\n    \n    function addToCounter(uint x) private {\n        x++;\n        counter += x;\n    }\n}\n\n"
  },
  {
    "path": "exeth/simple/contracts/counter.asm",
    "content": "\r\n======= counter.sol:Counter =======\r\nEVM assembly:\r\n    /* \"counter.sol\":63:399  contract Counter {\r... */\r\n  mstore(0x40, 0x60)\r\n    /* \"counter.sol\":109:165  function Counter() public {\r... */\r\n  jumpi(tag_1, iszero(callvalue))\r\n  0x0\r\n  dup1\r\n  revert\r\ntag_1:\r\ntag_2:\r\n    /* \"counter.sol\":156:157  1 */\r\n  0x1\r\n    /* \"counter.sol\":146:153  counter */\r\n  0x0\r\n    /* \"counter.sol\":146:157  counter = 1 */\r\n  dup2\r\n  swap1\r\n  sstore\r\n  pop\r\n    /* \"counter.sol\":109:165  function Counter() public {\r... */\r\ntag_3:\r\n    /* \"counter.sol\":63:399  contract Counter {\r... */\r\ntag_4:\r\n  dataSize(sub_0)\r\n  dup1\r\n  dataOffset(sub_0)\r\n  0x0\r\n  codecopy\r\n  0x0\r\n  return\r\nstop\r\n\r\nsub_0: assembly {\r\n        /* \"counter.sol\":63:399  contract Counter {\r... */\r\n      mstore(0x40, 0x60)\r\n      calldataload(0x0)\r\n      0x100000000000000000000000000000000000000000000000000000000\r\n      swap1\r\n      div\r\n      0xffffffff\r\n      and\r\n      dup1\r\n      0x1003e2d2\r\n      eq\r\n      tag_2\r\n      jumpi\r\n      dup1\r\n      0x8ada066e\r\n      eq\r\n      tag_3\r\n      jumpi\r\n      dup1\r\n      0xd09de08a\r\n      eq\r\n      tag_4\r\n      jumpi\r\n    tag_1:\r\n      0x0\r\n      dup1\r\n      revert\r\n        /* \"counter.sol\":242:301  function add(uint v) public {\r... */\r\n    tag_2:\r\n      jumpi(tag_5, iszero(callvalue))\r\n      0x0\r\n      dup1\r\n      revert\r\n    tag_5:\r\n      tag_6\r\n      0x4\r\n      dup1\r\n      dup1\r\n      calldataload\r\n      swap1\r\n      0x20\r\n      add\r\n      swap1\r\n      swap2\r\n      swap1\r\n      pop\r\n      pop\r\n      jump(tag_7)\r\n    tag_6:\r\n      stop\r\n        /* \"counter.sol\":310:396  function getCounter() public constant returns (uint) {\r... */\r\n    tag_3:\r\n      jumpi(tag_8, iszero(callvalue))\r\n      0x0\r\n      dup1\r\n      revert\r\n    tag_8:\r\n      tag_9\r\n      jump(tag_10)\r\n    tag_9:\r\n      mload(0x40)\r\n      dup1\r\n      dup3\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap2\r\n      pop\r\n      pop\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      return\r\n        /* \"counter.sol\":177:233  function increment() public {\r... */\r\n    tag_4:\r\n      jumpi(tag_11, iszero(callvalue))\r\n      0x0\r\n      dup1\r\n      revert\r\n    tag_11:\r\n      tag_12\r\n      jump(tag_13)\r\n    tag_12:\r\n      stop\r\n        /* \"counter.sol\":242:301  function add(uint v) public {\r... */\r\n    tag_7:\r\n        /* \"counter.sol\":292:293  v */\r\n      dup1\r\n        /* \"counter.sol\":281:288  counter */\r\n      0x0\r\n      dup1\r\n        /* \"counter.sol\":281:293  counter += v */\r\n      dup3\r\n      dup3\r\n      sload\r\n      add\r\n      swap3\r\n      pop\r\n      pop\r\n      dup2\r\n      swap1\r\n      sstore\r\n      pop\r\n        /* \"counter.sol\":242:301  function add(uint v) public {\r... */\r\n    tag_14:\r\n      pop\r\n      jump\t// out\r\n        /* \"counter.sol\":310:396  function getCounter() public constant returns (uint) {\r... */\r\n    tag_10:\r\n        /* \"counter.sol\":357:361  uint */\r\n      0x0\r\n        /* \"counter.sol\":381:388  counter */\r\n      dup1\r\n      sload\r\n        /* \"counter.sol\":374:388  return counter */\r\n      swap1\r\n      pop\r\n        /* \"counter.sol\":310:396  function getCounter() public constant returns (uint) {\r... */\r\n    tag_15:\r\n      swap1\r\n      jump\t// out\r\n        /* \"counter.sol\":177:233  function increment() public {\r... */\r\n    tag_13:\r\n        /* \"counter.sol\":216:223  counter */\r\n      0x0\r\n      dup1\r\n        /* \"counter.sol\":216:225  counter++ */\r\n      dup2\r\n      sload\r\n      dup1\r\n      swap3\r\n      swap2\r\n      swap1\r\n      0x1\r\n      add\r\n      swap2\r\n      swap1\r\n      pop\r\n      sstore\r\n      pop\r\n        /* \"counter.sol\":177:233  function increment() public {\r... */\r\n    tag_16:\r\n      jump\t// out\r\n\r\n    auxdata: 0xa165627a7a723058209c14b0491dc15ac395ea1519522f3b1b4162ad8e2a8a0f4e9b43e8b2963c528e0029\r\n}\r\n"
  },
  {
    "path": "exeth/simple/contracts/counter.sol",
    "content": "\r\npragma solidity >=0.4.21 <0.6.0;\r\n\r\n// Simple counter contract\r\n\r\ncontract Counter {\r\n    uint counter;\r\n\t\r\n    // function Counter() public {\r\n    constructor() public {\r\n        counter = 1;\r\n    }\r\n    \r\n    function increment() public {\r\n        counter++;\r\n    }\r\n\t\r\n    function add(uint v) public {\r\n        counter += v;\r\n    }\r\n\t\r\n    function getCounter() public view returns (uint) {\r\n        return counter;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "exeth/simple/contracts/creator.sol",
    "content": "\r\ncontract Counter {\r\n    uint x;\r\n\r\n    event Incremented(bool indexed odd, uint x);\r\n\tevent Created(uint x);\r\n\tevent Valued(uint x);\r\n\t\r\n    constructor() public {\r\n        x = 70;\r\n\t\temit Created(x);\r\n    }\r\n    \r\n    function increment() public {\r\n        ++x;\r\n        emit Incremented(x % 2 == 1, x);\r\n    }\r\n\t\r\n    function getValue() public view returns (uint) {\r\n\t\t// emit Valued(x);\r\n        return x;\r\n    }\r\n}\r\n\r\ncontract Creator {\r\n\tCounter public counter;\r\n\tevent CounterCreated(uint);\r\n\t\r\n\tconstructor() public {\r\n\t\tcounter = new Counter();\r\n\t\temit CounterCreated(counter.getValue());\r\n\t}\r\n}\r\n\r\n"
  },
  {
    "path": "exeth/simple/contracts/empty.asm",
    "content": "\r\n======= empty.sol:Empty =======\r\nEVM assembly:\r\n    /* \"empty.sol\":59:78  contract Empty {\r... */\r\n  mstore(0x40, 0x60)\r\n  jumpi(tag_1, iszero(callvalue))\r\n  0x0\r\n  dup1\r\n  revert\r\ntag_1:\r\ntag_2:\r\n  dataSize(sub_0)\r\n  dup1\r\n  dataOffset(sub_0)\r\n  0x0\r\n  codecopy\r\n  0x0\r\n  return\r\nstop\r\n\r\nsub_0: assembly {\r\n        /* \"empty.sol\":59:78  contract Empty {\r... */\r\n      mstore(0x40, 0x60)\r\n    tag_1:\r\n      0x0\r\n      dup1\r\n      revert\r\n\r\n    auxdata: 0xa165627a7a7230582046b5464930e5eb5db6027b5aaae7f9140430cdd322d5eb42de2e546521573bd90029\r\n}\r\n"
  },
  {
    "path": "exeth/simple/contracts/empty.sol",
    "content": "// pragma solidity ^0.4.18;\r\n\r\n// Simple empty contract\r\n\r\ncontract Empty {\r\n}\r\n\r\n"
  },
  {
    "path": "exeth/simple/contracts/foobar.sol",
    "content": "\r\n// Simple inheritance\r\n\r\ncontract Foo {\r\n}\r\n\r\ncontract Bar is Foo {\r\n}\r\n"
  },
  {
    "path": "exeth/simple/contracts/greeter.sol",
    "content": "\r\ncontract Greeter {\r\n    string public message;\r\n\r\n    constructor() public {\r\n        message = \"Hello, Contract\";\r\n    }\r\n    \r\n    function setMessage(string memory msg) public {\r\n        message = msg;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "exeth/simple/contracts/message.sol",
    "content": "\r\ncontract Message {\r\n    string public message;\r\n\r\n    constructor(string memory _message) public {\r\n        message = _message;\r\n    }\r\n    \r\n    function setMessage(string memory _message) public {\r\n        message = _message;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "exeth/simple/contracts/selector.sol",
    "content": "\r\ncontract Selector {\r\n  function f() returns (bytes4) {\r\n    return this.f.selector;\r\n  }\r\n}"
  },
  {
    "path": "exeth/simple/contracts/throw.sol",
    "content": "\r\ncontract Throw {\r\n    modifier sentValue() {\r\n        require(msg.value > 0);\r\n        _;\r\n    }\r\n    \r\n\tconstructor() public payable sentValue {\r\n\t\t// require(msg.value > 0);\r\n        //if (msg.value == 0)\r\n        //    throw;\r\n\t}\r\n    \r\n    function otherFunction() public payable sentValue {\r\n\t\t// require(msg.value > 0);\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "exeth/simple/contracts/token.asm",
    "content": "\r\n======= token.sol:Token =======\r\nEVM assembly:\r\n    /* \"token.sol\":31:697  contract Token { \r... */\r\n  mstore(0x40, 0x60)\r\n    /* \"token.sol\":262:333  function Token() public {\r... */\r\n  jumpi(tag_1, iszero(callvalue))\r\n  0x0\r\n  dup1\r\n  revert\r\ntag_1:\r\ntag_2:\r\n    /* \"token.sol\":320:325  10000 */\r\n  0x2710\r\n    /* \"token.sol\":297:305  balances */\r\n  0x0\r\n    /* \"token.sol\":297:317  balances[msg.sender] */\r\n  dup1\r\n    /* \"token.sol\":306:316  msg.sender */\r\n  caller\r\n    /* \"token.sol\":297:317  balances[msg.sender] */\r\n  0xffffffffffffffffffffffffffffffffffffffff\r\n  and\r\n  0xffffffffffffffffffffffffffffffffffffffff\r\n  and\r\n  dup2\r\n  mstore\r\n  0x20\r\n  add\r\n  swap1\r\n  dup2\r\n  mstore\r\n  0x20\r\n  add\r\n  0x0\r\n  keccak256\r\n    /* \"token.sol\":297:325  balances[msg.sender] = 10000 */\r\n  dup2\r\n  swap1\r\n  sstore\r\n  pop\r\n    /* \"token.sol\":262:333  function Token() public {\r... */\r\ntag_3:\r\n    /* \"token.sol\":31:697  contract Token { \r... */\r\ntag_4:\r\n  dataSize(sub_0)\r\n  dup1\r\n  dataOffset(sub_0)\r\n  0x0\r\n  codecopy\r\n  0x0\r\n  return\r\nstop\r\n\r\nsub_0: assembly {\r\n        /* \"token.sol\":31:697  contract Token { \r... */\r\n      mstore(0x40, 0x60)\r\n      calldataload(0x0)\r\n      0x100000000000000000000000000000000000000000000000000000000\r\n      swap1\r\n      div\r\n      0xffffffff\r\n      and\r\n      dup1\r\n      0x27e235e3\r\n      eq\r\n      tag_2\r\n      jumpi\r\n      dup1\r\n      0xa9059cbb\r\n      eq\r\n      tag_3\r\n      jumpi\r\n    tag_1:\r\n      0x0\r\n      dup1\r\n      revert\r\n        /* \"token.sol\":54:95  mapping (address => uint) public balances */\r\n    tag_2:\r\n      jumpi(tag_4, iszero(callvalue))\r\n      0x0\r\n      dup1\r\n      revert\r\n    tag_4:\r\n      tag_5\r\n      0x4\r\n      dup1\r\n      dup1\r\n      calldataload\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      swap1\r\n      0x20\r\n      add\r\n      swap1\r\n      swap2\r\n      swap1\r\n      pop\r\n      pop\r\n      jump(tag_6)\r\n    tag_5:\r\n      mload(0x40)\r\n      dup1\r\n      dup3\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap2\r\n      pop\r\n      pop\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      return\r\n        /* \"token.sol\":379:694  function transfer(address receiver, uint amount) public returns(bool sufficient) {\r... */\r\n    tag_3:\r\n      jumpi(tag_7, iszero(callvalue))\r\n      0x0\r\n      dup1\r\n      revert\r\n    tag_7:\r\n      tag_8\r\n      0x4\r\n      dup1\r\n      dup1\r\n      calldataload\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      swap1\r\n      0x20\r\n      add\r\n      swap1\r\n      swap2\r\n      swap1\r\n      dup1\r\n      calldataload\r\n      swap1\r\n      0x20\r\n      add\r\n      swap1\r\n      swap2\r\n      swap1\r\n      pop\r\n      pop\r\n      jump(tag_9)\r\n    tag_8:\r\n      mload(0x40)\r\n      dup1\r\n      dup3\r\n      iszero\r\n      iszero\r\n      iszero\r\n      iszero\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap2\r\n      pop\r\n      pop\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      return\r\n        /* \"token.sol\":54:95  mapping (address => uint) public balances */\r\n    tag_6:\r\n      mstore(0x20, 0x0)\r\n      dup1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x40)\r\n      0x0\r\n      swap2\r\n      pop\r\n      swap1\r\n      pop\r\n      sload\r\n      dup2\r\n      jump\t// out\r\n        /* \"token.sol\":379:694  function transfer(address receiver, uint amount) public returns(bool sufficient) {\r... */\r\n    tag_9:\r\n        /* \"token.sol\":443:458  bool sufficient */\r\n      0x0\r\n        /* \"token.sol\":498:504  amount */\r\n      dup2\r\n        /* \"token.sol\":475:483  balances */\r\n      0x0\r\n        /* \"token.sol\":475:495  balances[msg.sender] */\r\n      dup1\r\n        /* \"token.sol\":484:494  msg.sender */\r\n      caller\r\n        /* \"token.sol\":475:495  balances[msg.sender] */\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap1\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      0x0\r\n      keccak256\r\n      sload\r\n        /* \"token.sol\":475:504  balances[msg.sender] < amount */\r\n      lt\r\n        /* \"token.sol\":471:523  if (balances[msg.sender] < amount) \r... */\r\n      iszero\r\n      tag_11\r\n      jumpi\r\n        /* \"token.sol\":518:523  false */\r\n      0x0\r\n        /* \"token.sol\":511:523  return false */\r\n      swap1\r\n      pop\r\n      jump(tag_10)\r\n        /* \"token.sol\":471:523  if (balances[msg.sender] < amount) \r... */\r\n    tag_11:\r\n        /* \"token.sol\":562:568  amount */\r\n      dup2\r\n        /* \"token.sol\":538:546  balances */\r\n      0x0\r\n        /* \"token.sol\":538:558  balances[msg.sender] */\r\n      dup1\r\n        /* \"token.sol\":547:557  msg.sender */\r\n      caller\r\n        /* \"token.sol\":538:558  balances[msg.sender] */\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap1\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      0x0\r\n      keccak256\r\n      0x0\r\n        /* \"token.sol\":538:568  balances[msg.sender] -= amount */\r\n      dup3\r\n      dup3\r\n      sload\r\n      sub\r\n      swap3\r\n      pop\r\n      pop\r\n      dup2\r\n      swap1\r\n      sstore\r\n      pop\r\n        /* \"token.sol\":601:607  amount */\r\n      dup2\r\n        /* \"token.sol\":579:587  balances */\r\n      0x0\r\n        /* \"token.sol\":579:597  balances[receiver] */\r\n      dup1\r\n        /* \"token.sol\":588:596  receiver */\r\n      dup6\r\n        /* \"token.sol\":579:597  balances[receiver] */\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap1\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      0x0\r\n      keccak256\r\n      0x0\r\n        /* \"token.sol\":579:607  balances[receiver] += amount */\r\n      dup3\r\n      dup3\r\n      sload\r\n      add\r\n      swap3\r\n      pop\r\n      pop\r\n      dup2\r\n      swap1\r\n      sstore\r\n      pop\r\n        /* \"token.sol\":622:660  Transfer(msg.sender, receiver, amount) */\r\n      0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\r\n        /* \"token.sol\":631:641  msg.sender */\r\n      caller\r\n        /* \"token.sol\":643:651  receiver */\r\n      dup5\r\n        /* \"token.sol\":653:659  amount */\r\n      dup5\r\n        /* \"token.sol\":622:660  Transfer(msg.sender, receiver, amount) */\r\n      mload(0x40)\r\n      dup1\r\n      dup5\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      dup4\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      dup3\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap4\r\n      pop\r\n      pop\r\n      pop\r\n      pop\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      log1\r\n        /* \"token.sol\":682:686  true */\r\n      0x1\r\n        /* \"token.sol\":675:686  return true */\r\n      swap1\r\n      pop\r\n        /* \"token.sol\":379:694  function transfer(address receiver, uint amount) public returns(bool sufficient) {\r... */\r\n    tag_10:\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\t// out\r\n\r\n    auxdata: 0xa165627a7a723058206eeb5ce99ecaedf1e1d69e2be9f2b6aff6498dc1892a8884a484b4dff65ce9730029\r\n}\r\n"
  },
  {
    "path": "exeth/simple/contracts/token.sol",
    "content": "// pragma solidity ^0.4.18;\r\n\r\ncontract Token { \r\n    mapping (address => uint) public balances;\r\n    \r\n\tevent Transfer(address sender, address receiver, uint amount);\r\n\r\n\t/* Initializes contract with initial supply tokens to the creator of the contract */\r\n    constructor() public {\r\n        balances[msg.sender] = 10000;\r\n    }\r\n\r\n\t/* Very simple transfer function */\r\n    function transfer(address receiver, uint amount) public returns(bool sufficient) {\r\n        // require(balances[msg.sender] >= amount);\r\n        if (balances[msg.sender] <= amount) \r\n\t\t\treturn false;\r\n        \r\n\t\tbalances[msg.sender] -= amount;\r\n        balances[receiver] += amount;\r\n        \r\n\t\temit Transfer(msg.sender, receiver, amount);\r\n        \r\n\t\treturn true;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "exeth/simple/contracts/types.sol",
    "content": "\r\ncontract Types {\r\n    // signed integer (32 bytes)\r\n    int signed;\r\n    // unsigned integer (32 bytes)\r\n    uint unsigned;\r\n    // integer with bit size\r\n    uint16 short;\r\n\r\n    // boolean\r\n    bool flag;\r\n\r\n    // string\r\n    string name;\r\n\r\n    // address\r\n    address wallet;\r\n    // members: wallet.balance, \r\n    // wallet.transfer(uint256) throws on failure\r\n    // wallet.send(uint256) returns(bool)\r\n    // returns false on failure\r\n\r\n    // visible state variable\r\n    int public visible;\r\n\r\n    // fixed size byte arrays\r\n    bytes1 onebyte;\r\n    bytes20 twentybytes;\r\n    bytes32 thirtytwobytes;\r\n    int[10] tenintegers;\r\n    string[5] fivemessages;\r\n\r\n    // dynamically-sized arrays\r\n    bytes data;\r\n    string message;\r\n\r\n    // enums\r\n    enum Actions { GoLeft, GoRight, GoStraight, SitStill }\r\n\r\n    // dynamic array initialization\r\n    function f(uint len) {\r\n        uint[] memory a = new uint[](7);\r\n        bytes memory b = new bytes(len);\r\n        // Here we have a.length == 7 and b.length == len\r\n        a[6] = 8;\r\n    }\r\n\r\n    struct Voter {\r\n        address delegate;\r\n        bool voted;\r\n    }\r\n\r\n    struct Proposal {\r\n        bytes32 name;\r\n        uint voteCount;\r\n    }\r\n}"
  },
  {
    "path": "exeth/simple/counter.eth",
    "content": "\r\n# retrieve accounts\r\n\r\nmessage \"retrieving accounts...\"\r\naccounts\r\n\r\n# compile contract\r\n# (contracts variable has the compiled contract data)\r\n\r\nmessage \"compiling contract...\"\r\ncompile \"./contracts/counter.sol\"\r\nmessage \"counter.sol compiled\"\r\n\r\nmessage \"functions\"\r\ndump contracts.Counter.evm.methodIdentifiers\r\n\r\n# deploy instances, using default sender: accounts[0], message default result: 0\r\n# first argument: contract name\r\n# second argument: new instance name\r\n\r\nmessage \"deploy instance...\"\r\ndeploy Counter counter\r\n\r\n# show instance address\r\n# (instances variable has the instances data)\r\n\r\nmessage \"new instance\" instances.counter.address\r\n\r\n# get counter\r\n\r\ncall counter getCounter()\r\nset counter result\r\nmessage \"counter\" counter\r\n\r\nassert counter == 1\r\n\r\n# invoke increment (default sender: accounts[0])\r\n\r\nmessage \"increment...\"\r\ninvoke counter increment()\r\n\r\n# get counter\r\n\r\ncall counter getCounter()\r\nset counter result\r\nmessage \"counter\" counter\r\n\r\nassert counter == 2\r\n\r\n# invoke add (default sender: accounts[0])\r\n\r\nmessage \"add 40...\"\r\ninvoke counter add(uint256) 40\r\n\r\n# get counter\r\n\r\ncall counter getCounter()\r\nset counter result\r\nmessage \"counter\" counter\r\n\r\nassert counter == 42\r\n\r\nmessage \"done\"\r\n"
  },
  {
    "path": "exeth/simple/creator.eth",
    "content": "\r\naccounts\r\n\r\nmessage \"compiling creator.sol\"\r\ncompile \"./contracts/creator.sol\"\r\nmessage \"creator.sol compiled\"\r\n\r\ndeploy Creator creator1\r\n\r\nmessage \"contract deployed to address\" result\r\n\r\ncall creator1 counter()\r\n\r\nset counteraddr result\r\n\r\nmessage \"counter contract\" counteraddr\r\n\r\n"
  },
  {
    "path": "exeth/simple/deploy.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling counter.sol\"\r\ncompile \"./contracts/counter.sol\"\r\nmessage \"counter.sol compiled\"\r\n\r\ndeploy Counter counter1\r\n\r\nmessage \"contract deployed to address\" value\r\n\r\nmessage \"instance counter1 data\"\r\ndump instances.counter1\r\n\r\n\r\n"
  },
  {
    "path": "exeth/simple/dump.eth",
    "content": "\r\nmessage \"compiling empty.sol\"\r\ncompile \"./contracts/empty.sol\"\r\nmessage \"empty.sol compiled\"\r\n\r\nmessage \"Empty functions\"\r\ndump contracts.Empty.evm.methodIdentifiers\r\n\r\nmessage\r\n\r\nmessage \"compiling counter.sol\"\r\ncompile \"./contracts/counter.sol\"\r\nmessage \"counter.sol compiled\"\r\n\r\n# assertions\r\nassert contracts.Counter\r\nassert contracts.Counter.abi\r\nassert contracts.Counter.evm.bytecode\r\nassert contracts.Counter.evm.deployedBytecode\r\n\r\nmessage \"Counter functions\"\r\ndump contracts.Counter.evm.methodIdentifiers\r\n\r\nmessage \"Counter interface\"\r\ndump contracts.Counter.abi\r\n\r\nmessage \"Counter bytecodes\"\r\ndump contracts.Counter.evm.bytecode.object\r\n\r\n\r\n"
  },
  {
    "path": "exeth/simple/empty.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling empty.sol\"\r\ncompile \"./contracts/empty.sol\"\r\nmessage \"empty.sol compiled\"\r\n\r\ndeploy Empty empty1\r\n\r\nmessage \"contract deployed to address\" result\r\n\r\nmessage \"instance empty1 data\"\r\ndump instances.empty1\r\n\r\n\r\n"
  },
  {
    "path": "exeth/simple/greeter.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling greeter.sol\"\r\ncompile \"./contracts/greeter.sol\"\r\nmessage \"greeter.sol compiled\"\r\n\r\ndump contracts.Greeter.evm.methodIdentifiers\r\ndump contracts.Greeter.abi\r\n\r\ndeploy Greeter greeter1\r\n\r\nmessage \"contract deployed to address\" result\r\n\r\nmessage \"retrieving message\"\r\ncall greeter1 message()\r\nmessage \"message\" result\r\nassert result === \"Hello, Contract\"\r\n\r\nmessage \"changing message\"\r\ninvoke greeter1 setMessage(string) \"Hello, World\"\r\n\r\nmessage \"retrieving message\"\r\ncall greeter1 message()\r\n\r\nmessage \"message\" result\r\n\r\nassert result === \"Hello, World\"\r\n\r\n"
  },
  {
    "path": "exeth/simple/hello.eth",
    "content": "# a message \r\n\r\nmessage \"hello world\"\r\n\r\n"
  },
  {
    "path": "exeth/simple/message.eth",
    "content": "\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling message.sol\"\r\ncompile \"./contracts/message.sol\"\r\nmessage \"message.sol compiled\"\r\n\r\ndump Object.keys(contracts);\r\n#dump contracts.Message.evm.methodInterfaces\r\n#dump contracts.Message.abi\r\n\r\ndeploy Message message1 \"hello\"\r\n\r\nmessage \"contract deployed to address\" result\r\n\r\nmessage \"retrieving message\"\r\ncall message1 message()\r\nmessage \"message\" result\r\nassert result === \"hello\"\r\n\r\nmessage \"changing message\"\r\ninvoke message1 setMessage(string) \"Hello, World\"\r\n\r\nmessage \"retrieving message\"\r\ncall message1 message()\r\n\r\nmessage \"message\" result\r\n\r\nassert result === \"Hello, World\"\r\n\r\n"
  },
  {
    "path": "exeth/simple/rsksend.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# set RSK host\r\nhost \"http://localhost:4444\"\r\n\r\n# retrieve accounts from host\r\naccounts\r\n\r\nassert accounts\r\nassert accounts.length\r\n\r\nmessage \"Second account is\" accounts[1]\r\nbalance accounts[1]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Sending transaction...\"\r\nsend accounts[1] accounts[3] 1000000\r\n\r\nmessage \"Third account is\" accounts[2]\r\nbalance accounts[2]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Sending transaction...\"\r\nsend accounts[2] accounts[0] 1000000\r\n"
  },
  {
    "path": "exeth/simple/rsktransfer.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# set RSK host\r\nhost \"http://localhost:4444\"\r\n\r\n# retrieve accounts from host\r\naccounts\r\n\r\nassert accounts\r\nassert accounts.length\r\n\r\nmessage \"Fourth account is\" accounts[3]\r\nbalance accounts[4]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"First account is\" accounts[1]\r\nbalance accounts[0]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Transfering...\"\r\ntransfer accounts[4] accounts[0] 10000000000000\r\n\r\nmessage \"Second account is\" accounts[1]\r\nbalance accounts[1]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Transfering...\"\r\ntransfer accounts[4] accounts[1] 10000000000000\r\n\r\nmessage \"Third account is\" accounts[2]\r\nbalance accounts[2]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Transfering...\"\r\ntransfer accounts[4] accounts[2] 10000000000000\r\n\r\nmessage \"Fourth account is\" accounts[3]\r\nbalance accounts[3]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Transfering...\"\r\ntransfer accounts[4] accounts[3] 10000000000000\r\n"
  },
  {
    "path": "exeth/simple/throw.eth",
    "content": "\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling throw.sol\"\r\ncompile \"./contracts/throw.sol\"\r\nmessage \"throw.sol compiled\"\r\n\r\ndeploy Throw throw1\r\n\r\nmessage \"contract deployed to address\" value\r\n\r\nmessage \"instance throw1 data\"\r\ndump instances.throw1\r\n\r\n\r\n"
  },
  {
    "path": "exeth/simple/token.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling token.sol\"\r\ncompile \"./contracts/token.sol\"\r\nmessage \"token.sol compiled\"\r\n\r\ndump contracts.Token.evm.methodIdentifiers\r\n\r\ndeploy Token token1\r\n\r\nmessage \"contract deployed to address\" result\r\n\r\ncall token1 balances(address) accounts[0]\r\n\r\nmessage \"owner balance\" result\r\n\r\nassert result == 10000\r\n\r\ninvoke token1 transfer(address,uint256) accounts[1] 100\r\n\r\ncall token1 balances(address) accounts[0]\r\n\r\nmessage \"owner balance\" result\r\n\r\nassert result == 10000 - 100\r\n\r\ncall token1 balances(address) accounts[1]\r\n\r\nmessage \"receiver balance\" result\r\n\r\nassert result == 100\r\n\r\nmessage \"done\"\r\n\r\n\r\n"
  },
  {
    "path": "exeth/simple/transfer.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts from default host (http://localhost:8545)\r\naccounts\r\n\r\nassert accounts\r\nassert accounts.length\r\n\r\nmessage \"First account is\" accounts[0]\r\nbalance accounts[0]\r\nmessage \"Its balance is\" parseInt(result)\r\n\r\nmessage \"Second account is\" accounts[1]\r\nbalance accounts[1]\r\nmessage \"Its balance is\" parseInt(result)\r\n\r\nmessage \"Transfering...\"\r\ntransfer accounts[0] accounts[1] 1000000\r\n\r\nmessage \"First account is\" accounts[0]\r\nbalance accounts[0]\r\nmessage \"Its balance is\" parseInt(result)\r\n\r\nmessage \"Second account is\" accounts[1]\r\nbalance accounts[1]\r\nmessage \"Its balance is\" parseInt(result)\r\n\r\n"
  },
  {
    "path": "old/simple/.gitignore",
    "content": "context.json\r\n"
  },
  {
    "path": "old/simple/README.md",
    "content": "# Simple Contract Samples\r\n\r\n## Install\r\n\r\nInstall (NodeJS)[https://nodejs.org/en/]\r\n\r\nRun\r\n```\r\nnpm install\r\n```\r\n\r\n## Running a DSL file\r\n\r\nThere is a defined DSL (Domain Specific Language) to compile contracts and to send Ethereum commands\r\nto a node.\r\n\r\nExample, to show accounts the `accounts.eth` text file contains:\r\n\r\n```\r\n# retrieve accounts from default host (http://localhost:8545)\r\naccounts\r\n\r\n# dump the accounts addresses\r\ndump accounts\r\n```\r\n\r\nTo execute the DSL file, run:\r\n\r\n```\r\nnode run accounts\r\n```\r\n\r\n"
  },
  {
    "path": "old/simple/accounts.eth",
    "content": "\r\n# retrieve accounts from default host (http://localhost:8545)\r\naccounts\r\n\r\n# dump the accounts addresses\r\ndump accounts\r\n\r\nassert accounts\r\nassert accounts.length\r\n\r\n"
  },
  {
    "path": "old/simple/balance.eth",
    "content": "\r\n# retrieve accounts from default host (http://localhost:8545)\r\naccounts\r\n\r\nassert accounts\r\nassert accounts.length\r\n\r\nmessage \"First account is\" accounts[0]\r\n\r\nbalance accounts[0]\r\n\r\nmessage \"Its balance is\" value"
  },
  {
    "path": "old/simple/balances10.eth",
    "content": "\r\naccounts\r\n\r\nbalance accounts[0]\r\nmessage \"account\" accounts[0] \"balance is\" value\r\nbalance accounts[1]\r\nmessage \"account\" accounts[1] \"balance is\" value\r\nbalance accounts[2]\r\nmessage \"account\" accounts[2] \"balance is\" value\r\nbalance accounts[3]\r\nmessage \"account\" accounts[3] \"balance is\" value\r\nbalance accounts[4]\r\nmessage \"account\" accounts[4] \"balance is\" value\r\nbalance accounts[5]\r\nmessage \"account\" accounts[5] \"balance is\" value\r\nbalance accounts[6]\r\nmessage \"account\" accounts[6] \"balance is\" value\r\nbalance accounts[7]\r\nmessage \"account\" accounts[7] \"balance is\" value\r\nbalance accounts[8]\r\nmessage \"account\" accounts[8] \"balance is\" value\r\nbalance accounts[9]\r\nmessage \"account\" accounts[9] \"balance is\" value\r\n"
  },
  {
    "path": "old/simple/balances20.eth",
    "content": "\r\naccounts\r\n\r\nbalance accounts[0]\r\nmessage \"account\" accounts[0] \"balance is\" value\r\nbalance accounts[1]\r\nmessage \"account\" accounts[1] \"balance is\" value\r\nbalance accounts[2]\r\nmessage \"account\" accounts[2] \"balance is\" value\r\nbalance accounts[3]\r\nmessage \"account\" accounts[3] \"balance is\" value\r\nbalance accounts[4]\r\nmessage \"account\" accounts[4] \"balance is\" value\r\nbalance accounts[5]\r\nmessage \"account\" accounts[5] \"balance is\" value\r\nbalance accounts[6]\r\nmessage \"account\" accounts[6] \"balance is\" value\r\nbalance accounts[7]\r\nmessage \"account\" accounts[7] \"balance is\" value\r\nbalance accounts[8]\r\nmessage \"account\" accounts[8] \"balance is\" value\r\nbalance accounts[9]\r\nmessage \"account\" accounts[9] \"balance is\" value\r\nbalance accounts[10]\r\nmessage \"account\" accounts[10] \"balance is\" value\r\nbalance accounts[11]\r\nmessage \"account\" accounts[11] \"balance is\" value\r\nbalance accounts[12]\r\nmessage \"account\" accounts[12] \"balance is\" value\r\nbalance accounts[13]\r\nmessage \"account\" accounts[13] \"balance is\" value\r\nbalance accounts[14]\r\nmessage \"account\" accounts[14] \"balance is\" value\r\nbalance accounts[15]\r\nmessage \"account\" accounts[15] \"balance is\" value\r\nbalance accounts[16]\r\nmessage \"account\" accounts[16] \"balance is\" value\r\nbalance accounts[17]\r\nmessage \"account\" accounts[17] \"balance is\" value\r\nbalance accounts[18]\r\nmessage \"account\" accounts[18] \"balance is\" value\r\nbalance accounts[19]\r\nmessage \"account\" accounts[19] \"balance is\" value\r\n"
  },
  {
    "path": "old/simple/balances30.eth",
    "content": "\r\naccounts\r\n\r\nbalance accounts[0]\r\nmessage \"account\" accounts[0] \"balance is\" value\r\nbalance accounts[1]\r\nmessage \"account\" accounts[1] \"balance is\" value\r\nbalance accounts[2]\r\nmessage \"account\" accounts[2] \"balance is\" value\r\nbalance accounts[3]\r\nmessage \"account\" accounts[3] \"balance is\" value\r\nbalance accounts[4]\r\nmessage \"account\" accounts[4] \"balance is\" value\r\nbalance accounts[5]\r\nmessage \"account\" accounts[5] \"balance is\" value\r\nbalance accounts[6]\r\nmessage \"account\" accounts[6] \"balance is\" value\r\nbalance accounts[7]\r\nmessage \"account\" accounts[7] \"balance is\" value\r\nbalance accounts[8]\r\nmessage \"account\" accounts[8] \"balance is\" value\r\nbalance accounts[9]\r\nmessage \"account\" accounts[9] \"balance is\" value\r\nbalance accounts[10]\r\nmessage \"account\" accounts[10] \"balance is\" value\r\nbalance accounts[11]\r\nmessage \"account\" accounts[11] \"balance is\" value\r\nbalance accounts[12]\r\nmessage \"account\" accounts[12] \"balance is\" value\r\nbalance accounts[13]\r\nmessage \"account\" accounts[13] \"balance is\" value\r\nbalance accounts[14]\r\nmessage \"account\" accounts[14] \"balance is\" value\r\nbalance accounts[15]\r\nmessage \"account\" accounts[15] \"balance is\" value\r\nbalance accounts[16]\r\nmessage \"account\" accounts[16] \"balance is\" value\r\nbalance accounts[17]\r\nmessage \"account\" accounts[17] \"balance is\" value\r\nbalance accounts[18]\r\nmessage \"account\" accounts[18] \"balance is\" value\r\nbalance accounts[19]\r\nmessage \"account\" accounts[19] \"balance is\" value\r\nbalance accounts[20]\r\nmessage \"account\" accounts[20] \"balance is\" value\r\nbalance accounts[21]\r\nmessage \"account\" accounts[21] \"balance is\" value\r\nbalance accounts[22]\r\nmessage \"account\" accounts[22] \"balance is\" value\r\nbalance accounts[23]\r\nmessage \"account\" accounts[23] \"balance is\" value\r\nbalance accounts[24]\r\nmessage \"account\" accounts[24] \"balance is\" value\r\nbalance accounts[25]\r\nmessage \"account\" accounts[25] \"balance is\" value\r\nbalance accounts[26]\r\nmessage \"account\" accounts[26] \"balance is\" value\r\nbalance accounts[27]\r\nmessage \"account\" accounts[27] \"balance is\" value\r\nbalance accounts[28]\r\nmessage \"account\" accounts[28] \"balance is\" value\r\nbalance accounts[29]\r\nmessage \"account\" accounts[29] \"balance is\" value\r\n"
  },
  {
    "path": "old/simple/balances4.eth",
    "content": "\r\naccounts\r\n\r\nbalance accounts[0]\r\nmessage \"account\" accounts[0] \"balance is\" value\r\nbalance accounts[1]\r\nmessage \"account\" accounts[1] \"balance is\" value\r\nbalance accounts[2]\r\nmessage \"account\" accounts[2] \"balance is\" value\r\nbalance accounts[3]\r\nmessage \"account\" accounts[3] \"balance is\" value\r\n"
  },
  {
    "path": "old/simple/compile.eth",
    "content": "\r\nmessage \"compiling counter.sol\"\r\ncompile \"./contracts/counter.sol\"\r\nmessage \"counter.sol compiled\"\r\n\r\n# dump contracts.Counter.interface\r\n# dump contracts.Counter.opcodes\r\ndump Object.keys(contracts.Counter)\r\ndump contracts.Counter.assembly\r\n\r\ndump contracts.Counter.functionHashes\r\n\r\n"
  },
  {
    "path": "old/simple/config.json",
    "content": "{\r\n\t\"host\": \"http://localhost:8545\"\r\n}\r\n\r\n"
  },
  {
    "path": "old/simple/contracts/counter.sol",
    "content": "\r\n// pragma solidity ^0.4.18;\r\n\r\n// Simple counter contract\r\n\r\ncontract Counter {\r\n    uint counter;\r\n\t\r\n    function Counter() public {\r\n        counter = 1;\r\n    }\r\n    \r\n    function increment() public {\r\n        counter++;\r\n    }\r\n\t\r\n    function add(uint v) public {\r\n        counter += v;\r\n    }\r\n\t\r\n    function getCounter() public constant returns (uint) {\r\n        return counter;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "old/simple/contracts/creator.sol",
    "content": "\r\ncontract Counter {\r\n    event Incremented(bool indexed odd, uint x);\r\n\tevent Created(uint x);\r\n\tevent Valued(uint x);\r\n\t\r\n    function Counter() {\r\n        x = 70;\r\n\t\tCreated(x);\r\n    }\r\n    \r\n    function increment() {\r\n        ++x;\r\n        Incremented(x % 2 == 1, x);\r\n    }\r\n\t\r\n    function getValue() constant returns (uint) {\r\n\t\tValued(x);\r\n        return x;\r\n    }\r\n\r\n    uint x;\r\n}\r\n\r\ncontract Creator {\r\n\tCounter counter;\r\n\tevent CounterCreated(uint);\r\n\t\r\n\tfunction Creator() {\r\n\t\tcounter = new Counter();\r\n\t\tCounterCreated(counter.getValue());\r\n\t}\r\n}\r\n\r\n"
  },
  {
    "path": "old/simple/contracts/empty.sol",
    "content": "// pragma solidity ^0.4.18;\r\n\r\n// Simple empty contract\r\n\r\ncontract Empty {\r\n}\r\n\r\n"
  },
  {
    "path": "old/simple/contracts/foobar.sol",
    "content": "\r\n// Simple inheritance\r\n\r\ncontract Foo {\r\n}\r\n\r\ncontract Bar is Foo {\r\n}\r\n"
  },
  {
    "path": "old/simple/contracts/greeter.sol",
    "content": "\r\ncontract Greeter {\r\n    string public message;\r\n\r\n    function Greeter() {\r\n        message = \"Hello, Contract\";\r\n    }\r\n    \r\n    function setMessage(string msg) {\r\n        message = msg;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "old/simple/contracts/message.sol",
    "content": "\r\ncontract Message {\r\n    string public message;\r\n\r\n    function Message(string msg) {\r\n        message = msg;\r\n    }\r\n    \r\n    function setMessage(string msg) {\r\n        message = msg;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "old/simple/contracts/selector.sol",
    "content": "\r\ncontract Selector {\r\n  function f() returns (bytes4) {\r\n    return this.f.selector;\r\n  }\r\n}"
  },
  {
    "path": "old/simple/contracts/throw.sol",
    "content": "contract Throw {\r\n\tfunction Throw() {\r\n\t\trequire(msg.value > 0);\r\n\t}\r\n}\r\n\r\n"
  },
  {
    "path": "old/simple/contracts/token.asm",
    "content": "\r\n======= token.sol:Token =======\r\nEVM assembly:\r\n    /* \"token.sol\":31:697  contract Token { \r... */\r\n  mstore(0x40, 0x60)\r\n    /* \"token.sol\":262:333  function Token() public {\r... */\r\n  jumpi(tag_1, iszero(callvalue))\r\n  0x0\r\n  dup1\r\n  revert\r\ntag_1:\r\ntag_2:\r\n    /* \"token.sol\":320:325  10000 */\r\n  0x2710\r\n    /* \"token.sol\":297:305  balances */\r\n  0x0\r\n    /* \"token.sol\":297:317  balances[msg.sender] */\r\n  dup1\r\n    /* \"token.sol\":306:316  msg.sender */\r\n  caller\r\n    /* \"token.sol\":297:317  balances[msg.sender] */\r\n  0xffffffffffffffffffffffffffffffffffffffff\r\n  and\r\n  0xffffffffffffffffffffffffffffffffffffffff\r\n  and\r\n  dup2\r\n  mstore\r\n  0x20\r\n  add\r\n  swap1\r\n  dup2\r\n  mstore\r\n  0x20\r\n  add\r\n  0x0\r\n  keccak256\r\n    /* \"token.sol\":297:325  balances[msg.sender] = 10000 */\r\n  dup2\r\n  swap1\r\n  sstore\r\n  pop\r\n    /* \"token.sol\":262:333  function Token() public {\r... */\r\ntag_3:\r\n    /* \"token.sol\":31:697  contract Token { \r... */\r\ntag_4:\r\n  dataSize(sub_0)\r\n  dup1\r\n  dataOffset(sub_0)\r\n  0x0\r\n  codecopy\r\n  0x0\r\n  return\r\nstop\r\n\r\nsub_0: assembly {\r\n        /* \"token.sol\":31:697  contract Token { \r... */\r\n      mstore(0x40, 0x60)\r\n      calldataload(0x0)\r\n      0x100000000000000000000000000000000000000000000000000000000\r\n      swap1\r\n      div\r\n      0xffffffff\r\n      and\r\n      dup1\r\n      0x27e235e3\r\n      eq\r\n      tag_2\r\n      jumpi\r\n      dup1\r\n      0xa9059cbb\r\n      eq\r\n      tag_3\r\n      jumpi\r\n    tag_1:\r\n      0x0\r\n      dup1\r\n      revert\r\n        /* \"token.sol\":54:95  mapping (address => uint) public balances */\r\n    tag_2:\r\n      jumpi(tag_4, iszero(callvalue))\r\n      0x0\r\n      dup1\r\n      revert\r\n    tag_4:\r\n      tag_5\r\n      0x4\r\n      dup1\r\n      dup1\r\n      calldataload\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      swap1\r\n      0x20\r\n      add\r\n      swap1\r\n      swap2\r\n      swap1\r\n      pop\r\n      pop\r\n      jump(tag_6)\r\n    tag_5:\r\n      mload(0x40)\r\n      dup1\r\n      dup3\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap2\r\n      pop\r\n      pop\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      return\r\n        /* \"token.sol\":379:694  function transfer(address receiver, uint amount) public returns(bool sufficient) {\r... */\r\n    tag_3:\r\n      jumpi(tag_7, iszero(callvalue))\r\n      0x0\r\n      dup1\r\n      revert\r\n    tag_7:\r\n      tag_8\r\n      0x4\r\n      dup1\r\n      dup1\r\n      calldataload\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      swap1\r\n      0x20\r\n      add\r\n      swap1\r\n      swap2\r\n      swap1\r\n      dup1\r\n      calldataload\r\n      swap1\r\n      0x20\r\n      add\r\n      swap1\r\n      swap2\r\n      swap1\r\n      pop\r\n      pop\r\n      jump(tag_9)\r\n    tag_8:\r\n      mload(0x40)\r\n      dup1\r\n      dup3\r\n      iszero\r\n      iszero\r\n      iszero\r\n      iszero\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap2\r\n      pop\r\n      pop\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      return\r\n        /* \"token.sol\":54:95  mapping (address => uint) public balances */\r\n    tag_6:\r\n      mstore(0x20, 0x0)\r\n      dup1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x40)\r\n      0x0\r\n      swap2\r\n      pop\r\n      swap1\r\n      pop\r\n      sload\r\n      dup2\r\n      jump\t// out\r\n        /* \"token.sol\":379:694  function transfer(address receiver, uint amount) public returns(bool sufficient) {\r... */\r\n    tag_9:\r\n        /* \"token.sol\":443:458  bool sufficient */\r\n      0x0\r\n        /* \"token.sol\":498:504  amount */\r\n      dup2\r\n        /* \"token.sol\":475:483  balances */\r\n      0x0\r\n        /* \"token.sol\":475:495  balances[msg.sender] */\r\n      dup1\r\n        /* \"token.sol\":484:494  msg.sender */\r\n      caller\r\n        /* \"token.sol\":475:495  balances[msg.sender] */\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap1\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      0x0\r\n      keccak256\r\n      sload\r\n        /* \"token.sol\":475:504  balances[msg.sender] < amount */\r\n      lt\r\n        /* \"token.sol\":471:523  if (balances[msg.sender] < amount) \r... */\r\n      iszero\r\n      tag_11\r\n      jumpi\r\n        /* \"token.sol\":518:523  false */\r\n      0x0\r\n        /* \"token.sol\":511:523  return false */\r\n      swap1\r\n      pop\r\n      jump(tag_10)\r\n        /* \"token.sol\":471:523  if (balances[msg.sender] < amount) \r... */\r\n    tag_11:\r\n        /* \"token.sol\":562:568  amount */\r\n      dup2\r\n        /* \"token.sol\":538:546  balances */\r\n      0x0\r\n        /* \"token.sol\":538:558  balances[msg.sender] */\r\n      dup1\r\n        /* \"token.sol\":547:557  msg.sender */\r\n      caller\r\n        /* \"token.sol\":538:558  balances[msg.sender] */\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap1\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      0x0\r\n      keccak256\r\n      0x0\r\n        /* \"token.sol\":538:568  balances[msg.sender] -= amount */\r\n      dup3\r\n      dup3\r\n      sload\r\n      sub\r\n      swap3\r\n      pop\r\n      pop\r\n      dup2\r\n      swap1\r\n      sstore\r\n      pop\r\n        /* \"token.sol\":601:607  amount */\r\n      dup2\r\n        /* \"token.sol\":579:587  balances */\r\n      0x0\r\n        /* \"token.sol\":579:597  balances[receiver] */\r\n      dup1\r\n        /* \"token.sol\":588:596  receiver */\r\n      dup6\r\n        /* \"token.sol\":579:597  balances[receiver] */\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap1\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      0x0\r\n      keccak256\r\n      0x0\r\n        /* \"token.sol\":579:607  balances[receiver] += amount */\r\n      dup3\r\n      dup3\r\n      sload\r\n      add\r\n      swap3\r\n      pop\r\n      pop\r\n      dup2\r\n      swap1\r\n      sstore\r\n      pop\r\n        /* \"token.sol\":622:660  Transfer(msg.sender, receiver, amount) */\r\n      0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\r\n        /* \"token.sol\":631:641  msg.sender */\r\n      caller\r\n        /* \"token.sol\":643:651  receiver */\r\n      dup5\r\n        /* \"token.sol\":653:659  amount */\r\n      dup5\r\n        /* \"token.sol\":622:660  Transfer(msg.sender, receiver, amount) */\r\n      mload(0x40)\r\n      dup1\r\n      dup5\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      dup4\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      0xffffffffffffffffffffffffffffffffffffffff\r\n      and\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      dup3\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap4\r\n      pop\r\n      pop\r\n      pop\r\n      pop\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      log1\r\n        /* \"token.sol\":682:686  true */\r\n      0x1\r\n        /* \"token.sol\":675:686  return true */\r\n      swap1\r\n      pop\r\n        /* \"token.sol\":379:694  function transfer(address receiver, uint amount) public returns(bool sufficient) {\r... */\r\n    tag_10:\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\t// out\r\n\r\n    auxdata: 0xa165627a7a723058206eeb5ce99ecaedf1e1d69e2be9f2b6aff6498dc1892a8884a484b4dff65ce9730029\r\n}\r\n"
  },
  {
    "path": "old/simple/contracts/token.sol",
    "content": "// pragma solidity ^0.4.18;\r\n\r\ncontract Token { \r\n    mapping (address => uint) public balances;\r\n    \r\n\tevent Transfer(address sender, address receiver, uint amount);\r\n\r\n\t/* Initializes contract with initial supply tokens to the creator of the contract */\r\n    function Token() public {\r\n        balances[msg.sender] = 10000;\r\n    }\r\n\r\n\t/* Very simple transfer function */\r\n    function transfer(address receiver, uint amount) public returns(bool sufficient) {\r\n        if (balances[msg.sender] < amount) \r\n\t\t\treturn false;\r\n        \r\n\t\tbalances[msg.sender] -= amount;\r\n        balances[receiver] += amount;\r\n        \r\n\t\tTransfer(msg.sender, receiver, amount);\r\n        \r\n\t\treturn true;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "old/simple/contracts/types.sol",
    "content": "\r\ncontract Types {\r\n    // signed integer (32 bytes)\r\n    int signed;\r\n    // unsigned integer (32 bytes)\r\n    uint unsigned;\r\n    // integer with bit size\r\n    uint16 short;\r\n\r\n    // boolean\r\n    bool flag;\r\n\r\n    // string\r\n    string name;\r\n\r\n    // address\r\n    address wallet;\r\n    // members: wallet.balance, \r\n    // wallet.transfer(uint256) throws on failure\r\n    // wallet.send(uint256) returns(bool)\r\n    // returns false on failure\r\n\r\n    // visible state variable\r\n    int public visible;\r\n\r\n    // fixed size byte arrays\r\n    bytes1 onebyte;\r\n    bytes20 twentybytes;\r\n    bytes32 thirtytwobytes;\r\n    int[10] tenintegers;\r\n    string[5] fivemessages;\r\n\r\n    // dynamically-sized arrays\r\n    bytes data;\r\n    string message;\r\n\r\n    // enums\r\n    enum Actions { GoLeft, GoRight, GoStraight, SitStill }\r\n\r\n    // dynamic array initialization\r\n    function f(uint len) {\r\n        uint[] memory a = new uint[](7);\r\n        bytes memory b = new bytes(len);\r\n        // Here we have a.length == 7 and b.length == len\r\n        a[6] = 8;\r\n    }\r\n\r\n    struct Voter {\r\n        address delegate;\r\n        bool voted;\r\n    }\r\n\r\n    struct Proposal {\r\n        bytes32 name;\r\n        uint voteCount;\r\n    }\r\n}"
  },
  {
    "path": "old/simple/counter.asm",
    "content": "\r\n======= contracts\\counter.sol:Counter =======\r\nEVM assembly:\r\n    /* \"contracts\\counter.sol\":63:399  contract Counter {\r... */\r\n  mstore(0x40, 0x60)\r\n    /* \"contracts\\counter.sol\":109:165  function Counter() public {\r... */\r\n  jumpi(tag_1, iszero(callvalue))\r\n  0x0\r\n  dup1\r\n  revert\r\ntag_1:\r\ntag_2:\r\n    /* \"contracts\\counter.sol\":156:157  1 */\r\n  0x1\r\n    /* \"contracts\\counter.sol\":146:153  counter */\r\n  0x0\r\n    /* \"contracts\\counter.sol\":146:157  counter = 1 */\r\n  dup2\r\n  swap1\r\n  sstore\r\n  pop\r\n    /* \"contracts\\counter.sol\":109:165  function Counter() public {\r... */\r\ntag_3:\r\n    /* \"contracts\\counter.sol\":63:399  contract Counter {\r... */\r\ntag_4:\r\n  dataSize(sub_0)\r\n  dup1\r\n  dataOffset(sub_0)\r\n  0x0\r\n  codecopy\r\n  0x0\r\n  return\r\nstop\r\n\r\nsub_0: assembly {\r\n        /* \"contracts\\counter.sol\":63:399  contract Counter {\r... */\r\n      mstore(0x40, 0x60)\r\n      calldataload(0x0)\r\n      0x100000000000000000000000000000000000000000000000000000000\r\n      swap1\r\n      div\r\n      0xffffffff\r\n      and\r\n      dup1\r\n      0x1003e2d2\r\n      eq\r\n      tag_2\r\n      jumpi\r\n      dup1\r\n      0x8ada066e\r\n      eq\r\n      tag_3\r\n      jumpi\r\n      dup1\r\n      0xd09de08a\r\n      eq\r\n      tag_4\r\n      jumpi\r\n    tag_1:\r\n      0x0\r\n      dup1\r\n      revert\r\n        /* \"contracts\\counter.sol\":242:301  function add(uint v) public {\r... */\r\n    tag_2:\r\n      jumpi(tag_5, iszero(callvalue))\r\n      0x0\r\n      dup1\r\n      revert\r\n    tag_5:\r\n      tag_6\r\n      0x4\r\n      dup1\r\n      dup1\r\n      calldataload\r\n      swap1\r\n      0x20\r\n      add\r\n      swap1\r\n      swap2\r\n      swap1\r\n      pop\r\n      pop\r\n      jump(tag_7)\r\n    tag_6:\r\n      stop\r\n        /* \"contracts\\counter.sol\":310:396  function getCounter() public constant returns (uint) {\r... */\r\n    tag_3:\r\n      jumpi(tag_8, iszero(callvalue))\r\n      0x0\r\n      dup1\r\n      revert\r\n    tag_8:\r\n      tag_9\r\n      jump(tag_10)\r\n    tag_9:\r\n      mload(0x40)\r\n      dup1\r\n      dup3\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      swap2\r\n      pop\r\n      pop\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      return\r\n        /* \"contracts\\counter.sol\":177:233  function increment() public {\r... */\r\n    tag_4:\r\n      jumpi(tag_11, iszero(callvalue))\r\n      0x0\r\n      dup1\r\n      revert\r\n    tag_11:\r\n      tag_12\r\n      jump(tag_13)\r\n    tag_12:\r\n      stop\r\n        /* \"contracts\\counter.sol\":242:301  function add(uint v) public {\r... */\r\n    tag_7:\r\n        /* \"contracts\\counter.sol\":292:293  v */\r\n      dup1\r\n        /* \"contracts\\counter.sol\":281:288  counter */\r\n      0x0\r\n      dup1\r\n        /* \"contracts\\counter.sol\":281:293  counter += v */\r\n      dup3\r\n      dup3\r\n      sload\r\n      add\r\n      swap3\r\n      pop\r\n      pop\r\n      dup2\r\n      swap1\r\n      sstore\r\n      pop\r\n        /* \"contracts\\counter.sol\":242:301  function add(uint v) public {\r... */\r\n    tag_14:\r\n      pop\r\n      jump\t// out\r\n        /* \"contracts\\counter.sol\":310:396  function getCounter() public constant returns (uint) {\r... */\r\n    tag_10:\r\n        /* \"contracts\\counter.sol\":357:361  uint */\r\n      0x0\r\n        /* \"contracts\\counter.sol\":381:388  counter */\r\n      dup1\r\n      sload\r\n        /* \"contracts\\counter.sol\":374:388  return counter */\r\n      swap1\r\n      pop\r\n        /* \"contracts\\counter.sol\":310:396  function getCounter() public constant returns (uint) {\r... */\r\n    tag_15:\r\n      swap1\r\n      jump\t// out\r\n        /* \"contracts\\counter.sol\":177:233  function increment() public {\r... */\r\n    tag_13:\r\n        /* \"contracts\\counter.sol\":216:223  counter */\r\n      0x0\r\n      dup1\r\n        /* \"contracts\\counter.sol\":216:225  counter++ */\r\n      dup2\r\n      sload\r\n      dup1\r\n      swap3\r\n      swap2\r\n      swap1\r\n      0x1\r\n      add\r\n      swap2\r\n      swap1\r\n      pop\r\n      sstore\r\n      pop\r\n        /* \"contracts\\counter.sol\":177:233  function increment() public {\r... */\r\n    tag_16:\r\n      jump\t// out\r\n\r\n    auxdata: 0xa165627a7a72305820ce1256d578d3a616ce794b4e657934308050c723323cd4054e711e36e22d652d0029\r\n}\r\n"
  },
  {
    "path": "old/simple/counter.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling counter.sol\"\r\ncompile \"./contracts/counter.sol\"\r\nmessage \"counter.sol compiled\"\r\n\r\ndump contracts.Counter.functionHashes\r\n\r\ndeploy Counter counter1\r\n\r\nmessage \"contract deployed to address\" value\r\n\r\ncall counter1 getCounter\r\n\r\nmessage \"counter is\" value\r\n\r\nassert value == 1\r\n\r\ninvoke counter1 increment\r\n\r\ncall counter1 getCounter\r\n\r\nmessage \"counter is\" value\r\n\r\nassert value == 2\r\n\r\ninvoke counter1 add(uint256) 40\r\n\r\ncall counter1 getCounter\r\n\r\nmessage \"counter is\" value\r\n\r\nassert value == 42\r\n\r\n\r\n"
  },
  {
    "path": "old/simple/creator.eth",
    "content": "\r\naccounts\r\n\r\nmessage \"compiling creator.sol\"\r\ncompile \"./contracts/creator.sol\"\r\nmessage \"creator.sol compiled\"\r\n\r\ndeploy Creator creator1\r\n\r\nmessage \"contract deployed to address\" value\r\n\r\n"
  },
  {
    "path": "old/simple/deploy.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling counter.sol\"\r\ncompile \"./contracts/counter.sol\"\r\nmessage \"counter.sol compiled\"\r\n\r\ndeploy Counter counter1\r\n\r\nmessage \"contract deployed to address\" value\r\n\r\nmessage \"instance counter1 data\"\r\ndump instances.counter1\r\n\r\n\r\n"
  },
  {
    "path": "old/simple/do.js",
    "content": "\r\nvar commands = require('./lib/commands');\r\nvar config = require('./config.json');\r\n\r\nvar sargs = require('simpleargs');\r\n\r\nsargs\r\n    .define('h', 'host', config.host, 'Host JSON RPC entry point')\r\n    .define('n', 'name', config.name, 'Name of the new entity')\r\n    .define('g', 'gas', config.name, 'Gas limit to consume');\r\n\r\nvar options = sargs(process.argv.slice(3));\r\n\r\nvar args = options._ || [];\r\nvar cmdname = process.argv[2];\r\n\r\ncommands[cmdname](args, options, function (err, data) {\r\n\tif (err)\r\n\t\tconsole.error('error', err);\r\n\telse\r\n\t\tconsole.log(data);\r\n});\r\n\r\n"
  },
  {
    "path": "old/simple/dump.eth",
    "content": "\r\nmessage \"compiling empty.sol\"\r\ncompile \"./contracts/empty.sol\"\r\nmessage \"empty.sol compiled\"\r\n\r\nmessage \"Empty functions\"\r\ndump contracts.Empty.functionHashes\r\n\r\nmessage\r\n\r\nmessage \"compiling counter.sol\"\r\ncompile \"./contracts/counter.sol\"\r\nmessage \"counter.sol compiled\"\r\n\r\n# assertions\r\nassert contracts.Counter\r\nassert contracts.Counter.interface\r\nassert contracts.Counter.bytecode\r\nassert contracts.Counter.runtimeBytecode\r\n\r\nmessage \"Counter functions\"\r\ndump contracts.Counter.functionHashes\r\n\r\nmessage \"Counter interface\"\r\ndump contracts.Counter.interface\r\n\r\nmessage \"Counter bytecodes\"\r\ndump contracts.Counter.bytecode\r\n\r\n\r\n"
  },
  {
    "path": "old/simple/empty.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling empty.sol\"\r\ncompile \"./contracts/empty.sol\"\r\nmessage \"empty.sol compiled\"\r\n\r\n#unlock from \"passphrase\" 10000\r\n\r\ndeploy Empty empty1\r\n\r\nmessage \"contract deployed to address\" value\r\n\r\nmessage \"instance empty1 data\"\r\ndump instances.empty1\r\n\r\n\r\n"
  },
  {
    "path": "old/simple/greeter.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling greeter.sol\"\r\ncompile \"./contracts/greeter.sol\"\r\nmessage \"greeter.sol compiled\"\r\n\r\n# dump contracts.Greeter.functionHashes\r\n# dump contracts.Greeter.interface\r\n\r\ndeploy Greeter greeter1\r\n\r\nmessage \"contract deployed to address\" value\r\n\r\nmessage \"retrieving message\"\r\ncall greeter1 message\r\nmessage \"message\" value\r\nassert value === \"Hello, Contract\"\r\n\r\nmessage \"changing message\"\r\ninvoke greeter1 setMessage \"Hello, World\"\r\n\r\nmessage \"retrieving message\"\r\ncall greeter1 message\r\n\r\nmessage \"message\" value\r\n\r\nassert value === \"Hello, World\""
  },
  {
    "path": "old/simple/hello.eth",
    "content": "# a message \r\n\r\nmessage \"hello world\"\r\n\r\n"
  },
  {
    "path": "old/simple/lib/commands.js",
    "content": "\r\nvar rskapi = require('rskapi');\r\nvar async = require('simpleasync');\r\nvar solc = require('solc');\r\nvar utils = require('./utils');\r\nvar fs = require('fs');\r\nvar path = require('path');\r\n\r\nvar host = rskapi.host('http://localhost:4444');\r\n\r\nvar ctxfilename = 'context.json';\r\nvar context = loadContext(ctxfilename);\r\n\r\nfunction switchToHost(h) {\r\n\thost = h;\r\n\tflushHostContext(ctxfilename, context);\r\n}\r\n\r\nfunction setHost(url) {\r\n\tif (!url) {\r\n\t\tif (!host)\r\n\t\t\tswitchToHost(rskapi.host('http://localhost:4444'));\r\n\t}\r\n\telse\r\n\t\tswitchToHost(rskapi.host(url));\r\n}\r\n\r\nfunction loadContext(filename) {\r\n\tif (!fs.existsSync(filename))\r\n\t\treturn {};\r\n\t\r\n\treturn JSON.parse(fs.readFileSync(filename).toString());\r\n}\r\n\r\nfunction saveContext(filename, ctx) {\r\n\tvar text = JSON.stringify(ctx);\r\n\t\r\n\tfs.writeFileSync(filename, text);\r\n}\r\n\r\nfunction flushHostContext(filename, ctx) {\r\n\tif (!ctx.addresses)\r\n\t\treturn;\r\n\t\r\n\tdelete ctx.addresses;\r\n\t\r\n\tsaveContext(filename, ctx);\r\n}\r\n\r\nfunction toNumber(obj) {\r\n\tif (obj == null)\r\n\t\treturn null;\r\n\t\r\n\tif (typeof obj === 'number')\r\n\t\treturn obj;\r\n\t\r\n\tif (typeof obj === 'string' && obj.length < 16)\r\n\t\treturn parseInt(obj);\r\n\t\r\n\treturn obj;\r\n}\r\n\r\nfunction asNumber(obj) {\r\n\tif (typeof obj === 'number')\r\n\t\treturn obj;\r\n\t\r\n\tif (typeof obj === 'string' && obj.length <= 10)\r\n\t\treturn parseInt(obj);\r\n\t\r\n\treturn null;\r\n}\r\n\r\nfunction getAccountAddress(acc, cb) {\r\n\tif (acc == null)\r\n\t\treturn cb(null, null);\r\n\t\r\n\thost.getAccounts(function (err, accounts) {\r\n\t\tif (err)\r\n\t\t\treturn cb(err);\r\n\t\t\r\n\t\tcb(null, getAccount(accounts));\r\n\t});\r\n\r\n\tfunction getAccount(accounts) {\r\n\t\tvar n = asNumber(acc);\r\n\t\t\r\n\t\tif (n == null)\r\n\t\t\treturn acc;\r\n\t\t\r\n\t\treturn accounts[n];\r\n\t}\t\r\n}\r\n\r\nfunction saveContract(name, value) {\r\n\tif (!context.contracts)\r\n\t\tcontext.contracts = {};\r\n\t\r\n\tcontext.contracts[name] = value;\r\n}\r\n\r\nfunction saveInstance(name, contractname, txhash, address) {\r\n\tif (!context.instances)\r\n\t\tcontext.instances = {};\r\n\t\r\n\tcontext.instances[name] = {\r\n\t\tcontract: contractname,\r\n\t\ttx: txhash,\r\n\t\taddress: address\r\n\t}\r\n}\r\n\r\nfunction getInstance(instancename) {\r\n\tif (!instancename)\r\n\t\treturn null;\r\n\t\r\n\tif (!context.instances)\r\n\t\treturn null;\r\n\t\r\n\tif (!context.instances[instancename])\r\n\t\treturn null;\r\n\r\n\treturn context.instances[instancename];\r\n}\r\n\r\nfunction getContract(contractname) {\r\n\tif (!contractname)\r\n\t\treturn null;\r\n\t\r\n\tif (!context.contracts)\r\n\t\treturn null;\r\n\t\r\n\tif (!context.contracts[contractname])\r\n\t\treturn null;\r\n\t\r\n\treturn context.contracts[contractname];\r\n}\r\n\r\nfunction getInstanceContract(instancename) {\r\n\tvar instance = getInstance(instancename);\r\n\t\r\n\tif (!instance)\r\n\t\treturn null;\r\n\t\r\n\tvar contract = getContract(instance.contract);\r\n\t\r\n\tif (!contract)\r\n\t\treturn null;\r\n\t\r\n\treturn contract;\r\n}\r\n\r\nfunction getInstanceAddress(instancename) {\r\n\tvar instance = getInstance(instancename);\r\n\t\r\n\tif (!instance)\r\n\t\treturn null;\r\n\t\r\n\tif (!instance.address)\r\n\t\treturn null;\r\n\t\r\n\treturn instance.address;\r\n}\r\n\r\nfunction getInstance(name) {\r\n\tif (!context.instances)\r\n\t\treturn null;\r\n\t\r\n\treturn context.instances[name];\r\n}\r\n\r\nfunction toData(contract, fnname, fnargs) {\r\n\treturn contract.functionHashes[fnname] + utils.encodeArguments(fnargs);\r\n}\r\n\r\nfunction unlockAccount(addr, cb) {\r\n\thost.unlockPersonalAccount(addr, 'passphrase', 1000, cb);\r\n}\r\n\r\nfunction sendTransaction(from, to, value, options, cb) {\r\n    options = options || {};\r\n\tvar fromaddr;\r\n\tvar toaddr;\r\n\t\r\n\tasync()\r\n\t.exec(function (next) {\r\n\t\tgetAccountAddress(from, next);\r\n\t})\r\n\t.then(function (addr, next) {\r\n\t\tfromaddr = addr;\r\n\t\tgetAccountAddress(to, next);\r\n\t})\r\n\t.then(function (addr, next) {\r\n\t\ttoaddr = addr;\r\n\t\tunlockAccount(fromaddr, function (err, data) {\r\n\t\t\tnext();\r\n\t\t});\r\n\t})\r\n\t.then(function (data, next) {\r\n\t\tvar txdata = {\r\n\t\t\tfrom: fromaddr,\r\n\t\t\tto: toaddr,\r\n\t\t\tvalue: value,\r\n\t\t\tgas: options.gas || 21000,\r\n\t\t\tgasPrice: options.gasPrice || 1\r\n\t\t};\r\n\t\t\r\n\t\tif (options.data)\r\n\t\t\ttxdata.data = options.data;\r\n\r\n\t\thost.sendTransaction(txdata, cb);\r\n\t})\r\n\t.error(function (err) {\r\n\t\tcb(err);\r\n\t});\r\n}\r\n\r\nfunction sendRawCall(from, to, value, data, options, cb) {\r\n    options = options || {};\r\n    \r\n    var txdata = {\r\n        from: from,\r\n\t\tto: to,\r\n        value: value,\r\n        gas: options.gas || 21000,\r\n        gasPrice: options.gasPrice || 1,\r\n\t\tdata: data\r\n    };\r\n\r\n    host.callTransaction(txdata, cb);\r\n}\r\n\r\nfunction sendCallOrInvoke(instancename, from, fnname, fnargs, value, options, cb, iscall) {\r\n\tvar toaddr = getInstanceAddress(instancename);\r\n\t\r\n\tif (!toaddr)\r\n\t\treturn cb(new Error('unknown instance: ' + instancename));\r\n\t\r\n\tvar data = toData(getInstanceContract(instancename), fnname, fnargs);\r\n\tvar tx;\r\n\t\r\n\tif (!data)\r\n\t\tif (fnname && fnname.startsWith('0x') && fnname.length === 10)\r\n\t\t\tdata = fnname;\r\n\t\telse\r\n\t\t\treturn cb(new Error('unknown function: ' + fnname));\r\n\t\r\n\tasync()\r\n\t.exec(function (next) {\r\n\t\tgetAccountAddress(from, next);\r\n\t})\r\n\t.then(function (addr, next) {\r\n\t\tif (iscall)\r\n\t\t\treturn sendRawCall(addr, toaddr, value, data, options, cb);\r\n\t\t\r\n\t\toptions.data = data;\r\n\t\t\r\n\t\tif (!options.gas)\r\n\t\t\toptions.gas = 3000000;\r\n\t\t\r\n\t\tif (iscall)\r\n\t\t\treturn sendRawCall(addr, toaddr, value, data, options, cb);\r\n\t\t\r\n\t\tsendTransaction(addr, toaddr, value, options, next);\r\n\t})\r\n\t.then(function (txhash, next) {\r\n\t\ttx = txhash;\r\n\t\tgetTransactionReceipt(txhash, 60, next);\r\n\t})\r\n\t.then(function (txr, next) {\r\n\t\tcb(null, tx);\r\n\t})\r\n\t.error(cb);\r\n}\r\n\r\nfunction sendCall(instancename, from, fnname, fnargs, value, options, cb) {\r\n\tsendCallOrInvoke(instancename, from, fnname, fnargs, value, options, cb, true)\r\n}\r\n\r\nfunction sendInvoke(instancename, from, fnname, fnargs, value, options, cb) {\r\n\tsendCallOrInvoke(instancename, from, fnname, fnargs, value, options, cb, false)\r\n}\r\n\r\nfunction getTransactionReceipt(hash, ntry, cb) {\r\n\tif (ntry <= 0)\r\n\t\treturn cb('transaction ' + hash + 'not mined');\r\n\t\r\n    host.getTransactionReceiptByHash(hash, function (err, data) {\r\n        if (err)\r\n            return cb(err, null);\r\n            \r\n        if (data)\r\n            return cb(null, data);\r\n            \r\n        setTimeout(function () {\r\n            getTransactionReceipt(hash, ntry - 1, cb);\r\n        }, 1000);\r\n    });\r\n}\r\n\r\nfunction createContract(contractname, owner, value, options, cb) {\r\n\tvar opts = {};\r\n\t\r\n\topts.gas = options.gas || 3000000;\r\n\topts.data = context.contracts[contractname].bytecode;\r\n\t\r\n\tvar name = options.name || contractname;\r\n\tvar txhash;\r\n\t\r\n\tasync()\r\n\t.exec(function (next) {\r\n\t\tsendTransaction(owner, null, value, opts, next);\r\n\t})\r\n\t.then(function (tx, next) {\r\n\t\ttxhash = tx;\r\n\t\tgetTransactionReceipt(txhash, 60, next);\r\n\t})\r\n\t.then(function (txr, next) {\r\n\t\tsaveInstance(name, contractname, txhash, txr.contractAddress);\r\n\t\tsaveContext(ctxfilename, context);\r\n\t\t\r\n\t\tcb(null, name);\t\t\r\n\t})\r\n\t.error(function (err) {\r\n\t\tcb(err);\r\n\t});\r\n}\r\n\r\nfunction findImports(path) {\r\n    return { contents: fs.readFileSync('./' + path).toString() };\r\n    // return { error: 'File not found' }\r\n}\r\n\r\nfunction compileContract(filename, name) {\r\n    var input = fs.readFileSync(filename).toString();\r\n    var sources = {};\r\n    sources[filename] = input;\r\n    var output = solc.compile({ sources: sources }, 1, findImports); // 1 activates the optimiser\r\n\r\n\tif (!name) {\r\n\t\tvar fullname = Object.keys(output.contracts)[0];\r\n\t\tvar p = fullname.lastIndexOf(':');\r\n\t\t\r\n\t\tif (p >= 0)\r\n\t\t\tname = fullname.substring(p + 1);\r\n\t\telse\r\n\t\t\tname = fullname;\r\n\t}\r\n\t\r\n\tfor (var n in output.contracts)\r\n\t\tif (n.endsWith(':' + name)) {\r\n\t\t\tvar contract = output.contracts[n];\r\n\t\t\t\r\n\t\t\tsaveContract(name, contract);\r\n\t\t\tsaveContext(ctxfilename, context);\r\n\t\t\t\r\n\t\t\treturn { name: name, contract: contract };\r\n\t\t\t\r\n\t\t}\r\n}\r\n\r\nfunction compile(args, options, cb) {\r\n\tvar filename = path.join('.', 'contracts', args[0]);\r\n\tvar name = args[1];\r\n\t\r\n\tsetHost(options.host);\r\n\t\r\n\ttry {\r\n\t\tvar result = compileContract(filename, name);\r\n\t\tcb(null, result.name);\r\n\t}\r\n\tcatch (err) {\r\n\t\tcb(err);\r\n\t}\r\n}\r\n\r\nfunction account(args, options, cb) {\r\n\tsetHost(options.host);\r\n\tgetAccountAddress(args[0], cb);\r\n}\r\n\r\nfunction accounts(args, options, cb) {\r\n\tsetHost(options.host);\r\n\thost.getAccounts(cb);\r\n}\r\n\r\nfunction number(args, options, cb) {\r\n\tsetHost(options.host);\r\n\thost.getBlockNumber(cb);\r\n};\r\n\r\nfunction block(args, options, cb) {\r\n\tsetHost(options.host);\r\n\tvar id = args[0];\r\n\t\r\n\tif (typeof id === 'number' || id.length <= 10)\r\n\t\thost.getBlockByNumber(parseInt(id), cb);\r\n\telse\r\n\t\thost.getBlockByHash(id, cb);\r\n};\r\n\r\nfunction blocks(args, options, cb) {\r\n\tsetHost(options.host);\r\n\tvar id = args[0];\r\n\t\r\n\thost.getBlocksByNumber(parseInt(id), cb);\r\n};\r\n\r\nfunction balance(args, options, cb) {\r\n\tsetHost(options.host);\r\n\t\r\n\tvar address = args[0];\r\n\t\r\n\tasync()\r\n\t.exec(function (next) {\r\n\t\tgetAccountAddress(address, next);\r\n\t})\r\n\t.then(function (addr, next) {\r\n\t\thost.getBalance(addr, next);\r\n\t})\r\n\t.then(function (balance, next) {\r\n\t\tcb(null, toNumber(balance));\r\n\t})\r\n\t.error(function (err) {\r\n\t\tcb(err);\r\n\t});\r\n}\r\n\r\nfunction balances(args, options, cb) {\r\n\tsetHost(options.host);\r\n\t\r\n\tasync()\r\n\t.exec(function (next) {\r\n\t\thost.getAccounts(next);\r\n\t}).map(function (data, next) {\r\n\t\thost.getBalance(data, function (err, balance) {\r\n\t\t\tcb(err, { account: data, balance: balance });\r\n\t\t});\r\n\t}).then(function (data, next) {\r\n\t\tcb(null, data);\r\n\t}).error(function (err) {\r\n\t\tcb(err);\r\n\t});\r\n}\r\n\r\nfunction deploy(args, options, cb) {\r\n\tsetHost(options.host);\r\n\t\r\n\tcreateContract(args[0], args[1], args[2], options, cb);\r\n}\r\n\r\nfunction fns(args, options, cb) {\r\n\tvar name = args[0];\r\n\t\r\n\tif (!context.contracts[name])\r\n\t\treturn cb('unknown contract: ' + name);\r\n\t\r\n\tcb(null, Object.keys(context.contracts[name].functionHashes));\r\n}\r\n\r\nfunction transfer(args, options, cb) {\r\n\tsetHost(options.host);\r\n\t\r\n\tvar from = args[0];\r\n\tvar to = args[1];\r\n\tvar value = args[2];\r\n\tvar tx;\r\n\t\r\n\tasync()\r\n\t.exec(function (next) {\r\n\t\tsendTransaction(from, to, value, options, next);\r\n\t})\r\n\t.then(function (txhash, next) {\r\n\t\ttx = txhash;\r\n\t\tgetTransactionReceipt(txhash, 60, next);\r\n\t})\r\n\t.then(function (txr, next) {\r\n\t\tcb(null, tx);\r\n\t})\r\n\t.error(function (err) {\r\n\t\tcb(err);\r\n\t});\r\n}\r\n\r\nfunction instance(args, options, cb) {\r\n\tvar name = args[0];\r\n\tcb(null, getInstance(name));\r\n}\r\n\r\nfunction call(args, options, cb) {\r\n\tsetHost(options.host);\r\n\t\r\n\tvar name = args[0];\r\n\tvar from = args[1];\r\n\tvar fnname = args[2];\r\n\tvar fnargs = args[3] ? args[3].split(';') : [];\r\n\tvar value = args[4] ? toNumber(args[4]) : 0;\r\n\t\r\n\tsendCall(name, from, fnname, fnargs, value, options, cb);\r\n}\r\n\r\nfunction invoke(args, options, cb) {\r\n\tsetHost(options.host);\r\n\t\r\n\tvar name = args[0];\r\n\tvar from = args[1];\r\n\tvar fnname = args[2];\r\n\tvar fnargs = args[3] ? args[3].toString().split(';') : [];\r\n\tvar value = args[4] ? toNumber(args[4]) : 0;\r\n\t\r\n\tsendInvoke(name, from, fnname, fnargs, value, options, cb);\r\n}\r\n\r\nmodule.exports = {\r\n\tcompile: compile,\r\n\tdeploy: deploy,\r\n\tinstance: instance,\r\n\tfns: fns,\r\n\tcall: call,\r\n\tinvoke: invoke,\r\n\r\n\ttransfer: transfer,\r\n\t\r\n\taccount: account,\r\n\taccounts: accounts,\r\n\tbalance: balance,\r\n\tbalances: balances,\r\n\t\r\n\tnumber: number,\r\n\tblock: block,\r\n\tblocks: blocks\r\n};\r\n\r\n"
  },
  {
    "path": "old/simple/lib/contexts.js",
    "content": "\r\nfunction Context() {\r\n\tvar data = {\r\n\t\tcontracts: {}\r\n\t};\r\n\t\r\n\tthis.contract = function (name, value) {\r\n\t\tif (value !== undefined)\r\n\t\t\tdata.contracts[name] = value;\r\n\t\telse\r\n\t\t\treturn data.contracts[name];\r\n\t};\r\n}\r\n\r\nfunction createContext() {\r\n\treturn new Context();\r\n}\r\n\r\nmodule.exports = {\r\n\tcontext: createContext\r\n};"
  },
  {
    "path": "old/simple/lib/executors.js",
    "content": "\r\nvar fs = require('fs');\r\n\r\nvar rskapi = require('rskapi');\r\nvar simpledsl = require('simpledsl');\r\nvar solc = require('solc');\r\nvar chalk = require('chalk');\r\n\r\nvar utils = require('./utils');\r\n\r\nvar DEFAULT_HOST = \"http://localhost:8545\";\r\n\r\nfunction findImports(path) {\r\n    return { contents: fs.readFileSync('./' + path).toString() };\r\n    // return { error: 'File not found' }\r\n}\r\n\r\nfunction compileContract(filename) {\r\n    var input = fs.readFileSync(filename).toString();\r\n    var sources = {};\r\n    sources[filename] = input;\r\n\t\r\n    var output = solc.compile({ sources: sources }, 1, findImports); // 1 activates the optimiser\r\n\r\n\treturn output.contracts;\r\n}\r\n\r\nfunction toNumber(value) {\r\n\tif (typeof value === 'string' && value.startsWith('0x'))\r\n\t\treturn value;\r\n\t\r\n\treturn parseInt(value);\r\n}\r\n\r\nfunction Executor () {\r\n\tvar self = this;\r\n\tvar logger = console;\r\n\tvar dsl = simpledsl.dsl({ comment: '#' });\r\n\r\n\tvar value;\r\n\tvar host;\r\n\tvar contracts = {};\r\n\tvar instances = {};\r\n\tvar accounts = [];\r\n\tvar logging = false;\r\n\tvar from;\r\n\t\r\n\tregister('logging', function (cmd, next) {\r\n\t\tlogging = evaluate(cmd.args);\r\n\t\tnext(null, null);\r\n\t});\r\n\t\r\n\tregister('message', function (cmd, next) {\r\n\t\tlogger.log.apply(logger, expand(cmd.args));\r\n\t\tnext(null, null);\r\n\t});\r\n\t\r\n\tregister('dump', function (cmd, next) {\r\n\t\tlogger.log(evaluate(cmd.args));\r\n\t\tnext(null, null);\r\n\t});\r\n\t\r\n\tregister('evaluate', function (cmd, next) {\r\n\t\tvar result = evaluate(cmd.args);\r\n\t\tself.value(result);\r\n\t\tnext(null, result);\r\n\t});\r\n\t\r\n\tregister('assert', function (cmd, next) {\r\n\t\tvar result = evaluate(cmd.args);\r\n\t\t\r\n\t\tif (!result)\r\n\t\t\tthrow new Error('failed assertion: ' + cmd.args.join(' '));\r\n\t\telse\r\n\t\t\tnext(null, result);\r\n\t});\r\n\t\r\n\tregister('compile', function (cmd, next) {\r\n\t\tvar result = compileContract(expand(cmd.args)[0]);\r\n\t\t\r\n\t\tfor (var n in result) {\r\n\t\t\tself.contract(n, result[n]);\r\n\t\t\t\r\n\t\t\tvar p = n.lastIndexOf(':');\r\n\t\t\t\r\n\t\t\tif (p >= 0)\r\n\t\t\t\tself.contract(n.substring(p + 1), result[n]);\r\n\t\t}\r\n\t\t\r\n\t\tnext(null, null);\r\n\t});\r\n\t\r\n\tregister('accounts', function (cmd, next) {\r\n\t\tself.host().getAccounts(function (err, data) {\r\n\t\t\tif (err)\r\n\t\t\t\tnext(err, null);\r\n\t\t\telse {\r\n\t\t\t\taccounts = data;\r\n\t\t\t\tlog('accounts', data);\r\n\t\t\t\tnext(null, data);\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n\t\r\n\tregister('balance', function (cmd, next) {\r\n\t\tself.host().getBalance(expand(cmd.args)[0], function (err, data) {\r\n\t\t\tif (err)\r\n\t\t\t\tnext(err, null);\r\n\t\t\telse {\r\n\t\t\t\tvalue = data;\r\n\t\t\t\tnext(null, data);\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n\t\r\n\tregister('unlock', function (cmd, next) {\r\n\t\tvar args = expand(cmd.args);\r\n\r\n\t\tlog('unlock account', args[0]);\r\n\t\r\n\t\tself.host().unlockPersonalAccount(args[0], args[1], args[2], function (err, data) {\r\n\t\t\tif (err)\r\n\t\t\t\tnext(err, null);\r\n\t\t\telse {\r\n\t\t\t\tvalue = data;\r\n\t\t\t\tnext(null, data);\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n\t\r\n\tregister('host', function (cmd, next) {\r\n\t\thost = rskapi.host(expand(cmd.args)[0]);\r\n\t\tnext(null, null);\r\n\t});\r\n\t\r\n\tregister('transfer', function (cmd, next) {\r\n\t\tvar host = self.host();\r\n\t\tvar args = expand(cmd.args);\r\n\t\t\r\n\t\tvar from = args[0];\r\n\t\tvar to = args[1];\r\n\t\tvar value = args[2];\r\n\t\t\r\n\t\tvar tx;\r\n\t\t\r\n\t\tvar txdata = {\r\n\t\t\tfrom: from,\r\n\t\t\tto: to,\r\n\t\t\tvalue: toNumber(value),\r\n\t\t\tgas: 3000000,\r\n\t\t\tgasPrice: 0\r\n\t\t};\r\n\t\t\r\n\t\tlog('transaction data', txdata);\r\n\r\n\t\thost.sendTransaction(txdata, function (err, txhash) {\r\n\t\t\tif (err)\r\n\t\t\t\treturn next(err, null);\r\n\t\t\t\r\n\t\t\tlog('transaction hash', txhash);\r\n\t\t\t\r\n\t\t\tgetTransactionReceipt(txhash, 60, function (err, txreceipt) {\r\n\t\t\t\tif (err)\r\n\t\t\t\t\treturn next(err, null);\r\n\t\t\t\r\n\t\t\t\tlog('transaction receipt', txreceipt);\r\n\t\t\t\t\r\n\t\t\t\tvalue = txhash;\r\n\t\t\t\t\r\n\t\t\t\tnext(null, txhash);\r\n\t\t\t})\r\n\t\t});\r\n\t});\r\n\t\r\n\tregister('from', function (cmd, next) {\r\n\t\tfrom = expand(cmd.args)[0];\r\n\t\tnext(null, null);\r\n\t});\r\n\r\n\tregister('deploy', function (cmd, next) {\r\n\t\tvar host = self.host();\r\n\t\tvar args = cmd.args;\r\n\t\t\r\n\t\tvar contractname = args[0];\r\n\t\tvar instancename = args[1] || contractname;\r\n\t\tvar contract = contracts[contractname];\r\n\t\t\r\n\t\tvar from = self.from();\r\n\t\tvar to = '0x00';\r\n\t\tvar bytecode = contract.bytecode;\r\n\r\n\t\tvar fnargs = expand(args.slice(2));\r\n\t\tvar data = bytecode + toData(contract, null, fnargs);\r\n\t\t\r\n\t\tvar tx;\r\n\t\t\r\n\t\tvar txdata = {\r\n\t\t\tfrom: from,\r\n\t\t\t// to: to,\r\n\t\t\tvalue: 0,\r\n\t\t\tdata: data,\r\n\t\t\tgas: 2000000,\r\n\t\t\tgasPrice: 0\r\n\t\t};\r\n\r\n\t\tlog('transaction data', txdata);\r\n\r\n\t\thost.sendTransaction(txdata, function (err, txhash) {\r\n\t\t\tif (err)\r\n\t\t\t\treturn next(err, null);\r\n\t\t\t\r\n\t\t\tlog('transaction hash', txhash);\r\n\t\t\t\r\n\t\t\tgetTransactionReceipt(txhash, 60, function (err, txreceipt) {\r\n\t\t\t\tif (err)\r\n\t\t\t\t\treturn next(err, null);\r\n\t\t\t\r\n\t\t\t\tlog('transaction receipt', txreceipt);\r\n\t\t\t\t\r\n\t\t\t\tinstances[instancename] = {\r\n\t\t\t\t\ttransactionHash: txhash,\r\n\t\t\t\t\tcontractAddress: txreceipt.contractAddress,\r\n\t\t\t\t\tblockHash: txreceipt.blockHash,\r\n\t\t\t\t\tblockNumber: parseInt(txreceipt.blockNumber),\r\n\t\t\t\t\tcontractName: args[0]\r\n\t\t\t\t};\r\n\t\t\t\t\r\n\t\t\t\tvalue = txreceipt.contractAddress;\r\n\t\t\t\t\r\n\t\t\t\tnext(null, txreceipt.contractAddress);\r\n\t\t\t})\r\n\t\t});\r\n\t});\r\n\t\r\n\tregister('call', function (cmd, next) {\r\n\t\tvar host = self.host();\r\n\t\tvar args = cmd.args;\r\n\t\t\r\n\t\tvar instancename = args[0];\r\n\t\tvar instance = instances[instancename];\r\n\t\tvar contractname = instance.contractName;\r\n\t\tvar contract = contracts[contractname];\r\n\r\n\t\tvar fnname = args[1];\r\n\t\t\r\n\t\tvar fnargs = expand(args.slice(2));\r\n\t\t\r\n\t\tvar from = self.from();\r\n\t\tvar to = instance.contractAddress;\r\n\t\tvar data = toData(contract, fnname, fnargs);\r\n\t\t\r\n\t\tvar tx;\r\n\t\t\r\n\t\tvar txdata = {\r\n\t\t\tfrom: from,\r\n\t\t\tto: to,\r\n\t\t\tvalue: 0,\r\n\t\t\tdata: data,\r\n\t\t\tgas: 3000000,\r\n\t\t\tgasPrice: 0\r\n\t\t};\r\n\r\n\t\tlog('transaction data', txdata);\r\n\r\n\t\thost.callTransaction(txdata, function (err, result) {\r\n\t\t\tif (err)\r\n\t\t\t\treturn next(err, null);\r\n\t\t\t\r\n\t\t\tlog('call result', result);\r\n\t\t\t\r\n\t\t\tresult = utils.decodeValue(result);\r\n\t\t\t\r\n\t\t\tvalue = result;\r\n\t\t\t\r\n\t\t\tnext(null, result);\r\n\t\t});\r\n\t});\r\n\t\r\n\tregister('invoke', function (cmd, next) {\r\n\t\tvar host = self.host();\r\n\t\tvar args = cmd.args;\r\n\t\t\r\n\t\tvar instancename = args[0];\r\n\t\tvar instance = instances[instancename];\r\n\t\tvar contractname = instance.contractName;\r\n\t\tvar contract = contracts[contractname];\r\n\r\n\t\tvar fnname = args[1];\r\n\t\t\r\n\t\tvar fnargs = expand(args.slice(2));\r\n\t\t\r\n\t\tvar from = self.from();\r\n\t\tvar to = instance.contractAddress;\r\n\t\tvar data = toData(contract, fnname, fnargs);\r\n\t\t\r\n\t\tvar tx;\r\n\t\t\r\n\t\tvar txdata = {\r\n\t\t\tfrom: from,\r\n\t\t\tto: to,\r\n\t\t\tvalue: 0,\r\n\t\t\tdata: data,\r\n\t\t\tgas: 3000000,\r\n\t\t\tgasPrice: 0\r\n\t\t};\r\n\r\n\t\tlog('transaction data', txdata);\r\n\r\n\t\thost.sendTransaction(txdata, function (err, txhash) {\r\n\t\t\tif (err)\r\n\t\t\t\treturn next(err, null);\r\n\t\t\t\r\n\t\t\tlog('transaction hash', txhash);\r\n\t\t\t\r\n\t\t\tgetTransactionReceipt(txhash, 60, function (err, txreceipt) {\r\n\t\t\t\tif (err)\r\n\t\t\t\t\treturn next(err, null);\r\n\t\t\t\r\n\t\t\t\tlog('transaction receipt', txreceipt);\r\n\t\t\t\t\r\n\t\t\t\tvalue = txhash;\r\n\t\t\t\t\r\n\t\t\t\tnext(null, txhash);\r\n\t\t\t})\r\n\t\t});\r\n\t});\r\n\t\r\n\tthis.from = function (value) {\r\n\t\tif (value != null)\r\n\t\t\treturn from = value;\r\n\t\t\r\n\t\tif (from && accounts && accounts[from])\r\n\t\t\treturn accounts[from];\r\n\t\t\r\n\t\tif (from)\r\n\t\t\treturn from;\r\n\t\t\r\n\t\tif (accounts)\r\n\t\t\treturn accounts[0];\r\n\t\t\r\n\t\tthrow new Error('unknown sender');\r\n\t}\r\n\t\r\n\tthis.logging = function (value) {\r\n\t\tlogging = value;\r\n\t}\r\n\t\r\n\tthis.contract = function (name, value) {\r\n\t\tif (value === undefined)\r\n\t\t\treturn contracts[name];\r\n\t\telse\r\n\t\t\tcontracts[name] = value;\r\n\t}\r\n\t\r\n\tthis.value = function (newvalue) {\r\n\t\tif (newvalue === undefined)\r\n\t\t\treturn value;\r\n\t\telse\r\n\t\t\tvalue = newvalue;\r\n\t}\r\n\t\r\n\tthis.use = function (name, value) {\r\n\t\tif (name === 'logger')\r\n\t\t\tlogger = value;\r\n\t};\r\n\t\r\n\tthis.execute = function (txt, cb) {\r\n\t\tdsl.execute(txt, cb);\r\n\t};\r\n\t\r\n\tthis.executeFile = function (filename, cb) {\r\n\t\tdsl.executeFile(filename, cb);\r\n\t};\r\n\t\r\n\tthis.evaluate = function (expr) {\r\n\t\treturn evaluate(expr);\r\n\t}\r\n\t\r\n\tthis.host = function (value) {\r\n\t\tif (value)\r\n\t\t\thost = rskapi.host(value);\r\n\t\t\r\n\t\tif (host)\r\n\t\t\treturn host;\r\n\t\t\r\n\t\thost = rskapi.host(DEFAULT_HOST);\r\n\t\t\r\n\t\treturn host;\r\n\t}\r\n\t\r\n\tfunction register(name, fn) {\r\n\t\tdsl.register(name, function (cmd, next) {\r\n\t\t\ttry {\r\n\t\t\t\tfn(cmd, next);\r\n\t\t\t}\r\n\t\t\tcatch (ex) {\r\n\t\t\t\tnext(ex, null);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\t\r\n\tfunction evaluate(args) {\r\n\t\tvar expr;\r\n\t\t\r\n\t\tif (Array.isArray(args))\r\n\t\t\texpr = args.join(' ');\r\n\t\telse\r\n\t\t\texpr = args;\r\n\t\t\r\n\t\treturn eval(expr);\r\n\t}\r\n\t\r\n\tfunction expand(args) {\r\n\t\tif (Array.isArray(args))\r\n\t\t\treturn normalize(args).map(arg => expand(arg));\r\n\t\t\r\n\t\treturn evaluate(args);\r\n\t}\r\n\t\r\n\tfunction normalize(items) {\r\n\t\tvar result = [];\r\n\t\tvar ni = items.length;\r\n\t\tvar instring = false;\r\n\t\t\r\n\t\tfor (var k = 0; k < ni; k++) {\r\n\t\t\tvar item = items[k];\r\n\t\t\t\r\n\t\t\tif (instring)\r\n\t\t\t\tresult[result.length - 1] += ' ' + item;\r\n\t\t\telse\r\n\t\t\t\tresult.push(item);\r\n\t\t\t\r\n\t\t\tif (item.startsWith('\"'))\r\n\t\t\t\tinstring = true;\r\n\t\t\t\r\n\t\t\tif (item.endsWith('\"'))\r\n\t\t\t\tinstring = false;\r\n\t\t}\r\n\t\t\r\n\t\treturn result;\r\n\t}\r\n\t\r\n\tfunction log(message, value) {\r\n\t\tif (!logging)\r\n\t\t\treturn;\r\n\t\t\r\n\t\tif (value === undefined)\r\n\t\t\treturn console.log(chalk.green(message));\r\n\t\t\r\n\t\tif (typeof value !== 'object')\r\n\t\t\treturn console.log(chalk.green(message), chalk.green(value));\r\n\t\t\r\n\t\tconsole.log(chalk.green(message));\r\n\t\tconsole.log(chalk.green(JSON.stringify(value, null, 4)));\r\n\t}\r\n\t\r\n\tfunction toData(contract, fnname, fnargs) {\r\n\t\tif (!fnname)\r\n\t\t\treturn utils.encodeArguments(fnargs);\r\n\t\t\r\n\t\treturn toFunctionHash(contract, fnname) + utils.encodeArguments(fnargs);\r\n\t}\r\n\t\r\n\tfunction toFunctionHash(contract, fnname) {\r\n\t\tif (contract.functionHashes[fnname])\r\n\t\t\treturn contract.functionHashes[fnname];\r\n\t\t\r\n\t\tfor (var n in contract.functionHashes)\r\n\t\t\tif (n.startsWith(fnname + '('))\r\n\t\t\t\treturn contract.functionHashes[n];\r\n\t}\r\n\r\n\tfunction getTransactionReceipt(hash, ntry, cb) {\r\n\t\tvar host = self.host();\r\n\t\t\r\n\t\tif (ntry <= 0)\r\n\t\t\treturn cb(new Error('transaction ' + hash + ' not mined'));\r\n\t\t\r\n\t\thost.getTransactionReceiptByHash(hash, function (err, data) {\r\n\t\t\tif (err)\r\n\t\t\t\treturn cb(err, null);\r\n\t\t\t\t\r\n\t\t\tif (data)\r\n\t\t\t\treturn cb(null, data);\r\n\t\t\t\t\r\n\t\t\tsetTimeout(function () {\r\n\t\t\t\tgetTransactionReceipt(hash, ntry - 1, cb);\r\n\t\t\t}, 1000);\r\n\t\t});\r\n\t}\r\n\t\r\n}\r\n\r\nfunction createExecutor() {\r\n\treturn new Executor();\r\n}\r\n\r\nmodule.exports = {\r\n\texecutor: createExecutor\r\n};\r\n\r\n"
  },
  {
    "path": "old/simple/lib/utils.js",
    "content": "\r\nfunction repeatFunction(fn, ntimes, cb) {\r\n\tif (ntimes <= 0)\r\n\t\treturn cb(null, null);\r\n\t\r\n\tfn(function (err, data) {\r\n\t\tif (err)\r\n\t\t\treturn cb(err);\r\n\t\t\r\n\t\tsetTimeout(function () {\r\n\t\t\trepeatFunction(fn, ntimes - 1, cb);\r\n\t\t}, 0);\r\n\t});\r\n}\r\n\r\nfunction fillTo64(str) {\r\n\tif (str.length % 1)\r\n\t\tstr += '0';\r\n\t\r\n\twhile (str.length % 64)\r\n\t\tstr += '00';\r\n\t\r\n\treturn str;\r\n}\r\n\r\nfunction stringToHex(str) {\r\n\tvar hex = Buffer.from(str).toString('hex');\r\n\t\r\n\tif (hex.length % 1)\r\n\t\thex = '0' + hex;\r\n\t\r\n\treturn hex;\r\n}\r\n\r\nfunction encodeHexaValue(arg) {\r\n\tif (arg.startsWith('0x'))\r\n\t\targ = arg.substring(2);\r\n\t\r\n\twhile (arg.length < 64)\r\n\t\targ = '0' + arg;\r\n\t\r\n\treturn arg;\r\n}\r\n\r\nfunction encodeStringArgument(arg, ending) {\r\n\tvar result = [];\r\n\t\r\n\tresult.push(encodeIntegerArgument(ending));\r\n\t\r\n\tvar encoded = encodeIntegerArgument(arg.length) + fillTo64(stringToHex(arg));\r\n\t\r\n\tresult.push(encoded);\r\n\t\r\n\treturn result;\r\n}\r\n\r\nfunction encodeStringValue(arg) {\r\n\treturn encodeIntegerArgument(arg.length) + fillTo64(stringToHex(arg));\r\n\t\r\n\treturn result;\r\n}\r\n\r\nfunction encodeValue(arg) {\r\n    if (typeof arg === 'string')\r\n\t\tif (arg.startsWith('0x'))\r\n\t\t\treturn encodeHexaValue(arg);\r\n\t\telse\r\n\t\t\treturn encodeStringValue(arg);\r\n    else\r\n        return encodeIntegerArgument(arg);\r\n}\r\n\r\nfunction encodeArguments(args) {\r\n\tvar result = '';\r\n\tvar varresult = '';\r\n\t\r\n\targs.forEach(function (arg) {\r\n\t\tif (typeof arg === 'string') {\r\n\t\t\tif (arg.startsWith('0x'))\r\n\t\t\t\tresult += encodeHexaValue(arg);\r\n\t\t\telse {\r\n\t\t\t\tvar encoded = encodeStringArgument(arg, args.length * 32 + varresult.length / 2);\r\n\t\t\t\tresult += encoded[0];\r\n\t\t\t\tvarresult += encoded[1];\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t\tresult += encodeIntegerArgument(arg);\r\n\t});\r\n\t\r\n\treturn result + varresult;\r\n}\r\n\r\nfunction hexToString(hex) {\r\n\tvar str = '';\r\n\t\r\n\tfor (var k = 0; k < hex.length; k += 2)\r\n\t\tstr += String.fromCharCode(parseInt(hex.substring(k, k + 2), 16));\r\n\t\r\n\treturn str;\r\n}\r\n\r\nfunction decodeValue(encoded) {\r\n\tif (encoded.substring(0,2) === '0x')\r\n\t\tencoded = encoded.substring(2);\r\n\t\r\n\tif (encoded.length > 64) {\r\n\t\tvar position = decodeValue(encoded.substring(0, 64)) * 2;\r\n\t\tvar length = decodeValue(encoded.substring(position, position + 64)) * 2;\r\n\t\t\r\n\t\treturn hexToString(encoded.substring(position + 64, position + 64 + length));\r\n\t}\r\n\r\n\treturn parseInt(encoded, 16);\r\n}\r\n\r\nfunction decodeValues(encoded) {\r\n\tif (encoded.substring(0,2) === '0x')\r\n\t\tencoded = encoded.substring(2);\r\n\t\r\n\tvar values = [];\r\n\t\r\n\twhile (encoded.length >= 64) {\r\n\t\tvalues.push(decodeValue(encoded.substring(0, 64)));\r\n\t\tencoded = encoded.substring(64);\r\n\t}\r\n\t\r\n\treturn values;\r\n}\r\n\r\nfunction encodeIntegerArgument(arg) {\r\n\tvar encoded = arg.toString(16);\r\n\t\r\n\tif (arg < 0)\r\n\t\twhile (encoded.length < 64)\r\n\t\t\tencoded = 'f' + encoded;\r\n\telse\r\n\t\twhile (encoded.length < 64)\r\n\t\t\tencoded = '0' + encoded;\r\n\t\t\r\n\treturn encoded;\r\n}\r\n\r\nmodule.exports = {\r\n\trepeat: repeatFunction,\r\n\t\r\n\tencodeArguments: encodeArguments,\r\n\r\n    encodeValue: encodeValue,\r\n    \r\n\tdecodeValue: decodeValue,\r\n\tdecodeValues: decodeValues\r\n}\r\n\r\n"
  },
  {
    "path": "old/simple/message.eth",
    "content": "\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling message.sol\"\r\ncompile \"./contracts/message.sol\"\r\nmessage \"message.sol compiled\"\r\n\r\n# dump contracts.Message.functionHashes\r\ndump contracts.Message.interface\r\n\r\ndeploy Message message1 \"hello\"\r\n\r\nmessage \"contract deployed to address\" value\r\n\r\nmessage \"retrieving message\"\r\ncall message1 message\r\nmessage \"message\" value\r\nassert value === \"hello\"\r\n\r\nmessage \"changing message\"\r\ninvoke message1 setMessage \"Hello, World\"\r\n\r\nmessage \"retrieving message\"\r\ncall message1 message\r\n\r\nmessage \"message\" value\r\n\r\nassert value === \"Hello, World\""
  },
  {
    "path": "old/simple/package.json",
    "content": "{\n  \"name\": \"simple-solidity-contracts\",\n  \"private\": true,\n  \"version\": \"0.0.1\",\n  \"description\": \"Simple Solidity Contracts\",\n  \"main\": \"console.js\",\n  \"scripts\": {\n    \"test\": \"simpleunit test -r\"\n  },\n  \"author\": \"\",\n  \"license\": \"MIT\",\n  \"dependencies\": {\n    \"chalk\": \"^2.3.0\",\n    \"rskapi\": \"0.0.6\",\n    \"simpleargs\": \"0.0.3\",\n    \"simpleasync\": \"0.0.8\",\n    \"simpledsl\": \"0.0.3\",\n    \"solc\": \"0.4.18\"\n  },\n  \"engines\": {\n    \"node\": \">= 6.0.0\"\n  },\n  \"devDependencies\": {\n    \"solc\": \"0.4.18\",\n    \"simpleunit\": \"0.0.7\"\n  }\n}\n"
  },
  {
    "path": "old/simple/rsksend.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# set RSK host\r\nhost \"http://localhost:4444\"\r\n\r\n# retrieve accounts from host\r\naccounts\r\n\r\nassert accounts\r\nassert accounts.length\r\n\r\nmessage \"Second account is\" accounts[1]\r\nbalance accounts[1]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Sending transaction...\"\r\nsend accounts[1] accounts[3] 1000000\r\n\r\nmessage \"Third account is\" accounts[2]\r\nbalance accounts[2]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Sending transaction...\"\r\nsend accounts[2] accounts[0] 1000000\r\n"
  },
  {
    "path": "old/simple/rsktransfer.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# set RSK host\r\nhost \"http://localhost:4444\"\r\n\r\n# retrieve accounts from host\r\naccounts\r\n\r\nassert accounts\r\nassert accounts.length\r\n\r\nmessage \"Fourth account is\" accounts[3]\r\nbalance accounts[4]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"First account is\" accounts[1]\r\nbalance accounts[0]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Transfering...\"\r\ntransfer accounts[4] accounts[0] 10000000000000\r\n\r\nmessage \"Second account is\" accounts[1]\r\nbalance accounts[1]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Transfering...\"\r\ntransfer accounts[4] accounts[1] 10000000000000\r\n\r\nmessage \"Third account is\" accounts[2]\r\nbalance accounts[2]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Transfering...\"\r\ntransfer accounts[4] accounts[2] 10000000000000\r\n\r\nmessage \"Fourth account is\" accounts[3]\r\nbalance accounts[3]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Transfering...\"\r\ntransfer accounts[4] accounts[3] 10000000000000\r\n"
  },
  {
    "path": "old/simple/run.js",
    "content": "\r\nvar executor = require('./lib/executors').executor();\r\n\r\nvar path = require('path');\r\nvar config = require('./config.json');\r\n\r\nvar sargs = require('simpleargs');\r\n\r\nsargs\r\n    .define('h', 'host', config.host, 'Host JSON RPC entry point')\r\n    .define('f', 'from', config.from, 'From account address or number')\r\n\t.define('l', 'logging', false, 'Enable logging', { flag: true })\r\n\t\r\nvar options = sargs(process.argv.slice(2));\r\nvar args = options._;\r\n\r\nif (options.host)\r\n\texecutor.host(options.host);\r\n\r\nif (options.from != null)\r\n\texecutor.from(options.from);\r\n\r\nif (options.logging)\r\n\texecutor.logging(options.logging);\r\n\t\r\nfunction normalize(filename) {\r\n\tvar ext = path.extname(filename);\r\n\t\r\n\tif (!ext || ext.length == 0)\r\n\t\treturn filename + '.eth';\r\n\t\r\n\treturn filename;\r\n}\r\n\r\nvar cmdfile = normalize(process.argv[2]);\r\n\r\nexecutor.executeFile(cmdfile, function (err, data) {\r\n\tif (err)\r\n\t\tconsole.error(err);\r\n});"
  },
  {
    "path": "old/simple/test/assert.js",
    "content": "\r\nvar executors = require('../lib/executors');\r\n\r\nexports['assert true'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.async();\r\n\t\r\n\texecutor.execute('assert true', function (err, data) {\r\n\t\ttest.ok(!err);\r\n\t\ttest.equal(data, true);\r\n\t\ttest.done();\r\n\t});\r\n}\r\n\r\nexports['assert false'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.async();\r\n\t\r\n\texecutor.execute('assert false', function (err, data) {\r\n\t\ttest.ok(err);\r\n\t\ttest.equal(err.toString(), 'Error: failed assertion: false');\r\n\t\ttest.ok(!data);\r\n\t\ttest.done();\r\n\t});\r\n}\r\n"
  },
  {
    "path": "old/simple/test/compile.js",
    "content": "\r\nvar executors = require('../lib/executors');\r\n\r\nexports['compile empty contract'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.async();\r\n\t\r\n\texecutor.execute('compile \"./contracts/empty.sol\"', function (err, data) {\r\n\t\tif (err)\r\n\t\t\tconsole.error(err);\r\n\t\t\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(executor.contract('./contracts/empty.sol:Empty'));\r\n\t\ttest.ok(executor.contract('Empty'));\r\n\t\ttest.done();\r\n\t});\r\n}\r\n\r\nexports['compile two contracts'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.async();\r\n\t\r\n\texecutor.execute('compile \"./contracts/foobar.sol\"', function (err, data) {\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(executor.contract('./contracts/foobar.sol:Foo'));\r\n\t\ttest.ok(executor.contract('Foo'));\r\n\t\ttest.ok(executor.contract('./contracts/foobar.sol:Bar'));\r\n\t\ttest.ok(executor.contract('Bar'));\r\n\t\ttest.done();\r\n\t});\r\n}\r\n"
  },
  {
    "path": "old/simple/test/contexts.js",
    "content": "\r\nvar contexts = require('../lib/contexts');\r\n\r\nexports['unknown contract'] = function (test) {\r\n\tvar context = contexts.context();\r\n\t\r\n\ttest.equal(context.contract('foo'), null);\r\n};\r\n\r\nexports['set and get contract'] = function (test) {\r\n\tvar context = contexts.context();\r\n\tvar contract = { name: 'foo' };\r\n\t\r\n\tcontext.contract('foo', contract);\r\n\t\r\n\ttest.deepEqual(context.contract('foo'), contract);\r\n};\r\n"
  },
  {
    "path": "old/simple/test/evaluate.js",
    "content": "\r\nvar executors = require('../lib/executors');\r\n\r\nexports['evaluate true'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.async();\r\n\t\r\n\texecutor.execute('evaluate true', function (err, data) {\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(data === true);\r\n\t\ttest.ok(executor.value() === true);\r\n\t\ttest.done();\r\n\t});\r\n}\r\n\r\nexports['evaluate false'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.async();\r\n\t\r\n\texecutor.execute('evaluate false', function (err, data) {\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(data === false);\r\n\t\ttest.ok(executor.value() === false);\r\n\t\ttest.done();\r\n\t});\r\n}\r\n\r\nexports['evaluate comparison'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.async();\r\n\t\r\n\texecutor.execute('evaluate 1 > 0', function (err, data) {\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(data === true);\r\n\t\ttest.ok(executor.value() === true);\r\n\t\ttest.done();\r\n\t});\r\n}\r\n\r\nexports['evaluate false comparison'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.async();\r\n\t\r\n\texecutor.execute('evaluate 1 > 2', function (err, data) {\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(data === false);\r\n\t\ttest.ok(executor.value() === false);\r\n\t\ttest.done();\r\n\t});\r\n}\r\n\r\nexports['evaluate comparison without spaces'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.async();\r\n\t\r\n\texecutor.execute('evaluate 1>0', function (err, data) {\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(data === true);\r\n\t\ttest.ok(executor.value() === true);\r\n\t\ttest.done();\r\n\t});\r\n}\r\n\r\nexports['evaluate value'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.async();\r\n\t\r\n\texecutor.execute(['evaluate 1 + 2', 'evaluate value'], function (err, data) {\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(data === 3);\r\n\t\ttest.ok(executor.value() === 3);\r\n\t\ttest.done();\r\n\t});\r\n}\r\n"
  },
  {
    "path": "old/simple/test/executors.js",
    "content": "\r\nvar executors = require('../lib/executors');\r\n\r\nexports['executor as object'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.ok(executor);\r\n\ttest.equal(typeof executor, 'object');\r\n};\r\n\r\nexports['execute message'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\ttest.async();\r\n\t\r\n\texecutor.use('logger', {\r\n\t\tlog: function () {\r\n\t\t\ttest.ok(arguments);\r\n\t\t\ttest.equal(arguments[0], \"hello\");\r\n\t\t\ttest.equal(arguments[1], \"world\");\r\n\t\t}\r\n\t}); \r\n\t\r\n\texecutor.execute('message \"hello\" \"world\"', function (err, data) {\r\n\t\tif (err)\r\n\t\t\tconsole.error(err);\r\n\t\t\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(!data);\r\n\t\ttest.done();\r\n\t});\r\n};\r\n\r\nexports['execute message with evaluated argument'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\ttest.async();\r\n\t\r\n\texecutor.use('logger', {\r\n\t\tlog: function () {\r\n\t\t\ttest.ok(arguments);\r\n\t\t\ttest.equal(arguments[0], 3);\r\n\t\t}\r\n\t}); \r\n\t\r\n\texecutor.execute('message 1+2', function (err, data) {\r\n\t\tif (err)\r\n\t\t\tconsole.error(err);\r\n\t\t\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(!data);\r\n\t\ttest.done();\r\n\t});\r\n};\r\n\r\nexports['execute message with string argument'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\ttest.async();\r\n\t\r\n\texecutor.use('logger', {\r\n\t\tlog: function () {\r\n\t\t\ttest.ok(arguments);\r\n\t\t\ttest.equal(arguments[0], \"hello\");\r\n\t\t}\r\n\t}); \r\n\t\r\n\texecutor.execute('message \"hello\"', function (err, data) {\r\n\t\tif (err)\r\n\t\t\tconsole.error(err);\r\n\t\t\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(!data);\r\n\t\ttest.done();\r\n\t});\r\n};\r\n\r\nexports['execute dump'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\ttest.async();\r\n\t\r\n\texecutor.use('logger', {\r\n\t\tlog: function () {\r\n\t\t\ttest.ok(arguments);\r\n\t\t\ttest.deepEqual(arguments[0], { name: 'Adam', age: 800 });\r\n\t\t}\r\n\t}); \r\n\t\r\n\texecutor.execute(['evaluate new Object({ name: \"Adam\", age: 800 })', 'dump value'], function (err, data) {\r\n\t\tif (err)\r\n\t\t\tconsole.error(err);\r\n\t\t\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(!data);\r\n\t\ttest.done();\r\n\t});\r\n};\r\n\r\nexports['execute file with message'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\ttest.async();\r\n\t\r\n\texecutor.use('logger', {\r\n\t\tlog: function () {\r\n\t\t\ttest.ok(arguments);\r\n\t\t\ttest.equal(arguments[0], \"hello world\");\r\n\t\t}\r\n\t}); \r\n\t\r\n\texecutor.executeFile('./message.eth', function (err, data) {\r\n\t\tif (err)\r\n\t\t\tconsole.error(err);\r\n\t\t\r\n\t\ttest.ok(!err);\r\n\t\ttest.ok(!data);\r\n\t\ttest.done();\r\n\t});\r\n};\r\n\r\nexports['get host'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\tvar host = executor.host();\r\n\t\r\n\ttest.ok(host);\r\n\ttest.equal(typeof host, 'object');\r\n}\r\n\r\nexports['evaluate text'] = function (test) {\r\n\tvar executor = executors.executor();\r\n\t\r\n\ttest.equal(executor.evaluate('1 + 41'), 42);\r\n}\r\n\r\n"
  },
  {
    "path": "old/simple/test/utils.js",
    "content": "\r\nvar utils = require('../lib/utils');\r\n\r\nexports['encode decode integer value'] = function (test) {\r\n    var encoded = utils.encodeValue(42);\r\n    var result = utils.decodeValue(encoded);\r\n    \r\n    test.equal(result, 42);\r\n}\r\n\r\nexports['encode hexa value'] = function (test) {\r\n    var encoded = utils.encodeValue('0x1');\r\n\r\n\ttest.ok(encoded);\r\n\ttest.equal(encoded.length, 64);\r\n\ttest.equal(encoded, '0000000000000000000000000000000000000000000000000000000000000001');\r\n}\r\n\r\nexports['encode hexa arguments'] = function (test) {\r\n    var encoded = utils.encodeArguments(['0x1', '0x10']);\r\n\r\n\ttest.ok(encoded);\r\n\ttest.equal(encoded.length, 128);\r\n\ttest.equal(encoded, '00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000010');\r\n}\r\n\r\nexports['encode hexa arguments'] = function (test) {\r\n    var encoded = utils.encodeArguments(['0x1', '0x10']);\r\n\r\n\ttest.ok(encoded);\r\n\ttest.equal(encoded.length, 128);\r\n\ttest.equal(encoded, '00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000010');\r\n}\r\n"
  },
  {
    "path": "old/simple/throw.eth",
    "content": "\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling throw.sol\"\r\ncompile \"./contracts/throw.sol\"\r\nmessage \"throw.sol compiled\"\r\n\r\ndeploy Throw throw1\r\n\r\nmessage \"contract deployed to address\" value\r\n\r\nmessage \"instance throw1 data\"\r\ndump instances.throw1\r\n\r\n\r\n"
  },
  {
    "path": "old/simple/token.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts to use accounts[0] as default sender\r\naccounts\r\n\r\nmessage \"compiling token.sol\"\r\ncompile \"./contracts/token.sol\"\r\nmessage \"token.sol compiled\"\r\n\r\ndump contracts.Token.functionHashes\r\n\r\ndeploy Token token1\r\n\r\nmessage \"contract deployed to address\" value\r\n\r\ncall token1 balances(address) accounts[0]\r\n\r\nmessage \"owner balance\" value\r\n\r\nassert value == 10000\r\n\r\ninvoke token1 transfer(address,uint256) accounts[1] 100\r\n\r\ncall token1 balances(address) accounts[0]\r\n\r\nmessage \"owner balance\" value\r\n\r\nassert value == 10000-100\r\n\r\ncall token1 balances(address) accounts[1]\r\n\r\nmessage \"receiver balance\" value\r\n\r\nassert value == 100\r\n"
  },
  {
    "path": "old/simple/transfer.eth",
    "content": "\r\n# uncomment to enable logging\r\n# logging true\r\n\r\n# retrieve accounts from default host (http://localhost:8545)\r\naccounts\r\n\r\nassert accounts\r\nassert accounts.length\r\n\r\nmessage \"First account is\" accounts[0]\r\nbalance accounts[0]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Second account is\" accounts[1]\r\nbalance accounts[1]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Transfering...\"\r\ntransfer accounts[0] accounts[1] 1000000\r\n\r\nmessage \"First account is\" accounts[0]\r\nbalance accounts[0]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\nmessage \"Second account is\" accounts[1]\r\nbalance accounts[1]\r\nmessage \"Its balance is\" parseInt(value)\r\n\r\n"
  },
  {
    "path": "openzeppelin/first/.gitignore",
    "content": "node_modules\r\nbuild\r\n"
  },
  {
    "path": "openzeppelin/first/contracts/ConvertLib.sol",
    "content": "pragma solidity ^0.4.4;\n\nlibrary ConvertLib{\n\tfunction convert(uint amount,uint conversionRate) returns (uint convertedAmount)\n\t{\n\t\treturn amount * conversionRate;\n\t}\n}\n"
  },
  {
    "path": "openzeppelin/first/contracts/MetaCoin.sol",
    "content": "pragma solidity ^0.4.4;\n\nimport \"./ConvertLib.sol\";\n\n// This is just a simple example of a coin-like contract.\n// It is not standards compatible and cannot be expected to talk to other\n// coin/token contracts. If you want to create a standards-compliant\n// token, see: https://github.com/ConsenSys/Tokens. Cheers!\n\ncontract MetaCoin {\n\tmapping (address => uint) balances;\n\n\tevent Transfer(address indexed _from, address indexed _to, uint256 _value);\n\n\tfunction MetaCoin() {\n\t\tbalances[tx.origin] = 10000;\n\t}\n\n\tfunction sendCoin(address receiver, uint amount) returns(bool sufficient) {\n\t\tif (balances[msg.sender] < amount) return false;\n\t\tbalances[msg.sender] -= amount;\n\t\tbalances[receiver] += amount;\n\t\tTransfer(msg.sender, receiver, amount);\n\t\treturn true;\n\t}\n\n\tfunction getBalanceInEth(address addr) returns(uint){\n\t\treturn ConvertLib.convert(getBalance(addr),2);\n\t}\n\n\tfunction getBalance(address addr) returns(uint) {\n\t\treturn balances[addr];\n\t}\n}\n"
  },
  {
    "path": "openzeppelin/first/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.4;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function Migrations() {\n    owner = msg.sender;\n  }\n\n  function setCompleted(uint completed) restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "openzeppelin/first/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "openzeppelin/first/migrations/2_deploy_contracts.js",
    "content": "var ConvertLib = artifacts.require(\"./ConvertLib.sol\");\nvar MetaCoin = artifacts.require(\"./MetaCoin.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(ConvertLib);\n  deployer.link(ConvertLib, MetaCoin);\n  deployer.deploy(MetaCoin);\n};\n"
  },
  {
    "path": "openzeppelin/first/package.json",
    "content": "{\n  \"name\": \"openzeppelinfirst\",\n  \"private\": true,\n  \"version\": \"1.0.0\",\n  \"description\": \"OpenZeppelin sample\",\n  \"main\": \"truffle.js\",\n  \"directories\": {\n    \"test\": \"test\"\n  },\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"zeppelin-solidity\": \"^1.3.0\"\n  }\n}\n"
  },
  {
    "path": "openzeppelin/first/test/TestMetacoin.sol",
    "content": "pragma solidity ^0.4.2;\n\nimport \"truffle/Assert.sol\";\nimport \"truffle/DeployedAddresses.sol\";\nimport \"../contracts/MetaCoin.sol\";\n\ncontract TestMetacoin {\n\n  function testInitialBalanceUsingDeployedContract() {\n    MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());\n\n    uint expected = 10000;\n\n    Assert.equal(meta.getBalance(tx.origin), expected, \"Owner should have 10000 MetaCoin initially\");\n  }\n\n  function testInitialBalanceWithNewMetaCoin() {\n    MetaCoin meta = new MetaCoin();\n\n    uint expected = 10000;\n\n    Assert.equal(meta.getBalance(tx.origin), expected, \"Owner should have 10000 MetaCoin initially\");\n  }\n\n}\n"
  },
  {
    "path": "openzeppelin/first/test/metacoin.js",
    "content": "var MetaCoin = artifacts.require(\"./MetaCoin.sol\");\n\ncontract('MetaCoin', function(accounts) {\n  it(\"should put 10000 MetaCoin in the first account\", function() {\n    return MetaCoin.deployed().then(function(instance) {\n      return instance.getBalance.call(accounts[0]);\n    }).then(function(balance) {\n      assert.equal(balance.valueOf(), 10000, \"10000 wasn't in the first account\");\n    });\n  });\n  it(\"should call a function that depends on a linked library\", function() {\n    var meta;\n    var metaCoinBalance;\n    var metaCoinEthBalance;\n\n    return MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(accounts[0]);\n    }).then(function(outCoinBalance) {\n      metaCoinBalance = outCoinBalance.toNumber();\n      return meta.getBalanceInEth.call(accounts[0]);\n    }).then(function(outCoinBalanceEth) {\n      metaCoinEthBalance = outCoinBalanceEth.toNumber();\n    }).then(function() {\n      assert.equal(metaCoinEthBalance, 2 * metaCoinBalance, \"Library function returned unexpected function, linkage may be broken\");\n    });\n  });\n  it(\"should send coin correctly\", function() {\n    var meta;\n\n    // Get initial balances of first and second account.\n    var account_one = accounts[0];\n    var account_two = accounts[1];\n\n    var account_one_starting_balance;\n    var account_two_starting_balance;\n    var account_one_ending_balance;\n    var account_two_ending_balance;\n\n    var amount = 10;\n\n    return MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(account_one);\n    }).then(function(balance) {\n      account_one_starting_balance = balance.toNumber();\n      return meta.getBalance.call(account_two);\n    }).then(function(balance) {\n      account_two_starting_balance = balance.toNumber();\n      return meta.sendCoin(account_two, amount, {from: account_one});\n    }).then(function() {\n      return meta.getBalance.call(account_one);\n    }).then(function(balance) {\n      account_one_ending_balance = balance.toNumber();\n      return meta.getBalance.call(account_two);\n    }).then(function(balance) {\n      account_two_ending_balance = balance.toNumber();\n\n      assert.equal(account_one_ending_balance, account_one_starting_balance - amount, \"Amount wasn't correctly taken from the sender\");\n      assert.equal(account_two_ending_balance, account_two_starting_balance + amount, \"Amount wasn't correctly sent to the receiver\");\n    });\n  });\n});\n"
  },
  {
    "path": "openzeppelin/first/truffle.js",
    "content": "module.exports = {\n  networks: {\n    development: {\n      host: \"localhost\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};\n"
  },
  {
    "path": "rskapi/.gitignore",
    "content": "config.json\n"
  },
  {
    "path": "rskapi/package.json",
    "content": "{\n  \"name\": \"rskapi_samples\",\n  \"private\": true,\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"test.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"ethereumjs-tx\": \"^1.3.7\",\n    \"rskapi\": \"0.0.10\"\n  }\n}\n"
  },
  {
    "path": "rskapi/transfer.js",
    "content": "\nconst rskapi = require('rskapi');\nvar Tx = require('ethereumjs-tx');\n\nconst config = require('./config.json');\n\nconst value = parseInt(process.argv[2]);\nlet targetAccount = process.argv[3];\n\nconst host = rskapi.host(config.host);\n\nconst privateKey = new Buffer(config.account.privateKey.substring(2), 'hex');\n\nconst tx = {\n    to: targetAccount,\n    value: value,\n    gas: 22000,\n    gasPrice: 0\n};\n\n(async function () {\n    const nonce = await host.getTransactionCount(config.account.address);\n    \n    tx.nonce = nonce;\n    \n    var xtx = new Tx(tx);\n    xtx.sign(privateKey);\n    var serializedTx = xtx.serialize();\n    \n    host.sendRawTransaction('0x' + serializedTx.toString('hex'));\n})();\n\n"
  },
  {
    "path": "truffle/.gitignore",
    "content": "build"
  },
  {
    "path": "truffle/bac1/contracts/Counter.sol",
    "content": "\r\ncontract Counter {\r\n\tuint public counter;\r\n\t\r\n\tfunction increment() public {\r\n\t\tcounter++;\r\n\t}\r\n\t\r\n\tfunction add(uint v) public {\r\n\t\tcounter += v;\r\n\t}\r\n}\r\n\r\n\r\n"
  },
  {
    "path": "truffle/bac1/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.23;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  constructor() public {\n    owner = msg.sender;\n  }\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/bac1/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/bac1/migrations/2_deploy_contracts.js",
    "content": "var Counter = artifacts.require(\"./Counter.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Counter);\n};\n"
  },
  {
    "path": "truffle/bac1/test/CounterTest.js",
    "content": "\r\nvar assert = require('assert');\r\nvar Counter = artifacts.require(\"./Counter.sol\");\r\n\r\ncontract(\"Counter\", function (accounts) {\r\n\tvar counter;\r\n\t\r\n\tbeforeEach(async function () {\r\n\t\tcounter = await Counter.new();\r\n\t});\r\n\r\n\tdescribe(\"Increment\", function () {\r\n\t\tit(\"Create counter\", async function () {\r\n\t\t\tconst c = await counter.counter();\r\n\t\t\tassert.equal(c, 0);\r\n\t\t});\r\n\r\n\t\tit(\"Increment counter\", async function () {\r\n\t\t\tawait counter.increment();\r\n\t\t\tconst c = await counter.counter();\r\n\t\t\tassert.equal(c, 1);\r\n\t\t});\r\n\t});\r\n\r\n\tit(\"Add value to counter\", async function () {\r\n\t\tawait counter.add(1);\r\n\t\tawait counter.add(41);\r\n\t\tconst c = await counter.counter();\r\n\t\tassert.equal(c, 42);\r\n\t});\r\n});\r\n\r\n"
  },
  {
    "path": "truffle/bac1/truffle-config.js",
    "content": "/*\n * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a \n * function when declaring them. Failure to do so will cause commands to hang. ex:\n * ```\n * mainnet: {\n *     provider: function() { \n *       return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>') \n *     },\n *     network_id: '1',\n *     gas: 4500000,\n *     gasPrice: 10000000000,\n *   },\n */\n\nmodule.exports = {\n\t\n\tnetworks: {\n\t\tdevelopment: {\n\t\t\thost: \"127.0.0.1\",\n\t\t\tport: 8545,\n\t\t\tnetwork_id: \"*\" // Match any network id\n\t\t}\n\t}\n\t  // See <http://truffleframework.com/docs/advanced/configuration>\n  // to customize your Truffle configuration!\n};\n"
  },
  {
    "path": "truffle/bytes/.gitignore",
    "content": "node_modules\nbuild\n"
  },
  {
    "path": "truffle/bytes/contracts/Bytes.asm",
    "content": "\r\n======= contracts\\Bytes.sol:Bytes =======\r\nEVM assembly:\r\n    /* \"contracts\\Bytes.sol\":65:502  contract Bytes {\r... */\r\n  mstore(0x40, 0x80)\r\n  callvalue\r\n    /* \"--CODEGEN--\":8:17   */\r\n  dup1\r\n    /* \"--CODEGEN--\":5:7   */\r\n  iszero\r\n  tag_1\r\n  jumpi\r\n    /* \"--CODEGEN--\":30:31   */\r\n  0x0\r\n    /* \"--CODEGEN--\":27:28   */\r\n  dup1\r\n    /* \"--CODEGEN--\":20:32   */\r\n  revert\r\n    /* \"--CODEGEN--\":5:7   */\r\ntag_1:\r\n    /* \"contracts\\Bytes.sol\":65:502  contract Bytes {\r... */\r\n  pop\r\n  dataSize(sub_0)\r\n  dup1\r\n  dataOffset(sub_0)\r\n  0x0\r\n  codecopy\r\n  0x0\r\n  return\r\nstop\r\n\r\nsub_0: assembly {\r\n        /* \"contracts\\Bytes.sol\":65:502  contract Bytes {\r... */\r\n      mstore(0x40, 0x80)\r\n      jumpi(tag_1, lt(calldatasize, 0x4))\r\n      calldataload(0x0)\r\n      0x100000000000000000000000000000000000000000000000000000000\r\n      swap1\r\n      div\r\n      0xffffffff\r\n      and\r\n      dup1\r\n      0x87de500d\r\n      eq\r\n      tag_2\r\n      jumpi\r\n      dup1\r\n      0x9d5ef15e\r\n      eq\r\n      tag_3\r\n      jumpi\r\n      dup1\r\n      0xa62af6a2\r\n      eq\r\n      tag_4\r\n      jumpi\r\n      dup1\r\n      0xc8f43d16\r\n      eq\r\n      tag_5\r\n      jumpi\r\n      dup1\r\n      0xd8d798f2\r\n      eq\r\n      tag_6\r\n      jumpi\r\n      dup1\r\n      0xf0ba8440\r\n      eq\r\n      tag_7\r\n      jumpi\r\n    tag_1:\r\n      0x0\r\n      dup1\r\n      revert\r\n        /* \"contracts\\Bytes.sol\":308:383  function setData2(string[] _data2) public {\r... */\r\n    tag_2:\r\n      callvalue\r\n        /* \"--CODEGEN--\":8:17   */\r\n      dup1\r\n        /* \"--CODEGEN--\":5:7   */\r\n      iszero\r\n      tag_8\r\n      jumpi\r\n        /* \"--CODEGEN--\":30:31   */\r\n      0x0\r\n        /* \"--CODEGEN--\":27:28   */\r\n      dup1\r\n        /* \"--CODEGEN--\":20:32   */\r\n      revert\r\n        /* \"--CODEGEN--\":5:7   */\r\n    tag_8:\r\n        /* \"contracts\\Bytes.sol\":308:383  function setData2(string[] _data2) public {\r... */\r\n      pop\r\n      tag_9\r\n      0x4\r\n      dup1\r\n      calldatasize\r\n      sub\r\n      tag_10\r\n      swap2\r\n      swap1\r\n      dup2\r\n      add\r\n      swap1\r\n      jump(tag_11)\r\n    tag_10:\r\n      jump(tag_12)\r\n    tag_9:\r\n      stop\r\n        /* \"contracts\\Bytes.sol\":171:296  function setData(bytes[] _data) public {\r... */\r\n    tag_3:\r\n      callvalue\r\n        /* \"--CODEGEN--\":8:17   */\r\n      dup1\r\n        /* \"--CODEGEN--\":5:7   */\r\n      iszero\r\n      tag_13\r\n      jumpi\r\n        /* \"--CODEGEN--\":30:31   */\r\n      0x0\r\n        /* \"--CODEGEN--\":27:28   */\r\n      dup1\r\n        /* \"--CODEGEN--\":20:32   */\r\n      revert\r\n        /* \"--CODEGEN--\":5:7   */\r\n    tag_13:\r\n        /* \"contracts\\Bytes.sol\":171:296  function setData(bytes[] _data) public {\r... */\r\n      pop\r\n      tag_14\r\n      0x4\r\n      dup1\r\n      calldatasize\r\n      sub\r\n      tag_15\r\n      swap2\r\n      swap1\r\n      dup2\r\n      add\r\n      swap1\r\n      jump(tag_16)\r\n    tag_15:\r\n      jump(tag_17)\r\n    tag_14:\r\n      stop\r\n        /* \"contracts\\Bytes.sol\":395:499  function getDataItem(uint position) public view returns (bytes) {\r... */\r\n    tag_4:\r\n      callvalue\r\n        /* \"--CODEGEN--\":8:17   */\r\n      dup1\r\n        /* \"--CODEGEN--\":5:7   */\r\n      iszero\r\n      tag_18\r\n      jumpi\r\n        /* \"--CODEGEN--\":30:31   */\r\n      0x0\r\n        /* \"--CODEGEN--\":27:28   */\r\n      dup1\r\n        /* \"--CODEGEN--\":20:32   */\r\n      revert\r\n        /* \"--CODEGEN--\":5:7   */\r\n    tag_18:\r\n        /* \"contracts\\Bytes.sol\":395:499  function getDataItem(uint position) public view returns (bytes) {\r... */\r\n      pop\r\n      tag_19\r\n      0x4\r\n      dup1\r\n      calldatasize\r\n      sub\r\n      tag_20\r\n      swap2\r\n      swap1\r\n      dup2\r\n      add\r\n      swap1\r\n      jump(tag_21)\r\n    tag_20:\r\n      jump(tag_22)\r\n    tag_19:\r\n      mload(0x40)\r\n      tag_23\r\n      swap2\r\n      swap1\r\n      jump(tag_24)\r\n    tag_23:\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      return\r\n        /* \"contracts\\Bytes.sol\":137:158  string[] public data2 */\r\n    tag_5:\r\n      callvalue\r\n        /* \"--CODEGEN--\":8:17   */\r\n      dup1\r\n        /* \"--CODEGEN--\":5:7   */\r\n      iszero\r\n      tag_25\r\n      jumpi\r\n        /* \"--CODEGEN--\":30:31   */\r\n      0x0\r\n        /* \"--CODEGEN--\":27:28   */\r\n      dup1\r\n        /* \"--CODEGEN--\":20:32   */\r\n      revert\r\n        /* \"--CODEGEN--\":5:7   */\r\n    tag_25:\r\n        /* \"contracts\\Bytes.sol\":137:158  string[] public data2 */\r\n      pop\r\n      tag_26\r\n      0x4\r\n      dup1\r\n      calldatasize\r\n      sub\r\n      tag_27\r\n      swap2\r\n      swap1\r\n      dup2\r\n      add\r\n      swap1\r\n      jump(tag_21)\r\n    tag_27:\r\n      jump(tag_28)\r\n    tag_26:\r\n      mload(0x40)\r\n      tag_29\r\n      swap2\r\n      swap1\r\n      jump(tag_30)\r\n    tag_29:\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      return\r\n        /* \"contracts\\Bytes.sol\":113:130  uint public ldata */\r\n    tag_6:\r\n      callvalue\r\n        /* \"--CODEGEN--\":8:17   */\r\n      dup1\r\n        /* \"--CODEGEN--\":5:7   */\r\n      iszero\r\n      tag_31\r\n      jumpi\r\n        /* \"--CODEGEN--\":30:31   */\r\n      0x0\r\n        /* \"--CODEGEN--\":27:28   */\r\n      dup1\r\n        /* \"--CODEGEN--\":20:32   */\r\n      revert\r\n        /* \"--CODEGEN--\":5:7   */\r\n    tag_31:\r\n        /* \"contracts\\Bytes.sol\":113:130  uint public ldata */\r\n      pop\r\n      tag_32\r\n      jump(tag_33)\r\n    tag_32:\r\n      mload(0x40)\r\n      tag_34\r\n      swap2\r\n      swap1\r\n      jump(tag_35)\r\n    tag_34:\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      return\r\n        /* \"contracts\\Bytes.sol\":87:106  bytes[] public data */\r\n    tag_7:\r\n      callvalue\r\n        /* \"--CODEGEN--\":8:17   */\r\n      dup1\r\n        /* \"--CODEGEN--\":5:7   */\r\n      iszero\r\n      tag_36\r\n      jumpi\r\n        /* \"--CODEGEN--\":30:31   */\r\n      0x0\r\n        /* \"--CODEGEN--\":27:28   */\r\n      dup1\r\n        /* \"--CODEGEN--\":20:32   */\r\n      revert\r\n        /* \"--CODEGEN--\":5:7   */\r\n    tag_36:\r\n        /* \"contracts\\Bytes.sol\":87:106  bytes[] public data */\r\n      pop\r\n      tag_37\r\n      0x4\r\n      dup1\r\n      calldatasize\r\n      sub\r\n      tag_38\r\n      swap2\r\n      swap1\r\n      dup2\r\n      add\r\n      swap1\r\n      jump(tag_21)\r\n    tag_38:\r\n      jump(tag_39)\r\n    tag_37:\r\n      mload(0x40)\r\n      tag_40\r\n      swap2\r\n      swap1\r\n      jump(tag_41)\r\n    tag_40:\r\n      mload(0x40)\r\n      dup1\r\n      swap2\r\n      sub\r\n      swap1\r\n      return\r\n        /* \"contracts\\Bytes.sol\":308:383  function setData2(string[] _data2) public {\r... */\r\n    tag_12:\r\n        /* \"contracts\\Bytes.sol\":369:375  _data2 */\r\n      dup1\r\n        /* \"contracts\\Bytes.sol\":361:366  data2 */\r\n      0x2\r\n        /* \"contracts\\Bytes.sol\":361:375  data2 = _data2 */\r\n      swap1\r\n      dup1\r\n      mload\r\n      swap1\r\n      0x20\r\n      add\r\n      swap1\r\n      tag_43\r\n      swap3\r\n      swap2\r\n      swap1\r\n      jump\t// in(tag_44)\r\n    tag_43:\r\n      pop\r\n        /* \"contracts\\Bytes.sol\":308:383  function setData2(string[] _data2) public {\r... */\r\n      pop\r\n      jump\t// out\r\n        /* \"contracts\\Bytes.sol\":171:296  function setData(bytes[] _data) public {\r... */\r\n    tag_17:\r\n        /* \"contracts\\Bytes.sol\":287:288  1 */\r\n      0x1\r\n        /* \"contracts\\Bytes.sol\":279:284  ldata */\r\n      dup1\r\n        /* \"contracts\\Bytes.sol\":279:288  ldata = 1 */\r\n      dup2\r\n      swap1\r\n      sstore\r\n      pop\r\n        /* \"contracts\\Bytes.sol\":171:296  function setData(bytes[] _data) public {\r... */\r\n      pop\r\n      jump\t// out\r\n        /* \"contracts\\Bytes.sol\":395:499  function getDataItem(uint position) public view returns (bytes) {\r... */\r\n    tag_22:\r\n        /* \"contracts\\Bytes.sol\":452:457  bytes */\r\n      0x60\r\n        /* \"contracts\\Bytes.sol\":477:481  data */\r\n      0x0\r\n        /* \"contracts\\Bytes.sol\":482:490  position */\r\n      dup3\r\n        /* \"contracts\\Bytes.sol\":477:491  data[position] */\r\n      dup2\r\n      sload\r\n      dup2\r\n      lt\r\n      iszero\r\n      iszero\r\n      tag_47\r\n      jumpi\r\n      invalid\r\n    tag_47:\r\n      swap1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x20)\r\n      add\r\n        /* \"contracts\\Bytes.sol\":470:491  return data[position] */\r\n      dup1\r\n      sload\r\n      0x1\r\n      dup2\r\n      0x1\r\n      and\r\n      iszero\r\n      0x100\r\n      mul\r\n      sub\r\n      and\r\n      0x2\r\n      swap1\r\n      div\r\n      dup1\r\n      0x1f\r\n      add\r\n      0x20\r\n      dup1\r\n      swap2\r\n      div\r\n      mul\r\n      0x20\r\n      add\r\n      mload(0x40)\r\n      swap1\r\n      dup2\r\n      add\r\n      0x40\r\n      mstore\r\n      dup1\r\n      swap3\r\n      swap2\r\n      swap1\r\n      dup2\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      dup3\r\n      dup1\r\n      sload\r\n      0x1\r\n      dup2\r\n      0x1\r\n      and\r\n      iszero\r\n      0x100\r\n      mul\r\n      sub\r\n      and\r\n      0x2\r\n      swap1\r\n      div\r\n      dup1\r\n      iszero\r\n      tag_49\r\n      jumpi\r\n      dup1\r\n      0x1f\r\n      lt\r\n      tag_50\r\n      jumpi\r\n      0x100\r\n      dup1\r\n      dup4\r\n      sload\r\n      div\r\n      mul\r\n      dup4\r\n      mstore\r\n      swap2\r\n      0x20\r\n      add\r\n      swap2\r\n      jump(tag_49)\r\n    tag_50:\r\n      dup3\r\n      add\r\n      swap2\r\n      swap1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x20)\r\n      swap1\r\n    tag_51:\r\n      dup2\r\n      sload\r\n      dup2\r\n      mstore\r\n      swap1\r\n      0x1\r\n      add\r\n      swap1\r\n      0x20\r\n      add\r\n      dup1\r\n      dup4\r\n      gt\r\n      tag_51\r\n      jumpi\r\n      dup3\r\n      swap1\r\n      sub\r\n      0x1f\r\n      and\r\n      dup3\r\n      add\r\n      swap2\r\n    tag_49:\r\n      pop\r\n      pop\r\n      pop\r\n      pop\r\n      pop\r\n      swap1\r\n      pop\r\n        /* \"contracts\\Bytes.sol\":395:499  function getDataItem(uint position) public view returns (bytes) {\r... */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\t// out\r\n        /* \"contracts\\Bytes.sol\":137:158  string[] public data2 */\r\n    tag_28:\r\n      0x2\r\n      dup2\r\n      dup2\r\n      sload\r\n      dup2\r\n      lt\r\n      iszero\r\n      iszero\r\n      tag_52\r\n      jumpi\r\n      invalid\r\n    tag_52:\r\n      swap1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x20)\r\n      add\r\n      0x0\r\n      swap2\r\n      pop\r\n      swap1\r\n      pop\r\n      dup1\r\n      sload\r\n      0x1\r\n      dup2\r\n      0x1\r\n      and\r\n      iszero\r\n      0x100\r\n      mul\r\n      sub\r\n      and\r\n      0x2\r\n      swap1\r\n      div\r\n      dup1\r\n      0x1f\r\n      add\r\n      0x20\r\n      dup1\r\n      swap2\r\n      div\r\n      mul\r\n      0x20\r\n      add\r\n      mload(0x40)\r\n      swap1\r\n      dup2\r\n      add\r\n      0x40\r\n      mstore\r\n      dup1\r\n      swap3\r\n      swap2\r\n      swap1\r\n      dup2\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      dup3\r\n      dup1\r\n      sload\r\n      0x1\r\n      dup2\r\n      0x1\r\n      and\r\n      iszero\r\n      0x100\r\n      mul\r\n      sub\r\n      and\r\n      0x2\r\n      swap1\r\n      div\r\n      dup1\r\n      iszero\r\n      tag_54\r\n      jumpi\r\n      dup1\r\n      0x1f\r\n      lt\r\n      tag_55\r\n      jumpi\r\n      0x100\r\n      dup1\r\n      dup4\r\n      sload\r\n      div\r\n      mul\r\n      dup4\r\n      mstore\r\n      swap2\r\n      0x20\r\n      add\r\n      swap2\r\n      jump(tag_54)\r\n    tag_55:\r\n      dup3\r\n      add\r\n      swap2\r\n      swap1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x20)\r\n      swap1\r\n    tag_56:\r\n      dup2\r\n      sload\r\n      dup2\r\n      mstore\r\n      swap1\r\n      0x1\r\n      add\r\n      swap1\r\n      0x20\r\n      add\r\n      dup1\r\n      dup4\r\n      gt\r\n      tag_56\r\n      jumpi\r\n      dup3\r\n      swap1\r\n      sub\r\n      0x1f\r\n      and\r\n      dup3\r\n      add\r\n      swap2\r\n    tag_54:\r\n      pop\r\n      pop\r\n      pop\r\n      pop\r\n      pop\r\n      dup2\r\n      jump\t// out\r\n        /* \"contracts\\Bytes.sol\":113:130  uint public ldata */\r\n    tag_33:\r\n      sload(0x1)\r\n      dup2\r\n      jump\t// out\r\n        /* \"contracts\\Bytes.sol\":87:106  bytes[] public data */\r\n    tag_39:\r\n      0x0\r\n      dup2\r\n      dup2\r\n      sload\r\n      dup2\r\n      lt\r\n      iszero\r\n      iszero\r\n      tag_57\r\n      jumpi\r\n      invalid\r\n    tag_57:\r\n      swap1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x20)\r\n      add\r\n      0x0\r\n      swap2\r\n      pop\r\n      swap1\r\n      pop\r\n      dup1\r\n      sload\r\n      0x1\r\n      dup2\r\n      0x1\r\n      and\r\n      iszero\r\n      0x100\r\n      mul\r\n      sub\r\n      and\r\n      0x2\r\n      swap1\r\n      div\r\n      dup1\r\n      0x1f\r\n      add\r\n      0x20\r\n      dup1\r\n      swap2\r\n      div\r\n      mul\r\n      0x20\r\n      add\r\n      mload(0x40)\r\n      swap1\r\n      dup2\r\n      add\r\n      0x40\r\n      mstore\r\n      dup1\r\n      swap3\r\n      swap2\r\n      swap1\r\n      dup2\r\n      dup2\r\n      mstore\r\n      0x20\r\n      add\r\n      dup3\r\n      dup1\r\n      sload\r\n      0x1\r\n      dup2\r\n      0x1\r\n      and\r\n      iszero\r\n      0x100\r\n      mul\r\n      sub\r\n      and\r\n      0x2\r\n      swap1\r\n      div\r\n      dup1\r\n      iszero\r\n      tag_59\r\n      jumpi\r\n      dup1\r\n      0x1f\r\n      lt\r\n      tag_60\r\n      jumpi\r\n      0x100\r\n      dup1\r\n      dup4\r\n      sload\r\n      div\r\n      mul\r\n      dup4\r\n      mstore\r\n      swap2\r\n      0x20\r\n      add\r\n      swap2\r\n      jump(tag_59)\r\n    tag_60:\r\n      dup3\r\n      add\r\n      swap2\r\n      swap1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x20)\r\n      swap1\r\n    tag_61:\r\n      dup2\r\n      sload\r\n      dup2\r\n      mstore\r\n      swap1\r\n      0x1\r\n      add\r\n      swap1\r\n      0x20\r\n      add\r\n      dup1\r\n      dup4\r\n      gt\r\n      tag_61\r\n      jumpi\r\n      dup3\r\n      swap1\r\n      sub\r\n      0x1f\r\n      and\r\n      dup3\r\n      add\r\n      swap2\r\n    tag_59:\r\n      pop\r\n      pop\r\n      pop\r\n      pop\r\n      pop\r\n      dup2\r\n      jump\t// out\r\n        /* \"contracts\\Bytes.sol\":65:502  contract Bytes {\r... */\r\n    tag_44:\r\n      dup3\r\n      dup1\r\n      sload\r\n      dup3\r\n      dup3\r\n      sstore\r\n      swap1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x20)\r\n      swap1\r\n      dup2\r\n      add\r\n      swap3\r\n      dup3\r\n      iszero\r\n      tag_62\r\n      jumpi\r\n      swap2\r\n      0x20\r\n      mul\r\n      dup3\r\n      add\r\n    tag_63:\r\n      dup3\r\n      dup2\r\n      gt\r\n      iszero\r\n      tag_64\r\n      jumpi\r\n      dup3\r\n      mload\r\n      dup3\r\n      swap1\r\n      dup1\r\n      mload\r\n      swap1\r\n      0x20\r\n      add\r\n      swap1\r\n      tag_65\r\n      swap3\r\n      swap2\r\n      swap1\r\n      jump\t// in(tag_66)\r\n    tag_65:\r\n      pop\r\n      swap2\r\n      0x20\r\n      add\r\n      swap2\r\n      swap1\r\n      0x1\r\n      add\r\n      swap1\r\n      jump(tag_63)\r\n    tag_64:\r\n    tag_62:\r\n      pop\r\n      swap1\r\n      pop\r\n      tag_67\r\n      swap2\r\n      swap1\r\n      jump\t// in(tag_68)\r\n    tag_67:\r\n      pop\r\n      swap1\r\n      jump\t// out\r\n    tag_66:\r\n      dup3\r\n      dup1\r\n      sload\r\n      0x1\r\n      dup2\r\n      0x1\r\n      and\r\n      iszero\r\n      0x100\r\n      mul\r\n      sub\r\n      and\r\n      0x2\r\n      swap1\r\n      div\r\n      swap1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x20)\r\n      swap1\r\n      0x1f\r\n      add\r\n      0x20\r\n      swap1\r\n      div\r\n      dup2\r\n      add\r\n      swap3\r\n      dup3\r\n      0x1f\r\n      lt\r\n      tag_70\r\n      jumpi\r\n      dup1\r\n      mload\r\n      not(0xff)\r\n      and\r\n      dup4\r\n      dup1\r\n      add\r\n      or\r\n      dup6\r\n      sstore\r\n      jump(tag_69)\r\n    tag_70:\r\n      dup3\r\n      dup1\r\n      add\r\n      0x1\r\n      add\r\n      dup6\r\n      sstore\r\n      dup3\r\n      iszero\r\n      tag_69\r\n      jumpi\r\n      swap2\r\n      dup3\r\n      add\r\n    tag_71:\r\n      dup3\r\n      dup2\r\n      gt\r\n      iszero\r\n      tag_72\r\n      jumpi\r\n      dup3\r\n      mload\r\n      dup3\r\n      sstore\r\n      swap2\r\n      0x20\r\n      add\r\n      swap2\r\n      swap1\r\n      0x1\r\n      add\r\n      swap1\r\n      jump(tag_71)\r\n    tag_72:\r\n    tag_69:\r\n      pop\r\n      swap1\r\n      pop\r\n      tag_73\r\n      swap2\r\n      swap1\r\n      jump\t// in(tag_74)\r\n    tag_73:\r\n      pop\r\n      swap1\r\n      jump\t// out\r\n    tag_68:\r\n      tag_75\r\n      swap2\r\n      swap1\r\n    tag_76:\r\n      dup1\r\n      dup3\r\n      gt\r\n      iszero\r\n      tag_77\r\n      jumpi\r\n      0x0\r\n      dup2\r\n      dup2\r\n      tag_78\r\n      swap2\r\n      swap1\r\n      jump\t// in(tag_79)\r\n    tag_78:\r\n      pop\r\n      0x1\r\n      add\r\n      jump(tag_76)\r\n    tag_77:\r\n      pop\r\n      swap1\r\n      jump\r\n    tag_75:\r\n      swap1\r\n      jump\t// out\r\n    tag_74:\r\n      tag_80\r\n      swap2\r\n      swap1\r\n    tag_81:\r\n      dup1\r\n      dup3\r\n      gt\r\n      iszero\r\n      tag_82\r\n      jumpi\r\n      0x0\r\n      dup2\r\n      0x0\r\n      swap1\r\n      sstore\r\n      pop\r\n      0x1\r\n      add\r\n      jump(tag_81)\r\n    tag_82:\r\n      pop\r\n      swap1\r\n      jump\r\n    tag_80:\r\n      swap1\r\n      jump\t// out\r\n    tag_79:\r\n      pop\r\n      dup1\r\n      sload\r\n      0x1\r\n      dup2\r\n      0x1\r\n      and\r\n      iszero\r\n      0x100\r\n      mul\r\n      sub\r\n      and\r\n      0x2\r\n      swap1\r\n      div\r\n      0x0\r\n      dup3\r\n      sstore\r\n      dup1\r\n      0x1f\r\n      lt\r\n      tag_84\r\n      jumpi\r\n      pop\r\n      jump(tag_83)\r\n    tag_84:\r\n      0x1f\r\n      add\r\n      0x20\r\n      swap1\r\n      div\r\n      swap1\r\n      0x0\r\n      mstore\r\n      keccak256(0x0, 0x20)\r\n      swap1\r\n      dup2\r\n      add\r\n      swap1\r\n      tag_85\r\n      swap2\r\n      swap1\r\n      jump\t// in(tag_74)\r\n    tag_85:\r\n    tag_83:\r\n      pop\r\n      jump\t// out\r\n        /* \"--CODEGEN--\":21:714   */\r\n    tag_87:\r\n      0x0\r\n        /* \"--CODEGEN--\":143:146   */\r\n      dup3\r\n        /* \"--CODEGEN--\":136:140   */\r\n      0x1f\r\n        /* \"--CODEGEN--\":128:134   */\r\n      dup4\r\n        /* \"--CODEGEN--\":124:141   */\r\n      add\r\n        /* \"--CODEGEN--\":120:147   */\r\n      slt\r\n        /* \"--CODEGEN--\":113:148   */\r\n      iszero\r\n        /* \"--CODEGEN--\":110:112   */\r\n      iszero\r\n      tag_88\r\n      jumpi\r\n        /* \"--CODEGEN--\":161:162   */\r\n      0x0\r\n        /* \"--CODEGEN--\":158:159   */\r\n      dup1\r\n        /* \"--CODEGEN--\":151:163   */\r\n      revert\r\n        /* \"--CODEGEN--\":110:112   */\r\n    tag_88:\r\n        /* \"--CODEGEN--\":198:204   */\r\n      dup2\r\n        /* \"--CODEGEN--\":185:205   */\r\n      calldataload\r\n        /* \"--CODEGEN--\":220:305   */\r\n      tag_89\r\n        /* \"--CODEGEN--\":235:304   */\r\n      tag_90\r\n        /* \"--CODEGEN--\":297:303   */\r\n      dup3\r\n        /* \"--CODEGEN--\":235:304   */\r\n      jump(tag_91)\r\n    tag_90:\r\n        /* \"--CODEGEN--\":220:305   */\r\n      jump(tag_92)\r\n    tag_89:\r\n        /* \"--CODEGEN--\":211:305   */\r\n      swap2\r\n      pop\r\n        /* \"--CODEGEN--\":322:327   */\r\n      dup2\r\n        /* \"--CODEGEN--\":347:353   */\r\n      dup2\r\n        /* \"--CODEGEN--\":340:345   */\r\n      dup4\r\n        /* \"--CODEGEN--\":333:354   */\r\n      mstore\r\n        /* \"--CODEGEN--\":377:381   */\r\n      0x20\r\n        /* \"--CODEGEN--\":369:375   */\r\n      dup5\r\n        /* \"--CODEGEN--\":365:382   */\r\n      add\r\n        /* \"--CODEGEN--\":355:382   */\r\n      swap4\r\n      pop\r\n        /* \"--CODEGEN--\":399:403   */\r\n      0x20\r\n        /* \"--CODEGEN--\":394:397   */\r\n      dup2\r\n        /* \"--CODEGEN--\":390:404   */\r\n      add\r\n        /* \"--CODEGEN--\":383:404   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":452:458   */\r\n      dup4\r\n        /* \"--CODEGEN--\":485:486   */\r\n      0x0\r\n        /* \"--CODEGEN--\":470:708   */\r\n    tag_93:\r\n        /* \"--CODEGEN--\":495:501   */\r\n      dup4\r\n        /* \"--CODEGEN--\":492:493   */\r\n      dup2\r\n        /* \"--CODEGEN--\":489:502   */\r\n      lt\r\n        /* \"--CODEGEN--\":470:708   */\r\n      iszero\r\n      tag_94\r\n      jumpi\r\n        /* \"--CODEGEN--\":578:581   */\r\n      dup2\r\n        /* \"--CODEGEN--\":565:582   */\r\n      calldataload\r\n        /* \"--CODEGEN--\":557:563   */\r\n      dup7\r\n        /* \"--CODEGEN--\":553:583   */\r\n      add\r\n        /* \"--CODEGEN--\":602:644   */\r\n      tag_96\r\n        /* \"--CODEGEN--\":640:643   */\r\n      dup9\r\n        /* \"--CODEGEN--\":628:638   */\r\n      dup3\r\n        /* \"--CODEGEN--\":602:644   */\r\n      jump(tag_97)\r\n    tag_96:\r\n        /* \"--CODEGEN--\":597:600   */\r\n      dup5\r\n        /* \"--CODEGEN--\":590:645   */\r\n      mstore\r\n        /* \"--CODEGEN--\":668:672   */\r\n      0x20\r\n        /* \"--CODEGEN--\":663:666   */\r\n      dup5\r\n        /* \"--CODEGEN--\":659:673   */\r\n      add\r\n        /* \"--CODEGEN--\":652:673   */\r\n      swap4\r\n      pop\r\n        /* \"--CODEGEN--\":696:700   */\r\n      0x20\r\n        /* \"--CODEGEN--\":691:694   */\r\n      dup4\r\n        /* \"--CODEGEN--\":687:701   */\r\n      add\r\n        /* \"--CODEGEN--\":680:701   */\r\n      swap3\r\n      pop\r\n        /* \"--CODEGEN--\":527:708   */\r\n      pop\r\n        /* \"--CODEGEN--\":517:518   */\r\n      0x1\r\n        /* \"--CODEGEN--\":514:515   */\r\n      dup2\r\n        /* \"--CODEGEN--\":510:519   */\r\n      add\r\n        /* \"--CODEGEN--\":505:519   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":470:708   */\r\n      jump(tag_93)\r\n    tag_94:\r\n        /* \"--CODEGEN--\":474:488   */\r\n      pop\r\n        /* \"--CODEGEN--\":103:714   */\r\n      pop\r\n      pop\r\n      pop\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":739:1435   */\r\n    tag_99:\r\n      0x0\r\n        /* \"--CODEGEN--\":862:865   */\r\n      dup3\r\n        /* \"--CODEGEN--\":855:859   */\r\n      0x1f\r\n        /* \"--CODEGEN--\":847:853   */\r\n      dup4\r\n        /* \"--CODEGEN--\":843:860   */\r\n      add\r\n        /* \"--CODEGEN--\":839:866   */\r\n      slt\r\n        /* \"--CODEGEN--\":832:867   */\r\n      iszero\r\n        /* \"--CODEGEN--\":829:831   */\r\n      iszero\r\n      tag_100\r\n      jumpi\r\n        /* \"--CODEGEN--\":880:881   */\r\n      0x0\r\n        /* \"--CODEGEN--\":877:878   */\r\n      dup1\r\n        /* \"--CODEGEN--\":870:882   */\r\n      revert\r\n        /* \"--CODEGEN--\":829:831   */\r\n    tag_100:\r\n        /* \"--CODEGEN--\":917:923   */\r\n      dup2\r\n        /* \"--CODEGEN--\":904:924   */\r\n      calldataload\r\n        /* \"--CODEGEN--\":939:1025   */\r\n      tag_101\r\n        /* \"--CODEGEN--\":954:1024   */\r\n      tag_102\r\n        /* \"--CODEGEN--\":1017:1023   */\r\n      dup3\r\n        /* \"--CODEGEN--\":954:1024   */\r\n      jump(tag_103)\r\n    tag_102:\r\n        /* \"--CODEGEN--\":939:1025   */\r\n      jump(tag_92)\r\n    tag_101:\r\n        /* \"--CODEGEN--\":930:1025   */\r\n      swap2\r\n      pop\r\n        /* \"--CODEGEN--\":1042:1047   */\r\n      dup2\r\n        /* \"--CODEGEN--\":1067:1073   */\r\n      dup2\r\n        /* \"--CODEGEN--\":1060:1065   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1053:1074   */\r\n      mstore\r\n        /* \"--CODEGEN--\":1097:1101   */\r\n      0x20\r\n        /* \"--CODEGEN--\":1089:1095   */\r\n      dup5\r\n        /* \"--CODEGEN--\":1085:1102   */\r\n      add\r\n        /* \"--CODEGEN--\":1075:1102   */\r\n      swap4\r\n      pop\r\n        /* \"--CODEGEN--\":1119:1123   */\r\n      0x20\r\n        /* \"--CODEGEN--\":1114:1117   */\r\n      dup2\r\n        /* \"--CODEGEN--\":1110:1124   */\r\n      add\r\n        /* \"--CODEGEN--\":1103:1124   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":1172:1178   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1205:1206   */\r\n      0x0\r\n        /* \"--CODEGEN--\":1190:1429   */\r\n    tag_104:\r\n        /* \"--CODEGEN--\":1215:1221   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1212:1213   */\r\n      dup2\r\n        /* \"--CODEGEN--\":1209:1222   */\r\n      lt\r\n        /* \"--CODEGEN--\":1190:1429   */\r\n      iszero\r\n      tag_105\r\n      jumpi\r\n        /* \"--CODEGEN--\":1298:1301   */\r\n      dup2\r\n        /* \"--CODEGEN--\":1285:1302   */\r\n      calldataload\r\n        /* \"--CODEGEN--\":1277:1283   */\r\n      dup7\r\n        /* \"--CODEGEN--\":1273:1303   */\r\n      add\r\n        /* \"--CODEGEN--\":1322:1365   */\r\n      tag_107\r\n        /* \"--CODEGEN--\":1361:1364   */\r\n      dup9\r\n        /* \"--CODEGEN--\":1349:1359   */\r\n      dup3\r\n        /* \"--CODEGEN--\":1322:1365   */\r\n      jump(tag_108)\r\n    tag_107:\r\n        /* \"--CODEGEN--\":1317:1320   */\r\n      dup5\r\n        /* \"--CODEGEN--\":1310:1366   */\r\n      mstore\r\n        /* \"--CODEGEN--\":1389:1393   */\r\n      0x20\r\n        /* \"--CODEGEN--\":1384:1387   */\r\n      dup5\r\n        /* \"--CODEGEN--\":1380:1394   */\r\n      add\r\n        /* \"--CODEGEN--\":1373:1394   */\r\n      swap4\r\n      pop\r\n        /* \"--CODEGEN--\":1417:1421   */\r\n      0x20\r\n        /* \"--CODEGEN--\":1412:1415   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1408:1422   */\r\n      add\r\n        /* \"--CODEGEN--\":1401:1422   */\r\n      swap3\r\n      pop\r\n        /* \"--CODEGEN--\":1247:1429   */\r\n      pop\r\n        /* \"--CODEGEN--\":1237:1238   */\r\n      0x1\r\n        /* \"--CODEGEN--\":1234:1235   */\r\n      dup2\r\n        /* \"--CODEGEN--\":1230:1239   */\r\n      add\r\n        /* \"--CODEGEN--\":1225:1239   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":1190:1429   */\r\n      jump(tag_104)\r\n    tag_105:\r\n        /* \"--CODEGEN--\":1194:1208   */\r\n      pop\r\n        /* \"--CODEGEN--\":822:1435   */\r\n      pop\r\n      pop\r\n      pop\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":1444:1876   */\r\n    tag_97:\r\n      0x0\r\n        /* \"--CODEGEN--\":1541:1544   */\r\n      dup3\r\n        /* \"--CODEGEN--\":1534:1538   */\r\n      0x1f\r\n        /* \"--CODEGEN--\":1526:1532   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1522:1539   */\r\n      add\r\n        /* \"--CODEGEN--\":1518:1545   */\r\n      slt\r\n        /* \"--CODEGEN--\":1511:1546   */\r\n      iszero\r\n        /* \"--CODEGEN--\":1508:1510   */\r\n      iszero\r\n      tag_110\r\n      jumpi\r\n        /* \"--CODEGEN--\":1559:1560   */\r\n      0x0\r\n        /* \"--CODEGEN--\":1556:1557   */\r\n      dup1\r\n        /* \"--CODEGEN--\":1549:1561   */\r\n      revert\r\n        /* \"--CODEGEN--\":1508:1510   */\r\n    tag_110:\r\n        /* \"--CODEGEN--\":1596:1602   */\r\n      dup2\r\n        /* \"--CODEGEN--\":1583:1603   */\r\n      calldataload\r\n        /* \"--CODEGEN--\":1618:1678   */\r\n      tag_111\r\n        /* \"--CODEGEN--\":1633:1677   */\r\n      tag_112\r\n        /* \"--CODEGEN--\":1670:1676   */\r\n      dup3\r\n        /* \"--CODEGEN--\":1633:1677   */\r\n      jump(tag_113)\r\n    tag_112:\r\n        /* \"--CODEGEN--\":1618:1678   */\r\n      jump(tag_92)\r\n    tag_111:\r\n        /* \"--CODEGEN--\":1609:1678   */\r\n      swap2\r\n      pop\r\n        /* \"--CODEGEN--\":1698:1704   */\r\n      dup1\r\n        /* \"--CODEGEN--\":1691:1696   */\r\n      dup3\r\n        /* \"--CODEGEN--\":1684:1705   */\r\n      mstore\r\n        /* \"--CODEGEN--\":1734:1738   */\r\n      0x20\r\n        /* \"--CODEGEN--\":1726:1732   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1722:1739   */\r\n      add\r\n        /* \"--CODEGEN--\":1767:1771   */\r\n      0x20\r\n        /* \"--CODEGEN--\":1760:1765   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1756:1772   */\r\n      add\r\n        /* \"--CODEGEN--\":1802:1805   */\r\n      dup6\r\n        /* \"--CODEGEN--\":1793:1799   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1788:1791   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1784:1800   */\r\n      add\r\n        /* \"--CODEGEN--\":1781:1806   */\r\n      gt\r\n        /* \"--CODEGEN--\":1778:1780   */\r\n      iszero\r\n      tag_114\r\n      jumpi\r\n        /* \"--CODEGEN--\":1819:1820   */\r\n      0x0\r\n        /* \"--CODEGEN--\":1816:1817   */\r\n      dup1\r\n        /* \"--CODEGEN--\":1809:1821   */\r\n      revert\r\n        /* \"--CODEGEN--\":1778:1780   */\r\n    tag_114:\r\n        /* \"--CODEGEN--\":1829:1870   */\r\n      tag_115\r\n        /* \"--CODEGEN--\":1863:1869   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1858:1861   */\r\n      dup3\r\n        /* \"--CODEGEN--\":1853:1856   */\r\n      dup5\r\n        /* \"--CODEGEN--\":1829:1870   */\r\n      jump(tag_116)\r\n    tag_115:\r\n        /* \"--CODEGEN--\":1501:1876   */\r\n      pop\r\n      pop\r\n      pop\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":1885:2319   */\r\n    tag_108:\r\n      0x0\r\n        /* \"--CODEGEN--\":1983:1986   */\r\n      dup3\r\n        /* \"--CODEGEN--\":1976:1980   */\r\n      0x1f\r\n        /* \"--CODEGEN--\":1968:1974   */\r\n      dup4\r\n        /* \"--CODEGEN--\":1964:1981   */\r\n      add\r\n        /* \"--CODEGEN--\":1960:1987   */\r\n      slt\r\n        /* \"--CODEGEN--\":1953:1988   */\r\n      iszero\r\n        /* \"--CODEGEN--\":1950:1952   */\r\n      iszero\r\n      tag_118\r\n      jumpi\r\n        /* \"--CODEGEN--\":2001:2002   */\r\n      0x0\r\n        /* \"--CODEGEN--\":1998:1999   */\r\n      dup1\r\n        /* \"--CODEGEN--\":1991:2003   */\r\n      revert\r\n        /* \"--CODEGEN--\":1950:1952   */\r\n    tag_118:\r\n        /* \"--CODEGEN--\":2038:2044   */\r\n      dup2\r\n        /* \"--CODEGEN--\":2025:2045   */\r\n      calldataload\r\n        /* \"--CODEGEN--\":2060:2121   */\r\n      tag_119\r\n        /* \"--CODEGEN--\":2075:2120   */\r\n      tag_120\r\n        /* \"--CODEGEN--\":2113:2119   */\r\n      dup3\r\n        /* \"--CODEGEN--\":2075:2120   */\r\n      jump(tag_121)\r\n    tag_120:\r\n        /* \"--CODEGEN--\":2060:2121   */\r\n      jump(tag_92)\r\n    tag_119:\r\n        /* \"--CODEGEN--\":2051:2121   */\r\n      swap2\r\n      pop\r\n        /* \"--CODEGEN--\":2141:2147   */\r\n      dup1\r\n        /* \"--CODEGEN--\":2134:2139   */\r\n      dup3\r\n        /* \"--CODEGEN--\":2127:2148   */\r\n      mstore\r\n        /* \"--CODEGEN--\":2177:2181   */\r\n      0x20\r\n        /* \"--CODEGEN--\":2169:2175   */\r\n      dup4\r\n        /* \"--CODEGEN--\":2165:2182   */\r\n      add\r\n        /* \"--CODEGEN--\":2210:2214   */\r\n      0x20\r\n        /* \"--CODEGEN--\":2203:2208   */\r\n      dup4\r\n        /* \"--CODEGEN--\":2199:2215   */\r\n      add\r\n        /* \"--CODEGEN--\":2245:2248   */\r\n      dup6\r\n        /* \"--CODEGEN--\":2236:2242   */\r\n      dup4\r\n        /* \"--CODEGEN--\":2231:2234   */\r\n      dup4\r\n        /* \"--CODEGEN--\":2227:2243   */\r\n      add\r\n        /* \"--CODEGEN--\":2224:2249   */\r\n      gt\r\n        /* \"--CODEGEN--\":2221:2223   */\r\n      iszero\r\n      tag_122\r\n      jumpi\r\n        /* \"--CODEGEN--\":2262:2263   */\r\n      0x0\r\n        /* \"--CODEGEN--\":2259:2260   */\r\n      dup1\r\n        /* \"--CODEGEN--\":2252:2264   */\r\n      revert\r\n        /* \"--CODEGEN--\":2221:2223   */\r\n    tag_122:\r\n        /* \"--CODEGEN--\":2272:2313   */\r\n      tag_123\r\n        /* \"--CODEGEN--\":2306:2312   */\r\n      dup4\r\n        /* \"--CODEGEN--\":2301:2304   */\r\n      dup3\r\n        /* \"--CODEGEN--\":2296:2299   */\r\n      dup5\r\n        /* \"--CODEGEN--\":2272:2313   */\r\n      jump(tag_116)\r\n    tag_123:\r\n        /* \"--CODEGEN--\":1943:2319   */\r\n      pop\r\n      pop\r\n      pop\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":2327:2445   */\r\n    tag_125:\r\n      0x0\r\n        /* \"--CODEGEN--\":2394:2440   */\r\n      tag_126\r\n        /* \"--CODEGEN--\":2432:2438   */\r\n      dup3\r\n        /* \"--CODEGEN--\":2419:2439   */\r\n      calldataload\r\n        /* \"--CODEGEN--\":2394:2440   */\r\n      jump(tag_127)\r\n    tag_126:\r\n        /* \"--CODEGEN--\":2385:2440   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":2379:2445   */\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":2452:2839   */\r\n    tag_16:\r\n      0x0\r\n        /* \"--CODEGEN--\":2586:2588   */\r\n      0x20\r\n        /* \"--CODEGEN--\":2574:2583   */\r\n      dup3\r\n        /* \"--CODEGEN--\":2565:2572   */\r\n      dup5\r\n        /* \"--CODEGEN--\":2561:2584   */\r\n      sub\r\n        /* \"--CODEGEN--\":2557:2589   */\r\n      slt\r\n        /* \"--CODEGEN--\":2554:2556   */\r\n      iszero\r\n      tag_129\r\n      jumpi\r\n        /* \"--CODEGEN--\":2602:2603   */\r\n      0x0\r\n        /* \"--CODEGEN--\":2599:2600   */\r\n      dup1\r\n        /* \"--CODEGEN--\":2592:2604   */\r\n      revert\r\n        /* \"--CODEGEN--\":2554:2556   */\r\n    tag_129:\r\n        /* \"--CODEGEN--\":2665:2666   */\r\n      0x0\r\n        /* \"--CODEGEN--\":2654:2663   */\r\n      dup3\r\n        /* \"--CODEGEN--\":2650:2667   */\r\n      add\r\n        /* \"--CODEGEN--\":2637:2668   */\r\n      calldataload\r\n        /* \"--CODEGEN--\":2688:2706   */\r\n      0xffffffffffffffff\r\n        /* \"--CODEGEN--\":2680:2686   */\r\n      dup2\r\n        /* \"--CODEGEN--\":2677:2707   */\r\n      gt\r\n        /* \"--CODEGEN--\":2674:2676   */\r\n      iszero\r\n      tag_130\r\n      jumpi\r\n        /* \"--CODEGEN--\":2720:2721   */\r\n      0x0\r\n        /* \"--CODEGEN--\":2717:2718   */\r\n      dup1\r\n        /* \"--CODEGEN--\":2710:2722   */\r\n      revert\r\n        /* \"--CODEGEN--\":2674:2676   */\r\n    tag_130:\r\n        /* \"--CODEGEN--\":2740:2823   */\r\n      tag_131\r\n        /* \"--CODEGEN--\":2815:2822   */\r\n      dup5\r\n        /* \"--CODEGEN--\":2806:2812   */\r\n      dup3\r\n        /* \"--CODEGEN--\":2795:2804   */\r\n      dup6\r\n        /* \"--CODEGEN--\":2791:2813   */\r\n      add\r\n        /* \"--CODEGEN--\":2740:2823   */\r\n      jump(tag_87)\r\n    tag_131:\r\n        /* \"--CODEGEN--\":2730:2823   */\r\n      swap2\r\n      pop\r\n        /* \"--CODEGEN--\":2616:2829   */\r\n      pop\r\n        /* \"--CODEGEN--\":2548:2839   */\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":2846:3235   */\r\n    tag_11:\r\n      0x0\r\n        /* \"--CODEGEN--\":2981:2983   */\r\n      0x20\r\n        /* \"--CODEGEN--\":2969:2978   */\r\n      dup3\r\n        /* \"--CODEGEN--\":2960:2967   */\r\n      dup5\r\n        /* \"--CODEGEN--\":2956:2979   */\r\n      sub\r\n        /* \"--CODEGEN--\":2952:2984   */\r\n      slt\r\n        /* \"--CODEGEN--\":2949:2951   */\r\n      iszero\r\n      tag_133\r\n      jumpi\r\n        /* \"--CODEGEN--\":2997:2998   */\r\n      0x0\r\n        /* \"--CODEGEN--\":2994:2995   */\r\n      dup1\r\n        /* \"--CODEGEN--\":2987:2999   */\r\n      revert\r\n        /* \"--CODEGEN--\":2949:2951   */\r\n    tag_133:\r\n        /* \"--CODEGEN--\":3060:3061   */\r\n      0x0\r\n        /* \"--CODEGEN--\":3049:3058   */\r\n      dup3\r\n        /* \"--CODEGEN--\":3045:3062   */\r\n      add\r\n        /* \"--CODEGEN--\":3032:3063   */\r\n      calldataload\r\n        /* \"--CODEGEN--\":3083:3101   */\r\n      0xffffffffffffffff\r\n        /* \"--CODEGEN--\":3075:3081   */\r\n      dup2\r\n        /* \"--CODEGEN--\":3072:3102   */\r\n      gt\r\n        /* \"--CODEGEN--\":3069:3071   */\r\n      iszero\r\n      tag_134\r\n      jumpi\r\n        /* \"--CODEGEN--\":3115:3116   */\r\n      0x0\r\n        /* \"--CODEGEN--\":3112:3113   */\r\n      dup1\r\n        /* \"--CODEGEN--\":3105:3117   */\r\n      revert\r\n        /* \"--CODEGEN--\":3069:3071   */\r\n    tag_134:\r\n        /* \"--CODEGEN--\":3135:3219   */\r\n      tag_135\r\n        /* \"--CODEGEN--\":3211:3218   */\r\n      dup5\r\n        /* \"--CODEGEN--\":3202:3208   */\r\n      dup3\r\n        /* \"--CODEGEN--\":3191:3200   */\r\n      dup6\r\n        /* \"--CODEGEN--\":3187:3209   */\r\n      add\r\n        /* \"--CODEGEN--\":3135:3219   */\r\n      jump(tag_99)\r\n    tag_135:\r\n        /* \"--CODEGEN--\":3125:3219   */\r\n      swap2\r\n      pop\r\n        /* \"--CODEGEN--\":3011:3225   */\r\n      pop\r\n        /* \"--CODEGEN--\":2943:3235   */\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":3242:3483   */\r\n    tag_21:\r\n      0x0\r\n        /* \"--CODEGEN--\":3346:3348   */\r\n      0x20\r\n        /* \"--CODEGEN--\":3334:3343   */\r\n      dup3\r\n        /* \"--CODEGEN--\":3325:3332   */\r\n      dup5\r\n        /* \"--CODEGEN--\":3321:3344   */\r\n      sub\r\n        /* \"--CODEGEN--\":3317:3349   */\r\n      slt\r\n        /* \"--CODEGEN--\":3314:3316   */\r\n      iszero\r\n      tag_137\r\n      jumpi\r\n        /* \"--CODEGEN--\":3362:3363   */\r\n      0x0\r\n        /* \"--CODEGEN--\":3359:3360   */\r\n      dup1\r\n        /* \"--CODEGEN--\":3352:3364   */\r\n      revert\r\n        /* \"--CODEGEN--\":3314:3316   */\r\n    tag_137:\r\n        /* \"--CODEGEN--\":3397:3398   */\r\n      0x0\r\n        /* \"--CODEGEN--\":3414:3467   */\r\n      tag_138\r\n        /* \"--CODEGEN--\":3459:3466   */\r\n      dup5\r\n        /* \"--CODEGEN--\":3450:3456   */\r\n      dup3\r\n        /* \"--CODEGEN--\":3439:3448   */\r\n      dup6\r\n        /* \"--CODEGEN--\":3435:3457   */\r\n      add\r\n        /* \"--CODEGEN--\":3414:3467   */\r\n      jump(tag_125)\r\n    tag_138:\r\n        /* \"--CODEGEN--\":3404:3467   */\r\n      swap2\r\n      pop\r\n        /* \"--CODEGEN--\":3376:3473   */\r\n      pop\r\n        /* \"--CODEGEN--\":3308:3483   */\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":3490:3787   */\r\n    tag_140:\r\n      0x0\r\n        /* \"--CODEGEN--\":3590:3628   */\r\n      tag_141\r\n        /* \"--CODEGEN--\":3622:3627   */\r\n      dup3\r\n        /* \"--CODEGEN--\":3590:3628   */\r\n      jump(tag_142)\r\n    tag_141:\r\n        /* \"--CODEGEN--\":3645:3651   */\r\n      dup1\r\n        /* \"--CODEGEN--\":3640:3643   */\r\n      dup5\r\n        /* \"--CODEGEN--\":3633:3652   */\r\n      mstore\r\n        /* \"--CODEGEN--\":3657:3720   */\r\n      tag_143\r\n        /* \"--CODEGEN--\":3713:3719   */\r\n      dup2\r\n        /* \"--CODEGEN--\":3706:3710   */\r\n      0x20\r\n        /* \"--CODEGEN--\":3701:3704   */\r\n      dup7\r\n        /* \"--CODEGEN--\":3697:3711   */\r\n      add\r\n        /* \"--CODEGEN--\":3690:3694   */\r\n      0x20\r\n        /* \"--CODEGEN--\":3683:3688   */\r\n      dup7\r\n        /* \"--CODEGEN--\":3679:3695   */\r\n      add\r\n        /* \"--CODEGEN--\":3657:3720   */\r\n      jump(tag_144)\r\n    tag_143:\r\n        /* \"--CODEGEN--\":3752:3781   */\r\n      tag_145\r\n        /* \"--CODEGEN--\":3774:3780   */\r\n      dup2\r\n        /* \"--CODEGEN--\":3752:3781   */\r\n      jump(tag_146)\r\n    tag_145:\r\n        /* \"--CODEGEN--\":3745:3749   */\r\n      0x20\r\n        /* \"--CODEGEN--\":3740:3743   */\r\n      dup6\r\n        /* \"--CODEGEN--\":3736:3750   */\r\n      add\r\n        /* \"--CODEGEN--\":3732:3782   */\r\n      add\r\n        /* \"--CODEGEN--\":3725:3782   */\r\n      swap2\r\n      pop\r\n        /* \"--CODEGEN--\":3570:3787   */\r\n      pop\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":3794:4083   */\r\n    tag_148:\r\n      0x0\r\n        /* \"--CODEGEN--\":3890:3924   */\r\n      tag_149\r\n        /* \"--CODEGEN--\":3918:3923   */\r\n      dup3\r\n        /* \"--CODEGEN--\":3890:3924   */\r\n      jump(tag_150)\r\n    tag_149:\r\n        /* \"--CODEGEN--\":3941:3947   */\r\n      dup1\r\n        /* \"--CODEGEN--\":3936:3939   */\r\n      dup5\r\n        /* \"--CODEGEN--\":3929:3948   */\r\n      mstore\r\n        /* \"--CODEGEN--\":3953:4016   */\r\n      tag_151\r\n        /* \"--CODEGEN--\":4009:4015   */\r\n      dup2\r\n        /* \"--CODEGEN--\":4002:4006   */\r\n      0x20\r\n        /* \"--CODEGEN--\":3997:4000   */\r\n      dup7\r\n        /* \"--CODEGEN--\":3993:4007   */\r\n      add\r\n        /* \"--CODEGEN--\":3986:3990   */\r\n      0x20\r\n        /* \"--CODEGEN--\":3979:3984   */\r\n      dup7\r\n        /* \"--CODEGEN--\":3975:3991   */\r\n      add\r\n        /* \"--CODEGEN--\":3953:4016   */\r\n      jump(tag_144)\r\n    tag_151:\r\n        /* \"--CODEGEN--\":4048:4077   */\r\n      tag_152\r\n        /* \"--CODEGEN--\":4070:4076   */\r\n      dup2\r\n        /* \"--CODEGEN--\":4048:4077   */\r\n      jump(tag_146)\r\n    tag_152:\r\n        /* \"--CODEGEN--\":4041:4045   */\r\n      0x20\r\n        /* \"--CODEGEN--\":4036:4039   */\r\n      dup6\r\n        /* \"--CODEGEN--\":4032:4046   */\r\n      add\r\n        /* \"--CODEGEN--\":4028:4078   */\r\n      add\r\n        /* \"--CODEGEN--\":4021:4078   */\r\n      swap2\r\n      pop\r\n        /* \"--CODEGEN--\":3870:4083   */\r\n      pop\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":4090:4382   */\r\n    tag_154:\r\n      0x0\r\n        /* \"--CODEGEN--\":4188:4223   */\r\n      tag_155\r\n        /* \"--CODEGEN--\":4217:4222   */\r\n      dup3\r\n        /* \"--CODEGEN--\":4188:4223   */\r\n      jump(tag_156)\r\n    tag_155:\r\n        /* \"--CODEGEN--\":4240:4246   */\r\n      dup1\r\n        /* \"--CODEGEN--\":4235:4238   */\r\n      dup5\r\n        /* \"--CODEGEN--\":4228:4247   */\r\n      mstore\r\n        /* \"--CODEGEN--\":4252:4315   */\r\n      tag_157\r\n        /* \"--CODEGEN--\":4308:4314   */\r\n      dup2\r\n        /* \"--CODEGEN--\":4301:4305   */\r\n      0x20\r\n        /* \"--CODEGEN--\":4296:4299   */\r\n      dup7\r\n        /* \"--CODEGEN--\":4292:4306   */\r\n      add\r\n        /* \"--CODEGEN--\":4285:4289   */\r\n      0x20\r\n        /* \"--CODEGEN--\":4278:4283   */\r\n      dup7\r\n        /* \"--CODEGEN--\":4274:4290   */\r\n      add\r\n        /* \"--CODEGEN--\":4252:4315   */\r\n      jump(tag_144)\r\n    tag_157:\r\n        /* \"--CODEGEN--\":4347:4376   */\r\n      tag_158\r\n        /* \"--CODEGEN--\":4369:4375   */\r\n      dup2\r\n        /* \"--CODEGEN--\":4347:4376   */\r\n      jump(tag_146)\r\n    tag_158:\r\n        /* \"--CODEGEN--\":4340:4344   */\r\n      0x20\r\n        /* \"--CODEGEN--\":4335:4338   */\r\n      dup6\r\n        /* \"--CODEGEN--\":4331:4345   */\r\n      add\r\n        /* \"--CODEGEN--\":4327:4377   */\r\n      add\r\n        /* \"--CODEGEN--\":4320:4377   */\r\n      swap2\r\n      pop\r\n        /* \"--CODEGEN--\":4168:4382   */\r\n      pop\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":4389:4499   */\r\n    tag_160:\r\n        /* \"--CODEGEN--\":4462:4493   */\r\n      tag_161\r\n        /* \"--CODEGEN--\":4487:4492   */\r\n      dup2\r\n        /* \"--CODEGEN--\":4462:4493   */\r\n      jump(tag_162)\r\n    tag_161:\r\n        /* \"--CODEGEN--\":4457:4460   */\r\n      dup3\r\n        /* \"--CODEGEN--\":4450:4494   */\r\n      mstore\r\n        /* \"--CODEGEN--\":4444:4499   */\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":4506:4775   */\r\n    tag_41:\r\n      0x0\r\n        /* \"--CODEGEN--\":4628:4630   */\r\n      0x20\r\n        /* \"--CODEGEN--\":4617:4626   */\r\n      dup3\r\n        /* \"--CODEGEN--\":4613:4631   */\r\n      add\r\n        /* \"--CODEGEN--\":4605:4631   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":4678:4687   */\r\n      dup2\r\n        /* \"--CODEGEN--\":4672:4676   */\r\n      dup2\r\n        /* \"--CODEGEN--\":4668:4688   */\r\n      sub\r\n        /* \"--CODEGEN--\":4664:4665   */\r\n      0x0\r\n        /* \"--CODEGEN--\":4653:4662   */\r\n      dup4\r\n        /* \"--CODEGEN--\":4649:4666   */\r\n      add\r\n        /* \"--CODEGEN--\":4642:4689   */\r\n      mstore\r\n        /* \"--CODEGEN--\":4703:4765   */\r\n      tag_164\r\n        /* \"--CODEGEN--\":4760:4764   */\r\n      dup2\r\n        /* \"--CODEGEN--\":4751:4757   */\r\n      dup5\r\n        /* \"--CODEGEN--\":4703:4765   */\r\n      jump(tag_148)\r\n    tag_164:\r\n        /* \"--CODEGEN--\":4695:4765   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":4599:4775   */\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":4782:5059   */\r\n    tag_24:\r\n      0x0\r\n        /* \"--CODEGEN--\":4908:4910   */\r\n      0x20\r\n        /* \"--CODEGEN--\":4897:4906   */\r\n      dup3\r\n        /* \"--CODEGEN--\":4893:4911   */\r\n      add\r\n        /* \"--CODEGEN--\":4885:4911   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":4958:4967   */\r\n      dup2\r\n        /* \"--CODEGEN--\":4952:4956   */\r\n      dup2\r\n        /* \"--CODEGEN--\":4948:4968   */\r\n      sub\r\n        /* \"--CODEGEN--\":4944:4945   */\r\n      0x0\r\n        /* \"--CODEGEN--\":4933:4942   */\r\n      dup4\r\n        /* \"--CODEGEN--\":4929:4946   */\r\n      add\r\n        /* \"--CODEGEN--\":4922:4969   */\r\n      mstore\r\n        /* \"--CODEGEN--\":4983:5049   */\r\n      tag_166\r\n        /* \"--CODEGEN--\":5044:5048   */\r\n      dup2\r\n        /* \"--CODEGEN--\":5035:5041   */\r\n      dup5\r\n        /* \"--CODEGEN--\":4983:5049   */\r\n      jump(tag_140)\r\n    tag_166:\r\n        /* \"--CODEGEN--\":4975:5049   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":4879:5059   */\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":5066:5339   */\r\n    tag_30:\r\n      0x0\r\n        /* \"--CODEGEN--\":5190:5192   */\r\n      0x20\r\n        /* \"--CODEGEN--\":5179:5188   */\r\n      dup3\r\n        /* \"--CODEGEN--\":5175:5193   */\r\n      add\r\n        /* \"--CODEGEN--\":5167:5193   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":5240:5249   */\r\n      dup2\r\n        /* \"--CODEGEN--\":5234:5238   */\r\n      dup2\r\n        /* \"--CODEGEN--\":5230:5250   */\r\n      sub\r\n        /* \"--CODEGEN--\":5226:5227   */\r\n      0x0\r\n        /* \"--CODEGEN--\":5215:5224   */\r\n      dup4\r\n        /* \"--CODEGEN--\":5211:5228   */\r\n      add\r\n        /* \"--CODEGEN--\":5204:5251   */\r\n      mstore\r\n        /* \"--CODEGEN--\":5265:5329   */\r\n      tag_168\r\n        /* \"--CODEGEN--\":5324:5328   */\r\n      dup2\r\n        /* \"--CODEGEN--\":5315:5321   */\r\n      dup5\r\n        /* \"--CODEGEN--\":5265:5329   */\r\n      jump(tag_154)\r\n    tag_168:\r\n        /* \"--CODEGEN--\":5257:5329   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":5161:5339   */\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":5346:5539   */\r\n    tag_35:\r\n      0x0\r\n        /* \"--CODEGEN--\":5454:5456   */\r\n      0x20\r\n        /* \"--CODEGEN--\":5443:5452   */\r\n      dup3\r\n        /* \"--CODEGEN--\":5439:5457   */\r\n      add\r\n        /* \"--CODEGEN--\":5431:5457   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":5468:5529   */\r\n      tag_170\r\n        /* \"--CODEGEN--\":5526:5527   */\r\n      0x0\r\n        /* \"--CODEGEN--\":5515:5524   */\r\n      dup4\r\n        /* \"--CODEGEN--\":5511:5528   */\r\n      add\r\n        /* \"--CODEGEN--\":5502:5508   */\r\n      dup5\r\n        /* \"--CODEGEN--\":5468:5529   */\r\n      jump(tag_160)\r\n    tag_170:\r\n        /* \"--CODEGEN--\":5425:5539   */\r\n      swap3\r\n      swap2\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":5546:5802   */\r\n    tag_92:\r\n      0x0\r\n        /* \"--CODEGEN--\":5608:5610   */\r\n      0x40\r\n        /* \"--CODEGEN--\":5602:5611   */\r\n      mload\r\n        /* \"--CODEGEN--\":5592:5611   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":5646:5650   */\r\n      dup2\r\n        /* \"--CODEGEN--\":5638:5644   */\r\n      dup2\r\n        /* \"--CODEGEN--\":5634:5651   */\r\n      add\r\n        /* \"--CODEGEN--\":5745:5751   */\r\n      dup2\r\n        /* \"--CODEGEN--\":5733:5743   */\r\n      dup2\r\n        /* \"--CODEGEN--\":5730:5752   */\r\n      lt\r\n        /* \"--CODEGEN--\":5709:5727   */\r\n      0xffffffffffffffff\r\n        /* \"--CODEGEN--\":5697:5707   */\r\n      dup3\r\n        /* \"--CODEGEN--\":5694:5728   */\r\n      gt\r\n        /* \"--CODEGEN--\":5691:5753   */\r\n      or\r\n        /* \"--CODEGEN--\":5688:5690   */\r\n      iszero\r\n      tag_172\r\n      jumpi\r\n        /* \"--CODEGEN--\":5766:5767   */\r\n      0x0\r\n        /* \"--CODEGEN--\":5763:5764   */\r\n      dup1\r\n        /* \"--CODEGEN--\":5756:5768   */\r\n      revert\r\n        /* \"--CODEGEN--\":5688:5690   */\r\n    tag_172:\r\n        /* \"--CODEGEN--\":5786:5796   */\r\n      dup1\r\n        /* \"--CODEGEN--\":5782:5784   */\r\n      0x40\r\n        /* \"--CODEGEN--\":5775:5797   */\r\n      mstore\r\n        /* \"--CODEGEN--\":5586:5802   */\r\n      pop\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":5809:6072   */\r\n    tag_91:\r\n      0x0\r\n        /* \"--CODEGEN--\":5973:5991   */\r\n      0xffffffffffffffff\r\n        /* \"--CODEGEN--\":5965:5971   */\r\n      dup3\r\n        /* \"--CODEGEN--\":5962:5992   */\r\n      gt\r\n        /* \"--CODEGEN--\":5959:5961   */\r\n      iszero\r\n      tag_174\r\n      jumpi\r\n        /* \"--CODEGEN--\":6005:6006   */\r\n      0x0\r\n        /* \"--CODEGEN--\":6002:6003   */\r\n      dup1\r\n        /* \"--CODEGEN--\":5995:6007   */\r\n      revert\r\n        /* \"--CODEGEN--\":5959:5961   */\r\n    tag_174:\r\n        /* \"--CODEGEN--\":6034:6038   */\r\n      0x20\r\n        /* \"--CODEGEN--\":6026:6032   */\r\n      dup3\r\n        /* \"--CODEGEN--\":6022:6039   */\r\n      mul\r\n        /* \"--CODEGEN--\":6014:6039   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":6062:6066   */\r\n      0x20\r\n        /* \"--CODEGEN--\":6056:6060   */\r\n      dup2\r\n        /* \"--CODEGEN--\":6052:6067   */\r\n      add\r\n        /* \"--CODEGEN--\":6044:6067   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":5896:6072   */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":6079:6343   */\r\n    tag_103:\r\n      0x0\r\n        /* \"--CODEGEN--\":6244:6262   */\r\n      0xffffffffffffffff\r\n        /* \"--CODEGEN--\":6236:6242   */\r\n      dup3\r\n        /* \"--CODEGEN--\":6233:6263   */\r\n      gt\r\n        /* \"--CODEGEN--\":6230:6232   */\r\n      iszero\r\n      tag_176\r\n      jumpi\r\n        /* \"--CODEGEN--\":6276:6277   */\r\n      0x0\r\n        /* \"--CODEGEN--\":6273:6274   */\r\n      dup1\r\n        /* \"--CODEGEN--\":6266:6278   */\r\n      revert\r\n        /* \"--CODEGEN--\":6230:6232   */\r\n    tag_176:\r\n        /* \"--CODEGEN--\":6305:6309   */\r\n      0x20\r\n        /* \"--CODEGEN--\":6297:6303   */\r\n      dup3\r\n        /* \"--CODEGEN--\":6293:6310   */\r\n      mul\r\n        /* \"--CODEGEN--\":6285:6310   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":6333:6337   */\r\n      0x20\r\n        /* \"--CODEGEN--\":6327:6331   */\r\n      dup2\r\n        /* \"--CODEGEN--\":6323:6338   */\r\n      add\r\n        /* \"--CODEGEN--\":6315:6338   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":6167:6343   */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":6350:6604   */\r\n    tag_113:\r\n      0x0\r\n        /* \"--CODEGEN--\":6489:6507   */\r\n      0xffffffffffffffff\r\n        /* \"--CODEGEN--\":6481:6487   */\r\n      dup3\r\n        /* \"--CODEGEN--\":6478:6508   */\r\n      gt\r\n        /* \"--CODEGEN--\":6475:6477   */\r\n      iszero\r\n      tag_178\r\n      jumpi\r\n        /* \"--CODEGEN--\":6521:6522   */\r\n      0x0\r\n        /* \"--CODEGEN--\":6518:6519   */\r\n      dup1\r\n        /* \"--CODEGEN--\":6511:6523   */\r\n      revert\r\n        /* \"--CODEGEN--\":6475:6477   */\r\n    tag_178:\r\n        /* \"--CODEGEN--\":6565:6569   */\r\n      0x1f\r\n        /* \"--CODEGEN--\":6561:6570   */\r\n      not\r\n        /* \"--CODEGEN--\":6554:6558   */\r\n      0x1f\r\n        /* \"--CODEGEN--\":6546:6552   */\r\n      dup4\r\n        /* \"--CODEGEN--\":6542:6559   */\r\n      add\r\n        /* \"--CODEGEN--\":6538:6571   */\r\n      and\r\n        /* \"--CODEGEN--\":6530:6571   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":6594:6598   */\r\n      0x20\r\n        /* \"--CODEGEN--\":6588:6592   */\r\n      dup2\r\n        /* \"--CODEGEN--\":6584:6599   */\r\n      add\r\n        /* \"--CODEGEN--\":6576:6599   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":6412:6604   */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":6611:6866   */\r\n    tag_121:\r\n      0x0\r\n        /* \"--CODEGEN--\":6751:6769   */\r\n      0xffffffffffffffff\r\n        /* \"--CODEGEN--\":6743:6749   */\r\n      dup3\r\n        /* \"--CODEGEN--\":6740:6770   */\r\n      gt\r\n        /* \"--CODEGEN--\":6737:6739   */\r\n      iszero\r\n      tag_180\r\n      jumpi\r\n        /* \"--CODEGEN--\":6783:6784   */\r\n      0x0\r\n        /* \"--CODEGEN--\":6780:6781   */\r\n      dup1\r\n        /* \"--CODEGEN--\":6773:6785   */\r\n      revert\r\n        /* \"--CODEGEN--\":6737:6739   */\r\n    tag_180:\r\n        /* \"--CODEGEN--\":6827:6831   */\r\n      0x1f\r\n        /* \"--CODEGEN--\":6823:6832   */\r\n      not\r\n        /* \"--CODEGEN--\":6816:6820   */\r\n      0x1f\r\n        /* \"--CODEGEN--\":6808:6814   */\r\n      dup4\r\n        /* \"--CODEGEN--\":6804:6821   */\r\n      add\r\n        /* \"--CODEGEN--\":6800:6833   */\r\n      and\r\n        /* \"--CODEGEN--\":6792:6833   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":6856:6860   */\r\n      0x20\r\n        /* \"--CODEGEN--\":6850:6854   */\r\n      dup2\r\n        /* \"--CODEGEN--\":6846:6861   */\r\n      add\r\n        /* \"--CODEGEN--\":6838:6861   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":6674:6866   */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":6873:6960   */\r\n    tag_150:\r\n      0x0\r\n        /* \"--CODEGEN--\":6949:6954   */\r\n      dup2\r\n        /* \"--CODEGEN--\":6943:6955   */\r\n      mload\r\n        /* \"--CODEGEN--\":6933:6955   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":6927:6960   */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":6967:7058   */\r\n    tag_142:\r\n      0x0\r\n        /* \"--CODEGEN--\":7047:7052   */\r\n      dup2\r\n        /* \"--CODEGEN--\":7041:7053   */\r\n      mload\r\n        /* \"--CODEGEN--\":7031:7053   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":7025:7058   */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":7065:7153   */\r\n    tag_156:\r\n      0x0\r\n        /* \"--CODEGEN--\":7142:7147   */\r\n      dup2\r\n        /* \"--CODEGEN--\":7136:7148   */\r\n      mload\r\n        /* \"--CODEGEN--\":7126:7148   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":7120:7153   */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":7160:7239   */\r\n    tag_162:\r\n      0x0\r\n        /* \"--CODEGEN--\":7229:7234   */\r\n      dup2\r\n        /* \"--CODEGEN--\":7218:7234   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":7212:7239   */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":7246:7325   */\r\n    tag_127:\r\n      0x0\r\n        /* \"--CODEGEN--\":7315:7320   */\r\n      dup2\r\n        /* \"--CODEGEN--\":7304:7320   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":7298:7325   */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":7333:7478   */\r\n    tag_116:\r\n        /* \"--CODEGEN--\":7414:7420   */\r\n      dup3\r\n        /* \"--CODEGEN--\":7409:7412   */\r\n      dup2\r\n        /* \"--CODEGEN--\":7404:7407   */\r\n      dup4\r\n        /* \"--CODEGEN--\":7391:7421   */\r\n      calldatacopy\r\n        /* \"--CODEGEN--\":7470:7471   */\r\n      0x0\r\n        /* \"--CODEGEN--\":7461:7467   */\r\n      dup4\r\n        /* \"--CODEGEN--\":7456:7459   */\r\n      dup4\r\n        /* \"--CODEGEN--\":7452:7468   */\r\n      add\r\n        /* \"--CODEGEN--\":7445:7472   */\r\n      mstore\r\n        /* \"--CODEGEN--\":7384:7478   */\r\n      pop\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":7487:7755   */\r\n    tag_144:\r\n        /* \"--CODEGEN--\":7552:7553   */\r\n      0x0\r\n        /* \"--CODEGEN--\":7559:7660   */\r\n    tag_188:\r\n        /* \"--CODEGEN--\":7573:7579   */\r\n      dup4\r\n        /* \"--CODEGEN--\":7570:7571   */\r\n      dup2\r\n        /* \"--CODEGEN--\":7567:7580   */\r\n      lt\r\n        /* \"--CODEGEN--\":7559:7660   */\r\n      iszero\r\n      tag_189\r\n      jumpi\r\n        /* \"--CODEGEN--\":7649:7650   */\r\n      dup1\r\n        /* \"--CODEGEN--\":7644:7647   */\r\n      dup3\r\n        /* \"--CODEGEN--\":7640:7651   */\r\n      add\r\n        /* \"--CODEGEN--\":7634:7652   */\r\n      mload\r\n        /* \"--CODEGEN--\":7630:7631   */\r\n      dup2\r\n        /* \"--CODEGEN--\":7625:7628   */\r\n      dup5\r\n        /* \"--CODEGEN--\":7621:7632   */\r\n      add\r\n        /* \"--CODEGEN--\":7614:7653   */\r\n      mstore\r\n        /* \"--CODEGEN--\":7595:7597   */\r\n      0x20\r\n        /* \"--CODEGEN--\":7592:7593   */\r\n      dup2\r\n        /* \"--CODEGEN--\":7588:7598   */\r\n      add\r\n        /* \"--CODEGEN--\":7583:7598   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":7559:7660   */\r\n      jump(tag_188)\r\n    tag_189:\r\n        /* \"--CODEGEN--\":7675:7681   */\r\n      dup4\r\n        /* \"--CODEGEN--\":7672:7673   */\r\n      dup2\r\n        /* \"--CODEGEN--\":7669:7682   */\r\n      gt\r\n        /* \"--CODEGEN--\":7666:7668   */\r\n      iszero\r\n      tag_191\r\n      jumpi\r\n        /* \"--CODEGEN--\":7740:7741   */\r\n      0x0\r\n        /* \"--CODEGEN--\":7731:7737   */\r\n      dup5\r\n        /* \"--CODEGEN--\":7726:7729   */\r\n      dup5\r\n        /* \"--CODEGEN--\":7722:7738   */\r\n      add\r\n        /* \"--CODEGEN--\":7715:7742   */\r\n      mstore\r\n        /* \"--CODEGEN--\":7666:7668   */\r\n    tag_191:\r\n        /* \"--CODEGEN--\":7536:7755   */\r\n      pop\r\n      pop\r\n      pop\r\n      pop\r\n      jump\r\n        /* \"--CODEGEN--\":7763:7860   */\r\n    tag_146:\r\n      0x0\r\n        /* \"--CODEGEN--\":7851:7853   */\r\n      0x1f\r\n        /* \"--CODEGEN--\":7847:7854   */\r\n      not\r\n        /* \"--CODEGEN--\":7842:7844   */\r\n      0x1f\r\n        /* \"--CODEGEN--\":7835:7840   */\r\n      dup4\r\n        /* \"--CODEGEN--\":7831:7845   */\r\n      add\r\n        /* \"--CODEGEN--\":7827:7855   */\r\n      and\r\n        /* \"--CODEGEN--\":7817:7855   */\r\n      swap1\r\n      pop\r\n        /* \"--CODEGEN--\":7811:7860   */\r\n      swap2\r\n      swap1\r\n      pop\r\n      jump\r\n\r\n    auxdata: 0xa265627a7a72305820c13ebadd7c63100dbfb8b23f4cd71e360ee77691a607b09383d8fbbf4d478d3a6c6578706572696d656e74616cf50037\r\n}\r\n\r\n"
  },
  {
    "path": "truffle/bytes/contracts/Bytes.sol",
    "content": "pragma solidity ^0.4.24;\n\npragma experimental ABIEncoderV2;\n\ncontract Bytes {\n    bytes[] public data;\n    string[] public data2;\n    \n    function setData(bytes[] _data) public {\n        data = _data;\n    }\n    \n    function setData2(string[] _data2) public {\n        data2 = _data2;\n    }\n    \n    function getDataItem(uint position) public view returns (bytes) {\n        return data[position];\n    }\n}"
  },
  {
    "path": "truffle/bytes/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.23;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  constructor() public {\n    owner = msg.sender;\n  }\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/bytes/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/bytes/scripts/.gitignore",
    "content": "data.json"
  },
  {
    "path": "truffle/bytes/scripts/README.md",
    "content": "# Scripts\n\n## Installation\n\n## Configuration\n\n## Commands\n\n### Deploy contract\n\n### List owners\n\n### List prices\n\n### Item information\n\n### Sell item\n\n### Buy item\n\n\n\n"
  },
  {
    "path": "truffle/bytes/scripts/config.js",
    "content": "\nmodule.exports = {\n    networks: {\n        development: {\n            provider: \"http://localhost:8545\"\n        },\n        rsk: {\n            provider: \"http://localhost:4444\"\n        }\n    }\n};\n\n"
  },
  {
    "path": "truffle/bytes/scripts/deploy.js",
    "content": "\nconst fs = require('fs');\nconst rskapi = require('rskapi');\nconst simpleabi = require('simpleabi');\n\nconst config = require('./config');\n\nvar data;\n\ntry {\n    data = require('./data.json');\n}\ncatch (err) {\n    data = {};\n}\n\nconst Collectible = require('../build/contracts/Collectible.json');\n\nconst network = 'development';\n\nconst provider = config.networks[network].provider;\nconst host = rskapi.host(provider);\n\nconst bytecodes = Collectible.bytecode;\nconst params = simpleabi.encodeValues(1000, 100);\n\nasync function run() {\n    const accounts = await host.getAccounts();\n    const account = accounts[0];\n    \n    const tx = {\n        from: account,\n        data: bytecodes + params,\n        value: 0,\n        gas: 2000000,\n        gasPrice: 0\n    }\n    \n    const txhash = await host.sendTransaction(tx);\n\n    console.log(\"tx\", txhash);\n    \n    var counter = 0;\n\n    var txr = null\n    \n    while (counter++ < 50 && !txr)\n        txr = await host.getTransactionReceiptByHash(txhash);\n    \n    console.log('contract address', txr.contractAddress);\n    console.log('gas used', parseInt(txr.gasUsed));\n    \n    if (!data.networks)\n        data.networks = {};\n    \n    if (!data.networks[network])\n        data.networks[network] = {};\n    \n    data.networks[network].contractAddress = txr.contractAddress;\n    \n    const datajson = JSON.stringify(data, null, 4);\n    \n    fs.writeFileSync('data.json', datajson);\n}\n\nrun();\n"
  },
  {
    "path": "truffle/bytes/scripts/package.json",
    "content": "{\n  \"name\": \"scripts\",\n  \"private\": true,\n  \"version\": \"1.0.0\",\n  \"description\": \"Game scripts\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"MIT\",\n  \"dependencies\": {\n    \"ethereumjs-tx\": \"^1.3.7\",\n    \"rskapi\": \"0.0.10\",\n    \"simpleabi\": \"0.0.3\"\n  }\n}\n"
  },
  {
    "path": "truffle/bytes/test/Bytes_test.js",
    "content": "\nconst Bytes = artifacts.require('./Bytes.sol');\n\ncontract('Bytes', function (accounts) {\n    /*\n    it('set data and get item', async function () {\n        const bytes = await Bytes.new();\n        \n        await bytes.setData([ '0x01', '0x0102', '0x01022a' ]);\n    });\n\n    it('set data2 and get item', async function () {\n        const bytes = await Bytes.new();\n        \n        await bytes.setData2([ 'adam', 'eve' ]);\n    });\n    */\n    \n    it('transaction', async function () {\n        const bytes = await Bytes.new();\n        \n        const txdata = {\n            from: accounts[0],\n            to: bytes.address,\n            gas: \"0x6691b7\",\n            gasPrice: \"0x100\",\n            data: \"0x9d5ef15e00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020102000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000301022a0000000000000000000000000000000000000000000000000000000000\"\n        };\n        \n        await web3.eth.sendTransaction(txdata);\n        \n        const item0 = await bytes.getDataItem(0);\n        assert.equal(item0, '0x01');\n        \n        const item1 = await bytes.getDataItem(1);\n        assert.equal(item1, '0x0102');\n        \n        const item2 = await bytes.getDataItem(2);\n        assert.equal(item2, '0x01022a');\n    });\n});\n"
  },
  {
    "path": "truffle/bytes/truffle-config.js",
    "content": "/*\n * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a \n * function when declaring them. Failure to do so will cause commands to hang. ex:\n * ```\n * mainnet: {\n *     provider: function() { \n *       return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>') \n *     },\n *     network_id: '1',\n *     gas: 4500000,\n *     gasPrice: 10000000000,\n *   },\n */\n\nmodule.exports = {\n  // See <http://truffleframework.com/docs/advanced/configuration>\n  // to customize your Truffle configuration!\n  /*\n  networks: {\n    development: {\n      host: \"127.0.0.1\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    },\n    regtest: {\n      host: \"127.0.0.1\",\n      port: 4444,\n      network_id: \"*\" // Match any network id\n    }\n  }\n  */\n};\n"
  },
  {
    "path": "truffle/first/contracts/ConvertLib.sol",
    "content": "pragma solidity ^0.4.4;\n\nlibrary ConvertLib{\n\tfunction convert(uint amount,uint conversionRate) returns (uint convertedAmount)\n\t{\n\t\treturn amount * conversionRate;\n\t}\n}\n"
  },
  {
    "path": "truffle/first/contracts/MetaCoin.sol",
    "content": "pragma solidity ^0.4.4;\n\nimport \"./ConvertLib.sol\";\n\n// This is just a simple example of a coin-like contract.\n// It is not standards compatible and cannot be expected to talk to other\n// coin/token contracts. If you want to create a standards-compliant\n// token, see: https://github.com/ConsenSys/Tokens. Cheers!\n\ncontract MetaCoin {\n\tmapping (address => uint) balances;\n\n\tevent Transfer(address indexed _from, address indexed _to, uint256 _value);\n\n\tfunction MetaCoin() {\n\t\tbalances[tx.origin] = 10000;\n\t}\n\n\tfunction sendCoin(address receiver, uint amount) returns(bool sufficient) {\n\t\tif (balances[msg.sender] < amount) return false;\n\t\tbalances[msg.sender] -= amount;\n\t\tbalances[receiver] += amount;\n\t\tTransfer(msg.sender, receiver, amount);\n\t\treturn true;\n\t}\n\n\tfunction getBalanceInEth(address addr) returns(uint){\n\t\treturn ConvertLib.convert(getBalance(addr),2);\n\t}\n\n\tfunction getBalance(address addr) returns(uint) {\n\t\treturn balances[addr];\n\t}\n}\n"
  },
  {
    "path": "truffle/first/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.4;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function Migrations() {\n    owner = msg.sender;\n  }\n\n  function setCompleted(uint completed) restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/first/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/first/migrations/2_deploy_contracts.js",
    "content": "var ConvertLib = artifacts.require(\"./ConvertLib.sol\");\nvar MetaCoin = artifacts.require(\"./MetaCoin.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(ConvertLib);\n  deployer.link(ConvertLib, MetaCoin);\n  deployer.deploy(MetaCoin);\n};\n"
  },
  {
    "path": "truffle/first/test/TestMetacoin.sol",
    "content": "pragma solidity ^0.4.2;\n\nimport \"truffle/Assert.sol\";\nimport \"truffle/DeployedAddresses.sol\";\nimport \"../contracts/MetaCoin.sol\";\n\ncontract TestMetacoin {\n\n  function testInitialBalanceUsingDeployedContract() {\n    MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());\n\n    uint expected = 10000;\n\n    Assert.equal(meta.getBalance(tx.origin), expected, \"Owner should have 10000 MetaCoin initially\");\n  }\n\n  function testInitialBalanceWithNewMetaCoin() {\n    MetaCoin meta = new MetaCoin();\n\n    uint expected = 10000;\n\n    Assert.equal(meta.getBalance(tx.origin), expected, \"Owner should have 10000 MetaCoin initially\");\n  }\n\n}\n"
  },
  {
    "path": "truffle/first/test/metacoin.js",
    "content": "var MetaCoin = artifacts.require(\"./MetaCoin.sol\");\n\ncontract('MetaCoin', function(accounts) {\n  it(\"should put 10000 MetaCoin in the first account\", function() {\n    return MetaCoin.deployed().then(function(instance) {\n      return instance.getBalance.call(accounts[0]);\n    }).then(function(balance) {\n      assert.equal(balance.valueOf(), 10000, \"10000 wasn't in the first account\");\n    });\n  });\n  it(\"should call a function that depends on a linked library\", function() {\n    var meta;\n    var metaCoinBalance;\n    var metaCoinEthBalance;\n\n    return MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(accounts[0]);\n    }).then(function(outCoinBalance) {\n      metaCoinBalance = outCoinBalance.toNumber();\n      return meta.getBalanceInEth.call(accounts[0]);\n    }).then(function(outCoinBalanceEth) {\n      metaCoinEthBalance = outCoinBalanceEth.toNumber();\n    }).then(function() {\n      assert.equal(metaCoinEthBalance, 2 * metaCoinBalance, \"Library function returned unexpected function, linkage may be broken\");\n    });\n  });\n  it(\"should send coin correctly\", function() {\n    var meta;\n\n    // Get initial balances of first and second account.\n    var account_one = accounts[0];\n    var account_two = accounts[1];\n\n    var account_one_starting_balance;\n    var account_two_starting_balance;\n    var account_one_ending_balance;\n    var account_two_ending_balance;\n\n    var amount = 10;\n\n    return MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(account_one);\n    }).then(function(balance) {\n      account_one_starting_balance = balance.toNumber();\n      return meta.getBalance.call(account_two);\n    }).then(function(balance) {\n      account_two_starting_balance = balance.toNumber();\n      return meta.sendCoin(account_two, amount, {from: account_one});\n    }).then(function() {\n      return meta.getBalance.call(account_one);\n    }).then(function(balance) {\n      account_one_ending_balance = balance.toNumber();\n      return meta.getBalance.call(account_two);\n    }).then(function(balance) {\n      account_two_ending_balance = balance.toNumber();\n\n      assert.equal(account_one_ending_balance, account_one_starting_balance - amount, \"Amount wasn't correctly taken from the sender\");\n      assert.equal(account_two_ending_balance, account_two_starting_balance + amount, \"Amount wasn't correctly sent to the receiver\");\n    });\n  });\n});\n"
  },
  {
    "path": "truffle/first/truffle.js",
    "content": "module.exports = {\n  networks: {\n    development: {\n      host: \"localhost\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};\n"
  },
  {
    "path": "truffle/kc1/Ballot.txt",
    "content": "\n- Votar por si una propuesta\n- Evitar voto doble\n- Saber cuantos votos si tiene una propuesta\n- Solo un grupo de cuentas pueda votar\n"
  },
  {
    "path": "truffle/kc1/contracts/Ballot.sol",
    "content": "pragma solidity ^0.4.24;\n\ncontract Ballot {\n    mapping (uint => address[]) public votes;\n    address[] public members;\n    \n    constructor(address[] _members) public {\n        members = _members;\n    }\n    \n    function isMember(address user) private view returns (bool) {\n        for (uint k = 0; k < members.length; k++)\n            if (user == members[k])\n                return true;\n                \n        return false;\n    }\n    \n    modifier onlyMember() {\n        require(isMember(msg.sender));\n        _;        \n    }\n    \n    function vote(uint id) public onlyMember() {\n        address[] storage vts = votes[id];\n        \n        for (uint k = 0; k < vts.length; k++)\n            if (vts[k] == msg.sender)\n                return;\n                \n        vts.push(msg.sender);\n    }\n    \n    function noVotes(uint id) public view returns (uint) {\n        return votes[id].length;\n    }\n}\n\n    "
  },
  {
    "path": "truffle/kc1/contracts/Counter.sol",
    "content": "pragma solidity ^0.4.24;\n\ncontract Counter {\n    uint public counter;\n    \n    constructor() public {\n        counter = 1;\n    }\n    \n    function increment() public {\n        counter++;\n    }\n    \n    function add(uint value) public {\n        counter += value;\n    }\n}\n"
  },
  {
    "path": "truffle/kc1/contracts/Empty.sol",
    "content": "pragma solidity >=0.4.21 <0.6.0;\n    \ncontract Empty {\n}\n"
  },
  {
    "path": "truffle/kc1/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.23;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  constructor() public {\n    owner = msg.sender;\n  }\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/kc1/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/kc1/migrations/2_deploy_contracts.js",
    "content": "var Empty = artifacts.require(\"Empty\");\nvar Counter = artifacts.require(\"Counter\");\n//var Ballot = artifacts.require(\"Ballot\");\n\nmodule.exports = function(deployer) {\n    deployer.deploy(Empty);\n    deployer.deploy(Counter);\n    //deployer.deploy(Ballot);\n};\n\n"
  },
  {
    "path": "truffle/kc1/test/Ballot_test.js",
    "content": "\nconst Ballot = artifacts.require('Ballot');\n\nasync function expectThrow (promise) {\n  try {\n    await promise;\n  } catch (error) {\n      return;\n  }\n  \n  assert.fail('Expected throw not received');\n}\n\ncontract('Ballot', function (accounts) {\n    const members = [ accounts[0], accounts[1], accounts[2] ];\n    \n    beforeEach(async function () {\n        this.ballot = await Ballot.new(members);\n    });\n    \n    it('no vote for new proposal', async function () {\n       const novotes = await this.ballot.noVotes(1);\n       \n       assert.equal(novotes, 0);\n    });\n    \n    it('vote proposal', async function () {\n       await this.ballot.vote(1);\n       \n       const novotes = await this.ballot.noVotes(1);\n       \n       assert.equal(novotes, 1);\n    });\n    \n    it('vote proposal twice', async function () {\n       await this.ballot.vote(1, { from: accounts[0] });\n       await this.ballot.vote(1, { from: accounts[1] });\n       \n       const novotes = await this.ballot.noVotes(1);\n       \n       assert.equal(novotes, 2);\n    });\n    \n    it('cannot vote twice with the same account', async function () {\n       await this.ballot.vote(1);\n       await this.ballot.vote(1);\n       \n       const novotes = await this.ballot.noVotes(1);\n       \n       assert.equal(novotes, 1);\n    });\n    \n    it('non member cannot vote', async function () {\n       await expectThrow(this.ballot.vote(1, { from: accounts[4] }));\n    });\n});\n\n"
  },
  {
    "path": "truffle/kc1/test/Counter_test.js",
    "content": "\nconst Counter = artifacts.require(\"Counter\");\n\ncontract('Counter', function (accounts) {\n    //console.log(accounts);\n    \n    beforeEach(async function () {\n        this.counter = await Counter.new();\n    });\n    \n    it('counter is one', async function () {\n        //console.log(counter.address);\n        const c = await this.counter.counter();\n        //console.log(c.toNumber());\n        assert.equal(c, 1);\n    });\n    \n    it('increment', async function () {\n        await this.counter.increment();\n        const c = await this.counter.counter();\n        assert.equal(c, 2);\n    });\n    \n    it('add', async function () {\n        await this.counter.increment();\n        await this.counter.add(40);\n        const c = await this.counter.counter();\n        assert.equal(c, 42);\n    });\n});\n\n"
  },
  {
    "path": "truffle/kc1/truffle-config.js",
    "content": "/*\n * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a \n * function when declaring them. Failure to do so will cause commands to hang. ex:\n * ```\n * mainnet: {\n *     provider: function() { \n *       return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>') \n *     },\n *     network_id: '1',\n *     gas: 4500000,\n *     gasPrice: 10000000000,\n *   },\n */\n\nmodule.exports = {\n  // See <http://truffleframework.com/docs/advanced/configuration>\n  // to customize your Truffle configuration!\n\n  networks: {\n    development: {\n      host: \"127.0.0.1\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};\n\n\n"
  },
  {
    "path": "truffle/mug1/contracts/Counter.sol",
    "content": "\r\ncontract Counter {\r\n\tuint public counter;\r\n\t\r\n\tfunction increment() public {\r\n\t\tcounter++;\r\n\t}\r\n\t\r\n\tfunction add(uint value) public {\r\n\t\tcounter += value;\r\n\t}\r\n\t\r\n\tfunction process(bytes data) public {\r\n\t\t\r\n\t}\r\n\t\r\n\tfunction add(uint value, uint value2) public {\r\n\t\tcounter += value + value2;\r\n\t}\r\n}"
  },
  {
    "path": "truffle/mug1/contracts/Empty.sol",
    "content": "\r\ncontract Empty {\r\n\r\n}"
  },
  {
    "path": "truffle/mug1/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.23;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  constructor() public {\n    owner = msg.sender;\n  }\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/mug1/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/mug1/migrations/2_deploy_contracts.js",
    "content": "var Empty = artifacts.require(\"./Empty.sol\");\r\n\r\nmodule.exports = function(deployer) {\r\n  deployer.deploy(Empty);\r\n};\r\n"
  },
  {
    "path": "truffle/mug1/test/counter_test.js",
    "content": "\r\nvar Counter = artifacts.require('./Counter.sol');\r\n\r\ncontract('Counter', function (accounts) {\r\n\tconsole.log(accounts);\r\n\t\r\n\tvar contract;\r\n\t\r\n\tbeforeEach(async function() {\r\n\t\tcontract = await Counter.new();\r\n\t\t\r\n\t\tconsole.log('contract deployed', contract.address);\t\t\r\n\t});\r\n\t\r\n\tit('create contract', async function () {\r\n\t\tassert.equal(await contract.counter(), 0);\r\n\t});\r\n\t\r\n\tit('increment counter', async function () {\r\n\t\tawait contract.increment();\r\n\t\t\r\n\t\tassert.equal(await contract.counter(), 1);\r\n\t});\r\n\r\n\tit('add counter', async function () {\r\n\t\tawait contract.increment();\r\n\t\tawait contract.increment();\r\n\t\tawait contract.add(40, { from: accounts[1], gasPrice: 1, gas: 3000000 });\r\n\t\t\r\n\t\t// web3.eth.getAccounts();\r\n\t\t\r\n\t\tassert.equal(await contract.counter(), 42);\r\n\t});\r\n\r\n\tit('add counter with two arguments', async function () {\r\n\t\tawait contract.increment();\r\n\t\tawait contract.increment();\r\n\t\t\r\n\t\t// await contract.add(20, 20, { from: accounts[1], gasPrice: 1, gas: 3000000 });\r\n\t\t\r\n\t\t// assert.equal(await contract.counter(), 42);\r\n\t\t\r\n\t\t// await contract.process(\"0x01020304\");\r\n\t});\r\n});\r\n\r\n"
  },
  {
    "path": "truffle/mug1/truffle-config.js",
    "content": "module.exports = {\n  networks: {\n    development: {\n      host: \"127.0.0.1\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n\t}\n  }\n};"
  },
  {
    "path": "truffle/mug2/contracts/Counter.sol",
    "content": "pragma solidity ^0.4.24;\n\ncontract Counter {\n    uint public counter;\n    \n    constructor() public {\n        counter = 1;\n    }\n    \n    function increment() public {\n        counter++;\n    }\n    \n    function add(uint val) public {\n        counter += val;\n    }\n}\n\n"
  },
  {
    "path": "truffle/mug2/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.23;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  constructor() public {\n    owner = msg.sender;\n  }\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/mug2/contracts/Token.sol",
    "content": "pragma solidity ^0.4.24;\n\ncontract Token {\n    mapping (address => uint) balances;\n    \n    address owner;\n    \n    constructor(uint initial) public {\n        balances[msg.sender] = initial;\n        owner = msg.sender;\n    }\n    \n    function balanceOf(address account) public view returns (uint) {\n        return balances[account];\n    }\n    \n    function transfer(address receiver, uint amount) public {\n        require(balances[msg.sender] >= amount);\n        \n        balances[msg.sender] -= amount; \n        balances[receiver] += amount;\n    }\n\n    modifier onlyOwner() {\n        require(msg.sender == owner);\n        _;\n    }\n    \n    function emit(uint amount) onlyOwner public {\n        balances[msg.sender] += amount;\n    }\n}\n\n"
  },
  {
    "path": "truffle/mug2/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/mug2/migrations/2_deploy_contracts.js",
    "content": "var Counter = artifacts.require(\"./Counter.sol\");\n\nmodule.exports = function (deployer) {\n  deployer.deploy(Counter);\n};\n"
  },
  {
    "path": "truffle/mug2/test/Counter_test.js",
    "content": "\nconst Counter = artifacts.require('./Counter.sol');\n\ncontract('Counter', function (accounts) {\n//    console.dir(accounts);\n    var counter;\n    \n    beforeEach(async function() {\n        counter = await Counter.new();\n    });\n\n    describe('first tests', function () {\n        it('initial counter', async function () {\n            const c1 = await counter.counter();\n            \n            assert.equal(c1, 1);\n        });\n\n        it('increment', async function () {\n            await counter.increment();\n            \n            const c1 = await counter.counter();\n            \n            assert.equal(c1, 2);\n        });\n\n        it('add', async function () {\n            await counter.increment();\n            await counter.add(40);\n            \n            const c1 = await counter.counter();\n            \n            assert.equal(c1, 42);\n        });\n    });\n});\n\n"
  },
  {
    "path": "truffle/mug2/test/Token_test.js",
    "content": "\nconst Token = artifacts.require('./Token.sol');\n\nasync function expectThrow (promise) {\n  try {\n    await promise;\n  } catch (error) {\n      return;\n  }\n  \n  assert.fail('Expected throw not received');\n}\n\ncontract('Token', function (accounts) {\n    it('create token with initial balance', async function () {\n        var token = await Token.new(10000);\n        \n        const balance = await token.balanceOf(accounts[0]);\n        \n        assert.equal(balance, 10000);\n    });\n    \n    it('transfer tokens', async function ()  {\n        var token = await Token.new(10000);\n        \n        await token.transfer(accounts[1], 1000);\n        \n        const balance = await token.balanceOf(accounts[0]);\n        assert.equal(balance, 9000);\n        const balance2 = await token.balanceOf(accounts[1]);\n        assert.equal(balance2, 1000);\n    });\n    \n    it('cannot transfer tokens if not enough balance', async function ()  {\n        var token = await Token.new(10000);\n        \n        expectThrow(token.transfer(accounts[1], 1000, { from: accounts[2] }));\n        \n        const balance = await token.balanceOf(accounts[0]);\n        assert.equal(balance, 10000);\n        const balance2 = await token.balanceOf(accounts[1]);\n        assert.equal(balance2, 0);\n        const balance3 = await token.balanceOf(accounts[2]);\n        assert.equal(balance3, 0);\n    });\n\n    it('owner emits new tokens', async function ()  {\n        var token = await Token.new(10000);\n        \n        await token.emit(1000);\n        \n        const balance = await token.balanceOf(accounts[0]);\n        assert.equal(balance, 11000);\n    });\n\n    it('not owner cannot emit new tokens', async function ()  {\n        var token = await Token.new(10000);\n\n        expectThrow(token.emit(1000, { from: accounts[1] }));\n        \n        const balance = await token.balanceOf(accounts[0]);\n        assert.equal(balance, 10000);\n        const balance2 = await token.balanceOf(accounts[1]);\n        assert.equal(balance2, 0);\n    });\n});\n\n"
  },
  {
    "path": "truffle/mug2/truffle-config.js",
    "content": "/*\n * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a \n * function when declaring them. Failure to do so will cause commands to hang. ex:\n * ```\n * mainnet: {\n *     provider: function() { \n *       return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>') \n *     },\n *     network_id: '1',\n *     gas: 4500000,\n *     gasPrice: 10000000000,\n *   },\n */\n\nmodule.exports = {\n  networks: {\n    development: {\n      host: \"127.0.0.1\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    },\n    testnet: {\n      host: \"127.0.0.1\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    },\n    mainnet: {\n      host: \"127.0.0.1\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};"
  },
  {
    "path": "truffle/oz/contracts/Bounty.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport './payment/PullPayment.sol';\nimport './lifecycle/Destructible.sol';\n\n\n/**\n * @title Bounty\n * @dev This bounty will pay out to a researcher if they break invariant logic of the contract.\n */\ncontract Bounty is PullPayment, Destructible {\n  bool public claimed;\n  mapping(address => address) public researchers;\n\n  event TargetCreated(address createdAddress);\n\n  /**\n   * @dev Fallback function allowing the contract to receive funds, if they haven't already been claimed.\n   */\n  function() external payable {\n    require(!claimed);\n  }\n\n  /**\n   * @dev Create and deploy the target contract (extension of Target contract), and sets the\n   * msg.sender as a researcher\n   * @return A target contract\n   */\n  function createTarget() public returns(Target) {\n    Target target = Target(deployContract());\n    researchers[target] = msg.sender;\n    TargetCreated(target);\n    return target;\n  }\n\n  /**\n   * @dev Internal function to deploy the target contract.\n   * @return A target contract address\n   */\n  function deployContract() internal returns(address);\n\n  /**\n   * @dev Sends the contract funds to the researcher that proved the contract is broken.\n   * @param target contract\n   */\n  function claim(Target target) public {\n    address researcher = researchers[target];\n    require(researcher != 0);\n    // Check Target contract invariants\n    require(!target.checkInvariant());\n    asyncSend(researcher, this.balance);\n    claimed = true;\n  }\n\n}\n\n\n/**\n * @title Target\n * @dev Your main contract should inherit from this class and implement the checkInvariant method.\n */\ncontract Target {\n\n   /**\n    * @dev Checks all values a contract assumes to be true all the time. If this function returns\n    * false, the contract is broken in some way and is in an inconsistent state.\n    * In order to win the bounty, security researchers will try to cause this broken state.\n    * @return True if all invariant values are correct, false otherwise.\n    */\n  function checkInvariant() public returns(bool);\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ConvertLib.sol",
    "content": "pragma solidity ^0.4.4;\n\nlibrary ConvertLib{\n\tfunction convert(uint amount,uint conversionRate) returns (uint convertedAmount)\n\t{\n\t\treturn amount * conversionRate;\n\t}\n}\n"
  },
  {
    "path": "truffle/oz/contracts/DayLimit.sol",
    "content": "pragma solidity ^0.4.18;\n\n/**\n * @title DayLimit\n * @dev Base contract that enables methods to be protected by placing a linear limit (specifiable)\n * on a particular resource per calendar day. Is multiowned to allow the limit to be altered.\n */\ncontract DayLimit {\n\n  uint256 public dailyLimit;\n  uint256 public spentToday;\n  uint256 public lastDay;\n\n  /**\n   * @dev Constructor that sets the passed value as a dailyLimit.\n   * @param _limit uint256 to represent the daily limit.\n   */\n  function DayLimit(uint256 _limit) public {\n    dailyLimit = _limit;\n    lastDay = today();\n  }\n\n  /**\n   * @dev sets the daily limit. Does not alter the amount already spent today.\n   * @param _newLimit uint256 to represent the new limit.\n   */\n  function _setDailyLimit(uint256 _newLimit) internal {\n    dailyLimit = _newLimit;\n  }\n\n  /**\n   * @dev Resets the amount already spent today.\n   */\n  function _resetSpentToday() internal {\n    spentToday = 0;\n  }\n\n  /**\n   * @dev Checks to see if there is enough resource to spend today. If true, the resource may be expended.\n   * @param _value uint256 representing the amount of resource to spend.\n   * @return A boolean that is True if the resource was spent and false otherwise.\n   */\n  function underLimit(uint256 _value) internal returns (bool) {\n    // reset the spend limit if we're on a different day to last time.\n    if (today() > lastDay) {\n      spentToday = 0;\n      lastDay = today();\n    }\n    // check to see if there's enough left - if so, subtract and return true.\n    // overflow protection                    // dailyLimit check\n    if (spentToday + _value >= spentToday && spentToday + _value <= dailyLimit) {\n      spentToday += _value;\n      return true;\n    }\n    return false;\n  }\n\n  /**\n   * @dev Private function to determine today's index\n   * @return uint256 of today's index.\n   */\n  function today() private view returns (uint256) {\n    return now / 1 days;\n  }\n\n  /**\n   * @dev Simple modifier for daily limit.\n   */\n  modifier limitedDaily(uint256 _value) {\n    require(underLimit(_value));\n    _;\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ECRecovery.sol",
    "content": "pragma solidity ^0.4.18;\n\n\n/**\n * @title Eliptic curve signature operations\n *\n * @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d\n */\n\nlibrary ECRecovery {\n\n  /**\n   * @dev Recover signer address from a message by using his signature\n   * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.\n   * @param sig bytes signature, the signature is generated using web3.eth.sign()\n   */\n  function recover(bytes32 hash, bytes sig) public pure returns (address) {\n    bytes32 r;\n    bytes32 s;\n    uint8 v;\n\n    //Check the signature length\n    if (sig.length != 65) {\n      return (address(0));\n    }\n\n    // Divide the signature in r, s and v variables\n    assembly {\n      r := mload(add(sig, 32))\n      s := mload(add(sig, 64))\n      v := byte(0, mload(add(sig, 96)))\n    }\n\n    // Version of signature should be 27 or 28, but 0 and 1 are also possible versions\n    if (v < 27) {\n      v += 27;\n    }\n\n    // If the version is correct return the signer address\n    if (v != 27 && v != 28) {\n      return (address(0));\n    } else {\n      return ecrecover(hash, v, r, s);\n    }\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/LimitBalance.sol",
    "content": "pragma solidity ^0.4.18;\n\n\n/**\n * @title LimitBalance\n * @dev Simple contract to limit the balance of child contract.\n * @dev Note this doesn't prevent other contracts to send funds by using selfdestruct(address);\n * @dev See: https://github.com/ConsenSys/smart-contract-best-practices#remember-that-ether-can-be-forcibly-sent-to-an-account\n */\ncontract LimitBalance {\n\n  uint256 public limit;\n\n  /**\n   * @dev Constructor that sets the passed value as a limit.\n   * @param _limit uint256 to represent the limit.\n   */\n  function LimitBalance(uint256 _limit) public {\n    limit = _limit;\n  }\n\n  /**\n   * @dev Checks if limit was reached. Case true, it throws.\n   */\n  modifier limitedPayable() {\n    require(this.balance <= limit);\n    _;\n\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/MerkleProof.sol",
    "content": "pragma solidity ^0.4.18;\n\n/*\n * @title MerkleProof\n * @dev Merkle proof verification\n * @note Based on https://github.com/ameensol/merkle-tree-solidity/blob/master/src/MerkleProof.sol\n */\nlibrary MerkleProof {\n  /*\n   * @dev Verifies a Merkle proof proving the existence of a leaf in a Merkle tree. Assumes that each pair of leaves\n   * and each pair of pre-images is sorted.\n   * @param _proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree\n   * @param _root Merkle root\n   * @param _leaf Leaf of Merkle tree\n   */\n  function verifyProof(bytes _proof, bytes32 _root, bytes32 _leaf) public pure returns (bool) {\n    // Check if proof length is a multiple of 32\n    if (_proof.length % 32 != 0) return false;\n\n    bytes32 proofElement;\n    bytes32 computedHash = _leaf;\n\n    for (uint256 i = 32; i <= _proof.length; i += 32) {\n      assembly {\n        // Load the current element of the proof\n        proofElement := mload(add(_proof, i))\n      }\n\n      if (computedHash < proofElement) {\n        // Hash(current computed hash + current element of the proof)\n        computedHash = keccak256(computedHash, proofElement);\n      } else {\n        // Hash(current element of the proof + current computed hash)\n        computedHash = keccak256(proofElement, computedHash);\n      }\n    }\n\n    // Check if the computed hash (root) is equal to the provided root\n    return computedHash == _root;\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/MetaCoin.sol",
    "content": "pragma solidity ^0.4.4;\n\nimport \"./ConvertLib.sol\";\n\n// This is just a simple example of a coin-like contract.\n// It is not standards compatible and cannot be expected to talk to other\n// coin/token contracts. If you want to create a standards-compliant\n// token, see: https://github.com/ConsenSys/Tokens. Cheers!\n\ncontract MetaCoin {\n\tmapping (address => uint) balances;\n\n\tevent Transfer(address indexed _from, address indexed _to, uint256 _value);\n\n\tfunction MetaCoin() {\n\t\tbalances[tx.origin] = 10000;\n\t}\n\n\tfunction sendCoin(address receiver, uint amount) returns(bool sufficient) {\n\t\tif (balances[msg.sender] < amount) return false;\n\t\tbalances[msg.sender] -= amount;\n\t\tbalances[receiver] += amount;\n\t\tTransfer(msg.sender, receiver, amount);\n\t\treturn true;\n\t}\n\n\tfunction getBalanceInEth(address addr) returns(uint){\n\t\treturn ConvertLib.convert(getBalance(addr),2);\n\t}\n\n\tfunction getBalance(address addr) returns(uint) {\n\t\treturn balances[addr];\n\t}\n}\n"
  },
  {
    "path": "truffle/oz/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.4;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function Migrations() {\n    owner = msg.sender;\n  }\n\n  function setCompleted(uint completed) restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ReentrancyGuard.sol",
    "content": "pragma solidity ^0.4.18;\n\n/**\n * @title Helps contracts guard agains rentrancy attacks.\n * @author Remco Bloemen <remco@2π.com>\n * @notice If you mark a function `nonReentrant`, you should also\n * mark it `external`.\n */\ncontract ReentrancyGuard {\n\n  /**\n   * @dev We use a single lock for the whole contract.\n   */\n  bool private rentrancy_lock = false;\n\n  /**\n   * @dev Prevents a contract from calling itself, directly or indirectly.\n   * @notice If you mark a function `nonReentrant`, you should also\n   * mark it `external`. Calling one nonReentrant function from\n   * another is not supported. Instead, you can implement a\n   * `private` function doing the actual work, and a `external`\n   * wrapper marked as `nonReentrant`.\n   */\n  modifier nonReentrant() {\n    require(!rentrancy_lock);\n    rentrancy_lock = true;\n    _;\n    rentrancy_lock = false;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/crowdsale/CappedCrowdsale.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../math/SafeMath.sol';\nimport './Crowdsale.sol';\n\n/**\n * @title CappedCrowdsale\n * @dev Extension of Crowdsale with a max amount of funds raised\n */\ncontract CappedCrowdsale is Crowdsale {\n  using SafeMath for uint256;\n\n  uint256 public cap;\n\n  function CappedCrowdsale(uint256 _cap) public {\n    require(_cap > 0);\n    cap = _cap;\n  }\n\n  // overriding Crowdsale#validPurchase to add extra cap logic\n  // @return true if investors can buy at the moment\n  function validPurchase() internal view returns (bool) {\n    bool withinCap = weiRaised.add(msg.value) <= cap;\n    return super.validPurchase() && withinCap;\n  }\n\n  // overriding Crowdsale#hasEnded to add cap logic\n  // @return true if crowdsale event has ended\n  function hasEnded() public view returns (bool) {\n    bool capReached = weiRaised >= cap;\n    return super.hasEnded() || capReached;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/crowdsale/Crowdsale.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../token/MintableToken.sol';\nimport '../math/SafeMath.sol';\n\n/**\n * @title Crowdsale\n * @dev Crowdsale is a base contract for managing a token crowdsale.\n * Crowdsales have a start and end timestamps, where investors can make\n * token purchases and the crowdsale will assign them tokens based\n * on a token per ETH rate. Funds collected are forwarded to a wallet\n * as they arrive.\n */\ncontract Crowdsale {\n  using SafeMath for uint256;\n\n  // The token being sold\n  MintableToken public token;\n\n  // start and end timestamps where investments are allowed (both inclusive)\n  uint256 public startTime;\n  uint256 public endTime;\n\n  // address where funds are collected\n  address public wallet;\n\n  // how many token units a buyer gets per wei\n  uint256 public rate;\n\n  // amount of raised money in wei\n  uint256 public weiRaised;\n\n  /**\n   * event for token purchase logging\n   * @param purchaser who paid for the tokens\n   * @param beneficiary who got the tokens\n   * @param value weis paid for purchase\n   * @param amount amount of tokens purchased\n   */\n  event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);\n\n\n  function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public {\n    require(_startTime >= now);\n    require(_endTime >= _startTime);\n    require(_rate > 0);\n    require(_wallet != address(0));\n\n    token = createTokenContract();\n    startTime = _startTime;\n    endTime = _endTime;\n    rate = _rate;\n    wallet = _wallet;\n  }\n\n  // creates the token to be sold.\n  // override this method to have crowdsale of a specific mintable token.\n  function createTokenContract() internal returns (MintableToken) {\n    return new MintableToken();\n  }\n\n\n  // fallback function can be used to buy tokens\n  function () external payable {\n    buyTokens(msg.sender);\n  }\n\n  // low level token purchase function\n  function buyTokens(address beneficiary) public payable {\n    require(beneficiary != address(0));\n    require(validPurchase());\n\n    uint256 weiAmount = msg.value;\n\n    // calculate token amount to be created\n    uint256 tokens = weiAmount.mul(rate);\n\n    // update state\n    weiRaised = weiRaised.add(weiAmount);\n\n    token.mint(beneficiary, tokens);\n    TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);\n\n    forwardFunds();\n  }\n\n  // send ether to the fund collection wallet\n  // override to create custom fund forwarding mechanisms\n  function forwardFunds() internal {\n    wallet.transfer(msg.value);\n  }\n\n  // @return true if the transaction can buy tokens\n  function validPurchase() internal view returns (bool) {\n    bool withinPeriod = now >= startTime && now <= endTime;\n    bool nonZeroPurchase = msg.value != 0;\n    return withinPeriod && nonZeroPurchase;\n  }\n\n  // @return true if crowdsale event has ended\n  function hasEnded() public view returns (bool) {\n    return now > endTime;\n  }\n\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/crowdsale/FinalizableCrowdsale.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../math/SafeMath.sol';\nimport '../ownership/Ownable.sol';\nimport './Crowdsale.sol';\n\n/**\n * @title FinalizableCrowdsale\n * @dev Extension of Crowdsale where an owner can do extra work\n * after finishing.\n */\ncontract FinalizableCrowdsale is Crowdsale, Ownable {\n  using SafeMath for uint256;\n\n  bool public isFinalized = false;\n\n  event Finalized();\n\n  /**\n   * @dev Must be called after crowdsale ends, to do some extra finalization\n   * work. Calls the contract's finalization function.\n   */\n  function finalize() onlyOwner public {\n    require(!isFinalized);\n    require(hasEnded());\n\n    finalization();\n    Finalized();\n\n    isFinalized = true;\n  }\n\n  /**\n   * @dev Can be overridden to add finalization logic. The overriding function\n   * should call super.finalization() to ensure the chain of finalization is\n   * executed entirely.\n   */\n  function finalization() internal {\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/crowdsale/RefundVault.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../math/SafeMath.sol';\nimport '../ownership/Ownable.sol';\n\n/**\n * @title RefundVault\n * @dev This contract is used for storing funds while a crowdsale\n * is in progress. Supports refunding the money if crowdsale fails,\n * and forwarding it if crowdsale is successful.\n */\ncontract RefundVault is Ownable {\n  using SafeMath for uint256;\n\n  enum State { Active, Refunding, Closed }\n\n  mapping (address => uint256) public deposited;\n  address public wallet;\n  State public state;\n\n  event Closed();\n  event RefundsEnabled();\n  event Refunded(address indexed beneficiary, uint256 weiAmount);\n\n  function RefundVault(address _wallet) public {\n    require(_wallet != address(0));\n    wallet = _wallet;\n    state = State.Active;\n  }\n\n  function deposit(address investor) onlyOwner public payable {\n    require(state == State.Active);\n    deposited[investor] = deposited[investor].add(msg.value);\n  }\n\n  function close() onlyOwner public {\n    require(state == State.Active);\n    state = State.Closed;\n    Closed();\n    wallet.transfer(this.balance);\n  }\n\n  function enableRefunds() onlyOwner public {\n    require(state == State.Active);\n    state = State.Refunding;\n    RefundsEnabled();\n  }\n\n  function refund(address investor) public {\n    require(state == State.Refunding);\n    uint256 depositedValue = deposited[investor];\n    deposited[investor] = 0;\n    investor.transfer(depositedValue);\n    Refunded(investor, depositedValue);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/crowdsale/RefundableCrowdsale.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../math/SafeMath.sol';\nimport './FinalizableCrowdsale.sol';\nimport './RefundVault.sol';\n\n\n/**\n * @title RefundableCrowdsale\n * @dev Extension of Crowdsale contract that adds a funding goal, and\n * the possibility of users getting a refund if goal is not met.\n * Uses a RefundVault as the crowdsale's vault.\n */\ncontract RefundableCrowdsale is FinalizableCrowdsale {\n  using SafeMath for uint256;\n\n  // minimum amount of funds to be raised in weis\n  uint256 public goal;\n\n  // refund vault used to hold funds while crowdsale is running\n  RefundVault public vault;\n\n  function RefundableCrowdsale(uint256 _goal) public {\n    require(_goal > 0);\n    vault = new RefundVault(wallet);\n    goal = _goal;\n  }\n\n  // We're overriding the fund forwarding from Crowdsale.\n  // In addition to sending the funds, we want to call\n  // the RefundVault deposit function\n  function forwardFunds() internal {\n    vault.deposit.value(msg.value)(msg.sender);\n  }\n\n  // if crowdsale is unsuccessful, investors can claim refunds here\n  function claimRefund() public {\n    require(isFinalized);\n    require(!goalReached());\n\n    vault.refund(msg.sender);\n  }\n\n  // vault finalization task, called when owner calls finalize()\n  function finalization() internal {\n    if (goalReached()) {\n      vault.close();\n    } else {\n      vault.enableRefunds();\n    }\n\n    super.finalization();\n  }\n\n  function goalReached() public view returns (bool) {\n    return weiRaised >= goal;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/examples/SampleCrowdsale.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport \"../crowdsale/CappedCrowdsale.sol\";\nimport \"../crowdsale/RefundableCrowdsale.sol\";\nimport \"../token/MintableToken.sol\";\n\n/**\n * @title SampleCrowdsaleToken\n * @dev Very simple ERC20 Token that can be minted.\n * It is meant to be used in a crowdsale contract.\n */\ncontract SampleCrowdsaleToken is MintableToken {\n\n  string public constant name = \"Sample Crowdsale Token\";\n  string public constant symbol = \"SCT\";\n  uint8 public constant decimals = 18;\n\n}\n\n/**\n * @title SampleCrowdsale\n * @dev This is an example of a fully fledged crowdsale.\n * The way to add new features to a base crowdsale is by multiple inheritance.\n * In this example we are providing following extensions:\n * CappedCrowdsale - sets a max boundary for raised funds\n * RefundableCrowdsale - set a min goal to be reached and returns funds if it's not met\n *\n * After adding multiple features it's good practice to run integration tests\n * to ensure that subcontracts works together as intended.\n */\ncontract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale {\n\n  function SampleCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _goal, uint256 _cap, address _wallet) public\n    CappedCrowdsale(_cap)\n    FinalizableCrowdsale()\n    RefundableCrowdsale(_goal)\n    Crowdsale(_startTime, _endTime, _rate, _wallet)\n  {\n    //As goal needs to be met for a successful crowdsale\n    //the value needs to less or equal than a cap which is limit for accepted funds\n    require(_goal <= _cap);\n  }\n\n  function createTokenContract() internal returns (MintableToken) {\n    return new SampleCrowdsaleToken();\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/examples/SimpleToken.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport \"../token/StandardToken.sol\";\n\n\n/**\n * @title SimpleToken\n * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.\n * Note they can later distribute these tokens as they wish using `transfer` and other\n * `StandardToken` functions.\n */\ncontract SimpleToken is StandardToken {\n\n  string public constant name = \"SimpleToken\";\n  string public constant symbol = \"SIM\";\n  uint8 public constant decimals = 18;\n\n  uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals));\n\n  /**\n   * @dev Constructor that gives msg.sender all of existing tokens.\n   */\n  function SimpleToken() public {\n    totalSupply = INITIAL_SUPPLY;\n    balances[msg.sender] = INITIAL_SUPPLY;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/BasicTokenMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/token/BasicToken.sol';\n\n\n// mock class using BasicToken\ncontract BasicTokenMock is BasicToken {\n\n  function BasicTokenMock(address initialAccount, uint256 initialBalance) public {\n    balances[initialAccount] = initialBalance;\n    totalSupply = initialBalance;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/BurnableTokenMock.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/token/BurnableToken.sol';\n\ncontract BurnableTokenMock is BurnableToken {\n\n  function BurnableTokenMock(address initialAccount, uint initialBalance) public {\n    balances[initialAccount] = initialBalance;\n    totalSupply = initialBalance;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/CappedCrowdsaleImpl.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/crowdsale/CappedCrowdsale.sol';\n\n\ncontract CappedCrowdsaleImpl is CappedCrowdsale {\n\n  function CappedCrowdsaleImpl (\n    uint256 _startTime,\n    uint256 _endTime,\n    uint256 _rate,\n    address _wallet,\n    uint256 _cap\n  ) public\n    Crowdsale(_startTime, _endTime, _rate, _wallet)\n    CappedCrowdsale(_cap)\n  {\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/DayLimitMock.sol",
    "content": "pragma solidity ^0.4.18;\nimport \"../../contracts/DayLimit.sol\";\n\ncontract DayLimitMock is DayLimit {\n  uint256 public totalSpending;\n\n  function DayLimitMock(uint256 _value) public DayLimit(_value) {\n    totalSpending = 0;\n  }\n\n  function attemptSpend(uint256 _value) external limitedDaily(_value) {\n    totalSpending += _value;\n  }\n\n  function setDailyLimit(uint256 _newLimit) external {\n    _setDailyLimit(_newLimit);\n  }\n\n  function resetSpentToday() external {\n    _resetSpentToday();\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/DetailedERC20Mock.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/token/StandardToken.sol';\nimport '../../contracts/token/DetailedERC20.sol';\n\ncontract DetailedERC20Mock is StandardToken, DetailedERC20 {\n  function DetailedERC20Mock(string _name, string _symbol, uint8 _decimals) DetailedERC20(_name, _symbol, _decimals) public {}\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/ERC23TokenMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/token/BasicToken.sol';\n\n\ncontract ERC23ContractInterface {\n  function tokenFallback(address _from, uint256 _value, bytes _data) external;\n}\n\ncontract ERC23TokenMock is BasicToken {\n\n  function ERC23TokenMock(address initialAccount, uint256 initialBalance) public {\n    balances[initialAccount] = initialBalance;\n    totalSupply = initialBalance;\n  }\n\n  // ERC23 compatible transfer function (except the name)\n  function transferERC23(address _to, uint256 _value, bytes _data) public\n    returns (bool success)\n  {\n    transfer(_to, _value);\n    bool is_contract = false;\n    assembly {\n      is_contract := not(iszero(extcodesize(_to)))\n    }\n    if(is_contract) {\n      ERC23ContractInterface receiver = ERC23ContractInterface(_to);\n      receiver.tokenFallback(msg.sender, _value, _data);\n    }\n    return true;\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/EVMRevert.js",
    "content": "export default 'revert'\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/EVMThrow.js",
    "content": "export default 'invalid opcode'\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/FinalizableCrowdsaleImpl.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/crowdsale/FinalizableCrowdsale.sol';\n\n\ncontract FinalizableCrowdsaleImpl is FinalizableCrowdsale {\n\n  function FinalizableCrowdsaleImpl (\n    uint256 _startTime,\n    uint256 _endTime,\n    uint256 _rate,\n    address _wallet\n  ) public\n    Crowdsale(_startTime, _endTime, _rate, _wallet)\n    FinalizableCrowdsale()\n  {\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/ForceEther.sol",
    "content": "pragma solidity ^0.4.18;\n\n// @title Force Ether into a contract.\n// @notice  even\n// if the contract is not payable.\n// @notice To use, construct the contract with the target as argument.\n// @author Remco Bloemen <remco@neufund.org>\ncontract ForceEther  {\n\n  function ForceEther() public payable { }\n\n  function destroyAndSend(address _recipient) public {\n    selfdestruct(_recipient);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/HasNoEtherTest.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport \"../../contracts/ownership/HasNoEther.sol\";\n\ncontract HasNoEtherTest is HasNoEther {\n\n  // Constructor with explicit payable — should still fail\n  function HasNoEtherTest() public payable {\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/InsecureTargetBounty.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport {Bounty, Target} from \"../../contracts/Bounty.sol\";\n\n\ncontract InsecureTargetMock is Target {\n  function checkInvariant() public returns(bool){\n    return false;\n  }\n}\n\ncontract InsecureTargetBounty is Bounty {\n  function deployContract() internal returns (address) {\n    return new InsecureTargetMock();\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/LimitBalanceMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/LimitBalance.sol';\n\n\n// mock class using LimitBalance\ncontract LimitBalanceMock is LimitBalance(1000) {\n\n  function limitedDeposit() public payable limitedPayable {\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/PausableMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/lifecycle/Pausable.sol';\n\n\n// mock class using Pausable\ncontract PausableMock is Pausable {\n  bool public drasticMeasureTaken;\n  uint256 public count;\n\n  function PausableMock() public {\n    drasticMeasureTaken = false;\n    count = 0;\n  }\n\n  function normalProcess() external whenNotPaused {\n    count++;\n  }\n\n  function drasticMeasure() external whenPaused {\n    drasticMeasureTaken = true;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/PausableTokenMock.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/token/PausableToken.sol';\n\n// mock class using PausableToken\ncontract PausableTokenMock is PausableToken {\n\n  function PausableTokenMock(address initialAccount, uint initialBalance) public {\n    balances[initialAccount] = initialBalance;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/PullPaymentMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/payment/PullPayment.sol';\n\n\n// mock class using PullPayment\ncontract PullPaymentMock is PullPayment {\n\n  function PullPaymentMock() public payable { }\n\n  // test helper function to call asyncSend\n  function callSend(address dest, uint256 amount) public {\n    asyncSend(dest, amount);\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/ReentrancyAttack.sol",
    "content": "pragma solidity ^0.4.18;\n\ncontract ReentrancyAttack {\n\n  function callSender(bytes4 data) public {\n    require(msg.sender.call(data));\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/ReentrancyMock.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/ReentrancyGuard.sol';\nimport './ReentrancyAttack.sol';\n\ncontract ReentrancyMock is ReentrancyGuard {\n\n  uint256 public counter;\n\n  function ReentrancyMock() public {\n    counter = 0;\n  }\n\n  function count() private {\n    counter += 1;\n  }\n\n  function countLocalRecursive(uint256 n) public nonReentrant {\n    if(n > 0) {\n      count();\n      countLocalRecursive(n - 1);\n    }\n  }\n\n  function countThisRecursive(uint256 n) public nonReentrant {\n    bytes4 func = bytes4(keccak256(\"countThisRecursive(uint256)\"));\n    if(n > 0) {\n      count();\n      bool result = this.call(func, n - 1);\n      require(result == true);\n    }\n  }\n\n  function countAndCall(ReentrancyAttack attacker) public nonReentrant {\n    count();\n    bytes4 func = bytes4(keccak256(\"callback()\"));\n    attacker.callSender(func);\n  }\n\n  function callback() external nonReentrant {\n    count();\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/RefundableCrowdsaleImpl.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/crowdsale/RefundableCrowdsale.sol';\n\n\ncontract RefundableCrowdsaleImpl is RefundableCrowdsale {\n\n  function RefundableCrowdsaleImpl (\n    uint256 _startTime,\n    uint256 _endTime,\n    uint256 _rate,\n    address _wallet,\n    uint256 _goal\n  ) public\n    Crowdsale(_startTime, _endTime, _rate, _wallet)\n    RefundableCrowdsale(_goal)\n  {\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/SafeERC20Helper.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/token/ERC20.sol';\nimport '../../contracts/token/SafeERC20.sol';\n\ncontract ERC20FailingMock is ERC20 {\n  function transfer(address, uint256) public returns (bool) {\n    return false;\n  }\n\n  function transferFrom(address, address, uint256) public returns (bool) {\n    return false;\n  }\n\n  function approve(address, uint256) public returns (bool) {\n    return false;\n  }\n\n  function balanceOf(address) public constant returns (uint256) {\n    return 0;\n  }\n\n  function allowance(address, address) public constant returns (uint256) {\n    return 0;\n  }\n}\n\ncontract ERC20SucceedingMock is ERC20 {\n  function transfer(address, uint256) public returns (bool) {\n    return true;\n  }\n\n  function transferFrom(address, address, uint256) public returns (bool) {\n    return true;\n  }\n\n  function approve(address, uint256) public returns (bool) {\n    return true;\n  }\n\n  function balanceOf(address) public constant returns (uint256) {\n    return 0;\n  }\n\n  function allowance(address, address) public constant returns (uint256) {\n    return 0;\n  }\n}\n\ncontract SafeERC20Helper {\n  using SafeERC20 for ERC20;\n\n  ERC20 failing;\n  ERC20 succeeding;\n\n  function SafeERC20Helper() public {\n    failing = new ERC20FailingMock();\n    succeeding = new ERC20SucceedingMock();\n  }\n\n  function doFailingTransfer() public {\n    failing.safeTransfer(0, 0);\n  }\n\n  function doFailingTransferFrom() public {\n    failing.safeTransferFrom(0, 0, 0);\n  }\n\n  function doFailingApprove() public {\n    failing.safeApprove(0, 0);\n  }\n\n  function doSucceedingTransfer() public {\n    succeeding.safeTransfer(0, 0);\n  }\n\n  function doSucceedingTransferFrom() public {\n    succeeding.safeTransferFrom(0, 0, 0);\n  }\n\n  function doSucceedingApprove() public {\n    succeeding.safeApprove(0, 0);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/SafeMathMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/math/SafeMath.sol';\n\n\ncontract SafeMathMock {\n  uint256 public result;\n\n  function multiply(uint256 a, uint256 b) public {\n    result = SafeMath.mul(a, b);\n  }\n\n  function subtract(uint256 a, uint256 b) public {\n    result = SafeMath.sub(a, b);\n  }\n\n  function add(uint256 a, uint256 b) public {\n    result = SafeMath.add(a, b);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/SecureTargetBounty.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport {Bounty, Target} from \"../../contracts/Bounty.sol\";\n\n\ncontract SecureTargetMock is Target {\n  function checkInvariant() public returns(bool) {\n    return true;\n  }\n}\n\ncontract SecureTargetBounty is Bounty {\n  function deployContract() internal returns (address) {\n    return new SecureTargetMock();\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/SplitPaymentMock.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/payment/SplitPayment.sol';\n\n// mock class using SplitPayment\ncontract SplitPaymentMock is SplitPayment {\n  function SplitPaymentMock(address[] _payees, uint256[] _shares) public\n    SplitPayment(_payees, _shares) payable {}\n  function () external payable {}\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/StandardTokenMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/token/StandardToken.sol';\n\n\n// mock class using StandardToken\ncontract StandardTokenMock is StandardToken {\n\n  function StandardTokenMock(address initialAccount, uint256 initialBalance) public {\n    balances[initialAccount] = initialBalance;\n    totalSupply = initialBalance;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/advanceToBlock.js",
    "content": "export function advanceBlock() {\n  return new Promise((resolve, reject) => {\n    web3.currentProvider.sendAsync({\n      jsonrpc: '2.0',\n      method: 'evm_mine',\n      id: Date.now(),\n    }, (err, res) => {\n      return err ? reject(err) : resolve(res)\n    })\n  })\n}\n\n// Advances the block number so that the last mined block is `number`.\nexport default async function advanceToBlock(number) {\n  if (web3.eth.blockNumber > number) {\n    throw Error(`block number ${number} is in the past (current is ${web3.eth.blockNumber})`)\n  }\n\n  while (web3.eth.blockNumber < number) {\n    await advanceBlock()\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/assertJump.js",
    "content": "module.exports = function(error) {\n  assert.isAbove(error.message.search('invalid opcode'), -1, 'Invalid opcode error must be returned');\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/assertRevert.js",
    "content": "module.exports = function(error) {\n  assert.isAbove(error.message.search('revert'), -1, 'Error containing \"revert\" must be returned');\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/ether.js",
    "content": "export default function ether(n) {\n  return new web3.BigNumber(web3.toWei(n, 'ether'))\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/expectThrow.js",
    "content": "export default async promise => {\n  try {\n    await promise;\n  } catch (error) {\n    // TODO: Check jump destination to destinguish between a throw\n    //       and an actual invalid jump.\n    const invalidOpcode = error.message.search('invalid opcode') >= 0;\n    // TODO: When we contract A calls contract B, and B throws, instead\n    //       of an 'invalid jump', we get an 'out of gas' error. How do\n    //       we distinguish this from an actual out of gas event? (The\n    //       testrpc log actually show an 'invalid jump' event.)\n    const outOfGas = error.message.search('out of gas') >= 0;\n    const revert = error.message.search('revert') >= 0;\n    assert(\n      invalidOpcode || outOfGas || revert,\n      \"Expected throw, got '\" + error + \"' instead\",\n    );\n    return;\n  }\n  assert.fail('Expected throw not received');\n};\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/hashMessage.js",
    "content": "import utils from 'ethereumjs-util';\n\n// Hash and add same prefix to the hash that testrpc use.\nmodule.exports = function(message) {\n  const messageHex = new Buffer(utils.sha3(message).toString('hex'), 'hex');\n  const prefix = utils.toBuffer('\\u0019Ethereum Signed Message:\\n' + messageHex.length.toString());\n  return utils.bufferToHex( utils.sha3(Buffer.concat([prefix, messageHex])) );\n};\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/increaseTime.js",
    "content": "import latestTime from './latestTime'\n\n// Increases testrpc time by the passed duration in seconds\nexport default function increaseTime(duration) {\n  const id = Date.now()\n\n  return new Promise((resolve, reject) => {\n    web3.currentProvider.sendAsync({\n      jsonrpc: '2.0',\n      method: 'evm_increaseTime',\n      params: [duration],\n      id: id,\n    }, err1 => {\n      if (err1) return reject(err1)\n\n      web3.currentProvider.sendAsync({\n        jsonrpc: '2.0',\n        method: 'evm_mine',\n        id: id+1,\n      }, (err2, res) => {\n        return err2 ? reject(err2) : resolve(res)\n      })\n    })\n  })\n}\n\n/**\n * Beware that due to the need of calling two separate testrpc methods and rpc calls overhead\n * it's hard to increase time precisely to a target point so design your test to tolerate\n * small fluctuations from time to time.\n *\n * @param target time in seconds\n */\nexport function increaseTimeTo(target) {\n  let now = latestTime();\n  if (target < now) throw Error(`Cannot increase current time(${now}) to a moment in the past(${target})`);\n  let diff = target - now;\n  return increaseTime(diff);\n}\n\nexport const duration = {\n  seconds: function(val) { return val},\n  minutes: function(val) { return val * this.seconds(60) },\n  hours:   function(val) { return val * this.minutes(60) },\n  days:    function(val) { return val * this.hours(24) },\n  weeks:   function(val) { return val * this.days(7) },\n  years:   function(val) { return val * this.days(365)}\n};\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/latestTime.js",
    "content": "// Returns the time of the last mined block in seconds\nexport default function latestTime() {\n  return web3.eth.getBlock('latest').timestamp;\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/merkleTree.js",
    "content": "import { sha3, bufferToHex } from \"ethereumjs-util\";\n\nexport default class MerkleTree {\n  constructor(elements) {\n    // Filter empty strings and hash elements\n    this.elements = elements.filter(el => el).map(el => sha3(el));\n\n    // Deduplicate elements\n    this.elements = this.bufDedup(this.elements);\n    // Sort elements\n    this.elements.sort(Buffer.compare);\n\n    // Create layers\n    this.layers = this.getLayers(this.elements);\n  }\n\n  getLayers(elements) {\n    if (elements.length == 0) {\n      return [[\"\"]];\n    }\n\n    const layers = [];\n    layers.push(elements);\n\n    // Get next layer until we reach the root\n    while (layers[layers.length - 1].length > 1) {\n      layers.push(this.getNextLayer(layers[layers.length - 1]));\n    }\n\n    return layers;\n  }\n\n  getNextLayer(elements) {\n    return elements.reduce((layer, el, idx, arr) => {\n      if (idx % 2 === 0) {\n        // Hash the current element with its pair element\n        layer.push(this.combinedHash(el, arr[idx + 1]));\n      }\n\n      return layer;\n    }, []);\n  }\n\n  combinedHash(first, second) {\n    if (!first) { return second; }\n    if (!second) { return first; }\n\n    return sha3(this.sortAndConcat(first, second));\n  }\n\n  getRoot() {\n    return this.layers[this.layers.length - 1][0];\n  }\n\n  getHexRoot() {\n    return bufferToHex(this.getRoot());\n  }\n\n  getProof(el) {\n    let idx = this.bufIndexOf(el, this.elements);\n\n    if (idx === -1) {\n      throw new Error(\"Element does not exist in Merkle tree\");\n    }\n\n    return this.layers.reduce((proof, layer) => {\n      const pairElement = this.getPairElement(idx, layer);\n\n      if (pairElement) {\n        proof.push(pairElement);\n      }\n\n      idx = Math.floor(idx / 2);\n\n      return proof;\n    }, []);\n  }\n\n  getHexProof(el) {\n    const proof = this.getProof(el);\n\n    return this.bufArrToHex(proof);\n  }\n\n  getPairElement(idx, layer) {\n    const pairIdx = idx % 2 === 0 ? idx + 1 : idx - 1;\n\n    if (pairIdx < layer.length) {\n      return layer[pairIdx];\n    } else {\n      return null;\n    }\n  }\n\n  bufIndexOf(el, arr) {\n    let hash;\n\n    // Convert element to 32 byte hash if it is not one already\n    if (el.length !== 32 || !Buffer.isBuffer(el)) {\n      hash = sha3(el);\n    } else {\n      hash = el;\n    }\n\n    for (let i = 0; i < arr.length; i++) {\n      if (hash.equals(arr[i])) {\n        return i;\n      }\n    }\n\n    return -1;\n  }\n\n  bufDedup(elements) {\n    return elements.filter((el, idx) => {\n      return this.bufIndexOf(el, elements) === idx;\n    });\n  }\n\n  bufArrToHex(arr) {\n    if (arr.some(el => !Buffer.isBuffer(el))) {\n      throw new Error(\"Array is not an array of buffers\");\n    }\n\n    return \"0x\" + arr.map(el => el.toString(\"hex\")).join(\"\");\n  }\n\n  sortAndConcat(...args) {\n    return Buffer.concat([...args].sort(Buffer.compare));\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/toPromise.js",
    "content": "export default func =>\n  (...args) =>\n    new Promise((accept, reject) =>\n      func(...args, (error, data) => error ? reject(error) : accept(data)));\n"
  },
  {
    "path": "truffle/oz/contracts/helpers/transactionMined.js",
    "content": "'use strict';\n\n//from https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6\nmodule.export = web3.eth.transactionMined = function (txnHash, interval) {\n  var transactionReceiptAsync;\n  interval = interval ? interval : 500;\n  transactionReceiptAsync = function(txnHash, resolve, reject) {\n    try {\n      var receipt = web3.eth.getTransactionReceipt(txnHash);\n      if (receipt === null) {\n        setTimeout(function () {\n          transactionReceiptAsync(txnHash, resolve, reject);\n        }, interval);\n      } else {\n        resolve(receipt);\n      }\n    } catch(e) {\n      reject(e);\n    }\n  };\n\n  if (Array.isArray(txnHash)) {\n    var promises = [];\n    txnHash.forEach(function (oneTxHash) {\n      promises.push(\n        web3.eth.getTransactionReceiptMined(oneTxHash, interval));\n    });\n    return Promise.all(promises);\n  } else {\n    return new Promise(function (resolve, reject) {\n      transactionReceiptAsync(txnHash, resolve, reject);\n    });\n  }\n};\n"
  },
  {
    "path": "truffle/oz/contracts/lifecycle/Destructible.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport \"../ownership/Ownable.sol\";\n\n\n/**\n * @title Destructible\n * @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner.\n */\ncontract Destructible is Ownable {\n\n  function Destructible() public payable { }\n\n  /**\n   * @dev Transfers the current balance to the owner and terminates the contract.\n   */\n  function destroy() onlyOwner public {\n    selfdestruct(owner);\n  }\n\n  function destroyAndSend(address _recipient) onlyOwner public {\n    selfdestruct(_recipient);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/lifecycle/Migrations.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../ownership/Ownable.sol';\n\n/**\n * @title Migrations\n * @dev This is a truffle contract, needed for truffle integration, not meant for use by Zeppelin users.\n */\ncontract Migrations is Ownable {\n  uint256 public lastCompletedMigration;\n\n  function setCompleted(uint256 completed) onlyOwner public {\n    lastCompletedMigration = completed;\n  }\n\n  function upgrade(address newAddress) onlyOwner public {\n    Migrations upgraded = Migrations(newAddress);\n    upgraded.setCompleted(lastCompletedMigration);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/lifecycle/Pausable.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport \"../ownership/Ownable.sol\";\n\n\n/**\n * @title Pausable\n * @dev Base contract which allows children to implement an emergency stop mechanism.\n */\ncontract Pausable is Ownable {\n  event Pause();\n  event Unpause();\n\n  bool public paused = false;\n\n\n  /**\n   * @dev Modifier to make a function callable only when the contract is not paused.\n   */\n  modifier whenNotPaused() {\n    require(!paused);\n    _;\n  }\n\n  /**\n   * @dev Modifier to make a function callable only when the contract is paused.\n   */\n  modifier whenPaused() {\n    require(paused);\n    _;\n  }\n\n  /**\n   * @dev called by the owner to pause, triggers stopped state\n   */\n  function pause() onlyOwner whenNotPaused public {\n    paused = true;\n    Pause();\n  }\n\n  /**\n   * @dev called by the owner to unpause, returns to normal state\n   */\n  function unpause() onlyOwner whenPaused public {\n    paused = false;\n    Unpause();\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/lifecycle/TokenDestructible.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport \"../ownership/Ownable.sol\";\nimport \"../token/ERC20Basic.sol\";\n\n/**\n * @title TokenDestructible:\n * @author Remco Bloemen <remco@2π.com>\n * @dev Base contract that can be destroyed by owner. All funds in contract including\n * listed tokens will be sent to the owner.\n */\ncontract TokenDestructible is Ownable {\n\n  function TokenDestructible() public payable { }\n\n  /**\n   * @notice Terminate contract and refund to owner\n   * @param tokens List of addresses of ERC20 or ERC20Basic token contracts to\n   refund.\n   * @notice The called token contracts could try to re-enter this contract. Only\n   supply token contracts you trust.\n   */\n  function destroy(address[] tokens) onlyOwner public {\n\n    // Transfer tokens to owner\n    for(uint256 i = 0; i < tokens.length; i++) {\n      ERC20Basic token = ERC20Basic(tokens[i]);\n      uint256 balance = token.balanceOf(this);\n      token.transfer(owner, balance);\n    }\n\n    // Transfer Eth to owner and terminate contract\n    selfdestruct(owner);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/math/Math.sol",
    "content": "pragma solidity ^0.4.18;\n\n/**\n * @title Math\n * @dev Assorted math operations\n */\n\nlibrary Math {\n  function max64(uint64 a, uint64 b) internal pure returns (uint64) {\n    return a >= b ? a : b;\n  }\n\n  function min64(uint64 a, uint64 b) internal pure returns (uint64) {\n    return a < b ? a : b;\n  }\n\n  function max256(uint256 a, uint256 b) internal pure returns (uint256) {\n    return a >= b ? a : b;\n  }\n\n  function min256(uint256 a, uint256 b) internal pure returns (uint256) {\n    return a < b ? a : b;\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/math/SafeMath.sol",
    "content": "pragma solidity ^0.4.18;\n\n\n/**\n * @title SafeMath\n * @dev Math operations with safety checks that throw on error\n */\nlibrary SafeMath {\n  function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n    if (a == 0) {\n      return 0;\n    }\n    uint256 c = a * b;\n    assert(c / a == b);\n    return c;\n  }\n\n  function div(uint256 a, uint256 b) internal pure returns (uint256) {\n    // assert(b > 0); // Solidity automatically throws when dividing by 0\n    uint256 c = a / b;\n    // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n    return c;\n  }\n\n  function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n    assert(b <= a);\n    return a - b;\n  }\n\n  function add(uint256 a, uint256 b) internal pure returns (uint256) {\n    uint256 c = a + b;\n    assert(c >= a);\n    return c;\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ownership/CanReclaimToken.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport \"./Ownable.sol\";\nimport \"../token/ERC20Basic.sol\";\nimport \"../token/SafeERC20.sol\";\n\n/**\n * @title Contracts that should be able to recover tokens\n * @author SylTi\n * @dev This allow a contract to recover any ERC20 token received in a contract by transferring the balance to the contract owner.\n * This will prevent any accidental loss of tokens.\n */\ncontract CanReclaimToken is Ownable {\n  using SafeERC20 for ERC20Basic;\n\n  /**\n   * @dev Reclaim all ERC20Basic compatible tokens\n   * @param token ERC20Basic The address of the token contract\n   */\n  function reclaimToken(ERC20Basic token) external onlyOwner {\n    uint256 balance = token.balanceOf(this);\n    token.safeTransfer(owner, balance);\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ownership/Claimable.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport './Ownable.sol';\n\n\n/**\n * @title Claimable\n * @dev Extension for the Ownable contract, where the ownership needs to be claimed.\n * This allows the new owner to accept the transfer.\n */\ncontract Claimable is Ownable {\n  address public pendingOwner;\n\n  /**\n   * @dev Modifier throws if called by any account other than the pendingOwner.\n   */\n  modifier onlyPendingOwner() {\n    require(msg.sender == pendingOwner);\n    _;\n  }\n\n  /**\n   * @dev Allows the current owner to set the pendingOwner address.\n   * @param newOwner The address to transfer ownership to.\n   */\n  function transferOwnership(address newOwner) onlyOwner public {\n    pendingOwner = newOwner;\n  }\n\n  /**\n   * @dev Allows the pendingOwner address to finalize the transfer.\n   */\n  function claimOwnership() onlyPendingOwner public {\n    OwnershipTransferred(owner, pendingOwner);\n    owner = pendingOwner;\n    pendingOwner = address(0);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ownership/Contactable.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport './Ownable.sol';\n\n/**\n * @title Contactable token\n * @dev Basic version of a contactable contract, allowing the owner to provide a string with their\n * contact information.\n */\ncontract Contactable is Ownable{\n\n    string public contactInformation;\n\n    /**\n     * @dev Allows the owner to set a string with their contact information.\n     * @param info The contact information to attach to the contract.\n     */\n    function setContactInformation(string info) onlyOwner public {\n         contactInformation = info;\n     }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ownership/DelayedClaimable.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport './Claimable.sol';\n\n\n/**\n * @title DelayedClaimable\n * @dev Extension for the Claimable contract, where the ownership needs to be claimed before/after\n * a certain block number.\n */\ncontract DelayedClaimable is Claimable {\n\n  uint256 public end;\n  uint256 public start;\n\n  /**\n   * @dev Used to specify the time period during which a pending\n   * owner can claim ownership.\n   * @param _start The earliest time ownership can be claimed.\n   * @param _end The latest time ownership can be claimed.\n   */\n  function setLimits(uint256 _start, uint256 _end) onlyOwner public {\n    require(_start <= _end);\n    end = _end;\n    start = _start;\n  }\n\n\n  /**\n   * @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within\n   * the specified start and end time.\n   */\n  function claimOwnership() onlyPendingOwner public {\n    require((block.number <= end) && (block.number >= start));\n    OwnershipTransferred(owner, pendingOwner);\n    owner = pendingOwner;\n    pendingOwner = address(0);\n    end = 0;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ownership/HasNoContracts.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport \"./Ownable.sol\";\n\n/**\n * @title Contracts that should not own Contracts\n * @author Remco Bloemen <remco@2π.com>\n * @dev Should contracts (anything Ownable) end up being owned by this contract, it allows the owner\n * of this contract to reclaim ownership of the contracts.\n */\ncontract HasNoContracts is Ownable {\n\n  /**\n   * @dev Reclaim ownership of Ownable contracts\n   * @param contractAddr The address of the Ownable to be reclaimed.\n   */\n  function reclaimContract(address contractAddr) external onlyOwner {\n    Ownable contractInst = Ownable(contractAddr);\n    contractInst.transferOwnership(owner);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ownership/HasNoEther.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport \"./Ownable.sol\";\n\n/**\n * @title Contracts that should not own Ether\n * @author Remco Bloemen <remco@2π.com>\n * @dev This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end up\n * in the contract, it will allow the owner to reclaim this ether.\n * @notice Ether can still be send to this contract by:\n * calling functions labeled `payable`\n * `selfdestruct(contract_address)`\n * mining directly to the contract address\n*/\ncontract HasNoEther is Ownable {\n\n  /**\n  * @dev Constructor that rejects incoming Ether\n  * @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we\n  * leave out payable, then Solidity will allow inheriting contracts to implement a payable\n  * constructor. By doing it this way we prevent a payable constructor from working. Alternatively\n  * we could use assembly to access msg.value.\n  */\n  function HasNoEther() public payable {\n    require(msg.value == 0);\n  }\n\n  /**\n   * @dev Disallows direct send by settings a default function without the `payable` flag.\n   */\n  function() external {\n  }\n\n  /**\n   * @dev Transfer all Ether held by the contract to the owner.\n   */\n  function reclaimEther() external onlyOwner {\n    assert(owner.send(this.balance));\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ownership/HasNoTokens.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport \"./CanReclaimToken.sol\";\n\n/**\n * @title Contracts that should not own Tokens\n * @author Remco Bloemen <remco@2π.com>\n * @dev This blocks incoming ERC23 tokens to prevent accidental loss of tokens.\n * Should tokens (any ERC20Basic compatible) end up in the contract, it allows the\n * owner to reclaim the tokens.\n */\ncontract HasNoTokens is CanReclaimToken {\n\n /**\n  * @dev Reject all ERC23 compatible tokens\n  * @param from_ address The address that is transferring the tokens\n  * @param value_ uint256 the amount of the specified token\n  * @param data_ Bytes The data passed from the caller.\n  */\n  function tokenFallback(address from_, uint256 value_, bytes data_) external {\n    from_;\n    value_;\n    data_;\n    revert();\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ownership/NoOwner.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport \"./HasNoEther.sol\";\nimport \"./HasNoTokens.sol\";\nimport \"./HasNoContracts.sol\";\n\n/**\n * @title Base contract for contracts that should not own things.\n * @author Remco Bloemen <remco@2π.com>\n * @dev Solves a class of errors where a contract accidentally becomes owner of Ether, Tokens or\n * Owned contracts. See respective base contracts for details.\n */\ncontract NoOwner is HasNoEther, HasNoTokens, HasNoContracts {\n}\n"
  },
  {
    "path": "truffle/oz/contracts/ownership/Ownable.sol",
    "content": "pragma solidity ^0.4.18;\n\n\n/**\n * @title Ownable\n * @dev The Ownable contract has an owner address, and provides basic authorization control\n * functions, this simplifies the implementation of \"user permissions\".\n */\ncontract Ownable {\n  address public owner;\n\n\n  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n\n  /**\n   * @dev The Ownable constructor sets the original `owner` of the contract to the sender\n   * account.\n   */\n  function Ownable() public {\n    owner = msg.sender;\n  }\n\n\n  /**\n   * @dev Throws if called by any account other than the owner.\n   */\n  modifier onlyOwner() {\n    require(msg.sender == owner);\n    _;\n  }\n\n\n  /**\n   * @dev Allows the current owner to transfer control of the contract to a newOwner.\n   * @param newOwner The address to transfer ownership to.\n   */\n  function transferOwnership(address newOwner) public onlyOwner {\n    require(newOwner != address(0));\n    OwnershipTransferred(owner, newOwner);\n    owner = newOwner;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/payment/PullPayment.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../math/SafeMath.sol';\n\n\n/**\n * @title PullPayment\n * @dev Base contract supporting async send for pull payments. Inherit from this\n * contract and use asyncSend instead of send.\n */\ncontract PullPayment {\n  using SafeMath for uint256;\n\n  mapping(address => uint256) public payments;\n  uint256 public totalPayments;\n\n  /**\n  * @dev Called by the payer to store the sent amount as credit to be pulled.\n  * @param dest The destination address of the funds.\n  * @param amount The amount to transfer.\n  */\n  function asyncSend(address dest, uint256 amount) internal {\n    payments[dest] = payments[dest].add(amount);\n    totalPayments = totalPayments.add(amount);\n  }\n\n  /**\n  * @dev withdraw accumulated balance, called by payee.\n  */\n  function withdrawPayments() public {\n    address payee = msg.sender;\n    uint256 payment = payments[payee];\n\n    require(payment != 0);\n    require(this.balance >= payment);\n\n    totalPayments = totalPayments.sub(payment);\n    payments[payee] = 0;\n\n    assert(payee.send(payment));\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/payment/SplitPayment.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../math/SafeMath.sol';\n\n/**\n * @title SplitPayment\n * @dev Base contract that supports multiple payees claiming funds sent to this contract \n * according to the proportion they own.\n */\ncontract SplitPayment {\n  using SafeMath for uint256;\n\n  uint256 public totalShares = 0;\n  uint256 public totalReleased = 0;\n\n  mapping(address => uint256) public shares;\n  mapping(address => uint256) public released;\n  address[] public payees;\n\n  /**\n   * @dev Constructor\n   */\n  function SplitPayment(address[] _payees, uint256[] _shares) public {\n    require(_payees.length == _shares.length);\n\n    for (uint256 i = 0; i < _payees.length; i++) {\n      addPayee(_payees[i], _shares[i]);\n    }\n  }\n\n  /**\n   * @dev Add a new payee to the contract.\n   * @param _payee The address of the payee to add.\n   * @param _shares The number of shares owned by the payee.\n   */\n  function addPayee(address _payee, uint256 _shares) internal {\n    require(_payee != address(0));\n    require(_shares > 0);\n    require(shares[_payee] == 0);\n\n    payees.push(_payee);\n    shares[_payee] = _shares;\n    totalShares = totalShares.add(_shares);\n  }\n\n  /**\n   * @dev Claim your share of the balance.\n   */\n  function claim() public {\n    address payee = msg.sender;\n\n    require(shares[payee] > 0);\n\n    uint256 totalReceived = this.balance.add(totalReleased);\n    uint256 payment = totalReceived.mul(shares[payee]).div(totalShares).sub(released[payee]);\n\n    require(payment != 0);\n    require(this.balance >= payment);\n\n    released[payee] = released[payee].add(payment);\n    totalReleased = totalReleased.add(payment);\n\n    payee.transfer(payment);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/BasicToken.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport './ERC20Basic.sol';\nimport '../math/SafeMath.sol';\n\n\n/**\n * @title Basic token\n * @dev Basic version of StandardToken, with no allowances.\n */\ncontract BasicToken is ERC20Basic {\n  using SafeMath for uint256;\n\n  mapping(address => uint256) balances;\n\n  /**\n  * @dev transfer token for a specified address\n  * @param _to The address to transfer to.\n  * @param _value The amount to be transferred.\n  */\n  function transfer(address _to, uint256 _value) public returns (bool) {\n    require(_to != address(0));\n    require(_value <= balances[msg.sender]);\n\n    // SafeMath.sub will throw if there is not enough balance.\n    balances[msg.sender] = balances[msg.sender].sub(_value);\n    balances[_to] = balances[_to].add(_value);\n    Transfer(msg.sender, _to, _value);\n    return true;\n  }\n\n  /**\n  * @dev Gets the balance of the specified address.\n  * @param _owner The address to query the the balance of.\n  * @return An uint256 representing the amount owned by the passed address.\n  */\n  function balanceOf(address _owner) public view returns (uint256 balance) {\n    return balances[_owner];\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/BurnableToken.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport './StandardToken.sol';\n\n/**\n * @title Burnable Token\n * @dev Token that can be irreversibly burned (destroyed).\n */\ncontract BurnableToken is StandardToken {\n\n    event Burn(address indexed burner, uint256 value);\n\n    /**\n     * @dev Burns a specific amount of tokens.\n     * @param _value The amount of token to be burned.\n     */\n    function burn(uint256 _value) public {\n        require(_value > 0);\n        require(_value <= balances[msg.sender]);\n        // no need to require value <= totalSupply, since that would imply the\n        // sender's balance is greater than the totalSupply, which *should* be an assertion failure\n\n        address burner = msg.sender;\n        balances[burner] = balances[burner].sub(_value);\n        totalSupply = totalSupply.sub(_value);\n        Burn(burner, _value);\n    }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/CappedToken.sol",
    "content": "pragma solidity ^0.4.11;\n\nimport './MintableToken.sol';\n\n/**\n * @title Capped token\n * @dev Mintable token with a token cap.\n */\n\ncontract CappedToken is MintableToken {\n\n  uint256 public cap;\n\n  function CappedToken(uint256 _cap) public {\n    require(_cap > 0);\n    cap = _cap;\n  }\n\n  /**\n   * @dev Function to mint tokens\n   * @param _to The address that will receive the minted tokens.\n   * @param _amount The amount of tokens to mint.\n   * @return A boolean that indicates if the operation was successful.\n   */\n  function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {\n    require(totalSupply.add(_amount) <= cap);\n\n    return super.mint(_to, _amount);\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/DetailedERC20.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport './ERC20.sol';\n\ncontract DetailedERC20 is ERC20 {\n  string public name;\n  string public symbol;\n  uint8 public decimals;\n\n  function DetailedERC20(string _name, string _symbol, uint8 _decimals) public {\n    name = _name;\n    symbol = _symbol;\n    decimals = _decimals;\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/ERC20.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport './ERC20Basic.sol';\n\n\n/**\n * @title ERC20 interface\n * @dev see https://github.com/ethereum/EIPs/issues/20\n */\ncontract ERC20 is ERC20Basic {\n  function allowance(address owner, address spender) public view returns (uint256);\n  function transferFrom(address from, address to, uint256 value) public returns (bool);\n  function approve(address spender, uint256 value) public returns (bool);\n  event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/ERC20Basic.sol",
    "content": "pragma solidity ^0.4.18;\n\n\n/**\n * @title ERC20Basic\n * @dev Simpler version of ERC20 interface\n * @dev see https://github.com/ethereum/EIPs/issues/179\n */\ncontract ERC20Basic {\n  uint256 public totalSupply;\n  function balanceOf(address who) public view returns (uint256);\n  function transfer(address to, uint256 value) public returns (bool);\n  event Transfer(address indexed from, address indexed to, uint256 value);\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/MintableToken.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport './StandardToken.sol';\nimport '../ownership/Ownable.sol';\n\n\n\n/**\n * @title Mintable token\n * @dev Simple ERC20 Token example, with mintable token creation\n * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120\n * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol\n */\n\ncontract MintableToken is StandardToken, Ownable {\n  event Mint(address indexed to, uint256 amount);\n  event MintFinished();\n\n  bool public mintingFinished = false;\n\n\n  modifier canMint() {\n    require(!mintingFinished);\n    _;\n  }\n\n  /**\n   * @dev Function to mint tokens\n   * @param _to The address that will receive the minted tokens.\n   * @param _amount The amount of tokens to mint.\n   * @return A boolean that indicates if the operation was successful.\n   */\n  function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {\n    totalSupply = totalSupply.add(_amount);\n    balances[_to] = balances[_to].add(_amount);\n    Mint(_to, _amount);\n    Transfer(address(0), _to, _amount);\n    return true;\n  }\n\n  /**\n   * @dev Function to stop minting new tokens.\n   * @return True if the operation was successful.\n   */\n  function finishMinting() onlyOwner canMint public returns (bool) {\n    mintingFinished = true;\n    MintFinished();\n    return true;\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/PausableToken.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport './StandardToken.sol';\nimport '../lifecycle/Pausable.sol';\n\n/**\n * @title Pausable token\n *\n * @dev StandardToken modified with pausable transfers.\n **/\n\ncontract PausableToken is StandardToken, Pausable {\n\n  function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) {\n    return super.transfer(_to, _value);\n  }\n\n  function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) {\n    return super.transferFrom(_from, _to, _value);\n  }\n\n  function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) {\n    return super.approve(_spender, _value);\n  }\n\n  function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) {\n    return super.increaseApproval(_spender, _addedValue);\n  }\n\n  function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) {\n    return super.decreaseApproval(_spender, _subtractedValue);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/SafeERC20.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport './ERC20Basic.sol';\nimport './ERC20.sol';\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure.\n * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n  function safeTransfer(ERC20Basic token, address to, uint256 value) internal {\n    assert(token.transfer(to, value));\n  }\n\n  function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal {\n    assert(token.transferFrom(from, to, value));\n  }\n\n  function safeApprove(ERC20 token, address spender, uint256 value) internal {\n    assert(token.approve(spender, value));\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/StandardToken.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport './BasicToken.sol';\nimport './ERC20.sol';\n\n\n/**\n * @title Standard ERC20 token\n *\n * @dev Implementation of the basic standard token.\n * @dev https://github.com/ethereum/EIPs/issues/20\n * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol\n */\ncontract StandardToken is ERC20, BasicToken {\n\n  mapping (address => mapping (address => uint256)) internal allowed;\n\n\n  /**\n   * @dev Transfer tokens from one address to another\n   * @param _from address The address which you want to send tokens from\n   * @param _to address The address which you want to transfer to\n   * @param _value uint256 the amount of tokens to be transferred\n   */\n  function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {\n    require(_to != address(0));\n    require(_value <= balances[_from]);\n    require(_value <= allowed[_from][msg.sender]);\n\n    balances[_from] = balances[_from].sub(_value);\n    balances[_to] = balances[_to].add(_value);\n    allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);\n    Transfer(_from, _to, _value);\n    return true;\n  }\n\n  /**\n   * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.\n   *\n   * Beware that changing an allowance with this method brings the risk that someone may use both the old\n   * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this\n   * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:\n   * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n   * @param _spender The address which will spend the funds.\n   * @param _value The amount of tokens to be spent.\n   */\n  function approve(address _spender, uint256 _value) public returns (bool) {\n    allowed[msg.sender][_spender] = _value;\n    Approval(msg.sender, _spender, _value);\n    return true;\n  }\n\n  /**\n   * @dev Function to check the amount of tokens that an owner allowed to a spender.\n   * @param _owner address The address which owns the funds.\n   * @param _spender address The address which will spend the funds.\n   * @return A uint256 specifying the amount of tokens still available for the spender.\n   */\n  function allowance(address _owner, address _spender) public view returns (uint256) {\n    return allowed[_owner][_spender];\n  }\n\n  /**\n   * approve should be called when allowed[_spender] == 0. To increment\n   * allowed value is better to use this function to avoid 2 calls (and wait until\n   * the first transaction is mined)\n   * From MonolithDAO Token.sol\n   */\n  function increaseApproval(address _spender, uint _addedValue) public returns (bool) {\n    allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);\n    Approval(msg.sender, _spender, allowed[msg.sender][_spender]);\n    return true;\n  }\n\n  function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {\n    uint oldValue = allowed[msg.sender][_spender];\n    if (_subtractedValue > oldValue) {\n      allowed[msg.sender][_spender] = 0;\n    } else {\n      allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);\n    }\n    Approval(msg.sender, _spender, allowed[msg.sender][_spender]);\n    return true;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/TokenTimelock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport './ERC20Basic.sol';\nimport \"../token/SafeERC20.sol\";\n\n/**\n * @title TokenTimelock\n * @dev TokenTimelock is a token holder contract that will allow a\n * beneficiary to extract the tokens after a given release time\n */\ncontract TokenTimelock {\n  using SafeERC20 for ERC20Basic;\n\n  // ERC20 basic token contract being held\n  ERC20Basic public token;\n\n  // beneficiary of tokens after they are released\n  address public beneficiary;\n\n  // timestamp when token release is enabled\n  uint64 public releaseTime;\n\n  function TokenTimelock(ERC20Basic _token, address _beneficiary, uint64 _releaseTime) public {\n    require(_releaseTime > now);\n    token = _token;\n    beneficiary = _beneficiary;\n    releaseTime = _releaseTime;\n  }\n\n  /**\n   * @notice Transfers tokens held by timelock to beneficiary.\n   */\n  function release() public {\n    require(now >= releaseTime);\n\n    uint256 amount = token.balanceOf(this);\n    require(amount > 0);\n\n    token.safeTransfer(beneficiary, amount);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/contracts/token/TokenVesting.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport './ERC20Basic.sol';\nimport './SafeERC20.sol';\nimport '../ownership/Ownable.sol';\nimport '../math/SafeMath.sol';\n\n/**\n * @title TokenVesting\n * @dev A token holder contract that can release its token balance gradually like a\n * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the\n * owner.\n */\ncontract TokenVesting is Ownable {\n  using SafeMath for uint256;\n  using SafeERC20 for ERC20Basic;\n\n  event Released(uint256 amount);\n  event Revoked();\n\n  // beneficiary of tokens after they are released\n  address public beneficiary;\n\n  uint256 public cliff;\n  uint256 public start;\n  uint256 public duration;\n\n  bool public revocable;\n\n  mapping (address => uint256) public released;\n  mapping (address => bool) public revoked;\n\n  /**\n   * @dev Creates a vesting contract that vests its balance of any ERC20 token to the\n   * _beneficiary, gradually in a linear fashion until _start + _duration. By then all\n   * of the balance will have vested.\n   * @param _beneficiary address of the beneficiary to whom vested tokens are transferred\n   * @param _cliff duration in seconds of the cliff in which tokens will begin to vest\n   * @param _duration duration in seconds of the period in which the tokens will vest\n   * @param _revocable whether the vesting is revocable or not\n   */\n  function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public {\n    require(_beneficiary != address(0));\n    require(_cliff <= _duration);\n\n    beneficiary = _beneficiary;\n    revocable = _revocable;\n    duration = _duration;\n    cliff = _start.add(_cliff);\n    start = _start;\n  }\n\n  /**\n   * @notice Transfers vested tokens to beneficiary.\n   * @param token ERC20 token which is being vested\n   */\n  function release(ERC20Basic token) public {\n    uint256 unreleased = releasableAmount(token);\n\n    require(unreleased > 0);\n\n    released[token] = released[token].add(unreleased);\n\n    token.safeTransfer(beneficiary, unreleased);\n\n    Released(unreleased);\n  }\n\n  /**\n   * @notice Allows the owner to revoke the vesting. Tokens already vested\n   * remain in the contract, the rest are returned to the owner.\n   * @param token ERC20 token which is being vested\n   */\n  function revoke(ERC20Basic token) public onlyOwner {\n    require(revocable);\n    require(!revoked[token]);\n\n    uint256 balance = token.balanceOf(this);\n\n    uint256 unreleased = releasableAmount(token);\n    uint256 refund = balance.sub(unreleased);\n\n    revoked[token] = true;\n\n    token.safeTransfer(owner, refund);\n\n    Revoked();\n  }\n\n  /**\n   * @dev Calculates the amount that has already vested but hasn't been released yet.\n   * @param token ERC20 token which is being vested\n   */\n  function releasableAmount(ERC20Basic token) public view returns (uint256) {\n    return vestedAmount(token).sub(released[token]);\n  }\n\n  /**\n   * @dev Calculates the amount that has already vested.\n   * @param token ERC20 token which is being vested\n   */\n  function vestedAmount(ERC20Basic token) public view returns (uint256) {\n    uint256 currentBalance = token.balanceOf(this);\n    uint256 totalBalance = currentBalance.add(released[token]);\n\n    if (now < cliff) {\n      return 0;\n    } else if (now >= start.add(duration) || revoked[token]) {\n      return totalBalance;\n    } else {\n      return totalBalance.mul(now.sub(start)).div(duration);\n    }\n  }\n}\n"
  },
  {
    "path": "truffle/oz/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/oz/migrations/2_deploy_contracts.js",
    "content": "var Ownable = artifacts.require(\"ownership/Ownable.sol\");\nvar BasicToken = artifacts.require(\"token/BasicToken.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Ownable);\n  deployer.deploy(BasicToken);\n};\n"
  },
  {
    "path": "truffle/oz/package.json",
    "content": "{\n  \"name\": \"open-zeppelin-samples\",\n  \"private\": true,\n  \"version\": \"1.0.0\",\n  \"description\": \"Open Zeppelin Samples\",\n  \"main\": \"truffle.js\",\n  \"directories\": {\n    \"test\": \"test\"\n  },\n  \"dependencies\": {\n    \"truffle\": \"^4.0.1\",\n    \"zeppelin-solidity\": \"^1.4.0\"\n  },\n  \"devDependencies\": {},\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\"\n}\n"
  },
  {
    "path": "truffle/oz/test/BasicToken.js",
    "content": "const assertRevert = require('./helpers/assertRevert');\n\nvar BasicTokenMock = artifacts.require(\"./helpers/BasicTokenMock.sol\");\n\ncontract('BasicToken', function(accounts) {\n\n  it(\"should return the correct totalSupply after construction\", async function() {\n    let token = await BasicTokenMock.new(accounts[0], 100);\n    let totalSupply = await token.totalSupply();\n\n    assert.equal(totalSupply, 100);\n  })\n\n  it(\"should return correct balances after transfer\", async function(){\n    let token = await BasicTokenMock.new(accounts[0], 100);\n    let transfer = await token.transfer(accounts[1], 100);\n\n    let firstAccountBalance = await token.balanceOf(accounts[0]);\n    assert.equal(firstAccountBalance, 0);\n\n    let secondAccountBalance = await token.balanceOf(accounts[1]);\n    assert.equal(secondAccountBalance, 100);\n  });\n\n  it('should throw an error when trying to transfer more than balance', async function() {\n    let token = await BasicTokenMock.new(accounts[0], 100);\n    try {\n      let transfer = await token.transfer(accounts[1], 101);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n  it('should throw an error when trying to transfer to 0x0', async function() {\n    let token = await BasicTokenMock.new(accounts[0], 100);\n    try {\n      let transfer = await token.transfer(0x0, 100);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/Bounty.js",
    "content": "'use strict';\n\nlet sendReward = function(sender, receiver, value){\n  web3.eth.sendTransaction({\n    from:sender,\n    to:receiver,\n    value: value\n  });\n};\nvar SecureTargetBounty = artifacts.require('helpers/SecureTargetBounty.sol');\nvar InsecureTargetBounty = artifacts.require('helpers/InsecureTargetBounty.sol');\n\nfunction awaitEvent(event, handler) {\n  return new Promise((resolve, reject) => {\n    function wrappedHandler(...args) {\n      Promise.resolve(handler(...args)).then(resolve).catch(reject);\n    }\n\n    event.watch(wrappedHandler);\n  });\n}\n\ncontract('Bounty', function(accounts) {\n\n  it('sets reward', async function() {\n    let owner = accounts[0];\n    let reward = web3.toWei(1, 'ether');\n    let bounty = await SecureTargetBounty.new();\n    sendReward(owner, bounty.address, reward);\n\n    assert.equal(reward, web3.eth.getBalance(bounty.address).toNumber());\n  });\n\n  it('empties itself when destroyed', async function(){\n    let owner = accounts[0];\n    let reward = web3.toWei(1, 'ether');\n    let bounty = await SecureTargetBounty.new();\n    sendReward(owner, bounty.address, reward);\n\n    assert.equal(reward, web3.eth.getBalance(bounty.address).toNumber());\n\n    await bounty.destroy();\n    assert.equal(0, web3.eth.getBalance(bounty.address).toNumber());\n  });\n\n  describe('Against secure contract', function(){\n\n    it('cannot claim reward', async function(){\n      let owner = accounts[0];\n      let researcher = accounts[1];\n      let reward = web3.toWei(1, 'ether');\n      let bounty = await SecureTargetBounty.new();\n      let event = bounty.TargetCreated({});\n\n      let watcher = async function(err, result) {\n        event.stopWatching();\n        if (err) { throw err; }\n\n        var targetAddress = result.args.createdAddress;\n        sendReward(owner, bounty.address, reward);\n\n        assert.equal(reward,\n          web3.eth.getBalance(bounty.address).toNumber());\n\n        try {\n          await bounty.claim(targetAddress, {from:researcher});\n          assert.isTrue(false); // should never reach here\n        } catch(error) {\n          let reClaimedBounty = await bounty.claimed.call();\n          assert.isFalse(reClaimedBounty);\n\n        }\n        try {\n          await bounty.withdrawPayments({from:researcher});\n          assert.isTrue(false); // should never reach here\n        } catch (err) {\n          assert.equal(reward,\n            web3.eth.getBalance(bounty.address).toNumber());\n        }\n      };\n      bounty.createTarget({from:researcher});\n      await awaitEvent(event, watcher);\n    });\n  });\n\n  describe('Against broken contract', function(){\n    it('claims reward', async function() {\n      let owner = accounts[0];\n      let researcher = accounts[1];\n      let reward = web3.toWei(1, 'ether');\n      let bounty = await InsecureTargetBounty.new();\n      let event = bounty.TargetCreated({});\n\n      let watcher = async function(err, result) {\n        event.stopWatching();\n        if (err) { throw err; }\n        let targetAddress = result.args.createdAddress;\n        sendReward(owner, bounty.address, reward);\n\n        assert.equal(reward, web3.eth.getBalance(bounty.address).toNumber());\n\n        await bounty.claim(targetAddress, {from:researcher});\n        let claim = await bounty.claimed.call();\n\n        assert.isTrue(claim);\n\n        await bounty.withdrawPayments({from:researcher});\n\n        assert.equal(0, web3.eth.getBalance(bounty.address).toNumber());\n      };\n      bounty.createTarget({from:researcher});\n      await awaitEvent(event, watcher);\n    });\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/BurnableToken.js",
    "content": "'use strict'\n\nconst EVMRevert = require('./helpers/EVMRevert.js')\nconst BurnableTokenMock = artifacts.require(\"./helpers/BurnableTokenMock.sol\")\nconst BigNumber = web3.BigNumber\n\nrequire('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should()\n\nconst expect = require('chai').expect\n\ncontract('BurnableToken', function (accounts) {\n    let token\n    let expectedTokenSupply = new BigNumber(999)\n\n    beforeEach(async function () {\n        token = await BurnableTokenMock.new(accounts[0], 1000)\n    })\n\n    it('owner should be able to burn tokens', async function () {\n        const { logs } = await token.burn(1, { from: accounts[0] })\n\n        const balance = await token.balanceOf(accounts[0])\n        balance.should.be.bignumber.equal(expectedTokenSupply)\n\n        const totalSupply = await token.totalSupply()\n        totalSupply.should.be.bignumber.equal(expectedTokenSupply)\n\n        const event = logs.find(e => e.event === 'Burn')\n        expect(event).to.exist\n    })\n\n    it('cannot burn more tokens than your balance', async function () {\n        await token.burn(2000, { from: accounts[0] })\n        .should.be.rejectedWith(EVMRevert)\n    })\n})\n"
  },
  {
    "path": "truffle/oz/test/CanReclaimToken.js",
    "content": "'use strict';\nimport expectThrow from './helpers/expectThrow';\nimport toPromise from './helpers/toPromise';\nconst CanReclaimToken = artifacts.require('../contracts/ownership/CanReclaimToken.sol');\nconst BasicTokenMock = artifacts.require(\"./helpers/BasicTokenMock.sol\");\n\ncontract('CanReclaimToken', function(accounts) {\n  let token = null;\n  let canReclaimToken = null;\n\n  beforeEach(async function() {\n    // Create contract and token\n    token = await BasicTokenMock.new(accounts[0], 100);\n    canReclaimToken = await CanReclaimToken.new();\n    // Force token into contract\n    await token.transfer(canReclaimToken.address, 10);\n    const startBalance = await token.balanceOf(canReclaimToken.address);\n    assert.equal(startBalance, 10);\n  });\n\n  it('should allow owner to reclaim tokens', async function() {\n    const ownerStartBalance = await token.balanceOf(accounts[0]);\n    await canReclaimToken.reclaimToken(token.address);\n    const ownerFinalBalance = await token.balanceOf(accounts[0]);\n    const finalBalance = await token.balanceOf(canReclaimToken.address);\n    assert.equal(finalBalance, 0);\n    assert.equal(ownerFinalBalance - ownerStartBalance, 10);\n  });\n\n  it('should allow only owner to reclaim tokens', async function() {\n    await expectThrow(\n      canReclaimToken.reclaimToken(token.address, {from: accounts[1]}),\n    );\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/CappedCrowdsale.js",
    "content": "import ether from './helpers/ether'\nimport {advanceBlock} from './helpers/advanceToBlock'\nimport {increaseTimeTo, duration} from './helpers/increaseTime'\nimport latestTime from './helpers/latestTime'\nimport EVMRevert from './helpers/EVMRevert'\n\nconst BigNumber = web3.BigNumber\n\nrequire('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should()\n\nconst CappedCrowdsale = artifacts.require('./helpers/CappedCrowdsaleImpl.sol')\nconst MintableToken = artifacts.require('MintableToken')\n\ncontract('CappedCrowdsale', function ([_, wallet]) {\n\n  const rate = new BigNumber(1000)\n\n  const cap = ether(300)\n  const lessThanCap = ether(60)\n\n  before(async function() {\n    //Advance to the next block to correctly read time in the solidity \"now\" function interpreted by testrpc\n    await advanceBlock()\n  })\n\n  beforeEach(async function () {\n    this.startTime = latestTime() + duration.weeks(1);\n    this.endTime =   this.startTime + duration.weeks(1);\n\n    this.crowdsale = await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, cap)\n\n    this.token = MintableToken.at(await this.crowdsale.token())\n  })\n\n  describe('creating a valid crowdsale', function () {\n\n    it('should fail with zero cap', async function () {\n      await CappedCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0).should.be.rejectedWith(EVMRevert);\n    })\n\n  });\n\n  describe('accepting payments', function () {\n\n    beforeEach(async function () {\n      await increaseTimeTo(this.startTime)\n    })\n\n    it('should accept payments within cap', async function () {\n      await this.crowdsale.send(cap.minus(lessThanCap)).should.be.fulfilled\n      await this.crowdsale.send(lessThanCap).should.be.fulfilled\n    })\n\n    it('should reject payments outside cap', async function () {\n      await this.crowdsale.send(cap)\n      await this.crowdsale.send(1).should.be.rejectedWith(EVMRevert)\n    })\n\n    it('should reject payments that exceed cap', async function () {\n      await this.crowdsale.send(cap.plus(1)).should.be.rejectedWith(EVMRevert)\n    })\n\n  })\n\n  describe('ending', function () {\n\n    beforeEach(async function () {\n      await increaseTimeTo(this.startTime)\n    })\n\n    it('should not be ended if under cap', async function () {\n      let hasEnded = await this.crowdsale.hasEnded()\n      hasEnded.should.equal(false)\n      await this.crowdsale.send(lessThanCap)\n      hasEnded = await this.crowdsale.hasEnded()\n      hasEnded.should.equal(false)\n    })\n\n    it('should not be ended if just under cap', async function () {\n      await this.crowdsale.send(cap.minus(1))\n      let hasEnded = await this.crowdsale.hasEnded()\n      hasEnded.should.equal(false)\n    })\n\n    it('should be ended if cap reached', async function () {\n      await this.crowdsale.send(cap)\n      let hasEnded = await this.crowdsale.hasEnded()\n      hasEnded.should.equal(true)\n    })\n\n  })\n\n})\n"
  },
  {
    "path": "truffle/oz/test/CappedToken.js",
    "content": "'use strict';\n\nimport expectThrow from './helpers/expectThrow';\nimport ether from './helpers/ether';\nvar CappedToken = artifacts.require('../contracts/Tokens/CappedToken.sol');\n\nconst BigNumber = web3.BigNumber\n\ncontract('Capped', function(accounts) {\n  const cap = ether(1000);\n\n  let token;\n\n  beforeEach(async function() {\n    token = await CappedToken.new(cap);\n  })\n\n  it('should start with the correct cap', async function() {\n    let _cap = await token.cap();\n\n    assert(cap.eq(_cap));\n  })\n\n  it('should mint when amount is less than cap', async function() {\n    const result = await token.mint(accounts[0], 100);\n    assert.equal(result.logs[0].event, 'Mint');\n  })\n\n  it('should fail to mint if the ammount exceeds the cap', async function() {\n    await token.mint(accounts[0], cap.sub(1));\n    await expectThrow(token.mint(accounts[0], 100));\n  })\n\n  it('should fail to mint after cap is reached', async function() {\n    await token.mint(accounts[0], cap);\n    await expectThrow(token.mint(accounts[0], 1));\n  })\n\n});\n"
  },
  {
    "path": "truffle/oz/test/Claimable.js",
    "content": "'use strict';\nconst assertRevert = require('./helpers/assertRevert');\n\nvar Claimable = artifacts.require('../contracts/ownership/Claimable.sol');\n\ncontract('Claimable', function(accounts) {\n  let claimable;\n\n  beforeEach(async function() {\n    claimable = await Claimable.new();\n  });\n\n  it('should have an owner', async function() {\n    let owner = await claimable.owner();\n    assert.isTrue(owner !== 0);\n  });\n\n  it('changes pendingOwner after transfer', async function() {\n    let newOwner = accounts[1];\n    await claimable.transferOwnership(newOwner);\n    let pendingOwner = await claimable.pendingOwner();\n\n    assert.isTrue(pendingOwner === newOwner);\n  });\n\n  it('should prevent to claimOwnership from no pendingOwner', async function() {\n    try {\n      await claimable.claimOwnership({from: accounts[2]});\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n  it('should prevent non-owners from transfering', async function() {\n    const other = accounts[2];\n    const owner = await claimable.owner.call();\n    assert.isTrue(owner !== other);\n    try {\n      await claimable.transferOwnership(other, {from: other});\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n  describe('after initiating a transfer', function () {\n    let newOwner;\n\n    beforeEach(async function () {\n      newOwner = accounts[1];\n      await claimable.transferOwnership(newOwner);\n    });\n\n    it('changes allow pending owner to claim ownership', async function() {\n      await claimable.claimOwnership({from: newOwner});\n      let owner = await claimable.owner();\n\n      assert.isTrue(owner === newOwner);\n    });\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/Contactable.js",
    "content": "'use strict';\nconst assertRevert = require('./helpers/assertRevert');\n\nvar Contactable = artifacts.require('../contracts/ownership/Contactable.sol');\n\ncontract('Contactable', function(accounts) {\n  let contactable;\n\n  beforeEach(async function() {\n    contactable = await Contactable.new();\n  });\n\n  it('should have an empty contact info', async function() {\n    let info = await contactable.contactInformation();\n    assert.isTrue(info == \"\");\n  });\n\n  describe('after setting the contact information', function () {\n    let contactInfo = \"contact information\"\n\n    beforeEach(async function () {\n      await contactable.setContactInformation(contactInfo);\n    });\n\n    it('should return the setted contact information', async function() {\n      let info = await contactable.contactInformation();\n      assert.isTrue(info === contactInfo);\n   });\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/Crowdsale.js",
    "content": "import ether from './helpers/ether'\nimport {advanceBlock} from './helpers/advanceToBlock'\nimport {increaseTimeTo, duration} from './helpers/increaseTime'\nimport latestTime from './helpers/latestTime'\nimport EVMRevert from './helpers/EVMRevert'\n\nconst BigNumber = web3.BigNumber\n\nconst should = require('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should()\n\nconst Crowdsale = artifacts.require('Crowdsale')\nconst MintableToken = artifacts.require('MintableToken')\n\ncontract('Crowdsale', function ([_, investor, wallet, purchaser]) {\n\n  const rate = new BigNumber(1000)\n  const value = ether(42)\n\n  const expectedTokenAmount = rate.mul(value)\n\n  before(async function() {\n    //Advance to the next block to correctly read time in the solidity \"now\" function interpreted by testrpc\n    await advanceBlock()\n  })\n\n  beforeEach(async function () {\n    this.startTime = latestTime() + duration.weeks(1);\n    this.endTime =   this.startTime + duration.weeks(1);\n    this.afterEndTime = this.endTime + duration.seconds(1)\n\n\n    this.crowdsale = await Crowdsale.new(this.startTime, this.endTime, rate, wallet)\n\n    this.token = MintableToken.at(await this.crowdsale.token())\n  })\n\n  it('should be token owner', async function () {\n    const owner = await this.token.owner()\n    owner.should.equal(this.crowdsale.address)\n  })\n\n  it('should be ended only after end', async function () {\n    let ended = await this.crowdsale.hasEnded()\n    ended.should.equal(false)\n    await increaseTimeTo(this.afterEndTime)\n    ended = await this.crowdsale.hasEnded()\n    ended.should.equal(true)\n  })\n\n  describe('accepting payments', function () {\n\n    it('should reject payments before start', async function () {\n      await this.crowdsale.send(value).should.be.rejectedWith(EVMRevert)\n      await this.crowdsale.buyTokens(investor, {from: purchaser, value: value}).should.be.rejectedWith(EVMRevert)\n    })\n\n    it('should accept payments after start', async function () {\n      await increaseTimeTo(this.startTime)\n      await this.crowdsale.send(value).should.be.fulfilled\n      await this.crowdsale.buyTokens(investor, {value: value, from: purchaser}).should.be.fulfilled\n    })\n\n    it('should reject payments after end', async function () {\n      await increaseTimeTo(this.afterEndTime)\n      await this.crowdsale.send(value).should.be.rejectedWith(EVMRevert)\n      await this.crowdsale.buyTokens(investor, {value: value, from: purchaser}).should.be.rejectedWith(EVMRevert)\n    })\n\n  })\n\n  describe('high-level purchase', function () {\n\n    beforeEach(async function() {\n      await increaseTimeTo(this.startTime)\n    })\n\n    it('should log purchase', async function () {\n      const {logs} = await this.crowdsale.sendTransaction({value: value, from: investor})\n\n      const event = logs.find(e => e.event === 'TokenPurchase')\n\n      should.exist(event)\n      event.args.purchaser.should.equal(investor)\n      event.args.beneficiary.should.equal(investor)\n      event.args.value.should.be.bignumber.equal(value)\n      event.args.amount.should.be.bignumber.equal(expectedTokenAmount)\n    })\n\n    it('should increase totalSupply', async function () {\n      await this.crowdsale.send(value)\n      const totalSupply = await this.token.totalSupply()\n      totalSupply.should.be.bignumber.equal(expectedTokenAmount)\n    })\n\n    it('should assign tokens to sender', async function () {\n      await this.crowdsale.sendTransaction({value: value, from: investor})\n      let balance = await this.token.balanceOf(investor);\n      balance.should.be.bignumber.equal(expectedTokenAmount)\n    })\n\n    it('should forward funds to wallet', async function () {\n      const pre = web3.eth.getBalance(wallet)\n      await this.crowdsale.sendTransaction({value, from: investor})\n      const post = web3.eth.getBalance(wallet)\n      post.minus(pre).should.be.bignumber.equal(value)\n    })\n\n  })\n\n  describe('low-level purchase', function () {\n\n    beforeEach(async function() {\n      await increaseTimeTo(this.startTime)\n    })\n\n    it('should log purchase', async function () {\n      const {logs} = await this.crowdsale.buyTokens(investor, {value: value, from: purchaser})\n\n      const event = logs.find(e => e.event === 'TokenPurchase')\n\n      should.exist(event)\n      event.args.purchaser.should.equal(purchaser)\n      event.args.beneficiary.should.equal(investor)\n      event.args.value.should.be.bignumber.equal(value)\n      event.args.amount.should.be.bignumber.equal(expectedTokenAmount)\n    })\n\n    it('should increase totalSupply', async function () {\n      await this.crowdsale.buyTokens(investor, {value, from: purchaser})\n      const totalSupply = await this.token.totalSupply()\n      totalSupply.should.be.bignumber.equal(expectedTokenAmount)\n    })\n\n    it('should assign tokens to beneficiary', async function () {\n      await this.crowdsale.buyTokens(investor, {value, from: purchaser})\n      const balance = await this.token.balanceOf(investor)\n      balance.should.be.bignumber.equal(expectedTokenAmount)\n    })\n\n    it('should forward funds to wallet', async function () {\n      const pre = web3.eth.getBalance(wallet)\n      await this.crowdsale.buyTokens(investor, {value, from: purchaser})\n      const post = web3.eth.getBalance(wallet)\n      post.minus(pre).should.be.bignumber.equal(value)\n    })\n\n  })\n\n})\n"
  },
  {
    "path": "truffle/oz/test/DayLimit.js",
    "content": "'use strict';\nconst assertRevert = require('./helpers/assertRevert');\nimport latestTime from './helpers/latestTime'\nimport {increaseTimeTo, duration} from './helpers/increaseTime'\n\nvar DayLimitMock = artifacts.require('./helpers/DayLimitMock.sol');\n\ncontract('DayLimit', function(accounts) {\n\n  let dayLimit;\n  let initLimit = 10;\n\n  beforeEach( async function() {\n    this.startTime = latestTime();\n    dayLimit = await DayLimitMock.new(initLimit);\n  });\n\n  it('should construct with the passed daily limit', async function() {\n    let dailyLimit = await dayLimit.dailyLimit();\n    assert.equal(initLimit, dailyLimit);\n  });\n\n  it('should be able to spend if daily limit is not reached', async function() {\n    await dayLimit.attemptSpend(8);\n    let spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 8);\n\n    await dayLimit.attemptSpend(2);\n    spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 10);\n  });\n\n  it('should prevent spending if daily limit is reached', async function() {\n    await dayLimit.attemptSpend(8);\n    let spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 8);\n\n    try {\n      await dayLimit.attemptSpend(3);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n  it('should allow spending if daily limit is reached and then set higher', async function() {\n    await dayLimit.attemptSpend(8);\n    let spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 8);\n\n    try {\n      await dayLimit.attemptSpend(3);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n    spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 8);\n\n    await dayLimit.setDailyLimit(15);\n    await dayLimit.attemptSpend(3);\n    spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 11);\n  });\n\n  it('should allow spending if daily limit is reached and then amount spent is reset', async function() {\n    await dayLimit.attemptSpend(8);\n    let spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 8);\n\n    try {\n      await dayLimit.attemptSpend(3);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n    spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 8);\n\n    await dayLimit.resetSpentToday();\n    await dayLimit.attemptSpend(3);\n    spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 3);\n  });\n\n  it('should allow spending if daily limit is reached and then the next has come', async function() {\n    let limit = 10;\n    let dayLimit = await DayLimitMock.new(limit);\n\n    await dayLimit.attemptSpend(8);\n    let spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 8);\n\n    try {\n      await dayLimit.attemptSpend(3);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n    spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 8);\n\n    await increaseTimeTo(this.startTime + duration.days(1));\n\n    await dayLimit.attemptSpend(3);\n    spentToday = await dayLimit.spentToday();\n    assert.equal(spentToday, 3);\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/DelayedClaimble.js",
    "content": "'use strict';\n\nvar DelayedClaimable = artifacts.require('../contracts/ownership/DelayedClaimable.sol');\n\ncontract('DelayedClaimable', function(accounts) {\n  var delayedClaimable;\n\n  beforeEach(function() {\n    return DelayedClaimable.new().then(function(deployed) {\n      delayedClaimable = deployed;\n    });\n  });\n\n  it('can set claim blocks', async function() {\n    await delayedClaimable.transferOwnership(accounts[2]);\n    await delayedClaimable.setLimits(0, 1000);\n    let end = await delayedClaimable.end();\n    assert.equal(end, 1000);\n    let start = await delayedClaimable.start();\n    assert.equal(start, 0);\n  });\n\n  it('changes pendingOwner after transfer successful', async function() {\n    await delayedClaimable.transferOwnership(accounts[2]);\n    await delayedClaimable.setLimits(0, 1000);\n    let end = await delayedClaimable.end();\n    assert.equal(end, 1000);\n    let start = await delayedClaimable.start();\n    assert.equal(start, 0);\n    let pendingOwner = await delayedClaimable.pendingOwner();\n    assert.equal(pendingOwner, accounts[2]);\n    await delayedClaimable.claimOwnership({from: accounts[2]});\n    let owner = await delayedClaimable.owner();\n    assert.equal(owner, accounts[2]);\n  });\n\n  it('changes pendingOwner after transfer fails', async function() {\n    await delayedClaimable.transferOwnership(accounts[1]);\n    await delayedClaimable.setLimits(100, 110);\n    let end = await delayedClaimable.end();\n    assert.equal(end, 110);\n    let start = await delayedClaimable.start();\n    assert.equal(start, 100);\n    let pendingOwner = await delayedClaimable.pendingOwner();\n    assert.equal(pendingOwner, accounts[1]);\n    var err = null;\n    try {\n      await delayedClaimable.claimOwnership({from: accounts[1]});\n    } catch (error) {\n      err = error;\n    }\n    assert.isFalse(err.message.search('revert') === -1);\n    let owner = await delayedClaimable.owner();\n    assert.isTrue(owner !== accounts[1]);\n  });\n\n  it('set end and start invalid values fail', async function() {\n    await delayedClaimable.transferOwnership(accounts[1]);\n    var err = null;\n    try {\n      await delayedClaimable.setLimits(1001, 1000);\n    } catch (error) {\n      err = error;\n    }\n    assert.isFalse(err.message.search('revert') === -1);\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/Destructible.js",
    "content": "'use strict';\n\nvar Destructible = artifacts.require('../contracts/lifecycle/Destructible.sol');\nrequire('./helpers/transactionMined.js');\n\ncontract('Destructible', function(accounts) {\n\n  it('should send balance to owner after destruction', async function() {\n    let destructible = await Destructible.new({from: accounts[0], value: web3.toWei('10','ether')});\n    let owner = await destructible.owner();\n    let initBalance = web3.eth.getBalance(owner);\n    await destructible.destroy({from: owner});\n    let newBalance = web3.eth.getBalance(owner);\n    assert.isTrue(newBalance > initBalance);\n  });\n\n  it('should send balance to recepient after destruction', async function() {\n    let destructible = await Destructible.new({from: accounts[0], value: web3.toWei('10','ether')});\n    let owner = await destructible.owner();\n    let initBalance = web3.eth.getBalance(accounts[1]);\n    await destructible.destroyAndSend(accounts[1], {from: owner} );\n    let newBalance = web3.eth.getBalance(accounts[1]);\n    assert.isTrue(newBalance.greaterThan(initBalance));\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/DetailedERC20.js",
    "content": "const BigNumber = web3.BigNumber;\n\nrequire('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should();\n\nconst DetailedERC20Mock = artifacts.require('./helpers/DetailedERC20Mock.sol');\n\ncontract('DetailedERC20', accounts => {\n  let detailedERC20 = null;\n\n  const _name = \"My Detailed ERC20\";\n  const _symbol = \"MDT\";\n  const _decimals = 18;\n\n  beforeEach(async function() {\n    detailedERC20 = await DetailedERC20Mock.new(_name, _symbol, _decimals);\n  });\n\n  it('has a name', async function () {\n    const name = await detailedERC20.name();\n    name.should.be.equal(_name);\n  });\n\n  it('has a symbol', async function () {\n    const symbol = await detailedERC20.symbol();\n    symbol.should.be.equal(_symbol);\n  });\n\n  it('has an amount of decimals', async function () {\n    const decimals = await detailedERC20.decimals();\n    decimals.should.be.bignumber.equal(_decimals)\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/ECRecovery.js",
    "content": "var ECRecovery = artifacts.require(\"../contracts/ECRecovery.sol\");\nvar utils = require('ethereumjs-util');\nvar hashMessage = require('./helpers/hashMessage.js');\n\ncontract('ECRecovery', function(accounts) {\n\n  let ecrecovery;\n\n  before(async function() {\n    ecrecovery = await ECRecovery.new();\n  });\n\n  it(\"recover v0\", async function() {\n    // Signature generated outside testrpc with method web3.eth.sign(signer, message)\n    let signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c';\n    let message = '0x7dbaf558b0a1a5dc7a67202117ab143c1d8605a983e4a743bc06fcc03162dc0d'; // web3.sha3('OpenZeppelin')\n    let signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200';\n    assert.equal(signer, await ecrecovery.recover(message, signature));\n  });\n\n  it(\"recover v1\", async function() {\n    // Signature generated outside testrpc with method web3.eth.sign(signer, message)\n    let signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e';\n    let message = '0x7dbaf558b0a1a5dc7a67202117ab143c1d8605a983e4a743bc06fcc03162dc0d'; // web3.sha3('OpenZeppelin')\n    let signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001';\n    assert.equal(signer, await ecrecovery.recover(message, signature));\n  });\n\n  it(\"recover using web3.eth.sign()\", async function() {\n    // Create the signature using account[0]\n    const signature = web3.eth.sign(web3.eth.accounts[0], web3.sha3('OpenZeppelin'));\n\n    // Recover the signer address form the generated message and signature.\n    assert.equal(web3.eth.accounts[0], await ecrecovery.recover(hashMessage('OpenZeppelin'), signature));\n  });\n\n  it(\"recover using web3.eth.sign() should return wrong signer\", async function() {\n    // Create the signature using account[0]\n    const signature = web3.eth.sign(web3.eth.accounts[0], web3.sha3('OpenZeppelin'));\n\n    // Recover the signer address form the generated message and wrong signature.\n    assert.notEqual(web3.eth.accounts[0], await ecrecovery.recover(hashMessage('Test'), signature));\n  });\n\n  it(\"recover should fail when a wrong hash is sent\", async function() {\n    // Create the signature using account[0]\n    let signature = web3.eth.sign(web3.eth.accounts[0], web3.sha3('OpenZeppelin'));\n\n    // Recover the signer address form the generated message and wrong signature.\n    assert.equal('0x0000000000000000000000000000000000000000',\n      await ecrecovery.recover(hashMessage('OpenZeppelin').substring(2), signature)\n    );\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/FinalizableCrowdsale.js",
    "content": "import {advanceBlock} from './helpers/advanceToBlock'\nimport {increaseTimeTo, duration} from './helpers/increaseTime'\nimport latestTime from './helpers/latestTime'\nimport EVMRevert from './helpers/EVMRevert'\n\nconst BigNumber = web3.BigNumber\n\nconst should = require('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should()\n\nconst FinalizableCrowdsale = artifacts.require('./helpers/FinalizableCrowdsaleImpl.sol')\nconst MintableToken = artifacts.require('MintableToken')\n\ncontract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) {\n\n  const rate = new BigNumber(1000)\n\n  before(async function() {\n    //Advance to the next block to correctly read time in the solidity \"now\" function interpreted by testrpc\n    await advanceBlock()\n  })\n\n  beforeEach(async function () {\n    this.startTime = latestTime() + duration.weeks(1)\n    this.endTime =   this.startTime + duration.weeks(1)\n    this.afterEndTime = this.endTime + duration.seconds(1)\n\n\n    this.crowdsale = await FinalizableCrowdsale.new(this.startTime, this.endTime, rate, wallet, {from: owner})\n\n    this.token = MintableToken.at(await this.crowdsale.token())\n  })\n\n  it('cannot be finalized before ending', async function () {\n    await this.crowdsale.finalize({from: owner}).should.be.rejectedWith(EVMRevert)\n  })\n\n  it('cannot be finalized by third party after ending', async function () {\n    await increaseTimeTo(this.afterEndTime)\n    await this.crowdsale.finalize({from: thirdparty}).should.be.rejectedWith(EVMRevert)\n  })\n\n  it('can be finalized by owner after ending', async function () {\n    await increaseTimeTo(this.afterEndTime)\n    await this.crowdsale.finalize({from: owner}).should.be.fulfilled\n  })\n\n  it('cannot be finalized twice', async function () {\n    await increaseTimeTo(this.afterEndTime)\n    await this.crowdsale.finalize({from: owner})\n    await this.crowdsale.finalize({from: owner}).should.be.rejectedWith(EVMRevert)\n  })\n\n  it('logs finalized', async function () {\n    await increaseTimeTo(this.afterEndTime)\n    const {logs} = await this.crowdsale.finalize({from: owner})\n    const event = logs.find(e => e.event === 'Finalized')\n    should.exist(event)\n  })\n\n})\n"
  },
  {
    "path": "truffle/oz/test/HasNoContracts.js",
    "content": "'use strict';\nimport expectThrow from './helpers/expectThrow';\nimport toPromise from './helpers/toPromise';\nconst Ownable = artifacts.require('../contracts/ownership/Ownable.sol');\nconst HasNoContracts = artifacts.require(\n  '../contracts/ownership/HasNoContracts.sol',\n);\n\ncontract('HasNoContracts', function(accounts) {\n  let hasNoContracts = null;\n  let ownable = null;\n\n  beforeEach(async () => {\n    // Create contract and token\n    hasNoContracts = await HasNoContracts.new();\n    ownable = await Ownable.new();\n\n    // Force ownership into contract\n    await ownable.transferOwnership(hasNoContracts.address);\n    const owner = await ownable.owner();\n    assert.equal(owner, hasNoContracts.address);\n  });\n\n  it('should allow owner to reclaim contracts', async function() {\n    await hasNoContracts.reclaimContract(ownable.address);\n    const owner = await ownable.owner();\n    assert.equal(owner, accounts[0]);\n  });\n\n  it('should allow only owner to reclaim contracts', async function() {\n    await expectThrow(\n      hasNoContracts.reclaimContract(ownable.address, {from: accounts[1]}),\n    );\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/HasNoEther.js",
    "content": "'use strict';\nimport expectThrow from './helpers/expectThrow';\nimport toPromise from './helpers/toPromise';\nconst HasNoEther = artifacts.require('../contracts/lifecycle/HasNoEther.sol');\nconst HasNoEtherTest = artifacts.require('../helpers/HasNoEtherTest.sol');\nconst ForceEther = artifacts.require('../helpers/ForceEther.sol');\n\ncontract('HasNoEther', function(accounts) {\n  const amount = web3.toWei('1', 'ether');\n\n  it('should be constructorable', async function() {\n    let hasNoEther = await HasNoEtherTest.new();\n  });\n\n  it('should not accept ether in constructor', async function() {\n    await expectThrow(HasNoEtherTest.new({value: amount}));\n  });\n\n  it('should not accept ether', async function() {\n    let hasNoEther = await HasNoEtherTest.new();\n\n    await expectThrow(\n      toPromise(web3.eth.sendTransaction)({\n        from: accounts[1],\n        to: hasNoEther.address,\n        value: amount,\n      }),\n    );\n  });\n\n  it('should allow owner to reclaim ether', async function() {\n    // Create contract\n    let hasNoEther = await HasNoEtherTest.new();\n    const startBalance = await web3.eth.getBalance(hasNoEther.address);\n    assert.equal(startBalance, 0);\n\n    // Force ether into it\n    let forceEther = await ForceEther.new({value: amount});\n    await forceEther.destroyAndSend(hasNoEther.address);\n    const forcedBalance = await web3.eth.getBalance(hasNoEther.address);\n    assert.equal(forcedBalance, amount);\n\n    // Reclaim\n    const ownerStartBalance = await web3.eth.getBalance(accounts[0]);\n    await hasNoEther.reclaimEther();\n    const ownerFinalBalance = await web3.eth.getBalance(accounts[0]);\n    const finalBalance = await web3.eth.getBalance(hasNoEther.address);\n    assert.equal(finalBalance, 0);\n    assert.isAbove(ownerFinalBalance, ownerStartBalance);\n  });\n\n  it('should allow only owner to reclaim ether', async function() {\n    // Create contract\n    let hasNoEther = await HasNoEtherTest.new({from: accounts[0]});\n\n    // Force ether into it\n    let forceEther = await ForceEther.new({value: amount});\n    await forceEther.destroyAndSend(hasNoEther.address);\n    const forcedBalance = await web3.eth.getBalance(hasNoEther.address);\n    assert.equal(forcedBalance, amount);\n\n    // Reclaim\n    await expectThrow(hasNoEther.reclaimEther({from: accounts[1]}));\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/HasNoTokens.js",
    "content": "'use strict';\nimport expectThrow from './helpers/expectThrow';\nimport toPromise from './helpers/toPromise';\nconst HasNoTokens = artifacts.require('../contracts/lifecycle/HasNoTokens.sol');\nconst ERC23TokenMock = artifacts.require('./helpers/ERC23TokenMock.sol');\n\ncontract('HasNoTokens', function(accounts) {\n  let hasNoTokens = null;\n  let token = null;\n\n  beforeEach(async () => {\n    // Create contract and token\n    hasNoTokens = await HasNoTokens.new();\n    token = await ERC23TokenMock.new(accounts[0], 100);\n\n    // Force token into contract\n    await token.transfer(hasNoTokens.address, 10);\n    const startBalance = await token.balanceOf(hasNoTokens.address);\n    assert.equal(startBalance, 10);\n  });\n\n  it('should not accept ERC23 tokens', async function() {\n    await expectThrow(token.transferERC23(hasNoTokens.address, 10, ''));\n  });\n\n  it('should allow owner to reclaim tokens', async function() {\n    const ownerStartBalance = await token.balanceOf(accounts[0]);\n    await hasNoTokens.reclaimToken(token.address);\n    const ownerFinalBalance = await token.balanceOf(accounts[0]);\n    const finalBalance = await token.balanceOf(hasNoTokens.address);\n    assert.equal(finalBalance, 0);\n    assert.equal(ownerFinalBalance - ownerStartBalance, 10);\n  });\n\n  it('should allow only owner to reclaim tokens', async function() {\n    await expectThrow(\n      hasNoTokens.reclaimToken(token.address, {from: accounts[1]}),\n    );\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/LimitBalance.js",
    "content": "'use strict';\n\nvar LimitBalanceMock = artifacts.require('helpers/LimitBalanceMock.sol');\nconst assertRevert = require('./helpers/assertRevert');\n\ncontract('LimitBalance', function(accounts) {\n  let lb;\n\n  beforeEach(async function() {\n    lb = await LimitBalanceMock.new();\n  });\n\n  let LIMIT = 1000;\n\n  it('should expose limit', async function() {\n    let limit = await lb.limit();\n    assert.equal(limit, LIMIT);\n  });\n\n  it('should allow sending below limit', async function() {\n    let amount = 1;\n    await lb.limitedDeposit({value: amount});\n\n    assert.equal(web3.eth.getBalance(lb.address), amount);\n  });\n\n  it('shouldnt allow sending above limit', async function() {\n    let amount = 1110;\n    try {\n      await lb.limitedDeposit({value: amount});\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n  it('should allow multiple sends below limit', async function() {\n    let amount = 500;\n    await lb.limitedDeposit({value: amount});\n\n    assert.equal(web3.eth.getBalance(lb.address), amount);\n\n    await lb.limitedDeposit({value: amount});\n    assert.equal(web3.eth.getBalance(lb.address), amount*2);\n  });\n\n  it('shouldnt allow multiple sends above limit', async function() {\n    let amount = 500;\n    await lb.limitedDeposit({value: amount});\n\n    assert.equal(web3.eth.getBalance(lb.address), amount);\n\n    try {\n      await lb.limitedDeposit({value: amount+1});\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/MerkleProof.js",
    "content": "var MerkleProof = artifacts.require(\"./MerkleProof.sol\");\n\nimport MerkleTree from \"./helpers/merkleTree.js\";\nimport { sha3, bufferToHex } from \"ethereumjs-util\";\n\ncontract('MerkleProof', function(accounts) {\n  let merkleProof;\n\n  before(async function() {\n    merkleProof = await MerkleProof.new();\n  });\n\n  describe(\"verifyProof\", function() {\n    it(\"should return true for a valid Merkle proof\", async function() {\n      const elements = [\"a\", \"b\", \"c\", \"d\"];\n      const merkleTree = new MerkleTree(elements);\n\n      const root = merkleTree.getHexRoot();\n\n      const proof = merkleTree.getHexProof(elements[0]);\n\n      const leaf = bufferToHex(sha3(elements[0]));\n\n      const result = await merkleProof.verifyProof(proof, root, leaf);\n      assert.isOk(result, \"verifyProof did not return true for a valid proof\");\n    });\n\n    it(\"should return false for an invalid Merkle proof\", async function() {\n      const correctElements = [\"a\", \"b\", \"c\"]\n      const correctMerkleTree = new MerkleTree(correctElements);\n\n      const correctRoot = correctMerkleTree.getHexRoot();\n\n      const correctLeaf = bufferToHex(sha3(correctElements[0]));\n\n      const badElements = [\"d\", \"e\", \"f\"]\n      const badMerkleTree = new MerkleTree(badElements)\n\n      const badProof = badMerkleTree.getHexProof(badElements[0])\n\n      const result = await merkleProof.verifyProof(badProof, correctRoot, correctLeaf);\n      assert.isNotOk(result, \"verifyProof did not return false for an invalid proof\");\n    });\n\n    it(\"should return false for a Merkle proof of invalid length\", async function() {\n      const elements = [\"a\", \"b\", \"c\"]\n      const merkleTree = new MerkleTree(elements);\n\n      const root = merkleTree.getHexRoot();\n\n      const proof = merkleTree.getHexProof(elements[0]);\n      const badProof = proof.slice(0, proof.length - 5);\n\n      const leaf = bufferToHex(sha3(elements[0]));\n\n      const result = await merkleProof.verifyProof(badProof, root, leaf);\n      assert.isNotOk(result, \"verifyProof did not return false for proof of invalid length\");\n    })\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/MintableToken.js",
    "content": "'use strict';\n\nimport expectThrow from './helpers/expectThrow';\nvar MintableToken = artifacts.require('../contracts/Tokens/MintableToken.sol');\n\ncontract('Mintable', function(accounts) {\n  let token;\n\n  beforeEach(async function() {\n    token = await MintableToken.new();\n  });\n\n  it('should start with a totalSupply of 0', async function() {\n    let totalSupply = await token.totalSupply();\n\n    assert.equal(totalSupply, 0);\n  });\n\n  it('should return mintingFinished false after construction', async function() {\n    let mintingFinished = await token.mintingFinished();\n\n    assert.equal(mintingFinished, false);\n  });\n\n  it('should mint a given amount of tokens to a given address', async function() {\n    const result = await token.mint(accounts[0], 100);\n    assert.equal(result.logs[0].event, 'Mint');\n    assert.equal(result.logs[0].args.to.valueOf(), accounts[0]);\n    assert.equal(result.logs[0].args.amount.valueOf(), 100);\n    assert.equal(result.logs[1].event, 'Transfer');\n    assert.equal(result.logs[1].args.from.valueOf(), 0x0);\n\n    let balance0 = await token.balanceOf(accounts[0]);\n    assert(balance0, 100);\n\n    let totalSupply = await token.totalSupply();\n    assert(totalSupply, 100);\n  })\n\n  it('should fail to mint after call to finishMinting', async function () {\n    await token.finishMinting();\n    assert.equal(await token.mintingFinished(), true);\n    await expectThrow(token.mint(accounts[0], 100));\n  })\n\n});\n"
  },
  {
    "path": "truffle/oz/test/Ownable.js",
    "content": "'use strict';\nconst assertRevert = require('./helpers/assertRevert');\n\nvar Ownable = artifacts.require('../contracts/ownership/Ownable.sol');\n\ncontract('Ownable', function(accounts) {\n  let ownable;\n\n  beforeEach(async function() {\n    ownable = await Ownable.new();\n  });\n\n  it('should have an owner', async function() {\n    let owner = await ownable.owner();\n    assert.isTrue(owner !== 0);\n  });\n\n  it('changes owner after transfer', async function() {\n    let other = accounts[1];\n    await ownable.transferOwnership(other);\n    let owner = await ownable.owner();\n\n    assert.isTrue(owner === other);\n  });\n\n  it('should prevent non-owners from transfering', async function() {\n    const other = accounts[2];\n    const owner = await ownable.owner.call();\n    assert.isTrue(owner !== other);\n    try {\n      await ownable.transferOwnership(other, {from: other});\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n  it('should guard ownership against stuck state', async function() {\n    let originalOwner = await ownable.owner();\n    try {\n      await ownable.transferOwnership(null, {from: originalOwner});\n      assert.fail();\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/Pausable.js",
    "content": "'use strict';\n\nconst assertRevert = require('./helpers/assertRevert');\nconst PausableMock = artifacts.require('helpers/PausableMock.sol');\n\ncontract('Pausable', function(accounts) {\n\n  it('can perform normal process in non-pause', async function() {\n    let Pausable = await PausableMock.new();\n    let count0 = await Pausable.count();\n    assert.equal(count0, 0);\n\n    await Pausable.normalProcess();\n    let count1 = await Pausable.count();\n    assert.equal(count1, 1);\n  });\n\n  it('can not perform normal process in pause', async function() {\n    let Pausable = await PausableMock.new();\n    await Pausable.pause();\n    let count0 = await Pausable.count();\n    assert.equal(count0, 0);\n\n    try {\n      await Pausable.normalProcess();\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n    let count1 = await Pausable.count();\n    assert.equal(count1, 0);\n  });\n\n\n  it('can not take drastic measure in non-pause', async function() {\n    let Pausable = await PausableMock.new();\n    try {\n      await Pausable.drasticMeasure();\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n    const drasticMeasureTaken = await Pausable.drasticMeasureTaken();\n    assert.isFalse(drasticMeasureTaken);\n  });\n\n  it('can take a drastic measure in a pause', async function() {\n    let Pausable = await PausableMock.new();\n    await Pausable.pause();\n    await Pausable.drasticMeasure();\n    let drasticMeasureTaken = await Pausable.drasticMeasureTaken();\n\n    assert.isTrue(drasticMeasureTaken);\n  });\n\n  it('should resume allowing normal process after pause is over', async function() {\n    let Pausable = await PausableMock.new();\n    await Pausable.pause();\n    await Pausable.unpause();\n    await Pausable.normalProcess();\n    let count0 = await Pausable.count();\n\n    assert.equal(count0, 1);\n  });\n\n  it('should prevent drastic measure after pause is over', async function() {\n    let Pausable = await PausableMock.new();\n    await Pausable.pause();\n    await Pausable.unpause();\n    try {\n      await Pausable.drasticMeasure();\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n\n    const drasticMeasureTaken = await Pausable.drasticMeasureTaken();\n    assert.isFalse(drasticMeasureTaken);\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/PausableToken.js",
    "content": "'user strict';\n\nconst assertRevert = require('./helpers/assertRevert');\nvar PausableTokenMock = artifacts.require('./helpers/PausableTokenMock.sol');\n\ncontract('PausableToken', function(accounts) {\n  let token;\n\n  beforeEach(async function() {\n    token = await PausableTokenMock.new(accounts[0], 100);\n  });\n\n  it('should return paused false after construction', async function() {\n    let paused = await token.paused();\n\n    assert.equal(paused, false);\n  });\n\n  it('should return paused true after pause', async function() {\n    await token.pause();\n    let paused = await token.paused();\n\n    assert.equal(paused, true);\n  });\n\n  it('should return paused false after pause and unpause', async function() {\n    await token.pause();\n    await token.unpause();\n    let paused = await token.paused();\n\n    assert.equal(paused, false);\n  });\n\n  it('should be able to transfer if transfers are unpaused', async function() {\n    await token.transfer(accounts[1], 100);\n    let balance0 = await token.balanceOf(accounts[0]);\n    assert.equal(balance0, 0);\n\n    let balance1 = await token.balanceOf(accounts[1]);\n    assert.equal(balance1, 100);\n  });\n\n  it('should be able to transfer after transfers are paused and unpaused', async function() {\n    await token.pause();\n    await token.unpause();\n    await token.transfer(accounts[1], 100);\n    let balance0 = await token.balanceOf(accounts[0]);\n    assert.equal(balance0, 0);\n\n    let balance1 = await token.balanceOf(accounts[1]);\n    assert.equal(balance1, 100);\n  });\n\n  it('should throw an error trying to transfer while transactions are paused', async function() {\n    await token.pause();\n    try {\n      await token.transfer(accounts[1], 100);\n      assert.fail('should have thrown before');\n    } catch (error) {\n      assertRevert(error);\n    }\n  });\n\n  it('should throw an error trying to transfer from another account while transactions are paused', async function() {\n    await token.pause();\n    try {\n      await token.transferFrom(accounts[0], accounts[1], 100);\n      assert.fail('should have thrown before');\n    } catch (error) {\n      assertRevert(error);\n    }\n  });\n})\n"
  },
  {
    "path": "truffle/oz/test/PullPayment.js",
    "content": "var PullPaymentMock = artifacts.require(\"./helpers/PullPaymentMock.sol\");\n\ncontract('PullPayment', function(accounts) {\n  let ppce;\n  let amount = 17*1e18;\n\n  beforeEach(async function() {\n    ppce = await PullPaymentMock.new({value: amount});\n  });\n\n  it(\"can't call asyncSend externally\", async function() {\n    assert.isUndefined(ppce.asyncSend);\n  });\n\n  it(\"can record an async payment correctly\", async function() {\n    let AMOUNT = 100;\n    let callSend = await ppce.callSend(accounts[0], AMOUNT);\n    let paymentsToAccount0 = await ppce.payments(accounts[0]);\n    let totalPayments = await ppce.totalPayments();\n\n    assert.equal(totalPayments, AMOUNT);\n    assert.equal(paymentsToAccount0, AMOUNT);\n  });\n\n  it(\"can add multiple balances on one account\", async function() {\n    let call1 = await ppce.callSend(accounts[0], 200);\n    let call2 = await ppce.callSend(accounts[0], 300);\n    let paymentsToAccount0 = await ppce.payments(accounts[0]);\n    let totalPayments = await ppce.totalPayments();\n\n    assert.equal(totalPayments, 500);\n    assert.equal(paymentsToAccount0, 500);\n  });\n\n  it(\"can add balances on multiple accounts\", async function() {\n    let call1 = await ppce.callSend(accounts[0], 200);\n    let call2 = await ppce.callSend(accounts[1], 300);\n\n    let paymentsToAccount0 = await ppce.payments(accounts[0]);\n    assert.equal(paymentsToAccount0, 200);\n\n    let paymentsToAccount1 = await ppce.payments(accounts[1]);\n    assert.equal(paymentsToAccount1, 300);\n\n    let totalPayments = await ppce.totalPayments();\n    assert.equal(totalPayments, 500);\n  });\n\n  it(\"can withdraw payment\", async function() {\n    let payee = accounts[1];\n    let initialBalance = web3.eth.getBalance(payee);\n\n    let call1 = await ppce.callSend(payee, amount);\n\n    let payment1 = await ppce.payments(payee);\n    assert.equal(payment1, amount);\n\n    let totalPayments = await ppce.totalPayments();\n    assert.equal(totalPayments, amount);\n\n    let withdraw = await ppce.withdrawPayments({from: payee});\n    let payment2 = await ppce.payments(payee);\n    assert.equal(payment2, 0);\n\n    totalPayments = await ppce.totalPayments();\n    assert.equal(totalPayments, 0);\n\n    let balance = web3.eth.getBalance(payee);\n    assert(Math.abs(balance-initialBalance-amount) < 1e16);\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/ReentrancyGuard.js",
    "content": "'use strict';\nimport expectThrow from './helpers/expectThrow';\nconst ReentrancyMock = artifacts.require('./helper/ReentrancyMock.sol');\nconst ReentrancyAttack = artifacts.require('./helper/ReentrancyAttack.sol');\n\ncontract('ReentrancyGuard', function(accounts) {\n  let reentrancyMock;\n\n  beforeEach(async function() {\n    reentrancyMock = await ReentrancyMock.new();\n    let initialCounter = await reentrancyMock.counter();\n    assert.equal(initialCounter, 0);\n  });\n\n  it('should not allow remote callback', async function() {\n    let attacker = await ReentrancyAttack.new();\n    await expectThrow(reentrancyMock.countAndCall(attacker.address));\n  });\n\n  // The following are more side-effects that intended behaviour:\n  // I put them here as documentation, and to monitor any changes\n  // in the side-effects.\n\n  it('should not allow local recursion', async function() {\n    await expectThrow(reentrancyMock.countLocalRecursive(10));\n  });\n\n  it('should not allow indirect local recursion', async function() {\n    await expectThrow(reentrancyMock.countThisRecursive(10));\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/RefundVault.js",
    "content": "const BigNumber = web3.BigNumber\n\nrequire('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should()\n\nimport ether from './helpers/ether'\nimport EVMRevert from './helpers/EVMRevert'\n\nconst RefundVault = artifacts.require('RefundVault')\n\ncontract('RefundVault', function ([_, owner, wallet, investor]) {\n\n  const value = ether(42)\n\n  beforeEach(async function () {\n    this.vault = await RefundVault.new(wallet, {from: owner})\n  })\n\n  it('should accept contributions', async function () {\n    await this.vault.deposit(investor, {value, from: owner}).should.be.fulfilled\n  })\n\n  it('should not refund contribution during active state', async function () {\n    await this.vault.deposit(investor, {value, from: owner})\n    await this.vault.refund(investor).should.be.rejectedWith(EVMRevert)\n  })\n\n  it('only owner can enter refund mode', async function () {\n    await this.vault.enableRefunds({from: _}).should.be.rejectedWith(EVMRevert)\n    await this.vault.enableRefunds({from: owner}).should.be.fulfilled\n  })\n\n  it('should refund contribution after entering refund mode', async function () {\n    await this.vault.deposit(investor, {value, from: owner})\n    await this.vault.enableRefunds({from: owner})\n\n    const pre = web3.eth.getBalance(investor)\n    await this.vault.refund(investor)\n    const post = web3.eth.getBalance(investor)\n\n    post.minus(pre).should.be.bignumber.equal(value)\n  })\n\n  it('only owner can close', async function () {\n    await this.vault.close({from: _}).should.be.rejectedWith(EVMRevert)\n    await this.vault.close({from: owner}).should.be.fulfilled\n  })\n\n  it('should forward funds to wallet after closing', async function () {\n    await this.vault.deposit(investor, {value, from: owner})\n\n    const pre = web3.eth.getBalance(wallet)\n    await this.vault.close({from: owner})\n    const post = web3.eth.getBalance(wallet)\n\n    post.minus(pre).should.be.bignumber.equal(value)\n  })\n\n})\n"
  },
  {
    "path": "truffle/oz/test/RefundableCrowdsale.js",
    "content": "import ether from './helpers/ether'\nimport {advanceBlock} from './helpers/advanceToBlock'\nimport {increaseTimeTo, duration} from './helpers/increaseTime'\nimport latestTime from './helpers/latestTime'\nimport EVMRevert from './helpers/EVMRevert'\n\nconst BigNumber = web3.BigNumber\n\nrequire('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should()\n\nconst RefundableCrowdsale = artifacts.require('./helpers/RefundableCrowdsaleImpl.sol')\n\ncontract('RefundableCrowdsale', function ([_, owner, wallet, investor]) {\n\n  const rate = new BigNumber(1000)\n  const goal = ether(800)\n  const lessThanGoal = ether(750)\n\n  before(async function() {\n    //Advance to the next block to correctly read time in the solidity \"now\" function interpreted by testrpc\n    await advanceBlock()\n  })\n\n  beforeEach(async function () {\n    this.startTime = latestTime() + duration.weeks(1)\n    this.endTime =   this.startTime + duration.weeks(1)\n    this.afterEndTime = this.endTime + duration.seconds(1)\n\n    this.crowdsale = await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, goal, {from: owner})\n  })\n\n  describe('creating a valid crowdsale', function () {\n\n    it('should fail with zero goal', async function () {\n      await RefundableCrowdsale.new(this.startTime, this.endTime, rate, wallet, 0, {from: owner}).should.be.rejectedWith(EVMRevert);\n    })\n\n  });\n\n  it('should deny refunds before end', async function () {\n    await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMRevert)\n    await increaseTimeTo(this.startTime)\n    await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMRevert)\n  })\n\n  it('should deny refunds after end if goal was reached', async function () {\n    await increaseTimeTo(this.startTime)\n    await this.crowdsale.sendTransaction({value: goal, from: investor})\n    await increaseTimeTo(this.afterEndTime)\n    await this.crowdsale.claimRefund({from: investor}).should.be.rejectedWith(EVMRevert)\n  })\n\n  it('should allow refunds after end if goal was not reached', async function () {\n    await increaseTimeTo(this.startTime)\n    await this.crowdsale.sendTransaction({value: lessThanGoal, from: investor})\n    await increaseTimeTo(this.afterEndTime)\n\n    await this.crowdsale.finalize({from: owner})\n\n    const pre = web3.eth.getBalance(investor)\n    await this.crowdsale.claimRefund({from: investor, gasPrice: 0})\n\t\t\t.should.be.fulfilled\n    const post = web3.eth.getBalance(investor)\n\n    post.minus(pre).should.be.bignumber.equal(lessThanGoal)\n  })\n\n  it('should forward funds to wallet after end if goal was reached', async function () {\n    await increaseTimeTo(this.startTime)\n    await this.crowdsale.sendTransaction({value: goal, from: investor})\n    await increaseTimeTo(this.afterEndTime)\n\n    const pre = web3.eth.getBalance(wallet)\n    await this.crowdsale.finalize({from: owner})\n    const post = web3.eth.getBalance(wallet)\n\n    post.minus(pre).should.be.bignumber.equal(goal)\n  })\n\n})\n"
  },
  {
    "path": "truffle/oz/test/SafeERC20.js",
    "content": "import EVMThrow from './helpers/EVMThrow';\n\nrequire('chai')\n  .use(require('chai-as-promised'))\n  .should();\n\nconst SafeERC20Helper = artifacts.require('./helpers/SafeERC20Helper.sol');\n\ncontract('SafeERC20', function () {\n\n  beforeEach(async function () {\n    this.helper = await SafeERC20Helper.new();\n  });\n\n  it('should throw on failed transfer', async function () {\n    await this.helper.doFailingTransfer().should.be.rejectedWith(EVMThrow);\n  });\n\n  it('should throw on failed transferFrom', async function () {\n    await this.helper.doFailingTransferFrom().should.be.rejectedWith(EVMThrow);\n  });\n\n  it('should throw on failed approve', async function () {\n    await this.helper.doFailingApprove().should.be.rejectedWith(EVMThrow);\n  });\n\n  it('should not throw on succeeding transfer', async function () {\n    await this.helper.doSucceedingTransfer().should.be.fulfilled;\n  });\n\n  it('should not throw on succeeding transferFrom', async function () {\n    await this.helper.doSucceedingTransferFrom().should.be.fulfilled;\n  });\n\n  it('should not throw on succeeding approve', async function () {\n    await this.helper.doSucceedingApprove().should.be.fulfilled;\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/SafeMath.js",
    "content": "const assertRevert = require('./helpers/assertRevert');\nconst assertJump = require('./helpers/assertJump');\nvar SafeMathMock = artifacts.require(\"./helpers/SafeMathMock.sol\");\n\ncontract('SafeMath', function(accounts) {\n\n  let safeMath;\n\n  before(async function() {\n    safeMath = await SafeMathMock.new();\n  });\n\n  it(\"multiplies correctly\", async function() {\n    let a = 5678;\n    let b = 1234;\n    let mult = await safeMath.multiply(a, b);\n    let result = await safeMath.result();\n    assert.equal(result, a*b);\n  });\n\n  it(\"adds correctly\", async function() {\n    let a = 5678;\n    let b = 1234;\n    let add = await safeMath.add(a, b);\n    let result = await safeMath.result();\n\n    assert.equal(result, a+b);\n  });\n\n  it(\"subtracts correctly\", async function() {\n    let a = 5678;\n    let b = 1234;\n    let subtract = await safeMath.subtract(a, b);\n    let result = await safeMath.result();\n\n    assert.equal(result, a-b);\n  });\n\n  it(\"should throw an error if subtraction result would be negative\", async function () {\n    let a = 1234;\n    let b = 5678;\n    try {\n      let subtract = await safeMath.subtract(a, b);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertJump(error);\n    }\n  });\n\n  it(\"should throw an error on addition overflow\", async function() {\n    let a = 115792089237316195423570985008687907853269984665640564039457584007913129639935;\n    let b = 1;\n    try {\n      let add = await safeMath.add(a, b);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n  it(\"should throw an error on multiplication overflow\", async function() {\n    let a = 115792089237316195423570985008687907853269984665640564039457584007913129639933;\n    let b = 2;\n    try {\n      let multiply = await safeMath.multiply(a, b);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/SampleCrowdsale.js",
    "content": "import ether from './helpers/ether'\nimport {advanceBlock} from './helpers/advanceToBlock'\nimport {increaseTimeTo, duration} from './helpers/increaseTime'\nimport latestTime from './helpers/latestTime'\nimport EVMRevert from './helpers/EVMRevert'\n\nconst BigNumber = web3.BigNumber;\n\nconst should = require('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should();\n\nconst SampleCrowdsale = artifacts.require('SampleCrowdsale');\nconst SampleCrowdsaleToken = artifacts.require('SampleCrowdsaleToken');\n\ncontract('Crowdsale', function ([owner, wallet, investor]) {\n\n  const RATE = new BigNumber(10);\n  const GOAL = ether(10);\n  const CAP  = ether(20);\n\n  before(async function() {\n    //Advance to the next block to correctly read time in the solidity \"now\" function interpreted by testrpc\n    await advanceBlock()\n  })\n\n  beforeEach(async function () {\n    this.startTime = latestTime() + duration.weeks(1);\n    this.endTime =   this.startTime + duration.weeks(1);\n    this.afterEndTime = this.endTime + duration.seconds(1);\n\n    this.crowdsale = await SampleCrowdsale.new(this.startTime, this.endTime, RATE, GOAL, CAP, wallet);\n    this.token = SampleCrowdsaleToken.at(await this.crowdsale.token());\n  });\n\n\n  it('should create crowdsale with correct parameters', async function () {\n    this.crowdsale.should.exist;\n    this.token.should.exist;\n\n    (await this.crowdsale.startTime()).should.be.bignumber.equal(this.startTime);\n    (await this.crowdsale.endTime()).should.be.bignumber.equal(this.endTime);\n    (await this.crowdsale.rate()).should.be.bignumber.equal(RATE);\n    (await this.crowdsale.wallet()).should.be.equal(wallet);\n    (await this.crowdsale.goal()).should.be.bignumber.equal(GOAL);\n    (await this.crowdsale.cap()).should.be.bignumber.equal(CAP);\n  });\n\n  it('should not accept payments before start', async function () {\n    await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMRevert);\n    await this.crowdsale.buyTokens(investor, {from: investor, value: ether(1)}).should.be.rejectedWith(EVMRevert);\n  });\n\n  it('should accept payments during the sale', async function () {\n    const investmentAmount = ether(1);\n    const expectedTokenAmount = RATE.mul(investmentAmount);\n\n    await increaseTimeTo(this.startTime);\n    await this.crowdsale.buyTokens(investor, {value: investmentAmount, from: investor}).should.be.fulfilled;\n\n    (await this.token.balanceOf(investor)).should.be.bignumber.equal(expectedTokenAmount);\n    (await this.token.totalSupply()).should.be.bignumber.equal(expectedTokenAmount);\n  });\n\n  it('should reject payments after end', async function () {\n    await increaseTimeTo(this.afterEnd);\n    await this.crowdsale.send(ether(1)).should.be.rejectedWith(EVMRevert);\n    await this.crowdsale.buyTokens(investor, {value: ether(1), from: investor}).should.be.rejectedWith(EVMRevert);\n  });\n\n  it('should reject payments over cap', async function () {\n    await increaseTimeTo(this.startTime);\n    await this.crowdsale.send(CAP);\n    await this.crowdsale.send(1).should.be.rejectedWith(EVMRevert);\n  });\n\n  it('should allow finalization and transfer funds to wallet if the goal is reached', async function () {\n    await increaseTimeTo(this.startTime);\n    await this.crowdsale.send(GOAL);\n\n    const beforeFinalization = web3.eth.getBalance(wallet);\n    await increaseTimeTo(this.afterEndTime);\n    await this.crowdsale.finalize({from: owner});\n    const afterFinalization = web3.eth.getBalance(wallet);\n\n    afterFinalization.minus(beforeFinalization).should.be.bignumber.equal(GOAL);\n  });\n\n  it('should allow refunds if the goal is not reached', async function () {\n    const balanceBeforeInvestment = web3.eth.getBalance(investor);\n\n    await increaseTimeTo(this.startTime);\n    await this.crowdsale.sendTransaction({value: ether(1), from: investor, gasPrice: 0});\n    await increaseTimeTo(this.afterEndTime);\n\n    await this.crowdsale.finalize({from: owner});\n    await this.crowdsale.claimRefund({from: investor, gasPrice: 0}).should.be.fulfilled;\n\n    const balanceAfterRefund = web3.eth.getBalance(investor);\n    balanceBeforeInvestment.should.be.bignumber.equal(balanceAfterRefund);\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/SplitPayment.js",
    "content": "const BigNumber = web3.BigNumber\n\nconst should = require('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should()\n\nconst EVMThrow = require('./helpers/EVMThrow.js')\nconst SplitPaymentMock = artifacts.require('./helpers/SplitPaymentMock.sol')\n\ncontract('SplitPayment', function ([owner, payee1, payee2, payee3, nonpayee1, payer1]) {\n  const amount = web3.toWei(1.0, 'ether')\n\n  beforeEach(async function () {\n    this.payees = [payee1, payee2, payee3]\n    this.shares = [20, 10, 70]\n\n    this.contract = await SplitPaymentMock.new(this.payees, this.shares)\n  })\n\n  it('should accept payments', async function () {\n    await web3.eth.sendTransaction({ from: owner, to: this.contract.address, value: amount })\n\n    const balance = web3.eth.getBalance(this.contract.address)\n    balance.should.be.bignumber.equal(amount)\n  })\n\n  it('should store shares if address is payee', async function () {\n    const shares = await this.contract.shares.call(payee1)\n    shares.should.be.bignumber.not.equal(0)\n  })\n\n  it('should not store shares if address is not payee', async function () {\n    const shares = await this.contract.shares.call(nonpayee1)\n    shares.should.be.bignumber.equal(0)\n  })\n\n  it('should throw if no funds to claim', async function () {\n    await this.contract.claim({from: payee1}).should.be.rejectedWith(EVMThrow)\n  })\n\n  it('should throw if non-payee want to claim', async function () {\n    await web3.eth.sendTransaction({from: payer1, to: this.contract.address, value: amount})\n    await this.contract.claim({from: nonpayee1}).should.be.rejectedWith(EVMThrow)\n  })\n  \n  it('should distribute funds to payees', async function () {\n    await web3.eth.sendTransaction({from: payer1, to: this.contract.address, value: amount})\n\n    // receive funds\n    const initBalance = web3.eth.getBalance(this.contract.address)\n    initBalance.should.be.bignumber.equal(amount)\n\n    // distribute to payees\n    const initAmount1 = web3.eth.getBalance(payee1)\n    await this.contract.claim({from: payee1})\n    const profit1 = web3.eth.getBalance(payee1) - initAmount1\n    assert(Math.abs(profit1 - web3.toWei(0.20, 'ether')) < 1e16)\n\n    const initAmount2 = web3.eth.getBalance(payee2)\n    await this.contract.claim({from: payee2})\n    const profit2 = web3.eth.getBalance(payee2) - initAmount2\n    assert(Math.abs(profit2 - web3.toWei(0.10, 'ether')) < 1e16)\n\n    const initAmount3 = web3.eth.getBalance(payee3)\n    await this.contract.claim({from: payee3})\n    const profit3 = web3.eth.getBalance(payee3) - initAmount3\n    assert(Math.abs(profit3 - web3.toWei(0.70, 'ether')) < 1e16)\n\n    // end balance should be zero\n    const endBalance = web3.eth.getBalance(this.contract.address)\n    endBalance.should.be.bignumber.equal(0)\n\n    // check correct funds released accounting\n    const totalReleased = await this.contract.totalReleased.call()\n    totalReleased.should.be.bignumber.equal(initBalance)\n  })\n})\n"
  },
  {
    "path": "truffle/oz/test/StandardToken.js",
    "content": "'use strict';\n\nconst assertRevert = require('./helpers/assertRevert');\nconst expectThrow = require('./helpers/expectThrow');\nvar StandardTokenMock = artifacts.require('./helpers/StandardTokenMock.sol');\n\ncontract('StandardToken', function(accounts) {\n\n  let token;\n\n  beforeEach(async function() {\n    token = await StandardTokenMock.new(accounts[0], 100);\n  });\n\n  it('should return the correct totalSupply after construction', async function() {\n    let totalSupply = await token.totalSupply();\n\n    assert.equal(totalSupply, 100);\n  });\n\n  it('should return the correct allowance amount after approval', async function() {\n    let token = await StandardTokenMock.new();\n    await token.approve(accounts[1], 100);\n    let allowance = await token.allowance(accounts[0], accounts[1]);\n\n    assert.equal(allowance, 100);\n  });\n\n  it('should return correct balances after transfer', async function() {\n    let token = await StandardTokenMock.new(accounts[0], 100);\n    await token.transfer(accounts[1], 100);\n    let balance0 = await token.balanceOf(accounts[0]);\n    assert.equal(balance0, 0);\n\n    let balance1 = await token.balanceOf(accounts[1]);\n    assert.equal(balance1, 100);\n  });\n\n  it('should throw an error when trying to transfer more than balance', async function() {\n    let token = await StandardTokenMock.new(accounts[0], 100);\n    try {\n      await token.transfer(accounts[1], 101);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n  it('should return correct balances after transfering from another account', async function() {\n    let token = await StandardTokenMock.new(accounts[0], 100);\n    await token.approve(accounts[1], 100);\n    await token.transferFrom(accounts[0], accounts[2], 100, {from: accounts[1]});\n\n    let balance0 = await token.balanceOf(accounts[0]);\n    assert.equal(balance0, 0);\n\n    let balance1 = await token.balanceOf(accounts[2]);\n    assert.equal(balance1, 100);\n\n    let balance2 = await token.balanceOf(accounts[1]);\n    assert.equal(balance2, 0);\n  });\n\n  it('should throw an error when trying to transfer more than allowed', async function() {\n    await token.approve(accounts[1], 99);\n    try {\n      await token.transferFrom(accounts[0], accounts[2], 100, {from: accounts[1]});\n      assert.fail('should have thrown before');\n    } catch (error) {\n      assertRevert(error);\n    }\n  });\n\n  it('should throw an error when trying to transferFrom more than _from has', async function() {\n    let balance0 = await token.balanceOf(accounts[0]);\n    await token.approve(accounts[1], 99);\n    try {\n      await token.transferFrom(accounts[0], accounts[2], balance0+1, {from: accounts[1]});\n      assert.fail('should have thrown before');\n    } catch (error) {\n      assertRevert(error);\n    }\n  });\n\n  describe('validating allowance updates to spender', function() {\n    let preApproved;\n\n    it('should start with zero', async function() {\n      preApproved = await token.allowance(accounts[0], accounts[1]);\n      assert.equal(preApproved, 0);\n    })\n\n    it('should increase by 50 then decrease by 10', async function() {\n      await token.increaseApproval(accounts[1], 50);\n      let postIncrease = await token.allowance(accounts[0], accounts[1]);\n      preApproved.plus(50).should.be.bignumber.equal(postIncrease);\n      await token.decreaseApproval(accounts[1], 10);\n      let postDecrease = await token.allowance(accounts[0], accounts[1]);\n      postIncrease.minus(10).should.be.bignumber.equal(postDecrease);\n    })\n  });\n\n  it('should increase by 50 then set to 0 when decreasing by more than 50', async function() {\n    await token.approve(accounts[1], 50);\n    await token.decreaseApproval(accounts[1], 60);\n    let postDecrease = await token.allowance(accounts[0], accounts[1]);\n    postDecrease.should.be.bignumber.equal(0);\n});\n\n  it('should throw an error when trying to transfer to 0x0', async function() {\n    let token = await StandardTokenMock.new(accounts[0], 100);\n    try {\n      let transfer = await token.transfer(0x0, 100);\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n  it('should throw an error when trying to transferFrom to 0x0', async function() {\n    let token = await StandardTokenMock.new(accounts[0], 100);\n    await token.approve(accounts[1], 100);\n    try {\n      let transfer = await token.transferFrom(accounts[0], 0x0, 100, {from: accounts[1]});\n      assert.fail('should have thrown before');\n    } catch(error) {\n      assertRevert(error);\n    }\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/TestMetacoin.sol",
    "content": "pragma solidity ^0.4.2;\n\nimport \"truffle/Assert.sol\";\nimport \"truffle/DeployedAddresses.sol\";\nimport \"../contracts/MetaCoin.sol\";\n\ncontract TestMetacoin {\n\n  function testInitialBalanceUsingDeployedContract() {\n    MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());\n\n    uint expected = 10000;\n\n    Assert.equal(meta.getBalance(tx.origin), expected, \"Owner should have 10000 MetaCoin initially\");\n  }\n\n  function testInitialBalanceWithNewMetaCoin() {\n    MetaCoin meta = new MetaCoin();\n\n    uint expected = 10000;\n\n    Assert.equal(meta.getBalance(tx.origin), expected, \"Owner should have 10000 MetaCoin initially\");\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/TokenDestructible.js",
    "content": "'use strict';\n\nvar TokenDestructible = artifacts.require('../contracts/lifecycle/TokenDestructible.sol');\nvar StandardTokenMock = artifacts.require(\"./helpers/StandardTokenMock.sol\");\nrequire('./helpers/transactionMined.js');\n\ncontract('TokenDestructible', function(accounts) {\n  let destructible;\n\n  beforeEach(async function() {\n    destructible = await TokenDestructible.new({fron: accounts[0], value: web3.toWei('10', 'ether')});\n  });\n\n  it('should send balance to owner after destruction', async function() {\n    let owner = await destructible.owner();\n    let initBalance = web3.eth.getBalance(owner);\n    await destructible.destroy([], {from: owner});\n    let newBalance = web3.eth.getBalance(owner);\n    assert.isTrue(newBalance > initBalance);\n  });\n\n  it('should send tokens to owner after destruction', async function() {\n    let owner = await destructible.owner();\n    let token = await StandardTokenMock.new(destructible.address, 100);\n    let initContractBalance = await token.balanceOf(destructible.address);\n    let initOwnerBalance = await token.balanceOf(owner);\n    assert.equal(initContractBalance, 100);\n    assert.equal(initOwnerBalance, 0);\n    await destructible.destroy([token.address], {from: owner});\n    let newContractBalance = await token.balanceOf(destructible.address);\n    let newOwnerBalance = await token.balanceOf(owner);\n    assert.equal(newContractBalance, 0);\n    assert.equal(newOwnerBalance, 100);\n  });\n});\n"
  },
  {
    "path": "truffle/oz/test/TokenTimelock.js",
    "content": "const BigNumber = web3.BigNumber\n\nrequire('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should()\n\n\nimport latestTime from './helpers/latestTime'\nimport {increaseTimeTo, duration} from './helpers/increaseTime'\n\nconst MintableToken = artifacts.require('MintableToken')\nconst TokenTimelock = artifacts.require('TokenTimelock')\n\ncontract('TokenTimelock', function ([_, owner, beneficiary]) {\n\n  const amount = new BigNumber(100)\n\n  beforeEach(async function () {\n    this.token = await MintableToken.new({from: owner})\n    this.releaseTime = latestTime() + duration.years(1)\n    this.timelock = await TokenTimelock.new(this.token.address, beneficiary, this.releaseTime)\n    await this.token.mint(this.timelock.address, amount, {from: owner})\n  })\n\n  it('cannot be released before time limit', async function () {\n    await this.timelock.release().should.be.rejected\n  })\n\n  it('cannot be released just before time limit', async function () {\n    await increaseTimeTo(this.releaseTime - duration.seconds(3))\n    await this.timelock.release().should.be.rejected\n  })\n\n  it('can be released just after limit', async function () {\n    await increaseTimeTo(this.releaseTime + duration.seconds(1))\n    await this.timelock.release().should.be.fulfilled\n    const balance = await this.token.balanceOf(beneficiary)\n    balance.should.be.bignumber.equal(amount)\n  })\n\n  it('can be released after time limit', async function () {\n    await increaseTimeTo(this.releaseTime + duration.years(1))\n    await this.timelock.release().should.be.fulfilled\n    const balance = await this.token.balanceOf(beneficiary)\n    balance.should.be.bignumber.equal(amount)\n  })\n\n  it('cannot be released twice', async function () {\n    await increaseTimeTo(this.releaseTime + duration.years(1))\n    await this.timelock.release().should.be.fulfilled\n    await this.timelock.release().should.be.rejected\n    const balance = await this.token.balanceOf(beneficiary)\n    balance.should.be.bignumber.equal(amount)\n  })\n\n})\n"
  },
  {
    "path": "truffle/oz/test/TokenVesting.js",
    "content": "const BigNumber = web3.BigNumber\n\nrequire('chai')\n  .use(require('chai-as-promised'))\n  .use(require('chai-bignumber')(BigNumber))\n  .should();\n\nimport EVMRevert from './helpers/EVMRevert'\nimport latestTime from './helpers/latestTime';\nimport {increaseTimeTo, duration} from './helpers/increaseTime';\n\nconst MintableToken = artifacts.require('MintableToken');\nconst TokenVesting = artifacts.require('TokenVesting');\n\ncontract('TokenVesting', function ([_, owner, beneficiary]) {\n\n  const amount = new BigNumber(1000);\n\n  beforeEach(async function () {\n    this.token = await MintableToken.new({ from: owner });\n\n    this.start = latestTime() + duration.minutes(1); // +1 minute so it starts after contract instantiation\n    this.cliff = duration.years(1);\n    this.duration = duration.years(2);\n\n    this.vesting = await TokenVesting.new(beneficiary, this.start, this.cliff, this.duration, true, { from: owner });\n\n    await this.token.mint(this.vesting.address, amount, { from: owner });\n  });\n\n  it('cannot be released before cliff', async function () {\n    await this.vesting.release(this.token.address).should.be.rejectedWith(EVMRevert);\n  });\n\n  it('can be released after cliff', async function () {\n    await increaseTimeTo(this.start + this.cliff + duration.weeks(1));\n    await this.vesting.release(this.token.address).should.be.fulfilled;\n  });\n\n  it('should release proper amount after cliff', async function () {\n    await increaseTimeTo(this.start + this.cliff);\n\n    const { receipt } = await this.vesting.release(this.token.address);\n    const releaseTime = web3.eth.getBlock(receipt.blockNumber).timestamp;\n\n    const balance = await this.token.balanceOf(beneficiary);\n    balance.should.bignumber.equal(amount.mul(releaseTime - this.start).div(this.duration).floor());\n  });\n\n  it('should linearly release tokens during vesting period', async function () {\n    const vestingPeriod = this.duration - this.cliff;\n    const checkpoints = 4;\n\n    for (let i = 1; i <= checkpoints; i++) {\n      const now = this.start + this.cliff + i * (vestingPeriod / checkpoints);\n      await increaseTimeTo(now);\n\n      await this.vesting.release(this.token.address);\n      const balance = await this.token.balanceOf(beneficiary);\n      const expectedVesting = amount.mul(now - this.start).div(this.duration).floor();\n\n      balance.should.bignumber.equal(expectedVesting);\n    }\n  });\n\n  it('should have released all after end', async function () {\n    await increaseTimeTo(this.start + this.duration);\n    await this.vesting.release(this.token.address);\n    const balance = await this.token.balanceOf(beneficiary);\n    balance.should.bignumber.equal(amount);\n  });\n\n  it('should be revoked by owner if revocable is set', async function () {\n    await this.vesting.revoke(this.token.address, { from: owner }).should.be.fulfilled;\n  });\n\n  it('should fail to be revoked by owner if revocable not set', async function () {\n    const vesting = await TokenVesting.new(beneficiary, this.start, this.cliff, this.duration, false, { from: owner } );\n    await vesting.revoke(this.token.address, { from: owner }).should.be.rejectedWith(EVMRevert);\n  });\n\n  it('should return the non-vested tokens when revoked by owner', async function () {\n    await increaseTimeTo(this.start + this.cliff + duration.weeks(12));\n\n    const vested = await this.vesting.vestedAmount(this.token.address);\n\n    await this.vesting.revoke(this.token.address, { from: owner });\n\n    const ownerBalance = await this.token.balanceOf(owner);\n    ownerBalance.should.bignumber.equal(amount.sub(vested));\n  });\n\n  it('should keep the vested tokens when revoked by owner', async function () {\n    await increaseTimeTo(this.start + this.cliff + duration.weeks(12));\n\n    const vestedPre = await this.vesting.vestedAmount(this.token.address);\n\n    await this.vesting.revoke(this.token.address, { from: owner });\n\n    const vestedPost = await this.vesting.vestedAmount(this.token.address);\n\n    vestedPre.should.bignumber.equal(vestedPost);\n  });\n\n  it('should fail to be revoked a second time', async function () {\n    await increaseTimeTo(this.start + this.cliff + duration.weeks(12));\n\n    const vested = await this.vesting.vestedAmount(this.token.address);\n\n    await this.vesting.revoke(this.token.address, { from: owner });\n\n    await this.vesting.revoke(this.token.address, { from: owner }).should.be.rejectedWith(EVMRevert);\n  });\n\n});\n"
  },
  {
    "path": "truffle/oz/test/helpers/BasicTokenMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/token/BasicToken.sol';\n\n\n// mock class using BasicToken\ncontract BasicTokenMock is BasicToken {\n\n  function BasicTokenMock(address initialAccount, uint256 initialBalance) public {\n    balances[initialAccount] = initialBalance;\n    totalSupply = initialBalance;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/BurnableTokenMock.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/token/BurnableToken.sol';\n\ncontract BurnableTokenMock is BurnableToken {\n\n  function BurnableTokenMock(address initialAccount, uint initialBalance) public {\n    balances[initialAccount] = initialBalance;\n    totalSupply = initialBalance;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/CappedCrowdsaleImpl.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/crowdsale/CappedCrowdsale.sol';\n\n\ncontract CappedCrowdsaleImpl is CappedCrowdsale {\n\n  function CappedCrowdsaleImpl (\n    uint256 _startTime,\n    uint256 _endTime,\n    uint256 _rate,\n    address _wallet,\n    uint256 _cap\n  ) public\n    Crowdsale(_startTime, _endTime, _rate, _wallet)\n    CappedCrowdsale(_cap)\n  {\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/DayLimitMock.sol",
    "content": "pragma solidity ^0.4.18;\nimport \"../../contracts/DayLimit.sol\";\n\ncontract DayLimitMock is DayLimit {\n  uint256 public totalSpending;\n\n  function DayLimitMock(uint256 _value) public DayLimit(_value) {\n    totalSpending = 0;\n  }\n\n  function attemptSpend(uint256 _value) external limitedDaily(_value) {\n    totalSpending += _value;\n  }\n\n  function setDailyLimit(uint256 _newLimit) external {\n    _setDailyLimit(_newLimit);\n  }\n\n  function resetSpentToday() external {\n    _resetSpentToday();\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/DetailedERC20Mock.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/token/StandardToken.sol';\nimport '../../contracts/token/DetailedERC20.sol';\n\ncontract DetailedERC20Mock is StandardToken, DetailedERC20 {\n  function DetailedERC20Mock(string _name, string _symbol, uint8 _decimals) DetailedERC20(_name, _symbol, _decimals) public {}\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/ERC23TokenMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/token/BasicToken.sol';\n\n\ncontract ERC23ContractInterface {\n  function tokenFallback(address _from, uint256 _value, bytes _data) external;\n}\n\ncontract ERC23TokenMock is BasicToken {\n\n  function ERC23TokenMock(address initialAccount, uint256 initialBalance) public {\n    balances[initialAccount] = initialBalance;\n    totalSupply = initialBalance;\n  }\n\n  // ERC23 compatible transfer function (except the name)\n  function transferERC23(address _to, uint256 _value, bytes _data) public\n    returns (bool success)\n  {\n    transfer(_to, _value);\n    bool is_contract = false;\n    assembly {\n      is_contract := not(iszero(extcodesize(_to)))\n    }\n    if(is_contract) {\n      ERC23ContractInterface receiver = ERC23ContractInterface(_to);\n      receiver.tokenFallback(msg.sender, _value, _data);\n    }\n    return true;\n  }\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/EVMRevert.js",
    "content": "export default 'revert'\n"
  },
  {
    "path": "truffle/oz/test/helpers/EVMThrow.js",
    "content": "export default 'invalid opcode'\n"
  },
  {
    "path": "truffle/oz/test/helpers/FinalizableCrowdsaleImpl.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/crowdsale/FinalizableCrowdsale.sol';\n\n\ncontract FinalizableCrowdsaleImpl is FinalizableCrowdsale {\n\n  function FinalizableCrowdsaleImpl (\n    uint256 _startTime,\n    uint256 _endTime,\n    uint256 _rate,\n    address _wallet\n  ) public\n    Crowdsale(_startTime, _endTime, _rate, _wallet)\n    FinalizableCrowdsale()\n  {\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/ForceEther.sol",
    "content": "pragma solidity ^0.4.18;\n\n// @title Force Ether into a contract.\n// @notice  even\n// if the contract is not payable.\n// @notice To use, construct the contract with the target as argument.\n// @author Remco Bloemen <remco@neufund.org>\ncontract ForceEther  {\n\n  function ForceEther() public payable { }\n\n  function destroyAndSend(address _recipient) public {\n    selfdestruct(_recipient);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/HasNoEtherTest.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport \"../../contracts/ownership/HasNoEther.sol\";\n\ncontract HasNoEtherTest is HasNoEther {\n\n  // Constructor with explicit payable — should still fail\n  function HasNoEtherTest() public payable {\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/InsecureTargetBounty.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport {Bounty, Target} from \"../../contracts/Bounty.sol\";\n\n\ncontract InsecureTargetMock is Target {\n  function checkInvariant() public returns(bool){\n    return false;\n  }\n}\n\ncontract InsecureTargetBounty is Bounty {\n  function deployContract() internal returns (address) {\n    return new InsecureTargetMock();\n  }\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/LimitBalanceMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/LimitBalance.sol';\n\n\n// mock class using LimitBalance\ncontract LimitBalanceMock is LimitBalance(1000) {\n\n  function limitedDeposit() public payable limitedPayable {\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/PausableMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/lifecycle/Pausable.sol';\n\n\n// mock class using Pausable\ncontract PausableMock is Pausable {\n  bool public drasticMeasureTaken;\n  uint256 public count;\n\n  function PausableMock() public {\n    drasticMeasureTaken = false;\n    count = 0;\n  }\n\n  function normalProcess() external whenNotPaused {\n    count++;\n  }\n\n  function drasticMeasure() external whenPaused {\n    drasticMeasureTaken = true;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/PausableTokenMock.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/token/PausableToken.sol';\n\n// mock class using PausableToken\ncontract PausableTokenMock is PausableToken {\n\n  function PausableTokenMock(address initialAccount, uint initialBalance) public {\n    balances[initialAccount] = initialBalance;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/PullPaymentMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/payment/PullPayment.sol';\n\n\n// mock class using PullPayment\ncontract PullPaymentMock is PullPayment {\n\n  function PullPaymentMock() public payable { }\n\n  // test helper function to call asyncSend\n  function callSend(address dest, uint256 amount) public {\n    asyncSend(dest, amount);\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/ReentrancyAttack.sol",
    "content": "pragma solidity ^0.4.18;\n\ncontract ReentrancyAttack {\n\n  function callSender(bytes4 data) public {\n    require(msg.sender.call(data));\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/ReentrancyMock.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/ReentrancyGuard.sol';\nimport './ReentrancyAttack.sol';\n\ncontract ReentrancyMock is ReentrancyGuard {\n\n  uint256 public counter;\n\n  function ReentrancyMock() public {\n    counter = 0;\n  }\n\n  function count() private {\n    counter += 1;\n  }\n\n  function countLocalRecursive(uint256 n) public nonReentrant {\n    if(n > 0) {\n      count();\n      countLocalRecursive(n - 1);\n    }\n  }\n\n  function countThisRecursive(uint256 n) public nonReentrant {\n    bytes4 func = bytes4(keccak256(\"countThisRecursive(uint256)\"));\n    if(n > 0) {\n      count();\n      bool result = this.call(func, n - 1);\n      require(result == true);\n    }\n  }\n\n  function countAndCall(ReentrancyAttack attacker) public nonReentrant {\n    count();\n    bytes4 func = bytes4(keccak256(\"callback()\"));\n    attacker.callSender(func);\n  }\n\n  function callback() external nonReentrant {\n    count();\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/RefundableCrowdsaleImpl.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/crowdsale/RefundableCrowdsale.sol';\n\n\ncontract RefundableCrowdsaleImpl is RefundableCrowdsale {\n\n  function RefundableCrowdsaleImpl (\n    uint256 _startTime,\n    uint256 _endTime,\n    uint256 _rate,\n    address _wallet,\n    uint256 _goal\n  ) public\n    Crowdsale(_startTime, _endTime, _rate, _wallet)\n    RefundableCrowdsale(_goal)\n  {\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/SafeERC20Helper.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/token/ERC20.sol';\nimport '../../contracts/token/SafeERC20.sol';\n\ncontract ERC20FailingMock is ERC20 {\n  function transfer(address, uint256) public returns (bool) {\n    return false;\n  }\n\n  function transferFrom(address, address, uint256) public returns (bool) {\n    return false;\n  }\n\n  function approve(address, uint256) public returns (bool) {\n    return false;\n  }\n\n  function balanceOf(address) public constant returns (uint256) {\n    return 0;\n  }\n\n  function allowance(address, address) public constant returns (uint256) {\n    return 0;\n  }\n}\n\ncontract ERC20SucceedingMock is ERC20 {\n  function transfer(address, uint256) public returns (bool) {\n    return true;\n  }\n\n  function transferFrom(address, address, uint256) public returns (bool) {\n    return true;\n  }\n\n  function approve(address, uint256) public returns (bool) {\n    return true;\n  }\n\n  function balanceOf(address) public constant returns (uint256) {\n    return 0;\n  }\n\n  function allowance(address, address) public constant returns (uint256) {\n    return 0;\n  }\n}\n\ncontract SafeERC20Helper {\n  using SafeERC20 for ERC20;\n\n  ERC20 failing;\n  ERC20 succeeding;\n\n  function SafeERC20Helper() public {\n    failing = new ERC20FailingMock();\n    succeeding = new ERC20SucceedingMock();\n  }\n\n  function doFailingTransfer() public {\n    failing.safeTransfer(0, 0);\n  }\n\n  function doFailingTransferFrom() public {\n    failing.safeTransferFrom(0, 0, 0);\n  }\n\n  function doFailingApprove() public {\n    failing.safeApprove(0, 0);\n  }\n\n  function doSucceedingTransfer() public {\n    succeeding.safeTransfer(0, 0);\n  }\n\n  function doSucceedingTransferFrom() public {\n    succeeding.safeTransferFrom(0, 0, 0);\n  }\n\n  function doSucceedingApprove() public {\n    succeeding.safeApprove(0, 0);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/SafeMathMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/math/SafeMath.sol';\n\n\ncontract SafeMathMock {\n  uint256 public result;\n\n  function multiply(uint256 a, uint256 b) public {\n    result = SafeMath.mul(a, b);\n  }\n\n  function subtract(uint256 a, uint256 b) public {\n    result = SafeMath.sub(a, b);\n  }\n\n  function add(uint256 a, uint256 b) public {\n    result = SafeMath.add(a, b);\n  }\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/SecureTargetBounty.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport {Bounty, Target} from \"../../contracts/Bounty.sol\";\n\n\ncontract SecureTargetMock is Target {\n  function checkInvariant() public returns(bool) {\n    return true;\n  }\n}\n\ncontract SecureTargetBounty is Bounty {\n  function deployContract() internal returns (address) {\n    return new SecureTargetMock();\n  }\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/SplitPaymentMock.sol",
    "content": "pragma solidity ^0.4.18;\n\nimport '../../contracts/payment/SplitPayment.sol';\n\n// mock class using SplitPayment\ncontract SplitPaymentMock is SplitPayment {\n  function SplitPaymentMock(address[] _payees, uint256[] _shares) public\n    SplitPayment(_payees, _shares) payable {}\n  function () external payable {}\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/StandardTokenMock.sol",
    "content": "pragma solidity ^0.4.18;\n\n\nimport '../../contracts/token/StandardToken.sol';\n\n\n// mock class using StandardToken\ncontract StandardTokenMock is StandardToken {\n\n  function StandardTokenMock(address initialAccount, uint256 initialBalance) public {\n    balances[initialAccount] = initialBalance;\n    totalSupply = initialBalance;\n  }\n\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/advanceToBlock.js",
    "content": "export function advanceBlock() {\n  return new Promise((resolve, reject) => {\n    web3.currentProvider.sendAsync({\n      jsonrpc: '2.0',\n      method: 'evm_mine',\n      id: Date.now(),\n    }, (err, res) => {\n      return err ? reject(err) : resolve(res)\n    })\n  })\n}\n\n// Advances the block number so that the last mined block is `number`.\nexport default async function advanceToBlock(number) {\n  if (web3.eth.blockNumber > number) {\n    throw Error(`block number ${number} is in the past (current is ${web3.eth.blockNumber})`)\n  }\n\n  while (web3.eth.blockNumber < number) {\n    await advanceBlock()\n  }\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/assertJump.js",
    "content": "module.exports = function(error) {\n  assert.isAbove(error.message.search('invalid opcode'), -1, 'Invalid opcode error must be returned');\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/assertRevert.js",
    "content": "module.exports = function(error) {\n  assert.isAbove(error.message.search('revert'), -1, 'Error containing \"revert\" must be returned');\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/ether.js",
    "content": "export default function ether(n) {\n  return new web3.BigNumber(web3.toWei(n, 'ether'))\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/expectThrow.js",
    "content": "export default async promise => {\n  try {\n    await promise;\n  } catch (error) {\n    // TODO: Check jump destination to destinguish between a throw\n    //       and an actual invalid jump.\n    const invalidOpcode = error.message.search('invalid opcode') >= 0;\n    // TODO: When we contract A calls contract B, and B throws, instead\n    //       of an 'invalid jump', we get an 'out of gas' error. How do\n    //       we distinguish this from an actual out of gas event? (The\n    //       testrpc log actually show an 'invalid jump' event.)\n    const outOfGas = error.message.search('out of gas') >= 0;\n    const revert = error.message.search('revert') >= 0;\n    assert(\n      invalidOpcode || outOfGas || revert,\n      \"Expected throw, got '\" + error + \"' instead\",\n    );\n    return;\n  }\n  assert.fail('Expected throw not received');\n};\n"
  },
  {
    "path": "truffle/oz/test/helpers/hashMessage.js",
    "content": "import utils from 'ethereumjs-util';\n\n// Hash and add same prefix to the hash that testrpc use.\nmodule.exports = function(message) {\n  const messageHex = new Buffer(utils.sha3(message).toString('hex'), 'hex');\n  const prefix = utils.toBuffer('\\u0019Ethereum Signed Message:\\n' + messageHex.length.toString());\n  return utils.bufferToHex( utils.sha3(Buffer.concat([prefix, messageHex])) );\n};\n"
  },
  {
    "path": "truffle/oz/test/helpers/increaseTime.js",
    "content": "import latestTime from './latestTime'\n\n// Increases testrpc time by the passed duration in seconds\nexport default function increaseTime(duration) {\n  const id = Date.now()\n\n  return new Promise((resolve, reject) => {\n    web3.currentProvider.sendAsync({\n      jsonrpc: '2.0',\n      method: 'evm_increaseTime',\n      params: [duration],\n      id: id,\n    }, err1 => {\n      if (err1) return reject(err1)\n\n      web3.currentProvider.sendAsync({\n        jsonrpc: '2.0',\n        method: 'evm_mine',\n        id: id+1,\n      }, (err2, res) => {\n        return err2 ? reject(err2) : resolve(res)\n      })\n    })\n  })\n}\n\n/**\n * Beware that due to the need of calling two separate testrpc methods and rpc calls overhead\n * it's hard to increase time precisely to a target point so design your test to tolerate\n * small fluctuations from time to time.\n *\n * @param target time in seconds\n */\nexport function increaseTimeTo(target) {\n  let now = latestTime();\n  if (target < now) throw Error(`Cannot increase current time(${now}) to a moment in the past(${target})`);\n  let diff = target - now;\n  return increaseTime(diff);\n}\n\nexport const duration = {\n  seconds: function(val) { return val},\n  minutes: function(val) { return val * this.seconds(60) },\n  hours:   function(val) { return val * this.minutes(60) },\n  days:    function(val) { return val * this.hours(24) },\n  weeks:   function(val) { return val * this.days(7) },\n  years:   function(val) { return val * this.days(365)}\n};\n"
  },
  {
    "path": "truffle/oz/test/helpers/latestTime.js",
    "content": "// Returns the time of the last mined block in seconds\nexport default function latestTime() {\n  return web3.eth.getBlock('latest').timestamp;\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/merkleTree.js",
    "content": "import { sha3, bufferToHex } from \"ethereumjs-util\";\n\nexport default class MerkleTree {\n  constructor(elements) {\n    // Filter empty strings and hash elements\n    this.elements = elements.filter(el => el).map(el => sha3(el));\n\n    // Deduplicate elements\n    this.elements = this.bufDedup(this.elements);\n    // Sort elements\n    this.elements.sort(Buffer.compare);\n\n    // Create layers\n    this.layers = this.getLayers(this.elements);\n  }\n\n  getLayers(elements) {\n    if (elements.length == 0) {\n      return [[\"\"]];\n    }\n\n    const layers = [];\n    layers.push(elements);\n\n    // Get next layer until we reach the root\n    while (layers[layers.length - 1].length > 1) {\n      layers.push(this.getNextLayer(layers[layers.length - 1]));\n    }\n\n    return layers;\n  }\n\n  getNextLayer(elements) {\n    return elements.reduce((layer, el, idx, arr) => {\n      if (idx % 2 === 0) {\n        // Hash the current element with its pair element\n        layer.push(this.combinedHash(el, arr[idx + 1]));\n      }\n\n      return layer;\n    }, []);\n  }\n\n  combinedHash(first, second) {\n    if (!first) { return second; }\n    if (!second) { return first; }\n\n    return sha3(this.sortAndConcat(first, second));\n  }\n\n  getRoot() {\n    return this.layers[this.layers.length - 1][0];\n  }\n\n  getHexRoot() {\n    return bufferToHex(this.getRoot());\n  }\n\n  getProof(el) {\n    let idx = this.bufIndexOf(el, this.elements);\n\n    if (idx === -1) {\n      throw new Error(\"Element does not exist in Merkle tree\");\n    }\n\n    return this.layers.reduce((proof, layer) => {\n      const pairElement = this.getPairElement(idx, layer);\n\n      if (pairElement) {\n        proof.push(pairElement);\n      }\n\n      idx = Math.floor(idx / 2);\n\n      return proof;\n    }, []);\n  }\n\n  getHexProof(el) {\n    const proof = this.getProof(el);\n\n    return this.bufArrToHex(proof);\n  }\n\n  getPairElement(idx, layer) {\n    const pairIdx = idx % 2 === 0 ? idx + 1 : idx - 1;\n\n    if (pairIdx < layer.length) {\n      return layer[pairIdx];\n    } else {\n      return null;\n    }\n  }\n\n  bufIndexOf(el, arr) {\n    let hash;\n\n    // Convert element to 32 byte hash if it is not one already\n    if (el.length !== 32 || !Buffer.isBuffer(el)) {\n      hash = sha3(el);\n    } else {\n      hash = el;\n    }\n\n    for (let i = 0; i < arr.length; i++) {\n      if (hash.equals(arr[i])) {\n        return i;\n      }\n    }\n\n    return -1;\n  }\n\n  bufDedup(elements) {\n    return elements.filter((el, idx) => {\n      return this.bufIndexOf(el, elements) === idx;\n    });\n  }\n\n  bufArrToHex(arr) {\n    if (arr.some(el => !Buffer.isBuffer(el))) {\n      throw new Error(\"Array is not an array of buffers\");\n    }\n\n    return \"0x\" + arr.map(el => el.toString(\"hex\")).join(\"\");\n  }\n\n  sortAndConcat(...args) {\n    return Buffer.concat([...args].sort(Buffer.compare));\n  }\n}\n"
  },
  {
    "path": "truffle/oz/test/helpers/toPromise.js",
    "content": "export default func =>\n  (...args) =>\n    new Promise((accept, reject) =>\n      func(...args, (error, data) => error ? reject(error) : accept(data)));\n"
  },
  {
    "path": "truffle/oz/test/helpers/transactionMined.js",
    "content": "'use strict';\n\n//from https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6\nmodule.export = web3.eth.transactionMined = function (txnHash, interval) {\n  var transactionReceiptAsync;\n  interval = interval ? interval : 500;\n  transactionReceiptAsync = function(txnHash, resolve, reject) {\n    try {\n      var receipt = web3.eth.getTransactionReceipt(txnHash);\n      if (receipt === null) {\n        setTimeout(function () {\n          transactionReceiptAsync(txnHash, resolve, reject);\n        }, interval);\n      } else {\n        resolve(receipt);\n      }\n    } catch(e) {\n      reject(e);\n    }\n  };\n\n  if (Array.isArray(txnHash)) {\n    var promises = [];\n    txnHash.forEach(function (oneTxHash) {\n      promises.push(\n        web3.eth.getTransactionReceiptMined(oneTxHash, interval));\n    });\n    return Promise.all(promises);\n  } else {\n    return new Promise(function (resolve, reject) {\n      transactionReceiptAsync(txnHash, resolve, reject);\n    });\n  }\n};\n"
  },
  {
    "path": "truffle/oz/test/metacoin.js",
    "content": "var MetaCoin = artifacts.require(\"./MetaCoin.sol\");\n\ncontract('MetaCoin', function(accounts) {\n  it(\"should put 10000 MetaCoin in the first account\", function() {\n    return MetaCoin.deployed().then(function(instance) {\n      return instance.getBalance.call(accounts[0]);\n    }).then(function(balance) {\n      assert.equal(balance.valueOf(), 10000, \"10000 wasn't in the first account\");\n    });\n  });\n  it(\"should call a function that depends on a linked library\", function() {\n    var meta;\n    var metaCoinBalance;\n    var metaCoinEthBalance;\n\n    return MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(accounts[0]);\n    }).then(function(outCoinBalance) {\n      metaCoinBalance = outCoinBalance.toNumber();\n      return meta.getBalanceInEth.call(accounts[0]);\n    }).then(function(outCoinBalanceEth) {\n      metaCoinEthBalance = outCoinBalanceEth.toNumber();\n    }).then(function() {\n      assert.equal(metaCoinEthBalance, 2 * metaCoinBalance, \"Library function returned unexpected function, linkage may be broken\");\n    });\n  });\n  it(\"should send coin correctly\", function() {\n    var meta;\n\n    // Get initial balances of first and second account.\n    var account_one = accounts[0];\n    var account_two = accounts[1];\n\n    var account_one_starting_balance;\n    var account_two_starting_balance;\n    var account_one_ending_balance;\n    var account_two_ending_balance;\n\n    var amount = 10;\n\n    return MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(account_one);\n    }).then(function(balance) {\n      account_one_starting_balance = balance.toNumber();\n      return meta.getBalance.call(account_two);\n    }).then(function(balance) {\n      account_two_starting_balance = balance.toNumber();\n      return meta.sendCoin(account_two, amount, {from: account_one});\n    }).then(function() {\n      return meta.getBalance.call(account_one);\n    }).then(function(balance) {\n      account_one_ending_balance = balance.toNumber();\n      return meta.getBalance.call(account_two);\n    }).then(function(balance) {\n      account_two_ending_balance = balance.toNumber();\n\n      assert.equal(account_one_ending_balance, account_one_starting_balance - amount, \"Amount wasn't correctly taken from the sender\");\n      assert.equal(account_two_ending_balance, account_two_starting_balance + amount, \"Amount wasn't correctly sent to the receiver\");\n    });\n  });\n});\n"
  },
  {
    "path": "truffle/oz/truffle.js",
    "content": "module.exports = {\n  networks: {\n    development: {\n      host: \"localhost\",\n      port: 8545,\n\t  gas: 3000000,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};\n"
  },
  {
    "path": "truffle/ozex/README.md",
    "content": "## OpenZeppelin sample\r\n\r\nRun \r\n```\r\nnpm install zeppelin-solidity\r\ntruffle test\r\n```\r\n\r\n"
  },
  {
    "path": "truffle/ozex/contracts/ExampleToken.sol",
    "content": "pragma solidity ^0.4.11;\r\n\r\nimport \"zeppelin-solidity/contracts/token/StandardToken.sol\";\r\n\r\ncontract ExampleToken is StandardToken {\r\n\tstring public name = \"ExampleToken\"; \r\n\tstring public symbol = \"EGT\";\r\n\tuint public decimals = 18;\r\n\tuint public INITIAL_SUPPLY = 10000;\r\n\r\n\tfunction ExampleToken() {\r\n\t\ttotalSupply = INITIAL_SUPPLY;\r\n\t\tbalances[msg.sender] = INITIAL_SUPPLY;\r\n\t}\r\n} \r\n "
  },
  {
    "path": "truffle/ozex/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.17;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function Migrations() public {\n    owner = msg.sender;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/ozex/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/ozex/migrations/2_deploy_contracts.js",
    "content": "var ExampleToken = artifacts.require(\"./ExampleToken.sol\");\r\n\r\nmodule.exports = function(deployer) {\r\n  deployer.deploy(ExampleToken);\r\n};\r\n"
  },
  {
    "path": "truffle/ozex/test/exampletoken.js",
    "content": "var ExampleToken = artifacts.require(\"ExampleToken.sol\");\r\n\r\ncontract('ExampleToken', function(accounts) {\r\n\r\n  it(\"should return the correct totalSupply after construction\", async function() {\r\n    let token = await ExampleToken.new(accounts[0], 100);\r\n    let totalSupply = await token.totalSupply();\r\n\r\n\tconsole.log('total supply', totalSupply);\r\n    assert.equal(totalSupply, 10000);\r\n  })\r\n\r\n});\r\n"
  },
  {
    "path": "truffle/ozex/truffle-config.js",
    "content": "module.exports = {\n  // See <http://truffleframework.com/docs/advanced/configuration>\n  // to customize your Truffle configuration!\n};\n"
  },
  {
    "path": "truffle/ozex/truffle.js",
    "content": "module.exports = {\n  // See <http://truffleframework.com/docs/advanced/configuration>\n  // to customize your Truffle configuration!\n};\n"
  },
  {
    "path": "truffle/ozws/bs-config.json",
    "content": "{\n  \"server\": {\n    \"baseDir\": [\"./src\", \"./build/contracts\"]\n  }\n}\n"
  },
  {
    "path": "truffle/ozws/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.2;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function Migrations() public {\n    owner = msg.sender;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/ozws/contracts/TutorialToken.sol",
    "content": "import 'zeppelin-solidity/contracts/token/StandardToken.sol';\r\n\r\ncontract TutorialToken is StandardToken {\r\n\tstring public name = 'TutorialToken';\r\n\tstring public symbol = 'TT';\r\n\tuint public decimals = 2;\r\n\tuint public INITIAL_SUPPLY = 12000;\r\n\r\n\tfunction TutorialToken() {\r\n\t  totalSupply = INITIAL_SUPPLY;\r\n\t  balances[msg.sender] = INITIAL_SUPPLY;\r\n\t}\r\n}\r\n\r\n"
  },
  {
    "path": "truffle/ozws/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/ozws/migrations/2_deploy_contracts.js",
    "content": "var TutorialToken = artifacts.require(\"TutorialToken\");\r\n\r\nmodule.exports = function(deployer) {\r\n  deployer.deploy(TutorialToken);\r\n};\r\n\r\n"
  },
  {
    "path": "truffle/ozws/package.json",
    "content": "{\n  \"name\": \"tutorialtoken\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"truffle.js\",\n  \"directories\": {\n    \"test\": \"test\"\n  },\n  \"scripts\": {\n    \"dev\": \"lite-server\",\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"lite-server\": \"^2.3.0\"\n  }\n}\n"
  },
  {
    "path": "truffle/ozws/src/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->\n    <title>TutorialToken - Wallet</title>\n\n    <!-- Bootstrap -->\n    <link href=\"css/bootstrap.min.css\" rel=\"stylesheet\">\n\n    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->\n    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->\n    <!--[if lt IE 9]>\n      <script src=\"https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js\"></script>\n      <script src=\"https://oss.maxcdn.com/respond/1.4.2/respond.min.js\"></script>\n    <![endif]-->\n  </head>\n  <body>\n    <div class=\"container\">\n      <div class=\"row\">\n        <div class=\"col-xs-12 col-sm-8 col-sm-push-2\">\n          <h1 class=\"text-center\">TutorialToken</h1>\n          <hr/>\n          <br/>\n        </div>\n      </div>\n\n      <div id=\"petsRow\" class=\"row\">\n        <div class=\"col-sm-6 col-sm-push-3 col-md-4 col-md-push-4\">\n          <div class=\"panel panel-default\">\n            <div class=\"panel-heading\">\n              <h3 class=\"panel-title\">My Wallet</h3>\n            </div>\n            <div class=\"panel-body\">\n              <h4>Balance</h4>\n              <strong>Balance</strong>: <span id=\"TTBalance\"></span> TT<br/><br/>\n              <h4>Transfer</h4>\n              <input type=\"text\" class=\"form-control\" id=\"TTTransferAddress\" placeholder=\"Address\" />\n              <input type=\"text\" class=\"form-control\" id=\"TTTransferAmount\" placeholder=\"Amount\" />\n              <button class=\"btn btn-primary\" id=\"transferButton\" type=\"button\">Transfer</button>\n            </div>\n          </div>\n        </div>\n      </div>\n    </div>\n\n    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->\n    <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js\"></script>\n    <!-- Include all compiled plugins (below), or include individual files as needed -->\n    <script src=\"js/bootstrap.min.js\"></script>\n    <script src=\"js/web3.min.js\"></script>\n    <script src=\"js/truffle-contract.js\"></script>\n    <script src=\"js/app.js\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "truffle/ozws/src/js/app.js",
    "content": "App = {\n  web3Provider: null,\n  contracts: {},\n\n  init: function() {\n    return App.initWeb3();\n  },\n\n  initWeb3: function() {\n    // Initialize web3 and set the provider to the testRPC.\n    if (typeof web3 !== 'undefined') {\n      App.web3Provider = web3.currentProvider;\n      web3 = new Web3(web3.currentProvider);\n    } else {\n      // set the provider you want from Web3.providers\n      App.web3Provider = new Web3.providers.HttpProvider('http://127.0.0.1:8545');\n      web3 = new Web3(App.web3Provider);\n    }\n\n    return App.initContract();\n  },\n\n  initContract: function() {\n    $.getJSON('TutorialToken.json', function(data) {\n      // Get the necessary contract artifact file and instantiate it with truffle-contract.\n      var TutorialTokenArtifact = data;\n      App.contracts.TutorialToken = TruffleContract(TutorialTokenArtifact);\n\n      // Set the provider for our contract.\n      App.contracts.TutorialToken.setProvider(App.web3Provider);\n\n      // Use our contract to retieve and mark the adopted pets.\n      return App.getBalances();\n    });\n\n    return App.bindEvents();\n  },\n\n  bindEvents: function() {\n    $(document).on('click', '#transferButton', App.handleTransfer);\n  },\n\n  handleTransfer: function(event) {\n    event.preventDefault();\n\n    var amount = parseInt($('#TTTransferAmount').val());\n    var toAddress = $('#TTTransferAddress').val();\n\n    console.log('Transfer ' + amount + ' TT to ' + toAddress);\n\n    var tutorialTokenInstance;\n\n    web3.eth.getAccounts(function(error, accounts) {\n      if (error) {\n        console.log(error);\n      }\n\n      var account = accounts[0];\n\n      App.contracts.TutorialToken.deployed().then(function(instance) {\n        tutorialTokenInstance = instance;\n\n        return tutorialTokenInstance.transfer(toAddress, amount, {from: account});\n      }).then(function(result) {\n        alert('Transfer Successful!');\n        return App.getBalances();\n      }).catch(function(err) {\n        console.log(err.message);\n      });\n    });\n  },\n\n  getBalances: function(adopters, account) {\n    console.log('Getting balances...');\n\n    var tutorialTokenInstance;\n\n    web3.eth.getAccounts(function(error, accounts) {\n      if (error) {\n        console.log(error);\n      }\n\n      var account = accounts[0];\n\n      App.contracts.TutorialToken.deployed().then(function(instance) {\n        tutorialTokenInstance = instance;\n\n        return tutorialTokenInstance.balanceOf(account);\n      }).then(function(result) {\n        balance = result.c[0];\n\n        $('#TTBalance').text(balance);\n      }).catch(function(err) {\n        console.log(err.message);\n      });\n    });\n  }\n\n};\n\n$(function() {\n  $(window).load(function() {\n    App.init();\n  });\n});\n"
  },
  {
    "path": "truffle/ozws/src/js/truffle-contract.js",
    "content": "(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){\n(function (global){\nvar ethJSABI = require(\"ethjs-abi\");\nvar BlockchainUtils = require(\"truffle-blockchain-utils\");\nvar Web3 = require(\"web3\");\n\n// For browserified version. If browserify gave us an empty version,\n// look for the one provided by the user.\nif (typeof Web3 == \"object\" && Object.keys(Web3).length == 0) {\n  Web3 = global.Web3;\n}\n\nvar contract = (function(module) {\n\n  // Planned for future features, logging, etc.\n  function Provider(provider) {\n    this.provider = provider;\n  }\n\n  Provider.prototype.send = function() {\n    return this.provider.send.apply(this.provider, arguments);\n  };\n\n  Provider.prototype.sendAsync = function() {\n    return this.provider.sendAsync.apply(this.provider, arguments);\n  };\n\n  var BigNumber = (new Web3()).toBigNumber(0).constructor;\n\n  var Utils = {\n    is_object: function(val) {\n      return typeof val == \"object\" && !Array.isArray(val);\n    },\n    is_big_number: function(val) {\n      if (typeof val != \"object\") return false;\n\n      // Instanceof won't work because we have multiple versions of Web3.\n      try {\n        new BigNumber(val);\n        return true;\n      } catch (e) {\n        return false;\n      }\n    },\n    decodeLogs: function(C, instance, logs) {\n      return logs.map(function(log) {\n        var logABI = C.events[log.topics[0]];\n\n        if (logABI == null) {\n          return null;\n        }\n\n        // This function has been adapted from web3's SolidityEvent.decode() method,\n        // and built to work with ethjs-abi.\n\n        var copy = Utils.merge({}, log);\n\n        function partialABI(fullABI, indexed) {\n          var inputs = fullABI.inputs.filter(function (i) {\n            return i.indexed === indexed;\n          });\n\n          var partial = {\n            inputs: inputs,\n            name: fullABI.name,\n            type: fullABI.type,\n            anonymous: fullABI.anonymous\n          };\n\n          return partial;\n        }\n\n        var argTopics = logABI.anonymous ? copy.topics : copy.topics.slice(1);\n        var indexedData = \"0x\" + argTopics.map(function (topics) { return topics.slice(2); }).join(\"\");\n        var indexedParams = ethJSABI.decodeEvent(partialABI(logABI, true), indexedData);\n\n        var notIndexedData = copy.data;\n        var notIndexedParams = ethJSABI.decodeEvent(partialABI(logABI, false), notIndexedData);\n\n        copy.event = logABI.name;\n\n        copy.args = logABI.inputs.reduce(function (acc, current) {\n          var val = indexedParams[current.name];\n\n          if (val === undefined) {\n            val = notIndexedParams[current.name];\n          }\n\n          acc[current.name] = val;\n          return acc;\n        }, {});\n\n        Object.keys(copy.args).forEach(function(key) {\n          var val = copy.args[key];\n\n          // We have BN. Convert it to BigNumber\n          if (val.constructor.isBN) {\n            copy.args[key] = C.web3.toBigNumber(\"0x\" + val.toString(16));\n          }\n        });\n\n        delete copy.data;\n        delete copy.topics;\n\n        return copy;\n      }).filter(function(log) {\n        return log != null;\n      });\n    },\n    promisifyFunction: function(fn, C) {\n      var self = this;\n      return function() {\n        var instance = this;\n\n        var args = Array.prototype.slice.call(arguments);\n        var tx_params = {};\n        var last_arg = args[args.length - 1];\n\n        // It's only tx_params if it's an object and not a BigNumber.\n        if (Utils.is_object(last_arg) && !Utils.is_big_number(last_arg)) {\n          tx_params = args.pop();\n        }\n\n        tx_params = Utils.merge(C.class_defaults, tx_params);\n\n        return C.detectNetwork().then(function() {\n          return new Promise(function(accept, reject) {\n            var callback = function(error, result) {\n              if (error != null) {\n                reject(error);\n              } else {\n                accept(result);\n              }\n            };\n            args.push(tx_params, callback);\n            fn.apply(instance.contract, args);\n          });\n        });\n      };\n    },\n    synchronizeFunction: function(fn, instance, C) {\n      var self = this;\n      return function() {\n        var args = Array.prototype.slice.call(arguments);\n        var tx_params = {};\n        var last_arg = args[args.length - 1];\n\n        // It's only tx_params if it's an object and not a BigNumber.\n        if (Utils.is_object(last_arg) && !Utils.is_big_number(last_arg)) {\n          tx_params = args.pop();\n        }\n\n        tx_params = Utils.merge(C.class_defaults, tx_params);\n\n        return C.detectNetwork().then(function() {\n          return new Promise(function(accept, reject) {\n            var callback = function(error, tx) {\n              if (error != null) {\n                reject(error);\n                return;\n              }\n\n              var timeout = C.synchronization_timeout || 240000;\n              var start = new Date().getTime();\n\n              var make_attempt = function() {\n                C.web3.eth.getTransactionReceipt(tx, function(err, receipt) {\n                  if (err) return reject(err);\n\n                  if (receipt != null) {\n                    return accept({\n                      tx: tx,\n                      receipt: receipt,\n                      logs: Utils.decodeLogs(C, instance, receipt.logs)\n                    });\n                  }\n\n                  if (timeout > 0 && new Date().getTime() - start > timeout) {\n                    return reject(new Error(\"Transaction \" + tx + \" wasn't processed in \" + (timeout / 1000) + \" seconds!\"));\n                  }\n\n                  setTimeout(make_attempt, 1000);\n                });\n              };\n\n              make_attempt();\n            };\n\n            args.push(tx_params, callback);\n            fn.apply(self, args);\n          });\n        });\n      };\n    },\n    merge: function() {\n      var merged = {};\n      var args = Array.prototype.slice.call(arguments);\n\n      for (var i = 0; i < args.length; i++) {\n        var object = args[i];\n        var keys = Object.keys(object);\n        for (var j = 0; j < keys.length; j++) {\n          var key = keys[j];\n          var value = object[key];\n          merged[key] = value;\n        }\n      }\n\n      return merged;\n    },\n    parallel: function (arr, callback) {\n      callback = callback || function () {};\n      if (!arr.length) {\n        return callback(null, []);\n      }\n      var index = 0;\n      var results = new Array(arr.length);\n      arr.forEach(function (fn, position) {\n        fn(function (err, result) {\n          if (err) {\n            callback(err);\n            callback = function () {};\n          } else {\n            index++;\n            results[position] = result;\n            if (index >= arr.length) {\n              callback(null, results);\n            }\n          }\n        });\n      });\n    },\n    bootstrap: function(fn) {\n      // Add our static methods\n      Object.keys(fn._static_methods).forEach(function(key) {\n        fn[key] = fn._static_methods[key].bind(fn);\n      });\n\n      // Add our properties.\n      Object.keys(fn._properties).forEach(function(key) {\n        fn.addProp(key, fn._properties[key]);\n      });\n\n      return fn;\n    }\n  };\n\n  // Accepts a contract object created with web3.eth.contract.\n  // Optionally, if called without `new`, accepts a network_id and will\n  // create a new version of the contract abstraction with that network_id set.\n  function Contract(contract) {\n    var self = this;\n    var constructor = this.constructor;\n    this.abi = constructor.abi;\n\n    if (typeof contract == \"string\") {\n      var address = contract;\n      var contract_class = constructor.web3.eth.contract(this.abi);\n      contract = contract_class.at(address);\n    }\n\n    this.contract = contract;\n\n    // Provision our functions.\n    for (var i = 0; i < this.abi.length; i++) {\n      var item = this.abi[i];\n      if (item.type == \"function\") {\n        if (item.constant == true) {\n          this[item.name] = Utils.promisifyFunction(contract[item.name], constructor);\n        } else {\n          this[item.name] = Utils.synchronizeFunction(contract[item.name], this, constructor);\n        }\n\n        this[item.name].call = Utils.promisifyFunction(contract[item.name].call, constructor);\n        this[item.name].sendTransaction = Utils.promisifyFunction(contract[item.name].sendTransaction, constructor);\n        this[item.name].request = contract[item.name].request;\n        this[item.name].estimateGas = Utils.promisifyFunction(contract[item.name].estimateGas, constructor);\n      }\n\n      if (item.type == \"event\") {\n        this[item.name] = contract[item.name];\n      }\n    }\n\n    this.sendTransaction = Utils.synchronizeFunction(function(tx_params, callback) {\n      if (typeof tx_params == \"function\") {\n        callback = tx_params;\n        tx_params = {};\n      }\n\n      tx_params.to = self.address;\n\n      constructor.web3.eth.sendTransaction.apply(constructor.web3.eth, [tx_params, callback]);\n    }, this, constructor);\n\n    this.send = function(value) {\n      return self.sendTransaction({value: value});\n    };\n\n    this.allEvents = contract.allEvents;\n    this.address = contract.address;\n    this.transactionHash = contract.transactionHash;\n  };\n\n  Contract._static_methods = {\n    setProvider: function(provider) {\n      if (!provider) {\n        throw new Error(\"Invalid provider passed to setProvider(); provider is \" + provider);\n      }\n\n      var wrapped = new Provider(provider);\n      this.web3.setProvider(wrapped);\n      this.currentProvider = provider;\n    },\n\n    new: function() {\n      var self = this;\n\n      if (this.currentProvider == null) {\n        throw new Error(this.contract_name + \" error: Please call setProvider() first before calling new().\");\n      }\n\n      var args = Array.prototype.slice.call(arguments);\n\n      if (!this.unlinked_binary) {\n        throw new Error(this._json.contract_name + \" error: contract binary not set. Can't deploy new instance.\");\n      }\n\n      return self.detectNetwork().then(function(network_id) {\n        // After the network is set, check to make sure everything's ship shape.\n        var regex = /__[^_]+_+/g;\n        var unlinked_libraries = self.binary.match(regex);\n\n        if (unlinked_libraries != null) {\n          unlinked_libraries = unlinked_libraries.map(function(name) {\n            // Remove underscores\n            return name.replace(/_/g, \"\");\n          }).sort().filter(function(name, index, arr) {\n            // Remove duplicates\n            if (index + 1 >= arr.length) {\n              return true;\n            }\n\n            return name != arr[index + 1];\n          }).join(\", \");\n\n          throw new Error(self.contract_name + \" contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of \" + self._json.contract_name + \": \" + unlinked_libraries);\n        }\n      }).then(function() {\n        return new Promise(function(accept, reject) {\n          var contract_class = self.web3.eth.contract(self.abi);\n          var tx_params = {};\n          var last_arg = args[args.length - 1];\n\n          // It's only tx_params if it's an object and not a BigNumber.\n          if (Utils.is_object(last_arg) && !Utils.is_big_number(last_arg)) {\n            tx_params = args.pop();\n          }\n\n          tx_params = Utils.merge(self.class_defaults, tx_params);\n\n          if (tx_params.data == null) {\n            tx_params.data = self.binary;\n          }\n\n          // web3 0.9.0 and above calls new this callback twice.\n          // Why, I have no idea...\n          var intermediary = function(err, web3_instance) {\n            if (err != null) {\n              reject(err);\n              return;\n            }\n\n            if (err == null && web3_instance != null && web3_instance.address != null) {\n              accept(new self(web3_instance));\n            }\n          };\n\n          args.push(tx_params, intermediary);\n          contract_class.new.apply(contract_class, args);\n        });\n      });\n    },\n\n    at: function(address) {\n      var self = this;\n\n      if (address == null || typeof address != \"string\" || address.length != 42) {\n        throw new Error(\"Invalid address passed to \" + this._json.contract_name + \".at(): \" + address);\n      }\n\n      var contract = new this(address);\n\n      // Add thennable to allow people opt into new recommended usage.\n      contract.then = function(fn) {\n        return self.detectNetwork().then(function(network_id) {\n          var instance = new self(address);\n\n          return new Promise(function(accept, reject) {\n            self.web3.eth.getCode(address, function(err, code) {\n              if (err) return reject(err);\n\n              if (!code || new BigNumber(code).eq(0)) {\n                return reject(new Error(\"Cannot create instance of \" + self.contract_name + \"; no code at address \" + address));\n              }\n\n              accept(instance);\n            });\n          });\n        }).then(fn);\n      };\n\n      return contract;\n    },\n\n    deployed: function() {\n      var self = this;\n      var val = {}; //this.at(this.address);\n\n      // Add thennable to allow people to opt into new recommended usage.\n      val.then = function(fn) {\n        return self.detectNetwork().then(function() {\n          // We don't have a network config for the one we found\n          if (self._json.networks[self.network_id] == null) {\n            throw new Error(self.contract_name + \" has not been deployed to detected network (network/artifact mismatch)\");\n          }\n\n          // If we found the network but it's not deployed\n          if (!self.isDeployed()) {\n            throw new Error(self.contract_name + \" has not been deployed to detected network (\" + self.network_id + \")\");\n          }\n\n          return new self(self.address);\n        }).then(fn);\n      };\n\n      return val;\n    },\n\n    defaults: function(class_defaults) {\n      if (this.class_defaults == null) {\n        this.class_defaults = {};\n      }\n\n      if (class_defaults == null) {\n        class_defaults = {};\n      }\n\n      var self = this;\n      Object.keys(class_defaults).forEach(function(key) {\n        var value = class_defaults[key];\n        self.class_defaults[key] = value;\n      });\n\n      return this.class_defaults;\n    },\n\n    hasNetwork: function(network_id) {\n      return this._json.networks[network_id + \"\"] != null;\n    },\n\n    isDeployed: function() {\n      if (this.network_id == null) {\n        return false;\n      }\n\n      if (this._json.networks[this.network_id] == null) {\n        return false;\n      }\n\n      return !!this.network.address;\n    },\n\n    detectNetwork: function() {\n      var self = this;\n\n      return new Promise(function(accept, reject) {\n        // Try to detect the network we have artifacts for.\n        if (self.network_id) {\n          // We have a network id and a configuration, let's go with it.\n          if (self.networks[self.network_id] != null) {\n            return accept(self.network_id);\n          }\n        }\n\n        self.web3.version.getNetwork(function(err, result) {\n          if (err) return reject(err);\n\n          var network_id = result.toString();\n\n          // If we found the network via a number, let's use that.\n          if (self.hasNetwork(network_id)) {\n            self.setNetwork(network_id);\n            return accept();\n          }\n\n          // Otherwise, go through all the networks that are listed as\n          // blockchain uris and see if they match.\n          var uris = Object.keys(self._json.networks).filter(function(network) {\n            return network.indexOf(\"blockchain://\") == 0;\n          });\n\n          var matches = uris.map(function(uri) {\n            return BlockchainUtils.matches.bind(BlockchainUtils, uri, self.web3.currentProvider);\n          });\n\n          Utils.parallel(matches, function(err, results) {\n            if (err) return reject(err);\n\n            for (var i = 0; i < results.length; i++) {\n              if (results[i]) {\n                self.setNetwork(uris[i]);\n                return accept();\n              }\n            }\n\n            // We found nothing. Set the network id to whatever the provider states.\n            self.setNetwork(network_id);\n\n            accept();\n          });\n\n        });\n      });\n    },\n\n    setNetwork: function(network_id) {\n      if (!network_id) return;\n      this.network_id = network_id + \"\";\n    },\n\n    // Overrides the deployed address to null.\n    // You must call this explicitly so you don't inadvertently do this otherwise.\n    resetAddress: function() {\n      delete this.network.address;\n    },\n\n    link: function(name, address) {\n      var self = this;\n\n      if (typeof name == \"function\") {\n        var contract = name;\n\n        if (contract.isDeployed() == false) {\n          throw new Error(\"Cannot link contract without an address.\");\n        }\n\n        this.link(contract.contract_name, contract.address);\n\n        // Merge events so this contract knows about library's events\n        Object.keys(contract.events).forEach(function(topic) {\n          self.network.events[topic] = contract.events[topic];\n        });\n\n        return;\n      }\n\n      if (typeof name == \"object\") {\n        var obj = name;\n        Object.keys(obj).forEach(function(name) {\n          var a = obj[name];\n          self.link(name, a);\n        });\n        return;\n      }\n\n      if (this._json.networks[this.network_id] == null) {\n        this._json.networks[this.network_id] = {\n          events: {},\n          links: {}\n        };\n      }\n\n      this.network.links[name] = address;\n    },\n\n    clone: function(options) {\n      var self = this;\n      var temp = function TruffleContract() {\n        this.constructor = temp;\n        return Contract.apply(this, arguments);\n      };\n\n      var json = options;\n      var network_id;\n\n      if (typeof options != \"object\") {\n        json = self._json;\n        network_id = options;\n        options = {};\n      }\n\n      temp.prototype = Object.create(self.prototype);\n\n      temp._static_methods = this._static_methods;\n      temp._properties = this._properties;\n\n      temp._property_values = {};\n      temp._json = json || {};\n\n      Utils.bootstrap(temp);\n\n      temp.web3 = new Web3();\n      temp.class_defaults = temp.prototype.defaults || {};\n\n      if (network_id) {\n        temp.setNetwork(network_id);\n      }\n\n      // Copy over custom options\n      Object.keys(options).forEach(function(key) {\n        if (key.indexOf(\"x-\") != 0) return;\n        temp[key] = options[key];\n      });\n\n      return temp;\n    },\n\n    addProp: function(key, fn) {\n      var self = this;\n\n      var getter = function() {\n        if (fn.get != null) {\n          return fn.get.call(self);\n        }\n\n        return self._property_values[key] || fn.call(self);\n      }\n      var setter = function(val) {\n        if (fn.set != null) {\n          fn.set.call(self, val);\n          return;\n        }\n\n        // If there's not a setter, then the property is immutable.\n        throw new Error(key + \" property is immutable\");\n      };\n\n      var definition = {};\n      definition.enumerable = false;\n      definition.configurable = false;\n      definition.get = getter;\n      definition.set = setter;\n\n      Object.defineProperty(this, key, definition);\n    },\n\n    toJSON: function() {\n      return this._json;\n    }\n  };\n\n  // Getter functions are scoped to Contract object.\n  Contract._properties = {\n    contract_name: {\n      get: function() {\n        return this._json.contract_name;\n      },\n      set: function(val) {\n        this._json.contract_name = val;\n      }\n    },\n    abi: {\n      get: function() {\n        return this._json.abi;\n      },\n      set: function(val) {\n        this._json.abi = val;\n      }\n    },\n    network: function() {\n      var network_id = this.network_id;\n\n      if (network_id == null) {\n        throw new Error(this.contract_name + \" has no network id set, cannot lookup artifact data. Either set the network manually using \" + this.contract_name + \".setNetwork(), run \" + this.contract_name + \".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.\");\n      }\n\n      // TODO: this might be bad; setting a value on a get.\n      if (this._json.networks[network_id] == null) {\n        throw new Error(this.contract_name + \" has no network configuration for its current network id (\" + network_id + \").\");\n      }\n\n      return this._json.networks[network_id];\n    },\n    networks: function() {\n      return this._json.networks;\n    },\n    address: {\n      get: function() {\n        var address = this.network.address;\n\n        if (address == null) {\n          throw new Error(\"Cannot find deployed address: \" + this.contract_name + \" not deployed or address not set.\");\n        }\n\n        return address;\n      },\n      set: function(val) {\n        if (val == null) {\n          throw new Error(\"Cannot set deployed address; malformed value: \" + val);\n        }\n\n        var network_id = this.network_id;\n\n        if (network_id == null) {\n          throw new Error(this.contract_name + \" has no network id set, cannot lookup artifact data. Either set the network manually using \" + this.contract_name + \".setNetwork(), run \" + this.contract_name + \".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.\");\n        }\n\n        // Create a network if we don't have one.\n        if (this._json.networks[network_id] == null) {\n          this._json.networks[network_id] = {\n            events: {},\n            links: {}\n          };\n        }\n\n        // Finally, set the address.\n        this.network.address = val;\n      }\n    },\n    links: function() {\n      if (this._json.networks[this.network_id] == null) {\n        return {};\n      }\n\n      return this.network.links || {};\n    },\n    events: function() {\n      // helper web3; not used for provider\n      var web3 = new Web3();\n\n      var events;\n\n      if (this._json.networks[this.network_id] == null) {\n        events = {};\n      } else {\n        events = this.network.events || {};\n      }\n\n      // Merge abi events with whatever's returned.\n      var abi = this.abi;\n\n      abi.forEach(function(item) {\n        if (item.type != \"event\") return;\n\n        var signature = item.name + \"(\";\n\n        item.inputs.forEach(function(input, index) {\n          signature += input.type;\n\n          if (index < item.inputs.length - 1) {\n            signature += \",\";\n          }\n        });\n\n        signature += \")\";\n\n        var topic = web3.sha3(signature);\n\n        events[topic] = item;\n      });\n\n      return events;\n    },\n    binary: function() {\n      var self = this;\n      var binary = this.unlinked_binary;\n\n      Object.keys(this.links).forEach(function(library_name) {\n        var library_address = self.links[library_name];\n        var regex = new RegExp(\"__\" + library_name + \"_*\", \"g\");\n\n        binary = binary.replace(regex, library_address.replace(\"0x\", \"\"));\n      });\n\n      return binary;\n    },\n    unlinked_binary: {\n      get: function() {\n        return this._json.unlinked_binary;\n      },\n      set: function(val) {\n        // TODO: Ensure 0x prefix.\n        this._json.unlinked_binary = val;\n      }\n    },\n    schema_version: function() {\n      return this._json.schema_version;\n    },\n    updated_at: function() {\n      try {\n        return this.network.updated_at || this._json.updated_at;\n      } catch (e) {\n        return this._json.updated_at;\n      }\n    }\n  };\n\n  Utils.bootstrap(Contract);\n\n  module.exports = Contract;\n\n  return Contract;\n})(module || {});\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"ethjs-abi\":7,\"truffle-blockchain-utils\":15,\"web3\":5}],2:[function(require,module,exports){\nvar Schema = require(\"truffle-contract-schema\");\nvar Contract = require(\"./contract.js\");\n\nvar contract = function(options) {\n  options = Schema.normalizeOptions(options);\n  var binary = Schema.generateBinary(options, {}, {dirty: false});\n\n  // Note we don't use `new` here at all. This will cause the class to\n  // \"mutate\" instead of instantiate an instance.\n  return Contract.clone(binary);\n};\n\n// To be used to upgrade old .sol.js abstractions\ncontract.fromSolJS = function(soljs_abstraction, ignore_default_network) {\n  if (ignore_default_network == null) {\n    ignore_default_network = false;\n  }\n\n  // Find the latest binary\n  var latest_network = null;\n  var latest_network_updated_at = 0;\n\n  var networks = {};\n\n  Object.keys(soljs_abstraction.all_networks).forEach(function(network_name) {\n\n    if (network_name == \"default\") {\n      if (ignore_default_network == true ) {\n        return;\n      } else {\n        throw new Error(soljs_abstraction.contract_name + \" has legacy 'default' network artifacts stored within it. Generally these artifacts were a result of running Truffle on a development environment -- in order to store contracts with truffle-contract, all networks must have an identified id. If you're sure this default network represents your development environment, you can ignore processing of the default network by passing `true` as the second argument to this function. However, if you think this network represents artifacts you'd like to keep (i.e., addresses deployed to the main network), you'll need to edit your .sol.js file yourself and change the default network id to be the id of your desired network. For most people, ignoring the default network is the correct option.\");\n      }\n    }\n\n    if (soljs_abstraction.all_networks[network_name].updated_at > latest_network_updated_at) {\n      latest_network = network_name;\n      latest_network_updated_at = soljs_abstraction.all_networks[network_name].updated_at;\n    }\n\n    networks[network_name] = {};\n\n    [\"address\", \"events\", \"links\", \"updated_at\"].forEach(function(key) {\n      networks[network_name][key] = soljs_abstraction.all_networks[network_name][key];\n    })\n  });\n\n  latest_network = soljs_abstraction.all_networks[latest_network] || {};\n\n  var json = {\n    contract_name: soljs_abstraction.contract_name,\n    unlinked_binary: latest_network.unlinked_binary,\n    abi: latest_network.abi,\n    networks: networks,\n    updated_at: latest_network_updated_at == 0 ? undefined : latest_network_updated_at\n  };\n\n  return contract(json);\n};\n\nmodule.exports = contract;\n\nif (typeof window !== \"undefined\") {\n  window.TruffleContract = contract;\n}\n\n},{\"./contract.js\":1,\"truffle-contract-schema\":16}],3:[function(require,module,exports){\n'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n  lookup[i] = code[i]\n  revLookup[code.charCodeAt(i)] = i\n}\n\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction placeHoldersCount (b64) {\n  var len = b64.length\n  if (len % 4 > 0) {\n    throw new Error('Invalid string. Length must be a multiple of 4')\n  }\n\n  // the number of equal signs (place holders)\n  // if there are two placeholders, than the two characters before it\n  // represent one byte\n  // if there is only one, then the three characters before it represent 2 bytes\n  // this is just a cheap hack to not do indexOf twice\n  return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0\n}\n\nfunction byteLength (b64) {\n  // base64 is 4/3 + up to two characters of the original data\n  return b64.length * 3 / 4 - placeHoldersCount(b64)\n}\n\nfunction toByteArray (b64) {\n  var i, j, l, tmp, placeHolders, arr\n  var len = b64.length\n  placeHolders = placeHoldersCount(b64)\n\n  arr = new Arr(len * 3 / 4 - placeHolders)\n\n  // if there are placeholders, only get up to the last complete 4 chars\n  l = placeHolders > 0 ? len - 4 : len\n\n  var L = 0\n\n  for (i = 0, j = 0; i < l; i += 4, j += 3) {\n    tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]\n    arr[L++] = (tmp >> 16) & 0xFF\n    arr[L++] = (tmp >> 8) & 0xFF\n    arr[L++] = tmp & 0xFF\n  }\n\n  if (placeHolders === 2) {\n    tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)\n    arr[L++] = tmp & 0xFF\n  } else if (placeHolders === 1) {\n    tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)\n    arr[L++] = (tmp >> 8) & 0xFF\n    arr[L++] = tmp & 0xFF\n  }\n\n  return arr\n}\n\nfunction tripletToBase64 (num) {\n  return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n  var tmp\n  var output = []\n  for (var i = start; i < end; i += 3) {\n    tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])\n    output.push(tripletToBase64(tmp))\n  }\n  return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n  var tmp\n  var len = uint8.length\n  var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n  var output = ''\n  var parts = []\n  var maxChunkLength = 16383 // must be multiple of 3\n\n  // go through the array every three bytes, we'll deal with trailing stuff later\n  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n    parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n  }\n\n  // pad the end with zeros, but make sure to not forget the extra bytes\n  if (extraBytes === 1) {\n    tmp = uint8[len - 1]\n    output += lookup[tmp >> 2]\n    output += lookup[(tmp << 4) & 0x3F]\n    output += '=='\n  } else if (extraBytes === 2) {\n    tmp = (uint8[len - 2] << 8) + (uint8[len - 1])\n    output += lookup[tmp >> 10]\n    output += lookup[(tmp >> 4) & 0x3F]\n    output += lookup[(tmp << 2) & 0x3F]\n    output += '='\n  }\n\n  parts.push(output)\n\n  return parts.join('')\n}\n\n},{}],4:[function(require,module,exports){\n(function (module, exports) {\n  'use strict';\n\n  // Utils\n  function assert (val, msg) {\n    if (!val) throw new Error(msg || 'Assertion failed');\n  }\n\n  // Could use `inherits` module, but don't want to move from single file\n  // architecture yet.\n  function inherits (ctor, superCtor) {\n    ctor.super_ = superCtor;\n    var TempCtor = function () {};\n    TempCtor.prototype = superCtor.prototype;\n    ctor.prototype = new TempCtor();\n    ctor.prototype.constructor = ctor;\n  }\n\n  // BN\n\n  function BN (number, base, endian) {\n    if (BN.isBN(number)) {\n      return number;\n    }\n\n    this.negative = 0;\n    this.words = null;\n    this.length = 0;\n\n    // Reduction context\n    this.red = null;\n\n    if (number !== null) {\n      if (base === 'le' || base === 'be') {\n        endian = base;\n        base = 10;\n      }\n\n      this._init(number || 0, base || 10, endian || 'be');\n    }\n  }\n  if (typeof module === 'object') {\n    module.exports = BN;\n  } else {\n    exports.BN = BN;\n  }\n\n  BN.BN = BN;\n  BN.wordSize = 26;\n\n  var Buffer;\n  try {\n    Buffer = require('buf' + 'fer').Buffer;\n  } catch (e) {\n  }\n\n  BN.isBN = function isBN (num) {\n    if (num instanceof BN) {\n      return true;\n    }\n\n    return num !== null && typeof num === 'object' &&\n      num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);\n  };\n\n  BN.max = function max (left, right) {\n    if (left.cmp(right) > 0) return left;\n    return right;\n  };\n\n  BN.min = function min (left, right) {\n    if (left.cmp(right) < 0) return left;\n    return right;\n  };\n\n  BN.prototype._init = function init (number, base, endian) {\n    if (typeof number === 'number') {\n      return this._initNumber(number, base, endian);\n    }\n\n    if (typeof number === 'object') {\n      return this._initArray(number, base, endian);\n    }\n\n    if (base === 'hex') {\n      base = 16;\n    }\n    assert(base === (base | 0) && base >= 2 && base <= 36);\n\n    number = number.toString().replace(/\\s+/g, '');\n    var start = 0;\n    if (number[0] === '-') {\n      start++;\n    }\n\n    if (base === 16) {\n      this._parseHex(number, start);\n    } else {\n      this._parseBase(number, base, start);\n    }\n\n    if (number[0] === '-') {\n      this.negative = 1;\n    }\n\n    this.strip();\n\n    if (endian !== 'le') return;\n\n    this._initArray(this.toArray(), base, endian);\n  };\n\n  BN.prototype._initNumber = function _initNumber (number, base, endian) {\n    if (number < 0) {\n      this.negative = 1;\n      number = -number;\n    }\n    if (number < 0x4000000) {\n      this.words = [ number & 0x3ffffff ];\n      this.length = 1;\n    } else if (number < 0x10000000000000) {\n      this.words = [\n        number & 0x3ffffff,\n        (number / 0x4000000) & 0x3ffffff\n      ];\n      this.length = 2;\n    } else {\n      assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)\n      this.words = [\n        number & 0x3ffffff,\n        (number / 0x4000000) & 0x3ffffff,\n        1\n      ];\n      this.length = 3;\n    }\n\n    if (endian !== 'le') return;\n\n    // Reverse the bytes\n    this._initArray(this.toArray(), base, endian);\n  };\n\n  BN.prototype._initArray = function _initArray (number, base, endian) {\n    // Perhaps a Uint8Array\n    assert(typeof number.length === 'number');\n    if (number.length <= 0) {\n      this.words = [ 0 ];\n      this.length = 1;\n      return this;\n    }\n\n    this.length = Math.ceil(number.length / 3);\n    this.words = new Array(this.length);\n    for (var i = 0; i < this.length; i++) {\n      this.words[i] = 0;\n    }\n\n    var j, w;\n    var off = 0;\n    if (endian === 'be') {\n      for (i = number.length - 1, j = 0; i >= 0; i -= 3) {\n        w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);\n        this.words[j] |= (w << off) & 0x3ffffff;\n        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;\n        off += 24;\n        if (off >= 26) {\n          off -= 26;\n          j++;\n        }\n      }\n    } else if (endian === 'le') {\n      for (i = 0, j = 0; i < number.length; i += 3) {\n        w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);\n        this.words[j] |= (w << off) & 0x3ffffff;\n        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;\n        off += 24;\n        if (off >= 26) {\n          off -= 26;\n          j++;\n        }\n      }\n    }\n    return this.strip();\n  };\n\n  function parseHex (str, start, end) {\n    var r = 0;\n    var len = Math.min(str.length, end);\n    for (var i = start; i < len; i++) {\n      var c = str.charCodeAt(i) - 48;\n\n      r <<= 4;\n\n      // 'a' - 'f'\n      if (c >= 49 && c <= 54) {\n        r |= c - 49 + 0xa;\n\n      // 'A' - 'F'\n      } else if (c >= 17 && c <= 22) {\n        r |= c - 17 + 0xa;\n\n      // '0' - '9'\n      } else {\n        r |= c & 0xf;\n      }\n    }\n    return r;\n  }\n\n  BN.prototype._parseHex = function _parseHex (number, start) {\n    // Create possibly bigger array to ensure that it fits the number\n    this.length = Math.ceil((number.length - start) / 6);\n    this.words = new Array(this.length);\n    for (var i = 0; i < this.length; i++) {\n      this.words[i] = 0;\n    }\n\n    var j, w;\n    // Scan 24-bit chunks and add them to the number\n    var off = 0;\n    for (i = number.length - 6, j = 0; i >= start; i -= 6) {\n      w = parseHex(number, i, i + 6);\n      this.words[j] |= (w << off) & 0x3ffffff;\n      // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb\n      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;\n      off += 24;\n      if (off >= 26) {\n        off -= 26;\n        j++;\n      }\n    }\n    if (i + 6 !== start) {\n      w = parseHex(number, start, i + 6);\n      this.words[j] |= (w << off) & 0x3ffffff;\n      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;\n    }\n    this.strip();\n  };\n\n  function parseBase (str, start, end, mul) {\n    var r = 0;\n    var len = Math.min(str.length, end);\n    for (var i = start; i < len; i++) {\n      var c = str.charCodeAt(i) - 48;\n\n      r *= mul;\n\n      // 'a'\n      if (c >= 49) {\n        r += c - 49 + 0xa;\n\n      // 'A'\n      } else if (c >= 17) {\n        r += c - 17 + 0xa;\n\n      // '0' - '9'\n      } else {\n        r += c;\n      }\n    }\n    return r;\n  }\n\n  BN.prototype._parseBase = function _parseBase (number, base, start) {\n    // Initialize as zero\n    this.words = [ 0 ];\n    this.length = 1;\n\n    // Find length of limb in base\n    for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {\n      limbLen++;\n    }\n    limbLen--;\n    limbPow = (limbPow / base) | 0;\n\n    var total = number.length - start;\n    var mod = total % limbLen;\n    var end = Math.min(total, total - mod) + start;\n\n    var word = 0;\n    for (var i = start; i < end; i += limbLen) {\n      word = parseBase(number, i, i + limbLen, base);\n\n      this.imuln(limbPow);\n      if (this.words[0] + word < 0x4000000) {\n        this.words[0] += word;\n      } else {\n        this._iaddn(word);\n      }\n    }\n\n    if (mod !== 0) {\n      var pow = 1;\n      word = parseBase(number, i, number.length, base);\n\n      for (i = 0; i < mod; i++) {\n        pow *= base;\n      }\n\n      this.imuln(pow);\n      if (this.words[0] + word < 0x4000000) {\n        this.words[0] += word;\n      } else {\n        this._iaddn(word);\n      }\n    }\n  };\n\n  BN.prototype.copy = function copy (dest) {\n    dest.words = new Array(this.length);\n    for (var i = 0; i < this.length; i++) {\n      dest.words[i] = this.words[i];\n    }\n    dest.length = this.length;\n    dest.negative = this.negative;\n    dest.red = this.red;\n  };\n\n  BN.prototype.clone = function clone () {\n    var r = new BN(null);\n    this.copy(r);\n    return r;\n  };\n\n  BN.prototype._expand = function _expand (size) {\n    while (this.length < size) {\n      this.words[this.length++] = 0;\n    }\n    return this;\n  };\n\n  // Remove leading `0` from `this`\n  BN.prototype.strip = function strip () {\n    while (this.length > 1 && this.words[this.length - 1] === 0) {\n      this.length--;\n    }\n    return this._normSign();\n  };\n\n  BN.prototype._normSign = function _normSign () {\n    // -0 = 0\n    if (this.length === 1 && this.words[0] === 0) {\n      this.negative = 0;\n    }\n    return this;\n  };\n\n  BN.prototype.inspect = function inspect () {\n    return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';\n  };\n\n  /*\n\n  var zeros = [];\n  var groupSizes = [];\n  var groupBases = [];\n\n  var s = '';\n  var i = -1;\n  while (++i < BN.wordSize) {\n    zeros[i] = s;\n    s += '0';\n  }\n  groupSizes[0] = 0;\n  groupSizes[1] = 0;\n  groupBases[0] = 0;\n  groupBases[1] = 0;\n  var base = 2 - 1;\n  while (++base < 36 + 1) {\n    var groupSize = 0;\n    var groupBase = 1;\n    while (groupBase < (1 << BN.wordSize) / base) {\n      groupBase *= base;\n      groupSize += 1;\n    }\n    groupSizes[base] = groupSize;\n    groupBases[base] = groupBase;\n  }\n\n  */\n\n  var zeros = [\n    '',\n    '0',\n    '00',\n    '000',\n    '0000',\n    '00000',\n    '000000',\n    '0000000',\n    '00000000',\n    '000000000',\n    '0000000000',\n    '00000000000',\n    '000000000000',\n    '0000000000000',\n    '00000000000000',\n    '000000000000000',\n    '0000000000000000',\n    '00000000000000000',\n    '000000000000000000',\n    '0000000000000000000',\n    '00000000000000000000',\n    '000000000000000000000',\n    '0000000000000000000000',\n    '00000000000000000000000',\n    '000000000000000000000000',\n    '0000000000000000000000000'\n  ];\n\n  var groupSizes = [\n    0, 0,\n    25, 16, 12, 11, 10, 9, 8,\n    8, 7, 7, 7, 7, 6, 6,\n    6, 6, 6, 6, 6, 5, 5,\n    5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 5, 5, 5, 5\n  ];\n\n  var groupBases = [\n    0, 0,\n    33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,\n    43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,\n    16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,\n    6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,\n    24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176\n  ];\n\n  BN.prototype.toString = function toString (base, padding) {\n    base = base || 10;\n    padding = padding | 0 || 1;\n\n    var out;\n    if (base === 16 || base === 'hex') {\n      out = '';\n      var off = 0;\n      var carry = 0;\n      for (var i = 0; i < this.length; i++) {\n        var w = this.words[i];\n        var word = (((w << off) | carry) & 0xffffff).toString(16);\n        carry = (w >>> (24 - off)) & 0xffffff;\n        if (carry !== 0 || i !== this.length - 1) {\n          out = zeros[6 - word.length] + word + out;\n        } else {\n          out = word + out;\n        }\n        off += 2;\n        if (off >= 26) {\n          off -= 26;\n          i--;\n        }\n      }\n      if (carry !== 0) {\n        out = carry.toString(16) + out;\n      }\n      while (out.length % padding !== 0) {\n        out = '0' + out;\n      }\n      if (this.negative !== 0) {\n        out = '-' + out;\n      }\n      return out;\n    }\n\n    if (base === (base | 0) && base >= 2 && base <= 36) {\n      // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));\n      var groupSize = groupSizes[base];\n      // var groupBase = Math.pow(base, groupSize);\n      var groupBase = groupBases[base];\n      out = '';\n      var c = this.clone();\n      c.negative = 0;\n      while (!c.isZero()) {\n        var r = c.modn(groupBase).toString(base);\n        c = c.idivn(groupBase);\n\n        if (!c.isZero()) {\n          out = zeros[groupSize - r.length] + r + out;\n        } else {\n          out = r + out;\n        }\n      }\n      if (this.isZero()) {\n        out = '0' + out;\n      }\n      while (out.length % padding !== 0) {\n        out = '0' + out;\n      }\n      if (this.negative !== 0) {\n        out = '-' + out;\n      }\n      return out;\n    }\n\n    assert(false, 'Base should be between 2 and 36');\n  };\n\n  BN.prototype.toNumber = function toNumber () {\n    var ret = this.words[0];\n    if (this.length === 2) {\n      ret += this.words[1] * 0x4000000;\n    } else if (this.length === 3 && this.words[2] === 0x01) {\n      // NOTE: at this stage it is known that the top bit is set\n      ret += 0x10000000000000 + (this.words[1] * 0x4000000);\n    } else if (this.length > 2) {\n      assert(false, 'Number can only safely store up to 53 bits');\n    }\n    return (this.negative !== 0) ? -ret : ret;\n  };\n\n  BN.prototype.toJSON = function toJSON () {\n    return this.toString(16);\n  };\n\n  BN.prototype.toBuffer = function toBuffer (endian, length) {\n    assert(typeof Buffer !== 'undefined');\n    return this.toArrayLike(Buffer, endian, length);\n  };\n\n  BN.prototype.toArray = function toArray (endian, length) {\n    return this.toArrayLike(Array, endian, length);\n  };\n\n  BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {\n    var byteLength = this.byteLength();\n    var reqLength = length || Math.max(1, byteLength);\n    assert(byteLength <= reqLength, 'byte array longer than desired length');\n    assert(reqLength > 0, 'Requested array length <= 0');\n\n    this.strip();\n    var littleEndian = endian === 'le';\n    var res = new ArrayType(reqLength);\n\n    var b, i;\n    var q = this.clone();\n    if (!littleEndian) {\n      // Assume big-endian\n      for (i = 0; i < reqLength - byteLength; i++) {\n        res[i] = 0;\n      }\n\n      for (i = 0; !q.isZero(); i++) {\n        b = q.andln(0xff);\n        q.iushrn(8);\n\n        res[reqLength - i - 1] = b;\n      }\n    } else {\n      for (i = 0; !q.isZero(); i++) {\n        b = q.andln(0xff);\n        q.iushrn(8);\n\n        res[i] = b;\n      }\n\n      for (; i < reqLength; i++) {\n        res[i] = 0;\n      }\n    }\n\n    return res;\n  };\n\n  if (Math.clz32) {\n    BN.prototype._countBits = function _countBits (w) {\n      return 32 - Math.clz32(w);\n    };\n  } else {\n    BN.prototype._countBits = function _countBits (w) {\n      var t = w;\n      var r = 0;\n      if (t >= 0x1000) {\n        r += 13;\n        t >>>= 13;\n      }\n      if (t >= 0x40) {\n        r += 7;\n        t >>>= 7;\n      }\n      if (t >= 0x8) {\n        r += 4;\n        t >>>= 4;\n      }\n      if (t >= 0x02) {\n        r += 2;\n        t >>>= 2;\n      }\n      return r + t;\n    };\n  }\n\n  BN.prototype._zeroBits = function _zeroBits (w) {\n    // Short-cut\n    if (w === 0) return 26;\n\n    var t = w;\n    var r = 0;\n    if ((t & 0x1fff) === 0) {\n      r += 13;\n      t >>>= 13;\n    }\n    if ((t & 0x7f) === 0) {\n      r += 7;\n      t >>>= 7;\n    }\n    if ((t & 0xf) === 0) {\n      r += 4;\n      t >>>= 4;\n    }\n    if ((t & 0x3) === 0) {\n      r += 2;\n      t >>>= 2;\n    }\n    if ((t & 0x1) === 0) {\n      r++;\n    }\n    return r;\n  };\n\n  // Return number of used bits in a BN\n  BN.prototype.bitLength = function bitLength () {\n    var w = this.words[this.length - 1];\n    var hi = this._countBits(w);\n    return (this.length - 1) * 26 + hi;\n  };\n\n  function toBitArray (num) {\n    var w = new Array(num.bitLength());\n\n    for (var bit = 0; bit < w.length; bit++) {\n      var off = (bit / 26) | 0;\n      var wbit = bit % 26;\n\n      w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;\n    }\n\n    return w;\n  }\n\n  // Number of trailing zero bits\n  BN.prototype.zeroBits = function zeroBits () {\n    if (this.isZero()) return 0;\n\n    var r = 0;\n    for (var i = 0; i < this.length; i++) {\n      var b = this._zeroBits(this.words[i]);\n      r += b;\n      if (b !== 26) break;\n    }\n    return r;\n  };\n\n  BN.prototype.byteLength = function byteLength () {\n    return Math.ceil(this.bitLength() / 8);\n  };\n\n  BN.prototype.toTwos = function toTwos (width) {\n    if (this.negative !== 0) {\n      return this.abs().inotn(width).iaddn(1);\n    }\n    return this.clone();\n  };\n\n  BN.prototype.fromTwos = function fromTwos (width) {\n    if (this.testn(width - 1)) {\n      return this.notn(width).iaddn(1).ineg();\n    }\n    return this.clone();\n  };\n\n  BN.prototype.isNeg = function isNeg () {\n    return this.negative !== 0;\n  };\n\n  // Return negative clone of `this`\n  BN.prototype.neg = function neg () {\n    return this.clone().ineg();\n  };\n\n  BN.prototype.ineg = function ineg () {\n    if (!this.isZero()) {\n      this.negative ^= 1;\n    }\n\n    return this;\n  };\n\n  // Or `num` with `this` in-place\n  BN.prototype.iuor = function iuor (num) {\n    while (this.length < num.length) {\n      this.words[this.length++] = 0;\n    }\n\n    for (var i = 0; i < num.length; i++) {\n      this.words[i] = this.words[i] | num.words[i];\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.ior = function ior (num) {\n    assert((this.negative | num.negative) === 0);\n    return this.iuor(num);\n  };\n\n  // Or `num` with `this`\n  BN.prototype.or = function or (num) {\n    if (this.length > num.length) return this.clone().ior(num);\n    return num.clone().ior(this);\n  };\n\n  BN.prototype.uor = function uor (num) {\n    if (this.length > num.length) return this.clone().iuor(num);\n    return num.clone().iuor(this);\n  };\n\n  // And `num` with `this` in-place\n  BN.prototype.iuand = function iuand (num) {\n    // b = min-length(num, this)\n    var b;\n    if (this.length > num.length) {\n      b = num;\n    } else {\n      b = this;\n    }\n\n    for (var i = 0; i < b.length; i++) {\n      this.words[i] = this.words[i] & num.words[i];\n    }\n\n    this.length = b.length;\n\n    return this.strip();\n  };\n\n  BN.prototype.iand = function iand (num) {\n    assert((this.negative | num.negative) === 0);\n    return this.iuand(num);\n  };\n\n  // And `num` with `this`\n  BN.prototype.and = function and (num) {\n    if (this.length > num.length) return this.clone().iand(num);\n    return num.clone().iand(this);\n  };\n\n  BN.prototype.uand = function uand (num) {\n    if (this.length > num.length) return this.clone().iuand(num);\n    return num.clone().iuand(this);\n  };\n\n  // Xor `num` with `this` in-place\n  BN.prototype.iuxor = function iuxor (num) {\n    // a.length > b.length\n    var a;\n    var b;\n    if (this.length > num.length) {\n      a = this;\n      b = num;\n    } else {\n      a = num;\n      b = this;\n    }\n\n    for (var i = 0; i < b.length; i++) {\n      this.words[i] = a.words[i] ^ b.words[i];\n    }\n\n    if (this !== a) {\n      for (; i < a.length; i++) {\n        this.words[i] = a.words[i];\n      }\n    }\n\n    this.length = a.length;\n\n    return this.strip();\n  };\n\n  BN.prototype.ixor = function ixor (num) {\n    assert((this.negative | num.negative) === 0);\n    return this.iuxor(num);\n  };\n\n  // Xor `num` with `this`\n  BN.prototype.xor = function xor (num) {\n    if (this.length > num.length) return this.clone().ixor(num);\n    return num.clone().ixor(this);\n  };\n\n  BN.prototype.uxor = function uxor (num) {\n    if (this.length > num.length) return this.clone().iuxor(num);\n    return num.clone().iuxor(this);\n  };\n\n  // Not ``this`` with ``width`` bitwidth\n  BN.prototype.inotn = function inotn (width) {\n    assert(typeof width === 'number' && width >= 0);\n\n    var bytesNeeded = Math.ceil(width / 26) | 0;\n    var bitsLeft = width % 26;\n\n    // Extend the buffer with leading zeroes\n    this._expand(bytesNeeded);\n\n    if (bitsLeft > 0) {\n      bytesNeeded--;\n    }\n\n    // Handle complete words\n    for (var i = 0; i < bytesNeeded; i++) {\n      this.words[i] = ~this.words[i] & 0x3ffffff;\n    }\n\n    // Handle the residue\n    if (bitsLeft > 0) {\n      this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));\n    }\n\n    // And remove leading zeroes\n    return this.strip();\n  };\n\n  BN.prototype.notn = function notn (width) {\n    return this.clone().inotn(width);\n  };\n\n  // Set `bit` of `this`\n  BN.prototype.setn = function setn (bit, val) {\n    assert(typeof bit === 'number' && bit >= 0);\n\n    var off = (bit / 26) | 0;\n    var wbit = bit % 26;\n\n    this._expand(off + 1);\n\n    if (val) {\n      this.words[off] = this.words[off] | (1 << wbit);\n    } else {\n      this.words[off] = this.words[off] & ~(1 << wbit);\n    }\n\n    return this.strip();\n  };\n\n  // Add `num` to `this` in-place\n  BN.prototype.iadd = function iadd (num) {\n    var r;\n\n    // negative + positive\n    if (this.negative !== 0 && num.negative === 0) {\n      this.negative = 0;\n      r = this.isub(num);\n      this.negative ^= 1;\n      return this._normSign();\n\n    // positive + negative\n    } else if (this.negative === 0 && num.negative !== 0) {\n      num.negative = 0;\n      r = this.isub(num);\n      num.negative = 1;\n      return r._normSign();\n    }\n\n    // a.length > b.length\n    var a, b;\n    if (this.length > num.length) {\n      a = this;\n      b = num;\n    } else {\n      a = num;\n      b = this;\n    }\n\n    var carry = 0;\n    for (var i = 0; i < b.length; i++) {\n      r = (a.words[i] | 0) + (b.words[i] | 0) + carry;\n      this.words[i] = r & 0x3ffffff;\n      carry = r >>> 26;\n    }\n    for (; carry !== 0 && i < a.length; i++) {\n      r = (a.words[i] | 0) + carry;\n      this.words[i] = r & 0x3ffffff;\n      carry = r >>> 26;\n    }\n\n    this.length = a.length;\n    if (carry !== 0) {\n      this.words[this.length] = carry;\n      this.length++;\n    // Copy the rest of the words\n    } else if (a !== this) {\n      for (; i < a.length; i++) {\n        this.words[i] = a.words[i];\n      }\n    }\n\n    return this;\n  };\n\n  // Add `num` to `this`\n  BN.prototype.add = function add (num) {\n    var res;\n    if (num.negative !== 0 && this.negative === 0) {\n      num.negative = 0;\n      res = this.sub(num);\n      num.negative ^= 1;\n      return res;\n    } else if (num.negative === 0 && this.negative !== 0) {\n      this.negative = 0;\n      res = num.sub(this);\n      this.negative = 1;\n      return res;\n    }\n\n    if (this.length > num.length) return this.clone().iadd(num);\n\n    return num.clone().iadd(this);\n  };\n\n  // Subtract `num` from `this` in-place\n  BN.prototype.isub = function isub (num) {\n    // this - (-num) = this + num\n    if (num.negative !== 0) {\n      num.negative = 0;\n      var r = this.iadd(num);\n      num.negative = 1;\n      return r._normSign();\n\n    // -this - num = -(this + num)\n    } else if (this.negative !== 0) {\n      this.negative = 0;\n      this.iadd(num);\n      this.negative = 1;\n      return this._normSign();\n    }\n\n    // At this point both numbers are positive\n    var cmp = this.cmp(num);\n\n    // Optimization - zeroify\n    if (cmp === 0) {\n      this.negative = 0;\n      this.length = 1;\n      this.words[0] = 0;\n      return this;\n    }\n\n    // a > b\n    var a, b;\n    if (cmp > 0) {\n      a = this;\n      b = num;\n    } else {\n      a = num;\n      b = this;\n    }\n\n    var carry = 0;\n    for (var i = 0; i < b.length; i++) {\n      r = (a.words[i] | 0) - (b.words[i] | 0) + carry;\n      carry = r >> 26;\n      this.words[i] = r & 0x3ffffff;\n    }\n    for (; carry !== 0 && i < a.length; i++) {\n      r = (a.words[i] | 0) + carry;\n      carry = r >> 26;\n      this.words[i] = r & 0x3ffffff;\n    }\n\n    // Copy rest of the words\n    if (carry === 0 && i < a.length && a !== this) {\n      for (; i < a.length; i++) {\n        this.words[i] = a.words[i];\n      }\n    }\n\n    this.length = Math.max(this.length, i);\n\n    if (a !== this) {\n      this.negative = 1;\n    }\n\n    return this.strip();\n  };\n\n  // Subtract `num` from `this`\n  BN.prototype.sub = function sub (num) {\n    return this.clone().isub(num);\n  };\n\n  function smallMulTo (self, num, out) {\n    out.negative = num.negative ^ self.negative;\n    var len = (self.length + num.length) | 0;\n    out.length = len;\n    len = (len - 1) | 0;\n\n    // Peel one iteration (compiler can't do it, because of code complexity)\n    var a = self.words[0] | 0;\n    var b = num.words[0] | 0;\n    var r = a * b;\n\n    var lo = r & 0x3ffffff;\n    var carry = (r / 0x4000000) | 0;\n    out.words[0] = lo;\n\n    for (var k = 1; k < len; k++) {\n      // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n      // note that ncarry could be >= 0x3ffffff\n      var ncarry = carry >>> 26;\n      var rword = carry & 0x3ffffff;\n      var maxJ = Math.min(k, num.length - 1);\n      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {\n        var i = (k - j) | 0;\n        a = self.words[i] | 0;\n        b = num.words[j] | 0;\n        r = a * b + rword;\n        ncarry += (r / 0x4000000) | 0;\n        rword = r & 0x3ffffff;\n      }\n      out.words[k] = rword | 0;\n      carry = ncarry | 0;\n    }\n    if (carry !== 0) {\n      out.words[k] = carry | 0;\n    } else {\n      out.length--;\n    }\n\n    return out.strip();\n  }\n\n  // TODO(indutny): it may be reasonable to omit it for users who don't need\n  // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit\n  // multiplication (like elliptic secp256k1).\n  var comb10MulTo = function comb10MulTo (self, num, out) {\n    var a = self.words;\n    var b = num.words;\n    var o = out.words;\n    var c = 0;\n    var lo;\n    var mid;\n    var hi;\n    var a0 = a[0] | 0;\n    var al0 = a0 & 0x1fff;\n    var ah0 = a0 >>> 13;\n    var a1 = a[1] | 0;\n    var al1 = a1 & 0x1fff;\n    var ah1 = a1 >>> 13;\n    var a2 = a[2] | 0;\n    var al2 = a2 & 0x1fff;\n    var ah2 = a2 >>> 13;\n    var a3 = a[3] | 0;\n    var al3 = a3 & 0x1fff;\n    var ah3 = a3 >>> 13;\n    var a4 = a[4] | 0;\n    var al4 = a4 & 0x1fff;\n    var ah4 = a4 >>> 13;\n    var a5 = a[5] | 0;\n    var al5 = a5 & 0x1fff;\n    var ah5 = a5 >>> 13;\n    var a6 = a[6] | 0;\n    var al6 = a6 & 0x1fff;\n    var ah6 = a6 >>> 13;\n    var a7 = a[7] | 0;\n    var al7 = a7 & 0x1fff;\n    var ah7 = a7 >>> 13;\n    var a8 = a[8] | 0;\n    var al8 = a8 & 0x1fff;\n    var ah8 = a8 >>> 13;\n    var a9 = a[9] | 0;\n    var al9 = a9 & 0x1fff;\n    var ah9 = a9 >>> 13;\n    var b0 = b[0] | 0;\n    var bl0 = b0 & 0x1fff;\n    var bh0 = b0 >>> 13;\n    var b1 = b[1] | 0;\n    var bl1 = b1 & 0x1fff;\n    var bh1 = b1 >>> 13;\n    var b2 = b[2] | 0;\n    var bl2 = b2 & 0x1fff;\n    var bh2 = b2 >>> 13;\n    var b3 = b[3] | 0;\n    var bl3 = b3 & 0x1fff;\n    var bh3 = b3 >>> 13;\n    var b4 = b[4] | 0;\n    var bl4 = b4 & 0x1fff;\n    var bh4 = b4 >>> 13;\n    var b5 = b[5] | 0;\n    var bl5 = b5 & 0x1fff;\n    var bh5 = b5 >>> 13;\n    var b6 = b[6] | 0;\n    var bl6 = b6 & 0x1fff;\n    var bh6 = b6 >>> 13;\n    var b7 = b[7] | 0;\n    var bl7 = b7 & 0x1fff;\n    var bh7 = b7 >>> 13;\n    var b8 = b[8] | 0;\n    var bl8 = b8 & 0x1fff;\n    var bh8 = b8 >>> 13;\n    var b9 = b[9] | 0;\n    var bl9 = b9 & 0x1fff;\n    var bh9 = b9 >>> 13;\n\n    out.negative = self.negative ^ num.negative;\n    out.length = 19;\n    /* k = 0 */\n    lo = Math.imul(al0, bl0);\n    mid = Math.imul(al0, bh0);\n    mid = (mid + Math.imul(ah0, bl0)) | 0;\n    hi = Math.imul(ah0, bh0);\n    var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;\n    w0 &= 0x3ffffff;\n    /* k = 1 */\n    lo = Math.imul(al1, bl0);\n    mid = Math.imul(al1, bh0);\n    mid = (mid + Math.imul(ah1, bl0)) | 0;\n    hi = Math.imul(ah1, bh0);\n    lo = (lo + Math.imul(al0, bl1)) | 0;\n    mid = (mid + Math.imul(al0, bh1)) | 0;\n    mid = (mid + Math.imul(ah0, bl1)) | 0;\n    hi = (hi + Math.imul(ah0, bh1)) | 0;\n    var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;\n    w1 &= 0x3ffffff;\n    /* k = 2 */\n    lo = Math.imul(al2, bl0);\n    mid = Math.imul(al2, bh0);\n    mid = (mid + Math.imul(ah2, bl0)) | 0;\n    hi = Math.imul(ah2, bh0);\n    lo = (lo + Math.imul(al1, bl1)) | 0;\n    mid = (mid + Math.imul(al1, bh1)) | 0;\n    mid = (mid + Math.imul(ah1, bl1)) | 0;\n    hi = (hi + Math.imul(ah1, bh1)) | 0;\n    lo = (lo + Math.imul(al0, bl2)) | 0;\n    mid = (mid + Math.imul(al0, bh2)) | 0;\n    mid = (mid + Math.imul(ah0, bl2)) | 0;\n    hi = (hi + Math.imul(ah0, bh2)) | 0;\n    var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;\n    w2 &= 0x3ffffff;\n    /* k = 3 */\n    lo = Math.imul(al3, bl0);\n    mid = Math.imul(al3, bh0);\n    mid = (mid + Math.imul(ah3, bl0)) | 0;\n    hi = Math.imul(ah3, bh0);\n    lo = (lo + Math.imul(al2, bl1)) | 0;\n    mid = (mid + Math.imul(al2, bh1)) | 0;\n    mid = (mid + Math.imul(ah2, bl1)) | 0;\n    hi = (hi + Math.imul(ah2, bh1)) | 0;\n    lo = (lo + Math.imul(al1, bl2)) | 0;\n    mid = (mid + Math.imul(al1, bh2)) | 0;\n    mid = (mid + Math.imul(ah1, bl2)) | 0;\n    hi = (hi + Math.imul(ah1, bh2)) | 0;\n    lo = (lo + Math.imul(al0, bl3)) | 0;\n    mid = (mid + Math.imul(al0, bh3)) | 0;\n    mid = (mid + Math.imul(ah0, bl3)) | 0;\n    hi = (hi + Math.imul(ah0, bh3)) | 0;\n    var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;\n    w3 &= 0x3ffffff;\n    /* k = 4 */\n    lo = Math.imul(al4, bl0);\n    mid = Math.imul(al4, bh0);\n    mid = (mid + Math.imul(ah4, bl0)) | 0;\n    hi = Math.imul(ah4, bh0);\n    lo = (lo + Math.imul(al3, bl1)) | 0;\n    mid = (mid + Math.imul(al3, bh1)) | 0;\n    mid = (mid + Math.imul(ah3, bl1)) | 0;\n    hi = (hi + Math.imul(ah3, bh1)) | 0;\n    lo = (lo + Math.imul(al2, bl2)) | 0;\n    mid = (mid + Math.imul(al2, bh2)) | 0;\n    mid = (mid + Math.imul(ah2, bl2)) | 0;\n    hi = (hi + Math.imul(ah2, bh2)) | 0;\n    lo = (lo + Math.imul(al1, bl3)) | 0;\n    mid = (mid + Math.imul(al1, bh3)) | 0;\n    mid = (mid + Math.imul(ah1, bl3)) | 0;\n    hi = (hi + Math.imul(ah1, bh3)) | 0;\n    lo = (lo + Math.imul(al0, bl4)) | 0;\n    mid = (mid + Math.imul(al0, bh4)) | 0;\n    mid = (mid + Math.imul(ah0, bl4)) | 0;\n    hi = (hi + Math.imul(ah0, bh4)) | 0;\n    var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;\n    w4 &= 0x3ffffff;\n    /* k = 5 */\n    lo = Math.imul(al5, bl0);\n    mid = Math.imul(al5, bh0);\n    mid = (mid + Math.imul(ah5, bl0)) | 0;\n    hi = Math.imul(ah5, bh0);\n    lo = (lo + Math.imul(al4, bl1)) | 0;\n    mid = (mid + Math.imul(al4, bh1)) | 0;\n    mid = (mid + Math.imul(ah4, bl1)) | 0;\n    hi = (hi + Math.imul(ah4, bh1)) | 0;\n    lo = (lo + Math.imul(al3, bl2)) | 0;\n    mid = (mid + Math.imul(al3, bh2)) | 0;\n    mid = (mid + Math.imul(ah3, bl2)) | 0;\n    hi = (hi + Math.imul(ah3, bh2)) | 0;\n    lo = (lo + Math.imul(al2, bl3)) | 0;\n    mid = (mid + Math.imul(al2, bh3)) | 0;\n    mid = (mid + Math.imul(ah2, bl3)) | 0;\n    hi = (hi + Math.imul(ah2, bh3)) | 0;\n    lo = (lo + Math.imul(al1, bl4)) | 0;\n    mid = (mid + Math.imul(al1, bh4)) | 0;\n    mid = (mid + Math.imul(ah1, bl4)) | 0;\n    hi = (hi + Math.imul(ah1, bh4)) | 0;\n    lo = (lo + Math.imul(al0, bl5)) | 0;\n    mid = (mid + Math.imul(al0, bh5)) | 0;\n    mid = (mid + Math.imul(ah0, bl5)) | 0;\n    hi = (hi + Math.imul(ah0, bh5)) | 0;\n    var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;\n    w5 &= 0x3ffffff;\n    /* k = 6 */\n    lo = Math.imul(al6, bl0);\n    mid = Math.imul(al6, bh0);\n    mid = (mid + Math.imul(ah6, bl0)) | 0;\n    hi = Math.imul(ah6, bh0);\n    lo = (lo + Math.imul(al5, bl1)) | 0;\n    mid = (mid + Math.imul(al5, bh1)) | 0;\n    mid = (mid + Math.imul(ah5, bl1)) | 0;\n    hi = (hi + Math.imul(ah5, bh1)) | 0;\n    lo = (lo + Math.imul(al4, bl2)) | 0;\n    mid = (mid + Math.imul(al4, bh2)) | 0;\n    mid = (mid + Math.imul(ah4, bl2)) | 0;\n    hi = (hi + Math.imul(ah4, bh2)) | 0;\n    lo = (lo + Math.imul(al3, bl3)) | 0;\n    mid = (mid + Math.imul(al3, bh3)) | 0;\n    mid = (mid + Math.imul(ah3, bl3)) | 0;\n    hi = (hi + Math.imul(ah3, bh3)) | 0;\n    lo = (lo + Math.imul(al2, bl4)) | 0;\n    mid = (mid + Math.imul(al2, bh4)) | 0;\n    mid = (mid + Math.imul(ah2, bl4)) | 0;\n    hi = (hi + Math.imul(ah2, bh4)) | 0;\n    lo = (lo + Math.imul(al1, bl5)) | 0;\n    mid = (mid + Math.imul(al1, bh5)) | 0;\n    mid = (mid + Math.imul(ah1, bl5)) | 0;\n    hi = (hi + Math.imul(ah1, bh5)) | 0;\n    lo = (lo + Math.imul(al0, bl6)) | 0;\n    mid = (mid + Math.imul(al0, bh6)) | 0;\n    mid = (mid + Math.imul(ah0, bl6)) | 0;\n    hi = (hi + Math.imul(ah0, bh6)) | 0;\n    var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;\n    w6 &= 0x3ffffff;\n    /* k = 7 */\n    lo = Math.imul(al7, bl0);\n    mid = Math.imul(al7, bh0);\n    mid = (mid + Math.imul(ah7, bl0)) | 0;\n    hi = Math.imul(ah7, bh0);\n    lo = (lo + Math.imul(al6, bl1)) | 0;\n    mid = (mid + Math.imul(al6, bh1)) | 0;\n    mid = (mid + Math.imul(ah6, bl1)) | 0;\n    hi = (hi + Math.imul(ah6, bh1)) | 0;\n    lo = (lo + Math.imul(al5, bl2)) | 0;\n    mid = (mid + Math.imul(al5, bh2)) | 0;\n    mid = (mid + Math.imul(ah5, bl2)) | 0;\n    hi = (hi + Math.imul(ah5, bh2)) | 0;\n    lo = (lo + Math.imul(al4, bl3)) | 0;\n    mid = (mid + Math.imul(al4, bh3)) | 0;\n    mid = (mid + Math.imul(ah4, bl3)) | 0;\n    hi = (hi + Math.imul(ah4, bh3)) | 0;\n    lo = (lo + Math.imul(al3, bl4)) | 0;\n    mid = (mid + Math.imul(al3, bh4)) | 0;\n    mid = (mid + Math.imul(ah3, bl4)) | 0;\n    hi = (hi + Math.imul(ah3, bh4)) | 0;\n    lo = (lo + Math.imul(al2, bl5)) | 0;\n    mid = (mid + Math.imul(al2, bh5)) | 0;\n    mid = (mid + Math.imul(ah2, bl5)) | 0;\n    hi = (hi + Math.imul(ah2, bh5)) | 0;\n    lo = (lo + Math.imul(al1, bl6)) | 0;\n    mid = (mid + Math.imul(al1, bh6)) | 0;\n    mid = (mid + Math.imul(ah1, bl6)) | 0;\n    hi = (hi + Math.imul(ah1, bh6)) | 0;\n    lo = (lo + Math.imul(al0, bl7)) | 0;\n    mid = (mid + Math.imul(al0, bh7)) | 0;\n    mid = (mid + Math.imul(ah0, bl7)) | 0;\n    hi = (hi + Math.imul(ah0, bh7)) | 0;\n    var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;\n    w7 &= 0x3ffffff;\n    /* k = 8 */\n    lo = Math.imul(al8, bl0);\n    mid = Math.imul(al8, bh0);\n    mid = (mid + Math.imul(ah8, bl0)) | 0;\n    hi = Math.imul(ah8, bh0);\n    lo = (lo + Math.imul(al7, bl1)) | 0;\n    mid = (mid + Math.imul(al7, bh1)) | 0;\n    mid = (mid + Math.imul(ah7, bl1)) | 0;\n    hi = (hi + Math.imul(ah7, bh1)) | 0;\n    lo = (lo + Math.imul(al6, bl2)) | 0;\n    mid = (mid + Math.imul(al6, bh2)) | 0;\n    mid = (mid + Math.imul(ah6, bl2)) | 0;\n    hi = (hi + Math.imul(ah6, bh2)) | 0;\n    lo = (lo + Math.imul(al5, bl3)) | 0;\n    mid = (mid + Math.imul(al5, bh3)) | 0;\n    mid = (mid + Math.imul(ah5, bl3)) | 0;\n    hi = (hi + Math.imul(ah5, bh3)) | 0;\n    lo = (lo + Math.imul(al4, bl4)) | 0;\n    mid = (mid + Math.imul(al4, bh4)) | 0;\n    mid = (mid + Math.imul(ah4, bl4)) | 0;\n    hi = (hi + Math.imul(ah4, bh4)) | 0;\n    lo = (lo + Math.imul(al3, bl5)) | 0;\n    mid = (mid + Math.imul(al3, bh5)) | 0;\n    mid = (mid + Math.imul(ah3, bl5)) | 0;\n    hi = (hi + Math.imul(ah3, bh5)) | 0;\n    lo = (lo + Math.imul(al2, bl6)) | 0;\n    mid = (mid + Math.imul(al2, bh6)) | 0;\n    mid = (mid + Math.imul(ah2, bl6)) | 0;\n    hi = (hi + Math.imul(ah2, bh6)) | 0;\n    lo = (lo + Math.imul(al1, bl7)) | 0;\n    mid = (mid + Math.imul(al1, bh7)) | 0;\n    mid = (mid + Math.imul(ah1, bl7)) | 0;\n    hi = (hi + Math.imul(ah1, bh7)) | 0;\n    lo = (lo + Math.imul(al0, bl8)) | 0;\n    mid = (mid + Math.imul(al0, bh8)) | 0;\n    mid = (mid + Math.imul(ah0, bl8)) | 0;\n    hi = (hi + Math.imul(ah0, bh8)) | 0;\n    var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;\n    w8 &= 0x3ffffff;\n    /* k = 9 */\n    lo = Math.imul(al9, bl0);\n    mid = Math.imul(al9, bh0);\n    mid = (mid + Math.imul(ah9, bl0)) | 0;\n    hi = Math.imul(ah9, bh0);\n    lo = (lo + Math.imul(al8, bl1)) | 0;\n    mid = (mid + Math.imul(al8, bh1)) | 0;\n    mid = (mid + Math.imul(ah8, bl1)) | 0;\n    hi = (hi + Math.imul(ah8, bh1)) | 0;\n    lo = (lo + Math.imul(al7, bl2)) | 0;\n    mid = (mid + Math.imul(al7, bh2)) | 0;\n    mid = (mid + Math.imul(ah7, bl2)) | 0;\n    hi = (hi + Math.imul(ah7, bh2)) | 0;\n    lo = (lo + Math.imul(al6, bl3)) | 0;\n    mid = (mid + Math.imul(al6, bh3)) | 0;\n    mid = (mid + Math.imul(ah6, bl3)) | 0;\n    hi = (hi + Math.imul(ah6, bh3)) | 0;\n    lo = (lo + Math.imul(al5, bl4)) | 0;\n    mid = (mid + Math.imul(al5, bh4)) | 0;\n    mid = (mid + Math.imul(ah5, bl4)) | 0;\n    hi = (hi + Math.imul(ah5, bh4)) | 0;\n    lo = (lo + Math.imul(al4, bl5)) | 0;\n    mid = (mid + Math.imul(al4, bh5)) | 0;\n    mid = (mid + Math.imul(ah4, bl5)) | 0;\n    hi = (hi + Math.imul(ah4, bh5)) | 0;\n    lo = (lo + Math.imul(al3, bl6)) | 0;\n    mid = (mid + Math.imul(al3, bh6)) | 0;\n    mid = (mid + Math.imul(ah3, bl6)) | 0;\n    hi = (hi + Math.imul(ah3, bh6)) | 0;\n    lo = (lo + Math.imul(al2, bl7)) | 0;\n    mid = (mid + Math.imul(al2, bh7)) | 0;\n    mid = (mid + Math.imul(ah2, bl7)) | 0;\n    hi = (hi + Math.imul(ah2, bh7)) | 0;\n    lo = (lo + Math.imul(al1, bl8)) | 0;\n    mid = (mid + Math.imul(al1, bh8)) | 0;\n    mid = (mid + Math.imul(ah1, bl8)) | 0;\n    hi = (hi + Math.imul(ah1, bh8)) | 0;\n    lo = (lo + Math.imul(al0, bl9)) | 0;\n    mid = (mid + Math.imul(al0, bh9)) | 0;\n    mid = (mid + Math.imul(ah0, bl9)) | 0;\n    hi = (hi + Math.imul(ah0, bh9)) | 0;\n    var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;\n    w9 &= 0x3ffffff;\n    /* k = 10 */\n    lo = Math.imul(al9, bl1);\n    mid = Math.imul(al9, bh1);\n    mid = (mid + Math.imul(ah9, bl1)) | 0;\n    hi = Math.imul(ah9, bh1);\n    lo = (lo + Math.imul(al8, bl2)) | 0;\n    mid = (mid + Math.imul(al8, bh2)) | 0;\n    mid = (mid + Math.imul(ah8, bl2)) | 0;\n    hi = (hi + Math.imul(ah8, bh2)) | 0;\n    lo = (lo + Math.imul(al7, bl3)) | 0;\n    mid = (mid + Math.imul(al7, bh3)) | 0;\n    mid = (mid + Math.imul(ah7, bl3)) | 0;\n    hi = (hi + Math.imul(ah7, bh3)) | 0;\n    lo = (lo + Math.imul(al6, bl4)) | 0;\n    mid = (mid + Math.imul(al6, bh4)) | 0;\n    mid = (mid + Math.imul(ah6, bl4)) | 0;\n    hi = (hi + Math.imul(ah6, bh4)) | 0;\n    lo = (lo + Math.imul(al5, bl5)) | 0;\n    mid = (mid + Math.imul(al5, bh5)) | 0;\n    mid = (mid + Math.imul(ah5, bl5)) | 0;\n    hi = (hi + Math.imul(ah5, bh5)) | 0;\n    lo = (lo + Math.imul(al4, bl6)) | 0;\n    mid = (mid + Math.imul(al4, bh6)) | 0;\n    mid = (mid + Math.imul(ah4, bl6)) | 0;\n    hi = (hi + Math.imul(ah4, bh6)) | 0;\n    lo = (lo + Math.imul(al3, bl7)) | 0;\n    mid = (mid + Math.imul(al3, bh7)) | 0;\n    mid = (mid + Math.imul(ah3, bl7)) | 0;\n    hi = (hi + Math.imul(ah3, bh7)) | 0;\n    lo = (lo + Math.imul(al2, bl8)) | 0;\n    mid = (mid + Math.imul(al2, bh8)) | 0;\n    mid = (mid + Math.imul(ah2, bl8)) | 0;\n    hi = (hi + Math.imul(ah2, bh8)) | 0;\n    lo = (lo + Math.imul(al1, bl9)) | 0;\n    mid = (mid + Math.imul(al1, bh9)) | 0;\n    mid = (mid + Math.imul(ah1, bl9)) | 0;\n    hi = (hi + Math.imul(ah1, bh9)) | 0;\n    var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;\n    w10 &= 0x3ffffff;\n    /* k = 11 */\n    lo = Math.imul(al9, bl2);\n    mid = Math.imul(al9, bh2);\n    mid = (mid + Math.imul(ah9, bl2)) | 0;\n    hi = Math.imul(ah9, bh2);\n    lo = (lo + Math.imul(al8, bl3)) | 0;\n    mid = (mid + Math.imul(al8, bh3)) | 0;\n    mid = (mid + Math.imul(ah8, bl3)) | 0;\n    hi = (hi + Math.imul(ah8, bh3)) | 0;\n    lo = (lo + Math.imul(al7, bl4)) | 0;\n    mid = (mid + Math.imul(al7, bh4)) | 0;\n    mid = (mid + Math.imul(ah7, bl4)) | 0;\n    hi = (hi + Math.imul(ah7, bh4)) | 0;\n    lo = (lo + Math.imul(al6, bl5)) | 0;\n    mid = (mid + Math.imul(al6, bh5)) | 0;\n    mid = (mid + Math.imul(ah6, bl5)) | 0;\n    hi = (hi + Math.imul(ah6, bh5)) | 0;\n    lo = (lo + Math.imul(al5, bl6)) | 0;\n    mid = (mid + Math.imul(al5, bh6)) | 0;\n    mid = (mid + Math.imul(ah5, bl6)) | 0;\n    hi = (hi + Math.imul(ah5, bh6)) | 0;\n    lo = (lo + Math.imul(al4, bl7)) | 0;\n    mid = (mid + Math.imul(al4, bh7)) | 0;\n    mid = (mid + Math.imul(ah4, bl7)) | 0;\n    hi = (hi + Math.imul(ah4, bh7)) | 0;\n    lo = (lo + Math.imul(al3, bl8)) | 0;\n    mid = (mid + Math.imul(al3, bh8)) | 0;\n    mid = (mid + Math.imul(ah3, bl8)) | 0;\n    hi = (hi + Math.imul(ah3, bh8)) | 0;\n    lo = (lo + Math.imul(al2, bl9)) | 0;\n    mid = (mid + Math.imul(al2, bh9)) | 0;\n    mid = (mid + Math.imul(ah2, bl9)) | 0;\n    hi = (hi + Math.imul(ah2, bh9)) | 0;\n    var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;\n    w11 &= 0x3ffffff;\n    /* k = 12 */\n    lo = Math.imul(al9, bl3);\n    mid = Math.imul(al9, bh3);\n    mid = (mid + Math.imul(ah9, bl3)) | 0;\n    hi = Math.imul(ah9, bh3);\n    lo = (lo + Math.imul(al8, bl4)) | 0;\n    mid = (mid + Math.imul(al8, bh4)) | 0;\n    mid = (mid + Math.imul(ah8, bl4)) | 0;\n    hi = (hi + Math.imul(ah8, bh4)) | 0;\n    lo = (lo + Math.imul(al7, bl5)) | 0;\n    mid = (mid + Math.imul(al7, bh5)) | 0;\n    mid = (mid + Math.imul(ah7, bl5)) | 0;\n    hi = (hi + Math.imul(ah7, bh5)) | 0;\n    lo = (lo + Math.imul(al6, bl6)) | 0;\n    mid = (mid + Math.imul(al6, bh6)) | 0;\n    mid = (mid + Math.imul(ah6, bl6)) | 0;\n    hi = (hi + Math.imul(ah6, bh6)) | 0;\n    lo = (lo + Math.imul(al5, bl7)) | 0;\n    mid = (mid + Math.imul(al5, bh7)) | 0;\n    mid = (mid + Math.imul(ah5, bl7)) | 0;\n    hi = (hi + Math.imul(ah5, bh7)) | 0;\n    lo = (lo + Math.imul(al4, bl8)) | 0;\n    mid = (mid + Math.imul(al4, bh8)) | 0;\n    mid = (mid + Math.imul(ah4, bl8)) | 0;\n    hi = (hi + Math.imul(ah4, bh8)) | 0;\n    lo = (lo + Math.imul(al3, bl9)) | 0;\n    mid = (mid + Math.imul(al3, bh9)) | 0;\n    mid = (mid + Math.imul(ah3, bl9)) | 0;\n    hi = (hi + Math.imul(ah3, bh9)) | 0;\n    var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;\n    w12 &= 0x3ffffff;\n    /* k = 13 */\n    lo = Math.imul(al9, bl4);\n    mid = Math.imul(al9, bh4);\n    mid = (mid + Math.imul(ah9, bl4)) | 0;\n    hi = Math.imul(ah9, bh4);\n    lo = (lo + Math.imul(al8, bl5)) | 0;\n    mid = (mid + Math.imul(al8, bh5)) | 0;\n    mid = (mid + Math.imul(ah8, bl5)) | 0;\n    hi = (hi + Math.imul(ah8, bh5)) | 0;\n    lo = (lo + Math.imul(al7, bl6)) | 0;\n    mid = (mid + Math.imul(al7, bh6)) | 0;\n    mid = (mid + Math.imul(ah7, bl6)) | 0;\n    hi = (hi + Math.imul(ah7, bh6)) | 0;\n    lo = (lo + Math.imul(al6, bl7)) | 0;\n    mid = (mid + Math.imul(al6, bh7)) | 0;\n    mid = (mid + Math.imul(ah6, bl7)) | 0;\n    hi = (hi + Math.imul(ah6, bh7)) | 0;\n    lo = (lo + Math.imul(al5, bl8)) | 0;\n    mid = (mid + Math.imul(al5, bh8)) | 0;\n    mid = (mid + Math.imul(ah5, bl8)) | 0;\n    hi = (hi + Math.imul(ah5, bh8)) | 0;\n    lo = (lo + Math.imul(al4, bl9)) | 0;\n    mid = (mid + Math.imul(al4, bh9)) | 0;\n    mid = (mid + Math.imul(ah4, bl9)) | 0;\n    hi = (hi + Math.imul(ah4, bh9)) | 0;\n    var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;\n    w13 &= 0x3ffffff;\n    /* k = 14 */\n    lo = Math.imul(al9, bl5);\n    mid = Math.imul(al9, bh5);\n    mid = (mid + Math.imul(ah9, bl5)) | 0;\n    hi = Math.imul(ah9, bh5);\n    lo = (lo + Math.imul(al8, bl6)) | 0;\n    mid = (mid + Math.imul(al8, bh6)) | 0;\n    mid = (mid + Math.imul(ah8, bl6)) | 0;\n    hi = (hi + Math.imul(ah8, bh6)) | 0;\n    lo = (lo + Math.imul(al7, bl7)) | 0;\n    mid = (mid + Math.imul(al7, bh7)) | 0;\n    mid = (mid + Math.imul(ah7, bl7)) | 0;\n    hi = (hi + Math.imul(ah7, bh7)) | 0;\n    lo = (lo + Math.imul(al6, bl8)) | 0;\n    mid = (mid + Math.imul(al6, bh8)) | 0;\n    mid = (mid + Math.imul(ah6, bl8)) | 0;\n    hi = (hi + Math.imul(ah6, bh8)) | 0;\n    lo = (lo + Math.imul(al5, bl9)) | 0;\n    mid = (mid + Math.imul(al5, bh9)) | 0;\n    mid = (mid + Math.imul(ah5, bl9)) | 0;\n    hi = (hi + Math.imul(ah5, bh9)) | 0;\n    var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;\n    w14 &= 0x3ffffff;\n    /* k = 15 */\n    lo = Math.imul(al9, bl6);\n    mid = Math.imul(al9, bh6);\n    mid = (mid + Math.imul(ah9, bl6)) | 0;\n    hi = Math.imul(ah9, bh6);\n    lo = (lo + Math.imul(al8, bl7)) | 0;\n    mid = (mid + Math.imul(al8, bh7)) | 0;\n    mid = (mid + Math.imul(ah8, bl7)) | 0;\n    hi = (hi + Math.imul(ah8, bh7)) | 0;\n    lo = (lo + Math.imul(al7, bl8)) | 0;\n    mid = (mid + Math.imul(al7, bh8)) | 0;\n    mid = (mid + Math.imul(ah7, bl8)) | 0;\n    hi = (hi + Math.imul(ah7, bh8)) | 0;\n    lo = (lo + Math.imul(al6, bl9)) | 0;\n    mid = (mid + Math.imul(al6, bh9)) | 0;\n    mid = (mid + Math.imul(ah6, bl9)) | 0;\n    hi = (hi + Math.imul(ah6, bh9)) | 0;\n    var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;\n    w15 &= 0x3ffffff;\n    /* k = 16 */\n    lo = Math.imul(al9, bl7);\n    mid = Math.imul(al9, bh7);\n    mid = (mid + Math.imul(ah9, bl7)) | 0;\n    hi = Math.imul(ah9, bh7);\n    lo = (lo + Math.imul(al8, bl8)) | 0;\n    mid = (mid + Math.imul(al8, bh8)) | 0;\n    mid = (mid + Math.imul(ah8, bl8)) | 0;\n    hi = (hi + Math.imul(ah8, bh8)) | 0;\n    lo = (lo + Math.imul(al7, bl9)) | 0;\n    mid = (mid + Math.imul(al7, bh9)) | 0;\n    mid = (mid + Math.imul(ah7, bl9)) | 0;\n    hi = (hi + Math.imul(ah7, bh9)) | 0;\n    var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;\n    w16 &= 0x3ffffff;\n    /* k = 17 */\n    lo = Math.imul(al9, bl8);\n    mid = Math.imul(al9, bh8);\n    mid = (mid + Math.imul(ah9, bl8)) | 0;\n    hi = Math.imul(ah9, bh8);\n    lo = (lo + Math.imul(al8, bl9)) | 0;\n    mid = (mid + Math.imul(al8, bh9)) | 0;\n    mid = (mid + Math.imul(ah8, bl9)) | 0;\n    hi = (hi + Math.imul(ah8, bh9)) | 0;\n    var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;\n    w17 &= 0x3ffffff;\n    /* k = 18 */\n    lo = Math.imul(al9, bl9);\n    mid = Math.imul(al9, bh9);\n    mid = (mid + Math.imul(ah9, bl9)) | 0;\n    hi = Math.imul(ah9, bh9);\n    var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;\n    w18 &= 0x3ffffff;\n    o[0] = w0;\n    o[1] = w1;\n    o[2] = w2;\n    o[3] = w3;\n    o[4] = w4;\n    o[5] = w5;\n    o[6] = w6;\n    o[7] = w7;\n    o[8] = w8;\n    o[9] = w9;\n    o[10] = w10;\n    o[11] = w11;\n    o[12] = w12;\n    o[13] = w13;\n    o[14] = w14;\n    o[15] = w15;\n    o[16] = w16;\n    o[17] = w17;\n    o[18] = w18;\n    if (c !== 0) {\n      o[19] = c;\n      out.length++;\n    }\n    return out;\n  };\n\n  // Polyfill comb\n  if (!Math.imul) {\n    comb10MulTo = smallMulTo;\n  }\n\n  function bigMulTo (self, num, out) {\n    out.negative = num.negative ^ self.negative;\n    out.length = self.length + num.length;\n\n    var carry = 0;\n    var hncarry = 0;\n    for (var k = 0; k < out.length - 1; k++) {\n      // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n      // note that ncarry could be >= 0x3ffffff\n      var ncarry = hncarry;\n      hncarry = 0;\n      var rword = carry & 0x3ffffff;\n      var maxJ = Math.min(k, num.length - 1);\n      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {\n        var i = k - j;\n        var a = self.words[i] | 0;\n        var b = num.words[j] | 0;\n        var r = a * b;\n\n        var lo = r & 0x3ffffff;\n        ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;\n        lo = (lo + rword) | 0;\n        rword = lo & 0x3ffffff;\n        ncarry = (ncarry + (lo >>> 26)) | 0;\n\n        hncarry += ncarry >>> 26;\n        ncarry &= 0x3ffffff;\n      }\n      out.words[k] = rword;\n      carry = ncarry;\n      ncarry = hncarry;\n    }\n    if (carry !== 0) {\n      out.words[k] = carry;\n    } else {\n      out.length--;\n    }\n\n    return out.strip();\n  }\n\n  function jumboMulTo (self, num, out) {\n    var fftm = new FFTM();\n    return fftm.mulp(self, num, out);\n  }\n\n  BN.prototype.mulTo = function mulTo (num, out) {\n    var res;\n    var len = this.length + num.length;\n    if (this.length === 10 && num.length === 10) {\n      res = comb10MulTo(this, num, out);\n    } else if (len < 63) {\n      res = smallMulTo(this, num, out);\n    } else if (len < 1024) {\n      res = bigMulTo(this, num, out);\n    } else {\n      res = jumboMulTo(this, num, out);\n    }\n\n    return res;\n  };\n\n  // Cooley-Tukey algorithm for FFT\n  // slightly revisited to rely on looping instead of recursion\n\n  function FFTM (x, y) {\n    this.x = x;\n    this.y = y;\n  }\n\n  FFTM.prototype.makeRBT = function makeRBT (N) {\n    var t = new Array(N);\n    var l = BN.prototype._countBits(N) - 1;\n    for (var i = 0; i < N; i++) {\n      t[i] = this.revBin(i, l, N);\n    }\n\n    return t;\n  };\n\n  // Returns binary-reversed representation of `x`\n  FFTM.prototype.revBin = function revBin (x, l, N) {\n    if (x === 0 || x === N - 1) return x;\n\n    var rb = 0;\n    for (var i = 0; i < l; i++) {\n      rb |= (x & 1) << (l - i - 1);\n      x >>= 1;\n    }\n\n    return rb;\n  };\n\n  // Performs \"tweedling\" phase, therefore 'emulating'\n  // behaviour of the recursive algorithm\n  FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {\n    for (var i = 0; i < N; i++) {\n      rtws[i] = rws[rbt[i]];\n      itws[i] = iws[rbt[i]];\n    }\n  };\n\n  FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {\n    this.permute(rbt, rws, iws, rtws, itws, N);\n\n    for (var s = 1; s < N; s <<= 1) {\n      var l = s << 1;\n\n      var rtwdf = Math.cos(2 * Math.PI / l);\n      var itwdf = Math.sin(2 * Math.PI / l);\n\n      for (var p = 0; p < N; p += l) {\n        var rtwdf_ = rtwdf;\n        var itwdf_ = itwdf;\n\n        for (var j = 0; j < s; j++) {\n          var re = rtws[p + j];\n          var ie = itws[p + j];\n\n          var ro = rtws[p + j + s];\n          var io = itws[p + j + s];\n\n          var rx = rtwdf_ * ro - itwdf_ * io;\n\n          io = rtwdf_ * io + itwdf_ * ro;\n          ro = rx;\n\n          rtws[p + j] = re + ro;\n          itws[p + j] = ie + io;\n\n          rtws[p + j + s] = re - ro;\n          itws[p + j + s] = ie - io;\n\n          /* jshint maxdepth : false */\n          if (j !== l) {\n            rx = rtwdf * rtwdf_ - itwdf * itwdf_;\n\n            itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;\n            rtwdf_ = rx;\n          }\n        }\n      }\n    }\n  };\n\n  FFTM.prototype.guessLen13b = function guessLen13b (n, m) {\n    var N = Math.max(m, n) | 1;\n    var odd = N & 1;\n    var i = 0;\n    for (N = N / 2 | 0; N; N = N >>> 1) {\n      i++;\n    }\n\n    return 1 << i + 1 + odd;\n  };\n\n  FFTM.prototype.conjugate = function conjugate (rws, iws, N) {\n    if (N <= 1) return;\n\n    for (var i = 0; i < N / 2; i++) {\n      var t = rws[i];\n\n      rws[i] = rws[N - i - 1];\n      rws[N - i - 1] = t;\n\n      t = iws[i];\n\n      iws[i] = -iws[N - i - 1];\n      iws[N - i - 1] = -t;\n    }\n  };\n\n  FFTM.prototype.normalize13b = function normalize13b (ws, N) {\n    var carry = 0;\n    for (var i = 0; i < N / 2; i++) {\n      var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +\n        Math.round(ws[2 * i] / N) +\n        carry;\n\n      ws[i] = w & 0x3ffffff;\n\n      if (w < 0x4000000) {\n        carry = 0;\n      } else {\n        carry = w / 0x4000000 | 0;\n      }\n    }\n\n    return ws;\n  };\n\n  FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {\n    var carry = 0;\n    for (var i = 0; i < len; i++) {\n      carry = carry + (ws[i] | 0);\n\n      rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;\n      rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;\n    }\n\n    // Pad with zeroes\n    for (i = 2 * len; i < N; ++i) {\n      rws[i] = 0;\n    }\n\n    assert(carry === 0);\n    assert((carry & ~0x1fff) === 0);\n  };\n\n  FFTM.prototype.stub = function stub (N) {\n    var ph = new Array(N);\n    for (var i = 0; i < N; i++) {\n      ph[i] = 0;\n    }\n\n    return ph;\n  };\n\n  FFTM.prototype.mulp = function mulp (x, y, out) {\n    var N = 2 * this.guessLen13b(x.length, y.length);\n\n    var rbt = this.makeRBT(N);\n\n    var _ = this.stub(N);\n\n    var rws = new Array(N);\n    var rwst = new Array(N);\n    var iwst = new Array(N);\n\n    var nrws = new Array(N);\n    var nrwst = new Array(N);\n    var niwst = new Array(N);\n\n    var rmws = out.words;\n    rmws.length = N;\n\n    this.convert13b(x.words, x.length, rws, N);\n    this.convert13b(y.words, y.length, nrws, N);\n\n    this.transform(rws, _, rwst, iwst, N, rbt);\n    this.transform(nrws, _, nrwst, niwst, N, rbt);\n\n    for (var i = 0; i < N; i++) {\n      var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];\n      iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];\n      rwst[i] = rx;\n    }\n\n    this.conjugate(rwst, iwst, N);\n    this.transform(rwst, iwst, rmws, _, N, rbt);\n    this.conjugate(rmws, _, N);\n    this.normalize13b(rmws, N);\n\n    out.negative = x.negative ^ y.negative;\n    out.length = x.length + y.length;\n    return out.strip();\n  };\n\n  // Multiply `this` by `num`\n  BN.prototype.mul = function mul (num) {\n    var out = new BN(null);\n    out.words = new Array(this.length + num.length);\n    return this.mulTo(num, out);\n  };\n\n  // Multiply employing FFT\n  BN.prototype.mulf = function mulf (num) {\n    var out = new BN(null);\n    out.words = new Array(this.length + num.length);\n    return jumboMulTo(this, num, out);\n  };\n\n  // In-place Multiplication\n  BN.prototype.imul = function imul (num) {\n    return this.clone().mulTo(num, this);\n  };\n\n  BN.prototype.imuln = function imuln (num) {\n    assert(typeof num === 'number');\n    assert(num < 0x4000000);\n\n    // Carry\n    var carry = 0;\n    for (var i = 0; i < this.length; i++) {\n      var w = (this.words[i] | 0) * num;\n      var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);\n      carry >>= 26;\n      carry += (w / 0x4000000) | 0;\n      // NOTE: lo is 27bit maximum\n      carry += lo >>> 26;\n      this.words[i] = lo & 0x3ffffff;\n    }\n\n    if (carry !== 0) {\n      this.words[i] = carry;\n      this.length++;\n    }\n\n    return this;\n  };\n\n  BN.prototype.muln = function muln (num) {\n    return this.clone().imuln(num);\n  };\n\n  // `this` * `this`\n  BN.prototype.sqr = function sqr () {\n    return this.mul(this);\n  };\n\n  // `this` * `this` in-place\n  BN.prototype.isqr = function isqr () {\n    return this.imul(this.clone());\n  };\n\n  // Math.pow(`this`, `num`)\n  BN.prototype.pow = function pow (num) {\n    var w = toBitArray(num);\n    if (w.length === 0) return new BN(1);\n\n    // Skip leading zeroes\n    var res = this;\n    for (var i = 0; i < w.length; i++, res = res.sqr()) {\n      if (w[i] !== 0) break;\n    }\n\n    if (++i < w.length) {\n      for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {\n        if (w[i] === 0) continue;\n\n        res = res.mul(q);\n      }\n    }\n\n    return res;\n  };\n\n  // Shift-left in-place\n  BN.prototype.iushln = function iushln (bits) {\n    assert(typeof bits === 'number' && bits >= 0);\n    var r = bits % 26;\n    var s = (bits - r) / 26;\n    var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);\n    var i;\n\n    if (r !== 0) {\n      var carry = 0;\n\n      for (i = 0; i < this.length; i++) {\n        var newCarry = this.words[i] & carryMask;\n        var c = ((this.words[i] | 0) - newCarry) << r;\n        this.words[i] = c | carry;\n        carry = newCarry >>> (26 - r);\n      }\n\n      if (carry) {\n        this.words[i] = carry;\n        this.length++;\n      }\n    }\n\n    if (s !== 0) {\n      for (i = this.length - 1; i >= 0; i--) {\n        this.words[i + s] = this.words[i];\n      }\n\n      for (i = 0; i < s; i++) {\n        this.words[i] = 0;\n      }\n\n      this.length += s;\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.ishln = function ishln (bits) {\n    // TODO(indutny): implement me\n    assert(this.negative === 0);\n    return this.iushln(bits);\n  };\n\n  // Shift-right in-place\n  // NOTE: `hint` is a lowest bit before trailing zeroes\n  // NOTE: if `extended` is present - it will be filled with destroyed bits\n  BN.prototype.iushrn = function iushrn (bits, hint, extended) {\n    assert(typeof bits === 'number' && bits >= 0);\n    var h;\n    if (hint) {\n      h = (hint - (hint % 26)) / 26;\n    } else {\n      h = 0;\n    }\n\n    var r = bits % 26;\n    var s = Math.min((bits - r) / 26, this.length);\n    var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);\n    var maskedWords = extended;\n\n    h -= s;\n    h = Math.max(0, h);\n\n    // Extended mode, copy masked part\n    if (maskedWords) {\n      for (var i = 0; i < s; i++) {\n        maskedWords.words[i] = this.words[i];\n      }\n      maskedWords.length = s;\n    }\n\n    if (s === 0) {\n      // No-op, we should not move anything at all\n    } else if (this.length > s) {\n      this.length -= s;\n      for (i = 0; i < this.length; i++) {\n        this.words[i] = this.words[i + s];\n      }\n    } else {\n      this.words[0] = 0;\n      this.length = 1;\n    }\n\n    var carry = 0;\n    for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {\n      var word = this.words[i] | 0;\n      this.words[i] = (carry << (26 - r)) | (word >>> r);\n      carry = word & mask;\n    }\n\n    // Push carried bits as a mask\n    if (maskedWords && carry !== 0) {\n      maskedWords.words[maskedWords.length++] = carry;\n    }\n\n    if (this.length === 0) {\n      this.words[0] = 0;\n      this.length = 1;\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.ishrn = function ishrn (bits, hint, extended) {\n    // TODO(indutny): implement me\n    assert(this.negative === 0);\n    return this.iushrn(bits, hint, extended);\n  };\n\n  // Shift-left\n  BN.prototype.shln = function shln (bits) {\n    return this.clone().ishln(bits);\n  };\n\n  BN.prototype.ushln = function ushln (bits) {\n    return this.clone().iushln(bits);\n  };\n\n  // Shift-right\n  BN.prototype.shrn = function shrn (bits) {\n    return this.clone().ishrn(bits);\n  };\n\n  BN.prototype.ushrn = function ushrn (bits) {\n    return this.clone().iushrn(bits);\n  };\n\n  // Test if n bit is set\n  BN.prototype.testn = function testn (bit) {\n    assert(typeof bit === 'number' && bit >= 0);\n    var r = bit % 26;\n    var s = (bit - r) / 26;\n    var q = 1 << r;\n\n    // Fast case: bit is much higher than all existing words\n    if (this.length <= s) return false;\n\n    // Check bit and return\n    var w = this.words[s];\n\n    return !!(w & q);\n  };\n\n  // Return only lowers bits of number (in-place)\n  BN.prototype.imaskn = function imaskn (bits) {\n    assert(typeof bits === 'number' && bits >= 0);\n    var r = bits % 26;\n    var s = (bits - r) / 26;\n\n    assert(this.negative === 0, 'imaskn works only with positive numbers');\n\n    if (this.length <= s) {\n      return this;\n    }\n\n    if (r !== 0) {\n      s++;\n    }\n    this.length = Math.min(s, this.length);\n\n    if (r !== 0) {\n      var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);\n      this.words[this.length - 1] &= mask;\n    }\n\n    return this.strip();\n  };\n\n  // Return only lowers bits of number\n  BN.prototype.maskn = function maskn (bits) {\n    return this.clone().imaskn(bits);\n  };\n\n  // Add plain number `num` to `this`\n  BN.prototype.iaddn = function iaddn (num) {\n    assert(typeof num === 'number');\n    assert(num < 0x4000000);\n    if (num < 0) return this.isubn(-num);\n\n    // Possible sign change\n    if (this.negative !== 0) {\n      if (this.length === 1 && (this.words[0] | 0) < num) {\n        this.words[0] = num - (this.words[0] | 0);\n        this.negative = 0;\n        return this;\n      }\n\n      this.negative = 0;\n      this.isubn(num);\n      this.negative = 1;\n      return this;\n    }\n\n    // Add without checks\n    return this._iaddn(num);\n  };\n\n  BN.prototype._iaddn = function _iaddn (num) {\n    this.words[0] += num;\n\n    // Carry\n    for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {\n      this.words[i] -= 0x4000000;\n      if (i === this.length - 1) {\n        this.words[i + 1] = 1;\n      } else {\n        this.words[i + 1]++;\n      }\n    }\n    this.length = Math.max(this.length, i + 1);\n\n    return this;\n  };\n\n  // Subtract plain number `num` from `this`\n  BN.prototype.isubn = function isubn (num) {\n    assert(typeof num === 'number');\n    assert(num < 0x4000000);\n    if (num < 0) return this.iaddn(-num);\n\n    if (this.negative !== 0) {\n      this.negative = 0;\n      this.iaddn(num);\n      this.negative = 1;\n      return this;\n    }\n\n    this.words[0] -= num;\n\n    if (this.length === 1 && this.words[0] < 0) {\n      this.words[0] = -this.words[0];\n      this.negative = 1;\n    } else {\n      // Carry\n      for (var i = 0; i < this.length && this.words[i] < 0; i++) {\n        this.words[i] += 0x4000000;\n        this.words[i + 1] -= 1;\n      }\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.addn = function addn (num) {\n    return this.clone().iaddn(num);\n  };\n\n  BN.prototype.subn = function subn (num) {\n    return this.clone().isubn(num);\n  };\n\n  BN.prototype.iabs = function iabs () {\n    this.negative = 0;\n\n    return this;\n  };\n\n  BN.prototype.abs = function abs () {\n    return this.clone().iabs();\n  };\n\n  BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {\n    var len = num.length + shift;\n    var i;\n\n    this._expand(len);\n\n    var w;\n    var carry = 0;\n    for (i = 0; i < num.length; i++) {\n      w = (this.words[i + shift] | 0) + carry;\n      var right = (num.words[i] | 0) * mul;\n      w -= right & 0x3ffffff;\n      carry = (w >> 26) - ((right / 0x4000000) | 0);\n      this.words[i + shift] = w & 0x3ffffff;\n    }\n    for (; i < this.length - shift; i++) {\n      w = (this.words[i + shift] | 0) + carry;\n      carry = w >> 26;\n      this.words[i + shift] = w & 0x3ffffff;\n    }\n\n    if (carry === 0) return this.strip();\n\n    // Subtraction overflow\n    assert(carry === -1);\n    carry = 0;\n    for (i = 0; i < this.length; i++) {\n      w = -(this.words[i] | 0) + carry;\n      carry = w >> 26;\n      this.words[i] = w & 0x3ffffff;\n    }\n    this.negative = 1;\n\n    return this.strip();\n  };\n\n  BN.prototype._wordDiv = function _wordDiv (num, mode) {\n    var shift = this.length - num.length;\n\n    var a = this.clone();\n    var b = num;\n\n    // Normalize\n    var bhi = b.words[b.length - 1] | 0;\n    var bhiBits = this._countBits(bhi);\n    shift = 26 - bhiBits;\n    if (shift !== 0) {\n      b = b.ushln(shift);\n      a.iushln(shift);\n      bhi = b.words[b.length - 1] | 0;\n    }\n\n    // Initialize quotient\n    var m = a.length - b.length;\n    var q;\n\n    if (mode !== 'mod') {\n      q = new BN(null);\n      q.length = m + 1;\n      q.words = new Array(q.length);\n      for (var i = 0; i < q.length; i++) {\n        q.words[i] = 0;\n      }\n    }\n\n    var diff = a.clone()._ishlnsubmul(b, 1, m);\n    if (diff.negative === 0) {\n      a = diff;\n      if (q) {\n        q.words[m] = 1;\n      }\n    }\n\n    for (var j = m - 1; j >= 0; j--) {\n      var qj = (a.words[b.length + j] | 0) * 0x4000000 +\n        (a.words[b.length + j - 1] | 0);\n\n      // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max\n      // (0x7ffffff)\n      qj = Math.min((qj / bhi) | 0, 0x3ffffff);\n\n      a._ishlnsubmul(b, qj, j);\n      while (a.negative !== 0) {\n        qj--;\n        a.negative = 0;\n        a._ishlnsubmul(b, 1, j);\n        if (!a.isZero()) {\n          a.negative ^= 1;\n        }\n      }\n      if (q) {\n        q.words[j] = qj;\n      }\n    }\n    if (q) {\n      q.strip();\n    }\n    a.strip();\n\n    // Denormalize\n    if (mode !== 'div' && shift !== 0) {\n      a.iushrn(shift);\n    }\n\n    return {\n      div: q || null,\n      mod: a\n    };\n  };\n\n  // NOTE: 1) `mode` can be set to `mod` to request mod only,\n  //       to `div` to request div only, or be absent to\n  //       request both div & mod\n  //       2) `positive` is true if unsigned mod is requested\n  BN.prototype.divmod = function divmod (num, mode, positive) {\n    assert(!num.isZero());\n\n    if (this.isZero()) {\n      return {\n        div: new BN(0),\n        mod: new BN(0)\n      };\n    }\n\n    var div, mod, res;\n    if (this.negative !== 0 && num.negative === 0) {\n      res = this.neg().divmod(num, mode);\n\n      if (mode !== 'mod') {\n        div = res.div.neg();\n      }\n\n      if (mode !== 'div') {\n        mod = res.mod.neg();\n        if (positive && mod.negative !== 0) {\n          mod.iadd(num);\n        }\n      }\n\n      return {\n        div: div,\n        mod: mod\n      };\n    }\n\n    if (this.negative === 0 && num.negative !== 0) {\n      res = this.divmod(num.neg(), mode);\n\n      if (mode !== 'mod') {\n        div = res.div.neg();\n      }\n\n      return {\n        div: div,\n        mod: res.mod\n      };\n    }\n\n    if ((this.negative & num.negative) !== 0) {\n      res = this.neg().divmod(num.neg(), mode);\n\n      if (mode !== 'div') {\n        mod = res.mod.neg();\n        if (positive && mod.negative !== 0) {\n          mod.isub(num);\n        }\n      }\n\n      return {\n        div: res.div,\n        mod: mod\n      };\n    }\n\n    // Both numbers are positive at this point\n\n    // Strip both numbers to approximate shift value\n    if (num.length > this.length || this.cmp(num) < 0) {\n      return {\n        div: new BN(0),\n        mod: this\n      };\n    }\n\n    // Very short reduction\n    if (num.length === 1) {\n      if (mode === 'div') {\n        return {\n          div: this.divn(num.words[0]),\n          mod: null\n        };\n      }\n\n      if (mode === 'mod') {\n        return {\n          div: null,\n          mod: new BN(this.modn(num.words[0]))\n        };\n      }\n\n      return {\n        div: this.divn(num.words[0]),\n        mod: new BN(this.modn(num.words[0]))\n      };\n    }\n\n    return this._wordDiv(num, mode);\n  };\n\n  // Find `this` / `num`\n  BN.prototype.div = function div (num) {\n    return this.divmod(num, 'div', false).div;\n  };\n\n  // Find `this` % `num`\n  BN.prototype.mod = function mod (num) {\n    return this.divmod(num, 'mod', false).mod;\n  };\n\n  BN.prototype.umod = function umod (num) {\n    return this.divmod(num, 'mod', true).mod;\n  };\n\n  // Find Round(`this` / `num`)\n  BN.prototype.divRound = function divRound (num) {\n    var dm = this.divmod(num);\n\n    // Fast case - exact division\n    if (dm.mod.isZero()) return dm.div;\n\n    var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;\n\n    var half = num.ushrn(1);\n    var r2 = num.andln(1);\n    var cmp = mod.cmp(half);\n\n    // Round down\n    if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;\n\n    // Round up\n    return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);\n  };\n\n  BN.prototype.modn = function modn (num) {\n    assert(num <= 0x3ffffff);\n    var p = (1 << 26) % num;\n\n    var acc = 0;\n    for (var i = this.length - 1; i >= 0; i--) {\n      acc = (p * acc + (this.words[i] | 0)) % num;\n    }\n\n    return acc;\n  };\n\n  // In-place division by number\n  BN.prototype.idivn = function idivn (num) {\n    assert(num <= 0x3ffffff);\n\n    var carry = 0;\n    for (var i = this.length - 1; i >= 0; i--) {\n      var w = (this.words[i] | 0) + carry * 0x4000000;\n      this.words[i] = (w / num) | 0;\n      carry = w % num;\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.divn = function divn (num) {\n    return this.clone().idivn(num);\n  };\n\n  BN.prototype.egcd = function egcd (p) {\n    assert(p.negative === 0);\n    assert(!p.isZero());\n\n    var x = this;\n    var y = p.clone();\n\n    if (x.negative !== 0) {\n      x = x.umod(p);\n    } else {\n      x = x.clone();\n    }\n\n    // A * x + B * y = x\n    var A = new BN(1);\n    var B = new BN(0);\n\n    // C * x + D * y = y\n    var C = new BN(0);\n    var D = new BN(1);\n\n    var g = 0;\n\n    while (x.isEven() && y.isEven()) {\n      x.iushrn(1);\n      y.iushrn(1);\n      ++g;\n    }\n\n    var yp = y.clone();\n    var xp = x.clone();\n\n    while (!x.isZero()) {\n      for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n      if (i > 0) {\n        x.iushrn(i);\n        while (i-- > 0) {\n          if (A.isOdd() || B.isOdd()) {\n            A.iadd(yp);\n            B.isub(xp);\n          }\n\n          A.iushrn(1);\n          B.iushrn(1);\n        }\n      }\n\n      for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n      if (j > 0) {\n        y.iushrn(j);\n        while (j-- > 0) {\n          if (C.isOdd() || D.isOdd()) {\n            C.iadd(yp);\n            D.isub(xp);\n          }\n\n          C.iushrn(1);\n          D.iushrn(1);\n        }\n      }\n\n      if (x.cmp(y) >= 0) {\n        x.isub(y);\n        A.isub(C);\n        B.isub(D);\n      } else {\n        y.isub(x);\n        C.isub(A);\n        D.isub(B);\n      }\n    }\n\n    return {\n      a: C,\n      b: D,\n      gcd: y.iushln(g)\n    };\n  };\n\n  // This is reduced incarnation of the binary EEA\n  // above, designated to invert members of the\n  // _prime_ fields F(p) at a maximal speed\n  BN.prototype._invmp = function _invmp (p) {\n    assert(p.negative === 0);\n    assert(!p.isZero());\n\n    var a = this;\n    var b = p.clone();\n\n    if (a.negative !== 0) {\n      a = a.umod(p);\n    } else {\n      a = a.clone();\n    }\n\n    var x1 = new BN(1);\n    var x2 = new BN(0);\n\n    var delta = b.clone();\n\n    while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {\n      for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n      if (i > 0) {\n        a.iushrn(i);\n        while (i-- > 0) {\n          if (x1.isOdd()) {\n            x1.iadd(delta);\n          }\n\n          x1.iushrn(1);\n        }\n      }\n\n      for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n      if (j > 0) {\n        b.iushrn(j);\n        while (j-- > 0) {\n          if (x2.isOdd()) {\n            x2.iadd(delta);\n          }\n\n          x2.iushrn(1);\n        }\n      }\n\n      if (a.cmp(b) >= 0) {\n        a.isub(b);\n        x1.isub(x2);\n      } else {\n        b.isub(a);\n        x2.isub(x1);\n      }\n    }\n\n    var res;\n    if (a.cmpn(1) === 0) {\n      res = x1;\n    } else {\n      res = x2;\n    }\n\n    if (res.cmpn(0) < 0) {\n      res.iadd(p);\n    }\n\n    return res;\n  };\n\n  BN.prototype.gcd = function gcd (num) {\n    if (this.isZero()) return num.abs();\n    if (num.isZero()) return this.abs();\n\n    var a = this.clone();\n    var b = num.clone();\n    a.negative = 0;\n    b.negative = 0;\n\n    // Remove common factor of two\n    for (var shift = 0; a.isEven() && b.isEven(); shift++) {\n      a.iushrn(1);\n      b.iushrn(1);\n    }\n\n    do {\n      while (a.isEven()) {\n        a.iushrn(1);\n      }\n      while (b.isEven()) {\n        b.iushrn(1);\n      }\n\n      var r = a.cmp(b);\n      if (r < 0) {\n        // Swap `a` and `b` to make `a` always bigger than `b`\n        var t = a;\n        a = b;\n        b = t;\n      } else if (r === 0 || b.cmpn(1) === 0) {\n        break;\n      }\n\n      a.isub(b);\n    } while (true);\n\n    return b.iushln(shift);\n  };\n\n  // Invert number in the field F(num)\n  BN.prototype.invm = function invm (num) {\n    return this.egcd(num).a.umod(num);\n  };\n\n  BN.prototype.isEven = function isEven () {\n    return (this.words[0] & 1) === 0;\n  };\n\n  BN.prototype.isOdd = function isOdd () {\n    return (this.words[0] & 1) === 1;\n  };\n\n  // And first word and num\n  BN.prototype.andln = function andln (num) {\n    return this.words[0] & num;\n  };\n\n  // Increment at the bit position in-line\n  BN.prototype.bincn = function bincn (bit) {\n    assert(typeof bit === 'number');\n    var r = bit % 26;\n    var s = (bit - r) / 26;\n    var q = 1 << r;\n\n    // Fast case: bit is much higher than all existing words\n    if (this.length <= s) {\n      this._expand(s + 1);\n      this.words[s] |= q;\n      return this;\n    }\n\n    // Add bit and propagate, if needed\n    var carry = q;\n    for (var i = s; carry !== 0 && i < this.length; i++) {\n      var w = this.words[i] | 0;\n      w += carry;\n      carry = w >>> 26;\n      w &= 0x3ffffff;\n      this.words[i] = w;\n    }\n    if (carry !== 0) {\n      this.words[i] = carry;\n      this.length++;\n    }\n    return this;\n  };\n\n  BN.prototype.isZero = function isZero () {\n    return this.length === 1 && this.words[0] === 0;\n  };\n\n  BN.prototype.cmpn = function cmpn (num) {\n    var negative = num < 0;\n\n    if (this.negative !== 0 && !negative) return -1;\n    if (this.negative === 0 && negative) return 1;\n\n    this.strip();\n\n    var res;\n    if (this.length > 1) {\n      res = 1;\n    } else {\n      if (negative) {\n        num = -num;\n      }\n\n      assert(num <= 0x3ffffff, 'Number is too big');\n\n      var w = this.words[0] | 0;\n      res = w === num ? 0 : w < num ? -1 : 1;\n    }\n    if (this.negative !== 0) return -res | 0;\n    return res;\n  };\n\n  // Compare two numbers and return:\n  // 1 - if `this` > `num`\n  // 0 - if `this` == `num`\n  // -1 - if `this` < `num`\n  BN.prototype.cmp = function cmp (num) {\n    if (this.negative !== 0 && num.negative === 0) return -1;\n    if (this.negative === 0 && num.negative !== 0) return 1;\n\n    var res = this.ucmp(num);\n    if (this.negative !== 0) return -res | 0;\n    return res;\n  };\n\n  // Unsigned comparison\n  BN.prototype.ucmp = function ucmp (num) {\n    // At this point both numbers have the same sign\n    if (this.length > num.length) return 1;\n    if (this.length < num.length) return -1;\n\n    var res = 0;\n    for (var i = this.length - 1; i >= 0; i--) {\n      var a = this.words[i] | 0;\n      var b = num.words[i] | 0;\n\n      if (a === b) continue;\n      if (a < b) {\n        res = -1;\n      } else if (a > b) {\n        res = 1;\n      }\n      break;\n    }\n    return res;\n  };\n\n  BN.prototype.gtn = function gtn (num) {\n    return this.cmpn(num) === 1;\n  };\n\n  BN.prototype.gt = function gt (num) {\n    return this.cmp(num) === 1;\n  };\n\n  BN.prototype.gten = function gten (num) {\n    return this.cmpn(num) >= 0;\n  };\n\n  BN.prototype.gte = function gte (num) {\n    return this.cmp(num) >= 0;\n  };\n\n  BN.prototype.ltn = function ltn (num) {\n    return this.cmpn(num) === -1;\n  };\n\n  BN.prototype.lt = function lt (num) {\n    return this.cmp(num) === -1;\n  };\n\n  BN.prototype.lten = function lten (num) {\n    return this.cmpn(num) <= 0;\n  };\n\n  BN.prototype.lte = function lte (num) {\n    return this.cmp(num) <= 0;\n  };\n\n  BN.prototype.eqn = function eqn (num) {\n    return this.cmpn(num) === 0;\n  };\n\n  BN.prototype.eq = function eq (num) {\n    return this.cmp(num) === 0;\n  };\n\n  //\n  // A reduce context, could be using montgomery or something better, depending\n  // on the `m` itself.\n  //\n  BN.red = function red (num) {\n    return new Red(num);\n  };\n\n  BN.prototype.toRed = function toRed (ctx) {\n    assert(!this.red, 'Already a number in reduction context');\n    assert(this.negative === 0, 'red works only with positives');\n    return ctx.convertTo(this)._forceRed(ctx);\n  };\n\n  BN.prototype.fromRed = function fromRed () {\n    assert(this.red, 'fromRed works only with numbers in reduction context');\n    return this.red.convertFrom(this);\n  };\n\n  BN.prototype._forceRed = function _forceRed (ctx) {\n    this.red = ctx;\n    return this;\n  };\n\n  BN.prototype.forceRed = function forceRed (ctx) {\n    assert(!this.red, 'Already a number in reduction context');\n    return this._forceRed(ctx);\n  };\n\n  BN.prototype.redAdd = function redAdd (num) {\n    assert(this.red, 'redAdd works only with red numbers');\n    return this.red.add(this, num);\n  };\n\n  BN.prototype.redIAdd = function redIAdd (num) {\n    assert(this.red, 'redIAdd works only with red numbers');\n    return this.red.iadd(this, num);\n  };\n\n  BN.prototype.redSub = function redSub (num) {\n    assert(this.red, 'redSub works only with red numbers');\n    return this.red.sub(this, num);\n  };\n\n  BN.prototype.redISub = function redISub (num) {\n    assert(this.red, 'redISub works only with red numbers');\n    return this.red.isub(this, num);\n  };\n\n  BN.prototype.redShl = function redShl (num) {\n    assert(this.red, 'redShl works only with red numbers');\n    return this.red.shl(this, num);\n  };\n\n  BN.prototype.redMul = function redMul (num) {\n    assert(this.red, 'redMul works only with red numbers');\n    this.red._verify2(this, num);\n    return this.red.mul(this, num);\n  };\n\n  BN.prototype.redIMul = function redIMul (num) {\n    assert(this.red, 'redMul works only with red numbers');\n    this.red._verify2(this, num);\n    return this.red.imul(this, num);\n  };\n\n  BN.prototype.redSqr = function redSqr () {\n    assert(this.red, 'redSqr works only with red numbers');\n    this.red._verify1(this);\n    return this.red.sqr(this);\n  };\n\n  BN.prototype.redISqr = function redISqr () {\n    assert(this.red, 'redISqr works only with red numbers');\n    this.red._verify1(this);\n    return this.red.isqr(this);\n  };\n\n  // Square root over p\n  BN.prototype.redSqrt = function redSqrt () {\n    assert(this.red, 'redSqrt works only with red numbers');\n    this.red._verify1(this);\n    return this.red.sqrt(this);\n  };\n\n  BN.prototype.redInvm = function redInvm () {\n    assert(this.red, 'redInvm works only with red numbers');\n    this.red._verify1(this);\n    return this.red.invm(this);\n  };\n\n  // Return negative clone of `this` % `red modulo`\n  BN.prototype.redNeg = function redNeg () {\n    assert(this.red, 'redNeg works only with red numbers');\n    this.red._verify1(this);\n    return this.red.neg(this);\n  };\n\n  BN.prototype.redPow = function redPow (num) {\n    assert(this.red && !num.red, 'redPow(normalNum)');\n    this.red._verify1(this);\n    return this.red.pow(this, num);\n  };\n\n  // Prime numbers with efficient reduction\n  var primes = {\n    k256: null,\n    p224: null,\n    p192: null,\n    p25519: null\n  };\n\n  // Pseudo-Mersenne prime\n  function MPrime (name, p) {\n    // P = 2 ^ N - K\n    this.name = name;\n    this.p = new BN(p, 16);\n    this.n = this.p.bitLength();\n    this.k = new BN(1).iushln(this.n).isub(this.p);\n\n    this.tmp = this._tmp();\n  }\n\n  MPrime.prototype._tmp = function _tmp () {\n    var tmp = new BN(null);\n    tmp.words = new Array(Math.ceil(this.n / 13));\n    return tmp;\n  };\n\n  MPrime.prototype.ireduce = function ireduce (num) {\n    // Assumes that `num` is less than `P^2`\n    // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)\n    var r = num;\n    var rlen;\n\n    do {\n      this.split(r, this.tmp);\n      r = this.imulK(r);\n      r = r.iadd(this.tmp);\n      rlen = r.bitLength();\n    } while (rlen > this.n);\n\n    var cmp = rlen < this.n ? -1 : r.ucmp(this.p);\n    if (cmp === 0) {\n      r.words[0] = 0;\n      r.length = 1;\n    } else if (cmp > 0) {\n      r.isub(this.p);\n    } else {\n      r.strip();\n    }\n\n    return r;\n  };\n\n  MPrime.prototype.split = function split (input, out) {\n    input.iushrn(this.n, 0, out);\n  };\n\n  MPrime.prototype.imulK = function imulK (num) {\n    return num.imul(this.k);\n  };\n\n  function K256 () {\n    MPrime.call(\n      this,\n      'k256',\n      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');\n  }\n  inherits(K256, MPrime);\n\n  K256.prototype.split = function split (input, output) {\n    // 256 = 9 * 26 + 22\n    var mask = 0x3fffff;\n\n    var outLen = Math.min(input.length, 9);\n    for (var i = 0; i < outLen; i++) {\n      output.words[i] = input.words[i];\n    }\n    output.length = outLen;\n\n    if (input.length <= 9) {\n      input.words[0] = 0;\n      input.length = 1;\n      return;\n    }\n\n    // Shift by 9 limbs\n    var prev = input.words[9];\n    output.words[output.length++] = prev & mask;\n\n    for (i = 10; i < input.length; i++) {\n      var next = input.words[i] | 0;\n      input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);\n      prev = next;\n    }\n    prev >>>= 22;\n    input.words[i - 10] = prev;\n    if (prev === 0 && input.length > 10) {\n      input.length -= 10;\n    } else {\n      input.length -= 9;\n    }\n  };\n\n  K256.prototype.imulK = function imulK (num) {\n    // K = 0x1000003d1 = [ 0x40, 0x3d1 ]\n    num.words[num.length] = 0;\n    num.words[num.length + 1] = 0;\n    num.length += 2;\n\n    // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390\n    var lo = 0;\n    for (var i = 0; i < num.length; i++) {\n      var w = num.words[i] | 0;\n      lo += w * 0x3d1;\n      num.words[i] = lo & 0x3ffffff;\n      lo = w * 0x40 + ((lo / 0x4000000) | 0);\n    }\n\n    // Fast length reduction\n    if (num.words[num.length - 1] === 0) {\n      num.length--;\n      if (num.words[num.length - 1] === 0) {\n        num.length--;\n      }\n    }\n    return num;\n  };\n\n  function P224 () {\n    MPrime.call(\n      this,\n      'p224',\n      'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');\n  }\n  inherits(P224, MPrime);\n\n  function P192 () {\n    MPrime.call(\n      this,\n      'p192',\n      'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');\n  }\n  inherits(P192, MPrime);\n\n  function P25519 () {\n    // 2 ^ 255 - 19\n    MPrime.call(\n      this,\n      '25519',\n      '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');\n  }\n  inherits(P25519, MPrime);\n\n  P25519.prototype.imulK = function imulK (num) {\n    // K = 0x13\n    var carry = 0;\n    for (var i = 0; i < num.length; i++) {\n      var hi = (num.words[i] | 0) * 0x13 + carry;\n      var lo = hi & 0x3ffffff;\n      hi >>>= 26;\n\n      num.words[i] = lo;\n      carry = hi;\n    }\n    if (carry !== 0) {\n      num.words[num.length++] = carry;\n    }\n    return num;\n  };\n\n  // Exported mostly for testing purposes, use plain name instead\n  BN._prime = function prime (name) {\n    // Cached version of prime\n    if (primes[name]) return primes[name];\n\n    var prime;\n    if (name === 'k256') {\n      prime = new K256();\n    } else if (name === 'p224') {\n      prime = new P224();\n    } else if (name === 'p192') {\n      prime = new P192();\n    } else if (name === 'p25519') {\n      prime = new P25519();\n    } else {\n      throw new Error('Unknown prime ' + name);\n    }\n    primes[name] = prime;\n\n    return prime;\n  };\n\n  //\n  // Base reduction engine\n  //\n  function Red (m) {\n    if (typeof m === 'string') {\n      var prime = BN._prime(m);\n      this.m = prime.p;\n      this.prime = prime;\n    } else {\n      assert(m.gtn(1), 'modulus must be greater than 1');\n      this.m = m;\n      this.prime = null;\n    }\n  }\n\n  Red.prototype._verify1 = function _verify1 (a) {\n    assert(a.negative === 0, 'red works only with positives');\n    assert(a.red, 'red works only with red numbers');\n  };\n\n  Red.prototype._verify2 = function _verify2 (a, b) {\n    assert((a.negative | b.negative) === 0, 'red works only with positives');\n    assert(a.red && a.red === b.red,\n      'red works only with red numbers');\n  };\n\n  Red.prototype.imod = function imod (a) {\n    if (this.prime) return this.prime.ireduce(a)._forceRed(this);\n    return a.umod(this.m)._forceRed(this);\n  };\n\n  Red.prototype.neg = function neg (a) {\n    if (a.isZero()) {\n      return a.clone();\n    }\n\n    return this.m.sub(a)._forceRed(this);\n  };\n\n  Red.prototype.add = function add (a, b) {\n    this._verify2(a, b);\n\n    var res = a.add(b);\n    if (res.cmp(this.m) >= 0) {\n      res.isub(this.m);\n    }\n    return res._forceRed(this);\n  };\n\n  Red.prototype.iadd = function iadd (a, b) {\n    this._verify2(a, b);\n\n    var res = a.iadd(b);\n    if (res.cmp(this.m) >= 0) {\n      res.isub(this.m);\n    }\n    return res;\n  };\n\n  Red.prototype.sub = function sub (a, b) {\n    this._verify2(a, b);\n\n    var res = a.sub(b);\n    if (res.cmpn(0) < 0) {\n      res.iadd(this.m);\n    }\n    return res._forceRed(this);\n  };\n\n  Red.prototype.isub = function isub (a, b) {\n    this._verify2(a, b);\n\n    var res = a.isub(b);\n    if (res.cmpn(0) < 0) {\n      res.iadd(this.m);\n    }\n    return res;\n  };\n\n  Red.prototype.shl = function shl (a, num) {\n    this._verify1(a);\n    return this.imod(a.ushln(num));\n  };\n\n  Red.prototype.imul = function imul (a, b) {\n    this._verify2(a, b);\n    return this.imod(a.imul(b));\n  };\n\n  Red.prototype.mul = function mul (a, b) {\n    this._verify2(a, b);\n    return this.imod(a.mul(b));\n  };\n\n  Red.prototype.isqr = function isqr (a) {\n    return this.imul(a, a.clone());\n  };\n\n  Red.prototype.sqr = function sqr (a) {\n    return this.mul(a, a);\n  };\n\n  Red.prototype.sqrt = function sqrt (a) {\n    if (a.isZero()) return a.clone();\n\n    var mod3 = this.m.andln(3);\n    assert(mod3 % 2 === 1);\n\n    // Fast case\n    if (mod3 === 3) {\n      var pow = this.m.add(new BN(1)).iushrn(2);\n      return this.pow(a, pow);\n    }\n\n    // Tonelli-Shanks algorithm (Totally unoptimized and slow)\n    //\n    // Find Q and S, that Q * 2 ^ S = (P - 1)\n    var q = this.m.subn(1);\n    var s = 0;\n    while (!q.isZero() && q.andln(1) === 0) {\n      s++;\n      q.iushrn(1);\n    }\n    assert(!q.isZero());\n\n    var one = new BN(1).toRed(this);\n    var nOne = one.redNeg();\n\n    // Find quadratic non-residue\n    // NOTE: Max is such because of generalized Riemann hypothesis.\n    var lpow = this.m.subn(1).iushrn(1);\n    var z = this.m.bitLength();\n    z = new BN(2 * z * z).toRed(this);\n\n    while (this.pow(z, lpow).cmp(nOne) !== 0) {\n      z.redIAdd(nOne);\n    }\n\n    var c = this.pow(z, q);\n    var r = this.pow(a, q.addn(1).iushrn(1));\n    var t = this.pow(a, q);\n    var m = s;\n    while (t.cmp(one) !== 0) {\n      var tmp = t;\n      for (var i = 0; tmp.cmp(one) !== 0; i++) {\n        tmp = tmp.redSqr();\n      }\n      assert(i < m);\n      var b = this.pow(c, new BN(1).iushln(m - i - 1));\n\n      r = r.redMul(b);\n      c = b.redSqr();\n      t = t.redMul(c);\n      m = i;\n    }\n\n    return r;\n  };\n\n  Red.prototype.invm = function invm (a) {\n    var inv = a._invmp(this.m);\n    if (inv.negative !== 0) {\n      inv.negative = 0;\n      return this.imod(inv).redNeg();\n    } else {\n      return this.imod(inv);\n    }\n  };\n\n  Red.prototype.pow = function pow (a, num) {\n    if (num.isZero()) return new BN(1);\n    if (num.cmpn(1) === 0) return a.clone();\n\n    var windowSize = 4;\n    var wnd = new Array(1 << windowSize);\n    wnd[0] = new BN(1).toRed(this);\n    wnd[1] = a;\n    for (var i = 2; i < wnd.length; i++) {\n      wnd[i] = this.mul(wnd[i - 1], a);\n    }\n\n    var res = wnd[0];\n    var current = 0;\n    var currentLen = 0;\n    var start = num.bitLength() % 26;\n    if (start === 0) {\n      start = 26;\n    }\n\n    for (i = num.length - 1; i >= 0; i--) {\n      var word = num.words[i];\n      for (var j = start - 1; j >= 0; j--) {\n        var bit = (word >> j) & 1;\n        if (res !== wnd[0]) {\n          res = this.sqr(res);\n        }\n\n        if (bit === 0 && current === 0) {\n          currentLen = 0;\n          continue;\n        }\n\n        current <<= 1;\n        current |= bit;\n        currentLen++;\n        if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;\n\n        res = this.mul(res, wnd[current]);\n        currentLen = 0;\n        current = 0;\n      }\n      start = 26;\n    }\n\n    return res;\n  };\n\n  Red.prototype.convertTo = function convertTo (num) {\n    var r = num.umod(this.m);\n\n    return r === num ? r.clone() : r;\n  };\n\n  Red.prototype.convertFrom = function convertFrom (num) {\n    var res = num.clone();\n    res.red = null;\n    return res;\n  };\n\n  //\n  // Montgomery method engine\n  //\n\n  BN.mont = function mont (num) {\n    return new Mont(num);\n  };\n\n  function Mont (m) {\n    Red.call(this, m);\n\n    this.shift = this.m.bitLength();\n    if (this.shift % 26 !== 0) {\n      this.shift += 26 - (this.shift % 26);\n    }\n\n    this.r = new BN(1).iushln(this.shift);\n    this.r2 = this.imod(this.r.sqr());\n    this.rinv = this.r._invmp(this.m);\n\n    this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);\n    this.minv = this.minv.umod(this.r);\n    this.minv = this.r.sub(this.minv);\n  }\n  inherits(Mont, Red);\n\n  Mont.prototype.convertTo = function convertTo (num) {\n    return this.imod(num.ushln(this.shift));\n  };\n\n  Mont.prototype.convertFrom = function convertFrom (num) {\n    var r = this.imod(num.mul(this.rinv));\n    r.red = null;\n    return r;\n  };\n\n  Mont.prototype.imul = function imul (a, b) {\n    if (a.isZero() || b.isZero()) {\n      a.words[0] = 0;\n      a.length = 1;\n      return a;\n    }\n\n    var t = a.imul(b);\n    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n    var u = t.isub(c).iushrn(this.shift);\n    var res = u;\n\n    if (u.cmp(this.m) >= 0) {\n      res = u.isub(this.m);\n    } else if (u.cmpn(0) < 0) {\n      res = u.iadd(this.m);\n    }\n\n    return res._forceRed(this);\n  };\n\n  Mont.prototype.mul = function mul (a, b) {\n    if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);\n\n    var t = a.mul(b);\n    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n    var u = t.isub(c).iushrn(this.shift);\n    var res = u;\n    if (u.cmp(this.m) >= 0) {\n      res = u.isub(this.m);\n    } else if (u.cmpn(0) < 0) {\n      res = u.iadd(this.m);\n    }\n\n    return res._forceRed(this);\n  };\n\n  Mont.prototype.invm = function invm (a) {\n    // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R\n    var res = this.imod(a._invmp(this.m).mul(this.r2));\n    return res._forceRed(this);\n  };\n})(typeof module === 'undefined' || module, this);\n\n},{}],5:[function(require,module,exports){\n\n},{}],6:[function(require,module,exports){\n/*!\n * The buffer module from node.js, for the browser.\n *\n * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>\n * @license  MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nvar K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n *   === true    Use Uint8Array implementation (fastest)\n *   === false   Print warning and recommend using `buffer` v4.x which has an Object\n *               implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT) {\n  console.error(\n    'This browser lacks typed array (Uint8Array) support which is required by ' +\n    '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.')\n}\n\nfunction typedArraySupport () {\n  // Can typed array instances can be augmented?\n  try {\n    var arr = new Uint8Array(1)\n    arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n    return arr.foo() === 42\n  } catch (e) {\n    return false\n  }\n}\n\nfunction createBuffer (length) {\n  if (length > K_MAX_LENGTH) {\n    throw new RangeError('Invalid typed array length')\n  }\n  // Return an augmented `Uint8Array` instance\n  var buf = new Uint8Array(length)\n  buf.__proto__ = Buffer.prototype\n  return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n  // Common case.\n  if (typeof arg === 'number') {\n    if (typeof encodingOrOffset === 'string') {\n      throw new Error(\n        'If encoding is specified then the first argument must be a string'\n      )\n    }\n    return allocUnsafe(arg)\n  }\n  return from(arg, encodingOrOffset, length)\n}\n\n// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\nif (typeof Symbol !== 'undefined' && Symbol.species &&\n    Buffer[Symbol.species] === Buffer) {\n  Object.defineProperty(Buffer, Symbol.species, {\n    value: null,\n    configurable: true,\n    enumerable: false,\n    writable: false\n  })\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n  if (typeof value === 'number') {\n    throw new TypeError('\"value\" argument must not be a number')\n  }\n\n  if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n    return fromArrayBuffer(value, encodingOrOffset, length)\n  }\n\n  if (typeof value === 'string') {\n    return fromString(value, encodingOrOffset)\n  }\n\n  return fromObject(value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n  return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nBuffer.prototype.__proto__ = Uint8Array.prototype\nBuffer.__proto__ = Uint8Array\n\nfunction assertSize (size) {\n  if (typeof size !== 'number') {\n    throw new TypeError('\"size\" argument must be a number')\n  } else if (size < 0) {\n    throw new RangeError('\"size\" argument must not be negative')\n  }\n}\n\nfunction alloc (size, fill, encoding) {\n  assertSize(size)\n  if (size <= 0) {\n    return createBuffer(size)\n  }\n  if (fill !== undefined) {\n    // Only pay attention to encoding if it's a string. This\n    // prevents accidentally sending in a number that would\n    // be interpretted as a start offset.\n    return typeof encoding === 'string'\n      ? createBuffer(size).fill(fill, encoding)\n      : createBuffer(size).fill(fill)\n  }\n  return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n  return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n  assertSize(size)\n  return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n  return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n  return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n  if (typeof encoding !== 'string' || encoding === '') {\n    encoding = 'utf8'\n  }\n\n  if (!Buffer.isEncoding(encoding)) {\n    throw new TypeError('\"encoding\" must be a valid string encoding')\n  }\n\n  var length = byteLength(string, encoding) | 0\n  var buf = createBuffer(length)\n\n  var actual = buf.write(string, encoding)\n\n  if (actual !== length) {\n    // Writing a hex string, for example, that contains invalid characters will\n    // cause everything after the first invalid character to be ignored. (e.g.\n    // 'abxxcd' will be treated as 'ab')\n    buf = buf.slice(0, actual)\n  }\n\n  return buf\n}\n\nfunction fromArrayLike (array) {\n  var length = array.length < 0 ? 0 : checked(array.length) | 0\n  var buf = createBuffer(length)\n  for (var i = 0; i < length; i += 1) {\n    buf[i] = array[i] & 255\n  }\n  return buf\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n  array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n  if (byteOffset < 0 || array.byteLength < byteOffset) {\n    throw new RangeError('\\'offset\\' is out of bounds')\n  }\n\n  if (array.byteLength < byteOffset + (length || 0)) {\n    throw new RangeError('\\'length\\' is out of bounds')\n  }\n\n  var buf\n  if (byteOffset === undefined && length === undefined) {\n    buf = new Uint8Array(array)\n  } else if (length === undefined) {\n    buf = new Uint8Array(array, byteOffset)\n  } else {\n    buf = new Uint8Array(array, byteOffset, length)\n  }\n\n  // Return an augmented `Uint8Array` instance\n  buf.__proto__ = Buffer.prototype\n  return buf\n}\n\nfunction fromObject (obj) {\n  if (Buffer.isBuffer(obj)) {\n    var len = checked(obj.length) | 0\n    var buf = createBuffer(len)\n\n    if (buf.length === 0) {\n      return buf\n    }\n\n    obj.copy(buf, 0, 0, len)\n    return buf\n  }\n\n  if (obj) {\n    if ((typeof ArrayBuffer !== 'undefined' &&\n        obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n      if (typeof obj.length !== 'number' || isnan(obj.length)) {\n        return createBuffer(0)\n      }\n      return fromArrayLike(obj)\n    }\n\n    if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n      return fromArrayLike(obj.data)\n    }\n  }\n\n  throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n  // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n  // length is NaN (which is otherwise coerced to zero.)\n  if (length >= K_MAX_LENGTH) {\n    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n                         'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n  }\n  return length | 0\n}\n\nfunction SlowBuffer (length) {\n  if (+length != length) { // eslint-disable-line eqeqeq\n    length = 0\n  }\n  return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n  return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n    throw new TypeError('Arguments must be Buffers')\n  }\n\n  if (a === b) return 0\n\n  var x = a.length\n  var y = b.length\n\n  for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n    if (a[i] !== b[i]) {\n      x = a[i]\n      y = b[i]\n      break\n    }\n  }\n\n  if (x < y) return -1\n  if (y < x) return 1\n  return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n  switch (String(encoding).toLowerCase()) {\n    case 'hex':\n    case 'utf8':\n    case 'utf-8':\n    case 'ascii':\n    case 'latin1':\n    case 'binary':\n    case 'base64':\n    case 'ucs2':\n    case 'ucs-2':\n    case 'utf16le':\n    case 'utf-16le':\n      return true\n    default:\n      return false\n  }\n}\n\nBuffer.concat = function concat (list, length) {\n  if (!Array.isArray(list)) {\n    throw new TypeError('\"list\" argument must be an Array of Buffers')\n  }\n\n  if (list.length === 0) {\n    return Buffer.alloc(0)\n  }\n\n  var i\n  if (length === undefined) {\n    length = 0\n    for (i = 0; i < list.length; ++i) {\n      length += list[i].length\n    }\n  }\n\n  var buffer = Buffer.allocUnsafe(length)\n  var pos = 0\n  for (i = 0; i < list.length; ++i) {\n    var buf = list[i]\n    if (!Buffer.isBuffer(buf)) {\n      throw new TypeError('\"list\" argument must be an Array of Buffers')\n    }\n    buf.copy(buffer, pos)\n    pos += buf.length\n  }\n  return buffer\n}\n\nfunction byteLength (string, encoding) {\n  if (Buffer.isBuffer(string)) {\n    return string.length\n  }\n  if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n      (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n    return string.byteLength\n  }\n  if (typeof string !== 'string') {\n    string = '' + string\n  }\n\n  var len = string.length\n  if (len === 0) return 0\n\n  // Use a for loop to avoid recursion\n  var loweredCase = false\n  for (;;) {\n    switch (encoding) {\n      case 'ascii':\n      case 'latin1':\n      case 'binary':\n        return len\n      case 'utf8':\n      case 'utf-8':\n      case undefined:\n        return utf8ToBytes(string).length\n      case 'ucs2':\n      case 'ucs-2':\n      case 'utf16le':\n      case 'utf-16le':\n        return len * 2\n      case 'hex':\n        return len >>> 1\n      case 'base64':\n        return base64ToBytes(string).length\n      default:\n        if (loweredCase) return utf8ToBytes(string).length // assume utf8\n        encoding = ('' + encoding).toLowerCase()\n        loweredCase = true\n    }\n  }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n  var loweredCase = false\n\n  // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n  // property of a typed array.\n\n  // This behaves neither like String nor Uint8Array in that we set start/end\n  // to their upper/lower bounds if the value passed is out of range.\n  // undefined is handled specially as per ECMA-262 6th Edition,\n  // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n  if (start === undefined || start < 0) {\n    start = 0\n  }\n  // Return early if start > this.length. Done here to prevent potential uint32\n  // coercion fail below.\n  if (start > this.length) {\n    return ''\n  }\n\n  if (end === undefined || end > this.length) {\n    end = this.length\n  }\n\n  if (end <= 0) {\n    return ''\n  }\n\n  // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n  end >>>= 0\n  start >>>= 0\n\n  if (end <= start) {\n    return ''\n  }\n\n  if (!encoding) encoding = 'utf8'\n\n  while (true) {\n    switch (encoding) {\n      case 'hex':\n        return hexSlice(this, start, end)\n\n      case 'utf8':\n      case 'utf-8':\n        return utf8Slice(this, start, end)\n\n      case 'ascii':\n        return asciiSlice(this, start, end)\n\n      case 'latin1':\n      case 'binary':\n        return latin1Slice(this, start, end)\n\n      case 'base64':\n        return base64Slice(this, start, end)\n\n      case 'ucs2':\n      case 'ucs-2':\n      case 'utf16le':\n      case 'utf-16le':\n        return utf16leSlice(this, start, end)\n\n      default:\n        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n        encoding = (encoding + '').toLowerCase()\n        loweredCase = true\n    }\n  }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n  var i = b[n]\n  b[n] = b[m]\n  b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n  var len = this.length\n  if (len % 2 !== 0) {\n    throw new RangeError('Buffer size must be a multiple of 16-bits')\n  }\n  for (var i = 0; i < len; i += 2) {\n    swap(this, i, i + 1)\n  }\n  return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n  var len = this.length\n  if (len % 4 !== 0) {\n    throw new RangeError('Buffer size must be a multiple of 32-bits')\n  }\n  for (var i = 0; i < len; i += 4) {\n    swap(this, i, i + 3)\n    swap(this, i + 1, i + 2)\n  }\n  return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n  var len = this.length\n  if (len % 8 !== 0) {\n    throw new RangeError('Buffer size must be a multiple of 64-bits')\n  }\n  for (var i = 0; i < len; i += 8) {\n    swap(this, i, i + 7)\n    swap(this, i + 1, i + 6)\n    swap(this, i + 2, i + 5)\n    swap(this, i + 3, i + 4)\n  }\n  return this\n}\n\nBuffer.prototype.toString = function toString () {\n  var length = this.length\n  if (length === 0) return ''\n  if (arguments.length === 0) return utf8Slice(this, 0, length)\n  return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n  if (this === b) return true\n  return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n  var str = ''\n  var max = exports.INSPECT_MAX_BYTES\n  if (this.length > 0) {\n    str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n    if (this.length > max) str += ' ... '\n  }\n  return '<Buffer ' + str + '>'\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n  if (!Buffer.isBuffer(target)) {\n    throw new TypeError('Argument must be a Buffer')\n  }\n\n  if (start === undefined) {\n    start = 0\n  }\n  if (end === undefined) {\n    end = target ? target.length : 0\n  }\n  if (thisStart === undefined) {\n    thisStart = 0\n  }\n  if (thisEnd === undefined) {\n    thisEnd = this.length\n  }\n\n  if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n    throw new RangeError('out of range index')\n  }\n\n  if (thisStart >= thisEnd && start >= end) {\n    return 0\n  }\n  if (thisStart >= thisEnd) {\n    return -1\n  }\n  if (start >= end) {\n    return 1\n  }\n\n  start >>>= 0\n  end >>>= 0\n  thisStart >>>= 0\n  thisEnd >>>= 0\n\n  if (this === target) return 0\n\n  var x = thisEnd - thisStart\n  var y = end - start\n  var len = Math.min(x, y)\n\n  var thisCopy = this.slice(thisStart, thisEnd)\n  var targetCopy = target.slice(start, end)\n\n  for (var i = 0; i < len; ++i) {\n    if (thisCopy[i] !== targetCopy[i]) {\n      x = thisCopy[i]\n      y = targetCopy[i]\n      break\n    }\n  }\n\n  if (x < y) return -1\n  if (y < x) return 1\n  return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n  // Empty buffer means no match\n  if (buffer.length === 0) return -1\n\n  // Normalize byteOffset\n  if (typeof byteOffset === 'string') {\n    encoding = byteOffset\n    byteOffset = 0\n  } else if (byteOffset > 0x7fffffff) {\n    byteOffset = 0x7fffffff\n  } else if (byteOffset < -0x80000000) {\n    byteOffset = -0x80000000\n  }\n  byteOffset = +byteOffset  // Coerce to Number.\n  if (isNaN(byteOffset)) {\n    // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n    byteOffset = dir ? 0 : (buffer.length - 1)\n  }\n\n  // Normalize byteOffset: negative offsets start from the end of the buffer\n  if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n  if (byteOffset >= buffer.length) {\n    if (dir) return -1\n    else byteOffset = buffer.length - 1\n  } else if (byteOffset < 0) {\n    if (dir) byteOffset = 0\n    else return -1\n  }\n\n  // Normalize val\n  if (typeof val === 'string') {\n    val = Buffer.from(val, encoding)\n  }\n\n  // Finally, search either indexOf (if dir is true) or lastIndexOf\n  if (Buffer.isBuffer(val)) {\n    // Special case: looking for empty string/buffer always fails\n    if (val.length === 0) {\n      return -1\n    }\n    return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n  } else if (typeof val === 'number') {\n    val = val & 0xFF // Search for a byte value [0-255]\n    if (typeof Uint8Array.prototype.indexOf === 'function') {\n      if (dir) {\n        return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n      } else {\n        return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n      }\n    }\n    return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n  }\n\n  throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n  var indexSize = 1\n  var arrLength = arr.length\n  var valLength = val.length\n\n  if (encoding !== undefined) {\n    encoding = String(encoding).toLowerCase()\n    if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n        encoding === 'utf16le' || encoding === 'utf-16le') {\n      if (arr.length < 2 || val.length < 2) {\n        return -1\n      }\n      indexSize = 2\n      arrLength /= 2\n      valLength /= 2\n      byteOffset /= 2\n    }\n  }\n\n  function read (buf, i) {\n    if (indexSize === 1) {\n      return buf[i]\n    } else {\n      return buf.readUInt16BE(i * indexSize)\n    }\n  }\n\n  var i\n  if (dir) {\n    var foundIndex = -1\n    for (i = byteOffset; i < arrLength; i++) {\n      if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n        if (foundIndex === -1) foundIndex = i\n        if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n      } else {\n        if (foundIndex !== -1) i -= i - foundIndex\n        foundIndex = -1\n      }\n    }\n  } else {\n    if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n    for (i = byteOffset; i >= 0; i--) {\n      var found = true\n      for (var j = 0; j < valLength; j++) {\n        if (read(arr, i + j) !== read(val, j)) {\n          found = false\n          break\n        }\n      }\n      if (found) return i\n    }\n  }\n\n  return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n  return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n  return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n  return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n  offset = Number(offset) || 0\n  var remaining = buf.length - offset\n  if (!length) {\n    length = remaining\n  } else {\n    length = Number(length)\n    if (length > remaining) {\n      length = remaining\n    }\n  }\n\n  // must be an even number of digits\n  var strLen = string.length\n  if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n  if (length > strLen / 2) {\n    length = strLen / 2\n  }\n  for (var i = 0; i < length; ++i) {\n    var parsed = parseInt(string.substr(i * 2, 2), 16)\n    if (isNaN(parsed)) return i\n    buf[offset + i] = parsed\n  }\n  return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n  return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n  return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n  return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n  return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n  return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n  // Buffer#write(string)\n  if (offset === undefined) {\n    encoding = 'utf8'\n    length = this.length\n    offset = 0\n  // Buffer#write(string, encoding)\n  } else if (length === undefined && typeof offset === 'string') {\n    encoding = offset\n    length = this.length\n    offset = 0\n  // Buffer#write(string, offset[, length][, encoding])\n  } else if (isFinite(offset)) {\n    offset = offset >>> 0\n    if (isFinite(length)) {\n      length = length >>> 0\n      if (encoding === undefined) encoding = 'utf8'\n    } else {\n      encoding = length\n      length = undefined\n    }\n  // legacy write(string, encoding, offset, length) - remove in v0.13\n  } else {\n    throw new Error(\n      'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n    )\n  }\n\n  var remaining = this.length - offset\n  if (length === undefined || length > remaining) length = remaining\n\n  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n    throw new RangeError('Attempt to write outside buffer bounds')\n  }\n\n  if (!encoding) encoding = 'utf8'\n\n  var loweredCase = false\n  for (;;) {\n    switch (encoding) {\n      case 'hex':\n        return hexWrite(this, string, offset, length)\n\n      case 'utf8':\n      case 'utf-8':\n        return utf8Write(this, string, offset, length)\n\n      case 'ascii':\n        return asciiWrite(this, string, offset, length)\n\n      case 'latin1':\n      case 'binary':\n        return latin1Write(this, string, offset, length)\n\n      case 'base64':\n        // Warning: maxLength not taken into account in base64Write\n        return base64Write(this, string, offset, length)\n\n      case 'ucs2':\n      case 'ucs-2':\n      case 'utf16le':\n      case 'utf-16le':\n        return ucs2Write(this, string, offset, length)\n\n      default:\n        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n        encoding = ('' + encoding).toLowerCase()\n        loweredCase = true\n    }\n  }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n  return {\n    type: 'Buffer',\n    data: Array.prototype.slice.call(this._arr || this, 0)\n  }\n}\n\nfunction base64Slice (buf, start, end) {\n  if (start === 0 && end === buf.length) {\n    return base64.fromByteArray(buf)\n  } else {\n    return base64.fromByteArray(buf.slice(start, end))\n  }\n}\n\nfunction utf8Slice (buf, start, end) {\n  end = Math.min(buf.length, end)\n  var res = []\n\n  var i = start\n  while (i < end) {\n    var firstByte = buf[i]\n    var codePoint = null\n    var bytesPerSequence = (firstByte > 0xEF) ? 4\n      : (firstByte > 0xDF) ? 3\n      : (firstByte > 0xBF) ? 2\n      : 1\n\n    if (i + bytesPerSequence <= end) {\n      var secondByte, thirdByte, fourthByte, tempCodePoint\n\n      switch (bytesPerSequence) {\n        case 1:\n          if (firstByte < 0x80) {\n            codePoint = firstByte\n          }\n          break\n        case 2:\n          secondByte = buf[i + 1]\n          if ((secondByte & 0xC0) === 0x80) {\n            tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n            if (tempCodePoint > 0x7F) {\n              codePoint = tempCodePoint\n            }\n          }\n          break\n        case 3:\n          secondByte = buf[i + 1]\n          thirdByte = buf[i + 2]\n          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n            tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n            if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n              codePoint = tempCodePoint\n            }\n          }\n          break\n        case 4:\n          secondByte = buf[i + 1]\n          thirdByte = buf[i + 2]\n          fourthByte = buf[i + 3]\n          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n            tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n            if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n              codePoint = tempCodePoint\n            }\n          }\n      }\n    }\n\n    if (codePoint === null) {\n      // we did not generate a valid codePoint so insert a\n      // replacement char (U+FFFD) and advance only 1 byte\n      codePoint = 0xFFFD\n      bytesPerSequence = 1\n    } else if (codePoint > 0xFFFF) {\n      // encode to utf16 (surrogate pair dance)\n      codePoint -= 0x10000\n      res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n      codePoint = 0xDC00 | codePoint & 0x3FF\n    }\n\n    res.push(codePoint)\n    i += bytesPerSequence\n  }\n\n  return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n  var len = codePoints.length\n  if (len <= MAX_ARGUMENTS_LENGTH) {\n    return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n  }\n\n  // Decode in chunks to avoid \"call stack size exceeded\".\n  var res = ''\n  var i = 0\n  while (i < len) {\n    res += String.fromCharCode.apply(\n      String,\n      codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n    )\n  }\n  return res\n}\n\nfunction asciiSlice (buf, start, end) {\n  var ret = ''\n  end = Math.min(buf.length, end)\n\n  for (var i = start; i < end; ++i) {\n    ret += String.fromCharCode(buf[i] & 0x7F)\n  }\n  return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n  var ret = ''\n  end = Math.min(buf.length, end)\n\n  for (var i = start; i < end; ++i) {\n    ret += String.fromCharCode(buf[i])\n  }\n  return ret\n}\n\nfunction hexSlice (buf, start, end) {\n  var len = buf.length\n\n  if (!start || start < 0) start = 0\n  if (!end || end < 0 || end > len) end = len\n\n  var out = ''\n  for (var i = start; i < end; ++i) {\n    out += toHex(buf[i])\n  }\n  return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n  var bytes = buf.slice(start, end)\n  var res = ''\n  for (var i = 0; i < bytes.length; i += 2) {\n    res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n  }\n  return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n  var len = this.length\n  start = ~~start\n  end = end === undefined ? len : ~~end\n\n  if (start < 0) {\n    start += len\n    if (start < 0) start = 0\n  } else if (start > len) {\n    start = len\n  }\n\n  if (end < 0) {\n    end += len\n    if (end < 0) end = 0\n  } else if (end > len) {\n    end = len\n  }\n\n  if (end < start) end = start\n\n  var newBuf = this.subarray(start, end)\n  // Return an augmented `Uint8Array` instance\n  newBuf.__proto__ = Buffer.prototype\n  return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n  if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n  var val = this[offset]\n  var mul = 1\n  var i = 0\n  while (++i < byteLength && (mul *= 0x100)) {\n    val += this[offset + i] * mul\n  }\n\n  return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) {\n    checkOffset(offset, byteLength, this.length)\n  }\n\n  var val = this[offset + --byteLength]\n  var mul = 1\n  while (byteLength > 0 && (mul *= 0x100)) {\n    val += this[offset + --byteLength] * mul\n  }\n\n  return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 1, this.length)\n  return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return ((this[offset]) |\n      (this[offset + 1] << 8) |\n      (this[offset + 2] << 16)) +\n      (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return (this[offset] * 0x1000000) +\n    ((this[offset + 1] << 16) |\n    (this[offset + 2] << 8) |\n    this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n  var val = this[offset]\n  var mul = 1\n  var i = 0\n  while (++i < byteLength && (mul *= 0x100)) {\n    val += this[offset + i] * mul\n  }\n  mul *= 0x80\n\n  if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n  return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n  var i = byteLength\n  var mul = 1\n  var val = this[offset + --i]\n  while (i > 0 && (mul *= 0x100)) {\n    val += this[offset + --i] * mul\n  }\n  mul *= 0x80\n\n  if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n  return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 1, this.length)\n  if (!(this[offset] & 0x80)) return (this[offset])\n  return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  var val = this[offset] | (this[offset + 1] << 8)\n  return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  var val = this[offset + 1] | (this[offset] << 8)\n  return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return (this[offset]) |\n    (this[offset + 1] << 8) |\n    (this[offset + 2] << 16) |\n    (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return (this[offset] << 24) |\n    (this[offset + 1] << 16) |\n    (this[offset + 2] << 8) |\n    (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n  return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n  return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 8, this.length)\n  return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 8, this.length)\n  return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n  if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n  if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n  if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) {\n    var maxBytes = Math.pow(2, 8 * byteLength) - 1\n    checkInt(this, value, offset, byteLength, maxBytes, 0)\n  }\n\n  var mul = 1\n  var i = 0\n  this[offset] = value & 0xFF\n  while (++i < byteLength && (mul *= 0x100)) {\n    this[offset + i] = (value / mul) & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) {\n    var maxBytes = Math.pow(2, 8 * byteLength) - 1\n    checkInt(this, value, offset, byteLength, maxBytes, 0)\n  }\n\n  var i = byteLength - 1\n  var mul = 1\n  this[offset + i] = value & 0xFF\n  while (--i >= 0 && (mul *= 0x100)) {\n    this[offset + i] = (value / mul) & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n  this[offset] = (value & 0xff)\n  return offset + 1\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n  this[offset] = (value & 0xff)\n  this[offset + 1] = (value >>> 8)\n  return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n  this[offset] = (value >>> 8)\n  this[offset + 1] = (value & 0xff)\n  return offset + 2\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n  this[offset + 3] = (value >>> 24)\n  this[offset + 2] = (value >>> 16)\n  this[offset + 1] = (value >>> 8)\n  this[offset] = (value & 0xff)\n  return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n  this[offset] = (value >>> 24)\n  this[offset + 1] = (value >>> 16)\n  this[offset + 2] = (value >>> 8)\n  this[offset + 3] = (value & 0xff)\n  return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    var limit = Math.pow(2, 8 * byteLength - 1)\n\n    checkInt(this, value, offset, byteLength, limit - 1, -limit)\n  }\n\n  var i = 0\n  var mul = 1\n  var sub = 0\n  this[offset] = value & 0xFF\n  while (++i < byteLength && (mul *= 0x100)) {\n    if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n      sub = 1\n    }\n    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    var limit = Math.pow(2, 8 * byteLength - 1)\n\n    checkInt(this, value, offset, byteLength, limit - 1, -limit)\n  }\n\n  var i = byteLength - 1\n  var mul = 1\n  var sub = 0\n  this[offset + i] = value & 0xFF\n  while (--i >= 0 && (mul *= 0x100)) {\n    if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n      sub = 1\n    }\n    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n  if (value < 0) value = 0xff + value + 1\n  this[offset] = (value & 0xff)\n  return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n  this[offset] = (value & 0xff)\n  this[offset + 1] = (value >>> 8)\n  return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n  this[offset] = (value >>> 8)\n  this[offset + 1] = (value & 0xff)\n  return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n  this[offset] = (value & 0xff)\n  this[offset + 1] = (value >>> 8)\n  this[offset + 2] = (value >>> 16)\n  this[offset + 3] = (value >>> 24)\n  return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n  if (value < 0) value = 0xffffffff + value + 1\n  this[offset] = (value >>> 24)\n  this[offset + 1] = (value >>> 16)\n  this[offset + 2] = (value >>> 8)\n  this[offset + 3] = (value & 0xff)\n  return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n  if (offset + ext > buf.length) throw new RangeError('Index out of range')\n  if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n  }\n  ieee754.write(buf, value, offset, littleEndian, 23, 4)\n  return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n  return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n  return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n  }\n  ieee754.write(buf, value, offset, littleEndian, 52, 8)\n  return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n  return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n  return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n  if (!start) start = 0\n  if (!end && end !== 0) end = this.length\n  if (targetStart >= target.length) targetStart = target.length\n  if (!targetStart) targetStart = 0\n  if (end > 0 && end < start) end = start\n\n  // Copy 0 bytes; we're done\n  if (end === start) return 0\n  if (target.length === 0 || this.length === 0) return 0\n\n  // Fatal error conditions\n  if (targetStart < 0) {\n    throw new RangeError('targetStart out of bounds')\n  }\n  if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n  if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n  // Are we oob?\n  if (end > this.length) end = this.length\n  if (target.length - targetStart < end - start) {\n    end = target.length - targetStart + start\n  }\n\n  var len = end - start\n  var i\n\n  if (this === target && start < targetStart && targetStart < end) {\n    // descending copy from end\n    for (i = len - 1; i >= 0; --i) {\n      target[i + targetStart] = this[i + start]\n    }\n  } else if (len < 1000) {\n    // ascending copy from start\n    for (i = 0; i < len; ++i) {\n      target[i + targetStart] = this[i + start]\n    }\n  } else {\n    Uint8Array.prototype.set.call(\n      target,\n      this.subarray(start, start + len),\n      targetStart\n    )\n  }\n\n  return len\n}\n\n// Usage:\n//    buffer.fill(number[, offset[, end]])\n//    buffer.fill(buffer[, offset[, end]])\n//    buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n  // Handle string cases:\n  if (typeof val === 'string') {\n    if (typeof start === 'string') {\n      encoding = start\n      start = 0\n      end = this.length\n    } else if (typeof end === 'string') {\n      encoding = end\n      end = this.length\n    }\n    if (val.length === 1) {\n      var code = val.charCodeAt(0)\n      if (code < 256) {\n        val = code\n      }\n    }\n    if (encoding !== undefined && typeof encoding !== 'string') {\n      throw new TypeError('encoding must be a string')\n    }\n    if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n      throw new TypeError('Unknown encoding: ' + encoding)\n    }\n  } else if (typeof val === 'number') {\n    val = val & 255\n  }\n\n  // Invalid ranges are not set to a default, so can range check early.\n  if (start < 0 || this.length < start || this.length < end) {\n    throw new RangeError('Out of range index')\n  }\n\n  if (end <= start) {\n    return this\n  }\n\n  start = start >>> 0\n  end = end === undefined ? this.length : end >>> 0\n\n  if (!val) val = 0\n\n  var i\n  if (typeof val === 'number') {\n    for (i = start; i < end; ++i) {\n      this[i] = val\n    }\n  } else {\n    var bytes = Buffer.isBuffer(val)\n      ? val\n      : new Buffer(val, encoding)\n    var len = bytes.length\n    for (i = 0; i < end - start; ++i) {\n      this[i + start] = bytes[i % len]\n    }\n  }\n\n  return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n  // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n  str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n  // Node converts strings with length < 2 to ''\n  if (str.length < 2) return ''\n  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n  while (str.length % 4 !== 0) {\n    str = str + '='\n  }\n  return str\n}\n\nfunction stringtrim (str) {\n  if (str.trim) return str.trim()\n  return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n  if (n < 16) return '0' + n.toString(16)\n  return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n  units = units || Infinity\n  var codePoint\n  var length = string.length\n  var leadSurrogate = null\n  var bytes = []\n\n  for (var i = 0; i < length; ++i) {\n    codePoint = string.charCodeAt(i)\n\n    // is surrogate component\n    if (codePoint > 0xD7FF && codePoint < 0xE000) {\n      // last char was a lead\n      if (!leadSurrogate) {\n        // no lead yet\n        if (codePoint > 0xDBFF) {\n          // unexpected trail\n          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n          continue\n        } else if (i + 1 === length) {\n          // unpaired lead\n          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n          continue\n        }\n\n        // valid lead\n        leadSurrogate = codePoint\n\n        continue\n      }\n\n      // 2 leads in a row\n      if (codePoint < 0xDC00) {\n        if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n        leadSurrogate = codePoint\n        continue\n      }\n\n      // valid surrogate pair\n      codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n    } else if (leadSurrogate) {\n      // valid bmp char, but last char was a lead\n      if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n    }\n\n    leadSurrogate = null\n\n    // encode utf8\n    if (codePoint < 0x80) {\n      if ((units -= 1) < 0) break\n      bytes.push(codePoint)\n    } else if (codePoint < 0x800) {\n      if ((units -= 2) < 0) break\n      bytes.push(\n        codePoint >> 0x6 | 0xC0,\n        codePoint & 0x3F | 0x80\n      )\n    } else if (codePoint < 0x10000) {\n      if ((units -= 3) < 0) break\n      bytes.push(\n        codePoint >> 0xC | 0xE0,\n        codePoint >> 0x6 & 0x3F | 0x80,\n        codePoint & 0x3F | 0x80\n      )\n    } else if (codePoint < 0x110000) {\n      if ((units -= 4) < 0) break\n      bytes.push(\n        codePoint >> 0x12 | 0xF0,\n        codePoint >> 0xC & 0x3F | 0x80,\n        codePoint >> 0x6 & 0x3F | 0x80,\n        codePoint & 0x3F | 0x80\n      )\n    } else {\n      throw new Error('Invalid code point')\n    }\n  }\n\n  return bytes\n}\n\nfunction asciiToBytes (str) {\n  var byteArray = []\n  for (var i = 0; i < str.length; ++i) {\n    // Node's code seems to be doing this and not & 0x7F..\n    byteArray.push(str.charCodeAt(i) & 0xFF)\n  }\n  return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n  var c, hi, lo\n  var byteArray = []\n  for (var i = 0; i < str.length; ++i) {\n    if ((units -= 2) < 0) break\n\n    c = str.charCodeAt(i)\n    hi = c >> 8\n    lo = c % 256\n    byteArray.push(lo)\n    byteArray.push(hi)\n  }\n\n  return byteArray\n}\n\nfunction base64ToBytes (str) {\n  return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n  for (var i = 0; i < length; ++i) {\n    if ((i + offset >= dst.length) || (i >= src.length)) break\n    dst[i + offset] = src[i]\n  }\n  return i\n}\n\nfunction isnan (val) {\n  return val !== val // eslint-disable-line no-self-compare\n}\n\n},{\"base64-js\":3,\"ieee754\":9}],7:[function(require,module,exports){\n(function (Buffer){\n'use strict';\n\n/* eslint-disable */\n\nvar utils = require('./utils/index.js');\nvar uint256Coder = utils.uint256Coder;\nvar coderBoolean = utils.coderBoolean;\nvar coderFixedBytes = utils.coderFixedBytes;\nvar coderAddress = utils.coderAddress;\nvar coderDynamicBytes = utils.coderDynamicBytes;\nvar coderString = utils.coderString;\nvar coderArray = utils.coderArray;\nvar paramTypePart = utils.paramTypePart;\nvar getParamCoder = utils.getParamCoder;\n\nfunction Result() {}\n\nfunction encodeParams(types, values) {\n  if (types.length !== values.length) {\n    throw new Error('[ethjs-abi] while encoding params, types/values mismatch, types length ' + types.length + ' should be ' + values.length);\n  }\n\n  var parts = [];\n\n  types.forEach(function (type, index) {\n    var coder = getParamCoder(type);\n    parts.push({ dynamic: coder.dynamic, value: coder.encode(values[index]) });\n  });\n\n  function alignSize(size) {\n    return parseInt(32 * Math.ceil(size / 32));\n  }\n\n  var staticSize = 0,\n      dynamicSize = 0;\n  parts.forEach(function (part) {\n    if (part.dynamic) {\n      staticSize += 32;\n      dynamicSize += alignSize(part.value.length);\n    } else {\n      staticSize += alignSize(part.value.length);\n    }\n  });\n\n  var offset = 0,\n      dynamicOffset = staticSize;\n  var data = new Buffer(staticSize + dynamicSize);\n\n  parts.forEach(function (part, index) {\n    if (part.dynamic) {\n      uint256Coder.encode(dynamicOffset).copy(data, offset);\n      offset += 32;\n\n      part.value.copy(data, dynamicOffset);\n      dynamicOffset += alignSize(part.value.length);\n    } else {\n      part.value.copy(data, offset);\n      offset += alignSize(part.value.length);\n    }\n  });\n\n  return '0x' + data.toString('hex');\n}\n\n// decode bytecode data from output names and types\nfunction decodeParams(names, types, data) {\n  // Names is optional, so shift over all the parameters if not provided\n  if (arguments.length < 3) {\n    data = types;\n    types = names;\n    names = [];\n  }\n\n  data = utils.hexOrBuffer(data);\n  var values = new Result();\n\n  var offset = 0;\n  types.forEach(function (type, index) {\n    var coder = getParamCoder(type);\n    if (coder.dynamic) {\n      var dynamicOffset = uint256Coder.decode(data, offset);\n      var result = coder.decode(data, dynamicOffset.value.toNumber());\n      offset += dynamicOffset.consumed;\n    } else {\n      var result = coder.decode(data, offset);\n      offset += result.consumed;\n    }\n    values[index] = result.value;\n    if (names[index]) {\n      values[names[index]] = result.value;\n    }\n  });\n  return values;\n}\n\n// encode method ABI object with values in an array, output bytecode\nfunction encodeMethod(method, values) {\n  var signature = method.name + '(' + utils.getKeys(method.inputs, 'type').join(',') + ')';\n  var signatureEncoded = '0x' + new Buffer(utils.keccak256(signature), 'hex').slice(0, 4).toString('hex');\n  var paramsEncoded = encodeParams(utils.getKeys(method.inputs, 'type'), values).substring(2);\n\n  return '' + signatureEncoded + paramsEncoded;\n}\n\n// decode method data bytecode, from method ABI object\nfunction decodeMethod(method, data) {\n  var outputNames = utils.getKeys(method.outputs, 'name', true);\n  var outputTypes = utils.getKeys(method.outputs, 'type');\n\n  return decodeParams(outputNames, outputTypes, utils.hexOrBuffer(data));\n}\n\n// decode method data bytecode, from method ABI object\nfunction encodeEvent(eventObject, values) {\n  return encodeMethod(eventObject, values);\n}\n\n// decode method data bytecode, from method ABI object\nfunction decodeEvent(eventObject, data) {\n  var inputNames = utils.getKeys(eventObject.inputs, 'name', true);\n  var inputTypes = utils.getKeys(eventObject.inputs, 'type');\n\n  return decodeParams(inputNames, inputTypes, utils.hexOrBuffer(data));\n}\n\nmodule.exports = {\n  encodeParams: encodeParams,\n  decodeParams: decodeParams,\n  encodeMethod: encodeMethod,\n  decodeMethod: decodeMethod,\n  encodeEvent: encodeEvent,\n  decodeEvent: decodeEvent\n};\n}).call(this,require(\"buffer\").Buffer)\n},{\"./utils/index.js\":8,\"buffer\":6}],8:[function(require,module,exports){\n(function (Buffer){\n'use strict';\n\nvar BN = require('bn.js');\nvar numberToBN = require('number-to-bn');\nvar keccak256 = require('js-sha3').keccak_256;\n\n// from ethereumjs-util\nfunction stripZeros(aInput) {\n  var a = aInput; // eslint-disable-line\n  var first = a[0]; // eslint-disable-line\n  while (a.length > 0 && first.toString() === '0') {\n    a = a.slice(1);\n    first = a[0];\n  }\n  return a;\n}\n\nfunction bnToBuffer(bnInput) {\n  var bn = bnInput; // eslint-disable-line\n  var hex = bn.toString(16); // eslint-disable-line\n  if (hex.length % 2) {\n    hex = '0' + hex;\n  }\n  return stripZeros(new Buffer(hex, 'hex'));\n}\n\nfunction isHexString(value, length) {\n  if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {\n    return false;\n  }\n  if (length && value.length !== 2 + 2 * length) {\n    return false;\n  }\n  return true;\n}\n\nfunction hexOrBuffer(valueInput, name) {\n  var value = valueInput; // eslint-disable-line\n  if (!Buffer.isBuffer(value)) {\n    if (!isHexString(value)) {\n      var error = new Error(name ? '[ethjs-abi] invalid ' + name : '[ethjs-abi] invalid hex or buffer, must be a prefixed alphanumeric even length hex string');\n      error.reason = '[ethjs-abi] invalid hex string, hex must be prefixed and alphanumeric (e.g. 0x023..)';\n      error.value = value;\n      throw error;\n    }\n\n    value = value.substring(2);\n    if (value.length % 2) {\n      value = '0' + value;\n    }\n    value = new Buffer(value, 'hex');\n  }\n\n  return value;\n}\n\nfunction hexlify(value) {\n  if (typeof value === 'number') {\n    return '0x' + bnToBuffer(new BN(value)).toString('hex');\n  } else if (value.mod || value.modulo) {\n    return '0x' + bnToBuffer(value).toString('hex');\n  } else {\n    // eslint-disable-line\n    return '0x' + hexOrBuffer(value).toString('hex');\n  }\n}\n\n// getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3]\nfunction getKeys(params, key, allowEmpty) {\n  var result = []; // eslint-disable-line\n\n  if (!Array.isArray(params)) {\n    throw new Error('[ethjs-abi] while getting keys, invalid params value ' + JSON.stringify(params));\n  }\n\n  for (var i = 0; i < params.length; i++) {\n    // eslint-disable-line\n    var value = params[i][key]; // eslint-disable-line\n    if (allowEmpty && !value) {\n      value = '';\n    } else if (typeof value !== 'string') {\n      throw new Error('[ethjs-abi] while getKeys found invalid ABI data structure, type value not string');\n    }\n    result.push(value);\n  }\n\n  return result;\n}\n\nfunction coderNumber(size, signed) {\n  return {\n    encode: function encodeNumber(valueInput) {\n      var value = valueInput; // eslint-disable-line\n\n      if (typeof value === 'object' && value.toString && (value.toTwos || value.dividedToIntegerBy)) {\n        value = value.toString(10).split('.')[0];\n      }\n\n      if (typeof value === 'string' || typeof value === 'number') {\n        value = String(value).split('.')[0];\n      }\n\n      value = numberToBN(value);\n      value = value.toTwos(size * 8).maskn(size * 8);\n      if (signed) {\n        value = value.fromTwos(size * 8).toTwos(256);\n      }\n      return value.toArrayLike(Buffer, 'be', 32);\n    },\n    decode: function decodeNumber(data, offset) {\n      var junkLength = 32 - size; // eslint-disable-line\n      var value = new BN(data.slice(offset + junkLength, offset + 32)); // eslint-disable-line\n      if (signed) {\n        value = value.fromTwos(size * 8);\n      } else {\n        value = value.maskn(size * 8);\n      }\n      return {\n        consumed: 32,\n        value: new BN(value.toString(10))\n      };\n    }\n  };\n}\nvar uint256Coder = coderNumber(32, false);\n\nvar coderBoolean = {\n  encode: function encodeBoolean(value) {\n    return uint256Coder.encode(value ? 1 : 0);\n  },\n  decode: function decodeBoolean(data, offset) {\n    var result = uint256Coder.decode(data, offset); // eslint-disable-line\n    return {\n      consumed: result.consumed,\n      value: !result.value.isZero()\n    };\n  }\n};\n\nfunction coderFixedBytes(length) {\n  return {\n    encode: function encodeFixedBytes(valueInput) {\n      var value = valueInput; // eslint-disable-line\n      value = hexOrBuffer(value);\n\n      if (value.length === 32) {\n        return value;\n      }\n\n      var result = new Buffer(32); // eslint-disable-line\n      result.fill(0);\n      value.copy(result);\n      return result;\n    },\n    decode: function decodeFixedBytes(data, offset) {\n      if (data.length < offset + 32) {\n        throw new Error('[ethjs-abi] while decoding fixed bytes, invalid bytes data length: ' + length);\n      }\n\n      return {\n        consumed: 32,\n        value: '0x' + data.slice(offset, offset + length).toString('hex')\n      };\n    }\n  };\n}\n\nvar coderAddress = {\n  encode: function encodeAddress(valueInput) {\n    var value = valueInput; // eslint-disable-line\n    var result = new Buffer(32); // eslint-disable-line\n    if (!isHexString(value, 20)) {\n      throw new Error('[ethjs-abi] while encoding address, invalid address value, not alphanumeric 20 byte hex string');\n    }\n    value = hexOrBuffer(value);\n    result.fill(0);\n    value.copy(result, 12);\n    return result;\n  },\n  decode: function decodeAddress(data, offset) {\n    if (data.length === 0) {\n      return {\n        consumed: 32,\n        value: '0x'\n      };\n    }\n    if (data.length < offset + 32) {\n      throw new Error('[ethjs-abi] while decoding address data, invalid address data, invalid byte length ' + data.length);\n    }\n    return {\n      consumed: 32,\n      value: '0x' + data.slice(offset + 12, offset + 32).toString('hex')\n    };\n  }\n};\n\nfunction encodeDynamicBytesHelper(value) {\n  var dataLength = parseInt(32 * Math.ceil(value.length / 32)); // eslint-disable-line\n  var padding = new Buffer(dataLength - value.length); // eslint-disable-line\n  padding.fill(0);\n\n  return Buffer.concat([uint256Coder.encode(value.length), value, padding]);\n}\n\nfunction decodeDynamicBytesHelper(data, offset) {\n  if (data.length < offset + 32) {\n    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32));\n  }\n\n  var length = uint256Coder.decode(data, offset).value; // eslint-disable-line\n  length = length.toNumber();\n  if (data.length < offset + 32 + length) {\n    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32 + length));\n  }\n\n  return {\n    consumed: parseInt(32 + 32 * Math.ceil(length / 32), 10),\n    value: data.slice(offset + 32, offset + 32 + length)\n  };\n}\n\nvar coderDynamicBytes = {\n  encode: function encodeDynamicBytes(value) {\n    return encodeDynamicBytesHelper(hexOrBuffer(value));\n  },\n  decode: function decodeDynamicBytes(data, offset) {\n    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line\n    result.value = '0x' + result.value.toString('hex');\n    return result;\n  },\n  dynamic: true\n};\n\nvar coderString = {\n  encode: function encodeString(value) {\n    return encodeDynamicBytesHelper(new Buffer(value, 'utf8'));\n  },\n  decode: function decodeString(data, offset) {\n    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line\n    result.value = result.value.toString('utf8');\n    return result;\n  },\n  dynamic: true\n};\n\nfunction coderArray(coder, lengthInput) {\n  return {\n    encode: function encodeArray(value) {\n      var result = new Buffer(0); // eslint-disable-line\n      var length = lengthInput; // eslint-disable-line\n\n      if (!Array.isArray(value)) {\n        throw new Error('[ethjs-abi] while encoding array, invalid array data, not type Object (Array)');\n      }\n\n      if (length === -1) {\n        length = value.length;\n        result = uint256Coder.encode(length);\n      }\n\n      if (length !== value.length) {\n        throw new Error('[ethjs-abi] while encoding array, size mismatch array length ' + length + ' does not equal ' + value.length);\n      }\n\n      value.forEach(function (resultValue) {\n        result = Buffer.concat([result, coder.encode(resultValue)]);\n      });\n\n      return result;\n    },\n    decode: function decodeArray(data, offsetInput) {\n      var length = lengthInput; // eslint-disable-line\n      var offset = offsetInput; // eslint-disable-line\n      // @TODO:\n      // if (data.length < offset + length * 32) { throw new Error('invalid array'); }\n\n      var consumed = 0; // eslint-disable-line\n      var decodeResult; // eslint-disable-line\n\n      if (length === -1) {\n        decodeResult = uint256Coder.decode(data, offset);\n        length = decodeResult.value.toNumber();\n        consumed += decodeResult.consumed;\n        offset += decodeResult.consumed;\n      }\n\n      var value = []; // eslint-disable-line\n\n      for (var i = 0; i < length; i++) {\n        // eslint-disable-line\n        var loopResult = coder.decode(data, offset);\n        consumed += loopResult.consumed;\n        offset += loopResult.consumed;\n        value.push(loopResult.value);\n      }\n\n      return {\n        consumed: consumed,\n        value: value\n      };\n    },\n    dynamic: lengthInput === -1\n  };\n}\n\n// Break the type up into [staticType][staticArray]*[dynamicArray]? | [dynamicType] and\n// build the coder up from its parts\nvar paramTypePart = new RegExp(/^((u?int|bytes)([0-9]*)|(address|bool|string)|(\\[([0-9]*)\\]))/);\n\nfunction getParamCoder(typeInput) {\n  var type = typeInput; // eslint-disable-line\n  var coder = null; // eslint-disable-line\n  var invalidTypeErrorMessage = '[ethjs-abi] while getting param coder (getParamCoder) type value ' + JSON.stringify(type) + ' is either invalid or unsupported by ethjs-abi.';\n\n  while (type) {\n    var part = type.match(paramTypePart); // eslint-disable-line\n    if (!part) {\n      throw new Error(invalidTypeErrorMessage);\n    }\n    type = type.substring(part[0].length);\n\n    var prefix = part[2] || part[4] || part[5]; // eslint-disable-line\n    switch (prefix) {\n      case 'int':case 'uint':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        var intSize = parseInt(part[3] || 256); // eslint-disable-line\n        if (intSize === 0 || intSize > 256 || intSize % 8 !== 0) {\n          throw new Error('[ethjs-abi] while getting param coder for type ' + type + ', invalid ' + prefix + '<N> width: ' + type);\n        }\n\n        coder = coderNumber(intSize / 8, prefix === 'int');\n        break;\n\n      case 'bool':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderBoolean;\n        break;\n\n      case 'string':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderString;\n        break;\n\n      case 'bytes':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        if (part[3]) {\n          var size = parseInt(part[3]); // eslint-disable-line\n          if (size === 0 || size > 32) {\n            throw new Error('[ethjs-abi] while getting param coder for prefix bytes, invalid type ' + type + ', size ' + size + ' should be 0 or greater than 32');\n          }\n          coder = coderFixedBytes(size);\n        } else {\n          coder = coderDynamicBytes;\n        }\n        break;\n\n      case 'address':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderAddress;\n        break;\n\n      case '[]':\n        if (!coder || coder.dynamic) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderArray(coder, -1);\n        break;\n\n      // \"[0-9+]\"\n      default:\n        if (!coder || coder.dynamic) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        var defaultSize = parseInt(part[6]); // eslint-disable-line\n        coder = coderArray(coder, defaultSize);\n    }\n  }\n\n  if (!coder) {\n    throw new Error(invalidTypeErrorMessage);\n  }\n  return coder;\n}\n\nmodule.exports = {\n  BN: BN,\n  bnToBuffer: bnToBuffer,\n  isHexString: isHexString,\n  hexOrBuffer: hexOrBuffer,\n  hexlify: hexlify,\n  stripZeros: stripZeros,\n\n  keccak256: keccak256,\n\n  getKeys: getKeys,\n  numberToBN: numberToBN,\n  coderNumber: coderNumber,\n  uint256Coder: uint256Coder,\n  coderBoolean: coderBoolean,\n  coderFixedBytes: coderFixedBytes,\n  coderAddress: coderAddress,\n  coderDynamicBytes: coderDynamicBytes,\n  coderString: coderString,\n  coderArray: coderArray,\n  paramTypePart: paramTypePart,\n  getParamCoder: getParamCoder\n};\n}).call(this,require(\"buffer\").Buffer)\n},{\"bn.js\":4,\"buffer\":6,\"js-sha3\":11,\"number-to-bn\":12}],9:[function(require,module,exports){\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n  var e, m\n  var eLen = nBytes * 8 - mLen - 1\n  var eMax = (1 << eLen) - 1\n  var eBias = eMax >> 1\n  var nBits = -7\n  var i = isLE ? (nBytes - 1) : 0\n  var d = isLE ? -1 : 1\n  var s = buffer[offset + i]\n\n  i += d\n\n  e = s & ((1 << (-nBits)) - 1)\n  s >>= (-nBits)\n  nBits += eLen\n  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}\n\n  m = e & ((1 << (-nBits)) - 1)\n  e >>= (-nBits)\n  nBits += mLen\n  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}\n\n  if (e === 0) {\n    e = 1 - eBias\n  } else if (e === eMax) {\n    return m ? NaN : ((s ? -1 : 1) * Infinity)\n  } else {\n    m = m + Math.pow(2, mLen)\n    e = e - eBias\n  }\n  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n  var e, m, c\n  var eLen = nBytes * 8 - mLen - 1\n  var eMax = (1 << eLen) - 1\n  var eBias = eMax >> 1\n  var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n  var i = isLE ? 0 : (nBytes - 1)\n  var d = isLE ? 1 : -1\n  var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n  value = Math.abs(value)\n\n  if (isNaN(value) || value === Infinity) {\n    m = isNaN(value) ? 1 : 0\n    e = eMax\n  } else {\n    e = Math.floor(Math.log(value) / Math.LN2)\n    if (value * (c = Math.pow(2, -e)) < 1) {\n      e--\n      c *= 2\n    }\n    if (e + eBias >= 1) {\n      value += rt / c\n    } else {\n      value += rt * Math.pow(2, 1 - eBias)\n    }\n    if (value * c >= 2) {\n      e++\n      c /= 2\n    }\n\n    if (e + eBias >= eMax) {\n      m = 0\n      e = eMax\n    } else if (e + eBias >= 1) {\n      m = (value * c - 1) * Math.pow(2, mLen)\n      e = e + eBias\n    } else {\n      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n      e = 0\n    }\n  }\n\n  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n  e = (e << mLen) | m\n  eLen += mLen\n  for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n  buffer[offset + i - d] |= s * 128\n}\n\n},{}],10:[function(require,module,exports){\n/**\n * Returns a `Boolean` on whether or not the a `String` starts with '0x'\n * @param {String} str the string input value\n * @return {Boolean} a boolean if it is or is not hex prefixed\n * @throws if the str input is not a string\n */\nmodule.exports = function isHexPrefixed(str) {\n  if (typeof str !== 'string') {\n    throw new Error(\"[is-hex-prefixed] value must be type 'string', is currently type \" + (typeof str) + \", while checking isHexPrefixed.\");\n  }\n\n  return str.slice(0, 2) === '0x';\n}\n\n},{}],11:[function(require,module,exports){\n(function (process,global){\n/**\r\n * [js-sha3]{@link https://github.com/emn178/js-sha3}\r\n *\r\n * @version 0.5.5\r\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\r\n * @copyright Chen, Yi-Cyuan 2015-2016\r\n * @license MIT\r\n */\r\n(function (root) {\r\n  'use strict';\r\n\r\n  var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;\r\n  if (NODE_JS) {\r\n    root = global;\r\n  }\r\n  var COMMON_JS = !root.JS_SHA3_TEST && typeof module == 'object' && module.exports;\r\n  var HEX_CHARS = '0123456789abcdef'.split('');\r\n  var SHAKE_PADDING = [31, 7936, 2031616, 520093696];\r\n  var KECCAK_PADDING = [1, 256, 65536, 16777216];\r\n  var PADDING = [6, 1536, 393216, 100663296];\r\n  var SHIFT = [0, 8, 16, 24];\r\n  var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,\r\n            0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, \r\n            2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, \r\n            2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,\r\n            2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];\r\n  var BITS = [224, 256, 384, 512];\r\n  var SHAKE_BITS = [128, 256];\r\n  var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array'];\r\n\r\n  var createOutputMethod = function (bits, padding, outputType) {\r\n    return function (message) {\r\n      return new Keccak(bits, padding, bits).update(message)[outputType]();\r\n    }\r\n  };\r\n\r\n  var createShakeOutputMethod = function (bits, padding, outputType) {\r\n    return function (message, outputBits) {\r\n      return new Keccak(bits, padding, outputBits).update(message)[outputType]();\r\n    }\r\n  };\r\n\r\n  var createMethod = function (bits, padding) {\r\n    var method = createOutputMethod(bits, padding, 'hex');\r\n    method.create = function () {\r\n      return new Keccak(bits, padding, bits);\r\n    };\r\n    method.update = function (message) {\r\n      return method.create().update(message);\r\n    };\r\n    for (var i = 0;i < OUTPUT_TYPES.length;++i) {\r\n      var type = OUTPUT_TYPES[i];\r\n      method[type] = createOutputMethod(bits, padding, type);\r\n    }\r\n    return method;\r\n  };\r\n\r\n  var createShakeMethod = function (bits, padding) {\r\n    var method = createShakeOutputMethod(bits, padding, 'hex');\r\n    method.create = function (outputBits) {\r\n      return new Keccak(bits, padding, outputBits);\r\n    };\r\n    method.update = function (message, outputBits) {\r\n      return method.create(outputBits).update(message);\r\n    };\r\n    for (var i = 0;i < OUTPUT_TYPES.length;++i) {\r\n      var type = OUTPUT_TYPES[i];\r\n      method[type] = createShakeOutputMethod(bits, padding, type);\r\n    }\r\n    return method;\r\n  };\r\n\r\n  var algorithms = [\r\n    {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod},\r\n    {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod},\r\n    {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod}\r\n  ];\r\n\r\n  var methods = {};\r\n\r\n  for (var i = 0;i < algorithms.length;++i) {\r\n    var algorithm = algorithms[i];\r\n    var bits  = algorithm.bits;\r\n    for (var j = 0;j < bits.length;++j) {\r\n      methods[algorithm.name +'_' + bits[j]] = algorithm.createMethod(bits[j], algorithm.padding);\r\n    }\r\n  }\r\n\r\n  function Keccak(bits, padding, outputBits) {\r\n    this.blocks = [];\r\n    this.s = [];\r\n    this.padding = padding;\r\n    this.outputBits = outputBits;\r\n    this.reset = true;\r\n    this.block = 0;\r\n    this.start = 0;\r\n    this.blockCount = (1600 - (bits << 1)) >> 5;\r\n    this.byteCount = this.blockCount << 2;\r\n    this.outputBlocks = outputBits >> 5;\r\n    this.extraBytes = (outputBits & 31) >> 3;\r\n\r\n    for (var i = 0;i < 50;++i) {\r\n      this.s[i] = 0;\r\n    }\r\n  };\r\n\r\n  Keccak.prototype.update = function (message) {\r\n    var notString = typeof message != 'string';\r\n    if (notString && message.constructor == root.ArrayBuffer) {\r\n      message = new Uint8Array(message);\r\n    }\r\n    var length = message.length, blocks = this.blocks, byteCount = this.byteCount, \r\n        blockCount = this.blockCount, index = 0, s = this.s, i, code;\r\n    \r\n    while (index < length) {\r\n      if (this.reset) {\r\n        this.reset = false;\r\n        blocks[0] = this.block;\r\n        for (i = 1;i < blockCount + 1;++i) {\r\n          blocks[i] = 0;\r\n        }\r\n      }\r\n      if (notString) {\r\n        for (i = this.start;index < length && i < byteCount;++index) {\r\n          blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];\r\n        }\r\n      } else {\r\n        for (i = this.start;index < length && i < byteCount;++index) {\r\n          code = message.charCodeAt(index);\r\n          if (code < 0x80) {\r\n            blocks[i >> 2] |= code << SHIFT[i++ & 3];\r\n          } else if (code < 0x800) {\r\n            blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\r\n          } else if (code < 0xd800 || code >= 0xe000) {\r\n            blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\r\n          } else {\r\n            code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\r\n            blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\r\n          }\r\n        }\r\n      }\r\n      this.lastByteIndex = i;\r\n      if (i >= byteCount) {\r\n        this.start = i - byteCount;\r\n        this.block = blocks[blockCount];\r\n        for (i = 0;i < blockCount;++i) {\r\n          s[i] ^= blocks[i];\r\n        }\r\n        f(s);\r\n        this.reset = true;\r\n      } else {\r\n        this.start = i;\r\n      }\r\n    }\r\n    return this;\r\n  };\r\n\r\n  Keccak.prototype.finalize = function () {\r\n    var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;\r\n    blocks[i >> 2] |= this.padding[i & 3];\r\n    if (this.lastByteIndex == this.byteCount) {\r\n      blocks[0] = blocks[blockCount];\r\n      for (i = 1;i < blockCount + 1;++i) {\r\n        blocks[i] = 0;\r\n      }\r\n    }\r\n    blocks[blockCount - 1] |= 0x80000000;\r\n    for (i = 0;i < blockCount;++i) {\r\n      s[i] ^= blocks[i];\r\n    }\r\n    f(s);\r\n  };\r\n\r\n  Keccak.prototype.toString = Keccak.prototype.hex = function () {\r\n    this.finalize();\r\n\r\n    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, \r\n        extraBytes = this.extraBytes, i = 0, j = 0;\r\n    var hex = '', block;\r\n    while (j < outputBlocks) {\r\n      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {\r\n        block = s[i];\r\n        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +\r\n               HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +\r\n               HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +\r\n               HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];\r\n      }\r\n      if (j % blockCount == 0) {\r\n        f(s);\r\n        i = 0;\r\n      }\r\n    }\r\n    if (extraBytes) {\r\n      block = s[i];\r\n      if (extraBytes > 0) {\r\n        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];\r\n      }\r\n      if (extraBytes > 1) {\r\n        hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];\r\n      }\r\n      if (extraBytes > 2) {\r\n        hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];\r\n      }\r\n    }\r\n    return hex;\r\n  };\r\n\r\n  Keccak.prototype.arrayBuffer = function () {\r\n    this.finalize();\r\n\r\n    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, \r\n        extraBytes = this.extraBytes, i = 0, j = 0;\r\n    var bytes = this.outputBits >> 3;\r\n    var buffer;\r\n    if (extraBytes) {\r\n      buffer = new ArrayBuffer((outputBlocks + 1) << 2);\r\n    } else {\r\n      buffer = new ArrayBuffer(bytes);\r\n    }\r\n    var array = new Uint32Array(buffer);\r\n    while (j < outputBlocks) {\r\n      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {\r\n        array[j] = s[i];\r\n      }\r\n      if (j % blockCount == 0) {\r\n        f(s);\r\n      }\r\n    }\r\n    if (extraBytes) {\r\n      array[i] = s[i];\r\n      buffer = buffer.slice(0, bytes);\r\n    }\r\n    return buffer;\r\n  };\r\n\r\n  Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;\r\n\r\n  Keccak.prototype.digest = Keccak.prototype.array = function () {\r\n    this.finalize();\r\n\r\n    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, \r\n        extraBytes = this.extraBytes, i = 0, j = 0;\r\n    var array = [], offset, block;\r\n    while (j < outputBlocks) {\r\n      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {\r\n        offset = j << 2;\r\n        block = s[i];\r\n        array[offset] = block & 0xFF;\r\n        array[offset + 1] = (block >> 8) & 0xFF;\r\n        array[offset + 2] = (block >> 16) & 0xFF;\r\n        array[offset + 3] = (block >> 24) & 0xFF;\r\n      }\r\n      if (j % blockCount == 0) {\r\n        f(s);\r\n      }\r\n    }\r\n    if (extraBytes) {\r\n      offset = j << 2;\r\n      block = s[i];\r\n      if (extraBytes > 0) {\r\n        array[offset] = block & 0xFF;\r\n      }\r\n      if (extraBytes > 1) {\r\n        array[offset + 1] = (block >> 8) & 0xFF;\r\n      }\r\n      if (extraBytes > 2) {\r\n        array[offset + 2] = (block >> 16) & 0xFF;\r\n      }\r\n    }\r\n    return array;\r\n  };\r\n\r\n  var f = function (s) {\r\n    var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, \r\n        b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, \r\n        b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, \r\n        b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;\r\n    for (n = 0;n < 48;n += 2) {\r\n      c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];\r\n      c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];\r\n      c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];\r\n      c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];\r\n      c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];\r\n      c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];\r\n      c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];\r\n      c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];\r\n      c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];\r\n      c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];\r\n\r\n      h = c8 ^ ((c2 << 1) | (c3 >>> 31));\r\n      l = c9 ^ ((c3 << 1) | (c2 >>> 31));\r\n      s[0] ^= h;\r\n      s[1] ^= l;\r\n      s[10] ^= h;\r\n      s[11] ^= l;\r\n      s[20] ^= h;\r\n      s[21] ^= l;\r\n      s[30] ^= h;\r\n      s[31] ^= l;\r\n      s[40] ^= h;\r\n      s[41] ^= l;\r\n      h = c0 ^ ((c4 << 1) | (c5 >>> 31));\r\n      l = c1 ^ ((c5 << 1) | (c4 >>> 31));\r\n      s[2] ^= h;\r\n      s[3] ^= l;\r\n      s[12] ^= h;\r\n      s[13] ^= l;\r\n      s[22] ^= h;\r\n      s[23] ^= l;\r\n      s[32] ^= h;\r\n      s[33] ^= l;\r\n      s[42] ^= h;\r\n      s[43] ^= l;\r\n      h = c2 ^ ((c6 << 1) | (c7 >>> 31));\r\n      l = c3 ^ ((c7 << 1) | (c6 >>> 31));\r\n      s[4] ^= h;\r\n      s[5] ^= l;\r\n      s[14] ^= h;\r\n      s[15] ^= l;\r\n      s[24] ^= h;\r\n      s[25] ^= l;\r\n      s[34] ^= h;\r\n      s[35] ^= l;\r\n      s[44] ^= h;\r\n      s[45] ^= l;\r\n      h = c4 ^ ((c8 << 1) | (c9 >>> 31));\r\n      l = c5 ^ ((c9 << 1) | (c8 >>> 31));\r\n      s[6] ^= h;\r\n      s[7] ^= l;\r\n      s[16] ^= h;\r\n      s[17] ^= l;\r\n      s[26] ^= h;\r\n      s[27] ^= l;\r\n      s[36] ^= h;\r\n      s[37] ^= l;\r\n      s[46] ^= h;\r\n      s[47] ^= l;\r\n      h = c6 ^ ((c0 << 1) | (c1 >>> 31));\r\n      l = c7 ^ ((c1 << 1) | (c0 >>> 31));\r\n      s[8] ^= h;\r\n      s[9] ^= l;\r\n      s[18] ^= h;\r\n      s[19] ^= l;\r\n      s[28] ^= h;\r\n      s[29] ^= l;\r\n      s[38] ^= h;\r\n      s[39] ^= l;\r\n      s[48] ^= h;\r\n      s[49] ^= l;\r\n\r\n      b0 = s[0];\r\n      b1 = s[1];\r\n      b32 = (s[11] << 4) | (s[10] >>> 28);\r\n      b33 = (s[10] << 4) | (s[11] >>> 28);\r\n      b14 = (s[20] << 3) | (s[21] >>> 29);\r\n      b15 = (s[21] << 3) | (s[20] >>> 29);\r\n      b46 = (s[31] << 9) | (s[30] >>> 23);\r\n      b47 = (s[30] << 9) | (s[31] >>> 23);\r\n      b28 = (s[40] << 18) | (s[41] >>> 14);\r\n      b29 = (s[41] << 18) | (s[40] >>> 14);\r\n      b20 = (s[2] << 1) | (s[3] >>> 31);\r\n      b21 = (s[3] << 1) | (s[2] >>> 31);\r\n      b2 = (s[13] << 12) | (s[12] >>> 20);\r\n      b3 = (s[12] << 12) | (s[13] >>> 20);\r\n      b34 = (s[22] << 10) | (s[23] >>> 22);\r\n      b35 = (s[23] << 10) | (s[22] >>> 22);\r\n      b16 = (s[33] << 13) | (s[32] >>> 19);\r\n      b17 = (s[32] << 13) | (s[33] >>> 19);\r\n      b48 = (s[42] << 2) | (s[43] >>> 30);\r\n      b49 = (s[43] << 2) | (s[42] >>> 30);\r\n      b40 = (s[5] << 30) | (s[4] >>> 2);\r\n      b41 = (s[4] << 30) | (s[5] >>> 2);\r\n      b22 = (s[14] << 6) | (s[15] >>> 26);\r\n      b23 = (s[15] << 6) | (s[14] >>> 26);\r\n      b4 = (s[25] << 11) | (s[24] >>> 21);\r\n      b5 = (s[24] << 11) | (s[25] >>> 21);\r\n      b36 = (s[34] << 15) | (s[35] >>> 17);\r\n      b37 = (s[35] << 15) | (s[34] >>> 17);\r\n      b18 = (s[45] << 29) | (s[44] >>> 3);\r\n      b19 = (s[44] << 29) | (s[45] >>> 3);\r\n      b10 = (s[6] << 28) | (s[7] >>> 4);\r\n      b11 = (s[7] << 28) | (s[6] >>> 4);\r\n      b42 = (s[17] << 23) | (s[16] >>> 9);\r\n      b43 = (s[16] << 23) | (s[17] >>> 9);\r\n      b24 = (s[26] << 25) | (s[27] >>> 7);\r\n      b25 = (s[27] << 25) | (s[26] >>> 7);\r\n      b6 = (s[36] << 21) | (s[37] >>> 11);\r\n      b7 = (s[37] << 21) | (s[36] >>> 11);\r\n      b38 = (s[47] << 24) | (s[46] >>> 8);\r\n      b39 = (s[46] << 24) | (s[47] >>> 8);\r\n      b30 = (s[8] << 27) | (s[9] >>> 5);\r\n      b31 = (s[9] << 27) | (s[8] >>> 5);\r\n      b12 = (s[18] << 20) | (s[19] >>> 12);\r\n      b13 = (s[19] << 20) | (s[18] >>> 12);\r\n      b44 = (s[29] << 7) | (s[28] >>> 25);\r\n      b45 = (s[28] << 7) | (s[29] >>> 25);\r\n      b26 = (s[38] << 8) | (s[39] >>> 24);\r\n      b27 = (s[39] << 8) | (s[38] >>> 24);\r\n      b8 = (s[48] << 14) | (s[49] >>> 18);\r\n      b9 = (s[49] << 14) | (s[48] >>> 18);\r\n\r\n      s[0] = b0 ^ (~b2 & b4);\r\n      s[1] = b1 ^ (~b3 & b5);\r\n      s[10] = b10 ^ (~b12 & b14);\r\n      s[11] = b11 ^ (~b13 & b15);\r\n      s[20] = b20 ^ (~b22 & b24);\r\n      s[21] = b21 ^ (~b23 & b25);\r\n      s[30] = b30 ^ (~b32 & b34);\r\n      s[31] = b31 ^ (~b33 & b35);\r\n      s[40] = b40 ^ (~b42 & b44);\r\n      s[41] = b41 ^ (~b43 & b45);\r\n      s[2] = b2 ^ (~b4 & b6);\r\n      s[3] = b3 ^ (~b5 & b7);\r\n      s[12] = b12 ^ (~b14 & b16);\r\n      s[13] = b13 ^ (~b15 & b17);\r\n      s[22] = b22 ^ (~b24 & b26);\r\n      s[23] = b23 ^ (~b25 & b27);\r\n      s[32] = b32 ^ (~b34 & b36);\r\n      s[33] = b33 ^ (~b35 & b37);\r\n      s[42] = b42 ^ (~b44 & b46);\r\n      s[43] = b43 ^ (~b45 & b47);\r\n      s[4] = b4 ^ (~b6 & b8);\r\n      s[5] = b5 ^ (~b7 & b9);\r\n      s[14] = b14 ^ (~b16 & b18);\r\n      s[15] = b15 ^ (~b17 & b19);\r\n      s[24] = b24 ^ (~b26 & b28);\r\n      s[25] = b25 ^ (~b27 & b29);\r\n      s[34] = b34 ^ (~b36 & b38);\r\n      s[35] = b35 ^ (~b37 & b39);\r\n      s[44] = b44 ^ (~b46 & b48);\r\n      s[45] = b45 ^ (~b47 & b49);\r\n      s[6] = b6 ^ (~b8 & b0);\r\n      s[7] = b7 ^ (~b9 & b1);\r\n      s[16] = b16 ^ (~b18 & b10);\r\n      s[17] = b17 ^ (~b19 & b11);\r\n      s[26] = b26 ^ (~b28 & b20);\r\n      s[27] = b27 ^ (~b29 & b21);\r\n      s[36] = b36 ^ (~b38 & b30);\r\n      s[37] = b37 ^ (~b39 & b31);\r\n      s[46] = b46 ^ (~b48 & b40);\r\n      s[47] = b47 ^ (~b49 & b41);\r\n      s[8] = b8 ^ (~b0 & b2);\r\n      s[9] = b9 ^ (~b1 & b3);\r\n      s[18] = b18 ^ (~b10 & b12);\r\n      s[19] = b19 ^ (~b11 & b13);\r\n      s[28] = b28 ^ (~b20 & b22);\r\n      s[29] = b29 ^ (~b21 & b23);\r\n      s[38] = b38 ^ (~b30 & b32);\r\n      s[39] = b39 ^ (~b31 & b33);\r\n      s[48] = b48 ^ (~b40 & b42);\r\n      s[49] = b49 ^ (~b41 & b43);\r\n\r\n      s[0] ^= RC[n];\r\n      s[1] ^= RC[n + 1];\r\n    }\r\n  }\r\n\r\n  if (COMMON_JS) {\r\n    module.exports = methods;\r\n  } else if (root) {\r\n    for (var key in methods) {\r\n      root[key] = methods[key];\r\n    }\r\n  }\r\n}(this));\r\n\n}).call(this,require('_process'),typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"_process\":13}],12:[function(require,module,exports){\nvar BN = require('bn.js');\nvar stripHexPrefix = require('strip-hex-prefix');\n\n/**\n * Returns a BN object, converts a number value to a BN\n * @param {String|Number|Object} `arg` input a string number, hex string number, number, BigNumber or BN object\n * @return {Object} `output` BN object of the number\n * @throws if the argument is not an array, object that isn't a bignumber, not a string number or number\n */\nmodule.exports = function numberToBN(arg) {\n  if (typeof arg === 'string' || typeof arg === 'number') {\n    var multiplier = new BN(1); // eslint-disable-line\n    var formattedString = String(arg).toLowerCase().trim();\n    var isHexPrefixed = formattedString.substr(0, 2) === '0x' || formattedString.substr(0, 3) === '-0x';\n    var stringArg = stripHexPrefix(formattedString); // eslint-disable-line\n    if (stringArg.substr(0, 1) === '-') {\n      stringArg = stripHexPrefix(stringArg.slice(1));\n      multiplier = new BN(-1, 10);\n    }\n    stringArg = stringArg === '' ? '0' : stringArg;\n\n    if ((!stringArg.match(/^-?[0-9]+$/) && stringArg.match(/^[0-9A-Fa-f]+$/))\n      || stringArg.match(/^[a-fA-F]+$/)\n      || (isHexPrefixed === true && stringArg.match(/^[0-9A-Fa-f]+$/))) {\n      return new BN(stringArg, 16).mul(multiplier);\n    }\n\n    if ((stringArg.match(/^-?[0-9]+$/) || stringArg === '') && isHexPrefixed === false) {\n      return new BN(stringArg, 10).mul(multiplier);\n    }\n  } else if (typeof arg === 'object' && arg.toString && (!arg.pop && !arg.push)) {\n    if (arg.toString(10).match(/^-?[0-9]+$/) && (arg.mul || arg.dividedToIntegerBy)) {\n      return new BN(arg.toString(10), 10);\n    }\n  }\n\n  throw new Error('[number-to-bn] while converting number ' + JSON.stringify(arg) + ' to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.');\n}\n\n},{\"bn.js\":4,\"strip-hex-prefix\":14}],13:[function(require,module,exports){\n// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things.  But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals.  It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n    throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n    throw new Error('clearTimeout has not been defined');\n}\n(function () {\n    try {\n        if (typeof setTimeout === 'function') {\n            cachedSetTimeout = setTimeout;\n        } else {\n            cachedSetTimeout = defaultSetTimout;\n        }\n    } catch (e) {\n        cachedSetTimeout = defaultSetTimout;\n    }\n    try {\n        if (typeof clearTimeout === 'function') {\n            cachedClearTimeout = clearTimeout;\n        } else {\n            cachedClearTimeout = defaultClearTimeout;\n        }\n    } catch (e) {\n        cachedClearTimeout = defaultClearTimeout;\n    }\n} ())\nfunction runTimeout(fun) {\n    if (cachedSetTimeout === setTimeout) {\n        //normal enviroments in sane situations\n        return setTimeout(fun, 0);\n    }\n    // if setTimeout wasn't available but was latter defined\n    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n        cachedSetTimeout = setTimeout;\n        return setTimeout(fun, 0);\n    }\n    try {\n        // when when somebody has screwed with setTimeout but no I.E. maddness\n        return cachedSetTimeout(fun, 0);\n    } catch(e){\n        try {\n            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n            return cachedSetTimeout.call(null, fun, 0);\n        } catch(e){\n            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n            return cachedSetTimeout.call(this, fun, 0);\n        }\n    }\n\n\n}\nfunction runClearTimeout(marker) {\n    if (cachedClearTimeout === clearTimeout) {\n        //normal enviroments in sane situations\n        return clearTimeout(marker);\n    }\n    // if clearTimeout wasn't available but was latter defined\n    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n        cachedClearTimeout = clearTimeout;\n        return clearTimeout(marker);\n    }\n    try {\n        // when when somebody has screwed with setTimeout but no I.E. maddness\n        return cachedClearTimeout(marker);\n    } catch (e){\n        try {\n            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally\n            return cachedClearTimeout.call(null, marker);\n        } catch (e){\n            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n            // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n            return cachedClearTimeout.call(this, marker);\n        }\n    }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n    if (!draining || !currentQueue) {\n        return;\n    }\n    draining = false;\n    if (currentQueue.length) {\n        queue = currentQueue.concat(queue);\n    } else {\n        queueIndex = -1;\n    }\n    if (queue.length) {\n        drainQueue();\n    }\n}\n\nfunction drainQueue() {\n    if (draining) {\n        return;\n    }\n    var timeout = runTimeout(cleanUpNextTick);\n    draining = true;\n\n    var len = queue.length;\n    while(len) {\n        currentQueue = queue;\n        queue = [];\n        while (++queueIndex < len) {\n            if (currentQueue) {\n                currentQueue[queueIndex].run();\n            }\n        }\n        queueIndex = -1;\n        len = queue.length;\n    }\n    currentQueue = null;\n    draining = false;\n    runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n    var args = new Array(arguments.length - 1);\n    if (arguments.length > 1) {\n        for (var i = 1; i < arguments.length; i++) {\n            args[i - 1] = arguments[i];\n        }\n    }\n    queue.push(new Item(fun, args));\n    if (queue.length === 1 && !draining) {\n        runTimeout(drainQueue);\n    }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n    this.fun = fun;\n    this.array = array;\n}\nItem.prototype.run = function () {\n    this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n    throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n    throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n},{}],14:[function(require,module,exports){\nvar isHexPrefixed = require('is-hex-prefixed');\n\n/**\n * Removes '0x' from a given `String` is present\n * @param {String} str the string value\n * @return {String|Optional} a string by pass if necessary\n */\nmodule.exports = function stripHexPrefix(str) {\n  if (typeof str !== 'string') {\n    return str;\n  }\n\n  return isHexPrefixed(str) ? str.slice(2) : str;\n}\n\n},{\"is-hex-prefixed\":10}],15:[function(require,module,exports){\n// TODO: remove web3 requirement\n// Call functions directly on the provider.\nvar Web3 = require(\"web3\");\n\nvar Blockchain = {\n  parse: function(uri) {\n    var parsed = {};\n    if (uri.indexOf(\"blockchain://\") != 0) return parsed;\n\n    uri = uri.replace(\"blockchain://\", \"\");\n\n    var pieces = uri.split(\"/block/\");\n\n    parsed.genesis_hash = \"0x\" + pieces[0];\n    parsed.block_hash = \"0x\" + pieces[1];\n\n    return parsed;\n  },\n\n  asURI: function(provider, callback) {\n    var web3 = new Web3(provider);\n\n    web3.eth.getBlock(0, function(err, genesis) {\n      if (err) return callback(err);\n\n      web3.eth.getBlock(\"latest\", function(err, latest) {\n        if (err) return callback(err);\n\n        var url = \"blockchain://\" + genesis.hash.replace(\"0x\", \"\") + \"/block/\" + latest.hash.replace(\"0x\", \"\");\n\n        callback(null, url);\n      });\n    });\n  },\n\n  matches: function(uri, provider, callback) {\n    uri = this.parse(uri);\n\n    var expected_genesis = uri.genesis_hash;\n    var expected_block = uri.block_hash;\n\n    var web3 = new Web3(provider);\n\n    web3.eth.getBlock(0, function(err, block) {\n      if (err) return callback(err);\n      if (block.hash != expected_genesis) return callback(null, false);\n\n      web3.eth.getBlock(expected_block, function(err, block) {\n        // Treat an error as if the block didn't exist. This is because\n        // some clients respond differently.\n        if (err || block == null) {\n          return callback(null, false);\n        }\n\n        callback(null, true);\n      });\n    });\n  }\n};\n\nmodule.exports = Blockchain;\n\n},{\"web3\":5}],16:[function(require,module,exports){\nvar sha3 = require(\"crypto-js/sha3\");\nvar schema_version = require(\"./package.json\").version;\n\nvar TruffleSchema = {\n  // Normalize options passed in to be the exact options required\n  // for truffle-contract.\n  //\n  // options can be three things:\n  // - normal object\n  // - contract object\n  // - solc output\n  //\n  // TODO: Is extra_options still necessary?\n  normalizeOptions: function(options, extra_options) {\n    extra_options = extra_options || {};\n    var normalized = {};\n    var expected_keys = [\n      \"contract_name\",\n      \"abi\",\n      \"binary\",\n      \"unlinked_binary\",\n      \"address\",\n      \"networks\",\n      \"links\",\n      \"events\",\n      \"network_id\",\n      \"default_network\",\n      \"updated_at\"\n    ];\n\n    // Merge options/contract object first, then extra_options\n    expected_keys.forEach(function(key) {\n      var value;\n\n      try {\n        // Will throw an error if key == address and address doesn't exist.\n        value = options[key];\n\n        if (value != undefined) {\n          normalized[key] = value;\n        }\n      } catch (e) {\n        // Do nothing.\n      }\n\n      try {\n        // Will throw an error if key == address and address doesn't exist.\n        value = extra_options[key];\n\n        if (value != undefined) {\n          normalized[key] = value;\n        }\n      } catch (e) {\n        // Do nothing.\n      }\n    });\n\n    // Now look for solc specific items.\n    if (options.interface != null) {\n      normalized.abi = JSON.parse(options.interface);\n    }\n\n    if (options.bytecode != null) {\n      normalized.unlinked_binary = options.bytecode\n    }\n\n    // Assume any binary passed is the unlinked binary\n    if (normalized.unlinked_binary == null && normalized.binary) {\n      normalized.unlinked_binary = normalized.binary;\n    }\n\n    delete normalized.binary;\n\n    this.copyCustomOptions(options, normalized);\n\n    return normalized;\n  },\n\n  // Generate a proper binary from normalized options, and optionally\n  // merge it with an existing binary.\n  generateBinary: function(options, existing_binary, extra_options) {\n    extra_options = extra_options || {};\n\n    existing_binary = existing_binary || {};\n\n    if (options.overwrite == true) {\n      existing_binary = {};\n    }\n\n    existing_binary.contract_name = options.contract_name || existing_binary.contract_name || \"Contract\";\n    existing_binary.default_network = options.default_network || existing_binary.default_network;\n\n    existing_binary.abi = options.abi || existing_binary.abi;\n    existing_binary.unlinked_binary = options.unlinked_binary || existing_binary.unlinked_binary;\n\n    // Ensure unlinked binary starts with a 0x\n    if (existing_binary.unlinked_binary && existing_binary.unlinked_binary.indexOf(\"0x\") < 0) {\n      existing_binary.unlinked_binary = \"0x\" + existing_binary.unlinked_binary;\n    }\n\n    // Merge existing networks with any passed in networks.\n    existing_binary.networks = existing_binary.networks || {};\n    options.networks = options.networks || {};\n    Object.keys(options.networks).forEach(function(network_id) {\n      existing_binary.networks[network_id] = options.networks[network_id];\n    });\n\n    var updated_at = new Date().getTime();\n\n    if (options.network_id) {\n      // Ensure an object exists for this network.\n      existing_binary.networks[options.network_id] = existing_binary.networks[options.network_id] || {};\n\n      var network = existing_binary.networks[options.network_id];\n\n      // Override specific keys\n      network.address = options.address || network.address;\n      network.links = options.links;\n\n      // merge events with any that previously existed\n      network.events = network.events || {};\n      options.events = options.events || {};\n      Object.keys(options.events).forEach(function(event_id) {\n        options.events[event_id] = options.events[event_id];\n      });\n\n      // Now overwrite any events with the most recent data from the ABI.\n      existing_binary.abi.forEach(function(item) {\n        if (item.type != \"event\") return;\n\n        var signature = item.name + \"(\" + item.inputs.map(function(param) {return param.type;}).join(\",\") + \")\";\n        network.events[\"0x\" + sha3(signature, {outputLength: 256})] = item;\n      });\n\n      if (extra_options.dirty !== false) {\n        network.updated_at = updated_at;\n      }\n    } else {\n      if (options.address) {\n        throw new Error(\"Cannot set address without network id\");\n      }\n    }\n\n    // Ensure all networks have a `links` object.\n    Object.keys(existing_binary.networks).forEach(function(network_id) {\n      var network = existing_binary.networks[network_id];\n      network.links = network.links || {};\n    });\n\n    existing_binary.schema_version = schema_version;\n\n    if (extra_options.dirty !== false) {\n      existing_binary.updated_at = updated_at;\n    } else {\n      existing_binary.updated_at = options.updated_at || existing_binary.updated_at || updated_at;\n    }\n\n    this.copyCustomOptions(options, existing_binary);\n\n    return existing_binary;\n  },\n\n  copyCustomOptions: function(from, to) {\n    // Now let all x- options through.\n    Object.keys(from).forEach(function(key) {\n      if (key.indexOf(\"x-\") != 0) return;\n\n      try {\n        value = from[key];\n\n        if (value != undefined) {\n          to[key] = value;\n        }\n      } catch (e) {\n        // Do nothing.\n      }\n    });\n  }\n};\n\nmodule.exports = TruffleSchema;\n\n},{\"./package.json\":20,\"crypto-js/sha3\":18}],17:[function(require,module,exports){\n;(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory();\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\troot.CryptoJS = factory();\n\t}\n}(this, function () {\n\n\t/**\n\t * CryptoJS core components.\n\t */\n\tvar CryptoJS = CryptoJS || (function (Math, undefined) {\n\t    /*\n\t     * Local polyfil of Object.create\n\t     */\n\t    var create = Object.create || (function () {\n\t        function F() {};\n\n\t        return function (obj) {\n\t            var subtype;\n\n\t            F.prototype = obj;\n\n\t            subtype = new F();\n\n\t            F.prototype = null;\n\n\t            return subtype;\n\t        };\n\t    }())\n\n\t    /**\n\t     * CryptoJS namespace.\n\t     */\n\t    var C = {};\n\n\t    /**\n\t     * Library namespace.\n\t     */\n\t    var C_lib = C.lib = {};\n\n\t    /**\n\t     * Base object for prototypal inheritance.\n\t     */\n\t    var Base = C_lib.Base = (function () {\n\n\n\t        return {\n\t            /**\n\t             * Creates a new object that inherits from this object.\n\t             *\n\t             * @param {Object} overrides Properties to copy into the new object.\n\t             *\n\t             * @return {Object} The new object.\n\t             *\n\t             * @static\n\t             *\n\t             * @example\n\t             *\n\t             *     var MyType = CryptoJS.lib.Base.extend({\n\t             *         field: 'value',\n\t             *\n\t             *         method: function () {\n\t             *         }\n\t             *     });\n\t             */\n\t            extend: function (overrides) {\n\t                // Spawn\n\t                var subtype = create(this);\n\n\t                // Augment\n\t                if (overrides) {\n\t                    subtype.mixIn(overrides);\n\t                }\n\n\t                // Create default initializer\n\t                if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {\n\t                    subtype.init = function () {\n\t                        subtype.$super.init.apply(this, arguments);\n\t                    };\n\t                }\n\n\t                // Initializer's prototype is the subtype object\n\t                subtype.init.prototype = subtype;\n\n\t                // Reference supertype\n\t                subtype.$super = this;\n\n\t                return subtype;\n\t            },\n\n\t            /**\n\t             * Extends this object and runs the init method.\n\t             * Arguments to create() will be passed to init().\n\t             *\n\t             * @return {Object} The new object.\n\t             *\n\t             * @static\n\t             *\n\t             * @example\n\t             *\n\t             *     var instance = MyType.create();\n\t             */\n\t            create: function () {\n\t                var instance = this.extend();\n\t                instance.init.apply(instance, arguments);\n\n\t                return instance;\n\t            },\n\n\t            /**\n\t             * Initializes a newly created object.\n\t             * Override this method to add some logic when your objects are created.\n\t             *\n\t             * @example\n\t             *\n\t             *     var MyType = CryptoJS.lib.Base.extend({\n\t             *         init: function () {\n\t             *             // ...\n\t             *         }\n\t             *     });\n\t             */\n\t            init: function () {\n\t            },\n\n\t            /**\n\t             * Copies properties into this object.\n\t             *\n\t             * @param {Object} properties The properties to mix in.\n\t             *\n\t             * @example\n\t             *\n\t             *     MyType.mixIn({\n\t             *         field: 'value'\n\t             *     });\n\t             */\n\t            mixIn: function (properties) {\n\t                for (var propertyName in properties) {\n\t                    if (properties.hasOwnProperty(propertyName)) {\n\t                        this[propertyName] = properties[propertyName];\n\t                    }\n\t                }\n\n\t                // IE won't copy toString using the loop above\n\t                if (properties.hasOwnProperty('toString')) {\n\t                    this.toString = properties.toString;\n\t                }\n\t            },\n\n\t            /**\n\t             * Creates a copy of this object.\n\t             *\n\t             * @return {Object} The clone.\n\t             *\n\t             * @example\n\t             *\n\t             *     var clone = instance.clone();\n\t             */\n\t            clone: function () {\n\t                return this.init.prototype.extend(this);\n\t            }\n\t        };\n\t    }());\n\n\t    /**\n\t     * An array of 32-bit words.\n\t     *\n\t     * @property {Array} words The array of 32-bit words.\n\t     * @property {number} sigBytes The number of significant bytes in this word array.\n\t     */\n\t    var WordArray = C_lib.WordArray = Base.extend({\n\t        /**\n\t         * Initializes a newly created word array.\n\t         *\n\t         * @param {Array} words (Optional) An array of 32-bit words.\n\t         * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.lib.WordArray.create();\n\t         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);\n\t         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);\n\t         */\n\t        init: function (words, sigBytes) {\n\t            words = this.words = words || [];\n\n\t            if (sigBytes != undefined) {\n\t                this.sigBytes = sigBytes;\n\t            } else {\n\t                this.sigBytes = words.length * 4;\n\t            }\n\t        },\n\n\t        /**\n\t         * Converts this word array to a string.\n\t         *\n\t         * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex\n\t         *\n\t         * @return {string} The stringified word array.\n\t         *\n\t         * @example\n\t         *\n\t         *     var string = wordArray + '';\n\t         *     var string = wordArray.toString();\n\t         *     var string = wordArray.toString(CryptoJS.enc.Utf8);\n\t         */\n\t        toString: function (encoder) {\n\t            return (encoder || Hex).stringify(this);\n\t        },\n\n\t        /**\n\t         * Concatenates a word array to this word array.\n\t         *\n\t         * @param {WordArray} wordArray The word array to append.\n\t         *\n\t         * @return {WordArray} This word array.\n\t         *\n\t         * @example\n\t         *\n\t         *     wordArray1.concat(wordArray2);\n\t         */\n\t        concat: function (wordArray) {\n\t            // Shortcuts\n\t            var thisWords = this.words;\n\t            var thatWords = wordArray.words;\n\t            var thisSigBytes = this.sigBytes;\n\t            var thatSigBytes = wordArray.sigBytes;\n\n\t            // Clamp excess bits\n\t            this.clamp();\n\n\t            // Concat\n\t            if (thisSigBytes % 4) {\n\t                // Copy one byte at a time\n\t                for (var i = 0; i < thatSigBytes; i++) {\n\t                    var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t                    thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);\n\t                }\n\t            } else {\n\t                // Copy one word at a time\n\t                for (var i = 0; i < thatSigBytes; i += 4) {\n\t                    thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];\n\t                }\n\t            }\n\t            this.sigBytes += thatSigBytes;\n\n\t            // Chainable\n\t            return this;\n\t        },\n\n\t        /**\n\t         * Removes insignificant bits.\n\t         *\n\t         * @example\n\t         *\n\t         *     wordArray.clamp();\n\t         */\n\t        clamp: function () {\n\t            // Shortcuts\n\t            var words = this.words;\n\t            var sigBytes = this.sigBytes;\n\n\t            // Clamp\n\t            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);\n\t            words.length = Math.ceil(sigBytes / 4);\n\t        },\n\n\t        /**\n\t         * Creates a copy of this word array.\n\t         *\n\t         * @return {WordArray} The clone.\n\t         *\n\t         * @example\n\t         *\n\t         *     var clone = wordArray.clone();\n\t         */\n\t        clone: function () {\n\t            var clone = Base.clone.call(this);\n\t            clone.words = this.words.slice(0);\n\n\t            return clone;\n\t        },\n\n\t        /**\n\t         * Creates a word array filled with random bytes.\n\t         *\n\t         * @param {number} nBytes The number of random bytes to generate.\n\t         *\n\t         * @return {WordArray} The random word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.lib.WordArray.random(16);\n\t         */\n\t        random: function (nBytes) {\n\t            var words = [];\n\n\t            var r = (function (m_w) {\n\t                var m_w = m_w;\n\t                var m_z = 0x3ade68b1;\n\t                var mask = 0xffffffff;\n\n\t                return function () {\n\t                    m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;\n\t                    m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;\n\t                    var result = ((m_z << 0x10) + m_w) & mask;\n\t                    result /= 0x100000000;\n\t                    result += 0.5;\n\t                    return result * (Math.random() > .5 ? 1 : -1);\n\t                }\n\t            });\n\n\t            for (var i = 0, rcache; i < nBytes; i += 4) {\n\t                var _r = r((rcache || Math.random()) * 0x100000000);\n\n\t                rcache = _r() * 0x3ade67b7;\n\t                words.push((_r() * 0x100000000) | 0);\n\t            }\n\n\t            return new WordArray.init(words, nBytes);\n\t        }\n\t    });\n\n\t    /**\n\t     * Encoder namespace.\n\t     */\n\t    var C_enc = C.enc = {};\n\n\t    /**\n\t     * Hex encoding strategy.\n\t     */\n\t    var Hex = C_enc.Hex = {\n\t        /**\n\t         * Converts a word array to a hex string.\n\t         *\n\t         * @param {WordArray} wordArray The word array.\n\t         *\n\t         * @return {string} The hex string.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);\n\t         */\n\t        stringify: function (wordArray) {\n\t            // Shortcuts\n\t            var words = wordArray.words;\n\t            var sigBytes = wordArray.sigBytes;\n\n\t            // Convert\n\t            var hexChars = [];\n\t            for (var i = 0; i < sigBytes; i++) {\n\t                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t                hexChars.push((bite >>> 4).toString(16));\n\t                hexChars.push((bite & 0x0f).toString(16));\n\t            }\n\n\t            return hexChars.join('');\n\t        },\n\n\t        /**\n\t         * Converts a hex string to a word array.\n\t         *\n\t         * @param {string} hexStr The hex string.\n\t         *\n\t         * @return {WordArray} The word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.enc.Hex.parse(hexString);\n\t         */\n\t        parse: function (hexStr) {\n\t            // Shortcut\n\t            var hexStrLength = hexStr.length;\n\n\t            // Convert\n\t            var words = [];\n\t            for (var i = 0; i < hexStrLength; i += 2) {\n\t                words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);\n\t            }\n\n\t            return new WordArray.init(words, hexStrLength / 2);\n\t        }\n\t    };\n\n\t    /**\n\t     * Latin1 encoding strategy.\n\t     */\n\t    var Latin1 = C_enc.Latin1 = {\n\t        /**\n\t         * Converts a word array to a Latin1 string.\n\t         *\n\t         * @param {WordArray} wordArray The word array.\n\t         *\n\t         * @return {string} The Latin1 string.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);\n\t         */\n\t        stringify: function (wordArray) {\n\t            // Shortcuts\n\t            var words = wordArray.words;\n\t            var sigBytes = wordArray.sigBytes;\n\n\t            // Convert\n\t            var latin1Chars = [];\n\t            for (var i = 0; i < sigBytes; i++) {\n\t                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t                latin1Chars.push(String.fromCharCode(bite));\n\t            }\n\n\t            return latin1Chars.join('');\n\t        },\n\n\t        /**\n\t         * Converts a Latin1 string to a word array.\n\t         *\n\t         * @param {string} latin1Str The Latin1 string.\n\t         *\n\t         * @return {WordArray} The word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);\n\t         */\n\t        parse: function (latin1Str) {\n\t            // Shortcut\n\t            var latin1StrLength = latin1Str.length;\n\n\t            // Convert\n\t            var words = [];\n\t            for (var i = 0; i < latin1StrLength; i++) {\n\t                words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);\n\t            }\n\n\t            return new WordArray.init(words, latin1StrLength);\n\t        }\n\t    };\n\n\t    /**\n\t     * UTF-8 encoding strategy.\n\t     */\n\t    var Utf8 = C_enc.Utf8 = {\n\t        /**\n\t         * Converts a word array to a UTF-8 string.\n\t         *\n\t         * @param {WordArray} wordArray The word array.\n\t         *\n\t         * @return {string} The UTF-8 string.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);\n\t         */\n\t        stringify: function (wordArray) {\n\t            try {\n\t                return decodeURIComponent(escape(Latin1.stringify(wordArray)));\n\t            } catch (e) {\n\t                throw new Error('Malformed UTF-8 data');\n\t            }\n\t        },\n\n\t        /**\n\t         * Converts a UTF-8 string to a word array.\n\t         *\n\t         * @param {string} utf8Str The UTF-8 string.\n\t         *\n\t         * @return {WordArray} The word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);\n\t         */\n\t        parse: function (utf8Str) {\n\t            return Latin1.parse(unescape(encodeURIComponent(utf8Str)));\n\t        }\n\t    };\n\n\t    /**\n\t     * Abstract buffered block algorithm template.\n\t     *\n\t     * The property blockSize must be implemented in a concrete subtype.\n\t     *\n\t     * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0\n\t     */\n\t    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({\n\t        /**\n\t         * Resets this block algorithm's data buffer to its initial state.\n\t         *\n\t         * @example\n\t         *\n\t         *     bufferedBlockAlgorithm.reset();\n\t         */\n\t        reset: function () {\n\t            // Initial values\n\t            this._data = new WordArray.init();\n\t            this._nDataBytes = 0;\n\t        },\n\n\t        /**\n\t         * Adds new data to this block algorithm's buffer.\n\t         *\n\t         * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.\n\t         *\n\t         * @example\n\t         *\n\t         *     bufferedBlockAlgorithm._append('data');\n\t         *     bufferedBlockAlgorithm._append(wordArray);\n\t         */\n\t        _append: function (data) {\n\t            // Convert string to WordArray, else assume WordArray already\n\t            if (typeof data == 'string') {\n\t                data = Utf8.parse(data);\n\t            }\n\n\t            // Append\n\t            this._data.concat(data);\n\t            this._nDataBytes += data.sigBytes;\n\t        },\n\n\t        /**\n\t         * Processes available data blocks.\n\t         *\n\t         * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.\n\t         *\n\t         * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.\n\t         *\n\t         * @return {WordArray} The processed data.\n\t         *\n\t         * @example\n\t         *\n\t         *     var processedData = bufferedBlockAlgorithm._process();\n\t         *     var processedData = bufferedBlockAlgorithm._process(!!'flush');\n\t         */\n\t        _process: function (doFlush) {\n\t            // Shortcuts\n\t            var data = this._data;\n\t            var dataWords = data.words;\n\t            var dataSigBytes = data.sigBytes;\n\t            var blockSize = this.blockSize;\n\t            var blockSizeBytes = blockSize * 4;\n\n\t            // Count blocks ready\n\t            var nBlocksReady = dataSigBytes / blockSizeBytes;\n\t            if (doFlush) {\n\t                // Round up to include partial blocks\n\t                nBlocksReady = Math.ceil(nBlocksReady);\n\t            } else {\n\t                // Round down to include only full blocks,\n\t                // less the number of blocks that must remain in the buffer\n\t                nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);\n\t            }\n\n\t            // Count words ready\n\t            var nWordsReady = nBlocksReady * blockSize;\n\n\t            // Count bytes ready\n\t            var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);\n\n\t            // Process blocks\n\t            if (nWordsReady) {\n\t                for (var offset = 0; offset < nWordsReady; offset += blockSize) {\n\t                    // Perform concrete-algorithm logic\n\t                    this._doProcessBlock(dataWords, offset);\n\t                }\n\n\t                // Remove processed words\n\t                var processedWords = dataWords.splice(0, nWordsReady);\n\t                data.sigBytes -= nBytesReady;\n\t            }\n\n\t            // Return processed words\n\t            return new WordArray.init(processedWords, nBytesReady);\n\t        },\n\n\t        /**\n\t         * Creates a copy of this object.\n\t         *\n\t         * @return {Object} The clone.\n\t         *\n\t         * @example\n\t         *\n\t         *     var clone = bufferedBlockAlgorithm.clone();\n\t         */\n\t        clone: function () {\n\t            var clone = Base.clone.call(this);\n\t            clone._data = this._data.clone();\n\n\t            return clone;\n\t        },\n\n\t        _minBufferSize: 0\n\t    });\n\n\t    /**\n\t     * Abstract hasher template.\n\t     *\n\t     * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)\n\t     */\n\t    var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({\n\t        /**\n\t         * Configuration options.\n\t         */\n\t        cfg: Base.extend(),\n\n\t        /**\n\t         * Initializes a newly created hasher.\n\t         *\n\t         * @param {Object} cfg (Optional) The configuration options to use for this hash computation.\n\t         *\n\t         * @example\n\t         *\n\t         *     var hasher = CryptoJS.algo.SHA256.create();\n\t         */\n\t        init: function (cfg) {\n\t            // Apply config defaults\n\t            this.cfg = this.cfg.extend(cfg);\n\n\t            // Set initial values\n\t            this.reset();\n\t        },\n\n\t        /**\n\t         * Resets this hasher to its initial state.\n\t         *\n\t         * @example\n\t         *\n\t         *     hasher.reset();\n\t         */\n\t        reset: function () {\n\t            // Reset data buffer\n\t            BufferedBlockAlgorithm.reset.call(this);\n\n\t            // Perform concrete-hasher logic\n\t            this._doReset();\n\t        },\n\n\t        /**\n\t         * Updates this hasher with a message.\n\t         *\n\t         * @param {WordArray|string} messageUpdate The message to append.\n\t         *\n\t         * @return {Hasher} This hasher.\n\t         *\n\t         * @example\n\t         *\n\t         *     hasher.update('message');\n\t         *     hasher.update(wordArray);\n\t         */\n\t        update: function (messageUpdate) {\n\t            // Append\n\t            this._append(messageUpdate);\n\n\t            // Update the hash\n\t            this._process();\n\n\t            // Chainable\n\t            return this;\n\t        },\n\n\t        /**\n\t         * Finalizes the hash computation.\n\t         * Note that the finalize operation is effectively a destructive, read-once operation.\n\t         *\n\t         * @param {WordArray|string} messageUpdate (Optional) A final message update.\n\t         *\n\t         * @return {WordArray} The hash.\n\t         *\n\t         * @example\n\t         *\n\t         *     var hash = hasher.finalize();\n\t         *     var hash = hasher.finalize('message');\n\t         *     var hash = hasher.finalize(wordArray);\n\t         */\n\t        finalize: function (messageUpdate) {\n\t            // Final message update\n\t            if (messageUpdate) {\n\t                this._append(messageUpdate);\n\t            }\n\n\t            // Perform concrete-hasher logic\n\t            var hash = this._doFinalize();\n\n\t            return hash;\n\t        },\n\n\t        blockSize: 512/32,\n\n\t        /**\n\t         * Creates a shortcut function to a hasher's object interface.\n\t         *\n\t         * @param {Hasher} hasher The hasher to create a helper for.\n\t         *\n\t         * @return {Function} The shortcut function.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);\n\t         */\n\t        _createHelper: function (hasher) {\n\t            return function (message, cfg) {\n\t                return new hasher.init(cfg).finalize(message);\n\t            };\n\t        },\n\n\t        /**\n\t         * Creates a shortcut function to the HMAC's object interface.\n\t         *\n\t         * @param {Hasher} hasher The hasher to use in this HMAC helper.\n\t         *\n\t         * @return {Function} The shortcut function.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);\n\t         */\n\t        _createHmacHelper: function (hasher) {\n\t            return function (message, key) {\n\t                return new C_algo.HMAC.init(hasher, key).finalize(message);\n\t            };\n\t        }\n\t    });\n\n\t    /**\n\t     * Algorithm namespace.\n\t     */\n\t    var C_algo = C.algo = {};\n\n\t    return C;\n\t}(Math));\n\n\n\treturn CryptoJS;\n\n}));\n},{}],18:[function(require,module,exports){\n;(function (root, factory, undef) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"), require(\"./x64-core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\", \"./x64-core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (Math) {\n\t    // Shortcuts\n\t    var C = CryptoJS;\n\t    var C_lib = C.lib;\n\t    var WordArray = C_lib.WordArray;\n\t    var Hasher = C_lib.Hasher;\n\t    var C_x64 = C.x64;\n\t    var X64Word = C_x64.Word;\n\t    var C_algo = C.algo;\n\n\t    // Constants tables\n\t    var RHO_OFFSETS = [];\n\t    var PI_INDEXES  = [];\n\t    var ROUND_CONSTANTS = [];\n\n\t    // Compute Constants\n\t    (function () {\n\t        // Compute rho offset constants\n\t        var x = 1, y = 0;\n\t        for (var t = 0; t < 24; t++) {\n\t            RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;\n\n\t            var newX = y % 5;\n\t            var newY = (2 * x + 3 * y) % 5;\n\t            x = newX;\n\t            y = newY;\n\t        }\n\n\t        // Compute pi index constants\n\t        for (var x = 0; x < 5; x++) {\n\t            for (var y = 0; y < 5; y++) {\n\t                PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;\n\t            }\n\t        }\n\n\t        // Compute round constants\n\t        var LFSR = 0x01;\n\t        for (var i = 0; i < 24; i++) {\n\t            var roundConstantMsw = 0;\n\t            var roundConstantLsw = 0;\n\n\t            for (var j = 0; j < 7; j++) {\n\t                if (LFSR & 0x01) {\n\t                    var bitPosition = (1 << j) - 1;\n\t                    if (bitPosition < 32) {\n\t                        roundConstantLsw ^= 1 << bitPosition;\n\t                    } else /* if (bitPosition >= 32) */ {\n\t                        roundConstantMsw ^= 1 << (bitPosition - 32);\n\t                    }\n\t                }\n\n\t                // Compute next LFSR\n\t                if (LFSR & 0x80) {\n\t                    // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1\n\t                    LFSR = (LFSR << 1) ^ 0x71;\n\t                } else {\n\t                    LFSR <<= 1;\n\t                }\n\t            }\n\n\t            ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);\n\t        }\n\t    }());\n\n\t    // Reusable objects for temporary values\n\t    var T = [];\n\t    (function () {\n\t        for (var i = 0; i < 25; i++) {\n\t            T[i] = X64Word.create();\n\t        }\n\t    }());\n\n\t    /**\n\t     * SHA-3 hash algorithm.\n\t     */\n\t    var SHA3 = C_algo.SHA3 = Hasher.extend({\n\t        /**\n\t         * Configuration options.\n\t         *\n\t         * @property {number} outputLength\n\t         *   The desired number of bits in the output hash.\n\t         *   Only values permitted are: 224, 256, 384, 512.\n\t         *   Default: 512\n\t         */\n\t        cfg: Hasher.cfg.extend({\n\t            outputLength: 512\n\t        }),\n\n\t        _doReset: function () {\n\t            var state = this._state = []\n\t            for (var i = 0; i < 25; i++) {\n\t                state[i] = new X64Word.init();\n\t            }\n\n\t            this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;\n\t        },\n\n\t        _doProcessBlock: function (M, offset) {\n\t            // Shortcuts\n\t            var state = this._state;\n\t            var nBlockSizeLanes = this.blockSize / 2;\n\n\t            // Absorb\n\t            for (var i = 0; i < nBlockSizeLanes; i++) {\n\t                // Shortcuts\n\t                var M2i  = M[offset + 2 * i];\n\t                var M2i1 = M[offset + 2 * i + 1];\n\n\t                // Swap endian\n\t                M2i = (\n\t                    (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |\n\t                    (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)\n\t                );\n\t                M2i1 = (\n\t                    (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |\n\t                    (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)\n\t                );\n\n\t                // Absorb message into state\n\t                var lane = state[i];\n\t                lane.high ^= M2i1;\n\t                lane.low  ^= M2i;\n\t            }\n\n\t            // Rounds\n\t            for (var round = 0; round < 24; round++) {\n\t                // Theta\n\t                for (var x = 0; x < 5; x++) {\n\t                    // Mix column lanes\n\t                    var tMsw = 0, tLsw = 0;\n\t                    for (var y = 0; y < 5; y++) {\n\t                        var lane = state[x + 5 * y];\n\t                        tMsw ^= lane.high;\n\t                        tLsw ^= lane.low;\n\t                    }\n\n\t                    // Temporary values\n\t                    var Tx = T[x];\n\t                    Tx.high = tMsw;\n\t                    Tx.low  = tLsw;\n\t                }\n\t                for (var x = 0; x < 5; x++) {\n\t                    // Shortcuts\n\t                    var Tx4 = T[(x + 4) % 5];\n\t                    var Tx1 = T[(x + 1) % 5];\n\t                    var Tx1Msw = Tx1.high;\n\t                    var Tx1Lsw = Tx1.low;\n\n\t                    // Mix surrounding columns\n\t                    var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));\n\t                    var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));\n\t                    for (var y = 0; y < 5; y++) {\n\t                        var lane = state[x + 5 * y];\n\t                        lane.high ^= tMsw;\n\t                        lane.low  ^= tLsw;\n\t                    }\n\t                }\n\n\t                // Rho Pi\n\t                for (var laneIndex = 1; laneIndex < 25; laneIndex++) {\n\t                    // Shortcuts\n\t                    var lane = state[laneIndex];\n\t                    var laneMsw = lane.high;\n\t                    var laneLsw = lane.low;\n\t                    var rhoOffset = RHO_OFFSETS[laneIndex];\n\n\t                    // Rotate lanes\n\t                    if (rhoOffset < 32) {\n\t                        var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));\n\t                        var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));\n\t                    } else /* if (rhoOffset >= 32) */ {\n\t                        var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));\n\t                        var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));\n\t                    }\n\n\t                    // Transpose lanes\n\t                    var TPiLane = T[PI_INDEXES[laneIndex]];\n\t                    TPiLane.high = tMsw;\n\t                    TPiLane.low  = tLsw;\n\t                }\n\n\t                // Rho pi at x = y = 0\n\t                var T0 = T[0];\n\t                var state0 = state[0];\n\t                T0.high = state0.high;\n\t                T0.low  = state0.low;\n\n\t                // Chi\n\t                for (var x = 0; x < 5; x++) {\n\t                    for (var y = 0; y < 5; y++) {\n\t                        // Shortcuts\n\t                        var laneIndex = x + 5 * y;\n\t                        var lane = state[laneIndex];\n\t                        var TLane = T[laneIndex];\n\t                        var Tx1Lane = T[((x + 1) % 5) + 5 * y];\n\t                        var Tx2Lane = T[((x + 2) % 5) + 5 * y];\n\n\t                        // Mix rows\n\t                        lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);\n\t                        lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);\n\t                    }\n\t                }\n\n\t                // Iota\n\t                var lane = state[0];\n\t                var roundConstant = ROUND_CONSTANTS[round];\n\t                lane.high ^= roundConstant.high;\n\t                lane.low  ^= roundConstant.low;;\n\t            }\n\t        },\n\n\t        _doFinalize: function () {\n\t            // Shortcuts\n\t            var data = this._data;\n\t            var dataWords = data.words;\n\t            var nBitsTotal = this._nDataBytes * 8;\n\t            var nBitsLeft = data.sigBytes * 8;\n\t            var blockSizeBits = this.blockSize * 32;\n\n\t            // Add padding\n\t            dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);\n\t            dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;\n\t            data.sigBytes = dataWords.length * 4;\n\n\t            // Hash final blocks\n\t            this._process();\n\n\t            // Shortcuts\n\t            var state = this._state;\n\t            var outputLengthBytes = this.cfg.outputLength / 8;\n\t            var outputLengthLanes = outputLengthBytes / 8;\n\n\t            // Squeeze\n\t            var hashWords = [];\n\t            for (var i = 0; i < outputLengthLanes; i++) {\n\t                // Shortcuts\n\t                var lane = state[i];\n\t                var laneMsw = lane.high;\n\t                var laneLsw = lane.low;\n\n\t                // Swap endian\n\t                laneMsw = (\n\t                    (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |\n\t                    (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)\n\t                );\n\t                laneLsw = (\n\t                    (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |\n\t                    (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)\n\t                );\n\n\t                // Squeeze state to retrieve hash\n\t                hashWords.push(laneLsw);\n\t                hashWords.push(laneMsw);\n\t            }\n\n\t            // Return final computed hash\n\t            return new WordArray.init(hashWords, outputLengthBytes);\n\t        },\n\n\t        clone: function () {\n\t            var clone = Hasher.clone.call(this);\n\n\t            var state = clone._state = this._state.slice(0);\n\t            for (var i = 0; i < 25; i++) {\n\t                state[i] = state[i].clone();\n\t            }\n\n\t            return clone;\n\t        }\n\t    });\n\n\t    /**\n\t     * Shortcut function to the hasher's object interface.\n\t     *\n\t     * @param {WordArray|string} message The message to hash.\n\t     *\n\t     * @return {WordArray} The hash.\n\t     *\n\t     * @static\n\t     *\n\t     * @example\n\t     *\n\t     *     var hash = CryptoJS.SHA3('message');\n\t     *     var hash = CryptoJS.SHA3(wordArray);\n\t     */\n\t    C.SHA3 = Hasher._createHelper(SHA3);\n\n\t    /**\n\t     * Shortcut function to the HMAC's object interface.\n\t     *\n\t     * @param {WordArray|string} message The message to hash.\n\t     * @param {WordArray|string} key The secret key.\n\t     *\n\t     * @return {WordArray} The HMAC.\n\t     *\n\t     * @static\n\t     *\n\t     * @example\n\t     *\n\t     *     var hmac = CryptoJS.HmacSHA3(message, key);\n\t     */\n\t    C.HmacSHA3 = Hasher._createHmacHelper(SHA3);\n\t}(Math));\n\n\n\treturn CryptoJS.SHA3;\n\n}));\n},{\"./core\":17,\"./x64-core\":19}],19:[function(require,module,exports){\n;(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (undefined) {\n\t    // Shortcuts\n\t    var C = CryptoJS;\n\t    var C_lib = C.lib;\n\t    var Base = C_lib.Base;\n\t    var X32WordArray = C_lib.WordArray;\n\n\t    /**\n\t     * x64 namespace.\n\t     */\n\t    var C_x64 = C.x64 = {};\n\n\t    /**\n\t     * A 64-bit word.\n\t     */\n\t    var X64Word = C_x64.Word = Base.extend({\n\t        /**\n\t         * Initializes a newly created 64-bit word.\n\t         *\n\t         * @param {number} high The high 32 bits.\n\t         * @param {number} low The low 32 bits.\n\t         *\n\t         * @example\n\t         *\n\t         *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);\n\t         */\n\t        init: function (high, low) {\n\t            this.high = high;\n\t            this.low = low;\n\t        }\n\n\t        /**\n\t         * Bitwise NOTs this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after negating.\n\t         *\n\t         * @example\n\t         *\n\t         *     var negated = x64Word.not();\n\t         */\n\t        // not: function () {\n\t            // var high = ~this.high;\n\t            // var low = ~this.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Bitwise ANDs this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to AND with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after ANDing.\n\t         *\n\t         * @example\n\t         *\n\t         *     var anded = x64Word.and(anotherX64Word);\n\t         */\n\t        // and: function (word) {\n\t            // var high = this.high & word.high;\n\t            // var low = this.low & word.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Bitwise ORs this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to OR with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after ORing.\n\t         *\n\t         * @example\n\t         *\n\t         *     var ored = x64Word.or(anotherX64Word);\n\t         */\n\t        // or: function (word) {\n\t            // var high = this.high | word.high;\n\t            // var low = this.low | word.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Bitwise XORs this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to XOR with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after XORing.\n\t         *\n\t         * @example\n\t         *\n\t         *     var xored = x64Word.xor(anotherX64Word);\n\t         */\n\t        // xor: function (word) {\n\t            // var high = this.high ^ word.high;\n\t            // var low = this.low ^ word.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Shifts this word n bits to the left.\n\t         *\n\t         * @param {number} n The number of bits to shift.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after shifting.\n\t         *\n\t         * @example\n\t         *\n\t         *     var shifted = x64Word.shiftL(25);\n\t         */\n\t        // shiftL: function (n) {\n\t            // if (n < 32) {\n\t                // var high = (this.high << n) | (this.low >>> (32 - n));\n\t                // var low = this.low << n;\n\t            // } else {\n\t                // var high = this.low << (n - 32);\n\t                // var low = 0;\n\t            // }\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Shifts this word n bits to the right.\n\t         *\n\t         * @param {number} n The number of bits to shift.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after shifting.\n\t         *\n\t         * @example\n\t         *\n\t         *     var shifted = x64Word.shiftR(7);\n\t         */\n\t        // shiftR: function (n) {\n\t            // if (n < 32) {\n\t                // var low = (this.low >>> n) | (this.high << (32 - n));\n\t                // var high = this.high >>> n;\n\t            // } else {\n\t                // var low = this.high >>> (n - 32);\n\t                // var high = 0;\n\t            // }\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Rotates this word n bits to the left.\n\t         *\n\t         * @param {number} n The number of bits to rotate.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after rotating.\n\t         *\n\t         * @example\n\t         *\n\t         *     var rotated = x64Word.rotL(25);\n\t         */\n\t        // rotL: function (n) {\n\t            // return this.shiftL(n).or(this.shiftR(64 - n));\n\t        // },\n\n\t        /**\n\t         * Rotates this word n bits to the right.\n\t         *\n\t         * @param {number} n The number of bits to rotate.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after rotating.\n\t         *\n\t         * @example\n\t         *\n\t         *     var rotated = x64Word.rotR(7);\n\t         */\n\t        // rotR: function (n) {\n\t            // return this.shiftR(n).or(this.shiftL(64 - n));\n\t        // },\n\n\t        /**\n\t         * Adds this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to add with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after adding.\n\t         *\n\t         * @example\n\t         *\n\t         *     var added = x64Word.add(anotherX64Word);\n\t         */\n\t        // add: function (word) {\n\t            // var low = (this.low + word.low) | 0;\n\t            // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;\n\t            // var high = (this.high + word.high + carry) | 0;\n\n\t            // return X64Word.create(high, low);\n\t        // }\n\t    });\n\n\t    /**\n\t     * An array of 64-bit words.\n\t     *\n\t     * @property {Array} words The array of CryptoJS.x64.Word objects.\n\t     * @property {number} sigBytes The number of significant bytes in this word array.\n\t     */\n\t    var X64WordArray = C_x64.WordArray = Base.extend({\n\t        /**\n\t         * Initializes a newly created word array.\n\t         *\n\t         * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.\n\t         * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.x64.WordArray.create();\n\t         *\n\t         *     var wordArray = CryptoJS.x64.WordArray.create([\n\t         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),\n\t         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)\n\t         *     ]);\n\t         *\n\t         *     var wordArray = CryptoJS.x64.WordArray.create([\n\t         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),\n\t         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)\n\t         *     ], 10);\n\t         */\n\t        init: function (words, sigBytes) {\n\t            words = this.words = words || [];\n\n\t            if (sigBytes != undefined) {\n\t                this.sigBytes = sigBytes;\n\t            } else {\n\t                this.sigBytes = words.length * 8;\n\t            }\n\t        },\n\n\t        /**\n\t         * Converts this 64-bit word array to a 32-bit word array.\n\t         *\n\t         * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.\n\t         *\n\t         * @example\n\t         *\n\t         *     var x32WordArray = x64WordArray.toX32();\n\t         */\n\t        toX32: function () {\n\t            // Shortcuts\n\t            var x64Words = this.words;\n\t            var x64WordsLength = x64Words.length;\n\n\t            // Convert\n\t            var x32Words = [];\n\t            for (var i = 0; i < x64WordsLength; i++) {\n\t                var x64Word = x64Words[i];\n\t                x32Words.push(x64Word.high);\n\t                x32Words.push(x64Word.low);\n\t            }\n\n\t            return X32WordArray.create(x32Words, this.sigBytes);\n\t        },\n\n\t        /**\n\t         * Creates a copy of this word array.\n\t         *\n\t         * @return {X64WordArray} The clone.\n\t         *\n\t         * @example\n\t         *\n\t         *     var clone = x64WordArray.clone();\n\t         */\n\t        clone: function () {\n\t            var clone = Base.clone.call(this);\n\n\t            // Clone \"words\" array\n\t            var words = clone.words = this.words.slice(0);\n\n\t            // Clone each X64Word object\n\t            var wordsLength = words.length;\n\t            for (var i = 0; i < wordsLength; i++) {\n\t                words[i] = words[i].clone();\n\t            }\n\n\t            return clone;\n\t        }\n\t    });\n\t}());\n\n\n\treturn CryptoJS;\n\n}));\n},{\"./core\":17}],20:[function(require,module,exports){\nmodule.exports={\n  \"_args\": [\n    [\n      {\n        \"raw\": \"truffle-contract-schema@0.0.5\",\n        \"scope\": null,\n        \"escapedName\": \"truffle-contract-schema\",\n        \"name\": \"truffle-contract-schema\",\n        \"rawSpec\": \"0.0.5\",\n        \"spec\": \"0.0.5\",\n        \"type\": \"version\"\n      },\n      \"/Users/tim/Documents/workspace/Consensys/truffle-contract\"\n    ]\n  ],\n  \"_from\": \"truffle-contract-schema@0.0.5\",\n  \"_id\": \"truffle-contract-schema@0.0.5\",\n  \"_inCache\": true,\n  \"_location\": \"/truffle-contract-schema\",\n  \"_nodeVersion\": \"6.9.1\",\n  \"_npmOperationalInternal\": {\n    \"host\": \"packages-12-west.internal.npmjs.com\",\n    \"tmp\": \"tmp/truffle-contract-schema-0.0.5.tgz_1485557985137_0.46875762194395065\"\n  },\n  \"_npmUser\": {\n    \"name\": \"tcoulter\",\n    \"email\": \"tim@timothyjcoulter.com\"\n  },\n  \"_npmVersion\": \"3.10.8\",\n  \"_phantomChildren\": {},\n  \"_requested\": {\n    \"raw\": \"truffle-contract-schema@0.0.5\",\n    \"scope\": null,\n    \"escapedName\": \"truffle-contract-schema\",\n    \"name\": \"truffle-contract-schema\",\n    \"rawSpec\": \"0.0.5\",\n    \"spec\": \"0.0.5\",\n    \"type\": \"version\"\n  },\n  \"_requiredBy\": [\n    \"/\"\n  ],\n  \"_resolved\": \"https://registry.npmjs.org/truffle-contract-schema/-/truffle-contract-schema-0.0.5.tgz\",\n  \"_shasum\": \"5e9d20bd0bf2a27fe94310748249d484eee49961\",\n  \"_shrinkwrap\": null,\n  \"_spec\": \"truffle-contract-schema@0.0.5\",\n  \"_where\": \"/Users/tim/Documents/workspace/Consensys/truffle-contract\",\n  \"author\": {\n    \"name\": \"Tim Coulter\",\n    \"email\": \"tim.coulter@consensys.net\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/trufflesuite/truffle-schema/issues\"\n  },\n  \"dependencies\": {\n    \"crypto-js\": \"^3.1.9-1\"\n  },\n  \"description\": \"JSON schema for contract artifacts\",\n  \"devDependencies\": {\n    \"mocha\": \"^3.2.0\"\n  },\n  \"directories\": {},\n  \"dist\": {\n    \"shasum\": \"5e9d20bd0bf2a27fe94310748249d484eee49961\",\n    \"tarball\": \"https://registry.npmjs.org/truffle-contract-schema/-/truffle-contract-schema-0.0.5.tgz\"\n  },\n  \"gitHead\": \"cfa4313bd4bb95bf5b94f85185203ead418f9ee6\",\n  \"homepage\": \"https://github.com/trufflesuite/truffle-schema#readme\",\n  \"keywords\": [\n    \"ethereum\",\n    \"json\",\n    \"schema\",\n    \"contract\",\n    \"artifacts\"\n  ],\n  \"license\": \"MIT\",\n  \"main\": \"index.js\",\n  \"maintainers\": [\n    {\n      \"name\": \"tcoulter\",\n      \"email\": \"tim@timothyjcoulter.com\"\n    }\n  ],\n  \"name\": \"truffle-contract-schema\",\n  \"optionalDependencies\": {},\n  \"readme\": \"ERROR: No README data found!\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/trufflesuite/truffle-schema.git\"\n  },\n  \"scripts\": {\n    \"test\": \"mocha\"\n  },\n  \"version\": \"0.0.5\"\n}\n\n},{}]},{},[2]);\n"
  },
  {
    "path": "truffle/ozws/test/.placeholder",
    "content": "This is a placeholder file to ensure the parent directory in the git repository. Feel free to remove.\n"
  },
  {
    "path": "truffle/ozws/truffle.js",
    "content": "module.exports = {\n  networks: {\n    development: {\n      host: \"localhost\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};\n"
  },
  {
    "path": "truffle/prueba/contracts/Migrations.sol",
    "content": "pragma solidity >=0.4.21 <0.6.0;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  constructor() public {\n    owner = msg.sender;\n  }\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/prueba/migrations/1_initial_migration.js",
    "content": "const Migrations = artifacts.require(\"Migrations\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/prueba/truffle-config.js",
    "content": "/**\n * Use this file to configure your truffle project. It's seeded with some\n * common settings for different networks and features like migrations,\n * compilation and testing. Uncomment the ones you need or modify\n * them to suit your project as necessary.\n *\n * More information about configuration can be found at:\n *\n * truffleframework.com/docs/advanced/configuration\n *\n * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider)\n * to sign your transactions before they're sent to a remote public node. Infura API\n * keys are available for free at: infura.io/register\n *\n * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate\n * public/private key pairs. If you're publishing your code to GitHub make sure you load this\n * phrase from a file you've .gitignored so it doesn't accidentally become public.\n *\n */\n\n// const HDWalletProvider = require('truffle-hdwallet-provider');\n// const infuraKey = \"fj4jll3k.....\";\n//\n// const fs = require('fs');\n// const mnemonic = fs.readFileSync(\".secret\").toString().trim();\n\nmodule.exports = {\n  /**\n   * Networks define how you connect to your ethereum client and let you set the\n   * defaults web3 uses to send transactions. If you don't specify one truffle\n   * will spin up a development blockchain for you on port 9545 when you\n   * run `develop` or `test`. You can ask a truffle command to use a specific\n   * network from the command line, e.g\n   *\n   * $ truffle test --network <network-name>\n   */\n\n  networks: {\n    // Useful for testing. The `development` name is special - truffle uses it by default\n    // if it's defined here and no other network is specified at the command line.\n    // You should run a client (like ganache-cli, geth or parity) in a separate terminal\n    // tab if you use this network and you must also set the `host`, `port` and `network_id`\n    // options below to some value.\n    //\n    // development: {\n    //  host: \"127.0.0.1\",     // Localhost (default: none)\n    //  port: 8545,            // Standard Ethereum port (default: none)\n    //  network_id: \"*\",       // Any network (default: none)\n    // },\n\n    // Another network with more advanced options...\n    // advanced: {\n      // port: 8777,             // Custom port\n      // network_id: 1342,       // Custom network\n      // gas: 8500000,           // Gas sent with each transaction (default: ~6700000)\n      // gasPrice: 20000000000,  // 20 gwei (in wei) (default: 100 gwei)\n      // from: <address>,        // Account to send txs from (default: accounts[0])\n      // websockets: true        // Enable EventEmitter interface for web3 (default: false)\n    // },\n\n    // Useful for deploying to a public network.\n    // NB: It's important to wrap the provider as a function.\n    // ropsten: {\n      // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/${infuraKey}`),\n      // network_id: 3,       // Ropsten's id\n      // gas: 5500000,        // Ropsten has a lower block limit than mainnet\n      // confirmations: 2,    // # of confs to wait between deployments. (default: 0)\n      // timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)\n      // skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )\n    // },\n\n    // Useful for private networks\n    // private: {\n      // provider: () => new HDWalletProvider(mnemonic, `https://network.io`),\n      // network_id: 2111,   // This network is yours, in the cloud.\n      // production: true    // Treats this network as if it was a public net. (default: false)\n    // }\n  },\n\n  // Set default mocha options here, use special reporters etc.\n  mocha: {\n    // timeout: 100000\n  },\n\n  // Configure your compilers\n  compilers: {\n    solc: {\n      // version: \"0.5.1\",    // Fetch exact version from solc-bin (default: truffle's version)\n      // docker: true,        // Use \"0.5.1\" you've installed locally with docker (default: false)\n      // settings: {          // See the solidity docs for advice about optimization and evmVersion\n      //  optimizer: {\n      //    enabled: false,\n      //    runs: 200\n      //  },\n      //  evmVersion: \"byzantium\"\n      // }\n    }\n  }\n}\n"
  },
  {
    "path": "truffle/sf1/contracts/Ballot.sol",
    "content": "pragma solidity ^0.4.24;\n\ncontract Ballot {\n    mapping (bytes32 => address[]) public votes;\n    address[] voters;\n    \n    constructor(address[] _voters) public {\n        voters = _voters;\n    }\n    \n    modifier onlyVoters() {\n        for (uint k = 0; k < voters.length; k++)\n            if (msg.sender == voters[k]) {\n                _;\n                return;\n            }\n            \n        revert();\n    }\n    \n    function vote(bytes32 id) public onlyVoters {\n        for (uint k = 0; k < votes[id].length; k++)\n            if (votes[id][k] == msg.sender)\n                revert();\n                \n        votes[id].push(msg.sender);\n    }\n    \n    function noVotes(bytes32 id) public view returns (uint) {\n        return votes[id].length;\n    }\n    \n    function getVoters(bytes32 id) public view returns (address[]) {\n        return votes[id];\n    }\n}\n"
  },
  {
    "path": "truffle/sf1/contracts/Counter.sol",
    "content": "\npragma solidity ^0.4.24;\n\ncontract Counter {\n    uint public counter;\n    \n    constructor() public {\n        counter = 1;\n    }\n    \n    function increment() public {\n        counter++;\n    }\n    \n    function add(uint value) public {\n        counter += value;\n    }\n}\n\n\n\n"
  },
  {
    "path": "truffle/sf1/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.23;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  constructor() public {\n    owner = msg.sender;\n  }\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/sf1/contracts/Token.sol",
    "content": "\npragma solidity ^0.4.24;\n\ncontract Token {\n    mapping(address => uint) balances;\n    \n    constructor() public {\n        balances[msg.sender] = 1000000;\n    }\n    \n    function balanceOf(address account) view public returns (uint) {\n        return balances[account];\n    }\n    \n    function transfer(address receiver, uint amount) public {\n        require(balances[msg.sender] >= amount);\n\n        /*\n        if (balances[msg.sender] < amount)\n            return false;\n        */\n        \n        balances[msg.sender] -= amount;\n        balances[receiver] += amount;\n    }\n}\n\n\n"
  },
  {
    "path": "truffle/sf1/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/sf1/migrations/2_deploy_contracts.js",
    "content": "var Counter = artifacts.require(\"./Counter.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Counter);\n};\n\n"
  },
  {
    "path": "truffle/sf1/test/Ballot_test.js",
    "content": "\nconst Ballot = artifacts.require('./Ballot.sol');\n\nasync function expectThrow (promise) {\n  try {\n    await promise;\n  } catch (error) {\n      return;\n  }\n  \n  assert.fail('Expected throw not received');\n}\n\ncontract('Ballot', function (accounts) {\n    beforeEach(async function () {\n        this.ballot = await Ballot.new([ accounts[0], accounts[1] ]);\n    });\n    \n    it('no votes in unknown proposal', async function () {\n        // bytes32 identificar propuesta por hash\n        \n        const novotes = await this.ballot.noVotes(1);\n        \n        assert.equal(novotes, 0);\n    });\n    \n    it('vote proposal', async function () {\n        await this.ballot.vote(1);\n        \n        const novotes = await this.ballot.noVotes(1);\n        \n        assert.equal(novotes, 1);\n    });\n    \n    it('vote proposal and get voter', async function () {\n        await this.ballot.vote(1);\n        \n        const voters = await this.ballot.getVoters(1);\n        \n        assert.ok(voters);\n        assert.equal(voters.length, 1);\n        assert.equal(voters[0], accounts[0]);\n    });\n    \n    it('vote proposal twice and get voters', async function () {\n        await this.ballot.vote(1);\n        await this.ballot.vote(1, { from: accounts[1] });\n        \n        const voters = await this.ballot.getVoters(1);\n        \n        assert.ok(voters);\n        assert.equal(voters.length, 2);\n        assert.equal(voters[0], accounts[0]);\n        assert.equal(voters[1], accounts[1]);\n    });\n\n    it('avoid double vote', async function () {\n        await this.ballot.vote(1);\n        expectThrow(this.ballot.vote(1));\n        \n        const voters = await this.ballot.getVoters(1);\n        \n        assert.ok(voters);\n        assert.equal(voters.length, 1);\n        assert.equal(voters[0], accounts[0]);\n    });\n\n    it('only voter can vote', async function () {\n        expectThrow(this.ballot.vote(1, { from: accounts[2] }));\n        \n        const novotes = await this.ballot.noVotes(1);\n        \n        assert.equal(novotes, 0);\n    });\n});\n\n"
  },
  {
    "path": "truffle/sf1/test/Counter_tests.js",
    "content": "\nconst Counter = artifacts.require('./Counter.sol');\n\ncontract('Counter', function (accounts) {\n    // console.dir(accounts);\n    \n    describe('first tests', function () {\n        beforeEach(async function () {\n            this.counter = await Counter.new();\n        });\n        \n        it('create contract', async function () {\n            assert.equal(await this.counter.counter(), 1);\n        });\n\n        it('increment', async function () {\n            await this.counter.increment();\n            \n            assert.equal(await this.counter.counter(), 2);\n        });\n\n        it('increment and add', async function () {\n            await this.counter.increment();\n            await this.counter.add(40);\n            \n            assert.equal(await this.counter.counter(), 42);\n        });\n    });\n});\n\n\n"
  },
  {
    "path": "truffle/sf1/test/Token_test.js",
    "content": "\nconst Token = artifacts.require('./Token.sol');\n\ncontract('Token', function (accounts) {\n    it('create token', async function () {\n        const token = await Token.new();\n        \n        const balance = await token.balanceOf(accounts[0]);\n        \n        assert.equal(balance, 1000000);\n    });\n\n    it('create token with another account', async function () {\n        const token = await Token.new({ from: accounts[1] });\n        \n        const balance = await token.balanceOf(accounts[1]);\n        \n        assert.equal(balance, 1000000);\n\n        const balance0 = await token.balanceOf(accounts[0]);\n        \n        assert.equal(balance0, 0);\n    });\n\n    it('transfer', async function () {\n        const token = await Token.new();\n        \n        await token.transfer(accounts[1], 1000, { from: accounts[0] });\n        \n        const balance = await token.balanceOf(accounts[1]);\n        \n        assert.equal(balance, 1000);\n\n        const balance0 = await token.balanceOf(accounts[0]);\n        \n        assert.equal(balance0, 1000000 - 1000);\n    });\n});\n\n"
  },
  {
    "path": "truffle/sf1/truffle-config.js",
    "content": "/*\n * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a \n * function when declaring them. Failure to do so will cause commands to hang. ex:\n * ```\n * mainnet: {\n *     provider: function() { \n *       return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>') \n *     },\n *     network_id: '1',\n *     gas: 4500000,\n *     gasPrice: 10000000000,\n *   },\n */\n\nmodule.exports = {\n  // See <http://truffleframework.com/docs/advanced/configuration>\n  // to customize your Truffle configuration!\n\n  networks: {\n    development: {\n      host: \"127.0.0.1\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};\n\n\n"
  },
  {
    "path": "truffle/sj/contracts/Ballot.sol",
    "content": "\npragma solidity ^0.4.24;\n\ncontract Ballot {\n    mapping (address => bool) canVote;\n    mapping (uint => address[]) votes;\n    \n    modifier onlyVoter() {\n        if (canVote[msg.sender])\n            _;\n    }\n    \n    constructor(address[] _voters) public {\n        for (uint k = 0; k < _voters.length; k++)\n            canVote[_voters[k]] = true;\n    }\n    \n    function vote(uint nproposal) public onlyVoter returns(bool) {\n        address[] storage pvotes = votes[nproposal];\n        \n        for (uint k = 0; k < pvotes.length; k++)\n            if (pvotes[k] == msg.sender)\n                return false;\n                    \n        pvotes.push(msg.sender);\n        \n        return true;\n    }\n    \n    function noVotes(uint nproposal) public view returns (uint) {\n        return votes[nproposal].length;\n    }\n    \n    function getVotes(uint nproposal) public view returns (address[]) {\n        return votes[nproposal];\n    }\n}\n\n"
  },
  {
    "path": "truffle/sj/contracts/Counter.sol",
    "content": "\npragma solidity ^0.4.24;\n\ncontract Counter {\n    uint public counter;\n    \n    constructor(uint value) public {\n        counter = value;\n    }\n    \n    function increment() public {\n        counter++;\n    }\n    \n    function add(uint v) public {\n        counter += v;\n    }\n}\n"
  },
  {
    "path": "truffle/sj/contracts/Empty.sol",
    "content": "\npragma solidity ^0.4.24;\n\ncontract Empty {\n}\n\n"
  },
  {
    "path": "truffle/sj/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.23;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  constructor() public {\n    owner = msg.sender;\n  }\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/sj/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/sj/migrations/2_deploy_contracts.js",
    "content": "var Empty = artifacts.require(\"./Empty.sol\");\nvar Counter = artifacts.require(\"./Counter.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Empty);\n  deployer.deploy(Counter, 1);\n};\n\n"
  },
  {
    "path": "truffle/sj/test/Ballot_tests.js",
    "content": "\nconst Ballot = artifacts.require('./Ballot');\n\ncontract('Ballot', function (accounts) {\n    const voters = [ accounts[0], accounts[1], accounts[2] ];\n    \n    beforeEach(async function() {\n        this.ballot = await Ballot.new(voters);\n    });\n    \n    it('no votes for proposal', async function () {\n        const nvotes = await this.ballot.noVotes(1);\n        \n        assert.equal(nvotes, 0);\n    });\n    \n    it('vote proposal', async function () {\n        await this.ballot.vote(1);\n        \n        const nvotes = await this.ballot.noVotes(1);\n        \n        assert.equal(nvotes, 1);\n    });\n    \n    it('only voter could vote proposal', async function () {\n        await this.ballot.vote(1, { from: accounts[3] });\n        \n        const nvotes = await this.ballot.noVotes(1);\n        \n        assert.equal(nvotes, 0);\n    });\n    \n    it('repeated vote proposal', async function () {\n        await this.ballot.vote(1, { from: accounts[0] });\n        await this.ballot.vote(1, { from: accounts[0] });\n        \n        const nvotes = await this.ballot.noVotes(1);\n        \n        assert.equal(nvotes, 1);\n\n        const votes = await this.ballot.getVotes(1);\n        \n        assert.equal(votes.length, 1);\n        assert.equal(votes[0], accounts[0]);\n    });\n    \n    it('two votes for proposal', async function () {\n        await this.ballot.vote(1, { from: accounts[0] });\n        await this.ballot.vote(1, { from: accounts[1] });\n        \n        const nvotes = await this.ballot.noVotes(1);\n        \n        assert.equal(nvotes, 2);\n\n        const votes = await this.ballot.getVotes(1);\n        \n        assert.equal(votes.length, 2);\n        assert.equal(votes[0], accounts[0]);\n        assert.equal(votes[1], accounts[1]);\n    });\n});\n\n"
  },
  {
    "path": "truffle/sj/test/Counter_tests.js",
    "content": "\nconst Counter = artifacts.require('./Counter');\n\ncontract('Counter', function (accounts) {\n    beforeEach(async function() {\n        this.counter = await Counter.new(1);\n    });\n    \n    it('my first test', async function () {\n        const value = await this.counter.counter();\n        assert.equal(value.toNumber(), 1);\n    });\n\n    it('one increment', async function () {\n        await this.counter.increment();\n        \n        const value = await this.counter.counter();\n        assert.equal(value.toNumber(), 2);\n    });\n\n    it('two increments', async function () {\n        await this.counter.increment();\n        await this.counter.increment();\n        \n        const value = await this.counter.counter();\n        assert.equal(value.toNumber(), 3);\n    });\n\n    it('two increments and add', async function () {\n        await this.counter.increment();\n        await this.counter.increment();\n        await this.counter.add(39);\n        \n        const value = await this.counter.counter();\n        assert.equal(value.toNumber(), 42);\n    });\n});\n\n"
  },
  {
    "path": "truffle/sj/truffle-config.js",
    "content": "/*\n * NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a \n * function when declaring them. Failure to do so will cause commands to hang. ex:\n * ```\n * mainnet: {\n *     provider: function() { \n *       return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>') \n *     },\n *     network_id: '1',\n *     gas: 4500000,\n *     gasPrice: 10000000000,\n *   },\n */\n\nmodule.exports = {\n  // See <http://truffleframework.com/docs/advanced/configuration>\n  // to customize your Truffle configuration!\n  networks: {\n    development: {\n      host: \"127.0.0.1\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};"
  },
  {
    "path": "truffle/tokentutorial/bs-config.json",
    "content": "{\n  \"server\": {\n    \"baseDir\": [\"./src\", \"./build/contracts\"]\n  }\n}\n"
  },
  {
    "path": "truffle/tokentutorial/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.24;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  constructor() public {\n    owner = msg.sender;\n  }\n\n  function setCompleted(uint completed) public restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) public restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/tokentutorial/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/tokentutorial/package.json",
    "content": "{\n  \"name\": \"tutorialtoken\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"truffle.js\",\n  \"directories\": {\n    \"test\": \"test\"\n  },\n  \"scripts\": {\n    \"dev\": \"lite-server\",\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"lite-server\": \"^2.3.0\"\n  }\n}\n"
  },
  {
    "path": "truffle/tokentutorial/src/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->\n    <title>TutorialToken - Wallet</title>\n\n    <!-- Bootstrap -->\n    <link href=\"css/bootstrap.min.css\" rel=\"stylesheet\">\n\n    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->\n    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->\n    <!--[if lt IE 9]>\n      <script src=\"https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js\"></script>\n      <script src=\"https://oss.maxcdn.com/respond/1.4.2/respond.min.js\"></script>\n    <![endif]-->\n  </head>\n  <body>\n    <div class=\"container\">\n      <div class=\"row\">\n        <div class=\"col-xs-12 col-sm-8 col-sm-push-2\">\n          <h1 class=\"text-center\">TutorialToken</h1>\n          <hr/>\n          <br/>\n        </div>\n      </div>\n\n      <div id=\"petsRow\" class=\"row\">\n        <div class=\"col-sm-6 col-sm-push-3 col-md-4 col-md-push-4\">\n          <div class=\"panel panel-default\">\n            <div class=\"panel-heading\">\n              <h3 class=\"panel-title\">My Wallet</h3>\n            </div>\n            <div class=\"panel-body\">\n              <h4>Balance</h4>\n              <strong>Balance</strong>: <span id=\"TTBalance\"></span> TT<br/><br/>\n              <h4>Transfer</h4>\n              <input type=\"text\" class=\"form-control\" id=\"TTTransferAddress\" placeholder=\"Address\" />\n              <input type=\"text\" class=\"form-control\" id=\"TTTransferAmount\" placeholder=\"Amount\" />\n              <button class=\"btn btn-primary\" id=\"transferButton\" type=\"button\">Transfer</button>\n            </div>\n          </div>\n        </div>\n      </div>\n    </div>\n\n    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->\n    <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js\"></script>\n    <!-- Include all compiled plugins (below), or include individual files as needed -->\n    <script src=\"js/bootstrap.min.js\"></script>\n    <script src=\"js/web3.min.js\"></script>\n    <script src=\"js/truffle-contract.js\"></script>\n    <script src=\"js/app.js\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "truffle/tokentutorial/src/js/app.js",
    "content": "App = {\n  web3Provider: null,\n  contracts: {},\n\n  init: function() {\n    return App.initWeb3();\n  },\n\n  initWeb3: function() {\n    // Initialize web3 and set the provider to the testRPC.\n    if (typeof web3 !== 'undefined') {\n      App.web3Provider = web3.currentProvider;\n      web3 = new Web3(web3.currentProvider);\n    } else {\n      // set the provider you want from Web3.providers\n      App.web3Provider = new Web3.providers.HttpProvider('http://127.0.0.1:9545');\n      web3 = new Web3(App.web3Provider);\n    }\n\n    return App.initContract();\n  },\n\n  initContract: function() {\n    $.getJSON('TutorialToken.json', function(data) {\n      // Get the necessary contract artifact file and instantiate it with truffle-contract.\n      var TutorialTokenArtifact = data;\n      App.contracts.TutorialToken = TruffleContract(TutorialTokenArtifact);\n\n      // Set the provider for our contract.\n      App.contracts.TutorialToken.setProvider(App.web3Provider);\n\n      // Use our contract to retieve and mark the adopted pets.\n      return App.getBalances();\n    });\n\n    return App.bindEvents();\n  },\n\n  bindEvents: function() {\n    $(document).on('click', '#transferButton', App.handleTransfer);\n  },\n\n  handleTransfer: function(event) {\n    event.preventDefault();\n\n    var amount = parseInt($('#TTTransferAmount').val());\n    var toAddress = $('#TTTransferAddress').val();\n\n    console.log('Transfer ' + amount + ' TT to ' + toAddress);\n\n    var tutorialTokenInstance;\n\n    web3.eth.getAccounts(function(error, accounts) {\n      if (error) {\n        console.log(error);\n      }\n\n      var account = accounts[0];\n\n      App.contracts.TutorialToken.deployed().then(function(instance) {\n        tutorialTokenInstance = instance;\n\n        return tutorialTokenInstance.transfer(toAddress, amount, {from: account, gas: 100000});\n      }).then(function(result) {\n        alert('Transfer Successful!');\n        return App.getBalances();\n      }).catch(function(err) {\n        console.log(err.message);\n      });\n    });\n  },\n\n  getBalances: function() {\n    console.log('Getting balances...');\n\n    var tutorialTokenInstance;\n\n    web3.eth.getAccounts(function(error, accounts) {\n      if (error) {\n        console.log(error);\n      }\n\n      var account = accounts[0];\n\n      App.contracts.TutorialToken.deployed().then(function(instance) {\n        tutorialTokenInstance = instance;\n\n        return tutorialTokenInstance.balanceOf(account);\n      }).then(function(result) {\n        balance = result.c[0];\n\n        $('#TTBalance').text(balance);\n      }).catch(function(err) {\n        console.log(err.message);\n      });\n    });\n  }\n\n};\n\n$(function() {\n  $(window).load(function() {\n    App.init();\n  });\n});\n"
  },
  {
    "path": "truffle/tokentutorial/src/js/truffle-contract.js",
    "content": "(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){\n(function (global){\nvar ethJSABI = require(\"ethjs-abi\");\nvar BlockchainUtils = require(\"truffle-blockchain-utils\");\nvar Web3 = require(\"web3\");\n\n// For browserified version. If browserify gave us an empty version,\n// look for the one provided by the user.\nif (typeof Web3 == \"object\" && Object.keys(Web3).length == 0) {\n  Web3 = global.Web3;\n}\n\nvar contract = (function(module) {\n\n  // Planned for future features, logging, etc.\n  function Provider(provider) {\n    this.provider = provider;\n  }\n\n  Provider.prototype.send = function() {\n    return this.provider.send.apply(this.provider, arguments);\n  };\n\n  Provider.prototype.sendAsync = function() {\n    return this.provider.sendAsync.apply(this.provider, arguments);\n  };\n\n  var BigNumber = (new Web3()).toBigNumber(0).constructor;\n\n  var Utils = {\n    is_object: function(val) {\n      return typeof val == \"object\" && !Array.isArray(val);\n    },\n    is_big_number: function(val) {\n      if (typeof val != \"object\") return false;\n\n      // Instanceof won't work because we have multiple versions of Web3.\n      try {\n        new BigNumber(val);\n        return true;\n      } catch (e) {\n        return false;\n      }\n    },\n    decodeLogs: function(C, instance, logs) {\n      return logs.map(function(log) {\n        var logABI = C.events[log.topics[0]];\n\n        if (logABI == null) {\n          return null;\n        }\n\n        // This function has been adapted from web3's SolidityEvent.decode() method,\n        // and built to work with ethjs-abi.\n\n        var copy = Utils.merge({}, log);\n\n        function partialABI(fullABI, indexed) {\n          var inputs = fullABI.inputs.filter(function (i) {\n            return i.indexed === indexed;\n          });\n\n          var partial = {\n            inputs: inputs,\n            name: fullABI.name,\n            type: fullABI.type,\n            anonymous: fullABI.anonymous\n          };\n\n          return partial;\n        }\n\n        var argTopics = logABI.anonymous ? copy.topics : copy.topics.slice(1);\n        var indexedData = \"0x\" + argTopics.map(function (topics) { return topics.slice(2); }).join(\"\");\n        var indexedParams = ethJSABI.decodeEvent(partialABI(logABI, true), indexedData);\n\n        var notIndexedData = copy.data;\n        var notIndexedParams = ethJSABI.decodeEvent(partialABI(logABI, false), notIndexedData);\n\n        copy.event = logABI.name;\n\n        copy.args = logABI.inputs.reduce(function (acc, current) {\n          var val = indexedParams[current.name];\n\n          if (val === undefined) {\n            val = notIndexedParams[current.name];\n          }\n\n          acc[current.name] = val;\n          return acc;\n        }, {});\n\n        Object.keys(copy.args).forEach(function(key) {\n          var val = copy.args[key];\n\n          // We have BN. Convert it to BigNumber\n          if (val.constructor.isBN) {\n            copy.args[key] = C.web3.toBigNumber(\"0x\" + val.toString(16));\n          }\n        });\n\n        delete copy.data;\n        delete copy.topics;\n\n        return copy;\n      }).filter(function(log) {\n        return log != null;\n      });\n    },\n    promisifyFunction: function(fn, C) {\n      var self = this;\n      return function() {\n        var instance = this;\n\n        var args = Array.prototype.slice.call(arguments);\n        var tx_params = {};\n        var last_arg = args[args.length - 1];\n\n        // It's only tx_params if it's an object and not a BigNumber.\n        if (Utils.is_object(last_arg) && !Utils.is_big_number(last_arg)) {\n          tx_params = args.pop();\n        }\n\n        tx_params = Utils.merge(C.class_defaults, tx_params);\n\n        return C.detectNetwork().then(function() {\n          return new Promise(function(accept, reject) {\n            var callback = function(error, result) {\n              if (error != null) {\n                reject(error);\n              } else {\n                accept(result);\n              }\n            };\n            args.push(tx_params, callback);\n            fn.apply(instance.contract, args);\n          });\n        });\n      };\n    },\n    synchronizeFunction: function(fn, instance, C) {\n      var self = this;\n      return function() {\n        var args = Array.prototype.slice.call(arguments);\n        var tx_params = {};\n        var last_arg = args[args.length - 1];\n\n        // It's only tx_params if it's an object and not a BigNumber.\n        if (Utils.is_object(last_arg) && !Utils.is_big_number(last_arg)) {\n          tx_params = args.pop();\n        }\n\n        tx_params = Utils.merge(C.class_defaults, tx_params);\n\n        return C.detectNetwork().then(function() {\n          return new Promise(function(accept, reject) {\n            var callback = function(error, tx) {\n              if (error != null) {\n                reject(error);\n                return;\n              }\n\n              var timeout = C.synchronization_timeout || 240000;\n              var start = new Date().getTime();\n\n              var make_attempt = function() {\n                C.web3.eth.getTransactionReceipt(tx, function(err, receipt) {\n                  if (err) return reject(err);\n\n                  if (receipt != null) {\n                    return accept({\n                      tx: tx,\n                      receipt: receipt,\n                      logs: Utils.decodeLogs(C, instance, receipt.logs)\n                    });\n                  }\n\n                  if (timeout > 0 && new Date().getTime() - start > timeout) {\n                    return reject(new Error(\"Transaction \" + tx + \" wasn't processed in \" + (timeout / 1000) + \" seconds!\"));\n                  }\n\n                  setTimeout(make_attempt, 1000);\n                });\n              };\n\n              make_attempt();\n            };\n\n            args.push(tx_params, callback);\n            fn.apply(self, args);\n          });\n        });\n      };\n    },\n    merge: function() {\n      var merged = {};\n      var args = Array.prototype.slice.call(arguments);\n\n      for (var i = 0; i < args.length; i++) {\n        var object = args[i];\n        var keys = Object.keys(object);\n        for (var j = 0; j < keys.length; j++) {\n          var key = keys[j];\n          var value = object[key];\n          merged[key] = value;\n        }\n      }\n\n      return merged;\n    },\n    parallel: function (arr, callback) {\n      callback = callback || function () {};\n      if (!arr.length) {\n        return callback(null, []);\n      }\n      var index = 0;\n      var results = new Array(arr.length);\n      arr.forEach(function (fn, position) {\n        fn(function (err, result) {\n          if (err) {\n            callback(err);\n            callback = function () {};\n          } else {\n            index++;\n            results[position] = result;\n            if (index >= arr.length) {\n              callback(null, results);\n            }\n          }\n        });\n      });\n    },\n    bootstrap: function(fn) {\n      // Add our static methods\n      Object.keys(fn._static_methods).forEach(function(key) {\n        fn[key] = fn._static_methods[key].bind(fn);\n      });\n\n      // Add our properties.\n      Object.keys(fn._properties).forEach(function(key) {\n        fn.addProp(key, fn._properties[key]);\n      });\n\n      return fn;\n    }\n  };\n\n  // Accepts a contract object created with web3.eth.contract.\n  // Optionally, if called without `new`, accepts a network_id and will\n  // create a new version of the contract abstraction with that network_id set.\n  function Contract(contract) {\n    var self = this;\n    var constructor = this.constructor;\n    this.abi = constructor.abi;\n\n    if (typeof contract == \"string\") {\n      var address = contract;\n      var contract_class = constructor.web3.eth.contract(this.abi);\n      contract = contract_class.at(address);\n    }\n\n    this.contract = contract;\n\n    // Provision our functions.\n    for (var i = 0; i < this.abi.length; i++) {\n      var item = this.abi[i];\n      if (item.type == \"function\") {\n        if (item.constant == true) {\n          this[item.name] = Utils.promisifyFunction(contract[item.name], constructor);\n        } else {\n          this[item.name] = Utils.synchronizeFunction(contract[item.name], this, constructor);\n        }\n\n        this[item.name].call = Utils.promisifyFunction(contract[item.name].call, constructor);\n        this[item.name].sendTransaction = Utils.promisifyFunction(contract[item.name].sendTransaction, constructor);\n        this[item.name].request = contract[item.name].request;\n        this[item.name].estimateGas = Utils.promisifyFunction(contract[item.name].estimateGas, constructor);\n      }\n\n      if (item.type == \"event\") {\n        this[item.name] = contract[item.name];\n      }\n    }\n\n    this.sendTransaction = Utils.synchronizeFunction(function(tx_params, callback) {\n      if (typeof tx_params == \"function\") {\n        callback = tx_params;\n        tx_params = {};\n      }\n\n      tx_params.to = self.address;\n\n      constructor.web3.eth.sendTransaction.apply(constructor.web3.eth, [tx_params, callback]);\n    }, this, constructor);\n\n    this.send = function(value) {\n      return self.sendTransaction({value: value});\n    };\n\n    this.allEvents = contract.allEvents;\n    this.address = contract.address;\n    this.transactionHash = contract.transactionHash;\n  };\n\n  Contract._static_methods = {\n    setProvider: function(provider) {\n      if (!provider) {\n        throw new Error(\"Invalid provider passed to setProvider(); provider is \" + provider);\n      }\n\n      var wrapped = new Provider(provider);\n      this.web3.setProvider(wrapped);\n      this.currentProvider = provider;\n    },\n\n    new: function() {\n      var self = this;\n\n      if (this.currentProvider == null) {\n        throw new Error(this.contract_name + \" error: Please call setProvider() first before calling new().\");\n      }\n\n      var args = Array.prototype.slice.call(arguments);\n\n      if (!this.unlinked_binary) {\n        throw new Error(this._json.contract_name + \" error: contract binary not set. Can't deploy new instance.\");\n      }\n\n      return self.detectNetwork().then(function(network_id) {\n        // After the network is set, check to make sure everything's ship shape.\n        var regex = /__[^_]+_+/g;\n        var unlinked_libraries = self.binary.match(regex);\n\n        if (unlinked_libraries != null) {\n          unlinked_libraries = unlinked_libraries.map(function(name) {\n            // Remove underscores\n            return name.replace(/_/g, \"\");\n          }).sort().filter(function(name, index, arr) {\n            // Remove duplicates\n            if (index + 1 >= arr.length) {\n              return true;\n            }\n\n            return name != arr[index + 1];\n          }).join(\", \");\n\n          throw new Error(self.contract_name + \" contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of \" + self._json.contract_name + \": \" + unlinked_libraries);\n        }\n      }).then(function() {\n        return new Promise(function(accept, reject) {\n          var contract_class = self.web3.eth.contract(self.abi);\n          var tx_params = {};\n          var last_arg = args[args.length - 1];\n\n          // It's only tx_params if it's an object and not a BigNumber.\n          if (Utils.is_object(last_arg) && !Utils.is_big_number(last_arg)) {\n            tx_params = args.pop();\n          }\n\n          tx_params = Utils.merge(self.class_defaults, tx_params);\n\n          if (tx_params.data == null) {\n            tx_params.data = self.binary;\n          }\n\n          // web3 0.9.0 and above calls new this callback twice.\n          // Why, I have no idea...\n          var intermediary = function(err, web3_instance) {\n            if (err != null) {\n              reject(err);\n              return;\n            }\n\n            if (err == null && web3_instance != null && web3_instance.address != null) {\n              accept(new self(web3_instance));\n            }\n          };\n\n          args.push(tx_params, intermediary);\n          contract_class.new.apply(contract_class, args);\n        });\n      });\n    },\n\n    at: function(address) {\n      var self = this;\n\n      if (address == null || typeof address != \"string\" || address.length != 42) {\n        throw new Error(\"Invalid address passed to \" + this._json.contract_name + \".at(): \" + address);\n      }\n\n      var contract = new this(address);\n\n      // Add thennable to allow people opt into new recommended usage.\n      contract.then = function(fn) {\n        return self.detectNetwork().then(function(network_id) {\n          var instance = new self(address);\n\n          return new Promise(function(accept, reject) {\n            self.web3.eth.getCode(address, function(err, code) {\n              if (err) return reject(err);\n\n              if (!code || new BigNumber(code).eq(0)) {\n                return reject(new Error(\"Cannot create instance of \" + self.contract_name + \"; no code at address \" + address));\n              }\n\n              accept(instance);\n            });\n          });\n        }).then(fn);\n      };\n\n      return contract;\n    },\n\n    deployed: function() {\n      var self = this;\n      var val = {}; //this.at(this.address);\n\n      // Add thennable to allow people to opt into new recommended usage.\n      val.then = function(fn) {\n        return self.detectNetwork().then(function() {\n          // We don't have a network config for the one we found\n          if (self._json.networks[self.network_id] == null) {\n            throw new Error(self.contract_name + \" has not been deployed to detected network (network/artifact mismatch)\");\n          }\n\n          // If we found the network but it's not deployed\n          if (!self.isDeployed()) {\n            throw new Error(self.contract_name + \" has not been deployed to detected network (\" + self.network_id + \")\");\n          }\n\n          return new self(self.address);\n        }).then(fn);\n      };\n\n      return val;\n    },\n\n    defaults: function(class_defaults) {\n      if (this.class_defaults == null) {\n        this.class_defaults = {};\n      }\n\n      if (class_defaults == null) {\n        class_defaults = {};\n      }\n\n      var self = this;\n      Object.keys(class_defaults).forEach(function(key) {\n        var value = class_defaults[key];\n        self.class_defaults[key] = value;\n      });\n\n      return this.class_defaults;\n    },\n\n    hasNetwork: function(network_id) {\n      return this._json.networks[network_id + \"\"] != null;\n    },\n\n    isDeployed: function() {\n      if (this.network_id == null) {\n        return false;\n      }\n\n      if (this._json.networks[this.network_id] == null) {\n        return false;\n      }\n\n      return !!this.network.address;\n    },\n\n    detectNetwork: function() {\n      var self = this;\n\n      return new Promise(function(accept, reject) {\n        // Try to detect the network we have artifacts for.\n        if (self.network_id) {\n          // We have a network id and a configuration, let's go with it.\n          if (self.networks[self.network_id] != null) {\n            return accept(self.network_id);\n          }\n        }\n\n        self.web3.version.getNetwork(function(err, result) {\n          if (err) return reject(err);\n\n          var network_id = result.toString();\n\n          // If we found the network via a number, let's use that.\n          if (self.hasNetwork(network_id)) {\n            self.setNetwork(network_id);\n            return accept();\n          }\n\n          // Otherwise, go through all the networks that are listed as\n          // blockchain uris and see if they match.\n          var uris = Object.keys(self._json.networks).filter(function(network) {\n            return network.indexOf(\"blockchain://\") == 0;\n          });\n\n          var matches = uris.map(function(uri) {\n            return BlockchainUtils.matches.bind(BlockchainUtils, uri, self.web3.currentProvider);\n          });\n\n          Utils.parallel(matches, function(err, results) {\n            if (err) return reject(err);\n\n            for (var i = 0; i < results.length; i++) {\n              if (results[i]) {\n                self.setNetwork(uris[i]);\n                return accept();\n              }\n            }\n\n            // We found nothing. Set the network id to whatever the provider states.\n            self.setNetwork(network_id);\n\n            accept();\n          });\n\n        });\n      });\n    },\n\n    setNetwork: function(network_id) {\n      if (!network_id) return;\n      this.network_id = network_id + \"\";\n    },\n\n    // Overrides the deployed address to null.\n    // You must call this explicitly so you don't inadvertently do this otherwise.\n    resetAddress: function() {\n      delete this.network.address;\n    },\n\n    link: function(name, address) {\n      var self = this;\n\n      if (typeof name == \"function\") {\n        var contract = name;\n\n        if (contract.isDeployed() == false) {\n          throw new Error(\"Cannot link contract without an address.\");\n        }\n\n        this.link(contract.contract_name, contract.address);\n\n        // Merge events so this contract knows about library's events\n        Object.keys(contract.events).forEach(function(topic) {\n          self.network.events[topic] = contract.events[topic];\n        });\n\n        return;\n      }\n\n      if (typeof name == \"object\") {\n        var obj = name;\n        Object.keys(obj).forEach(function(name) {\n          var a = obj[name];\n          self.link(name, a);\n        });\n        return;\n      }\n\n      if (this._json.networks[this.network_id] == null) {\n        this._json.networks[this.network_id] = {\n          events: {},\n          links: {}\n        };\n      }\n\n      this.network.links[name] = address;\n    },\n\n    clone: function(options) {\n      var self = this;\n      var temp = function TruffleContract() {\n        this.constructor = temp;\n        return Contract.apply(this, arguments);\n      };\n\n      var json = options;\n      var network_id;\n\n      if (typeof options != \"object\") {\n        json = self._json;\n        network_id = options;\n        options = {};\n      }\n\n      temp.prototype = Object.create(self.prototype);\n\n      temp._static_methods = this._static_methods;\n      temp._properties = this._properties;\n\n      temp._property_values = {};\n      temp._json = json || {};\n\n      Utils.bootstrap(temp);\n\n      temp.web3 = new Web3();\n      temp.class_defaults = temp.prototype.defaults || {};\n\n      if (network_id) {\n        temp.setNetwork(network_id);\n      }\n\n      // Copy over custom options\n      Object.keys(options).forEach(function(key) {\n        if (key.indexOf(\"x-\") != 0) return;\n        temp[key] = options[key];\n      });\n\n      return temp;\n    },\n\n    addProp: function(key, fn) {\n      var self = this;\n\n      var getter = function() {\n        if (fn.get != null) {\n          return fn.get.call(self);\n        }\n\n        return self._property_values[key] || fn.call(self);\n      }\n      var setter = function(val) {\n        if (fn.set != null) {\n          fn.set.call(self, val);\n          return;\n        }\n\n        // If there's not a setter, then the property is immutable.\n        throw new Error(key + \" property is immutable\");\n      };\n\n      var definition = {};\n      definition.enumerable = false;\n      definition.configurable = false;\n      definition.get = getter;\n      definition.set = setter;\n\n      Object.defineProperty(this, key, definition);\n    },\n\n    toJSON: function() {\n      return this._json;\n    }\n  };\n\n  // Getter functions are scoped to Contract object.\n  Contract._properties = {\n    contract_name: {\n      get: function() {\n        return this._json.contract_name;\n      },\n      set: function(val) {\n        this._json.contract_name = val;\n      }\n    },\n    abi: {\n      get: function() {\n        return this._json.abi;\n      },\n      set: function(val) {\n        this._json.abi = val;\n      }\n    },\n    network: function() {\n      var network_id = this.network_id;\n\n      if (network_id == null) {\n        throw new Error(this.contract_name + \" has no network id set, cannot lookup artifact data. Either set the network manually using \" + this.contract_name + \".setNetwork(), run \" + this.contract_name + \".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.\");\n      }\n\n      // TODO: this might be bad; setting a value on a get.\n      if (this._json.networks[network_id] == null) {\n        throw new Error(this.contract_name + \" has no network configuration for its current network id (\" + network_id + \").\");\n      }\n\n      return this._json.networks[network_id];\n    },\n    networks: function() {\n      return this._json.networks;\n    },\n    address: {\n      get: function() {\n        var address = this.network.address;\n\n        if (address == null) {\n          throw new Error(\"Cannot find deployed address: \" + this.contract_name + \" not deployed or address not set.\");\n        }\n\n        return address;\n      },\n      set: function(val) {\n        if (val == null) {\n          throw new Error(\"Cannot set deployed address; malformed value: \" + val);\n        }\n\n        var network_id = this.network_id;\n\n        if (network_id == null) {\n          throw new Error(this.contract_name + \" has no network id set, cannot lookup artifact data. Either set the network manually using \" + this.contract_name + \".setNetwork(), run \" + this.contract_name + \".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.\");\n        }\n\n        // Create a network if we don't have one.\n        if (this._json.networks[network_id] == null) {\n          this._json.networks[network_id] = {\n            events: {},\n            links: {}\n          };\n        }\n\n        // Finally, set the address.\n        this.network.address = val;\n      }\n    },\n    links: function() {\n      if (this._json.networks[this.network_id] == null) {\n        return {};\n      }\n\n      return this.network.links || {};\n    },\n    events: function() {\n      // helper web3; not used for provider\n      var web3 = new Web3();\n\n      var events;\n\n      if (this._json.networks[this.network_id] == null) {\n        events = {};\n      } else {\n        events = this.network.events || {};\n      }\n\n      // Merge abi events with whatever's returned.\n      var abi = this.abi;\n\n      abi.forEach(function(item) {\n        if (item.type != \"event\") return;\n\n        var signature = item.name + \"(\";\n\n        item.inputs.forEach(function(input, index) {\n          signature += input.type;\n\n          if (index < item.inputs.length - 1) {\n            signature += \",\";\n          }\n        });\n\n        signature += \")\";\n\n        var topic = web3.sha3(signature);\n\n        events[topic] = item;\n      });\n\n      return events;\n    },\n    binary: function() {\n      var self = this;\n      var binary = this.unlinked_binary;\n\n      Object.keys(this.links).forEach(function(library_name) {\n        var library_address = self.links[library_name];\n        var regex = new RegExp(\"__\" + library_name + \"_*\", \"g\");\n\n        binary = binary.replace(regex, library_address.replace(\"0x\", \"\"));\n      });\n\n      return binary;\n    },\n    unlinked_binary: {\n      get: function() {\n        return this._json.unlinked_binary;\n      },\n      set: function(val) {\n        // TODO: Ensure 0x prefix.\n        this._json.unlinked_binary = val;\n      }\n    },\n    schema_version: function() {\n      return this._json.schema_version;\n    },\n    updated_at: function() {\n      try {\n        return this.network.updated_at || this._json.updated_at;\n      } catch (e) {\n        return this._json.updated_at;\n      }\n    }\n  };\n\n  Utils.bootstrap(Contract);\n\n  module.exports = Contract;\n\n  return Contract;\n})(module || {});\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"ethjs-abi\":7,\"truffle-blockchain-utils\":15,\"web3\":5}],2:[function(require,module,exports){\nvar Schema = require(\"truffle-contract-schema\");\nvar Contract = require(\"./contract.js\");\n\nvar contract = function(options) {\n  options = Schema.normalizeOptions(options);\n  var binary = Schema.generateBinary(options, {}, {dirty: false});\n\n  // Note we don't use `new` here at all. This will cause the class to\n  // \"mutate\" instead of instantiate an instance.\n  return Contract.clone(binary);\n};\n\n// To be used to upgrade old .sol.js abstractions\ncontract.fromSolJS = function(soljs_abstraction, ignore_default_network) {\n  if (ignore_default_network == null) {\n    ignore_default_network = false;\n  }\n\n  // Find the latest binary\n  var latest_network = null;\n  var latest_network_updated_at = 0;\n\n  var networks = {};\n\n  Object.keys(soljs_abstraction.all_networks).forEach(function(network_name) {\n\n    if (network_name == \"default\") {\n      if (ignore_default_network == true ) {\n        return;\n      } else {\n        throw new Error(soljs_abstraction.contract_name + \" has legacy 'default' network artifacts stored within it. Generally these artifacts were a result of running Truffle on a development environment -- in order to store contracts with truffle-contract, all networks must have an identified id. If you're sure this default network represents your development environment, you can ignore processing of the default network by passing `true` as the second argument to this function. However, if you think this network represents artifacts you'd like to keep (i.e., addresses deployed to the main network), you'll need to edit your .sol.js file yourself and change the default network id to be the id of your desired network. For most people, ignoring the default network is the correct option.\");\n      }\n    }\n\n    if (soljs_abstraction.all_networks[network_name].updated_at > latest_network_updated_at) {\n      latest_network = network_name;\n      latest_network_updated_at = soljs_abstraction.all_networks[network_name].updated_at;\n    }\n\n    networks[network_name] = {};\n\n    [\"address\", \"events\", \"links\", \"updated_at\"].forEach(function(key) {\n      networks[network_name][key] = soljs_abstraction.all_networks[network_name][key];\n    })\n  });\n\n  latest_network = soljs_abstraction.all_networks[latest_network] || {};\n\n  var json = {\n    contract_name: soljs_abstraction.contract_name,\n    unlinked_binary: latest_network.unlinked_binary,\n    abi: latest_network.abi,\n    networks: networks,\n    updated_at: latest_network_updated_at == 0 ? undefined : latest_network_updated_at\n  };\n\n  return contract(json);\n};\n\nmodule.exports = contract;\n\nif (typeof window !== \"undefined\") {\n  window.TruffleContract = contract;\n}\n\n},{\"./contract.js\":1,\"truffle-contract-schema\":16}],3:[function(require,module,exports){\n'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n  lookup[i] = code[i]\n  revLookup[code.charCodeAt(i)] = i\n}\n\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction placeHoldersCount (b64) {\n  var len = b64.length\n  if (len % 4 > 0) {\n    throw new Error('Invalid string. Length must be a multiple of 4')\n  }\n\n  // the number of equal signs (place holders)\n  // if there are two placeholders, than the two characters before it\n  // represent one byte\n  // if there is only one, then the three characters before it represent 2 bytes\n  // this is just a cheap hack to not do indexOf twice\n  return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0\n}\n\nfunction byteLength (b64) {\n  // base64 is 4/3 + up to two characters of the original data\n  return b64.length * 3 / 4 - placeHoldersCount(b64)\n}\n\nfunction toByteArray (b64) {\n  var i, j, l, tmp, placeHolders, arr\n  var len = b64.length\n  placeHolders = placeHoldersCount(b64)\n\n  arr = new Arr(len * 3 / 4 - placeHolders)\n\n  // if there are placeholders, only get up to the last complete 4 chars\n  l = placeHolders > 0 ? len - 4 : len\n\n  var L = 0\n\n  for (i = 0, j = 0; i < l; i += 4, j += 3) {\n    tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]\n    arr[L++] = (tmp >> 16) & 0xFF\n    arr[L++] = (tmp >> 8) & 0xFF\n    arr[L++] = tmp & 0xFF\n  }\n\n  if (placeHolders === 2) {\n    tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)\n    arr[L++] = tmp & 0xFF\n  } else if (placeHolders === 1) {\n    tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)\n    arr[L++] = (tmp >> 8) & 0xFF\n    arr[L++] = tmp & 0xFF\n  }\n\n  return arr\n}\n\nfunction tripletToBase64 (num) {\n  return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n  var tmp\n  var output = []\n  for (var i = start; i < end; i += 3) {\n    tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])\n    output.push(tripletToBase64(tmp))\n  }\n  return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n  var tmp\n  var len = uint8.length\n  var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n  var output = ''\n  var parts = []\n  var maxChunkLength = 16383 // must be multiple of 3\n\n  // go through the array every three bytes, we'll deal with trailing stuff later\n  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n    parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n  }\n\n  // pad the end with zeros, but make sure to not forget the extra bytes\n  if (extraBytes === 1) {\n    tmp = uint8[len - 1]\n    output += lookup[tmp >> 2]\n    output += lookup[(tmp << 4) & 0x3F]\n    output += '=='\n  } else if (extraBytes === 2) {\n    tmp = (uint8[len - 2] << 8) + (uint8[len - 1])\n    output += lookup[tmp >> 10]\n    output += lookup[(tmp >> 4) & 0x3F]\n    output += lookup[(tmp << 2) & 0x3F]\n    output += '='\n  }\n\n  parts.push(output)\n\n  return parts.join('')\n}\n\n},{}],4:[function(require,module,exports){\n(function (module, exports) {\n  'use strict';\n\n  // Utils\n  function assert (val, msg) {\n    if (!val) throw new Error(msg || 'Assertion failed');\n  }\n\n  // Could use `inherits` module, but don't want to move from single file\n  // architecture yet.\n  function inherits (ctor, superCtor) {\n    ctor.super_ = superCtor;\n    var TempCtor = function () {};\n    TempCtor.prototype = superCtor.prototype;\n    ctor.prototype = new TempCtor();\n    ctor.prototype.constructor = ctor;\n  }\n\n  // BN\n\n  function BN (number, base, endian) {\n    if (BN.isBN(number)) {\n      return number;\n    }\n\n    this.negative = 0;\n    this.words = null;\n    this.length = 0;\n\n    // Reduction context\n    this.red = null;\n\n    if (number !== null) {\n      if (base === 'le' || base === 'be') {\n        endian = base;\n        base = 10;\n      }\n\n      this._init(number || 0, base || 10, endian || 'be');\n    }\n  }\n  if (typeof module === 'object') {\n    module.exports = BN;\n  } else {\n    exports.BN = BN;\n  }\n\n  BN.BN = BN;\n  BN.wordSize = 26;\n\n  var Buffer;\n  try {\n    Buffer = require('buf' + 'fer').Buffer;\n  } catch (e) {\n  }\n\n  BN.isBN = function isBN (num) {\n    if (num instanceof BN) {\n      return true;\n    }\n\n    return num !== null && typeof num === 'object' &&\n      num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);\n  };\n\n  BN.max = function max (left, right) {\n    if (left.cmp(right) > 0) return left;\n    return right;\n  };\n\n  BN.min = function min (left, right) {\n    if (left.cmp(right) < 0) return left;\n    return right;\n  };\n\n  BN.prototype._init = function init (number, base, endian) {\n    if (typeof number === 'number') {\n      return this._initNumber(number, base, endian);\n    }\n\n    if (typeof number === 'object') {\n      return this._initArray(number, base, endian);\n    }\n\n    if (base === 'hex') {\n      base = 16;\n    }\n    assert(base === (base | 0) && base >= 2 && base <= 36);\n\n    number = number.toString().replace(/\\s+/g, '');\n    var start = 0;\n    if (number[0] === '-') {\n      start++;\n    }\n\n    if (base === 16) {\n      this._parseHex(number, start);\n    } else {\n      this._parseBase(number, base, start);\n    }\n\n    if (number[0] === '-') {\n      this.negative = 1;\n    }\n\n    this.strip();\n\n    if (endian !== 'le') return;\n\n    this._initArray(this.toArray(), base, endian);\n  };\n\n  BN.prototype._initNumber = function _initNumber (number, base, endian) {\n    if (number < 0) {\n      this.negative = 1;\n      number = -number;\n    }\n    if (number < 0x4000000) {\n      this.words = [ number & 0x3ffffff ];\n      this.length = 1;\n    } else if (number < 0x10000000000000) {\n      this.words = [\n        number & 0x3ffffff,\n        (number / 0x4000000) & 0x3ffffff\n      ];\n      this.length = 2;\n    } else {\n      assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)\n      this.words = [\n        number & 0x3ffffff,\n        (number / 0x4000000) & 0x3ffffff,\n        1\n      ];\n      this.length = 3;\n    }\n\n    if (endian !== 'le') return;\n\n    // Reverse the bytes\n    this._initArray(this.toArray(), base, endian);\n  };\n\n  BN.prototype._initArray = function _initArray (number, base, endian) {\n    // Perhaps a Uint8Array\n    assert(typeof number.length === 'number');\n    if (number.length <= 0) {\n      this.words = [ 0 ];\n      this.length = 1;\n      return this;\n    }\n\n    this.length = Math.ceil(number.length / 3);\n    this.words = new Array(this.length);\n    for (var i = 0; i < this.length; i++) {\n      this.words[i] = 0;\n    }\n\n    var j, w;\n    var off = 0;\n    if (endian === 'be') {\n      for (i = number.length - 1, j = 0; i >= 0; i -= 3) {\n        w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);\n        this.words[j] |= (w << off) & 0x3ffffff;\n        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;\n        off += 24;\n        if (off >= 26) {\n          off -= 26;\n          j++;\n        }\n      }\n    } else if (endian === 'le') {\n      for (i = 0, j = 0; i < number.length; i += 3) {\n        w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);\n        this.words[j] |= (w << off) & 0x3ffffff;\n        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;\n        off += 24;\n        if (off >= 26) {\n          off -= 26;\n          j++;\n        }\n      }\n    }\n    return this.strip();\n  };\n\n  function parseHex (str, start, end) {\n    var r = 0;\n    var len = Math.min(str.length, end);\n    for (var i = start; i < len; i++) {\n      var c = str.charCodeAt(i) - 48;\n\n      r <<= 4;\n\n      // 'a' - 'f'\n      if (c >= 49 && c <= 54) {\n        r |= c - 49 + 0xa;\n\n      // 'A' - 'F'\n      } else if (c >= 17 && c <= 22) {\n        r |= c - 17 + 0xa;\n\n      // '0' - '9'\n      } else {\n        r |= c & 0xf;\n      }\n    }\n    return r;\n  }\n\n  BN.prototype._parseHex = function _parseHex (number, start) {\n    // Create possibly bigger array to ensure that it fits the number\n    this.length = Math.ceil((number.length - start) / 6);\n    this.words = new Array(this.length);\n    for (var i = 0; i < this.length; i++) {\n      this.words[i] = 0;\n    }\n\n    var j, w;\n    // Scan 24-bit chunks and add them to the number\n    var off = 0;\n    for (i = number.length - 6, j = 0; i >= start; i -= 6) {\n      w = parseHex(number, i, i + 6);\n      this.words[j] |= (w << off) & 0x3ffffff;\n      // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb\n      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;\n      off += 24;\n      if (off >= 26) {\n        off -= 26;\n        j++;\n      }\n    }\n    if (i + 6 !== start) {\n      w = parseHex(number, start, i + 6);\n      this.words[j] |= (w << off) & 0x3ffffff;\n      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;\n    }\n    this.strip();\n  };\n\n  function parseBase (str, start, end, mul) {\n    var r = 0;\n    var len = Math.min(str.length, end);\n    for (var i = start; i < len; i++) {\n      var c = str.charCodeAt(i) - 48;\n\n      r *= mul;\n\n      // 'a'\n      if (c >= 49) {\n        r += c - 49 + 0xa;\n\n      // 'A'\n      } else if (c >= 17) {\n        r += c - 17 + 0xa;\n\n      // '0' - '9'\n      } else {\n        r += c;\n      }\n    }\n    return r;\n  }\n\n  BN.prototype._parseBase = function _parseBase (number, base, start) {\n    // Initialize as zero\n    this.words = [ 0 ];\n    this.length = 1;\n\n    // Find length of limb in base\n    for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {\n      limbLen++;\n    }\n    limbLen--;\n    limbPow = (limbPow / base) | 0;\n\n    var total = number.length - start;\n    var mod = total % limbLen;\n    var end = Math.min(total, total - mod) + start;\n\n    var word = 0;\n    for (var i = start; i < end; i += limbLen) {\n      word = parseBase(number, i, i + limbLen, base);\n\n      this.imuln(limbPow);\n      if (this.words[0] + word < 0x4000000) {\n        this.words[0] += word;\n      } else {\n        this._iaddn(word);\n      }\n    }\n\n    if (mod !== 0) {\n      var pow = 1;\n      word = parseBase(number, i, number.length, base);\n\n      for (i = 0; i < mod; i++) {\n        pow *= base;\n      }\n\n      this.imuln(pow);\n      if (this.words[0] + word < 0x4000000) {\n        this.words[0] += word;\n      } else {\n        this._iaddn(word);\n      }\n    }\n  };\n\n  BN.prototype.copy = function copy (dest) {\n    dest.words = new Array(this.length);\n    for (var i = 0; i < this.length; i++) {\n      dest.words[i] = this.words[i];\n    }\n    dest.length = this.length;\n    dest.negative = this.negative;\n    dest.red = this.red;\n  };\n\n  BN.prototype.clone = function clone () {\n    var r = new BN(null);\n    this.copy(r);\n    return r;\n  };\n\n  BN.prototype._expand = function _expand (size) {\n    while (this.length < size) {\n      this.words[this.length++] = 0;\n    }\n    return this;\n  };\n\n  // Remove leading `0` from `this`\n  BN.prototype.strip = function strip () {\n    while (this.length > 1 && this.words[this.length - 1] === 0) {\n      this.length--;\n    }\n    return this._normSign();\n  };\n\n  BN.prototype._normSign = function _normSign () {\n    // -0 = 0\n    if (this.length === 1 && this.words[0] === 0) {\n      this.negative = 0;\n    }\n    return this;\n  };\n\n  BN.prototype.inspect = function inspect () {\n    return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';\n  };\n\n  /*\n\n  var zeros = [];\n  var groupSizes = [];\n  var groupBases = [];\n\n  var s = '';\n  var i = -1;\n  while (++i < BN.wordSize) {\n    zeros[i] = s;\n    s += '0';\n  }\n  groupSizes[0] = 0;\n  groupSizes[1] = 0;\n  groupBases[0] = 0;\n  groupBases[1] = 0;\n  var base = 2 - 1;\n  while (++base < 36 + 1) {\n    var groupSize = 0;\n    var groupBase = 1;\n    while (groupBase < (1 << BN.wordSize) / base) {\n      groupBase *= base;\n      groupSize += 1;\n    }\n    groupSizes[base] = groupSize;\n    groupBases[base] = groupBase;\n  }\n\n  */\n\n  var zeros = [\n    '',\n    '0',\n    '00',\n    '000',\n    '0000',\n    '00000',\n    '000000',\n    '0000000',\n    '00000000',\n    '000000000',\n    '0000000000',\n    '00000000000',\n    '000000000000',\n    '0000000000000',\n    '00000000000000',\n    '000000000000000',\n    '0000000000000000',\n    '00000000000000000',\n    '000000000000000000',\n    '0000000000000000000',\n    '00000000000000000000',\n    '000000000000000000000',\n    '0000000000000000000000',\n    '00000000000000000000000',\n    '000000000000000000000000',\n    '0000000000000000000000000'\n  ];\n\n  var groupSizes = [\n    0, 0,\n    25, 16, 12, 11, 10, 9, 8,\n    8, 7, 7, 7, 7, 6, 6,\n    6, 6, 6, 6, 6, 5, 5,\n    5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 5, 5, 5, 5\n  ];\n\n  var groupBases = [\n    0, 0,\n    33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,\n    43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,\n    16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,\n    6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,\n    24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176\n  ];\n\n  BN.prototype.toString = function toString (base, padding) {\n    base = base || 10;\n    padding = padding | 0 || 1;\n\n    var out;\n    if (base === 16 || base === 'hex') {\n      out = '';\n      var off = 0;\n      var carry = 0;\n      for (var i = 0; i < this.length; i++) {\n        var w = this.words[i];\n        var word = (((w << off) | carry) & 0xffffff).toString(16);\n        carry = (w >>> (24 - off)) & 0xffffff;\n        if (carry !== 0 || i !== this.length - 1) {\n          out = zeros[6 - word.length] + word + out;\n        } else {\n          out = word + out;\n        }\n        off += 2;\n        if (off >= 26) {\n          off -= 26;\n          i--;\n        }\n      }\n      if (carry !== 0) {\n        out = carry.toString(16) + out;\n      }\n      while (out.length % padding !== 0) {\n        out = '0' + out;\n      }\n      if (this.negative !== 0) {\n        out = '-' + out;\n      }\n      return out;\n    }\n\n    if (base === (base | 0) && base >= 2 && base <= 36) {\n      // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));\n      var groupSize = groupSizes[base];\n      // var groupBase = Math.pow(base, groupSize);\n      var groupBase = groupBases[base];\n      out = '';\n      var c = this.clone();\n      c.negative = 0;\n      while (!c.isZero()) {\n        var r = c.modn(groupBase).toString(base);\n        c = c.idivn(groupBase);\n\n        if (!c.isZero()) {\n          out = zeros[groupSize - r.length] + r + out;\n        } else {\n          out = r + out;\n        }\n      }\n      if (this.isZero()) {\n        out = '0' + out;\n      }\n      while (out.length % padding !== 0) {\n        out = '0' + out;\n      }\n      if (this.negative !== 0) {\n        out = '-' + out;\n      }\n      return out;\n    }\n\n    assert(false, 'Base should be between 2 and 36');\n  };\n\n  BN.prototype.toNumber = function toNumber () {\n    var ret = this.words[0];\n    if (this.length === 2) {\n      ret += this.words[1] * 0x4000000;\n    } else if (this.length === 3 && this.words[2] === 0x01) {\n      // NOTE: at this stage it is known that the top bit is set\n      ret += 0x10000000000000 + (this.words[1] * 0x4000000);\n    } else if (this.length > 2) {\n      assert(false, 'Number can only safely store up to 53 bits');\n    }\n    return (this.negative !== 0) ? -ret : ret;\n  };\n\n  BN.prototype.toJSON = function toJSON () {\n    return this.toString(16);\n  };\n\n  BN.prototype.toBuffer = function toBuffer (endian, length) {\n    assert(typeof Buffer !== 'undefined');\n    return this.toArrayLike(Buffer, endian, length);\n  };\n\n  BN.prototype.toArray = function toArray (endian, length) {\n    return this.toArrayLike(Array, endian, length);\n  };\n\n  BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {\n    var byteLength = this.byteLength();\n    var reqLength = length || Math.max(1, byteLength);\n    assert(byteLength <= reqLength, 'byte array longer than desired length');\n    assert(reqLength > 0, 'Requested array length <= 0');\n\n    this.strip();\n    var littleEndian = endian === 'le';\n    var res = new ArrayType(reqLength);\n\n    var b, i;\n    var q = this.clone();\n    if (!littleEndian) {\n      // Assume big-endian\n      for (i = 0; i < reqLength - byteLength; i++) {\n        res[i] = 0;\n      }\n\n      for (i = 0; !q.isZero(); i++) {\n        b = q.andln(0xff);\n        q.iushrn(8);\n\n        res[reqLength - i - 1] = b;\n      }\n    } else {\n      for (i = 0; !q.isZero(); i++) {\n        b = q.andln(0xff);\n        q.iushrn(8);\n\n        res[i] = b;\n      }\n\n      for (; i < reqLength; i++) {\n        res[i] = 0;\n      }\n    }\n\n    return res;\n  };\n\n  if (Math.clz32) {\n    BN.prototype._countBits = function _countBits (w) {\n      return 32 - Math.clz32(w);\n    };\n  } else {\n    BN.prototype._countBits = function _countBits (w) {\n      var t = w;\n      var r = 0;\n      if (t >= 0x1000) {\n        r += 13;\n        t >>>= 13;\n      }\n      if (t >= 0x40) {\n        r += 7;\n        t >>>= 7;\n      }\n      if (t >= 0x8) {\n        r += 4;\n        t >>>= 4;\n      }\n      if (t >= 0x02) {\n        r += 2;\n        t >>>= 2;\n      }\n      return r + t;\n    };\n  }\n\n  BN.prototype._zeroBits = function _zeroBits (w) {\n    // Short-cut\n    if (w === 0) return 26;\n\n    var t = w;\n    var r = 0;\n    if ((t & 0x1fff) === 0) {\n      r += 13;\n      t >>>= 13;\n    }\n    if ((t & 0x7f) === 0) {\n      r += 7;\n      t >>>= 7;\n    }\n    if ((t & 0xf) === 0) {\n      r += 4;\n      t >>>= 4;\n    }\n    if ((t & 0x3) === 0) {\n      r += 2;\n      t >>>= 2;\n    }\n    if ((t & 0x1) === 0) {\n      r++;\n    }\n    return r;\n  };\n\n  // Return number of used bits in a BN\n  BN.prototype.bitLength = function bitLength () {\n    var w = this.words[this.length - 1];\n    var hi = this._countBits(w);\n    return (this.length - 1) * 26 + hi;\n  };\n\n  function toBitArray (num) {\n    var w = new Array(num.bitLength());\n\n    for (var bit = 0; bit < w.length; bit++) {\n      var off = (bit / 26) | 0;\n      var wbit = bit % 26;\n\n      w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;\n    }\n\n    return w;\n  }\n\n  // Number of trailing zero bits\n  BN.prototype.zeroBits = function zeroBits () {\n    if (this.isZero()) return 0;\n\n    var r = 0;\n    for (var i = 0; i < this.length; i++) {\n      var b = this._zeroBits(this.words[i]);\n      r += b;\n      if (b !== 26) break;\n    }\n    return r;\n  };\n\n  BN.prototype.byteLength = function byteLength () {\n    return Math.ceil(this.bitLength() / 8);\n  };\n\n  BN.prototype.toTwos = function toTwos (width) {\n    if (this.negative !== 0) {\n      return this.abs().inotn(width).iaddn(1);\n    }\n    return this.clone();\n  };\n\n  BN.prototype.fromTwos = function fromTwos (width) {\n    if (this.testn(width - 1)) {\n      return this.notn(width).iaddn(1).ineg();\n    }\n    return this.clone();\n  };\n\n  BN.prototype.isNeg = function isNeg () {\n    return this.negative !== 0;\n  };\n\n  // Return negative clone of `this`\n  BN.prototype.neg = function neg () {\n    return this.clone().ineg();\n  };\n\n  BN.prototype.ineg = function ineg () {\n    if (!this.isZero()) {\n      this.negative ^= 1;\n    }\n\n    return this;\n  };\n\n  // Or `num` with `this` in-place\n  BN.prototype.iuor = function iuor (num) {\n    while (this.length < num.length) {\n      this.words[this.length++] = 0;\n    }\n\n    for (var i = 0; i < num.length; i++) {\n      this.words[i] = this.words[i] | num.words[i];\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.ior = function ior (num) {\n    assert((this.negative | num.negative) === 0);\n    return this.iuor(num);\n  };\n\n  // Or `num` with `this`\n  BN.prototype.or = function or (num) {\n    if (this.length > num.length) return this.clone().ior(num);\n    return num.clone().ior(this);\n  };\n\n  BN.prototype.uor = function uor (num) {\n    if (this.length > num.length) return this.clone().iuor(num);\n    return num.clone().iuor(this);\n  };\n\n  // And `num` with `this` in-place\n  BN.prototype.iuand = function iuand (num) {\n    // b = min-length(num, this)\n    var b;\n    if (this.length > num.length) {\n      b = num;\n    } else {\n      b = this;\n    }\n\n    for (var i = 0; i < b.length; i++) {\n      this.words[i] = this.words[i] & num.words[i];\n    }\n\n    this.length = b.length;\n\n    return this.strip();\n  };\n\n  BN.prototype.iand = function iand (num) {\n    assert((this.negative | num.negative) === 0);\n    return this.iuand(num);\n  };\n\n  // And `num` with `this`\n  BN.prototype.and = function and (num) {\n    if (this.length > num.length) return this.clone().iand(num);\n    return num.clone().iand(this);\n  };\n\n  BN.prototype.uand = function uand (num) {\n    if (this.length > num.length) return this.clone().iuand(num);\n    return num.clone().iuand(this);\n  };\n\n  // Xor `num` with `this` in-place\n  BN.prototype.iuxor = function iuxor (num) {\n    // a.length > b.length\n    var a;\n    var b;\n    if (this.length > num.length) {\n      a = this;\n      b = num;\n    } else {\n      a = num;\n      b = this;\n    }\n\n    for (var i = 0; i < b.length; i++) {\n      this.words[i] = a.words[i] ^ b.words[i];\n    }\n\n    if (this !== a) {\n      for (; i < a.length; i++) {\n        this.words[i] = a.words[i];\n      }\n    }\n\n    this.length = a.length;\n\n    return this.strip();\n  };\n\n  BN.prototype.ixor = function ixor (num) {\n    assert((this.negative | num.negative) === 0);\n    return this.iuxor(num);\n  };\n\n  // Xor `num` with `this`\n  BN.prototype.xor = function xor (num) {\n    if (this.length > num.length) return this.clone().ixor(num);\n    return num.clone().ixor(this);\n  };\n\n  BN.prototype.uxor = function uxor (num) {\n    if (this.length > num.length) return this.clone().iuxor(num);\n    return num.clone().iuxor(this);\n  };\n\n  // Not ``this`` with ``width`` bitwidth\n  BN.prototype.inotn = function inotn (width) {\n    assert(typeof width === 'number' && width >= 0);\n\n    var bytesNeeded = Math.ceil(width / 26) | 0;\n    var bitsLeft = width % 26;\n\n    // Extend the buffer with leading zeroes\n    this._expand(bytesNeeded);\n\n    if (bitsLeft > 0) {\n      bytesNeeded--;\n    }\n\n    // Handle complete words\n    for (var i = 0; i < bytesNeeded; i++) {\n      this.words[i] = ~this.words[i] & 0x3ffffff;\n    }\n\n    // Handle the residue\n    if (bitsLeft > 0) {\n      this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));\n    }\n\n    // And remove leading zeroes\n    return this.strip();\n  };\n\n  BN.prototype.notn = function notn (width) {\n    return this.clone().inotn(width);\n  };\n\n  // Set `bit` of `this`\n  BN.prototype.setn = function setn (bit, val) {\n    assert(typeof bit === 'number' && bit >= 0);\n\n    var off = (bit / 26) | 0;\n    var wbit = bit % 26;\n\n    this._expand(off + 1);\n\n    if (val) {\n      this.words[off] = this.words[off] | (1 << wbit);\n    } else {\n      this.words[off] = this.words[off] & ~(1 << wbit);\n    }\n\n    return this.strip();\n  };\n\n  // Add `num` to `this` in-place\n  BN.prototype.iadd = function iadd (num) {\n    var r;\n\n    // negative + positive\n    if (this.negative !== 0 && num.negative === 0) {\n      this.negative = 0;\n      r = this.isub(num);\n      this.negative ^= 1;\n      return this._normSign();\n\n    // positive + negative\n    } else if (this.negative === 0 && num.negative !== 0) {\n      num.negative = 0;\n      r = this.isub(num);\n      num.negative = 1;\n      return r._normSign();\n    }\n\n    // a.length > b.length\n    var a, b;\n    if (this.length > num.length) {\n      a = this;\n      b = num;\n    } else {\n      a = num;\n      b = this;\n    }\n\n    var carry = 0;\n    for (var i = 0; i < b.length; i++) {\n      r = (a.words[i] | 0) + (b.words[i] | 0) + carry;\n      this.words[i] = r & 0x3ffffff;\n      carry = r >>> 26;\n    }\n    for (; carry !== 0 && i < a.length; i++) {\n      r = (a.words[i] | 0) + carry;\n      this.words[i] = r & 0x3ffffff;\n      carry = r >>> 26;\n    }\n\n    this.length = a.length;\n    if (carry !== 0) {\n      this.words[this.length] = carry;\n      this.length++;\n    // Copy the rest of the words\n    } else if (a !== this) {\n      for (; i < a.length; i++) {\n        this.words[i] = a.words[i];\n      }\n    }\n\n    return this;\n  };\n\n  // Add `num` to `this`\n  BN.prototype.add = function add (num) {\n    var res;\n    if (num.negative !== 0 && this.negative === 0) {\n      num.negative = 0;\n      res = this.sub(num);\n      num.negative ^= 1;\n      return res;\n    } else if (num.negative === 0 && this.negative !== 0) {\n      this.negative = 0;\n      res = num.sub(this);\n      this.negative = 1;\n      return res;\n    }\n\n    if (this.length > num.length) return this.clone().iadd(num);\n\n    return num.clone().iadd(this);\n  };\n\n  // Subtract `num` from `this` in-place\n  BN.prototype.isub = function isub (num) {\n    // this - (-num) = this + num\n    if (num.negative !== 0) {\n      num.negative = 0;\n      var r = this.iadd(num);\n      num.negative = 1;\n      return r._normSign();\n\n    // -this - num = -(this + num)\n    } else if (this.negative !== 0) {\n      this.negative = 0;\n      this.iadd(num);\n      this.negative = 1;\n      return this._normSign();\n    }\n\n    // At this point both numbers are positive\n    var cmp = this.cmp(num);\n\n    // Optimization - zeroify\n    if (cmp === 0) {\n      this.negative = 0;\n      this.length = 1;\n      this.words[0] = 0;\n      return this;\n    }\n\n    // a > b\n    var a, b;\n    if (cmp > 0) {\n      a = this;\n      b = num;\n    } else {\n      a = num;\n      b = this;\n    }\n\n    var carry = 0;\n    for (var i = 0; i < b.length; i++) {\n      r = (a.words[i] | 0) - (b.words[i] | 0) + carry;\n      carry = r >> 26;\n      this.words[i] = r & 0x3ffffff;\n    }\n    for (; carry !== 0 && i < a.length; i++) {\n      r = (a.words[i] | 0) + carry;\n      carry = r >> 26;\n      this.words[i] = r & 0x3ffffff;\n    }\n\n    // Copy rest of the words\n    if (carry === 0 && i < a.length && a !== this) {\n      for (; i < a.length; i++) {\n        this.words[i] = a.words[i];\n      }\n    }\n\n    this.length = Math.max(this.length, i);\n\n    if (a !== this) {\n      this.negative = 1;\n    }\n\n    return this.strip();\n  };\n\n  // Subtract `num` from `this`\n  BN.prototype.sub = function sub (num) {\n    return this.clone().isub(num);\n  };\n\n  function smallMulTo (self, num, out) {\n    out.negative = num.negative ^ self.negative;\n    var len = (self.length + num.length) | 0;\n    out.length = len;\n    len = (len - 1) | 0;\n\n    // Peel one iteration (compiler can't do it, because of code complexity)\n    var a = self.words[0] | 0;\n    var b = num.words[0] | 0;\n    var r = a * b;\n\n    var lo = r & 0x3ffffff;\n    var carry = (r / 0x4000000) | 0;\n    out.words[0] = lo;\n\n    for (var k = 1; k < len; k++) {\n      // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n      // note that ncarry could be >= 0x3ffffff\n      var ncarry = carry >>> 26;\n      var rword = carry & 0x3ffffff;\n      var maxJ = Math.min(k, num.length - 1);\n      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {\n        var i = (k - j) | 0;\n        a = self.words[i] | 0;\n        b = num.words[j] | 0;\n        r = a * b + rword;\n        ncarry += (r / 0x4000000) | 0;\n        rword = r & 0x3ffffff;\n      }\n      out.words[k] = rword | 0;\n      carry = ncarry | 0;\n    }\n    if (carry !== 0) {\n      out.words[k] = carry | 0;\n    } else {\n      out.length--;\n    }\n\n    return out.strip();\n  }\n\n  // TODO(indutny): it may be reasonable to omit it for users who don't need\n  // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit\n  // multiplication (like elliptic secp256k1).\n  var comb10MulTo = function comb10MulTo (self, num, out) {\n    var a = self.words;\n    var b = num.words;\n    var o = out.words;\n    var c = 0;\n    var lo;\n    var mid;\n    var hi;\n    var a0 = a[0] | 0;\n    var al0 = a0 & 0x1fff;\n    var ah0 = a0 >>> 13;\n    var a1 = a[1] | 0;\n    var al1 = a1 & 0x1fff;\n    var ah1 = a1 >>> 13;\n    var a2 = a[2] | 0;\n    var al2 = a2 & 0x1fff;\n    var ah2 = a2 >>> 13;\n    var a3 = a[3] | 0;\n    var al3 = a3 & 0x1fff;\n    var ah3 = a3 >>> 13;\n    var a4 = a[4] | 0;\n    var al4 = a4 & 0x1fff;\n    var ah4 = a4 >>> 13;\n    var a5 = a[5] | 0;\n    var al5 = a5 & 0x1fff;\n    var ah5 = a5 >>> 13;\n    var a6 = a[6] | 0;\n    var al6 = a6 & 0x1fff;\n    var ah6 = a6 >>> 13;\n    var a7 = a[7] | 0;\n    var al7 = a7 & 0x1fff;\n    var ah7 = a7 >>> 13;\n    var a8 = a[8] | 0;\n    var al8 = a8 & 0x1fff;\n    var ah8 = a8 >>> 13;\n    var a9 = a[9] | 0;\n    var al9 = a9 & 0x1fff;\n    var ah9 = a9 >>> 13;\n    var b0 = b[0] | 0;\n    var bl0 = b0 & 0x1fff;\n    var bh0 = b0 >>> 13;\n    var b1 = b[1] | 0;\n    var bl1 = b1 & 0x1fff;\n    var bh1 = b1 >>> 13;\n    var b2 = b[2] | 0;\n    var bl2 = b2 & 0x1fff;\n    var bh2 = b2 >>> 13;\n    var b3 = b[3] | 0;\n    var bl3 = b3 & 0x1fff;\n    var bh3 = b3 >>> 13;\n    var b4 = b[4] | 0;\n    var bl4 = b4 & 0x1fff;\n    var bh4 = b4 >>> 13;\n    var b5 = b[5] | 0;\n    var bl5 = b5 & 0x1fff;\n    var bh5 = b5 >>> 13;\n    var b6 = b[6] | 0;\n    var bl6 = b6 & 0x1fff;\n    var bh6 = b6 >>> 13;\n    var b7 = b[7] | 0;\n    var bl7 = b7 & 0x1fff;\n    var bh7 = b7 >>> 13;\n    var b8 = b[8] | 0;\n    var bl8 = b8 & 0x1fff;\n    var bh8 = b8 >>> 13;\n    var b9 = b[9] | 0;\n    var bl9 = b9 & 0x1fff;\n    var bh9 = b9 >>> 13;\n\n    out.negative = self.negative ^ num.negative;\n    out.length = 19;\n    /* k = 0 */\n    lo = Math.imul(al0, bl0);\n    mid = Math.imul(al0, bh0);\n    mid = (mid + Math.imul(ah0, bl0)) | 0;\n    hi = Math.imul(ah0, bh0);\n    var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;\n    w0 &= 0x3ffffff;\n    /* k = 1 */\n    lo = Math.imul(al1, bl0);\n    mid = Math.imul(al1, bh0);\n    mid = (mid + Math.imul(ah1, bl0)) | 0;\n    hi = Math.imul(ah1, bh0);\n    lo = (lo + Math.imul(al0, bl1)) | 0;\n    mid = (mid + Math.imul(al0, bh1)) | 0;\n    mid = (mid + Math.imul(ah0, bl1)) | 0;\n    hi = (hi + Math.imul(ah0, bh1)) | 0;\n    var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;\n    w1 &= 0x3ffffff;\n    /* k = 2 */\n    lo = Math.imul(al2, bl0);\n    mid = Math.imul(al2, bh0);\n    mid = (mid + Math.imul(ah2, bl0)) | 0;\n    hi = Math.imul(ah2, bh0);\n    lo = (lo + Math.imul(al1, bl1)) | 0;\n    mid = (mid + Math.imul(al1, bh1)) | 0;\n    mid = (mid + Math.imul(ah1, bl1)) | 0;\n    hi = (hi + Math.imul(ah1, bh1)) | 0;\n    lo = (lo + Math.imul(al0, bl2)) | 0;\n    mid = (mid + Math.imul(al0, bh2)) | 0;\n    mid = (mid + Math.imul(ah0, bl2)) | 0;\n    hi = (hi + Math.imul(ah0, bh2)) | 0;\n    var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;\n    w2 &= 0x3ffffff;\n    /* k = 3 */\n    lo = Math.imul(al3, bl0);\n    mid = Math.imul(al3, bh0);\n    mid = (mid + Math.imul(ah3, bl0)) | 0;\n    hi = Math.imul(ah3, bh0);\n    lo = (lo + Math.imul(al2, bl1)) | 0;\n    mid = (mid + Math.imul(al2, bh1)) | 0;\n    mid = (mid + Math.imul(ah2, bl1)) | 0;\n    hi = (hi + Math.imul(ah2, bh1)) | 0;\n    lo = (lo + Math.imul(al1, bl2)) | 0;\n    mid = (mid + Math.imul(al1, bh2)) | 0;\n    mid = (mid + Math.imul(ah1, bl2)) | 0;\n    hi = (hi + Math.imul(ah1, bh2)) | 0;\n    lo = (lo + Math.imul(al0, bl3)) | 0;\n    mid = (mid + Math.imul(al0, bh3)) | 0;\n    mid = (mid + Math.imul(ah0, bl3)) | 0;\n    hi = (hi + Math.imul(ah0, bh3)) | 0;\n    var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;\n    w3 &= 0x3ffffff;\n    /* k = 4 */\n    lo = Math.imul(al4, bl0);\n    mid = Math.imul(al4, bh0);\n    mid = (mid + Math.imul(ah4, bl0)) | 0;\n    hi = Math.imul(ah4, bh0);\n    lo = (lo + Math.imul(al3, bl1)) | 0;\n    mid = (mid + Math.imul(al3, bh1)) | 0;\n    mid = (mid + Math.imul(ah3, bl1)) | 0;\n    hi = (hi + Math.imul(ah3, bh1)) | 0;\n    lo = (lo + Math.imul(al2, bl2)) | 0;\n    mid = (mid + Math.imul(al2, bh2)) | 0;\n    mid = (mid + Math.imul(ah2, bl2)) | 0;\n    hi = (hi + Math.imul(ah2, bh2)) | 0;\n    lo = (lo + Math.imul(al1, bl3)) | 0;\n    mid = (mid + Math.imul(al1, bh3)) | 0;\n    mid = (mid + Math.imul(ah1, bl3)) | 0;\n    hi = (hi + Math.imul(ah1, bh3)) | 0;\n    lo = (lo + Math.imul(al0, bl4)) | 0;\n    mid = (mid + Math.imul(al0, bh4)) | 0;\n    mid = (mid + Math.imul(ah0, bl4)) | 0;\n    hi = (hi + Math.imul(ah0, bh4)) | 0;\n    var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;\n    w4 &= 0x3ffffff;\n    /* k = 5 */\n    lo = Math.imul(al5, bl0);\n    mid = Math.imul(al5, bh0);\n    mid = (mid + Math.imul(ah5, bl0)) | 0;\n    hi = Math.imul(ah5, bh0);\n    lo = (lo + Math.imul(al4, bl1)) | 0;\n    mid = (mid + Math.imul(al4, bh1)) | 0;\n    mid = (mid + Math.imul(ah4, bl1)) | 0;\n    hi = (hi + Math.imul(ah4, bh1)) | 0;\n    lo = (lo + Math.imul(al3, bl2)) | 0;\n    mid = (mid + Math.imul(al3, bh2)) | 0;\n    mid = (mid + Math.imul(ah3, bl2)) | 0;\n    hi = (hi + Math.imul(ah3, bh2)) | 0;\n    lo = (lo + Math.imul(al2, bl3)) | 0;\n    mid = (mid + Math.imul(al2, bh3)) | 0;\n    mid = (mid + Math.imul(ah2, bl3)) | 0;\n    hi = (hi + Math.imul(ah2, bh3)) | 0;\n    lo = (lo + Math.imul(al1, bl4)) | 0;\n    mid = (mid + Math.imul(al1, bh4)) | 0;\n    mid = (mid + Math.imul(ah1, bl4)) | 0;\n    hi = (hi + Math.imul(ah1, bh4)) | 0;\n    lo = (lo + Math.imul(al0, bl5)) | 0;\n    mid = (mid + Math.imul(al0, bh5)) | 0;\n    mid = (mid + Math.imul(ah0, bl5)) | 0;\n    hi = (hi + Math.imul(ah0, bh5)) | 0;\n    var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;\n    w5 &= 0x3ffffff;\n    /* k = 6 */\n    lo = Math.imul(al6, bl0);\n    mid = Math.imul(al6, bh0);\n    mid = (mid + Math.imul(ah6, bl0)) | 0;\n    hi = Math.imul(ah6, bh0);\n    lo = (lo + Math.imul(al5, bl1)) | 0;\n    mid = (mid + Math.imul(al5, bh1)) | 0;\n    mid = (mid + Math.imul(ah5, bl1)) | 0;\n    hi = (hi + Math.imul(ah5, bh1)) | 0;\n    lo = (lo + Math.imul(al4, bl2)) | 0;\n    mid = (mid + Math.imul(al4, bh2)) | 0;\n    mid = (mid + Math.imul(ah4, bl2)) | 0;\n    hi = (hi + Math.imul(ah4, bh2)) | 0;\n    lo = (lo + Math.imul(al3, bl3)) | 0;\n    mid = (mid + Math.imul(al3, bh3)) | 0;\n    mid = (mid + Math.imul(ah3, bl3)) | 0;\n    hi = (hi + Math.imul(ah3, bh3)) | 0;\n    lo = (lo + Math.imul(al2, bl4)) | 0;\n    mid = (mid + Math.imul(al2, bh4)) | 0;\n    mid = (mid + Math.imul(ah2, bl4)) | 0;\n    hi = (hi + Math.imul(ah2, bh4)) | 0;\n    lo = (lo + Math.imul(al1, bl5)) | 0;\n    mid = (mid + Math.imul(al1, bh5)) | 0;\n    mid = (mid + Math.imul(ah1, bl5)) | 0;\n    hi = (hi + Math.imul(ah1, bh5)) | 0;\n    lo = (lo + Math.imul(al0, bl6)) | 0;\n    mid = (mid + Math.imul(al0, bh6)) | 0;\n    mid = (mid + Math.imul(ah0, bl6)) | 0;\n    hi = (hi + Math.imul(ah0, bh6)) | 0;\n    var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;\n    w6 &= 0x3ffffff;\n    /* k = 7 */\n    lo = Math.imul(al7, bl0);\n    mid = Math.imul(al7, bh0);\n    mid = (mid + Math.imul(ah7, bl0)) | 0;\n    hi = Math.imul(ah7, bh0);\n    lo = (lo + Math.imul(al6, bl1)) | 0;\n    mid = (mid + Math.imul(al6, bh1)) | 0;\n    mid = (mid + Math.imul(ah6, bl1)) | 0;\n    hi = (hi + Math.imul(ah6, bh1)) | 0;\n    lo = (lo + Math.imul(al5, bl2)) | 0;\n    mid = (mid + Math.imul(al5, bh2)) | 0;\n    mid = (mid + Math.imul(ah5, bl2)) | 0;\n    hi = (hi + Math.imul(ah5, bh2)) | 0;\n    lo = (lo + Math.imul(al4, bl3)) | 0;\n    mid = (mid + Math.imul(al4, bh3)) | 0;\n    mid = (mid + Math.imul(ah4, bl3)) | 0;\n    hi = (hi + Math.imul(ah4, bh3)) | 0;\n    lo = (lo + Math.imul(al3, bl4)) | 0;\n    mid = (mid + Math.imul(al3, bh4)) | 0;\n    mid = (mid + Math.imul(ah3, bl4)) | 0;\n    hi = (hi + Math.imul(ah3, bh4)) | 0;\n    lo = (lo + Math.imul(al2, bl5)) | 0;\n    mid = (mid + Math.imul(al2, bh5)) | 0;\n    mid = (mid + Math.imul(ah2, bl5)) | 0;\n    hi = (hi + Math.imul(ah2, bh5)) | 0;\n    lo = (lo + Math.imul(al1, bl6)) | 0;\n    mid = (mid + Math.imul(al1, bh6)) | 0;\n    mid = (mid + Math.imul(ah1, bl6)) | 0;\n    hi = (hi + Math.imul(ah1, bh6)) | 0;\n    lo = (lo + Math.imul(al0, bl7)) | 0;\n    mid = (mid + Math.imul(al0, bh7)) | 0;\n    mid = (mid + Math.imul(ah0, bl7)) | 0;\n    hi = (hi + Math.imul(ah0, bh7)) | 0;\n    var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;\n    w7 &= 0x3ffffff;\n    /* k = 8 */\n    lo = Math.imul(al8, bl0);\n    mid = Math.imul(al8, bh0);\n    mid = (mid + Math.imul(ah8, bl0)) | 0;\n    hi = Math.imul(ah8, bh0);\n    lo = (lo + Math.imul(al7, bl1)) | 0;\n    mid = (mid + Math.imul(al7, bh1)) | 0;\n    mid = (mid + Math.imul(ah7, bl1)) | 0;\n    hi = (hi + Math.imul(ah7, bh1)) | 0;\n    lo = (lo + Math.imul(al6, bl2)) | 0;\n    mid = (mid + Math.imul(al6, bh2)) | 0;\n    mid = (mid + Math.imul(ah6, bl2)) | 0;\n    hi = (hi + Math.imul(ah6, bh2)) | 0;\n    lo = (lo + Math.imul(al5, bl3)) | 0;\n    mid = (mid + Math.imul(al5, bh3)) | 0;\n    mid = (mid + Math.imul(ah5, bl3)) | 0;\n    hi = (hi + Math.imul(ah5, bh3)) | 0;\n    lo = (lo + Math.imul(al4, bl4)) | 0;\n    mid = (mid + Math.imul(al4, bh4)) | 0;\n    mid = (mid + Math.imul(ah4, bl4)) | 0;\n    hi = (hi + Math.imul(ah4, bh4)) | 0;\n    lo = (lo + Math.imul(al3, bl5)) | 0;\n    mid = (mid + Math.imul(al3, bh5)) | 0;\n    mid = (mid + Math.imul(ah3, bl5)) | 0;\n    hi = (hi + Math.imul(ah3, bh5)) | 0;\n    lo = (lo + Math.imul(al2, bl6)) | 0;\n    mid = (mid + Math.imul(al2, bh6)) | 0;\n    mid = (mid + Math.imul(ah2, bl6)) | 0;\n    hi = (hi + Math.imul(ah2, bh6)) | 0;\n    lo = (lo + Math.imul(al1, bl7)) | 0;\n    mid = (mid + Math.imul(al1, bh7)) | 0;\n    mid = (mid + Math.imul(ah1, bl7)) | 0;\n    hi = (hi + Math.imul(ah1, bh7)) | 0;\n    lo = (lo + Math.imul(al0, bl8)) | 0;\n    mid = (mid + Math.imul(al0, bh8)) | 0;\n    mid = (mid + Math.imul(ah0, bl8)) | 0;\n    hi = (hi + Math.imul(ah0, bh8)) | 0;\n    var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;\n    w8 &= 0x3ffffff;\n    /* k = 9 */\n    lo = Math.imul(al9, bl0);\n    mid = Math.imul(al9, bh0);\n    mid = (mid + Math.imul(ah9, bl0)) | 0;\n    hi = Math.imul(ah9, bh0);\n    lo = (lo + Math.imul(al8, bl1)) | 0;\n    mid = (mid + Math.imul(al8, bh1)) | 0;\n    mid = (mid + Math.imul(ah8, bl1)) | 0;\n    hi = (hi + Math.imul(ah8, bh1)) | 0;\n    lo = (lo + Math.imul(al7, bl2)) | 0;\n    mid = (mid + Math.imul(al7, bh2)) | 0;\n    mid = (mid + Math.imul(ah7, bl2)) | 0;\n    hi = (hi + Math.imul(ah7, bh2)) | 0;\n    lo = (lo + Math.imul(al6, bl3)) | 0;\n    mid = (mid + Math.imul(al6, bh3)) | 0;\n    mid = (mid + Math.imul(ah6, bl3)) | 0;\n    hi = (hi + Math.imul(ah6, bh3)) | 0;\n    lo = (lo + Math.imul(al5, bl4)) | 0;\n    mid = (mid + Math.imul(al5, bh4)) | 0;\n    mid = (mid + Math.imul(ah5, bl4)) | 0;\n    hi = (hi + Math.imul(ah5, bh4)) | 0;\n    lo = (lo + Math.imul(al4, bl5)) | 0;\n    mid = (mid + Math.imul(al4, bh5)) | 0;\n    mid = (mid + Math.imul(ah4, bl5)) | 0;\n    hi = (hi + Math.imul(ah4, bh5)) | 0;\n    lo = (lo + Math.imul(al3, bl6)) | 0;\n    mid = (mid + Math.imul(al3, bh6)) | 0;\n    mid = (mid + Math.imul(ah3, bl6)) | 0;\n    hi = (hi + Math.imul(ah3, bh6)) | 0;\n    lo = (lo + Math.imul(al2, bl7)) | 0;\n    mid = (mid + Math.imul(al2, bh7)) | 0;\n    mid = (mid + Math.imul(ah2, bl7)) | 0;\n    hi = (hi + Math.imul(ah2, bh7)) | 0;\n    lo = (lo + Math.imul(al1, bl8)) | 0;\n    mid = (mid + Math.imul(al1, bh8)) | 0;\n    mid = (mid + Math.imul(ah1, bl8)) | 0;\n    hi = (hi + Math.imul(ah1, bh8)) | 0;\n    lo = (lo + Math.imul(al0, bl9)) | 0;\n    mid = (mid + Math.imul(al0, bh9)) | 0;\n    mid = (mid + Math.imul(ah0, bl9)) | 0;\n    hi = (hi + Math.imul(ah0, bh9)) | 0;\n    var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;\n    w9 &= 0x3ffffff;\n    /* k = 10 */\n    lo = Math.imul(al9, bl1);\n    mid = Math.imul(al9, bh1);\n    mid = (mid + Math.imul(ah9, bl1)) | 0;\n    hi = Math.imul(ah9, bh1);\n    lo = (lo + Math.imul(al8, bl2)) | 0;\n    mid = (mid + Math.imul(al8, bh2)) | 0;\n    mid = (mid + Math.imul(ah8, bl2)) | 0;\n    hi = (hi + Math.imul(ah8, bh2)) | 0;\n    lo = (lo + Math.imul(al7, bl3)) | 0;\n    mid = (mid + Math.imul(al7, bh3)) | 0;\n    mid = (mid + Math.imul(ah7, bl3)) | 0;\n    hi = (hi + Math.imul(ah7, bh3)) | 0;\n    lo = (lo + Math.imul(al6, bl4)) | 0;\n    mid = (mid + Math.imul(al6, bh4)) | 0;\n    mid = (mid + Math.imul(ah6, bl4)) | 0;\n    hi = (hi + Math.imul(ah6, bh4)) | 0;\n    lo = (lo + Math.imul(al5, bl5)) | 0;\n    mid = (mid + Math.imul(al5, bh5)) | 0;\n    mid = (mid + Math.imul(ah5, bl5)) | 0;\n    hi = (hi + Math.imul(ah5, bh5)) | 0;\n    lo = (lo + Math.imul(al4, bl6)) | 0;\n    mid = (mid + Math.imul(al4, bh6)) | 0;\n    mid = (mid + Math.imul(ah4, bl6)) | 0;\n    hi = (hi + Math.imul(ah4, bh6)) | 0;\n    lo = (lo + Math.imul(al3, bl7)) | 0;\n    mid = (mid + Math.imul(al3, bh7)) | 0;\n    mid = (mid + Math.imul(ah3, bl7)) | 0;\n    hi = (hi + Math.imul(ah3, bh7)) | 0;\n    lo = (lo + Math.imul(al2, bl8)) | 0;\n    mid = (mid + Math.imul(al2, bh8)) | 0;\n    mid = (mid + Math.imul(ah2, bl8)) | 0;\n    hi = (hi + Math.imul(ah2, bh8)) | 0;\n    lo = (lo + Math.imul(al1, bl9)) | 0;\n    mid = (mid + Math.imul(al1, bh9)) | 0;\n    mid = (mid + Math.imul(ah1, bl9)) | 0;\n    hi = (hi + Math.imul(ah1, bh9)) | 0;\n    var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;\n    w10 &= 0x3ffffff;\n    /* k = 11 */\n    lo = Math.imul(al9, bl2);\n    mid = Math.imul(al9, bh2);\n    mid = (mid + Math.imul(ah9, bl2)) | 0;\n    hi = Math.imul(ah9, bh2);\n    lo = (lo + Math.imul(al8, bl3)) | 0;\n    mid = (mid + Math.imul(al8, bh3)) | 0;\n    mid = (mid + Math.imul(ah8, bl3)) | 0;\n    hi = (hi + Math.imul(ah8, bh3)) | 0;\n    lo = (lo + Math.imul(al7, bl4)) | 0;\n    mid = (mid + Math.imul(al7, bh4)) | 0;\n    mid = (mid + Math.imul(ah7, bl4)) | 0;\n    hi = (hi + Math.imul(ah7, bh4)) | 0;\n    lo = (lo + Math.imul(al6, bl5)) | 0;\n    mid = (mid + Math.imul(al6, bh5)) | 0;\n    mid = (mid + Math.imul(ah6, bl5)) | 0;\n    hi = (hi + Math.imul(ah6, bh5)) | 0;\n    lo = (lo + Math.imul(al5, bl6)) | 0;\n    mid = (mid + Math.imul(al5, bh6)) | 0;\n    mid = (mid + Math.imul(ah5, bl6)) | 0;\n    hi = (hi + Math.imul(ah5, bh6)) | 0;\n    lo = (lo + Math.imul(al4, bl7)) | 0;\n    mid = (mid + Math.imul(al4, bh7)) | 0;\n    mid = (mid + Math.imul(ah4, bl7)) | 0;\n    hi = (hi + Math.imul(ah4, bh7)) | 0;\n    lo = (lo + Math.imul(al3, bl8)) | 0;\n    mid = (mid + Math.imul(al3, bh8)) | 0;\n    mid = (mid + Math.imul(ah3, bl8)) | 0;\n    hi = (hi + Math.imul(ah3, bh8)) | 0;\n    lo = (lo + Math.imul(al2, bl9)) | 0;\n    mid = (mid + Math.imul(al2, bh9)) | 0;\n    mid = (mid + Math.imul(ah2, bl9)) | 0;\n    hi = (hi + Math.imul(ah2, bh9)) | 0;\n    var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;\n    w11 &= 0x3ffffff;\n    /* k = 12 */\n    lo = Math.imul(al9, bl3);\n    mid = Math.imul(al9, bh3);\n    mid = (mid + Math.imul(ah9, bl3)) | 0;\n    hi = Math.imul(ah9, bh3);\n    lo = (lo + Math.imul(al8, bl4)) | 0;\n    mid = (mid + Math.imul(al8, bh4)) | 0;\n    mid = (mid + Math.imul(ah8, bl4)) | 0;\n    hi = (hi + Math.imul(ah8, bh4)) | 0;\n    lo = (lo + Math.imul(al7, bl5)) | 0;\n    mid = (mid + Math.imul(al7, bh5)) | 0;\n    mid = (mid + Math.imul(ah7, bl5)) | 0;\n    hi = (hi + Math.imul(ah7, bh5)) | 0;\n    lo = (lo + Math.imul(al6, bl6)) | 0;\n    mid = (mid + Math.imul(al6, bh6)) | 0;\n    mid = (mid + Math.imul(ah6, bl6)) | 0;\n    hi = (hi + Math.imul(ah6, bh6)) | 0;\n    lo = (lo + Math.imul(al5, bl7)) | 0;\n    mid = (mid + Math.imul(al5, bh7)) | 0;\n    mid = (mid + Math.imul(ah5, bl7)) | 0;\n    hi = (hi + Math.imul(ah5, bh7)) | 0;\n    lo = (lo + Math.imul(al4, bl8)) | 0;\n    mid = (mid + Math.imul(al4, bh8)) | 0;\n    mid = (mid + Math.imul(ah4, bl8)) | 0;\n    hi = (hi + Math.imul(ah4, bh8)) | 0;\n    lo = (lo + Math.imul(al3, bl9)) | 0;\n    mid = (mid + Math.imul(al3, bh9)) | 0;\n    mid = (mid + Math.imul(ah3, bl9)) | 0;\n    hi = (hi + Math.imul(ah3, bh9)) | 0;\n    var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;\n    w12 &= 0x3ffffff;\n    /* k = 13 */\n    lo = Math.imul(al9, bl4);\n    mid = Math.imul(al9, bh4);\n    mid = (mid + Math.imul(ah9, bl4)) | 0;\n    hi = Math.imul(ah9, bh4);\n    lo = (lo + Math.imul(al8, bl5)) | 0;\n    mid = (mid + Math.imul(al8, bh5)) | 0;\n    mid = (mid + Math.imul(ah8, bl5)) | 0;\n    hi = (hi + Math.imul(ah8, bh5)) | 0;\n    lo = (lo + Math.imul(al7, bl6)) | 0;\n    mid = (mid + Math.imul(al7, bh6)) | 0;\n    mid = (mid + Math.imul(ah7, bl6)) | 0;\n    hi = (hi + Math.imul(ah7, bh6)) | 0;\n    lo = (lo + Math.imul(al6, bl7)) | 0;\n    mid = (mid + Math.imul(al6, bh7)) | 0;\n    mid = (mid + Math.imul(ah6, bl7)) | 0;\n    hi = (hi + Math.imul(ah6, bh7)) | 0;\n    lo = (lo + Math.imul(al5, bl8)) | 0;\n    mid = (mid + Math.imul(al5, bh8)) | 0;\n    mid = (mid + Math.imul(ah5, bl8)) | 0;\n    hi = (hi + Math.imul(ah5, bh8)) | 0;\n    lo = (lo + Math.imul(al4, bl9)) | 0;\n    mid = (mid + Math.imul(al4, bh9)) | 0;\n    mid = (mid + Math.imul(ah4, bl9)) | 0;\n    hi = (hi + Math.imul(ah4, bh9)) | 0;\n    var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;\n    w13 &= 0x3ffffff;\n    /* k = 14 */\n    lo = Math.imul(al9, bl5);\n    mid = Math.imul(al9, bh5);\n    mid = (mid + Math.imul(ah9, bl5)) | 0;\n    hi = Math.imul(ah9, bh5);\n    lo = (lo + Math.imul(al8, bl6)) | 0;\n    mid = (mid + Math.imul(al8, bh6)) | 0;\n    mid = (mid + Math.imul(ah8, bl6)) | 0;\n    hi = (hi + Math.imul(ah8, bh6)) | 0;\n    lo = (lo + Math.imul(al7, bl7)) | 0;\n    mid = (mid + Math.imul(al7, bh7)) | 0;\n    mid = (mid + Math.imul(ah7, bl7)) | 0;\n    hi = (hi + Math.imul(ah7, bh7)) | 0;\n    lo = (lo + Math.imul(al6, bl8)) | 0;\n    mid = (mid + Math.imul(al6, bh8)) | 0;\n    mid = (mid + Math.imul(ah6, bl8)) | 0;\n    hi = (hi + Math.imul(ah6, bh8)) | 0;\n    lo = (lo + Math.imul(al5, bl9)) | 0;\n    mid = (mid + Math.imul(al5, bh9)) | 0;\n    mid = (mid + Math.imul(ah5, bl9)) | 0;\n    hi = (hi + Math.imul(ah5, bh9)) | 0;\n    var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;\n    w14 &= 0x3ffffff;\n    /* k = 15 */\n    lo = Math.imul(al9, bl6);\n    mid = Math.imul(al9, bh6);\n    mid = (mid + Math.imul(ah9, bl6)) | 0;\n    hi = Math.imul(ah9, bh6);\n    lo = (lo + Math.imul(al8, bl7)) | 0;\n    mid = (mid + Math.imul(al8, bh7)) | 0;\n    mid = (mid + Math.imul(ah8, bl7)) | 0;\n    hi = (hi + Math.imul(ah8, bh7)) | 0;\n    lo = (lo + Math.imul(al7, bl8)) | 0;\n    mid = (mid + Math.imul(al7, bh8)) | 0;\n    mid = (mid + Math.imul(ah7, bl8)) | 0;\n    hi = (hi + Math.imul(ah7, bh8)) | 0;\n    lo = (lo + Math.imul(al6, bl9)) | 0;\n    mid = (mid + Math.imul(al6, bh9)) | 0;\n    mid = (mid + Math.imul(ah6, bl9)) | 0;\n    hi = (hi + Math.imul(ah6, bh9)) | 0;\n    var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;\n    w15 &= 0x3ffffff;\n    /* k = 16 */\n    lo = Math.imul(al9, bl7);\n    mid = Math.imul(al9, bh7);\n    mid = (mid + Math.imul(ah9, bl7)) | 0;\n    hi = Math.imul(ah9, bh7);\n    lo = (lo + Math.imul(al8, bl8)) | 0;\n    mid = (mid + Math.imul(al8, bh8)) | 0;\n    mid = (mid + Math.imul(ah8, bl8)) | 0;\n    hi = (hi + Math.imul(ah8, bh8)) | 0;\n    lo = (lo + Math.imul(al7, bl9)) | 0;\n    mid = (mid + Math.imul(al7, bh9)) | 0;\n    mid = (mid + Math.imul(ah7, bl9)) | 0;\n    hi = (hi + Math.imul(ah7, bh9)) | 0;\n    var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;\n    w16 &= 0x3ffffff;\n    /* k = 17 */\n    lo = Math.imul(al9, bl8);\n    mid = Math.imul(al9, bh8);\n    mid = (mid + Math.imul(ah9, bl8)) | 0;\n    hi = Math.imul(ah9, bh8);\n    lo = (lo + Math.imul(al8, bl9)) | 0;\n    mid = (mid + Math.imul(al8, bh9)) | 0;\n    mid = (mid + Math.imul(ah8, bl9)) | 0;\n    hi = (hi + Math.imul(ah8, bh9)) | 0;\n    var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;\n    w17 &= 0x3ffffff;\n    /* k = 18 */\n    lo = Math.imul(al9, bl9);\n    mid = Math.imul(al9, bh9);\n    mid = (mid + Math.imul(ah9, bl9)) | 0;\n    hi = Math.imul(ah9, bh9);\n    var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;\n    w18 &= 0x3ffffff;\n    o[0] = w0;\n    o[1] = w1;\n    o[2] = w2;\n    o[3] = w3;\n    o[4] = w4;\n    o[5] = w5;\n    o[6] = w6;\n    o[7] = w7;\n    o[8] = w8;\n    o[9] = w9;\n    o[10] = w10;\n    o[11] = w11;\n    o[12] = w12;\n    o[13] = w13;\n    o[14] = w14;\n    o[15] = w15;\n    o[16] = w16;\n    o[17] = w17;\n    o[18] = w18;\n    if (c !== 0) {\n      o[19] = c;\n      out.length++;\n    }\n    return out;\n  };\n\n  // Polyfill comb\n  if (!Math.imul) {\n    comb10MulTo = smallMulTo;\n  }\n\n  function bigMulTo (self, num, out) {\n    out.negative = num.negative ^ self.negative;\n    out.length = self.length + num.length;\n\n    var carry = 0;\n    var hncarry = 0;\n    for (var k = 0; k < out.length - 1; k++) {\n      // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n      // note that ncarry could be >= 0x3ffffff\n      var ncarry = hncarry;\n      hncarry = 0;\n      var rword = carry & 0x3ffffff;\n      var maxJ = Math.min(k, num.length - 1);\n      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {\n        var i = k - j;\n        var a = self.words[i] | 0;\n        var b = num.words[j] | 0;\n        var r = a * b;\n\n        var lo = r & 0x3ffffff;\n        ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;\n        lo = (lo + rword) | 0;\n        rword = lo & 0x3ffffff;\n        ncarry = (ncarry + (lo >>> 26)) | 0;\n\n        hncarry += ncarry >>> 26;\n        ncarry &= 0x3ffffff;\n      }\n      out.words[k] = rword;\n      carry = ncarry;\n      ncarry = hncarry;\n    }\n    if (carry !== 0) {\n      out.words[k] = carry;\n    } else {\n      out.length--;\n    }\n\n    return out.strip();\n  }\n\n  function jumboMulTo (self, num, out) {\n    var fftm = new FFTM();\n    return fftm.mulp(self, num, out);\n  }\n\n  BN.prototype.mulTo = function mulTo (num, out) {\n    var res;\n    var len = this.length + num.length;\n    if (this.length === 10 && num.length === 10) {\n      res = comb10MulTo(this, num, out);\n    } else if (len < 63) {\n      res = smallMulTo(this, num, out);\n    } else if (len < 1024) {\n      res = bigMulTo(this, num, out);\n    } else {\n      res = jumboMulTo(this, num, out);\n    }\n\n    return res;\n  };\n\n  // Cooley-Tukey algorithm for FFT\n  // slightly revisited to rely on looping instead of recursion\n\n  function FFTM (x, y) {\n    this.x = x;\n    this.y = y;\n  }\n\n  FFTM.prototype.makeRBT = function makeRBT (N) {\n    var t = new Array(N);\n    var l = BN.prototype._countBits(N) - 1;\n    for (var i = 0; i < N; i++) {\n      t[i] = this.revBin(i, l, N);\n    }\n\n    return t;\n  };\n\n  // Returns binary-reversed representation of `x`\n  FFTM.prototype.revBin = function revBin (x, l, N) {\n    if (x === 0 || x === N - 1) return x;\n\n    var rb = 0;\n    for (var i = 0; i < l; i++) {\n      rb |= (x & 1) << (l - i - 1);\n      x >>= 1;\n    }\n\n    return rb;\n  };\n\n  // Performs \"tweedling\" phase, therefore 'emulating'\n  // behaviour of the recursive algorithm\n  FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {\n    for (var i = 0; i < N; i++) {\n      rtws[i] = rws[rbt[i]];\n      itws[i] = iws[rbt[i]];\n    }\n  };\n\n  FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {\n    this.permute(rbt, rws, iws, rtws, itws, N);\n\n    for (var s = 1; s < N; s <<= 1) {\n      var l = s << 1;\n\n      var rtwdf = Math.cos(2 * Math.PI / l);\n      var itwdf = Math.sin(2 * Math.PI / l);\n\n      for (var p = 0; p < N; p += l) {\n        var rtwdf_ = rtwdf;\n        var itwdf_ = itwdf;\n\n        for (var j = 0; j < s; j++) {\n          var re = rtws[p + j];\n          var ie = itws[p + j];\n\n          var ro = rtws[p + j + s];\n          var io = itws[p + j + s];\n\n          var rx = rtwdf_ * ro - itwdf_ * io;\n\n          io = rtwdf_ * io + itwdf_ * ro;\n          ro = rx;\n\n          rtws[p + j] = re + ro;\n          itws[p + j] = ie + io;\n\n          rtws[p + j + s] = re - ro;\n          itws[p + j + s] = ie - io;\n\n          /* jshint maxdepth : false */\n          if (j !== l) {\n            rx = rtwdf * rtwdf_ - itwdf * itwdf_;\n\n            itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;\n            rtwdf_ = rx;\n          }\n        }\n      }\n    }\n  };\n\n  FFTM.prototype.guessLen13b = function guessLen13b (n, m) {\n    var N = Math.max(m, n) | 1;\n    var odd = N & 1;\n    var i = 0;\n    for (N = N / 2 | 0; N; N = N >>> 1) {\n      i++;\n    }\n\n    return 1 << i + 1 + odd;\n  };\n\n  FFTM.prototype.conjugate = function conjugate (rws, iws, N) {\n    if (N <= 1) return;\n\n    for (var i = 0; i < N / 2; i++) {\n      var t = rws[i];\n\n      rws[i] = rws[N - i - 1];\n      rws[N - i - 1] = t;\n\n      t = iws[i];\n\n      iws[i] = -iws[N - i - 1];\n      iws[N - i - 1] = -t;\n    }\n  };\n\n  FFTM.prototype.normalize13b = function normalize13b (ws, N) {\n    var carry = 0;\n    for (var i = 0; i < N / 2; i++) {\n      var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +\n        Math.round(ws[2 * i] / N) +\n        carry;\n\n      ws[i] = w & 0x3ffffff;\n\n      if (w < 0x4000000) {\n        carry = 0;\n      } else {\n        carry = w / 0x4000000 | 0;\n      }\n    }\n\n    return ws;\n  };\n\n  FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {\n    var carry = 0;\n    for (var i = 0; i < len; i++) {\n      carry = carry + (ws[i] | 0);\n\n      rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;\n      rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;\n    }\n\n    // Pad with zeroes\n    for (i = 2 * len; i < N; ++i) {\n      rws[i] = 0;\n    }\n\n    assert(carry === 0);\n    assert((carry & ~0x1fff) === 0);\n  };\n\n  FFTM.prototype.stub = function stub (N) {\n    var ph = new Array(N);\n    for (var i = 0; i < N; i++) {\n      ph[i] = 0;\n    }\n\n    return ph;\n  };\n\n  FFTM.prototype.mulp = function mulp (x, y, out) {\n    var N = 2 * this.guessLen13b(x.length, y.length);\n\n    var rbt = this.makeRBT(N);\n\n    var _ = this.stub(N);\n\n    var rws = new Array(N);\n    var rwst = new Array(N);\n    var iwst = new Array(N);\n\n    var nrws = new Array(N);\n    var nrwst = new Array(N);\n    var niwst = new Array(N);\n\n    var rmws = out.words;\n    rmws.length = N;\n\n    this.convert13b(x.words, x.length, rws, N);\n    this.convert13b(y.words, y.length, nrws, N);\n\n    this.transform(rws, _, rwst, iwst, N, rbt);\n    this.transform(nrws, _, nrwst, niwst, N, rbt);\n\n    for (var i = 0; i < N; i++) {\n      var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];\n      iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];\n      rwst[i] = rx;\n    }\n\n    this.conjugate(rwst, iwst, N);\n    this.transform(rwst, iwst, rmws, _, N, rbt);\n    this.conjugate(rmws, _, N);\n    this.normalize13b(rmws, N);\n\n    out.negative = x.negative ^ y.negative;\n    out.length = x.length + y.length;\n    return out.strip();\n  };\n\n  // Multiply `this` by `num`\n  BN.prototype.mul = function mul (num) {\n    var out = new BN(null);\n    out.words = new Array(this.length + num.length);\n    return this.mulTo(num, out);\n  };\n\n  // Multiply employing FFT\n  BN.prototype.mulf = function mulf (num) {\n    var out = new BN(null);\n    out.words = new Array(this.length + num.length);\n    return jumboMulTo(this, num, out);\n  };\n\n  // In-place Multiplication\n  BN.prototype.imul = function imul (num) {\n    return this.clone().mulTo(num, this);\n  };\n\n  BN.prototype.imuln = function imuln (num) {\n    assert(typeof num === 'number');\n    assert(num < 0x4000000);\n\n    // Carry\n    var carry = 0;\n    for (var i = 0; i < this.length; i++) {\n      var w = (this.words[i] | 0) * num;\n      var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);\n      carry >>= 26;\n      carry += (w / 0x4000000) | 0;\n      // NOTE: lo is 27bit maximum\n      carry += lo >>> 26;\n      this.words[i] = lo & 0x3ffffff;\n    }\n\n    if (carry !== 0) {\n      this.words[i] = carry;\n      this.length++;\n    }\n\n    return this;\n  };\n\n  BN.prototype.muln = function muln (num) {\n    return this.clone().imuln(num);\n  };\n\n  // `this` * `this`\n  BN.prototype.sqr = function sqr () {\n    return this.mul(this);\n  };\n\n  // `this` * `this` in-place\n  BN.prototype.isqr = function isqr () {\n    return this.imul(this.clone());\n  };\n\n  // Math.pow(`this`, `num`)\n  BN.prototype.pow = function pow (num) {\n    var w = toBitArray(num);\n    if (w.length === 0) return new BN(1);\n\n    // Skip leading zeroes\n    var res = this;\n    for (var i = 0; i < w.length; i++, res = res.sqr()) {\n      if (w[i] !== 0) break;\n    }\n\n    if (++i < w.length) {\n      for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {\n        if (w[i] === 0) continue;\n\n        res = res.mul(q);\n      }\n    }\n\n    return res;\n  };\n\n  // Shift-left in-place\n  BN.prototype.iushln = function iushln (bits) {\n    assert(typeof bits === 'number' && bits >= 0);\n    var r = bits % 26;\n    var s = (bits - r) / 26;\n    var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);\n    var i;\n\n    if (r !== 0) {\n      var carry = 0;\n\n      for (i = 0; i < this.length; i++) {\n        var newCarry = this.words[i] & carryMask;\n        var c = ((this.words[i] | 0) - newCarry) << r;\n        this.words[i] = c | carry;\n        carry = newCarry >>> (26 - r);\n      }\n\n      if (carry) {\n        this.words[i] = carry;\n        this.length++;\n      }\n    }\n\n    if (s !== 0) {\n      for (i = this.length - 1; i >= 0; i--) {\n        this.words[i + s] = this.words[i];\n      }\n\n      for (i = 0; i < s; i++) {\n        this.words[i] = 0;\n      }\n\n      this.length += s;\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.ishln = function ishln (bits) {\n    // TODO(indutny): implement me\n    assert(this.negative === 0);\n    return this.iushln(bits);\n  };\n\n  // Shift-right in-place\n  // NOTE: `hint` is a lowest bit before trailing zeroes\n  // NOTE: if `extended` is present - it will be filled with destroyed bits\n  BN.prototype.iushrn = function iushrn (bits, hint, extended) {\n    assert(typeof bits === 'number' && bits >= 0);\n    var h;\n    if (hint) {\n      h = (hint - (hint % 26)) / 26;\n    } else {\n      h = 0;\n    }\n\n    var r = bits % 26;\n    var s = Math.min((bits - r) / 26, this.length);\n    var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);\n    var maskedWords = extended;\n\n    h -= s;\n    h = Math.max(0, h);\n\n    // Extended mode, copy masked part\n    if (maskedWords) {\n      for (var i = 0; i < s; i++) {\n        maskedWords.words[i] = this.words[i];\n      }\n      maskedWords.length = s;\n    }\n\n    if (s === 0) {\n      // No-op, we should not move anything at all\n    } else if (this.length > s) {\n      this.length -= s;\n      for (i = 0; i < this.length; i++) {\n        this.words[i] = this.words[i + s];\n      }\n    } else {\n      this.words[0] = 0;\n      this.length = 1;\n    }\n\n    var carry = 0;\n    for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {\n      var word = this.words[i] | 0;\n      this.words[i] = (carry << (26 - r)) | (word >>> r);\n      carry = word & mask;\n    }\n\n    // Push carried bits as a mask\n    if (maskedWords && carry !== 0) {\n      maskedWords.words[maskedWords.length++] = carry;\n    }\n\n    if (this.length === 0) {\n      this.words[0] = 0;\n      this.length = 1;\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.ishrn = function ishrn (bits, hint, extended) {\n    // TODO(indutny): implement me\n    assert(this.negative === 0);\n    return this.iushrn(bits, hint, extended);\n  };\n\n  // Shift-left\n  BN.prototype.shln = function shln (bits) {\n    return this.clone().ishln(bits);\n  };\n\n  BN.prototype.ushln = function ushln (bits) {\n    return this.clone().iushln(bits);\n  };\n\n  // Shift-right\n  BN.prototype.shrn = function shrn (bits) {\n    return this.clone().ishrn(bits);\n  };\n\n  BN.prototype.ushrn = function ushrn (bits) {\n    return this.clone().iushrn(bits);\n  };\n\n  // Test if n bit is set\n  BN.prototype.testn = function testn (bit) {\n    assert(typeof bit === 'number' && bit >= 0);\n    var r = bit % 26;\n    var s = (bit - r) / 26;\n    var q = 1 << r;\n\n    // Fast case: bit is much higher than all existing words\n    if (this.length <= s) return false;\n\n    // Check bit and return\n    var w = this.words[s];\n\n    return !!(w & q);\n  };\n\n  // Return only lowers bits of number (in-place)\n  BN.prototype.imaskn = function imaskn (bits) {\n    assert(typeof bits === 'number' && bits >= 0);\n    var r = bits % 26;\n    var s = (bits - r) / 26;\n\n    assert(this.negative === 0, 'imaskn works only with positive numbers');\n\n    if (this.length <= s) {\n      return this;\n    }\n\n    if (r !== 0) {\n      s++;\n    }\n    this.length = Math.min(s, this.length);\n\n    if (r !== 0) {\n      var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);\n      this.words[this.length - 1] &= mask;\n    }\n\n    return this.strip();\n  };\n\n  // Return only lowers bits of number\n  BN.prototype.maskn = function maskn (bits) {\n    return this.clone().imaskn(bits);\n  };\n\n  // Add plain number `num` to `this`\n  BN.prototype.iaddn = function iaddn (num) {\n    assert(typeof num === 'number');\n    assert(num < 0x4000000);\n    if (num < 0) return this.isubn(-num);\n\n    // Possible sign change\n    if (this.negative !== 0) {\n      if (this.length === 1 && (this.words[0] | 0) < num) {\n        this.words[0] = num - (this.words[0] | 0);\n        this.negative = 0;\n        return this;\n      }\n\n      this.negative = 0;\n      this.isubn(num);\n      this.negative = 1;\n      return this;\n    }\n\n    // Add without checks\n    return this._iaddn(num);\n  };\n\n  BN.prototype._iaddn = function _iaddn (num) {\n    this.words[0] += num;\n\n    // Carry\n    for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {\n      this.words[i] -= 0x4000000;\n      if (i === this.length - 1) {\n        this.words[i + 1] = 1;\n      } else {\n        this.words[i + 1]++;\n      }\n    }\n    this.length = Math.max(this.length, i + 1);\n\n    return this;\n  };\n\n  // Subtract plain number `num` from `this`\n  BN.prototype.isubn = function isubn (num) {\n    assert(typeof num === 'number');\n    assert(num < 0x4000000);\n    if (num < 0) return this.iaddn(-num);\n\n    if (this.negative !== 0) {\n      this.negative = 0;\n      this.iaddn(num);\n      this.negative = 1;\n      return this;\n    }\n\n    this.words[0] -= num;\n\n    if (this.length === 1 && this.words[0] < 0) {\n      this.words[0] = -this.words[0];\n      this.negative = 1;\n    } else {\n      // Carry\n      for (var i = 0; i < this.length && this.words[i] < 0; i++) {\n        this.words[i] += 0x4000000;\n        this.words[i + 1] -= 1;\n      }\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.addn = function addn (num) {\n    return this.clone().iaddn(num);\n  };\n\n  BN.prototype.subn = function subn (num) {\n    return this.clone().isubn(num);\n  };\n\n  BN.prototype.iabs = function iabs () {\n    this.negative = 0;\n\n    return this;\n  };\n\n  BN.prototype.abs = function abs () {\n    return this.clone().iabs();\n  };\n\n  BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {\n    var len = num.length + shift;\n    var i;\n\n    this._expand(len);\n\n    var w;\n    var carry = 0;\n    for (i = 0; i < num.length; i++) {\n      w = (this.words[i + shift] | 0) + carry;\n      var right = (num.words[i] | 0) * mul;\n      w -= right & 0x3ffffff;\n      carry = (w >> 26) - ((right / 0x4000000) | 0);\n      this.words[i + shift] = w & 0x3ffffff;\n    }\n    for (; i < this.length - shift; i++) {\n      w = (this.words[i + shift] | 0) + carry;\n      carry = w >> 26;\n      this.words[i + shift] = w & 0x3ffffff;\n    }\n\n    if (carry === 0) return this.strip();\n\n    // Subtraction overflow\n    assert(carry === -1);\n    carry = 0;\n    for (i = 0; i < this.length; i++) {\n      w = -(this.words[i] | 0) + carry;\n      carry = w >> 26;\n      this.words[i] = w & 0x3ffffff;\n    }\n    this.negative = 1;\n\n    return this.strip();\n  };\n\n  BN.prototype._wordDiv = function _wordDiv (num, mode) {\n    var shift = this.length - num.length;\n\n    var a = this.clone();\n    var b = num;\n\n    // Normalize\n    var bhi = b.words[b.length - 1] | 0;\n    var bhiBits = this._countBits(bhi);\n    shift = 26 - bhiBits;\n    if (shift !== 0) {\n      b = b.ushln(shift);\n      a.iushln(shift);\n      bhi = b.words[b.length - 1] | 0;\n    }\n\n    // Initialize quotient\n    var m = a.length - b.length;\n    var q;\n\n    if (mode !== 'mod') {\n      q = new BN(null);\n      q.length = m + 1;\n      q.words = new Array(q.length);\n      for (var i = 0; i < q.length; i++) {\n        q.words[i] = 0;\n      }\n    }\n\n    var diff = a.clone()._ishlnsubmul(b, 1, m);\n    if (diff.negative === 0) {\n      a = diff;\n      if (q) {\n        q.words[m] = 1;\n      }\n    }\n\n    for (var j = m - 1; j >= 0; j--) {\n      var qj = (a.words[b.length + j] | 0) * 0x4000000 +\n        (a.words[b.length + j - 1] | 0);\n\n      // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max\n      // (0x7ffffff)\n      qj = Math.min((qj / bhi) | 0, 0x3ffffff);\n\n      a._ishlnsubmul(b, qj, j);\n      while (a.negative !== 0) {\n        qj--;\n        a.negative = 0;\n        a._ishlnsubmul(b, 1, j);\n        if (!a.isZero()) {\n          a.negative ^= 1;\n        }\n      }\n      if (q) {\n        q.words[j] = qj;\n      }\n    }\n    if (q) {\n      q.strip();\n    }\n    a.strip();\n\n    // Denormalize\n    if (mode !== 'div' && shift !== 0) {\n      a.iushrn(shift);\n    }\n\n    return {\n      div: q || null,\n      mod: a\n    };\n  };\n\n  // NOTE: 1) `mode` can be set to `mod` to request mod only,\n  //       to `div` to request div only, or be absent to\n  //       request both div & mod\n  //       2) `positive` is true if unsigned mod is requested\n  BN.prototype.divmod = function divmod (num, mode, positive) {\n    assert(!num.isZero());\n\n    if (this.isZero()) {\n      return {\n        div: new BN(0),\n        mod: new BN(0)\n      };\n    }\n\n    var div, mod, res;\n    if (this.negative !== 0 && num.negative === 0) {\n      res = this.neg().divmod(num, mode);\n\n      if (mode !== 'mod') {\n        div = res.div.neg();\n      }\n\n      if (mode !== 'div') {\n        mod = res.mod.neg();\n        if (positive && mod.negative !== 0) {\n          mod.iadd(num);\n        }\n      }\n\n      return {\n        div: div,\n        mod: mod\n      };\n    }\n\n    if (this.negative === 0 && num.negative !== 0) {\n      res = this.divmod(num.neg(), mode);\n\n      if (mode !== 'mod') {\n        div = res.div.neg();\n      }\n\n      return {\n        div: div,\n        mod: res.mod\n      };\n    }\n\n    if ((this.negative & num.negative) !== 0) {\n      res = this.neg().divmod(num.neg(), mode);\n\n      if (mode !== 'div') {\n        mod = res.mod.neg();\n        if (positive && mod.negative !== 0) {\n          mod.isub(num);\n        }\n      }\n\n      return {\n        div: res.div,\n        mod: mod\n      };\n    }\n\n    // Both numbers are positive at this point\n\n    // Strip both numbers to approximate shift value\n    if (num.length > this.length || this.cmp(num) < 0) {\n      return {\n        div: new BN(0),\n        mod: this\n      };\n    }\n\n    // Very short reduction\n    if (num.length === 1) {\n      if (mode === 'div') {\n        return {\n          div: this.divn(num.words[0]),\n          mod: null\n        };\n      }\n\n      if (mode === 'mod') {\n        return {\n          div: null,\n          mod: new BN(this.modn(num.words[0]))\n        };\n      }\n\n      return {\n        div: this.divn(num.words[0]),\n        mod: new BN(this.modn(num.words[0]))\n      };\n    }\n\n    return this._wordDiv(num, mode);\n  };\n\n  // Find `this` / `num`\n  BN.prototype.div = function div (num) {\n    return this.divmod(num, 'div', false).div;\n  };\n\n  // Find `this` % `num`\n  BN.prototype.mod = function mod (num) {\n    return this.divmod(num, 'mod', false).mod;\n  };\n\n  BN.prototype.umod = function umod (num) {\n    return this.divmod(num, 'mod', true).mod;\n  };\n\n  // Find Round(`this` / `num`)\n  BN.prototype.divRound = function divRound (num) {\n    var dm = this.divmod(num);\n\n    // Fast case - exact division\n    if (dm.mod.isZero()) return dm.div;\n\n    var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;\n\n    var half = num.ushrn(1);\n    var r2 = num.andln(1);\n    var cmp = mod.cmp(half);\n\n    // Round down\n    if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;\n\n    // Round up\n    return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);\n  };\n\n  BN.prototype.modn = function modn (num) {\n    assert(num <= 0x3ffffff);\n    var p = (1 << 26) % num;\n\n    var acc = 0;\n    for (var i = this.length - 1; i >= 0; i--) {\n      acc = (p * acc + (this.words[i] | 0)) % num;\n    }\n\n    return acc;\n  };\n\n  // In-place division by number\n  BN.prototype.idivn = function idivn (num) {\n    assert(num <= 0x3ffffff);\n\n    var carry = 0;\n    for (var i = this.length - 1; i >= 0; i--) {\n      var w = (this.words[i] | 0) + carry * 0x4000000;\n      this.words[i] = (w / num) | 0;\n      carry = w % num;\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.divn = function divn (num) {\n    return this.clone().idivn(num);\n  };\n\n  BN.prototype.egcd = function egcd (p) {\n    assert(p.negative === 0);\n    assert(!p.isZero());\n\n    var x = this;\n    var y = p.clone();\n\n    if (x.negative !== 0) {\n      x = x.umod(p);\n    } else {\n      x = x.clone();\n    }\n\n    // A * x + B * y = x\n    var A = new BN(1);\n    var B = new BN(0);\n\n    // C * x + D * y = y\n    var C = new BN(0);\n    var D = new BN(1);\n\n    var g = 0;\n\n    while (x.isEven() && y.isEven()) {\n      x.iushrn(1);\n      y.iushrn(1);\n      ++g;\n    }\n\n    var yp = y.clone();\n    var xp = x.clone();\n\n    while (!x.isZero()) {\n      for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n      if (i > 0) {\n        x.iushrn(i);\n        while (i-- > 0) {\n          if (A.isOdd() || B.isOdd()) {\n            A.iadd(yp);\n            B.isub(xp);\n          }\n\n          A.iushrn(1);\n          B.iushrn(1);\n        }\n      }\n\n      for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n      if (j > 0) {\n        y.iushrn(j);\n        while (j-- > 0) {\n          if (C.isOdd() || D.isOdd()) {\n            C.iadd(yp);\n            D.isub(xp);\n          }\n\n          C.iushrn(1);\n          D.iushrn(1);\n        }\n      }\n\n      if (x.cmp(y) >= 0) {\n        x.isub(y);\n        A.isub(C);\n        B.isub(D);\n      } else {\n        y.isub(x);\n        C.isub(A);\n        D.isub(B);\n      }\n    }\n\n    return {\n      a: C,\n      b: D,\n      gcd: y.iushln(g)\n    };\n  };\n\n  // This is reduced incarnation of the binary EEA\n  // above, designated to invert members of the\n  // _prime_ fields F(p) at a maximal speed\n  BN.prototype._invmp = function _invmp (p) {\n    assert(p.negative === 0);\n    assert(!p.isZero());\n\n    var a = this;\n    var b = p.clone();\n\n    if (a.negative !== 0) {\n      a = a.umod(p);\n    } else {\n      a = a.clone();\n    }\n\n    var x1 = new BN(1);\n    var x2 = new BN(0);\n\n    var delta = b.clone();\n\n    while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {\n      for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n      if (i > 0) {\n        a.iushrn(i);\n        while (i-- > 0) {\n          if (x1.isOdd()) {\n            x1.iadd(delta);\n          }\n\n          x1.iushrn(1);\n        }\n      }\n\n      for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n      if (j > 0) {\n        b.iushrn(j);\n        while (j-- > 0) {\n          if (x2.isOdd()) {\n            x2.iadd(delta);\n          }\n\n          x2.iushrn(1);\n        }\n      }\n\n      if (a.cmp(b) >= 0) {\n        a.isub(b);\n        x1.isub(x2);\n      } else {\n        b.isub(a);\n        x2.isub(x1);\n      }\n    }\n\n    var res;\n    if (a.cmpn(1) === 0) {\n      res = x1;\n    } else {\n      res = x2;\n    }\n\n    if (res.cmpn(0) < 0) {\n      res.iadd(p);\n    }\n\n    return res;\n  };\n\n  BN.prototype.gcd = function gcd (num) {\n    if (this.isZero()) return num.abs();\n    if (num.isZero()) return this.abs();\n\n    var a = this.clone();\n    var b = num.clone();\n    a.negative = 0;\n    b.negative = 0;\n\n    // Remove common factor of two\n    for (var shift = 0; a.isEven() && b.isEven(); shift++) {\n      a.iushrn(1);\n      b.iushrn(1);\n    }\n\n    do {\n      while (a.isEven()) {\n        a.iushrn(1);\n      }\n      while (b.isEven()) {\n        b.iushrn(1);\n      }\n\n      var r = a.cmp(b);\n      if (r < 0) {\n        // Swap `a` and `b` to make `a` always bigger than `b`\n        var t = a;\n        a = b;\n        b = t;\n      } else if (r === 0 || b.cmpn(1) === 0) {\n        break;\n      }\n\n      a.isub(b);\n    } while (true);\n\n    return b.iushln(shift);\n  };\n\n  // Invert number in the field F(num)\n  BN.prototype.invm = function invm (num) {\n    return this.egcd(num).a.umod(num);\n  };\n\n  BN.prototype.isEven = function isEven () {\n    return (this.words[0] & 1) === 0;\n  };\n\n  BN.prototype.isOdd = function isOdd () {\n    return (this.words[0] & 1) === 1;\n  };\n\n  // And first word and num\n  BN.prototype.andln = function andln (num) {\n    return this.words[0] & num;\n  };\n\n  // Increment at the bit position in-line\n  BN.prototype.bincn = function bincn (bit) {\n    assert(typeof bit === 'number');\n    var r = bit % 26;\n    var s = (bit - r) / 26;\n    var q = 1 << r;\n\n    // Fast case: bit is much higher than all existing words\n    if (this.length <= s) {\n      this._expand(s + 1);\n      this.words[s] |= q;\n      return this;\n    }\n\n    // Add bit and propagate, if needed\n    var carry = q;\n    for (var i = s; carry !== 0 && i < this.length; i++) {\n      var w = this.words[i] | 0;\n      w += carry;\n      carry = w >>> 26;\n      w &= 0x3ffffff;\n      this.words[i] = w;\n    }\n    if (carry !== 0) {\n      this.words[i] = carry;\n      this.length++;\n    }\n    return this;\n  };\n\n  BN.prototype.isZero = function isZero () {\n    return this.length === 1 && this.words[0] === 0;\n  };\n\n  BN.prototype.cmpn = function cmpn (num) {\n    var negative = num < 0;\n\n    if (this.negative !== 0 && !negative) return -1;\n    if (this.negative === 0 && negative) return 1;\n\n    this.strip();\n\n    var res;\n    if (this.length > 1) {\n      res = 1;\n    } else {\n      if (negative) {\n        num = -num;\n      }\n\n      assert(num <= 0x3ffffff, 'Number is too big');\n\n      var w = this.words[0] | 0;\n      res = w === num ? 0 : w < num ? -1 : 1;\n    }\n    if (this.negative !== 0) return -res | 0;\n    return res;\n  };\n\n  // Compare two numbers and return:\n  // 1 - if `this` > `num`\n  // 0 - if `this` == `num`\n  // -1 - if `this` < `num`\n  BN.prototype.cmp = function cmp (num) {\n    if (this.negative !== 0 && num.negative === 0) return -1;\n    if (this.negative === 0 && num.negative !== 0) return 1;\n\n    var res = this.ucmp(num);\n    if (this.negative !== 0) return -res | 0;\n    return res;\n  };\n\n  // Unsigned comparison\n  BN.prototype.ucmp = function ucmp (num) {\n    // At this point both numbers have the same sign\n    if (this.length > num.length) return 1;\n    if (this.length < num.length) return -1;\n\n    var res = 0;\n    for (var i = this.length - 1; i >= 0; i--) {\n      var a = this.words[i] | 0;\n      var b = num.words[i] | 0;\n\n      if (a === b) continue;\n      if (a < b) {\n        res = -1;\n      } else if (a > b) {\n        res = 1;\n      }\n      break;\n    }\n    return res;\n  };\n\n  BN.prototype.gtn = function gtn (num) {\n    return this.cmpn(num) === 1;\n  };\n\n  BN.prototype.gt = function gt (num) {\n    return this.cmp(num) === 1;\n  };\n\n  BN.prototype.gten = function gten (num) {\n    return this.cmpn(num) >= 0;\n  };\n\n  BN.prototype.gte = function gte (num) {\n    return this.cmp(num) >= 0;\n  };\n\n  BN.prototype.ltn = function ltn (num) {\n    return this.cmpn(num) === -1;\n  };\n\n  BN.prototype.lt = function lt (num) {\n    return this.cmp(num) === -1;\n  };\n\n  BN.prototype.lten = function lten (num) {\n    return this.cmpn(num) <= 0;\n  };\n\n  BN.prototype.lte = function lte (num) {\n    return this.cmp(num) <= 0;\n  };\n\n  BN.prototype.eqn = function eqn (num) {\n    return this.cmpn(num) === 0;\n  };\n\n  BN.prototype.eq = function eq (num) {\n    return this.cmp(num) === 0;\n  };\n\n  //\n  // A reduce context, could be using montgomery or something better, depending\n  // on the `m` itself.\n  //\n  BN.red = function red (num) {\n    return new Red(num);\n  };\n\n  BN.prototype.toRed = function toRed (ctx) {\n    assert(!this.red, 'Already a number in reduction context');\n    assert(this.negative === 0, 'red works only with positives');\n    return ctx.convertTo(this)._forceRed(ctx);\n  };\n\n  BN.prototype.fromRed = function fromRed () {\n    assert(this.red, 'fromRed works only with numbers in reduction context');\n    return this.red.convertFrom(this);\n  };\n\n  BN.prototype._forceRed = function _forceRed (ctx) {\n    this.red = ctx;\n    return this;\n  };\n\n  BN.prototype.forceRed = function forceRed (ctx) {\n    assert(!this.red, 'Already a number in reduction context');\n    return this._forceRed(ctx);\n  };\n\n  BN.prototype.redAdd = function redAdd (num) {\n    assert(this.red, 'redAdd works only with red numbers');\n    return this.red.add(this, num);\n  };\n\n  BN.prototype.redIAdd = function redIAdd (num) {\n    assert(this.red, 'redIAdd works only with red numbers');\n    return this.red.iadd(this, num);\n  };\n\n  BN.prototype.redSub = function redSub (num) {\n    assert(this.red, 'redSub works only with red numbers');\n    return this.red.sub(this, num);\n  };\n\n  BN.prototype.redISub = function redISub (num) {\n    assert(this.red, 'redISub works only with red numbers');\n    return this.red.isub(this, num);\n  };\n\n  BN.prototype.redShl = function redShl (num) {\n    assert(this.red, 'redShl works only with red numbers');\n    return this.red.shl(this, num);\n  };\n\n  BN.prototype.redMul = function redMul (num) {\n    assert(this.red, 'redMul works only with red numbers');\n    this.red._verify2(this, num);\n    return this.red.mul(this, num);\n  };\n\n  BN.prototype.redIMul = function redIMul (num) {\n    assert(this.red, 'redMul works only with red numbers');\n    this.red._verify2(this, num);\n    return this.red.imul(this, num);\n  };\n\n  BN.prototype.redSqr = function redSqr () {\n    assert(this.red, 'redSqr works only with red numbers');\n    this.red._verify1(this);\n    return this.red.sqr(this);\n  };\n\n  BN.prototype.redISqr = function redISqr () {\n    assert(this.red, 'redISqr works only with red numbers');\n    this.red._verify1(this);\n    return this.red.isqr(this);\n  };\n\n  // Square root over p\n  BN.prototype.redSqrt = function redSqrt () {\n    assert(this.red, 'redSqrt works only with red numbers');\n    this.red._verify1(this);\n    return this.red.sqrt(this);\n  };\n\n  BN.prototype.redInvm = function redInvm () {\n    assert(this.red, 'redInvm works only with red numbers');\n    this.red._verify1(this);\n    return this.red.invm(this);\n  };\n\n  // Return negative clone of `this` % `red modulo`\n  BN.prototype.redNeg = function redNeg () {\n    assert(this.red, 'redNeg works only with red numbers');\n    this.red._verify1(this);\n    return this.red.neg(this);\n  };\n\n  BN.prototype.redPow = function redPow (num) {\n    assert(this.red && !num.red, 'redPow(normalNum)');\n    this.red._verify1(this);\n    return this.red.pow(this, num);\n  };\n\n  // Prime numbers with efficient reduction\n  var primes = {\n    k256: null,\n    p224: null,\n    p192: null,\n    p25519: null\n  };\n\n  // Pseudo-Mersenne prime\n  function MPrime (name, p) {\n    // P = 2 ^ N - K\n    this.name = name;\n    this.p = new BN(p, 16);\n    this.n = this.p.bitLength();\n    this.k = new BN(1).iushln(this.n).isub(this.p);\n\n    this.tmp = this._tmp();\n  }\n\n  MPrime.prototype._tmp = function _tmp () {\n    var tmp = new BN(null);\n    tmp.words = new Array(Math.ceil(this.n / 13));\n    return tmp;\n  };\n\n  MPrime.prototype.ireduce = function ireduce (num) {\n    // Assumes that `num` is less than `P^2`\n    // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)\n    var r = num;\n    var rlen;\n\n    do {\n      this.split(r, this.tmp);\n      r = this.imulK(r);\n      r = r.iadd(this.tmp);\n      rlen = r.bitLength();\n    } while (rlen > this.n);\n\n    var cmp = rlen < this.n ? -1 : r.ucmp(this.p);\n    if (cmp === 0) {\n      r.words[0] = 0;\n      r.length = 1;\n    } else if (cmp > 0) {\n      r.isub(this.p);\n    } else {\n      r.strip();\n    }\n\n    return r;\n  };\n\n  MPrime.prototype.split = function split (input, out) {\n    input.iushrn(this.n, 0, out);\n  };\n\n  MPrime.prototype.imulK = function imulK (num) {\n    return num.imul(this.k);\n  };\n\n  function K256 () {\n    MPrime.call(\n      this,\n      'k256',\n      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');\n  }\n  inherits(K256, MPrime);\n\n  K256.prototype.split = function split (input, output) {\n    // 256 = 9 * 26 + 22\n    var mask = 0x3fffff;\n\n    var outLen = Math.min(input.length, 9);\n    for (var i = 0; i < outLen; i++) {\n      output.words[i] = input.words[i];\n    }\n    output.length = outLen;\n\n    if (input.length <= 9) {\n      input.words[0] = 0;\n      input.length = 1;\n      return;\n    }\n\n    // Shift by 9 limbs\n    var prev = input.words[9];\n    output.words[output.length++] = prev & mask;\n\n    for (i = 10; i < input.length; i++) {\n      var next = input.words[i] | 0;\n      input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);\n      prev = next;\n    }\n    prev >>>= 22;\n    input.words[i - 10] = prev;\n    if (prev === 0 && input.length > 10) {\n      input.length -= 10;\n    } else {\n      input.length -= 9;\n    }\n  };\n\n  K256.prototype.imulK = function imulK (num) {\n    // K = 0x1000003d1 = [ 0x40, 0x3d1 ]\n    num.words[num.length] = 0;\n    num.words[num.length + 1] = 0;\n    num.length += 2;\n\n    // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390\n    var lo = 0;\n    for (var i = 0; i < num.length; i++) {\n      var w = num.words[i] | 0;\n      lo += w * 0x3d1;\n      num.words[i] = lo & 0x3ffffff;\n      lo = w * 0x40 + ((lo / 0x4000000) | 0);\n    }\n\n    // Fast length reduction\n    if (num.words[num.length - 1] === 0) {\n      num.length--;\n      if (num.words[num.length - 1] === 0) {\n        num.length--;\n      }\n    }\n    return num;\n  };\n\n  function P224 () {\n    MPrime.call(\n      this,\n      'p224',\n      'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');\n  }\n  inherits(P224, MPrime);\n\n  function P192 () {\n    MPrime.call(\n      this,\n      'p192',\n      'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');\n  }\n  inherits(P192, MPrime);\n\n  function P25519 () {\n    // 2 ^ 255 - 19\n    MPrime.call(\n      this,\n      '25519',\n      '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');\n  }\n  inherits(P25519, MPrime);\n\n  P25519.prototype.imulK = function imulK (num) {\n    // K = 0x13\n    var carry = 0;\n    for (var i = 0; i < num.length; i++) {\n      var hi = (num.words[i] | 0) * 0x13 + carry;\n      var lo = hi & 0x3ffffff;\n      hi >>>= 26;\n\n      num.words[i] = lo;\n      carry = hi;\n    }\n    if (carry !== 0) {\n      num.words[num.length++] = carry;\n    }\n    return num;\n  };\n\n  // Exported mostly for testing purposes, use plain name instead\n  BN._prime = function prime (name) {\n    // Cached version of prime\n    if (primes[name]) return primes[name];\n\n    var prime;\n    if (name === 'k256') {\n      prime = new K256();\n    } else if (name === 'p224') {\n      prime = new P224();\n    } else if (name === 'p192') {\n      prime = new P192();\n    } else if (name === 'p25519') {\n      prime = new P25519();\n    } else {\n      throw new Error('Unknown prime ' + name);\n    }\n    primes[name] = prime;\n\n    return prime;\n  };\n\n  //\n  // Base reduction engine\n  //\n  function Red (m) {\n    if (typeof m === 'string') {\n      var prime = BN._prime(m);\n      this.m = prime.p;\n      this.prime = prime;\n    } else {\n      assert(m.gtn(1), 'modulus must be greater than 1');\n      this.m = m;\n      this.prime = null;\n    }\n  }\n\n  Red.prototype._verify1 = function _verify1 (a) {\n    assert(a.negative === 0, 'red works only with positives');\n    assert(a.red, 'red works only with red numbers');\n  };\n\n  Red.prototype._verify2 = function _verify2 (a, b) {\n    assert((a.negative | b.negative) === 0, 'red works only with positives');\n    assert(a.red && a.red === b.red,\n      'red works only with red numbers');\n  };\n\n  Red.prototype.imod = function imod (a) {\n    if (this.prime) return this.prime.ireduce(a)._forceRed(this);\n    return a.umod(this.m)._forceRed(this);\n  };\n\n  Red.prototype.neg = function neg (a) {\n    if (a.isZero()) {\n      return a.clone();\n    }\n\n    return this.m.sub(a)._forceRed(this);\n  };\n\n  Red.prototype.add = function add (a, b) {\n    this._verify2(a, b);\n\n    var res = a.add(b);\n    if (res.cmp(this.m) >= 0) {\n      res.isub(this.m);\n    }\n    return res._forceRed(this);\n  };\n\n  Red.prototype.iadd = function iadd (a, b) {\n    this._verify2(a, b);\n\n    var res = a.iadd(b);\n    if (res.cmp(this.m) >= 0) {\n      res.isub(this.m);\n    }\n    return res;\n  };\n\n  Red.prototype.sub = function sub (a, b) {\n    this._verify2(a, b);\n\n    var res = a.sub(b);\n    if (res.cmpn(0) < 0) {\n      res.iadd(this.m);\n    }\n    return res._forceRed(this);\n  };\n\n  Red.prototype.isub = function isub (a, b) {\n    this._verify2(a, b);\n\n    var res = a.isub(b);\n    if (res.cmpn(0) < 0) {\n      res.iadd(this.m);\n    }\n    return res;\n  };\n\n  Red.prototype.shl = function shl (a, num) {\n    this._verify1(a);\n    return this.imod(a.ushln(num));\n  };\n\n  Red.prototype.imul = function imul (a, b) {\n    this._verify2(a, b);\n    return this.imod(a.imul(b));\n  };\n\n  Red.prototype.mul = function mul (a, b) {\n    this._verify2(a, b);\n    return this.imod(a.mul(b));\n  };\n\n  Red.prototype.isqr = function isqr (a) {\n    return this.imul(a, a.clone());\n  };\n\n  Red.prototype.sqr = function sqr (a) {\n    return this.mul(a, a);\n  };\n\n  Red.prototype.sqrt = function sqrt (a) {\n    if (a.isZero()) return a.clone();\n\n    var mod3 = this.m.andln(3);\n    assert(mod3 % 2 === 1);\n\n    // Fast case\n    if (mod3 === 3) {\n      var pow = this.m.add(new BN(1)).iushrn(2);\n      return this.pow(a, pow);\n    }\n\n    // Tonelli-Shanks algorithm (Totally unoptimized and slow)\n    //\n    // Find Q and S, that Q * 2 ^ S = (P - 1)\n    var q = this.m.subn(1);\n    var s = 0;\n    while (!q.isZero() && q.andln(1) === 0) {\n      s++;\n      q.iushrn(1);\n    }\n    assert(!q.isZero());\n\n    var one = new BN(1).toRed(this);\n    var nOne = one.redNeg();\n\n    // Find quadratic non-residue\n    // NOTE: Max is such because of generalized Riemann hypothesis.\n    var lpow = this.m.subn(1).iushrn(1);\n    var z = this.m.bitLength();\n    z = new BN(2 * z * z).toRed(this);\n\n    while (this.pow(z, lpow).cmp(nOne) !== 0) {\n      z.redIAdd(nOne);\n    }\n\n    var c = this.pow(z, q);\n    var r = this.pow(a, q.addn(1).iushrn(1));\n    var t = this.pow(a, q);\n    var m = s;\n    while (t.cmp(one) !== 0) {\n      var tmp = t;\n      for (var i = 0; tmp.cmp(one) !== 0; i++) {\n        tmp = tmp.redSqr();\n      }\n      assert(i < m);\n      var b = this.pow(c, new BN(1).iushln(m - i - 1));\n\n      r = r.redMul(b);\n      c = b.redSqr();\n      t = t.redMul(c);\n      m = i;\n    }\n\n    return r;\n  };\n\n  Red.prototype.invm = function invm (a) {\n    var inv = a._invmp(this.m);\n    if (inv.negative !== 0) {\n      inv.negative = 0;\n      return this.imod(inv).redNeg();\n    } else {\n      return this.imod(inv);\n    }\n  };\n\n  Red.prototype.pow = function pow (a, num) {\n    if (num.isZero()) return new BN(1);\n    if (num.cmpn(1) === 0) return a.clone();\n\n    var windowSize = 4;\n    var wnd = new Array(1 << windowSize);\n    wnd[0] = new BN(1).toRed(this);\n    wnd[1] = a;\n    for (var i = 2; i < wnd.length; i++) {\n      wnd[i] = this.mul(wnd[i - 1], a);\n    }\n\n    var res = wnd[0];\n    var current = 0;\n    var currentLen = 0;\n    var start = num.bitLength() % 26;\n    if (start === 0) {\n      start = 26;\n    }\n\n    for (i = num.length - 1; i >= 0; i--) {\n      var word = num.words[i];\n      for (var j = start - 1; j >= 0; j--) {\n        var bit = (word >> j) & 1;\n        if (res !== wnd[0]) {\n          res = this.sqr(res);\n        }\n\n        if (bit === 0 && current === 0) {\n          currentLen = 0;\n          continue;\n        }\n\n        current <<= 1;\n        current |= bit;\n        currentLen++;\n        if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;\n\n        res = this.mul(res, wnd[current]);\n        currentLen = 0;\n        current = 0;\n      }\n      start = 26;\n    }\n\n    return res;\n  };\n\n  Red.prototype.convertTo = function convertTo (num) {\n    var r = num.umod(this.m);\n\n    return r === num ? r.clone() : r;\n  };\n\n  Red.prototype.convertFrom = function convertFrom (num) {\n    var res = num.clone();\n    res.red = null;\n    return res;\n  };\n\n  //\n  // Montgomery method engine\n  //\n\n  BN.mont = function mont (num) {\n    return new Mont(num);\n  };\n\n  function Mont (m) {\n    Red.call(this, m);\n\n    this.shift = this.m.bitLength();\n    if (this.shift % 26 !== 0) {\n      this.shift += 26 - (this.shift % 26);\n    }\n\n    this.r = new BN(1).iushln(this.shift);\n    this.r2 = this.imod(this.r.sqr());\n    this.rinv = this.r._invmp(this.m);\n\n    this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);\n    this.minv = this.minv.umod(this.r);\n    this.minv = this.r.sub(this.minv);\n  }\n  inherits(Mont, Red);\n\n  Mont.prototype.convertTo = function convertTo (num) {\n    return this.imod(num.ushln(this.shift));\n  };\n\n  Mont.prototype.convertFrom = function convertFrom (num) {\n    var r = this.imod(num.mul(this.rinv));\n    r.red = null;\n    return r;\n  };\n\n  Mont.prototype.imul = function imul (a, b) {\n    if (a.isZero() || b.isZero()) {\n      a.words[0] = 0;\n      a.length = 1;\n      return a;\n    }\n\n    var t = a.imul(b);\n    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n    var u = t.isub(c).iushrn(this.shift);\n    var res = u;\n\n    if (u.cmp(this.m) >= 0) {\n      res = u.isub(this.m);\n    } else if (u.cmpn(0) < 0) {\n      res = u.iadd(this.m);\n    }\n\n    return res._forceRed(this);\n  };\n\n  Mont.prototype.mul = function mul (a, b) {\n    if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);\n\n    var t = a.mul(b);\n    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n    var u = t.isub(c).iushrn(this.shift);\n    var res = u;\n    if (u.cmp(this.m) >= 0) {\n      res = u.isub(this.m);\n    } else if (u.cmpn(0) < 0) {\n      res = u.iadd(this.m);\n    }\n\n    return res._forceRed(this);\n  };\n\n  Mont.prototype.invm = function invm (a) {\n    // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R\n    var res = this.imod(a._invmp(this.m).mul(this.r2));\n    return res._forceRed(this);\n  };\n})(typeof module === 'undefined' || module, this);\n\n},{}],5:[function(require,module,exports){\n\n},{}],6:[function(require,module,exports){\n/*!\n * The buffer module from node.js, for the browser.\n *\n * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>\n * @license  MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nvar K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n *   === true    Use Uint8Array implementation (fastest)\n *   === false   Print warning and recommend using `buffer` v4.x which has an Object\n *               implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT) {\n  console.error(\n    'This browser lacks typed array (Uint8Array) support which is required by ' +\n    '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.')\n}\n\nfunction typedArraySupport () {\n  // Can typed array instances can be augmented?\n  try {\n    var arr = new Uint8Array(1)\n    arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n    return arr.foo() === 42\n  } catch (e) {\n    return false\n  }\n}\n\nfunction createBuffer (length) {\n  if (length > K_MAX_LENGTH) {\n    throw new RangeError('Invalid typed array length')\n  }\n  // Return an augmented `Uint8Array` instance\n  var buf = new Uint8Array(length)\n  buf.__proto__ = Buffer.prototype\n  return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n  // Common case.\n  if (typeof arg === 'number') {\n    if (typeof encodingOrOffset === 'string') {\n      throw new Error(\n        'If encoding is specified then the first argument must be a string'\n      )\n    }\n    return allocUnsafe(arg)\n  }\n  return from(arg, encodingOrOffset, length)\n}\n\n// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\nif (typeof Symbol !== 'undefined' && Symbol.species &&\n    Buffer[Symbol.species] === Buffer) {\n  Object.defineProperty(Buffer, Symbol.species, {\n    value: null,\n    configurable: true,\n    enumerable: false,\n    writable: false\n  })\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n  if (typeof value === 'number') {\n    throw new TypeError('\"value\" argument must not be a number')\n  }\n\n  if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n    return fromArrayBuffer(value, encodingOrOffset, length)\n  }\n\n  if (typeof value === 'string') {\n    return fromString(value, encodingOrOffset)\n  }\n\n  return fromObject(value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n  return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nBuffer.prototype.__proto__ = Uint8Array.prototype\nBuffer.__proto__ = Uint8Array\n\nfunction assertSize (size) {\n  if (typeof size !== 'number') {\n    throw new TypeError('\"size\" argument must be a number')\n  } else if (size < 0) {\n    throw new RangeError('\"size\" argument must not be negative')\n  }\n}\n\nfunction alloc (size, fill, encoding) {\n  assertSize(size)\n  if (size <= 0) {\n    return createBuffer(size)\n  }\n  if (fill !== undefined) {\n    // Only pay attention to encoding if it's a string. This\n    // prevents accidentally sending in a number that would\n    // be interpretted as a start offset.\n    return typeof encoding === 'string'\n      ? createBuffer(size).fill(fill, encoding)\n      : createBuffer(size).fill(fill)\n  }\n  return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n  return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n  assertSize(size)\n  return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n  return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n  return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n  if (typeof encoding !== 'string' || encoding === '') {\n    encoding = 'utf8'\n  }\n\n  if (!Buffer.isEncoding(encoding)) {\n    throw new TypeError('\"encoding\" must be a valid string encoding')\n  }\n\n  var length = byteLength(string, encoding) | 0\n  var buf = createBuffer(length)\n\n  var actual = buf.write(string, encoding)\n\n  if (actual !== length) {\n    // Writing a hex string, for example, that contains invalid characters will\n    // cause everything after the first invalid character to be ignored. (e.g.\n    // 'abxxcd' will be treated as 'ab')\n    buf = buf.slice(0, actual)\n  }\n\n  return buf\n}\n\nfunction fromArrayLike (array) {\n  var length = array.length < 0 ? 0 : checked(array.length) | 0\n  var buf = createBuffer(length)\n  for (var i = 0; i < length; i += 1) {\n    buf[i] = array[i] & 255\n  }\n  return buf\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n  array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n  if (byteOffset < 0 || array.byteLength < byteOffset) {\n    throw new RangeError('\\'offset\\' is out of bounds')\n  }\n\n  if (array.byteLength < byteOffset + (length || 0)) {\n    throw new RangeError('\\'length\\' is out of bounds')\n  }\n\n  var buf\n  if (byteOffset === undefined && length === undefined) {\n    buf = new Uint8Array(array)\n  } else if (length === undefined) {\n    buf = new Uint8Array(array, byteOffset)\n  } else {\n    buf = new Uint8Array(array, byteOffset, length)\n  }\n\n  // Return an augmented `Uint8Array` instance\n  buf.__proto__ = Buffer.prototype\n  return buf\n}\n\nfunction fromObject (obj) {\n  if (Buffer.isBuffer(obj)) {\n    var len = checked(obj.length) | 0\n    var buf = createBuffer(len)\n\n    if (buf.length === 0) {\n      return buf\n    }\n\n    obj.copy(buf, 0, 0, len)\n    return buf\n  }\n\n  if (obj) {\n    if ((typeof ArrayBuffer !== 'undefined' &&\n        obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n      if (typeof obj.length !== 'number' || isnan(obj.length)) {\n        return createBuffer(0)\n      }\n      return fromArrayLike(obj)\n    }\n\n    if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n      return fromArrayLike(obj.data)\n    }\n  }\n\n  throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n  // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n  // length is NaN (which is otherwise coerced to zero.)\n  if (length >= K_MAX_LENGTH) {\n    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n                         'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n  }\n  return length | 0\n}\n\nfunction SlowBuffer (length) {\n  if (+length != length) { // eslint-disable-line eqeqeq\n    length = 0\n  }\n  return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n  return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n    throw new TypeError('Arguments must be Buffers')\n  }\n\n  if (a === b) return 0\n\n  var x = a.length\n  var y = b.length\n\n  for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n    if (a[i] !== b[i]) {\n      x = a[i]\n      y = b[i]\n      break\n    }\n  }\n\n  if (x < y) return -1\n  if (y < x) return 1\n  return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n  switch (String(encoding).toLowerCase()) {\n    case 'hex':\n    case 'utf8':\n    case 'utf-8':\n    case 'ascii':\n    case 'latin1':\n    case 'binary':\n    case 'base64':\n    case 'ucs2':\n    case 'ucs-2':\n    case 'utf16le':\n    case 'utf-16le':\n      return true\n    default:\n      return false\n  }\n}\n\nBuffer.concat = function concat (list, length) {\n  if (!Array.isArray(list)) {\n    throw new TypeError('\"list\" argument must be an Array of Buffers')\n  }\n\n  if (list.length === 0) {\n    return Buffer.alloc(0)\n  }\n\n  var i\n  if (length === undefined) {\n    length = 0\n    for (i = 0; i < list.length; ++i) {\n      length += list[i].length\n    }\n  }\n\n  var buffer = Buffer.allocUnsafe(length)\n  var pos = 0\n  for (i = 0; i < list.length; ++i) {\n    var buf = list[i]\n    if (!Buffer.isBuffer(buf)) {\n      throw new TypeError('\"list\" argument must be an Array of Buffers')\n    }\n    buf.copy(buffer, pos)\n    pos += buf.length\n  }\n  return buffer\n}\n\nfunction byteLength (string, encoding) {\n  if (Buffer.isBuffer(string)) {\n    return string.length\n  }\n  if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n      (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n    return string.byteLength\n  }\n  if (typeof string !== 'string') {\n    string = '' + string\n  }\n\n  var len = string.length\n  if (len === 0) return 0\n\n  // Use a for loop to avoid recursion\n  var loweredCase = false\n  for (;;) {\n    switch (encoding) {\n      case 'ascii':\n      case 'latin1':\n      case 'binary':\n        return len\n      case 'utf8':\n      case 'utf-8':\n      case undefined:\n        return utf8ToBytes(string).length\n      case 'ucs2':\n      case 'ucs-2':\n      case 'utf16le':\n      case 'utf-16le':\n        return len * 2\n      case 'hex':\n        return len >>> 1\n      case 'base64':\n        return base64ToBytes(string).length\n      default:\n        if (loweredCase) return utf8ToBytes(string).length // assume utf8\n        encoding = ('' + encoding).toLowerCase()\n        loweredCase = true\n    }\n  }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n  var loweredCase = false\n\n  // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n  // property of a typed array.\n\n  // This behaves neither like String nor Uint8Array in that we set start/end\n  // to their upper/lower bounds if the value passed is out of range.\n  // undefined is handled specially as per ECMA-262 6th Edition,\n  // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n  if (start === undefined || start < 0) {\n    start = 0\n  }\n  // Return early if start > this.length. Done here to prevent potential uint32\n  // coercion fail below.\n  if (start > this.length) {\n    return ''\n  }\n\n  if (end === undefined || end > this.length) {\n    end = this.length\n  }\n\n  if (end <= 0) {\n    return ''\n  }\n\n  // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n  end >>>= 0\n  start >>>= 0\n\n  if (end <= start) {\n    return ''\n  }\n\n  if (!encoding) encoding = 'utf8'\n\n  while (true) {\n    switch (encoding) {\n      case 'hex':\n        return hexSlice(this, start, end)\n\n      case 'utf8':\n      case 'utf-8':\n        return utf8Slice(this, start, end)\n\n      case 'ascii':\n        return asciiSlice(this, start, end)\n\n      case 'latin1':\n      case 'binary':\n        return latin1Slice(this, start, end)\n\n      case 'base64':\n        return base64Slice(this, start, end)\n\n      case 'ucs2':\n      case 'ucs-2':\n      case 'utf16le':\n      case 'utf-16le':\n        return utf16leSlice(this, start, end)\n\n      default:\n        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n        encoding = (encoding + '').toLowerCase()\n        loweredCase = true\n    }\n  }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n  var i = b[n]\n  b[n] = b[m]\n  b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n  var len = this.length\n  if (len % 2 !== 0) {\n    throw new RangeError('Buffer size must be a multiple of 16-bits')\n  }\n  for (var i = 0; i < len; i += 2) {\n    swap(this, i, i + 1)\n  }\n  return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n  var len = this.length\n  if (len % 4 !== 0) {\n    throw new RangeError('Buffer size must be a multiple of 32-bits')\n  }\n  for (var i = 0; i < len; i += 4) {\n    swap(this, i, i + 3)\n    swap(this, i + 1, i + 2)\n  }\n  return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n  var len = this.length\n  if (len % 8 !== 0) {\n    throw new RangeError('Buffer size must be a multiple of 64-bits')\n  }\n  for (var i = 0; i < len; i += 8) {\n    swap(this, i, i + 7)\n    swap(this, i + 1, i + 6)\n    swap(this, i + 2, i + 5)\n    swap(this, i + 3, i + 4)\n  }\n  return this\n}\n\nBuffer.prototype.toString = function toString () {\n  var length = this.length\n  if (length === 0) return ''\n  if (arguments.length === 0) return utf8Slice(this, 0, length)\n  return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n  if (this === b) return true\n  return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n  var str = ''\n  var max = exports.INSPECT_MAX_BYTES\n  if (this.length > 0) {\n    str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n    if (this.length > max) str += ' ... '\n  }\n  return '<Buffer ' + str + '>'\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n  if (!Buffer.isBuffer(target)) {\n    throw new TypeError('Argument must be a Buffer')\n  }\n\n  if (start === undefined) {\n    start = 0\n  }\n  if (end === undefined) {\n    end = target ? target.length : 0\n  }\n  if (thisStart === undefined) {\n    thisStart = 0\n  }\n  if (thisEnd === undefined) {\n    thisEnd = this.length\n  }\n\n  if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n    throw new RangeError('out of range index')\n  }\n\n  if (thisStart >= thisEnd && start >= end) {\n    return 0\n  }\n  if (thisStart >= thisEnd) {\n    return -1\n  }\n  if (start >= end) {\n    return 1\n  }\n\n  start >>>= 0\n  end >>>= 0\n  thisStart >>>= 0\n  thisEnd >>>= 0\n\n  if (this === target) return 0\n\n  var x = thisEnd - thisStart\n  var y = end - start\n  var len = Math.min(x, y)\n\n  var thisCopy = this.slice(thisStart, thisEnd)\n  var targetCopy = target.slice(start, end)\n\n  for (var i = 0; i < len; ++i) {\n    if (thisCopy[i] !== targetCopy[i]) {\n      x = thisCopy[i]\n      y = targetCopy[i]\n      break\n    }\n  }\n\n  if (x < y) return -1\n  if (y < x) return 1\n  return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n  // Empty buffer means no match\n  if (buffer.length === 0) return -1\n\n  // Normalize byteOffset\n  if (typeof byteOffset === 'string') {\n    encoding = byteOffset\n    byteOffset = 0\n  } else if (byteOffset > 0x7fffffff) {\n    byteOffset = 0x7fffffff\n  } else if (byteOffset < -0x80000000) {\n    byteOffset = -0x80000000\n  }\n  byteOffset = +byteOffset  // Coerce to Number.\n  if (isNaN(byteOffset)) {\n    // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n    byteOffset = dir ? 0 : (buffer.length - 1)\n  }\n\n  // Normalize byteOffset: negative offsets start from the end of the buffer\n  if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n  if (byteOffset >= buffer.length) {\n    if (dir) return -1\n    else byteOffset = buffer.length - 1\n  } else if (byteOffset < 0) {\n    if (dir) byteOffset = 0\n    else return -1\n  }\n\n  // Normalize val\n  if (typeof val === 'string') {\n    val = Buffer.from(val, encoding)\n  }\n\n  // Finally, search either indexOf (if dir is true) or lastIndexOf\n  if (Buffer.isBuffer(val)) {\n    // Special case: looking for empty string/buffer always fails\n    if (val.length === 0) {\n      return -1\n    }\n    return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n  } else if (typeof val === 'number') {\n    val = val & 0xFF // Search for a byte value [0-255]\n    if (typeof Uint8Array.prototype.indexOf === 'function') {\n      if (dir) {\n        return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n      } else {\n        return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n      }\n    }\n    return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n  }\n\n  throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n  var indexSize = 1\n  var arrLength = arr.length\n  var valLength = val.length\n\n  if (encoding !== undefined) {\n    encoding = String(encoding).toLowerCase()\n    if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n        encoding === 'utf16le' || encoding === 'utf-16le') {\n      if (arr.length < 2 || val.length < 2) {\n        return -1\n      }\n      indexSize = 2\n      arrLength /= 2\n      valLength /= 2\n      byteOffset /= 2\n    }\n  }\n\n  function read (buf, i) {\n    if (indexSize === 1) {\n      return buf[i]\n    } else {\n      return buf.readUInt16BE(i * indexSize)\n    }\n  }\n\n  var i\n  if (dir) {\n    var foundIndex = -1\n    for (i = byteOffset; i < arrLength; i++) {\n      if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n        if (foundIndex === -1) foundIndex = i\n        if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n      } else {\n        if (foundIndex !== -1) i -= i - foundIndex\n        foundIndex = -1\n      }\n    }\n  } else {\n    if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n    for (i = byteOffset; i >= 0; i--) {\n      var found = true\n      for (var j = 0; j < valLength; j++) {\n        if (read(arr, i + j) !== read(val, j)) {\n          found = false\n          break\n        }\n      }\n      if (found) return i\n    }\n  }\n\n  return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n  return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n  return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n  return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n  offset = Number(offset) || 0\n  var remaining = buf.length - offset\n  if (!length) {\n    length = remaining\n  } else {\n    length = Number(length)\n    if (length > remaining) {\n      length = remaining\n    }\n  }\n\n  // must be an even number of digits\n  var strLen = string.length\n  if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n  if (length > strLen / 2) {\n    length = strLen / 2\n  }\n  for (var i = 0; i < length; ++i) {\n    var parsed = parseInt(string.substr(i * 2, 2), 16)\n    if (isNaN(parsed)) return i\n    buf[offset + i] = parsed\n  }\n  return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n  return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n  return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n  return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n  return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n  return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n  // Buffer#write(string)\n  if (offset === undefined) {\n    encoding = 'utf8'\n    length = this.length\n    offset = 0\n  // Buffer#write(string, encoding)\n  } else if (length === undefined && typeof offset === 'string') {\n    encoding = offset\n    length = this.length\n    offset = 0\n  // Buffer#write(string, offset[, length][, encoding])\n  } else if (isFinite(offset)) {\n    offset = offset >>> 0\n    if (isFinite(length)) {\n      length = length >>> 0\n      if (encoding === undefined) encoding = 'utf8'\n    } else {\n      encoding = length\n      length = undefined\n    }\n  // legacy write(string, encoding, offset, length) - remove in v0.13\n  } else {\n    throw new Error(\n      'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n    )\n  }\n\n  var remaining = this.length - offset\n  if (length === undefined || length > remaining) length = remaining\n\n  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n    throw new RangeError('Attempt to write outside buffer bounds')\n  }\n\n  if (!encoding) encoding = 'utf8'\n\n  var loweredCase = false\n  for (;;) {\n    switch (encoding) {\n      case 'hex':\n        return hexWrite(this, string, offset, length)\n\n      case 'utf8':\n      case 'utf-8':\n        return utf8Write(this, string, offset, length)\n\n      case 'ascii':\n        return asciiWrite(this, string, offset, length)\n\n      case 'latin1':\n      case 'binary':\n        return latin1Write(this, string, offset, length)\n\n      case 'base64':\n        // Warning: maxLength not taken into account in base64Write\n        return base64Write(this, string, offset, length)\n\n      case 'ucs2':\n      case 'ucs-2':\n      case 'utf16le':\n      case 'utf-16le':\n        return ucs2Write(this, string, offset, length)\n\n      default:\n        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n        encoding = ('' + encoding).toLowerCase()\n        loweredCase = true\n    }\n  }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n  return {\n    type: 'Buffer',\n    data: Array.prototype.slice.call(this._arr || this, 0)\n  }\n}\n\nfunction base64Slice (buf, start, end) {\n  if (start === 0 && end === buf.length) {\n    return base64.fromByteArray(buf)\n  } else {\n    return base64.fromByteArray(buf.slice(start, end))\n  }\n}\n\nfunction utf8Slice (buf, start, end) {\n  end = Math.min(buf.length, end)\n  var res = []\n\n  var i = start\n  while (i < end) {\n    var firstByte = buf[i]\n    var codePoint = null\n    var bytesPerSequence = (firstByte > 0xEF) ? 4\n      : (firstByte > 0xDF) ? 3\n      : (firstByte > 0xBF) ? 2\n      : 1\n\n    if (i + bytesPerSequence <= end) {\n      var secondByte, thirdByte, fourthByte, tempCodePoint\n\n      switch (bytesPerSequence) {\n        case 1:\n          if (firstByte < 0x80) {\n            codePoint = firstByte\n          }\n          break\n        case 2:\n          secondByte = buf[i + 1]\n          if ((secondByte & 0xC0) === 0x80) {\n            tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n            if (tempCodePoint > 0x7F) {\n              codePoint = tempCodePoint\n            }\n          }\n          break\n        case 3:\n          secondByte = buf[i + 1]\n          thirdByte = buf[i + 2]\n          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n            tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n            if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n              codePoint = tempCodePoint\n            }\n          }\n          break\n        case 4:\n          secondByte = buf[i + 1]\n          thirdByte = buf[i + 2]\n          fourthByte = buf[i + 3]\n          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n            tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n            if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n              codePoint = tempCodePoint\n            }\n          }\n      }\n    }\n\n    if (codePoint === null) {\n      // we did not generate a valid codePoint so insert a\n      // replacement char (U+FFFD) and advance only 1 byte\n      codePoint = 0xFFFD\n      bytesPerSequence = 1\n    } else if (codePoint > 0xFFFF) {\n      // encode to utf16 (surrogate pair dance)\n      codePoint -= 0x10000\n      res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n      codePoint = 0xDC00 | codePoint & 0x3FF\n    }\n\n    res.push(codePoint)\n    i += bytesPerSequence\n  }\n\n  return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n  var len = codePoints.length\n  if (len <= MAX_ARGUMENTS_LENGTH) {\n    return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n  }\n\n  // Decode in chunks to avoid \"call stack size exceeded\".\n  var res = ''\n  var i = 0\n  while (i < len) {\n    res += String.fromCharCode.apply(\n      String,\n      codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n    )\n  }\n  return res\n}\n\nfunction asciiSlice (buf, start, end) {\n  var ret = ''\n  end = Math.min(buf.length, end)\n\n  for (var i = start; i < end; ++i) {\n    ret += String.fromCharCode(buf[i] & 0x7F)\n  }\n  return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n  var ret = ''\n  end = Math.min(buf.length, end)\n\n  for (var i = start; i < end; ++i) {\n    ret += String.fromCharCode(buf[i])\n  }\n  return ret\n}\n\nfunction hexSlice (buf, start, end) {\n  var len = buf.length\n\n  if (!start || start < 0) start = 0\n  if (!end || end < 0 || end > len) end = len\n\n  var out = ''\n  for (var i = start; i < end; ++i) {\n    out += toHex(buf[i])\n  }\n  return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n  var bytes = buf.slice(start, end)\n  var res = ''\n  for (var i = 0; i < bytes.length; i += 2) {\n    res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n  }\n  return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n  var len = this.length\n  start = ~~start\n  end = end === undefined ? len : ~~end\n\n  if (start < 0) {\n    start += len\n    if (start < 0) start = 0\n  } else if (start > len) {\n    start = len\n  }\n\n  if (end < 0) {\n    end += len\n    if (end < 0) end = 0\n  } else if (end > len) {\n    end = len\n  }\n\n  if (end < start) end = start\n\n  var newBuf = this.subarray(start, end)\n  // Return an augmented `Uint8Array` instance\n  newBuf.__proto__ = Buffer.prototype\n  return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n  if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n  var val = this[offset]\n  var mul = 1\n  var i = 0\n  while (++i < byteLength && (mul *= 0x100)) {\n    val += this[offset + i] * mul\n  }\n\n  return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) {\n    checkOffset(offset, byteLength, this.length)\n  }\n\n  var val = this[offset + --byteLength]\n  var mul = 1\n  while (byteLength > 0 && (mul *= 0x100)) {\n    val += this[offset + --byteLength] * mul\n  }\n\n  return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 1, this.length)\n  return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return ((this[offset]) |\n      (this[offset + 1] << 8) |\n      (this[offset + 2] << 16)) +\n      (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return (this[offset] * 0x1000000) +\n    ((this[offset + 1] << 16) |\n    (this[offset + 2] << 8) |\n    this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n  var val = this[offset]\n  var mul = 1\n  var i = 0\n  while (++i < byteLength && (mul *= 0x100)) {\n    val += this[offset + i] * mul\n  }\n  mul *= 0x80\n\n  if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n  return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n  var i = byteLength\n  var mul = 1\n  var val = this[offset + --i]\n  while (i > 0 && (mul *= 0x100)) {\n    val += this[offset + --i] * mul\n  }\n  mul *= 0x80\n\n  if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n  return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 1, this.length)\n  if (!(this[offset] & 0x80)) return (this[offset])\n  return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  var val = this[offset] | (this[offset + 1] << 8)\n  return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  var val = this[offset + 1] | (this[offset] << 8)\n  return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return (this[offset]) |\n    (this[offset + 1] << 8) |\n    (this[offset + 2] << 16) |\n    (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return (this[offset] << 24) |\n    (this[offset + 1] << 16) |\n    (this[offset + 2] << 8) |\n    (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n  return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n  return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 8, this.length)\n  return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 8, this.length)\n  return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n  if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n  if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n  if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) {\n    var maxBytes = Math.pow(2, 8 * byteLength) - 1\n    checkInt(this, value, offset, byteLength, maxBytes, 0)\n  }\n\n  var mul = 1\n  var i = 0\n  this[offset] = value & 0xFF\n  while (++i < byteLength && (mul *= 0x100)) {\n    this[offset + i] = (value / mul) & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) {\n    var maxBytes = Math.pow(2, 8 * byteLength) - 1\n    checkInt(this, value, offset, byteLength, maxBytes, 0)\n  }\n\n  var i = byteLength - 1\n  var mul = 1\n  this[offset + i] = value & 0xFF\n  while (--i >= 0 && (mul *= 0x100)) {\n    this[offset + i] = (value / mul) & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n  this[offset] = (value & 0xff)\n  return offset + 1\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n  this[offset] = (value & 0xff)\n  this[offset + 1] = (value >>> 8)\n  return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n  this[offset] = (value >>> 8)\n  this[offset + 1] = (value & 0xff)\n  return offset + 2\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n  this[offset + 3] = (value >>> 24)\n  this[offset + 2] = (value >>> 16)\n  this[offset + 1] = (value >>> 8)\n  this[offset] = (value & 0xff)\n  return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n  this[offset] = (value >>> 24)\n  this[offset + 1] = (value >>> 16)\n  this[offset + 2] = (value >>> 8)\n  this[offset + 3] = (value & 0xff)\n  return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    var limit = Math.pow(2, 8 * byteLength - 1)\n\n    checkInt(this, value, offset, byteLength, limit - 1, -limit)\n  }\n\n  var i = 0\n  var mul = 1\n  var sub = 0\n  this[offset] = value & 0xFF\n  while (++i < byteLength && (mul *= 0x100)) {\n    if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n      sub = 1\n    }\n    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    var limit = Math.pow(2, 8 * byteLength - 1)\n\n    checkInt(this, value, offset, byteLength, limit - 1, -limit)\n  }\n\n  var i = byteLength - 1\n  var mul = 1\n  var sub = 0\n  this[offset + i] = value & 0xFF\n  while (--i >= 0 && (mul *= 0x100)) {\n    if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n      sub = 1\n    }\n    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n  if (value < 0) value = 0xff + value + 1\n  this[offset] = (value & 0xff)\n  return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n  this[offset] = (value & 0xff)\n  this[offset + 1] = (value >>> 8)\n  return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n  this[offset] = (value >>> 8)\n  this[offset + 1] = (value & 0xff)\n  return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n  this[offset] = (value & 0xff)\n  this[offset + 1] = (value >>> 8)\n  this[offset + 2] = (value >>> 16)\n  this[offset + 3] = (value >>> 24)\n  return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n  if (value < 0) value = 0xffffffff + value + 1\n  this[offset] = (value >>> 24)\n  this[offset + 1] = (value >>> 16)\n  this[offset + 2] = (value >>> 8)\n  this[offset + 3] = (value & 0xff)\n  return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n  if (offset + ext > buf.length) throw new RangeError('Index out of range')\n  if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n  }\n  ieee754.write(buf, value, offset, littleEndian, 23, 4)\n  return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n  return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n  return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n  }\n  ieee754.write(buf, value, offset, littleEndian, 52, 8)\n  return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n  return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n  return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n  if (!start) start = 0\n  if (!end && end !== 0) end = this.length\n  if (targetStart >= target.length) targetStart = target.length\n  if (!targetStart) targetStart = 0\n  if (end > 0 && end < start) end = start\n\n  // Copy 0 bytes; we're done\n  if (end === start) return 0\n  if (target.length === 0 || this.length === 0) return 0\n\n  // Fatal error conditions\n  if (targetStart < 0) {\n    throw new RangeError('targetStart out of bounds')\n  }\n  if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n  if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n  // Are we oob?\n  if (end > this.length) end = this.length\n  if (target.length - targetStart < end - start) {\n    end = target.length - targetStart + start\n  }\n\n  var len = end - start\n  var i\n\n  if (this === target && start < targetStart && targetStart < end) {\n    // descending copy from end\n    for (i = len - 1; i >= 0; --i) {\n      target[i + targetStart] = this[i + start]\n    }\n  } else if (len < 1000) {\n    // ascending copy from start\n    for (i = 0; i < len; ++i) {\n      target[i + targetStart] = this[i + start]\n    }\n  } else {\n    Uint8Array.prototype.set.call(\n      target,\n      this.subarray(start, start + len),\n      targetStart\n    )\n  }\n\n  return len\n}\n\n// Usage:\n//    buffer.fill(number[, offset[, end]])\n//    buffer.fill(buffer[, offset[, end]])\n//    buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n  // Handle string cases:\n  if (typeof val === 'string') {\n    if (typeof start === 'string') {\n      encoding = start\n      start = 0\n      end = this.length\n    } else if (typeof end === 'string') {\n      encoding = end\n      end = this.length\n    }\n    if (val.length === 1) {\n      var code = val.charCodeAt(0)\n      if (code < 256) {\n        val = code\n      }\n    }\n    if (encoding !== undefined && typeof encoding !== 'string') {\n      throw new TypeError('encoding must be a string')\n    }\n    if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n      throw new TypeError('Unknown encoding: ' + encoding)\n    }\n  } else if (typeof val === 'number') {\n    val = val & 255\n  }\n\n  // Invalid ranges are not set to a default, so can range check early.\n  if (start < 0 || this.length < start || this.length < end) {\n    throw new RangeError('Out of range index')\n  }\n\n  if (end <= start) {\n    return this\n  }\n\n  start = start >>> 0\n  end = end === undefined ? this.length : end >>> 0\n\n  if (!val) val = 0\n\n  var i\n  if (typeof val === 'number') {\n    for (i = start; i < end; ++i) {\n      this[i] = val\n    }\n  } else {\n    var bytes = Buffer.isBuffer(val)\n      ? val\n      : new Buffer(val, encoding)\n    var len = bytes.length\n    for (i = 0; i < end - start; ++i) {\n      this[i + start] = bytes[i % len]\n    }\n  }\n\n  return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n  // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n  str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n  // Node converts strings with length < 2 to ''\n  if (str.length < 2) return ''\n  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n  while (str.length % 4 !== 0) {\n    str = str + '='\n  }\n  return str\n}\n\nfunction stringtrim (str) {\n  if (str.trim) return str.trim()\n  return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n  if (n < 16) return '0' + n.toString(16)\n  return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n  units = units || Infinity\n  var codePoint\n  var length = string.length\n  var leadSurrogate = null\n  var bytes = []\n\n  for (var i = 0; i < length; ++i) {\n    codePoint = string.charCodeAt(i)\n\n    // is surrogate component\n    if (codePoint > 0xD7FF && codePoint < 0xE000) {\n      // last char was a lead\n      if (!leadSurrogate) {\n        // no lead yet\n        if (codePoint > 0xDBFF) {\n          // unexpected trail\n          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n          continue\n        } else if (i + 1 === length) {\n          // unpaired lead\n          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n          continue\n        }\n\n        // valid lead\n        leadSurrogate = codePoint\n\n        continue\n      }\n\n      // 2 leads in a row\n      if (codePoint < 0xDC00) {\n        if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n        leadSurrogate = codePoint\n        continue\n      }\n\n      // valid surrogate pair\n      codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n    } else if (leadSurrogate) {\n      // valid bmp char, but last char was a lead\n      if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n    }\n\n    leadSurrogate = null\n\n    // encode utf8\n    if (codePoint < 0x80) {\n      if ((units -= 1) < 0) break\n      bytes.push(codePoint)\n    } else if (codePoint < 0x800) {\n      if ((units -= 2) < 0) break\n      bytes.push(\n        codePoint >> 0x6 | 0xC0,\n        codePoint & 0x3F | 0x80\n      )\n    } else if (codePoint < 0x10000) {\n      if ((units -= 3) < 0) break\n      bytes.push(\n        codePoint >> 0xC | 0xE0,\n        codePoint >> 0x6 & 0x3F | 0x80,\n        codePoint & 0x3F | 0x80\n      )\n    } else if (codePoint < 0x110000) {\n      if ((units -= 4) < 0) break\n      bytes.push(\n        codePoint >> 0x12 | 0xF0,\n        codePoint >> 0xC & 0x3F | 0x80,\n        codePoint >> 0x6 & 0x3F | 0x80,\n        codePoint & 0x3F | 0x80\n      )\n    } else {\n      throw new Error('Invalid code point')\n    }\n  }\n\n  return bytes\n}\n\nfunction asciiToBytes (str) {\n  var byteArray = []\n  for (var i = 0; i < str.length; ++i) {\n    // Node's code seems to be doing this and not & 0x7F..\n    byteArray.push(str.charCodeAt(i) & 0xFF)\n  }\n  return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n  var c, hi, lo\n  var byteArray = []\n  for (var i = 0; i < str.length; ++i) {\n    if ((units -= 2) < 0) break\n\n    c = str.charCodeAt(i)\n    hi = c >> 8\n    lo = c % 256\n    byteArray.push(lo)\n    byteArray.push(hi)\n  }\n\n  return byteArray\n}\n\nfunction base64ToBytes (str) {\n  return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n  for (var i = 0; i < length; ++i) {\n    if ((i + offset >= dst.length) || (i >= src.length)) break\n    dst[i + offset] = src[i]\n  }\n  return i\n}\n\nfunction isnan (val) {\n  return val !== val // eslint-disable-line no-self-compare\n}\n\n},{\"base64-js\":3,\"ieee754\":9}],7:[function(require,module,exports){\n(function (Buffer){\n'use strict';\n\n/* eslint-disable */\n\nvar utils = require('./utils/index.js');\nvar uint256Coder = utils.uint256Coder;\nvar coderBoolean = utils.coderBoolean;\nvar coderFixedBytes = utils.coderFixedBytes;\nvar coderAddress = utils.coderAddress;\nvar coderDynamicBytes = utils.coderDynamicBytes;\nvar coderString = utils.coderString;\nvar coderArray = utils.coderArray;\nvar paramTypePart = utils.paramTypePart;\nvar getParamCoder = utils.getParamCoder;\n\nfunction Result() {}\n\nfunction encodeParams(types, values) {\n  if (types.length !== values.length) {\n    throw new Error('[ethjs-abi] while encoding params, types/values mismatch, types length ' + types.length + ' should be ' + values.length);\n  }\n\n  var parts = [];\n\n  types.forEach(function (type, index) {\n    var coder = getParamCoder(type);\n    parts.push({ dynamic: coder.dynamic, value: coder.encode(values[index]) });\n  });\n\n  function alignSize(size) {\n    return parseInt(32 * Math.ceil(size / 32));\n  }\n\n  var staticSize = 0,\n      dynamicSize = 0;\n  parts.forEach(function (part) {\n    if (part.dynamic) {\n      staticSize += 32;\n      dynamicSize += alignSize(part.value.length);\n    } else {\n      staticSize += alignSize(part.value.length);\n    }\n  });\n\n  var offset = 0,\n      dynamicOffset = staticSize;\n  var data = new Buffer(staticSize + dynamicSize);\n\n  parts.forEach(function (part, index) {\n    if (part.dynamic) {\n      uint256Coder.encode(dynamicOffset).copy(data, offset);\n      offset += 32;\n\n      part.value.copy(data, dynamicOffset);\n      dynamicOffset += alignSize(part.value.length);\n    } else {\n      part.value.copy(data, offset);\n      offset += alignSize(part.value.length);\n    }\n  });\n\n  return '0x' + data.toString('hex');\n}\n\n// decode bytecode data from output names and types\nfunction decodeParams(names, types, data) {\n  // Names is optional, so shift over all the parameters if not provided\n  if (arguments.length < 3) {\n    data = types;\n    types = names;\n    names = [];\n  }\n\n  data = utils.hexOrBuffer(data);\n  var values = new Result();\n\n  var offset = 0;\n  types.forEach(function (type, index) {\n    var coder = getParamCoder(type);\n    if (coder.dynamic) {\n      var dynamicOffset = uint256Coder.decode(data, offset);\n      var result = coder.decode(data, dynamicOffset.value.toNumber());\n      offset += dynamicOffset.consumed;\n    } else {\n      var result = coder.decode(data, offset);\n      offset += result.consumed;\n    }\n    values[index] = result.value;\n    if (names[index]) {\n      values[names[index]] = result.value;\n    }\n  });\n  return values;\n}\n\n// encode method ABI object with values in an array, output bytecode\nfunction encodeMethod(method, values) {\n  var signature = method.name + '(' + utils.getKeys(method.inputs, 'type').join(',') + ')';\n  var signatureEncoded = '0x' + new Buffer(utils.keccak256(signature), 'hex').slice(0, 4).toString('hex');\n  var paramsEncoded = encodeParams(utils.getKeys(method.inputs, 'type'), values).substring(2);\n\n  return '' + signatureEncoded + paramsEncoded;\n}\n\n// decode method data bytecode, from method ABI object\nfunction decodeMethod(method, data) {\n  var outputNames = utils.getKeys(method.outputs, 'name', true);\n  var outputTypes = utils.getKeys(method.outputs, 'type');\n\n  return decodeParams(outputNames, outputTypes, utils.hexOrBuffer(data));\n}\n\n// decode method data bytecode, from method ABI object\nfunction encodeEvent(eventObject, values) {\n  return encodeMethod(eventObject, values);\n}\n\n// decode method data bytecode, from method ABI object\nfunction decodeEvent(eventObject, data) {\n  var inputNames = utils.getKeys(eventObject.inputs, 'name', true);\n  var inputTypes = utils.getKeys(eventObject.inputs, 'type');\n\n  return decodeParams(inputNames, inputTypes, utils.hexOrBuffer(data));\n}\n\nmodule.exports = {\n  encodeParams: encodeParams,\n  decodeParams: decodeParams,\n  encodeMethod: encodeMethod,\n  decodeMethod: decodeMethod,\n  encodeEvent: encodeEvent,\n  decodeEvent: decodeEvent\n};\n}).call(this,require(\"buffer\").Buffer)\n},{\"./utils/index.js\":8,\"buffer\":6}],8:[function(require,module,exports){\n(function (Buffer){\n'use strict';\n\nvar BN = require('bn.js');\nvar numberToBN = require('number-to-bn');\nvar keccak256 = require('js-sha3').keccak_256;\n\n// from ethereumjs-util\nfunction stripZeros(aInput) {\n  var a = aInput; // eslint-disable-line\n  var first = a[0]; // eslint-disable-line\n  while (a.length > 0 && first.toString() === '0') {\n    a = a.slice(1);\n    first = a[0];\n  }\n  return a;\n}\n\nfunction bnToBuffer(bnInput) {\n  var bn = bnInput; // eslint-disable-line\n  var hex = bn.toString(16); // eslint-disable-line\n  if (hex.length % 2) {\n    hex = '0' + hex;\n  }\n  return stripZeros(new Buffer(hex, 'hex'));\n}\n\nfunction isHexString(value, length) {\n  if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {\n    return false;\n  }\n  if (length && value.length !== 2 + 2 * length) {\n    return false;\n  }\n  return true;\n}\n\nfunction hexOrBuffer(valueInput, name) {\n  var value = valueInput; // eslint-disable-line\n  if (!Buffer.isBuffer(value)) {\n    if (!isHexString(value)) {\n      var error = new Error(name ? '[ethjs-abi] invalid ' + name : '[ethjs-abi] invalid hex or buffer, must be a prefixed alphanumeric even length hex string');\n      error.reason = '[ethjs-abi] invalid hex string, hex must be prefixed and alphanumeric (e.g. 0x023..)';\n      error.value = value;\n      throw error;\n    }\n\n    value = value.substring(2);\n    if (value.length % 2) {\n      value = '0' + value;\n    }\n    value = new Buffer(value, 'hex');\n  }\n\n  return value;\n}\n\nfunction hexlify(value) {\n  if (typeof value === 'number') {\n    return '0x' + bnToBuffer(new BN(value)).toString('hex');\n  } else if (value.mod || value.modulo) {\n    return '0x' + bnToBuffer(value).toString('hex');\n  } else {\n    // eslint-disable-line\n    return '0x' + hexOrBuffer(value).toString('hex');\n  }\n}\n\n// getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3]\nfunction getKeys(params, key, allowEmpty) {\n  var result = []; // eslint-disable-line\n\n  if (!Array.isArray(params)) {\n    throw new Error('[ethjs-abi] while getting keys, invalid params value ' + JSON.stringify(params));\n  }\n\n  for (var i = 0; i < params.length; i++) {\n    // eslint-disable-line\n    var value = params[i][key]; // eslint-disable-line\n    if (allowEmpty && !value) {\n      value = '';\n    } else if (typeof value !== 'string') {\n      throw new Error('[ethjs-abi] while getKeys found invalid ABI data structure, type value not string');\n    }\n    result.push(value);\n  }\n\n  return result;\n}\n\nfunction coderNumber(size, signed) {\n  return {\n    encode: function encodeNumber(valueInput) {\n      var value = valueInput; // eslint-disable-line\n\n      if (typeof value === 'object' && value.toString && (value.toTwos || value.dividedToIntegerBy)) {\n        value = value.toString(10).split('.')[0];\n      }\n\n      if (typeof value === 'string' || typeof value === 'number') {\n        value = String(value).split('.')[0];\n      }\n\n      value = numberToBN(value);\n      value = value.toTwos(size * 8).maskn(size * 8);\n      if (signed) {\n        value = value.fromTwos(size * 8).toTwos(256);\n      }\n      return value.toArrayLike(Buffer, 'be', 32);\n    },\n    decode: function decodeNumber(data, offset) {\n      var junkLength = 32 - size; // eslint-disable-line\n      var value = new BN(data.slice(offset + junkLength, offset + 32)); // eslint-disable-line\n      if (signed) {\n        value = value.fromTwos(size * 8);\n      } else {\n        value = value.maskn(size * 8);\n      }\n      return {\n        consumed: 32,\n        value: new BN(value.toString(10))\n      };\n    }\n  };\n}\nvar uint256Coder = coderNumber(32, false);\n\nvar coderBoolean = {\n  encode: function encodeBoolean(value) {\n    return uint256Coder.encode(value ? 1 : 0);\n  },\n  decode: function decodeBoolean(data, offset) {\n    var result = uint256Coder.decode(data, offset); // eslint-disable-line\n    return {\n      consumed: result.consumed,\n      value: !result.value.isZero()\n    };\n  }\n};\n\nfunction coderFixedBytes(length) {\n  return {\n    encode: function encodeFixedBytes(valueInput) {\n      var value = valueInput; // eslint-disable-line\n      value = hexOrBuffer(value);\n\n      if (value.length === 32) {\n        return value;\n      }\n\n      var result = new Buffer(32); // eslint-disable-line\n      result.fill(0);\n      value.copy(result);\n      return result;\n    },\n    decode: function decodeFixedBytes(data, offset) {\n      if (data.length < offset + 32) {\n        throw new Error('[ethjs-abi] while decoding fixed bytes, invalid bytes data length: ' + length);\n      }\n\n      return {\n        consumed: 32,\n        value: '0x' + data.slice(offset, offset + length).toString('hex')\n      };\n    }\n  };\n}\n\nvar coderAddress = {\n  encode: function encodeAddress(valueInput) {\n    var value = valueInput; // eslint-disable-line\n    var result = new Buffer(32); // eslint-disable-line\n    if (!isHexString(value, 20)) {\n      throw new Error('[ethjs-abi] while encoding address, invalid address value, not alphanumeric 20 byte hex string');\n    }\n    value = hexOrBuffer(value);\n    result.fill(0);\n    value.copy(result, 12);\n    return result;\n  },\n  decode: function decodeAddress(data, offset) {\n    if (data.length === 0) {\n      return {\n        consumed: 32,\n        value: '0x'\n      };\n    }\n    if (data.length < offset + 32) {\n      throw new Error('[ethjs-abi] while decoding address data, invalid address data, invalid byte length ' + data.length);\n    }\n    return {\n      consumed: 32,\n      value: '0x' + data.slice(offset + 12, offset + 32).toString('hex')\n    };\n  }\n};\n\nfunction encodeDynamicBytesHelper(value) {\n  var dataLength = parseInt(32 * Math.ceil(value.length / 32)); // eslint-disable-line\n  var padding = new Buffer(dataLength - value.length); // eslint-disable-line\n  padding.fill(0);\n\n  return Buffer.concat([uint256Coder.encode(value.length), value, padding]);\n}\n\nfunction decodeDynamicBytesHelper(data, offset) {\n  if (data.length < offset + 32) {\n    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32));\n  }\n\n  var length = uint256Coder.decode(data, offset).value; // eslint-disable-line\n  length = length.toNumber();\n  if (data.length < offset + 32 + length) {\n    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32 + length));\n  }\n\n  return {\n    consumed: parseInt(32 + 32 * Math.ceil(length / 32), 10),\n    value: data.slice(offset + 32, offset + 32 + length)\n  };\n}\n\nvar coderDynamicBytes = {\n  encode: function encodeDynamicBytes(value) {\n    return encodeDynamicBytesHelper(hexOrBuffer(value));\n  },\n  decode: function decodeDynamicBytes(data, offset) {\n    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line\n    result.value = '0x' + result.value.toString('hex');\n    return result;\n  },\n  dynamic: true\n};\n\nvar coderString = {\n  encode: function encodeString(value) {\n    return encodeDynamicBytesHelper(new Buffer(value, 'utf8'));\n  },\n  decode: function decodeString(data, offset) {\n    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line\n    result.value = result.value.toString('utf8');\n    return result;\n  },\n  dynamic: true\n};\n\nfunction coderArray(coder, lengthInput) {\n  return {\n    encode: function encodeArray(value) {\n      var result = new Buffer(0); // eslint-disable-line\n      var length = lengthInput; // eslint-disable-line\n\n      if (!Array.isArray(value)) {\n        throw new Error('[ethjs-abi] while encoding array, invalid array data, not type Object (Array)');\n      }\n\n      if (length === -1) {\n        length = value.length;\n        result = uint256Coder.encode(length);\n      }\n\n      if (length !== value.length) {\n        throw new Error('[ethjs-abi] while encoding array, size mismatch array length ' + length + ' does not equal ' + value.length);\n      }\n\n      value.forEach(function (resultValue) {\n        result = Buffer.concat([result, coder.encode(resultValue)]);\n      });\n\n      return result;\n    },\n    decode: function decodeArray(data, offsetInput) {\n      var length = lengthInput; // eslint-disable-line\n      var offset = offsetInput; // eslint-disable-line\n      // @TODO:\n      // if (data.length < offset + length * 32) { throw new Error('invalid array'); }\n\n      var consumed = 0; // eslint-disable-line\n      var decodeResult; // eslint-disable-line\n\n      if (length === -1) {\n        decodeResult = uint256Coder.decode(data, offset);\n        length = decodeResult.value.toNumber();\n        consumed += decodeResult.consumed;\n        offset += decodeResult.consumed;\n      }\n\n      var value = []; // eslint-disable-line\n\n      for (var i = 0; i < length; i++) {\n        // eslint-disable-line\n        var loopResult = coder.decode(data, offset);\n        consumed += loopResult.consumed;\n        offset += loopResult.consumed;\n        value.push(loopResult.value);\n      }\n\n      return {\n        consumed: consumed,\n        value: value\n      };\n    },\n    dynamic: lengthInput === -1\n  };\n}\n\n// Break the type up into [staticType][staticArray]*[dynamicArray]? | [dynamicType] and\n// build the coder up from its parts\nvar paramTypePart = new RegExp(/^((u?int|bytes)([0-9]*)|(address|bool|string)|(\\[([0-9]*)\\]))/);\n\nfunction getParamCoder(typeInput) {\n  var type = typeInput; // eslint-disable-line\n  var coder = null; // eslint-disable-line\n  var invalidTypeErrorMessage = '[ethjs-abi] while getting param coder (getParamCoder) type value ' + JSON.stringify(type) + ' is either invalid or unsupported by ethjs-abi.';\n\n  while (type) {\n    var part = type.match(paramTypePart); // eslint-disable-line\n    if (!part) {\n      throw new Error(invalidTypeErrorMessage);\n    }\n    type = type.substring(part[0].length);\n\n    var prefix = part[2] || part[4] || part[5]; // eslint-disable-line\n    switch (prefix) {\n      case 'int':case 'uint':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        var intSize = parseInt(part[3] || 256); // eslint-disable-line\n        if (intSize === 0 || intSize > 256 || intSize % 8 !== 0) {\n          throw new Error('[ethjs-abi] while getting param coder for type ' + type + ', invalid ' + prefix + '<N> width: ' + type);\n        }\n\n        coder = coderNumber(intSize / 8, prefix === 'int');\n        break;\n\n      case 'bool':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderBoolean;\n        break;\n\n      case 'string':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderString;\n        break;\n\n      case 'bytes':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        if (part[3]) {\n          var size = parseInt(part[3]); // eslint-disable-line\n          if (size === 0 || size > 32) {\n            throw new Error('[ethjs-abi] while getting param coder for prefix bytes, invalid type ' + type + ', size ' + size + ' should be 0 or greater than 32');\n          }\n          coder = coderFixedBytes(size);\n        } else {\n          coder = coderDynamicBytes;\n        }\n        break;\n\n      case 'address':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderAddress;\n        break;\n\n      case '[]':\n        if (!coder || coder.dynamic) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderArray(coder, -1);\n        break;\n\n      // \"[0-9+]\"\n      default:\n        if (!coder || coder.dynamic) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        var defaultSize = parseInt(part[6]); // eslint-disable-line\n        coder = coderArray(coder, defaultSize);\n    }\n  }\n\n  if (!coder) {\n    throw new Error(invalidTypeErrorMessage);\n  }\n  return coder;\n}\n\nmodule.exports = {\n  BN: BN,\n  bnToBuffer: bnToBuffer,\n  isHexString: isHexString,\n  hexOrBuffer: hexOrBuffer,\n  hexlify: hexlify,\n  stripZeros: stripZeros,\n\n  keccak256: keccak256,\n\n  getKeys: getKeys,\n  numberToBN: numberToBN,\n  coderNumber: coderNumber,\n  uint256Coder: uint256Coder,\n  coderBoolean: coderBoolean,\n  coderFixedBytes: coderFixedBytes,\n  coderAddress: coderAddress,\n  coderDynamicBytes: coderDynamicBytes,\n  coderString: coderString,\n  coderArray: coderArray,\n  paramTypePart: paramTypePart,\n  getParamCoder: getParamCoder\n};\n}).call(this,require(\"buffer\").Buffer)\n},{\"bn.js\":4,\"buffer\":6,\"js-sha3\":11,\"number-to-bn\":12}],9:[function(require,module,exports){\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n  var e, m\n  var eLen = nBytes * 8 - mLen - 1\n  var eMax = (1 << eLen) - 1\n  var eBias = eMax >> 1\n  var nBits = -7\n  var i = isLE ? (nBytes - 1) : 0\n  var d = isLE ? -1 : 1\n  var s = buffer[offset + i]\n\n  i += d\n\n  e = s & ((1 << (-nBits)) - 1)\n  s >>= (-nBits)\n  nBits += eLen\n  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}\n\n  m = e & ((1 << (-nBits)) - 1)\n  e >>= (-nBits)\n  nBits += mLen\n  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}\n\n  if (e === 0) {\n    e = 1 - eBias\n  } else if (e === eMax) {\n    return m ? NaN : ((s ? -1 : 1) * Infinity)\n  } else {\n    m = m + Math.pow(2, mLen)\n    e = e - eBias\n  }\n  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n  var e, m, c\n  var eLen = nBytes * 8 - mLen - 1\n  var eMax = (1 << eLen) - 1\n  var eBias = eMax >> 1\n  var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n  var i = isLE ? 0 : (nBytes - 1)\n  var d = isLE ? 1 : -1\n  var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n  value = Math.abs(value)\n\n  if (isNaN(value) || value === Infinity) {\n    m = isNaN(value) ? 1 : 0\n    e = eMax\n  } else {\n    e = Math.floor(Math.log(value) / Math.LN2)\n    if (value * (c = Math.pow(2, -e)) < 1) {\n      e--\n      c *= 2\n    }\n    if (e + eBias >= 1) {\n      value += rt / c\n    } else {\n      value += rt * Math.pow(2, 1 - eBias)\n    }\n    if (value * c >= 2) {\n      e++\n      c /= 2\n    }\n\n    if (e + eBias >= eMax) {\n      m = 0\n      e = eMax\n    } else if (e + eBias >= 1) {\n      m = (value * c - 1) * Math.pow(2, mLen)\n      e = e + eBias\n    } else {\n      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n      e = 0\n    }\n  }\n\n  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n  e = (e << mLen) | m\n  eLen += mLen\n  for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n  buffer[offset + i - d] |= s * 128\n}\n\n},{}],10:[function(require,module,exports){\n/**\n * Returns a `Boolean` on whether or not the a `String` starts with '0x'\n * @param {String} str the string input value\n * @return {Boolean} a boolean if it is or is not hex prefixed\n * @throws if the str input is not a string\n */\nmodule.exports = function isHexPrefixed(str) {\n  if (typeof str !== 'string') {\n    throw new Error(\"[is-hex-prefixed] value must be type 'string', is currently type \" + (typeof str) + \", while checking isHexPrefixed.\");\n  }\n\n  return str.slice(0, 2) === '0x';\n}\n\n},{}],11:[function(require,module,exports){\n(function (process,global){\n/**\n * [js-sha3]{@link https://github.com/emn178/js-sha3}\n *\n * @version 0.5.5\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\n * @copyright Chen, Yi-Cyuan 2015-2016\n * @license MIT\n */\n(function (root) {\n  'use strict';\n\n  var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;\n  if (NODE_JS) {\n    root = global;\n  }\n  var COMMON_JS = !root.JS_SHA3_TEST && typeof module == 'object' && module.exports;\n  var HEX_CHARS = '0123456789abcdef'.split('');\n  var SHAKE_PADDING = [31, 7936, 2031616, 520093696];\n  var KECCAK_PADDING = [1, 256, 65536, 16777216];\n  var PADDING = [6, 1536, 393216, 100663296];\n  var SHIFT = [0, 8, 16, 24];\n  var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,\n            0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, \n            2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, \n            2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,\n            2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];\n  var BITS = [224, 256, 384, 512];\n  var SHAKE_BITS = [128, 256];\n  var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array'];\n\n  var createOutputMethod = function (bits, padding, outputType) {\n    return function (message) {\n      return new Keccak(bits, padding, bits).update(message)[outputType]();\n    }\n  };\n\n  var createShakeOutputMethod = function (bits, padding, outputType) {\n    return function (message, outputBits) {\n      return new Keccak(bits, padding, outputBits).update(message)[outputType]();\n    }\n  };\n\n  var createMethod = function (bits, padding) {\n    var method = createOutputMethod(bits, padding, 'hex');\n    method.create = function () {\n      return new Keccak(bits, padding, bits);\n    };\n    method.update = function (message) {\n      return method.create().update(message);\n    };\n    for (var i = 0;i < OUTPUT_TYPES.length;++i) {\n      var type = OUTPUT_TYPES[i];\n      method[type] = createOutputMethod(bits, padding, type);\n    }\n    return method;\n  };\n\n  var createShakeMethod = function (bits, padding) {\n    var method = createShakeOutputMethod(bits, padding, 'hex');\n    method.create = function (outputBits) {\n      return new Keccak(bits, padding, outputBits);\n    };\n    method.update = function (message, outputBits) {\n      return method.create(outputBits).update(message);\n    };\n    for (var i = 0;i < OUTPUT_TYPES.length;++i) {\n      var type = OUTPUT_TYPES[i];\n      method[type] = createShakeOutputMethod(bits, padding, type);\n    }\n    return method;\n  };\n\n  var algorithms = [\n    {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod},\n    {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod},\n    {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod}\n  ];\n\n  var methods = {};\n\n  for (var i = 0;i < algorithms.length;++i) {\n    var algorithm = algorithms[i];\n    var bits  = algorithm.bits;\n    for (var j = 0;j < bits.length;++j) {\n      methods[algorithm.name +'_' + bits[j]] = algorithm.createMethod(bits[j], algorithm.padding);\n    }\n  }\n\n  function Keccak(bits, padding, outputBits) {\n    this.blocks = [];\n    this.s = [];\n    this.padding = padding;\n    this.outputBits = outputBits;\n    this.reset = true;\n    this.block = 0;\n    this.start = 0;\n    this.blockCount = (1600 - (bits << 1)) >> 5;\n    this.byteCount = this.blockCount << 2;\n    this.outputBlocks = outputBits >> 5;\n    this.extraBytes = (outputBits & 31) >> 3;\n\n    for (var i = 0;i < 50;++i) {\n      this.s[i] = 0;\n    }\n  };\n\n  Keccak.prototype.update = function (message) {\n    var notString = typeof message != 'string';\n    if (notString && message.constructor == root.ArrayBuffer) {\n      message = new Uint8Array(message);\n    }\n    var length = message.length, blocks = this.blocks, byteCount = this.byteCount, \n        blockCount = this.blockCount, index = 0, s = this.s, i, code;\n    \n    while (index < length) {\n      if (this.reset) {\n        this.reset = false;\n        blocks[0] = this.block;\n        for (i = 1;i < blockCount + 1;++i) {\n          blocks[i] = 0;\n        }\n      }\n      if (notString) {\n        for (i = this.start;index < length && i < byteCount;++index) {\n          blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];\n        }\n      } else {\n        for (i = this.start;index < length && i < byteCount;++index) {\n          code = message.charCodeAt(index);\n          if (code < 0x80) {\n            blocks[i >> 2] |= code << SHIFT[i++ & 3];\n          } else if (code < 0x800) {\n            blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];\n            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n          } else if (code < 0xd800 || code >= 0xe000) {\n            blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];\n            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\n            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n          } else {\n            code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\n            blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];\n            blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];\n            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\n            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n          }\n        }\n      }\n      this.lastByteIndex = i;\n      if (i >= byteCount) {\n        this.start = i - byteCount;\n        this.block = blocks[blockCount];\n        for (i = 0;i < blockCount;++i) {\n          s[i] ^= blocks[i];\n        }\n        f(s);\n        this.reset = true;\n      } else {\n        this.start = i;\n      }\n    }\n    return this;\n  };\n\n  Keccak.prototype.finalize = function () {\n    var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;\n    blocks[i >> 2] |= this.padding[i & 3];\n    if (this.lastByteIndex == this.byteCount) {\n      blocks[0] = blocks[blockCount];\n      for (i = 1;i < blockCount + 1;++i) {\n        blocks[i] = 0;\n      }\n    }\n    blocks[blockCount - 1] |= 0x80000000;\n    for (i = 0;i < blockCount;++i) {\n      s[i] ^= blocks[i];\n    }\n    f(s);\n  };\n\n  Keccak.prototype.toString = Keccak.prototype.hex = function () {\n    this.finalize();\n\n    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, \n        extraBytes = this.extraBytes, i = 0, j = 0;\n    var hex = '', block;\n    while (j < outputBlocks) {\n      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {\n        block = s[i];\n        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +\n               HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +\n               HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +\n               HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];\n      }\n      if (j % blockCount == 0) {\n        f(s);\n        i = 0;\n      }\n    }\n    if (extraBytes) {\n      block = s[i];\n      if (extraBytes > 0) {\n        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];\n      }\n      if (extraBytes > 1) {\n        hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];\n      }\n      if (extraBytes > 2) {\n        hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];\n      }\n    }\n    return hex;\n  };\n\n  Keccak.prototype.arrayBuffer = function () {\n    this.finalize();\n\n    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, \n        extraBytes = this.extraBytes, i = 0, j = 0;\n    var bytes = this.outputBits >> 3;\n    var buffer;\n    if (extraBytes) {\n      buffer = new ArrayBuffer((outputBlocks + 1) << 2);\n    } else {\n      buffer = new ArrayBuffer(bytes);\n    }\n    var array = new Uint32Array(buffer);\n    while (j < outputBlocks) {\n      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {\n        array[j] = s[i];\n      }\n      if (j % blockCount == 0) {\n        f(s);\n      }\n    }\n    if (extraBytes) {\n      array[i] = s[i];\n      buffer = buffer.slice(0, bytes);\n    }\n    return buffer;\n  };\n\n  Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;\n\n  Keccak.prototype.digest = Keccak.prototype.array = function () {\n    this.finalize();\n\n    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, \n        extraBytes = this.extraBytes, i = 0, j = 0;\n    var array = [], offset, block;\n    while (j < outputBlocks) {\n      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {\n        offset = j << 2;\n        block = s[i];\n        array[offset] = block & 0xFF;\n        array[offset + 1] = (block >> 8) & 0xFF;\n        array[offset + 2] = (block >> 16) & 0xFF;\n        array[offset + 3] = (block >> 24) & 0xFF;\n      }\n      if (j % blockCount == 0) {\n        f(s);\n      }\n    }\n    if (extraBytes) {\n      offset = j << 2;\n      block = s[i];\n      if (extraBytes > 0) {\n        array[offset] = block & 0xFF;\n      }\n      if (extraBytes > 1) {\n        array[offset + 1] = (block >> 8) & 0xFF;\n      }\n      if (extraBytes > 2) {\n        array[offset + 2] = (block >> 16) & 0xFF;\n      }\n    }\n    return array;\n  };\n\n  var f = function (s) {\n    var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, \n        b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, \n        b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, \n        b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;\n    for (n = 0;n < 48;n += 2) {\n      c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];\n      c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];\n      c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];\n      c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];\n      c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];\n      c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];\n      c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];\n      c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];\n      c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];\n      c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];\n\n      h = c8 ^ ((c2 << 1) | (c3 >>> 31));\n      l = c9 ^ ((c3 << 1) | (c2 >>> 31));\n      s[0] ^= h;\n      s[1] ^= l;\n      s[10] ^= h;\n      s[11] ^= l;\n      s[20] ^= h;\n      s[21] ^= l;\n      s[30] ^= h;\n      s[31] ^= l;\n      s[40] ^= h;\n      s[41] ^= l;\n      h = c0 ^ ((c4 << 1) | (c5 >>> 31));\n      l = c1 ^ ((c5 << 1) | (c4 >>> 31));\n      s[2] ^= h;\n      s[3] ^= l;\n      s[12] ^= h;\n      s[13] ^= l;\n      s[22] ^= h;\n      s[23] ^= l;\n      s[32] ^= h;\n      s[33] ^= l;\n      s[42] ^= h;\n      s[43] ^= l;\n      h = c2 ^ ((c6 << 1) | (c7 >>> 31));\n      l = c3 ^ ((c7 << 1) | (c6 >>> 31));\n      s[4] ^= h;\n      s[5] ^= l;\n      s[14] ^= h;\n      s[15] ^= l;\n      s[24] ^= h;\n      s[25] ^= l;\n      s[34] ^= h;\n      s[35] ^= l;\n      s[44] ^= h;\n      s[45] ^= l;\n      h = c4 ^ ((c8 << 1) | (c9 >>> 31));\n      l = c5 ^ ((c9 << 1) | (c8 >>> 31));\n      s[6] ^= h;\n      s[7] ^= l;\n      s[16] ^= h;\n      s[17] ^= l;\n      s[26] ^= h;\n      s[27] ^= l;\n      s[36] ^= h;\n      s[37] ^= l;\n      s[46] ^= h;\n      s[47] ^= l;\n      h = c6 ^ ((c0 << 1) | (c1 >>> 31));\n      l = c7 ^ ((c1 << 1) | (c0 >>> 31));\n      s[8] ^= h;\n      s[9] ^= l;\n      s[18] ^= h;\n      s[19] ^= l;\n      s[28] ^= h;\n      s[29] ^= l;\n      s[38] ^= h;\n      s[39] ^= l;\n      s[48] ^= h;\n      s[49] ^= l;\n\n      b0 = s[0];\n      b1 = s[1];\n      b32 = (s[11] << 4) | (s[10] >>> 28);\n      b33 = (s[10] << 4) | (s[11] >>> 28);\n      b14 = (s[20] << 3) | (s[21] >>> 29);\n      b15 = (s[21] << 3) | (s[20] >>> 29);\n      b46 = (s[31] << 9) | (s[30] >>> 23);\n      b47 = (s[30] << 9) | (s[31] >>> 23);\n      b28 = (s[40] << 18) | (s[41] >>> 14);\n      b29 = (s[41] << 18) | (s[40] >>> 14);\n      b20 = (s[2] << 1) | (s[3] >>> 31);\n      b21 = (s[3] << 1) | (s[2] >>> 31);\n      b2 = (s[13] << 12) | (s[12] >>> 20);\n      b3 = (s[12] << 12) | (s[13] >>> 20);\n      b34 = (s[22] << 10) | (s[23] >>> 22);\n      b35 = (s[23] << 10) | (s[22] >>> 22);\n      b16 = (s[33] << 13) | (s[32] >>> 19);\n      b17 = (s[32] << 13) | (s[33] >>> 19);\n      b48 = (s[42] << 2) | (s[43] >>> 30);\n      b49 = (s[43] << 2) | (s[42] >>> 30);\n      b40 = (s[5] << 30) | (s[4] >>> 2);\n      b41 = (s[4] << 30) | (s[5] >>> 2);\n      b22 = (s[14] << 6) | (s[15] >>> 26);\n      b23 = (s[15] << 6) | (s[14] >>> 26);\n      b4 = (s[25] << 11) | (s[24] >>> 21);\n      b5 = (s[24] << 11) | (s[25] >>> 21);\n      b36 = (s[34] << 15) | (s[35] >>> 17);\n      b37 = (s[35] << 15) | (s[34] >>> 17);\n      b18 = (s[45] << 29) | (s[44] >>> 3);\n      b19 = (s[44] << 29) | (s[45] >>> 3);\n      b10 = (s[6] << 28) | (s[7] >>> 4);\n      b11 = (s[7] << 28) | (s[6] >>> 4);\n      b42 = (s[17] << 23) | (s[16] >>> 9);\n      b43 = (s[16] << 23) | (s[17] >>> 9);\n      b24 = (s[26] << 25) | (s[27] >>> 7);\n      b25 = (s[27] << 25) | (s[26] >>> 7);\n      b6 = (s[36] << 21) | (s[37] >>> 11);\n      b7 = (s[37] << 21) | (s[36] >>> 11);\n      b38 = (s[47] << 24) | (s[46] >>> 8);\n      b39 = (s[46] << 24) | (s[47] >>> 8);\n      b30 = (s[8] << 27) | (s[9] >>> 5);\n      b31 = (s[9] << 27) | (s[8] >>> 5);\n      b12 = (s[18] << 20) | (s[19] >>> 12);\n      b13 = (s[19] << 20) | (s[18] >>> 12);\n      b44 = (s[29] << 7) | (s[28] >>> 25);\n      b45 = (s[28] << 7) | (s[29] >>> 25);\n      b26 = (s[38] << 8) | (s[39] >>> 24);\n      b27 = (s[39] << 8) | (s[38] >>> 24);\n      b8 = (s[48] << 14) | (s[49] >>> 18);\n      b9 = (s[49] << 14) | (s[48] >>> 18);\n\n      s[0] = b0 ^ (~b2 & b4);\n      s[1] = b1 ^ (~b3 & b5);\n      s[10] = b10 ^ (~b12 & b14);\n      s[11] = b11 ^ (~b13 & b15);\n      s[20] = b20 ^ (~b22 & b24);\n      s[21] = b21 ^ (~b23 & b25);\n      s[30] = b30 ^ (~b32 & b34);\n      s[31] = b31 ^ (~b33 & b35);\n      s[40] = b40 ^ (~b42 & b44);\n      s[41] = b41 ^ (~b43 & b45);\n      s[2] = b2 ^ (~b4 & b6);\n      s[3] = b3 ^ (~b5 & b7);\n      s[12] = b12 ^ (~b14 & b16);\n      s[13] = b13 ^ (~b15 & b17);\n      s[22] = b22 ^ (~b24 & b26);\n      s[23] = b23 ^ (~b25 & b27);\n      s[32] = b32 ^ (~b34 & b36);\n      s[33] = b33 ^ (~b35 & b37);\n      s[42] = b42 ^ (~b44 & b46);\n      s[43] = b43 ^ (~b45 & b47);\n      s[4] = b4 ^ (~b6 & b8);\n      s[5] = b5 ^ (~b7 & b9);\n      s[14] = b14 ^ (~b16 & b18);\n      s[15] = b15 ^ (~b17 & b19);\n      s[24] = b24 ^ (~b26 & b28);\n      s[25] = b25 ^ (~b27 & b29);\n      s[34] = b34 ^ (~b36 & b38);\n      s[35] = b35 ^ (~b37 & b39);\n      s[44] = b44 ^ (~b46 & b48);\n      s[45] = b45 ^ (~b47 & b49);\n      s[6] = b6 ^ (~b8 & b0);\n      s[7] = b7 ^ (~b9 & b1);\n      s[16] = b16 ^ (~b18 & b10);\n      s[17] = b17 ^ (~b19 & b11);\n      s[26] = b26 ^ (~b28 & b20);\n      s[27] = b27 ^ (~b29 & b21);\n      s[36] = b36 ^ (~b38 & b30);\n      s[37] = b37 ^ (~b39 & b31);\n      s[46] = b46 ^ (~b48 & b40);\n      s[47] = b47 ^ (~b49 & b41);\n      s[8] = b8 ^ (~b0 & b2);\n      s[9] = b9 ^ (~b1 & b3);\n      s[18] = b18 ^ (~b10 & b12);\n      s[19] = b19 ^ (~b11 & b13);\n      s[28] = b28 ^ (~b20 & b22);\n      s[29] = b29 ^ (~b21 & b23);\n      s[38] = b38 ^ (~b30 & b32);\n      s[39] = b39 ^ (~b31 & b33);\n      s[48] = b48 ^ (~b40 & b42);\n      s[49] = b49 ^ (~b41 & b43);\n\n      s[0] ^= RC[n];\n      s[1] ^= RC[n + 1];\n    }\n  }\n\n  if (COMMON_JS) {\n    module.exports = methods;\n  } else if (root) {\n    for (var key in methods) {\n      root[key] = methods[key];\n    }\n  }\n}(this));\n\n}).call(this,require('_process'),typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"_process\":13}],12:[function(require,module,exports){\nvar BN = require('bn.js');\nvar stripHexPrefix = require('strip-hex-prefix');\n\n/**\n * Returns a BN object, converts a number value to a BN\n * @param {String|Number|Object} `arg` input a string number, hex string number, number, BigNumber or BN object\n * @return {Object} `output` BN object of the number\n * @throws if the argument is not an array, object that isn't a bignumber, not a string number or number\n */\nmodule.exports = function numberToBN(arg) {\n  if (typeof arg === 'string' || typeof arg === 'number') {\n    var multiplier = new BN(1); // eslint-disable-line\n    var formattedString = String(arg).toLowerCase().trim();\n    var isHexPrefixed = formattedString.substr(0, 2) === '0x' || formattedString.substr(0, 3) === '-0x';\n    var stringArg = stripHexPrefix(formattedString); // eslint-disable-line\n    if (stringArg.substr(0, 1) === '-') {\n      stringArg = stripHexPrefix(stringArg.slice(1));\n      multiplier = new BN(-1, 10);\n    }\n    stringArg = stringArg === '' ? '0' : stringArg;\n\n    if ((!stringArg.match(/^-?[0-9]+$/) && stringArg.match(/^[0-9A-Fa-f]+$/))\n      || stringArg.match(/^[a-fA-F]+$/)\n      || (isHexPrefixed === true && stringArg.match(/^[0-9A-Fa-f]+$/))) {\n      return new BN(stringArg, 16).mul(multiplier);\n    }\n\n    if ((stringArg.match(/^-?[0-9]+$/) || stringArg === '') && isHexPrefixed === false) {\n      return new BN(stringArg, 10).mul(multiplier);\n    }\n  } else if (typeof arg === 'object' && arg.toString && (!arg.pop && !arg.push)) {\n    if (arg.toString(10).match(/^-?[0-9]+$/) && (arg.mul || arg.dividedToIntegerBy)) {\n      return new BN(arg.toString(10), 10);\n    }\n  }\n\n  throw new Error('[number-to-bn] while converting number ' + JSON.stringify(arg) + ' to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.');\n}\n\n},{\"bn.js\":4,\"strip-hex-prefix\":14}],13:[function(require,module,exports){\n// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things.  But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals.  It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n    throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n    throw new Error('clearTimeout has not been defined');\n}\n(function () {\n    try {\n        if (typeof setTimeout === 'function') {\n            cachedSetTimeout = setTimeout;\n        } else {\n            cachedSetTimeout = defaultSetTimout;\n        }\n    } catch (e) {\n        cachedSetTimeout = defaultSetTimout;\n    }\n    try {\n        if (typeof clearTimeout === 'function') {\n            cachedClearTimeout = clearTimeout;\n        } else {\n            cachedClearTimeout = defaultClearTimeout;\n        }\n    } catch (e) {\n        cachedClearTimeout = defaultClearTimeout;\n    }\n} ())\nfunction runTimeout(fun) {\n    if (cachedSetTimeout === setTimeout) {\n        //normal enviroments in sane situations\n        return setTimeout(fun, 0);\n    }\n    // if setTimeout wasn't available but was latter defined\n    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n        cachedSetTimeout = setTimeout;\n        return setTimeout(fun, 0);\n    }\n    try {\n        // when when somebody has screwed with setTimeout but no I.E. maddness\n        return cachedSetTimeout(fun, 0);\n    } catch(e){\n        try {\n            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n            return cachedSetTimeout.call(null, fun, 0);\n        } catch(e){\n            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n            return cachedSetTimeout.call(this, fun, 0);\n        }\n    }\n\n\n}\nfunction runClearTimeout(marker) {\n    if (cachedClearTimeout === clearTimeout) {\n        //normal enviroments in sane situations\n        return clearTimeout(marker);\n    }\n    // if clearTimeout wasn't available but was latter defined\n    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n        cachedClearTimeout = clearTimeout;\n        return clearTimeout(marker);\n    }\n    try {\n        // when when somebody has screwed with setTimeout but no I.E. maddness\n        return cachedClearTimeout(marker);\n    } catch (e){\n        try {\n            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally\n            return cachedClearTimeout.call(null, marker);\n        } catch (e){\n            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n            // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n            return cachedClearTimeout.call(this, marker);\n        }\n    }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n    if (!draining || !currentQueue) {\n        return;\n    }\n    draining = false;\n    if (currentQueue.length) {\n        queue = currentQueue.concat(queue);\n    } else {\n        queueIndex = -1;\n    }\n    if (queue.length) {\n        drainQueue();\n    }\n}\n\nfunction drainQueue() {\n    if (draining) {\n        return;\n    }\n    var timeout = runTimeout(cleanUpNextTick);\n    draining = true;\n\n    var len = queue.length;\n    while(len) {\n        currentQueue = queue;\n        queue = [];\n        while (++queueIndex < len) {\n            if (currentQueue) {\n                currentQueue[queueIndex].run();\n            }\n        }\n        queueIndex = -1;\n        len = queue.length;\n    }\n    currentQueue = null;\n    draining = false;\n    runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n    var args = new Array(arguments.length - 1);\n    if (arguments.length > 1) {\n        for (var i = 1; i < arguments.length; i++) {\n            args[i - 1] = arguments[i];\n        }\n    }\n    queue.push(new Item(fun, args));\n    if (queue.length === 1 && !draining) {\n        runTimeout(drainQueue);\n    }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n    this.fun = fun;\n    this.array = array;\n}\nItem.prototype.run = function () {\n    this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n    throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n    throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n},{}],14:[function(require,module,exports){\nvar isHexPrefixed = require('is-hex-prefixed');\n\n/**\n * Removes '0x' from a given `String` is present\n * @param {String} str the string value\n * @return {String|Optional} a string by pass if necessary\n */\nmodule.exports = function stripHexPrefix(str) {\n  if (typeof str !== 'string') {\n    return str;\n  }\n\n  return isHexPrefixed(str) ? str.slice(2) : str;\n}\n\n},{\"is-hex-prefixed\":10}],15:[function(require,module,exports){\n// TODO: remove web3 requirement\n// Call functions directly on the provider.\nvar Web3 = require(\"web3\");\n\nvar Blockchain = {\n  parse: function(uri) {\n    var parsed = {};\n    if (uri.indexOf(\"blockchain://\") != 0) return parsed;\n\n    uri = uri.replace(\"blockchain://\", \"\");\n\n    var pieces = uri.split(\"/block/\");\n\n    parsed.genesis_hash = \"0x\" + pieces[0];\n    parsed.block_hash = \"0x\" + pieces[1];\n\n    return parsed;\n  },\n\n  asURI: function(provider, callback) {\n    var web3 = new Web3(provider);\n\n    web3.eth.getBlock(0, function(err, genesis) {\n      if (err) return callback(err);\n\n      web3.eth.getBlock(\"latest\", function(err, latest) {\n        if (err) return callback(err);\n\n        var url = \"blockchain://\" + genesis.hash.replace(\"0x\", \"\") + \"/block/\" + latest.hash.replace(\"0x\", \"\");\n\n        callback(null, url);\n      });\n    });\n  },\n\n  matches: function(uri, provider, callback) {\n    uri = this.parse(uri);\n\n    var expected_genesis = uri.genesis_hash;\n    var expected_block = uri.block_hash;\n\n    var web3 = new Web3(provider);\n\n    web3.eth.getBlock(0, function(err, block) {\n      if (err) return callback(err);\n      if (block.hash != expected_genesis) return callback(null, false);\n\n      web3.eth.getBlock(expected_block, function(err, block) {\n        // Treat an error as if the block didn't exist. This is because\n        // some clients respond differently.\n        if (err || block == null) {\n          return callback(null, false);\n        }\n\n        callback(null, true);\n      });\n    });\n  }\n};\n\nmodule.exports = Blockchain;\n\n},{\"web3\":5}],16:[function(require,module,exports){\nvar sha3 = require(\"crypto-js/sha3\");\nvar schema_version = require(\"./package.json\").version;\n\nvar TruffleSchema = {\n  // Normalize options passed in to be the exact options required\n  // for truffle-contract.\n  //\n  // options can be three things:\n  // - normal object\n  // - contract object\n  // - solc output\n  //\n  // TODO: Is extra_options still necessary?\n  normalizeOptions: function(options, extra_options) {\n    extra_options = extra_options || {};\n    var normalized = {};\n    var expected_keys = [\n      \"contract_name\",\n      \"abi\",\n      \"binary\",\n      \"unlinked_binary\",\n      \"address\",\n      \"networks\",\n      \"links\",\n      \"events\",\n      \"network_id\",\n      \"default_network\",\n      \"updated_at\"\n    ];\n\n    // Merge options/contract object first, then extra_options\n    expected_keys.forEach(function(key) {\n      var value;\n\n      try {\n        // Will throw an error if key == address and address doesn't exist.\n        value = options[key];\n\n        if (value != undefined) {\n          normalized[key] = value;\n        }\n      } catch (e) {\n        // Do nothing.\n      }\n\n      try {\n        // Will throw an error if key == address and address doesn't exist.\n        value = extra_options[key];\n\n        if (value != undefined) {\n          normalized[key] = value;\n        }\n      } catch (e) {\n        // Do nothing.\n      }\n    });\n\n    // Now look for solc specific items.\n    if (options.interface != null) {\n      normalized.abi = JSON.parse(options.interface);\n    }\n\n    if (options.bytecode != null) {\n      normalized.unlinked_binary = options.bytecode\n    }\n\n    // Assume any binary passed is the unlinked binary\n    if (normalized.unlinked_binary == null && normalized.binary) {\n      normalized.unlinked_binary = normalized.binary;\n    }\n\n    delete normalized.binary;\n\n    this.copyCustomOptions(options, normalized);\n\n    return normalized;\n  },\n\n  // Generate a proper binary from normalized options, and optionally\n  // merge it with an existing binary.\n  generateBinary: function(options, existing_binary, extra_options) {\n    extra_options = extra_options || {};\n\n    existing_binary = existing_binary || {};\n\n    if (options.overwrite == true) {\n      existing_binary = {};\n    }\n\n    existing_binary.contract_name = options.contract_name || existing_binary.contract_name || \"Contract\";\n    existing_binary.default_network = options.default_network || existing_binary.default_network;\n\n    existing_binary.abi = options.abi || existing_binary.abi;\n    existing_binary.unlinked_binary = options.unlinked_binary || existing_binary.unlinked_binary;\n\n    // Ensure unlinked binary starts with a 0x\n    if (existing_binary.unlinked_binary && existing_binary.unlinked_binary.indexOf(\"0x\") < 0) {\n      existing_binary.unlinked_binary = \"0x\" + existing_binary.unlinked_binary;\n    }\n\n    // Merge existing networks with any passed in networks.\n    existing_binary.networks = existing_binary.networks || {};\n    options.networks = options.networks || {};\n    Object.keys(options.networks).forEach(function(network_id) {\n      existing_binary.networks[network_id] = options.networks[network_id];\n    });\n\n    var updated_at = new Date().getTime();\n\n    if (options.network_id) {\n      // Ensure an object exists for this network.\n      existing_binary.networks[options.network_id] = existing_binary.networks[options.network_id] || {};\n\n      var network = existing_binary.networks[options.network_id];\n\n      // Override specific keys\n      network.address = options.address || network.address;\n      network.links = options.links;\n\n      // merge events with any that previously existed\n      network.events = network.events || {};\n      options.events = options.events || {};\n      Object.keys(options.events).forEach(function(event_id) {\n        options.events[event_id] = options.events[event_id];\n      });\n\n      // Now overwrite any events with the most recent data from the ABI.\n      existing_binary.abi.forEach(function(item) {\n        if (item.type != \"event\") return;\n\n        var signature = item.name + \"(\" + item.inputs.map(function(param) {return param.type;}).join(\",\") + \")\";\n        network.events[\"0x\" + sha3(signature, {outputLength: 256})] = item;\n      });\n\n      if (extra_options.dirty !== false) {\n        network.updated_at = updated_at;\n      }\n    } else {\n      if (options.address) {\n        throw new Error(\"Cannot set address without network id\");\n      }\n    }\n\n    // Ensure all networks have a `links` object.\n    Object.keys(existing_binary.networks).forEach(function(network_id) {\n      var network = existing_binary.networks[network_id];\n      network.links = network.links || {};\n    });\n\n    existing_binary.schema_version = schema_version;\n\n    if (extra_options.dirty !== false) {\n      existing_binary.updated_at = updated_at;\n    } else {\n      existing_binary.updated_at = options.updated_at || existing_binary.updated_at || updated_at;\n    }\n\n    this.copyCustomOptions(options, existing_binary);\n\n    return existing_binary;\n  },\n\n  copyCustomOptions: function(from, to) {\n    // Now let all x- options through.\n    Object.keys(from).forEach(function(key) {\n      if (key.indexOf(\"x-\") != 0) return;\n\n      try {\n        value = from[key];\n\n        if (value != undefined) {\n          to[key] = value;\n        }\n      } catch (e) {\n        // Do nothing.\n      }\n    });\n  }\n};\n\nmodule.exports = TruffleSchema;\n\n},{\"./package.json\":20,\"crypto-js/sha3\":18}],17:[function(require,module,exports){\n;(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory();\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\troot.CryptoJS = factory();\n\t}\n}(this, function () {\n\n\t/**\n\t * CryptoJS core components.\n\t */\n\tvar CryptoJS = CryptoJS || (function (Math, undefined) {\n\t    /*\n\t     * Local polyfil of Object.create\n\t     */\n\t    var create = Object.create || (function () {\n\t        function F() {};\n\n\t        return function (obj) {\n\t            var subtype;\n\n\t            F.prototype = obj;\n\n\t            subtype = new F();\n\n\t            F.prototype = null;\n\n\t            return subtype;\n\t        };\n\t    }())\n\n\t    /**\n\t     * CryptoJS namespace.\n\t     */\n\t    var C = {};\n\n\t    /**\n\t     * Library namespace.\n\t     */\n\t    var C_lib = C.lib = {};\n\n\t    /**\n\t     * Base object for prototypal inheritance.\n\t     */\n\t    var Base = C_lib.Base = (function () {\n\n\n\t        return {\n\t            /**\n\t             * Creates a new object that inherits from this object.\n\t             *\n\t             * @param {Object} overrides Properties to copy into the new object.\n\t             *\n\t             * @return {Object} The new object.\n\t             *\n\t             * @static\n\t             *\n\t             * @example\n\t             *\n\t             *     var MyType = CryptoJS.lib.Base.extend({\n\t             *         field: 'value',\n\t             *\n\t             *         method: function () {\n\t             *         }\n\t             *     });\n\t             */\n\t            extend: function (overrides) {\n\t                // Spawn\n\t                var subtype = create(this);\n\n\t                // Augment\n\t                if (overrides) {\n\t                    subtype.mixIn(overrides);\n\t                }\n\n\t                // Create default initializer\n\t                if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {\n\t                    subtype.init = function () {\n\t                        subtype.$super.init.apply(this, arguments);\n\t                    };\n\t                }\n\n\t                // Initializer's prototype is the subtype object\n\t                subtype.init.prototype = subtype;\n\n\t                // Reference supertype\n\t                subtype.$super = this;\n\n\t                return subtype;\n\t            },\n\n\t            /**\n\t             * Extends this object and runs the init method.\n\t             * Arguments to create() will be passed to init().\n\t             *\n\t             * @return {Object} The new object.\n\t             *\n\t             * @static\n\t             *\n\t             * @example\n\t             *\n\t             *     var instance = MyType.create();\n\t             */\n\t            create: function () {\n\t                var instance = this.extend();\n\t                instance.init.apply(instance, arguments);\n\n\t                return instance;\n\t            },\n\n\t            /**\n\t             * Initializes a newly created object.\n\t             * Override this method to add some logic when your objects are created.\n\t             *\n\t             * @example\n\t             *\n\t             *     var MyType = CryptoJS.lib.Base.extend({\n\t             *         init: function () {\n\t             *             // ...\n\t             *         }\n\t             *     });\n\t             */\n\t            init: function () {\n\t            },\n\n\t            /**\n\t             * Copies properties into this object.\n\t             *\n\t             * @param {Object} properties The properties to mix in.\n\t             *\n\t             * @example\n\t             *\n\t             *     MyType.mixIn({\n\t             *         field: 'value'\n\t             *     });\n\t             */\n\t            mixIn: function (properties) {\n\t                for (var propertyName in properties) {\n\t                    if (properties.hasOwnProperty(propertyName)) {\n\t                        this[propertyName] = properties[propertyName];\n\t                    }\n\t                }\n\n\t                // IE won't copy toString using the loop above\n\t                if (properties.hasOwnProperty('toString')) {\n\t                    this.toString = properties.toString;\n\t                }\n\t            },\n\n\t            /**\n\t             * Creates a copy of this object.\n\t             *\n\t             * @return {Object} The clone.\n\t             *\n\t             * @example\n\t             *\n\t             *     var clone = instance.clone();\n\t             */\n\t            clone: function () {\n\t                return this.init.prototype.extend(this);\n\t            }\n\t        };\n\t    }());\n\n\t    /**\n\t     * An array of 32-bit words.\n\t     *\n\t     * @property {Array} words The array of 32-bit words.\n\t     * @property {number} sigBytes The number of significant bytes in this word array.\n\t     */\n\t    var WordArray = C_lib.WordArray = Base.extend({\n\t        /**\n\t         * Initializes a newly created word array.\n\t         *\n\t         * @param {Array} words (Optional) An array of 32-bit words.\n\t         * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.lib.WordArray.create();\n\t         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);\n\t         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);\n\t         */\n\t        init: function (words, sigBytes) {\n\t            words = this.words = words || [];\n\n\t            if (sigBytes != undefined) {\n\t                this.sigBytes = sigBytes;\n\t            } else {\n\t                this.sigBytes = words.length * 4;\n\t            }\n\t        },\n\n\t        /**\n\t         * Converts this word array to a string.\n\t         *\n\t         * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex\n\t         *\n\t         * @return {string} The stringified word array.\n\t         *\n\t         * @example\n\t         *\n\t         *     var string = wordArray + '';\n\t         *     var string = wordArray.toString();\n\t         *     var string = wordArray.toString(CryptoJS.enc.Utf8);\n\t         */\n\t        toString: function (encoder) {\n\t            return (encoder || Hex).stringify(this);\n\t        },\n\n\t        /**\n\t         * Concatenates a word array to this word array.\n\t         *\n\t         * @param {WordArray} wordArray The word array to append.\n\t         *\n\t         * @return {WordArray} This word array.\n\t         *\n\t         * @example\n\t         *\n\t         *     wordArray1.concat(wordArray2);\n\t         */\n\t        concat: function (wordArray) {\n\t            // Shortcuts\n\t            var thisWords = this.words;\n\t            var thatWords = wordArray.words;\n\t            var thisSigBytes = this.sigBytes;\n\t            var thatSigBytes = wordArray.sigBytes;\n\n\t            // Clamp excess bits\n\t            this.clamp();\n\n\t            // Concat\n\t            if (thisSigBytes % 4) {\n\t                // Copy one byte at a time\n\t                for (var i = 0; i < thatSigBytes; i++) {\n\t                    var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t                    thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);\n\t                }\n\t            } else {\n\t                // Copy one word at a time\n\t                for (var i = 0; i < thatSigBytes; i += 4) {\n\t                    thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];\n\t                }\n\t            }\n\t            this.sigBytes += thatSigBytes;\n\n\t            // Chainable\n\t            return this;\n\t        },\n\n\t        /**\n\t         * Removes insignificant bits.\n\t         *\n\t         * @example\n\t         *\n\t         *     wordArray.clamp();\n\t         */\n\t        clamp: function () {\n\t            // Shortcuts\n\t            var words = this.words;\n\t            var sigBytes = this.sigBytes;\n\n\t            // Clamp\n\t            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);\n\t            words.length = Math.ceil(sigBytes / 4);\n\t        },\n\n\t        /**\n\t         * Creates a copy of this word array.\n\t         *\n\t         * @return {WordArray} The clone.\n\t         *\n\t         * @example\n\t         *\n\t         *     var clone = wordArray.clone();\n\t         */\n\t        clone: function () {\n\t            var clone = Base.clone.call(this);\n\t            clone.words = this.words.slice(0);\n\n\t            return clone;\n\t        },\n\n\t        /**\n\t         * Creates a word array filled with random bytes.\n\t         *\n\t         * @param {number} nBytes The number of random bytes to generate.\n\t         *\n\t         * @return {WordArray} The random word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.lib.WordArray.random(16);\n\t         */\n\t        random: function (nBytes) {\n\t            var words = [];\n\n\t            var r = (function (m_w) {\n\t                var m_w = m_w;\n\t                var m_z = 0x3ade68b1;\n\t                var mask = 0xffffffff;\n\n\t                return function () {\n\t                    m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;\n\t                    m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;\n\t                    var result = ((m_z << 0x10) + m_w) & mask;\n\t                    result /= 0x100000000;\n\t                    result += 0.5;\n\t                    return result * (Math.random() > .5 ? 1 : -1);\n\t                }\n\t            });\n\n\t            for (var i = 0, rcache; i < nBytes; i += 4) {\n\t                var _r = r((rcache || Math.random()) * 0x100000000);\n\n\t                rcache = _r() * 0x3ade67b7;\n\t                words.push((_r() * 0x100000000) | 0);\n\t            }\n\n\t            return new WordArray.init(words, nBytes);\n\t        }\n\t    });\n\n\t    /**\n\t     * Encoder namespace.\n\t     */\n\t    var C_enc = C.enc = {};\n\n\t    /**\n\t     * Hex encoding strategy.\n\t     */\n\t    var Hex = C_enc.Hex = {\n\t        /**\n\t         * Converts a word array to a hex string.\n\t         *\n\t         * @param {WordArray} wordArray The word array.\n\t         *\n\t         * @return {string} The hex string.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);\n\t         */\n\t        stringify: function (wordArray) {\n\t            // Shortcuts\n\t            var words = wordArray.words;\n\t            var sigBytes = wordArray.sigBytes;\n\n\t            // Convert\n\t            var hexChars = [];\n\t            for (var i = 0; i < sigBytes; i++) {\n\t                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t                hexChars.push((bite >>> 4).toString(16));\n\t                hexChars.push((bite & 0x0f).toString(16));\n\t            }\n\n\t            return hexChars.join('');\n\t        },\n\n\t        /**\n\t         * Converts a hex string to a word array.\n\t         *\n\t         * @param {string} hexStr The hex string.\n\t         *\n\t         * @return {WordArray} The word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.enc.Hex.parse(hexString);\n\t         */\n\t        parse: function (hexStr) {\n\t            // Shortcut\n\t            var hexStrLength = hexStr.length;\n\n\t            // Convert\n\t            var words = [];\n\t            for (var i = 0; i < hexStrLength; i += 2) {\n\t                words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);\n\t            }\n\n\t            return new WordArray.init(words, hexStrLength / 2);\n\t        }\n\t    };\n\n\t    /**\n\t     * Latin1 encoding strategy.\n\t     */\n\t    var Latin1 = C_enc.Latin1 = {\n\t        /**\n\t         * Converts a word array to a Latin1 string.\n\t         *\n\t         * @param {WordArray} wordArray The word array.\n\t         *\n\t         * @return {string} The Latin1 string.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);\n\t         */\n\t        stringify: function (wordArray) {\n\t            // Shortcuts\n\t            var words = wordArray.words;\n\t            var sigBytes = wordArray.sigBytes;\n\n\t            // Convert\n\t            var latin1Chars = [];\n\t            for (var i = 0; i < sigBytes; i++) {\n\t                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t                latin1Chars.push(String.fromCharCode(bite));\n\t            }\n\n\t            return latin1Chars.join('');\n\t        },\n\n\t        /**\n\t         * Converts a Latin1 string to a word array.\n\t         *\n\t         * @param {string} latin1Str The Latin1 string.\n\t         *\n\t         * @return {WordArray} The word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);\n\t         */\n\t        parse: function (latin1Str) {\n\t            // Shortcut\n\t            var latin1StrLength = latin1Str.length;\n\n\t            // Convert\n\t            var words = [];\n\t            for (var i = 0; i < latin1StrLength; i++) {\n\t                words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);\n\t            }\n\n\t            return new WordArray.init(words, latin1StrLength);\n\t        }\n\t    };\n\n\t    /**\n\t     * UTF-8 encoding strategy.\n\t     */\n\t    var Utf8 = C_enc.Utf8 = {\n\t        /**\n\t         * Converts a word array to a UTF-8 string.\n\t         *\n\t         * @param {WordArray} wordArray The word array.\n\t         *\n\t         * @return {string} The UTF-8 string.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);\n\t         */\n\t        stringify: function (wordArray) {\n\t            try {\n\t                return decodeURIComponent(escape(Latin1.stringify(wordArray)));\n\t            } catch (e) {\n\t                throw new Error('Malformed UTF-8 data');\n\t            }\n\t        },\n\n\t        /**\n\t         * Converts a UTF-8 string to a word array.\n\t         *\n\t         * @param {string} utf8Str The UTF-8 string.\n\t         *\n\t         * @return {WordArray} The word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);\n\t         */\n\t        parse: function (utf8Str) {\n\t            return Latin1.parse(unescape(encodeURIComponent(utf8Str)));\n\t        }\n\t    };\n\n\t    /**\n\t     * Abstract buffered block algorithm template.\n\t     *\n\t     * The property blockSize must be implemented in a concrete subtype.\n\t     *\n\t     * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0\n\t     */\n\t    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({\n\t        /**\n\t         * Resets this block algorithm's data buffer to its initial state.\n\t         *\n\t         * @example\n\t         *\n\t         *     bufferedBlockAlgorithm.reset();\n\t         */\n\t        reset: function () {\n\t            // Initial values\n\t            this._data = new WordArray.init();\n\t            this._nDataBytes = 0;\n\t        },\n\n\t        /**\n\t         * Adds new data to this block algorithm's buffer.\n\t         *\n\t         * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.\n\t         *\n\t         * @example\n\t         *\n\t         *     bufferedBlockAlgorithm._append('data');\n\t         *     bufferedBlockAlgorithm._append(wordArray);\n\t         */\n\t        _append: function (data) {\n\t            // Convert string to WordArray, else assume WordArray already\n\t            if (typeof data == 'string') {\n\t                data = Utf8.parse(data);\n\t            }\n\n\t            // Append\n\t            this._data.concat(data);\n\t            this._nDataBytes += data.sigBytes;\n\t        },\n\n\t        /**\n\t         * Processes available data blocks.\n\t         *\n\t         * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.\n\t         *\n\t         * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.\n\t         *\n\t         * @return {WordArray} The processed data.\n\t         *\n\t         * @example\n\t         *\n\t         *     var processedData = bufferedBlockAlgorithm._process();\n\t         *     var processedData = bufferedBlockAlgorithm._process(!!'flush');\n\t         */\n\t        _process: function (doFlush) {\n\t            // Shortcuts\n\t            var data = this._data;\n\t            var dataWords = data.words;\n\t            var dataSigBytes = data.sigBytes;\n\t            var blockSize = this.blockSize;\n\t            var blockSizeBytes = blockSize * 4;\n\n\t            // Count blocks ready\n\t            var nBlocksReady = dataSigBytes / blockSizeBytes;\n\t            if (doFlush) {\n\t                // Round up to include partial blocks\n\t                nBlocksReady = Math.ceil(nBlocksReady);\n\t            } else {\n\t                // Round down to include only full blocks,\n\t                // less the number of blocks that must remain in the buffer\n\t                nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);\n\t            }\n\n\t            // Count words ready\n\t            var nWordsReady = nBlocksReady * blockSize;\n\n\t            // Count bytes ready\n\t            var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);\n\n\t            // Process blocks\n\t            if (nWordsReady) {\n\t                for (var offset = 0; offset < nWordsReady; offset += blockSize) {\n\t                    // Perform concrete-algorithm logic\n\t                    this._doProcessBlock(dataWords, offset);\n\t                }\n\n\t                // Remove processed words\n\t                var processedWords = dataWords.splice(0, nWordsReady);\n\t                data.sigBytes -= nBytesReady;\n\t            }\n\n\t            // Return processed words\n\t            return new WordArray.init(processedWords, nBytesReady);\n\t        },\n\n\t        /**\n\t         * Creates a copy of this object.\n\t         *\n\t         * @return {Object} The clone.\n\t         *\n\t         * @example\n\t         *\n\t         *     var clone = bufferedBlockAlgorithm.clone();\n\t         */\n\t        clone: function () {\n\t            var clone = Base.clone.call(this);\n\t            clone._data = this._data.clone();\n\n\t            return clone;\n\t        },\n\n\t        _minBufferSize: 0\n\t    });\n\n\t    /**\n\t     * Abstract hasher template.\n\t     *\n\t     * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)\n\t     */\n\t    var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({\n\t        /**\n\t         * Configuration options.\n\t         */\n\t        cfg: Base.extend(),\n\n\t        /**\n\t         * Initializes a newly created hasher.\n\t         *\n\t         * @param {Object} cfg (Optional) The configuration options to use for this hash computation.\n\t         *\n\t         * @example\n\t         *\n\t         *     var hasher = CryptoJS.algo.SHA256.create();\n\t         */\n\t        init: function (cfg) {\n\t            // Apply config defaults\n\t            this.cfg = this.cfg.extend(cfg);\n\n\t            // Set initial values\n\t            this.reset();\n\t        },\n\n\t        /**\n\t         * Resets this hasher to its initial state.\n\t         *\n\t         * @example\n\t         *\n\t         *     hasher.reset();\n\t         */\n\t        reset: function () {\n\t            // Reset data buffer\n\t            BufferedBlockAlgorithm.reset.call(this);\n\n\t            // Perform concrete-hasher logic\n\t            this._doReset();\n\t        },\n\n\t        /**\n\t         * Updates this hasher with a message.\n\t         *\n\t         * @param {WordArray|string} messageUpdate The message to append.\n\t         *\n\t         * @return {Hasher} This hasher.\n\t         *\n\t         * @example\n\t         *\n\t         *     hasher.update('message');\n\t         *     hasher.update(wordArray);\n\t         */\n\t        update: function (messageUpdate) {\n\t            // Append\n\t            this._append(messageUpdate);\n\n\t            // Update the hash\n\t            this._process();\n\n\t            // Chainable\n\t            return this;\n\t        },\n\n\t        /**\n\t         * Finalizes the hash computation.\n\t         * Note that the finalize operation is effectively a destructive, read-once operation.\n\t         *\n\t         * @param {WordArray|string} messageUpdate (Optional) A final message update.\n\t         *\n\t         * @return {WordArray} The hash.\n\t         *\n\t         * @example\n\t         *\n\t         *     var hash = hasher.finalize();\n\t         *     var hash = hasher.finalize('message');\n\t         *     var hash = hasher.finalize(wordArray);\n\t         */\n\t        finalize: function (messageUpdate) {\n\t            // Final message update\n\t            if (messageUpdate) {\n\t                this._append(messageUpdate);\n\t            }\n\n\t            // Perform concrete-hasher logic\n\t            var hash = this._doFinalize();\n\n\t            return hash;\n\t        },\n\n\t        blockSize: 512/32,\n\n\t        /**\n\t         * Creates a shortcut function to a hasher's object interface.\n\t         *\n\t         * @param {Hasher} hasher The hasher to create a helper for.\n\t         *\n\t         * @return {Function} The shortcut function.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);\n\t         */\n\t        _createHelper: function (hasher) {\n\t            return function (message, cfg) {\n\t                return new hasher.init(cfg).finalize(message);\n\t            };\n\t        },\n\n\t        /**\n\t         * Creates a shortcut function to the HMAC's object interface.\n\t         *\n\t         * @param {Hasher} hasher The hasher to use in this HMAC helper.\n\t         *\n\t         * @return {Function} The shortcut function.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);\n\t         */\n\t        _createHmacHelper: function (hasher) {\n\t            return function (message, key) {\n\t                return new C_algo.HMAC.init(hasher, key).finalize(message);\n\t            };\n\t        }\n\t    });\n\n\t    /**\n\t     * Algorithm namespace.\n\t     */\n\t    var C_algo = C.algo = {};\n\n\t    return C;\n\t}(Math));\n\n\n\treturn CryptoJS;\n\n}));\n},{}],18:[function(require,module,exports){\n;(function (root, factory, undef) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"), require(\"./x64-core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\", \"./x64-core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (Math) {\n\t    // Shortcuts\n\t    var C = CryptoJS;\n\t    var C_lib = C.lib;\n\t    var WordArray = C_lib.WordArray;\n\t    var Hasher = C_lib.Hasher;\n\t    var C_x64 = C.x64;\n\t    var X64Word = C_x64.Word;\n\t    var C_algo = C.algo;\n\n\t    // Constants tables\n\t    var RHO_OFFSETS = [];\n\t    var PI_INDEXES  = [];\n\t    var ROUND_CONSTANTS = [];\n\n\t    // Compute Constants\n\t    (function () {\n\t        // Compute rho offset constants\n\t        var x = 1, y = 0;\n\t        for (var t = 0; t < 24; t++) {\n\t            RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;\n\n\t            var newX = y % 5;\n\t            var newY = (2 * x + 3 * y) % 5;\n\t            x = newX;\n\t            y = newY;\n\t        }\n\n\t        // Compute pi index constants\n\t        for (var x = 0; x < 5; x++) {\n\t            for (var y = 0; y < 5; y++) {\n\t                PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;\n\t            }\n\t        }\n\n\t        // Compute round constants\n\t        var LFSR = 0x01;\n\t        for (var i = 0; i < 24; i++) {\n\t            var roundConstantMsw = 0;\n\t            var roundConstantLsw = 0;\n\n\t            for (var j = 0; j < 7; j++) {\n\t                if (LFSR & 0x01) {\n\t                    var bitPosition = (1 << j) - 1;\n\t                    if (bitPosition < 32) {\n\t                        roundConstantLsw ^= 1 << bitPosition;\n\t                    } else /* if (bitPosition >= 32) */ {\n\t                        roundConstantMsw ^= 1 << (bitPosition - 32);\n\t                    }\n\t                }\n\n\t                // Compute next LFSR\n\t                if (LFSR & 0x80) {\n\t                    // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1\n\t                    LFSR = (LFSR << 1) ^ 0x71;\n\t                } else {\n\t                    LFSR <<= 1;\n\t                }\n\t            }\n\n\t            ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);\n\t        }\n\t    }());\n\n\t    // Reusable objects for temporary values\n\t    var T = [];\n\t    (function () {\n\t        for (var i = 0; i < 25; i++) {\n\t            T[i] = X64Word.create();\n\t        }\n\t    }());\n\n\t    /**\n\t     * SHA-3 hash algorithm.\n\t     */\n\t    var SHA3 = C_algo.SHA3 = Hasher.extend({\n\t        /**\n\t         * Configuration options.\n\t         *\n\t         * @property {number} outputLength\n\t         *   The desired number of bits in the output hash.\n\t         *   Only values permitted are: 224, 256, 384, 512.\n\t         *   Default: 512\n\t         */\n\t        cfg: Hasher.cfg.extend({\n\t            outputLength: 512\n\t        }),\n\n\t        _doReset: function () {\n\t            var state = this._state = []\n\t            for (var i = 0; i < 25; i++) {\n\t                state[i] = new X64Word.init();\n\t            }\n\n\t            this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;\n\t        },\n\n\t        _doProcessBlock: function (M, offset) {\n\t            // Shortcuts\n\t            var state = this._state;\n\t            var nBlockSizeLanes = this.blockSize / 2;\n\n\t            // Absorb\n\t            for (var i = 0; i < nBlockSizeLanes; i++) {\n\t                // Shortcuts\n\t                var M2i  = M[offset + 2 * i];\n\t                var M2i1 = M[offset + 2 * i + 1];\n\n\t                // Swap endian\n\t                M2i = (\n\t                    (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |\n\t                    (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)\n\t                );\n\t                M2i1 = (\n\t                    (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |\n\t                    (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)\n\t                );\n\n\t                // Absorb message into state\n\t                var lane = state[i];\n\t                lane.high ^= M2i1;\n\t                lane.low  ^= M2i;\n\t            }\n\n\t            // Rounds\n\t            for (var round = 0; round < 24; round++) {\n\t                // Theta\n\t                for (var x = 0; x < 5; x++) {\n\t                    // Mix column lanes\n\t                    var tMsw = 0, tLsw = 0;\n\t                    for (var y = 0; y < 5; y++) {\n\t                        var lane = state[x + 5 * y];\n\t                        tMsw ^= lane.high;\n\t                        tLsw ^= lane.low;\n\t                    }\n\n\t                    // Temporary values\n\t                    var Tx = T[x];\n\t                    Tx.high = tMsw;\n\t                    Tx.low  = tLsw;\n\t                }\n\t                for (var x = 0; x < 5; x++) {\n\t                    // Shortcuts\n\t                    var Tx4 = T[(x + 4) % 5];\n\t                    var Tx1 = T[(x + 1) % 5];\n\t                    var Tx1Msw = Tx1.high;\n\t                    var Tx1Lsw = Tx1.low;\n\n\t                    // Mix surrounding columns\n\t                    var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));\n\t                    var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));\n\t                    for (var y = 0; y < 5; y++) {\n\t                        var lane = state[x + 5 * y];\n\t                        lane.high ^= tMsw;\n\t                        lane.low  ^= tLsw;\n\t                    }\n\t                }\n\n\t                // Rho Pi\n\t                for (var laneIndex = 1; laneIndex < 25; laneIndex++) {\n\t                    // Shortcuts\n\t                    var lane = state[laneIndex];\n\t                    var laneMsw = lane.high;\n\t                    var laneLsw = lane.low;\n\t                    var rhoOffset = RHO_OFFSETS[laneIndex];\n\n\t                    // Rotate lanes\n\t                    if (rhoOffset < 32) {\n\t                        var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));\n\t                        var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));\n\t                    } else /* if (rhoOffset >= 32) */ {\n\t                        var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));\n\t                        var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));\n\t                    }\n\n\t                    // Transpose lanes\n\t                    var TPiLane = T[PI_INDEXES[laneIndex]];\n\t                    TPiLane.high = tMsw;\n\t                    TPiLane.low  = tLsw;\n\t                }\n\n\t                // Rho pi at x = y = 0\n\t                var T0 = T[0];\n\t                var state0 = state[0];\n\t                T0.high = state0.high;\n\t                T0.low  = state0.low;\n\n\t                // Chi\n\t                for (var x = 0; x < 5; x++) {\n\t                    for (var y = 0; y < 5; y++) {\n\t                        // Shortcuts\n\t                        var laneIndex = x + 5 * y;\n\t                        var lane = state[laneIndex];\n\t                        var TLane = T[laneIndex];\n\t                        var Tx1Lane = T[((x + 1) % 5) + 5 * y];\n\t                        var Tx2Lane = T[((x + 2) % 5) + 5 * y];\n\n\t                        // Mix rows\n\t                        lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);\n\t                        lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);\n\t                    }\n\t                }\n\n\t                // Iota\n\t                var lane = state[0];\n\t                var roundConstant = ROUND_CONSTANTS[round];\n\t                lane.high ^= roundConstant.high;\n\t                lane.low  ^= roundConstant.low;;\n\t            }\n\t        },\n\n\t        _doFinalize: function () {\n\t            // Shortcuts\n\t            var data = this._data;\n\t            var dataWords = data.words;\n\t            var nBitsTotal = this._nDataBytes * 8;\n\t            var nBitsLeft = data.sigBytes * 8;\n\t            var blockSizeBits = this.blockSize * 32;\n\n\t            // Add padding\n\t            dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);\n\t            dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;\n\t            data.sigBytes = dataWords.length * 4;\n\n\t            // Hash final blocks\n\t            this._process();\n\n\t            // Shortcuts\n\t            var state = this._state;\n\t            var outputLengthBytes = this.cfg.outputLength / 8;\n\t            var outputLengthLanes = outputLengthBytes / 8;\n\n\t            // Squeeze\n\t            var hashWords = [];\n\t            for (var i = 0; i < outputLengthLanes; i++) {\n\t                // Shortcuts\n\t                var lane = state[i];\n\t                var laneMsw = lane.high;\n\t                var laneLsw = lane.low;\n\n\t                // Swap endian\n\t                laneMsw = (\n\t                    (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |\n\t                    (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)\n\t                );\n\t                laneLsw = (\n\t                    (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |\n\t                    (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)\n\t                );\n\n\t                // Squeeze state to retrieve hash\n\t                hashWords.push(laneLsw);\n\t                hashWords.push(laneMsw);\n\t            }\n\n\t            // Return final computed hash\n\t            return new WordArray.init(hashWords, outputLengthBytes);\n\t        },\n\n\t        clone: function () {\n\t            var clone = Hasher.clone.call(this);\n\n\t            var state = clone._state = this._state.slice(0);\n\t            for (var i = 0; i < 25; i++) {\n\t                state[i] = state[i].clone();\n\t            }\n\n\t            return clone;\n\t        }\n\t    });\n\n\t    /**\n\t     * Shortcut function to the hasher's object interface.\n\t     *\n\t     * @param {WordArray|string} message The message to hash.\n\t     *\n\t     * @return {WordArray} The hash.\n\t     *\n\t     * @static\n\t     *\n\t     * @example\n\t     *\n\t     *     var hash = CryptoJS.SHA3('message');\n\t     *     var hash = CryptoJS.SHA3(wordArray);\n\t     */\n\t    C.SHA3 = Hasher._createHelper(SHA3);\n\n\t    /**\n\t     * Shortcut function to the HMAC's object interface.\n\t     *\n\t     * @param {WordArray|string} message The message to hash.\n\t     * @param {WordArray|string} key The secret key.\n\t     *\n\t     * @return {WordArray} The HMAC.\n\t     *\n\t     * @static\n\t     *\n\t     * @example\n\t     *\n\t     *     var hmac = CryptoJS.HmacSHA3(message, key);\n\t     */\n\t    C.HmacSHA3 = Hasher._createHmacHelper(SHA3);\n\t}(Math));\n\n\n\treturn CryptoJS.SHA3;\n\n}));\n},{\"./core\":17,\"./x64-core\":19}],19:[function(require,module,exports){\n;(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (undefined) {\n\t    // Shortcuts\n\t    var C = CryptoJS;\n\t    var C_lib = C.lib;\n\t    var Base = C_lib.Base;\n\t    var X32WordArray = C_lib.WordArray;\n\n\t    /**\n\t     * x64 namespace.\n\t     */\n\t    var C_x64 = C.x64 = {};\n\n\t    /**\n\t     * A 64-bit word.\n\t     */\n\t    var X64Word = C_x64.Word = Base.extend({\n\t        /**\n\t         * Initializes a newly created 64-bit word.\n\t         *\n\t         * @param {number} high The high 32 bits.\n\t         * @param {number} low The low 32 bits.\n\t         *\n\t         * @example\n\t         *\n\t         *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);\n\t         */\n\t        init: function (high, low) {\n\t            this.high = high;\n\t            this.low = low;\n\t        }\n\n\t        /**\n\t         * Bitwise NOTs this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after negating.\n\t         *\n\t         * @example\n\t         *\n\t         *     var negated = x64Word.not();\n\t         */\n\t        // not: function () {\n\t            // var high = ~this.high;\n\t            // var low = ~this.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Bitwise ANDs this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to AND with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after ANDing.\n\t         *\n\t         * @example\n\t         *\n\t         *     var anded = x64Word.and(anotherX64Word);\n\t         */\n\t        // and: function (word) {\n\t            // var high = this.high & word.high;\n\t            // var low = this.low & word.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Bitwise ORs this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to OR with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after ORing.\n\t         *\n\t         * @example\n\t         *\n\t         *     var ored = x64Word.or(anotherX64Word);\n\t         */\n\t        // or: function (word) {\n\t            // var high = this.high | word.high;\n\t            // var low = this.low | word.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Bitwise XORs this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to XOR with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after XORing.\n\t         *\n\t         * @example\n\t         *\n\t         *     var xored = x64Word.xor(anotherX64Word);\n\t         */\n\t        // xor: function (word) {\n\t            // var high = this.high ^ word.high;\n\t            // var low = this.low ^ word.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Shifts this word n bits to the left.\n\t         *\n\t         * @param {number} n The number of bits to shift.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after shifting.\n\t         *\n\t         * @example\n\t         *\n\t         *     var shifted = x64Word.shiftL(25);\n\t         */\n\t        // shiftL: function (n) {\n\t            // if (n < 32) {\n\t                // var high = (this.high << n) | (this.low >>> (32 - n));\n\t                // var low = this.low << n;\n\t            // } else {\n\t                // var high = this.low << (n - 32);\n\t                // var low = 0;\n\t            // }\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Shifts this word n bits to the right.\n\t         *\n\t         * @param {number} n The number of bits to shift.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after shifting.\n\t         *\n\t         * @example\n\t         *\n\t         *     var shifted = x64Word.shiftR(7);\n\t         */\n\t        // shiftR: function (n) {\n\t            // if (n < 32) {\n\t                // var low = (this.low >>> n) | (this.high << (32 - n));\n\t                // var high = this.high >>> n;\n\t            // } else {\n\t                // var low = this.high >>> (n - 32);\n\t                // var high = 0;\n\t            // }\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Rotates this word n bits to the left.\n\t         *\n\t         * @param {number} n The number of bits to rotate.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after rotating.\n\t         *\n\t         * @example\n\t         *\n\t         *     var rotated = x64Word.rotL(25);\n\t         */\n\t        // rotL: function (n) {\n\t            // return this.shiftL(n).or(this.shiftR(64 - n));\n\t        // },\n\n\t        /**\n\t         * Rotates this word n bits to the right.\n\t         *\n\t         * @param {number} n The number of bits to rotate.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after rotating.\n\t         *\n\t         * @example\n\t         *\n\t         *     var rotated = x64Word.rotR(7);\n\t         */\n\t        // rotR: function (n) {\n\t            // return this.shiftR(n).or(this.shiftL(64 - n));\n\t        // },\n\n\t        /**\n\t         * Adds this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to add with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after adding.\n\t         *\n\t         * @example\n\t         *\n\t         *     var added = x64Word.add(anotherX64Word);\n\t         */\n\t        // add: function (word) {\n\t            // var low = (this.low + word.low) | 0;\n\t            // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;\n\t            // var high = (this.high + word.high + carry) | 0;\n\n\t            // return X64Word.create(high, low);\n\t        // }\n\t    });\n\n\t    /**\n\t     * An array of 64-bit words.\n\t     *\n\t     * @property {Array} words The array of CryptoJS.x64.Word objects.\n\t     * @property {number} sigBytes The number of significant bytes in this word array.\n\t     */\n\t    var X64WordArray = C_x64.WordArray = Base.extend({\n\t        /**\n\t         * Initializes a newly created word array.\n\t         *\n\t         * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.\n\t         * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.x64.WordArray.create();\n\t         *\n\t         *     var wordArray = CryptoJS.x64.WordArray.create([\n\t         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),\n\t         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)\n\t         *     ]);\n\t         *\n\t         *     var wordArray = CryptoJS.x64.WordArray.create([\n\t         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),\n\t         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)\n\t         *     ], 10);\n\t         */\n\t        init: function (words, sigBytes) {\n\t            words = this.words = words || [];\n\n\t            if (sigBytes != undefined) {\n\t                this.sigBytes = sigBytes;\n\t            } else {\n\t                this.sigBytes = words.length * 8;\n\t            }\n\t        },\n\n\t        /**\n\t         * Converts this 64-bit word array to a 32-bit word array.\n\t         *\n\t         * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.\n\t         *\n\t         * @example\n\t         *\n\t         *     var x32WordArray = x64WordArray.toX32();\n\t         */\n\t        toX32: function () {\n\t            // Shortcuts\n\t            var x64Words = this.words;\n\t            var x64WordsLength = x64Words.length;\n\n\t            // Convert\n\t            var x32Words = [];\n\t            for (var i = 0; i < x64WordsLength; i++) {\n\t                var x64Word = x64Words[i];\n\t                x32Words.push(x64Word.high);\n\t                x32Words.push(x64Word.low);\n\t            }\n\n\t            return X32WordArray.create(x32Words, this.sigBytes);\n\t        },\n\n\t        /**\n\t         * Creates a copy of this word array.\n\t         *\n\t         * @return {X64WordArray} The clone.\n\t         *\n\t         * @example\n\t         *\n\t         *     var clone = x64WordArray.clone();\n\t         */\n\t        clone: function () {\n\t            var clone = Base.clone.call(this);\n\n\t            // Clone \"words\" array\n\t            var words = clone.words = this.words.slice(0);\n\n\t            // Clone each X64Word object\n\t            var wordsLength = words.length;\n\t            for (var i = 0; i < wordsLength; i++) {\n\t                words[i] = words[i].clone();\n\t            }\n\n\t            return clone;\n\t        }\n\t    });\n\t}());\n\n\n\treturn CryptoJS;\n\n}));\n},{\"./core\":17}],20:[function(require,module,exports){\nmodule.exports={\n  \"_args\": [\n    [\n      {\n        \"raw\": \"truffle-contract-schema@0.0.5\",\n        \"scope\": null,\n        \"escapedName\": \"truffle-contract-schema\",\n        \"name\": \"truffle-contract-schema\",\n        \"rawSpec\": \"0.0.5\",\n        \"spec\": \"0.0.5\",\n        \"type\": \"version\"\n      },\n      \"/Users/tim/Documents/workspace/Consensys/truffle-contract\"\n    ]\n  ],\n  \"_from\": \"truffle-contract-schema@0.0.5\",\n  \"_id\": \"truffle-contract-schema@0.0.5\",\n  \"_inCache\": true,\n  \"_location\": \"/truffle-contract-schema\",\n  \"_nodeVersion\": \"6.9.1\",\n  \"_npmOperationalInternal\": {\n    \"host\": \"packages-12-west.internal.npmjs.com\",\n    \"tmp\": \"tmp/truffle-contract-schema-0.0.5.tgz_1485557985137_0.46875762194395065\"\n  },\n  \"_npmUser\": {\n    \"name\": \"tcoulter\",\n    \"email\": \"tim@timothyjcoulter.com\"\n  },\n  \"_npmVersion\": \"3.10.8\",\n  \"_phantomChildren\": {},\n  \"_requested\": {\n    \"raw\": \"truffle-contract-schema@0.0.5\",\n    \"scope\": null,\n    \"escapedName\": \"truffle-contract-schema\",\n    \"name\": \"truffle-contract-schema\",\n    \"rawSpec\": \"0.0.5\",\n    \"spec\": \"0.0.5\",\n    \"type\": \"version\"\n  },\n  \"_requiredBy\": [\n    \"/\"\n  ],\n  \"_resolved\": \"https://registry.npmjs.org/truffle-contract-schema/-/truffle-contract-schema-0.0.5.tgz\",\n  \"_shasum\": \"5e9d20bd0bf2a27fe94310748249d484eee49961\",\n  \"_shrinkwrap\": null,\n  \"_spec\": \"truffle-contract-schema@0.0.5\",\n  \"_where\": \"/Users/tim/Documents/workspace/Consensys/truffle-contract\",\n  \"author\": {\n    \"name\": \"Tim Coulter\",\n    \"email\": \"tim.coulter@consensys.net\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/trufflesuite/truffle-schema/issues\"\n  },\n  \"dependencies\": {\n    \"crypto-js\": \"^3.1.9-1\"\n  },\n  \"description\": \"JSON schema for contract artifacts\",\n  \"devDependencies\": {\n    \"mocha\": \"^3.2.0\"\n  },\n  \"directories\": {},\n  \"dist\": {\n    \"shasum\": \"5e9d20bd0bf2a27fe94310748249d484eee49961\",\n    \"tarball\": \"https://registry.npmjs.org/truffle-contract-schema/-/truffle-contract-schema-0.0.5.tgz\"\n  },\n  \"gitHead\": \"cfa4313bd4bb95bf5b94f85185203ead418f9ee6\",\n  \"homepage\": \"https://github.com/trufflesuite/truffle-schema#readme\",\n  \"keywords\": [\n    \"ethereum\",\n    \"json\",\n    \"schema\",\n    \"contract\",\n    \"artifacts\"\n  ],\n  \"license\": \"MIT\",\n  \"main\": \"index.js\",\n  \"maintainers\": [\n    {\n      \"name\": \"tcoulter\",\n      \"email\": \"tim@timothyjcoulter.com\"\n    }\n  ],\n  \"name\": \"truffle-contract-schema\",\n  \"optionalDependencies\": {},\n  \"readme\": \"ERROR: No README data found!\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/trufflesuite/truffle-schema.git\"\n  },\n  \"scripts\": {\n    \"test\": \"mocha\"\n  },\n  \"version\": \"0.0.5\"\n}\n\n},{}]},{},[2]);\n"
  },
  {
    "path": "truffle/tokentutorial/test/.placeholder",
    "content": "This is a placeholder file to ensure the parent directory in the git repository. Feel free to remove.\n"
  },
  {
    "path": "truffle/tokentutorial/truffle.js",
    "content": "module.exports = {\n  // See <http://truffleframework.com/docs/advanced/configuration>\n  // for more about customizing your Truffle configuration!\n  networks: {\n    development: {\n      host: \"127.0.0.1\",\n      port: 7545,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};\n"
  },
  {
    "path": "truffle/tpetshop/README.md",
    "content": "# Pet Shop Sample\r\n\r\nCreating using the tutorial http://truffleframework.com/tutorials/pet-shop\r\n\r\nRun\r\n```\r\ntruffle compile\r\ntruffle deploy\r\nnpm install\r\nnpm run dev\r\n```\r\n\r\nIn Windows you must use `truffle.cmd` instead of `truffle`\r\n\r\nIt was tested using Truffle v3.4.9, installed globally:\r\n\r\n```\r\nnpm install -g truffle@3.4.9\r\n```\r\n\r\n\r\n\r\n"
  },
  {
    "path": "truffle/tpetshop/bs-config.json",
    "content": "{\n  \"server\": {\n    \"baseDir\": [\"./src\", \"./build/contracts\"]\n  }\n}\n"
  },
  {
    "path": "truffle/tpetshop/contracts/.gitkeep",
    "content": ""
  },
  {
    "path": "truffle/tpetshop/contracts/Adoption.sol",
    "content": "\r\npragma solidity ^0.4.15;\r\n\r\ncontract Adoption {\r\n\taddress[16] public adopters;\r\n\t\r\n\t// Adopting a pet\r\n\tfunction adopt(uint petId) public returns (uint) {\r\n\t  require(petId >= 0 && petId <= 15);\r\n      require(adopters[petId] == 0);\r\n      \r\n\t  adopters[petId] = msg.sender;\r\n\r\n\t  return petId;\r\n\t}\r\n\t\r\n\t// Retrieving the adopters\r\n\tfunction getAdopters() public returns (address[16]) {\r\n\t  return adopters;\r\n\t}\r\n}\r\n"
  },
  {
    "path": "truffle/tpetshop/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.2;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function Migrations() {\n    owner = msg.sender;\n  }\n\n  function setCompleted(uint completed) restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/tpetshop/contracts/MyContract.sol",
    "content": "pragma solidity ^0.4.4;\n\ncontract MyContract {\n  function MyContract() {\n    // constructor\n  }\n}\n"
  },
  {
    "path": "truffle/tpetshop/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/tpetshop/migrations/2_deploy_contracts.js",
    "content": "var Adoption = artifacts.require(\"./Adoption.sol\");\r\n\r\nmodule.exports = function(deployer) {\r\n  deployer.deploy(Adoption);\r\n};\r\n"
  },
  {
    "path": "truffle/tpetshop/package.json",
    "content": "{\n  \"name\": \"pet-shop\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"truffle.js\",\n  \"directories\": {\n    \"test\": \"test\"\n  },\n  \"scripts\": {\n    \"preinstall\": \"npx npm-force-resolutions\",\n    \"dev\": \"lite-server\",\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"minimist\": \"^1.2.5\",\n    \"lite-server\": \"^2.3.0\"\n  },\n  \"resolutions\": {\n    \"minimist\": \"^1.2.5\"\n  }\n}\n"
  },
  {
    "path": "truffle/tpetshop/src/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->\n    <title>Pete's Pet Shop</title>\n\n    <!-- Bootstrap -->\n    <link href=\"css/bootstrap.min.css\" rel=\"stylesheet\">\n\n    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->\n    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->\n    <!--[if lt IE 9]>\n      <script src=\"https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js\"></script>\n      <script src=\"https://oss.maxcdn.com/respond/1.4.2/respond.min.js\"></script>\n    <![endif]-->\n  </head>\n  <body>\n    <div class=\"container\">\n      <div class=\"row\">\n        <div class=\"col-xs-12 col-sm-8 col-sm-push-2\">\n          <h1 class=\"text-center\">Pete's Pet Shop</h1>\n          <hr/>\n          <br/>\n        </div>\n      </div>\n\n      <div id=\"petsRow\" class=\"row\">\n        <!-- PETS LOAD HERE -->\n      </div>\n    </div>\n\n    <div id=\"petTemplate\" style=\"display: none;\">\n      <div class=\"col-sm-6 col-md-4 col-lg-3\">\n        <div class=\"panel panel-default panel-pet\">\n          <div class=\"panel-heading\">\n            <h3 class=\"panel-title\">Scrappy</h3>\n          </div>\n          <div class=\"panel-body\">\n            <img alt=\"140x140\" data-src=\"holder.js/140x140\" class=\"img-rounded img-center\" style=\"width: 100%;\" src=\"https://animalso.com/wp-content/uploads/2017/01/Golden-Retriever_6.jpg\" data-holder-rendered=\"true\">\n            <br/><br/>\n            <strong>Breed</strong>: <span class=\"pet-breed\">Golden Retriever</span><br/>\n            <strong>Age</strong>: <span class=\"pet-age\">3</span><br/>\n            <strong>Location</strong>: <span class=\"pet-location\">Warren, MI</span><br/><br/>\n            <button class=\"btn btn-default btn-adopt\" type=\"button\" data-id=\"0\">Adopt</button>\n          </div>\n        </div>\n      </div>\n    </div>\n\n    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->\n    <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js\"></script>\n    <!-- Include all compiled plugins (below), or include individual files as needed -->\n    <script src=\"js/bootstrap.min.js\"></script>\n    <script src=\"js/web3.min.js\"></script>\n    <script src=\"js/truffle-contract.js\"></script>\n    <script src=\"js/app.js\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "truffle/tpetshop/src/js/app.js",
    "content": "App = {\n  web3Provider: null,\n  contracts: {},\n\n  init: function() {\n    // Load pets.\n    $.getJSON('../pets.json', function(data) {\n      var petsRow = $('#petsRow');\n      var petTemplate = $('#petTemplate');\n\n      for (i = 0; i < data.length; i ++) {\n        petTemplate.find('.panel-title').text(data[i].name);\n        petTemplate.find('img').attr('src', data[i].picture);\n        petTemplate.find('.pet-breed').text(data[i].breed);\n        petTemplate.find('.pet-age').text(data[i].age);\n        petTemplate.find('.pet-location').text(data[i].location);\n        petTemplate.find('.btn-adopt').attr('data-id', data[i].id);\n\n        petsRow.append(petTemplate.html());\n      }\n    });\n\n    return App.initWeb3();\n  },\n\n  initWeb3: function() {\n\t// Is there is an injected web3 instance?\n\tif (typeof web3 !== 'undefined') {\n\t  App.web3Provider = web3.currentProvider;\n\t} else {\n\t  // If no injected web3 instance is detected, fallback to the TestRPC\n\t  App.web3Provider = new Web3.providers.HttpProvider('http://localhost:8545');\n\t}\n\tweb3 = new Web3(App.web3Provider);\n\n    return App.initContract();\n  },\n\n  initContract: function() {\n\t$.getJSON('Adoption.json', function(data) {\n\t  // Get the necessary contract artifact file and instantiate it with truffle-contract\n\t  var AdoptionArtifact = data;\n\t  App.contracts.Adoption = TruffleContract(AdoptionArtifact);\n\n\t  // Set the provider for our contract\n\t  App.contracts.Adoption.setProvider(App.web3Provider);\n\n\t  // Use our contract to retrieve and mark the adopted pets\n\t  return App.markAdopted();\n\t});\n\n    return App.bindEvents();\n  },\n\n  bindEvents: function() {\n    $(document).on('click', '.btn-adopt', App.handleAdopt);\n  },\n\n  markAdopted: function(adopters, account) {\n\t\tvar adoptionInstance;\n\n\t\tApp.contracts.Adoption.deployed().then(function(instance) {\n\t\t  adoptionInstance = instance;\n\n\t\t  return adoptionInstance.getAdopters.call();\n\t\t}).then(function(adopters) {\n\t\t  for (i = 0; i < adopters.length; i++) {\n\t\t\tif (adopters[i] !== '0x0000000000000000000000000000000000000000') {\n\t\t\t  $('.panel-pet').eq(i).find('button').text('Success').attr('disabled', true);\n\t\t\t}\n\t\t  }\n\t\t}).catch(function(err) {\n\t\t  console.log(err.message);\n\t\t});\n  },\n\n  handleAdopt: function() {\n    event.preventDefault();\n\n    var petId = parseInt($(event.target).data('id'));\n\n\tvar adoptionInstance;\n\n\tweb3.eth.getAccounts(function(error, accounts) {\n\t  if (error) {\n\t\tconsole.log(error);\n\t  }\n\n\t  var account = accounts[0];\n\n\t  App.contracts.Adoption.deployed().then(function(instance) {\n\t\tadoptionInstance = instance;\n\n\t\t// Execute adopt as a transaction by sending account\n\t\treturn adoptionInstance.adopt(petId, {from: account});\n\t  }).then(function(result) {\n\t\treturn App.markAdopted();\n\t  }).catch(function(err) {\n\t\tconsole.log(err.message);\n\t  });\n\t});\n  }\n\n};\n\n$(function() {\n  $(window).load(function() {\n    App.init();\n  });\n});\n"
  },
  {
    "path": "truffle/tpetshop/src/js/truffle-contract.js",
    "content": "(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){\n(function (global){\nvar ethJSABI = require(\"ethjs-abi\");\nvar BlockchainUtils = require(\"truffle-blockchain-utils\");\nvar Web3 = require(\"web3\");\n\n// For browserified version. If browserify gave us an empty version,\n// look for the one provided by the user.\nif (typeof Web3 == \"object\" && Object.keys(Web3).length == 0) {\n  Web3 = global.Web3;\n}\n\nvar contract = (function(module) {\n\n  // Planned for future features, logging, etc.\n  function Provider(provider) {\n    this.provider = provider;\n  }\n\n  Provider.prototype.send = function() {\n    return this.provider.send.apply(this.provider, arguments);\n  };\n\n  Provider.prototype.sendAsync = function() {\n    return this.provider.sendAsync.apply(this.provider, arguments);\n  };\n\n  var BigNumber = (new Web3()).toBigNumber(0).constructor;\n\n  var Utils = {\n    is_object: function(val) {\n      return typeof val == \"object\" && !Array.isArray(val);\n    },\n    is_big_number: function(val) {\n      if (typeof val != \"object\") return false;\n\n      // Instanceof won't work because we have multiple versions of Web3.\n      try {\n        new BigNumber(val);\n        return true;\n      } catch (e) {\n        return false;\n      }\n    },\n    decodeLogs: function(C, instance, logs) {\n      return logs.map(function(log) {\n        var logABI = C.events[log.topics[0]];\n\n        if (logABI == null) {\n          return null;\n        }\n\n        // This function has been adapted from web3's SolidityEvent.decode() method,\n        // and built to work with ethjs-abi.\n\n        var copy = Utils.merge({}, log);\n\n        function partialABI(fullABI, indexed) {\n          var inputs = fullABI.inputs.filter(function (i) {\n            return i.indexed === indexed;\n          });\n\n          var partial = {\n            inputs: inputs,\n            name: fullABI.name,\n            type: fullABI.type,\n            anonymous: fullABI.anonymous\n          };\n\n          return partial;\n        }\n\n        var argTopics = logABI.anonymous ? copy.topics : copy.topics.slice(1);\n        var indexedData = \"0x\" + argTopics.map(function (topics) { return topics.slice(2); }).join(\"\");\n        var indexedParams = ethJSABI.decodeEvent(partialABI(logABI, true), indexedData);\n\n        var notIndexedData = copy.data;\n        var notIndexedParams = ethJSABI.decodeEvent(partialABI(logABI, false), notIndexedData);\n\n        copy.event = logABI.name;\n\n        copy.args = logABI.inputs.reduce(function (acc, current) {\n          var val = indexedParams[current.name];\n\n          if (val === undefined) {\n            val = notIndexedParams[current.name];\n          }\n\n          acc[current.name] = val;\n          return acc;\n        }, {});\n\n        Object.keys(copy.args).forEach(function(key) {\n          var val = copy.args[key];\n\n          // We have BN. Convert it to BigNumber\n          if (val.constructor.isBN) {\n            copy.args[key] = C.web3.toBigNumber(\"0x\" + val.toString(16));\n          }\n        });\n\n        delete copy.data;\n        delete copy.topics;\n\n        return copy;\n      }).filter(function(log) {\n        return log != null;\n      });\n    },\n    promisifyFunction: function(fn, C) {\n      var self = this;\n      return function() {\n        var instance = this;\n\n        var args = Array.prototype.slice.call(arguments);\n        var tx_params = {};\n        var last_arg = args[args.length - 1];\n\n        // It's only tx_params if it's an object and not a BigNumber.\n        if (Utils.is_object(last_arg) && !Utils.is_big_number(last_arg)) {\n          tx_params = args.pop();\n        }\n\n        tx_params = Utils.merge(C.class_defaults, tx_params);\n\n        return C.detectNetwork().then(function() {\n          return new Promise(function(accept, reject) {\n            var callback = function(error, result) {\n              if (error != null) {\n                reject(error);\n              } else {\n                accept(result);\n              }\n            };\n            args.push(tx_params, callback);\n            fn.apply(instance.contract, args);\n          });\n        });\n      };\n    },\n    synchronizeFunction: function(fn, instance, C) {\n      var self = this;\n      return function() {\n        var args = Array.prototype.slice.call(arguments);\n        var tx_params = {};\n        var last_arg = args[args.length - 1];\n\n        // It's only tx_params if it's an object and not a BigNumber.\n        if (Utils.is_object(last_arg) && !Utils.is_big_number(last_arg)) {\n          tx_params = args.pop();\n        }\n\n        tx_params = Utils.merge(C.class_defaults, tx_params);\n\n        return C.detectNetwork().then(function() {\n          return new Promise(function(accept, reject) {\n            var callback = function(error, tx) {\n              if (error != null) {\n                reject(error);\n                return;\n              }\n\n              var timeout = C.synchronization_timeout || 240000;\n              var start = new Date().getTime();\n\n              var make_attempt = function() {\n                C.web3.eth.getTransactionReceipt(tx, function(err, receipt) {\n                  if (err) return reject(err);\n\n                  if (receipt != null) {\n                    return accept({\n                      tx: tx,\n                      receipt: receipt,\n                      logs: Utils.decodeLogs(C, instance, receipt.logs)\n                    });\n                  }\n\n                  if (timeout > 0 && new Date().getTime() - start > timeout) {\n                    return reject(new Error(\"Transaction \" + tx + \" wasn't processed in \" + (timeout / 1000) + \" seconds!\"));\n                  }\n\n                  setTimeout(make_attempt, 1000);\n                });\n              };\n\n              make_attempt();\n            };\n\n            args.push(tx_params, callback);\n            fn.apply(self, args);\n          });\n        });\n      };\n    },\n    merge: function() {\n      var merged = {};\n      var args = Array.prototype.slice.call(arguments);\n\n      for (var i = 0; i < args.length; i++) {\n        var object = args[i];\n        var keys = Object.keys(object);\n        for (var j = 0; j < keys.length; j++) {\n          var key = keys[j];\n          var value = object[key];\n          merged[key] = value;\n        }\n      }\n\n      return merged;\n    },\n    parallel: function (arr, callback) {\n      callback = callback || function () {};\n      if (!arr.length) {\n        return callback(null, []);\n      }\n      var index = 0;\n      var results = new Array(arr.length);\n      arr.forEach(function (fn, position) {\n        fn(function (err, result) {\n          if (err) {\n            callback(err);\n            callback = function () {};\n          } else {\n            index++;\n            results[position] = result;\n            if (index >= arr.length) {\n              callback(null, results);\n            }\n          }\n        });\n      });\n    },\n    bootstrap: function(fn) {\n      // Add our static methods\n      Object.keys(fn._static_methods).forEach(function(key) {\n        fn[key] = fn._static_methods[key].bind(fn);\n      });\n\n      // Add our properties.\n      Object.keys(fn._properties).forEach(function(key) {\n        fn.addProp(key, fn._properties[key]);\n      });\n\n      return fn;\n    }\n  };\n\n  // Accepts a contract object created with web3.eth.contract.\n  // Optionally, if called without `new`, accepts a network_id and will\n  // create a new version of the contract abstraction with that network_id set.\n  function Contract(contract) {\n    var self = this;\n    var constructor = this.constructor;\n    this.abi = constructor.abi;\n\n    if (typeof contract == \"string\") {\n      var address = contract;\n      var contract_class = constructor.web3.eth.contract(this.abi);\n      contract = contract_class.at(address);\n    }\n\n    this.contract = contract;\n\n    // Provision our functions.\n    for (var i = 0; i < this.abi.length; i++) {\n      var item = this.abi[i];\n      if (item.type == \"function\") {\n        if (item.constant == true) {\n          this[item.name] = Utils.promisifyFunction(contract[item.name], constructor);\n        } else {\n          this[item.name] = Utils.synchronizeFunction(contract[item.name], this, constructor);\n        }\n\n        this[item.name].call = Utils.promisifyFunction(contract[item.name].call, constructor);\n        this[item.name].sendTransaction = Utils.promisifyFunction(contract[item.name].sendTransaction, constructor);\n        this[item.name].request = contract[item.name].request;\n        this[item.name].estimateGas = Utils.promisifyFunction(contract[item.name].estimateGas, constructor);\n      }\n\n      if (item.type == \"event\") {\n        this[item.name] = contract[item.name];\n      }\n    }\n\n    this.sendTransaction = Utils.synchronizeFunction(function(tx_params, callback) {\n      if (typeof tx_params == \"function\") {\n        callback = tx_params;\n        tx_params = {};\n      }\n\n      tx_params.to = self.address;\n\n      constructor.web3.eth.sendTransaction.apply(constructor.web3.eth, [tx_params, callback]);\n    }, this, constructor);\n\n    this.send = function(value) {\n      return self.sendTransaction({value: value});\n    };\n\n    this.allEvents = contract.allEvents;\n    this.address = contract.address;\n    this.transactionHash = contract.transactionHash;\n  };\n\n  Contract._static_methods = {\n    setProvider: function(provider) {\n      if (!provider) {\n        throw new Error(\"Invalid provider passed to setProvider(); provider is \" + provider);\n      }\n\n      var wrapped = new Provider(provider);\n      this.web3.setProvider(wrapped);\n      this.currentProvider = provider;\n    },\n\n    new: function() {\n      var self = this;\n\n      if (this.currentProvider == null) {\n        throw new Error(this.contract_name + \" error: Please call setProvider() first before calling new().\");\n      }\n\n      var args = Array.prototype.slice.call(arguments);\n\n      if (!this.unlinked_binary) {\n        throw new Error(this._json.contract_name + \" error: contract binary not set. Can't deploy new instance.\");\n      }\n\n      return self.detectNetwork().then(function(network_id) {\n        // After the network is set, check to make sure everything's ship shape.\n        var regex = /__[^_]+_+/g;\n        var unlinked_libraries = self.binary.match(regex);\n\n        if (unlinked_libraries != null) {\n          unlinked_libraries = unlinked_libraries.map(function(name) {\n            // Remove underscores\n            return name.replace(/_/g, \"\");\n          }).sort().filter(function(name, index, arr) {\n            // Remove duplicates\n            if (index + 1 >= arr.length) {\n              return true;\n            }\n\n            return name != arr[index + 1];\n          }).join(\", \");\n\n          throw new Error(self.contract_name + \" contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of \" + self._json.contract_name + \": \" + unlinked_libraries);\n        }\n      }).then(function() {\n        return new Promise(function(accept, reject) {\n          var contract_class = self.web3.eth.contract(self.abi);\n          var tx_params = {};\n          var last_arg = args[args.length - 1];\n\n          // It's only tx_params if it's an object and not a BigNumber.\n          if (Utils.is_object(last_arg) && !Utils.is_big_number(last_arg)) {\n            tx_params = args.pop();\n          }\n\n          tx_params = Utils.merge(self.class_defaults, tx_params);\n\n          if (tx_params.data == null) {\n            tx_params.data = self.binary;\n          }\n\n          // web3 0.9.0 and above calls new this callback twice.\n          // Why, I have no idea...\n          var intermediary = function(err, web3_instance) {\n            if (err != null) {\n              reject(err);\n              return;\n            }\n\n            if (err == null && web3_instance != null && web3_instance.address != null) {\n              accept(new self(web3_instance));\n            }\n          };\n\n          args.push(tx_params, intermediary);\n          contract_class.new.apply(contract_class, args);\n        });\n      });\n    },\n\n    at: function(address) {\n      var self = this;\n\n      if (address == null || typeof address != \"string\" || address.length != 42) {\n        throw new Error(\"Invalid address passed to \" + this._json.contract_name + \".at(): \" + address);\n      }\n\n      var contract = new this(address);\n\n      // Add thennable to allow people opt into new recommended usage.\n      contract.then = function(fn) {\n        return self.detectNetwork().then(function(network_id) {\n          var instance = new self(address);\n\n          return new Promise(function(accept, reject) {\n            self.web3.eth.getCode(address, function(err, code) {\n              if (err) return reject(err);\n\n              if (!code || new BigNumber(code).eq(0)) {\n                return reject(new Error(\"Cannot create instance of \" + self.contract_name + \"; no code at address \" + address));\n              }\n\n              accept(instance);\n            });\n          });\n        }).then(fn);\n      };\n\n      return contract;\n    },\n\n    deployed: function() {\n      var self = this;\n      var val = {}; //this.at(this.address);\n\n      // Add thennable to allow people to opt into new recommended usage.\n      val.then = function(fn) {\n        return self.detectNetwork().then(function() {\n          // We don't have a network config for the one we found\n          if (self._json.networks[self.network_id] == null) {\n            throw new Error(self.contract_name + \" has not been deployed to detected network (network/artifact mismatch)\");\n          }\n\n          // If we found the network but it's not deployed\n          if (!self.isDeployed()) {\n            throw new Error(self.contract_name + \" has not been deployed to detected network (\" + self.network_id + \")\");\n          }\n\n          return new self(self.address);\n        }).then(fn);\n      };\n\n      return val;\n    },\n\n    defaults: function(class_defaults) {\n      if (this.class_defaults == null) {\n        this.class_defaults = {};\n      }\n\n      if (class_defaults == null) {\n        class_defaults = {};\n      }\n\n      var self = this;\n      Object.keys(class_defaults).forEach(function(key) {\n        var value = class_defaults[key];\n        self.class_defaults[key] = value;\n      });\n\n      return this.class_defaults;\n    },\n\n    hasNetwork: function(network_id) {\n      return this._json.networks[network_id + \"\"] != null;\n    },\n\n    isDeployed: function() {\n      if (this.network_id == null) {\n        return false;\n      }\n\n      if (this._json.networks[this.network_id] == null) {\n        return false;\n      }\n\n      return !!this.network.address;\n    },\n\n    detectNetwork: function() {\n      var self = this;\n\n      return new Promise(function(accept, reject) {\n        // Try to detect the network we have artifacts for.\n        if (self.network_id) {\n          // We have a network id and a configuration, let's go with it.\n          if (self.networks[self.network_id] != null) {\n            return accept(self.network_id);\n          }\n        }\n\n        self.web3.version.getNetwork(function(err, result) {\n          if (err) return reject(err);\n\n          var network_id = result.toString();\n\n          // If we found the network via a number, let's use that.\n          if (self.hasNetwork(network_id)) {\n            self.setNetwork(network_id);\n            return accept();\n          }\n\n          // Otherwise, go through all the networks that are listed as\n          // blockchain uris and see if they match.\n          var uris = Object.keys(self._json.networks).filter(function(network) {\n            return network.indexOf(\"blockchain://\") == 0;\n          });\n\n          var matches = uris.map(function(uri) {\n            return BlockchainUtils.matches.bind(BlockchainUtils, uri, self.web3.currentProvider);\n          });\n\n          Utils.parallel(matches, function(err, results) {\n            if (err) return reject(err);\n\n            for (var i = 0; i < results.length; i++) {\n              if (results[i]) {\n                self.setNetwork(uris[i]);\n                return accept();\n              }\n            }\n\n            // We found nothing. Set the network id to whatever the provider states.\n            self.setNetwork(network_id);\n\n            accept();\n          });\n\n        });\n      });\n    },\n\n    setNetwork: function(network_id) {\n      if (!network_id) return;\n      this.network_id = network_id + \"\";\n    },\n\n    // Overrides the deployed address to null.\n    // You must call this explicitly so you don't inadvertently do this otherwise.\n    resetAddress: function() {\n      delete this.network.address;\n    },\n\n    link: function(name, address) {\n      var self = this;\n\n      if (typeof name == \"function\") {\n        var contract = name;\n\n        if (contract.isDeployed() == false) {\n          throw new Error(\"Cannot link contract without an address.\");\n        }\n\n        this.link(contract.contract_name, contract.address);\n\n        // Merge events so this contract knows about library's events\n        Object.keys(contract.events).forEach(function(topic) {\n          self.network.events[topic] = contract.events[topic];\n        });\n\n        return;\n      }\n\n      if (typeof name == \"object\") {\n        var obj = name;\n        Object.keys(obj).forEach(function(name) {\n          var a = obj[name];\n          self.link(name, a);\n        });\n        return;\n      }\n\n      if (this._json.networks[this.network_id] == null) {\n        this._json.networks[this.network_id] = {\n          events: {},\n          links: {}\n        };\n      }\n\n      this.network.links[name] = address;\n    },\n\n    clone: function(options) {\n      var self = this;\n      var temp = function TruffleContract() {\n        this.constructor = temp;\n        return Contract.apply(this, arguments);\n      };\n\n      var json = options;\n      var network_id;\n\n      if (typeof options != \"object\") {\n        json = self._json;\n        network_id = options;\n        options = {};\n      }\n\n      temp.prototype = Object.create(self.prototype);\n\n      temp._static_methods = this._static_methods;\n      temp._properties = this._properties;\n\n      temp._property_values = {};\n      temp._json = json || {};\n\n      Utils.bootstrap(temp);\n\n      temp.web3 = new Web3();\n      temp.class_defaults = temp.prototype.defaults || {};\n\n      if (network_id) {\n        temp.setNetwork(network_id);\n      }\n\n      // Copy over custom options\n      Object.keys(options).forEach(function(key) {\n        if (key.indexOf(\"x-\") != 0) return;\n        temp[key] = options[key];\n      });\n\n      return temp;\n    },\n\n    addProp: function(key, fn) {\n      var self = this;\n\n      var getter = function() {\n        if (fn.get != null) {\n          return fn.get.call(self);\n        }\n\n        return self._property_values[key] || fn.call(self);\n      }\n      var setter = function(val) {\n        if (fn.set != null) {\n          fn.set.call(self, val);\n          return;\n        }\n\n        // If there's not a setter, then the property is immutable.\n        throw new Error(key + \" property is immutable\");\n      };\n\n      var definition = {};\n      definition.enumerable = false;\n      definition.configurable = false;\n      definition.get = getter;\n      definition.set = setter;\n\n      Object.defineProperty(this, key, definition);\n    },\n\n    toJSON: function() {\n      return this._json;\n    }\n  };\n\n  // Getter functions are scoped to Contract object.\n  Contract._properties = {\n    contract_name: {\n      get: function() {\n        return this._json.contract_name;\n      },\n      set: function(val) {\n        this._json.contract_name = val;\n      }\n    },\n    abi: {\n      get: function() {\n        return this._json.abi;\n      },\n      set: function(val) {\n        this._json.abi = val;\n      }\n    },\n    network: function() {\n      var network_id = this.network_id;\n\n      if (network_id == null) {\n        throw new Error(this.contract_name + \" has no network id set, cannot lookup artifact data. Either set the network manually using \" + this.contract_name + \".setNetwork(), run \" + this.contract_name + \".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.\");\n      }\n\n      // TODO: this might be bad; setting a value on a get.\n      if (this._json.networks[network_id] == null) {\n        throw new Error(this.contract_name + \" has no network configuration for its current network id (\" + network_id + \").\");\n      }\n\n      return this._json.networks[network_id];\n    },\n    networks: function() {\n      return this._json.networks;\n    },\n    address: {\n      get: function() {\n        var address = this.network.address;\n\n        if (address == null) {\n          throw new Error(\"Cannot find deployed address: \" + this.contract_name + \" not deployed or address not set.\");\n        }\n\n        return address;\n      },\n      set: function(val) {\n        if (val == null) {\n          throw new Error(\"Cannot set deployed address; malformed value: \" + val);\n        }\n\n        var network_id = this.network_id;\n\n        if (network_id == null) {\n          throw new Error(this.contract_name + \" has no network id set, cannot lookup artifact data. Either set the network manually using \" + this.contract_name + \".setNetwork(), run \" + this.contract_name + \".detectNetwork(), or use new(), at() or deployed() as a thenable which will detect the network automatically.\");\n        }\n\n        // Create a network if we don't have one.\n        if (this._json.networks[network_id] == null) {\n          this._json.networks[network_id] = {\n            events: {},\n            links: {}\n          };\n        }\n\n        // Finally, set the address.\n        this.network.address = val;\n      }\n    },\n    links: function() {\n      if (this._json.networks[this.network_id] == null) {\n        return {};\n      }\n\n      return this.network.links || {};\n    },\n    events: function() {\n      // helper web3; not used for provider\n      var web3 = new Web3();\n\n      var events;\n\n      if (this._json.networks[this.network_id] == null) {\n        events = {};\n      } else {\n        events = this.network.events || {};\n      }\n\n      // Merge abi events with whatever's returned.\n      var abi = this.abi;\n\n      abi.forEach(function(item) {\n        if (item.type != \"event\") return;\n\n        var signature = item.name + \"(\";\n\n        item.inputs.forEach(function(input, index) {\n          signature += input.type;\n\n          if (index < item.inputs.length - 1) {\n            signature += \",\";\n          }\n        });\n\n        signature += \")\";\n\n        var topic = web3.sha3(signature);\n\n        events[topic] = item;\n      });\n\n      return events;\n    },\n    binary: function() {\n      var self = this;\n      var binary = this.unlinked_binary;\n\n      Object.keys(this.links).forEach(function(library_name) {\n        var library_address = self.links[library_name];\n        var regex = new RegExp(\"__\" + library_name + \"_*\", \"g\");\n\n        binary = binary.replace(regex, library_address.replace(\"0x\", \"\"));\n      });\n\n      return binary;\n    },\n    unlinked_binary: {\n      get: function() {\n        return this._json.unlinked_binary;\n      },\n      set: function(val) {\n        // TODO: Ensure 0x prefix.\n        this._json.unlinked_binary = val;\n      }\n    },\n    schema_version: function() {\n      return this._json.schema_version;\n    },\n    updated_at: function() {\n      try {\n        return this.network.updated_at || this._json.updated_at;\n      } catch (e) {\n        return this._json.updated_at;\n      }\n    }\n  };\n\n  Utils.bootstrap(Contract);\n\n  module.exports = Contract;\n\n  return Contract;\n})(module || {});\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"ethjs-abi\":7,\"truffle-blockchain-utils\":15,\"web3\":5}],2:[function(require,module,exports){\nvar Schema = require(\"truffle-contract-schema\");\nvar Contract = require(\"./contract.js\");\n\nvar contract = function(options) {\n  options = Schema.normalizeOptions(options);\n  var binary = Schema.generateBinary(options, {}, {dirty: false});\n\n  // Note we don't use `new` here at all. This will cause the class to\n  // \"mutate\" instead of instantiate an instance.\n  return Contract.clone(binary);\n};\n\n// To be used to upgrade old .sol.js abstractions\ncontract.fromSolJS = function(soljs_abstraction, ignore_default_network) {\n  if (ignore_default_network == null) {\n    ignore_default_network = false;\n  }\n\n  // Find the latest binary\n  var latest_network = null;\n  var latest_network_updated_at = 0;\n\n  var networks = {};\n\n  Object.keys(soljs_abstraction.all_networks).forEach(function(network_name) {\n\n    if (network_name == \"default\") {\n      if (ignore_default_network == true ) {\n        return;\n      } else {\n        throw new Error(soljs_abstraction.contract_name + \" has legacy 'default' network artifacts stored within it. Generally these artifacts were a result of running Truffle on a development environment -- in order to store contracts with truffle-contract, all networks must have an identified id. If you're sure this default network represents your development environment, you can ignore processing of the default network by passing `true` as the second argument to this function. However, if you think this network represents artifacts you'd like to keep (i.e., addresses deployed to the main network), you'll need to edit your .sol.js file yourself and change the default network id to be the id of your desired network. For most people, ignoring the default network is the correct option.\");\n      }\n    }\n\n    if (soljs_abstraction.all_networks[network_name].updated_at > latest_network_updated_at) {\n      latest_network = network_name;\n      latest_network_updated_at = soljs_abstraction.all_networks[network_name].updated_at;\n    }\n\n    networks[network_name] = {};\n\n    [\"address\", \"events\", \"links\", \"updated_at\"].forEach(function(key) {\n      networks[network_name][key] = soljs_abstraction.all_networks[network_name][key];\n    })\n  });\n\n  latest_network = soljs_abstraction.all_networks[latest_network] || {};\n\n  var json = {\n    contract_name: soljs_abstraction.contract_name,\n    unlinked_binary: latest_network.unlinked_binary,\n    abi: latest_network.abi,\n    networks: networks,\n    updated_at: latest_network_updated_at == 0 ? undefined : latest_network_updated_at\n  };\n\n  return contract(json);\n};\n\nmodule.exports = contract;\n\nif (typeof window !== \"undefined\") {\n  window.TruffleContract = contract;\n}\n\n},{\"./contract.js\":1,\"truffle-contract-schema\":16}],3:[function(require,module,exports){\n'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n  lookup[i] = code[i]\n  revLookup[code.charCodeAt(i)] = i\n}\n\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction placeHoldersCount (b64) {\n  var len = b64.length\n  if (len % 4 > 0) {\n    throw new Error('Invalid string. Length must be a multiple of 4')\n  }\n\n  // the number of equal signs (place holders)\n  // if there are two placeholders, than the two characters before it\n  // represent one byte\n  // if there is only one, then the three characters before it represent 2 bytes\n  // this is just a cheap hack to not do indexOf twice\n  return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0\n}\n\nfunction byteLength (b64) {\n  // base64 is 4/3 + up to two characters of the original data\n  return b64.length * 3 / 4 - placeHoldersCount(b64)\n}\n\nfunction toByteArray (b64) {\n  var i, j, l, tmp, placeHolders, arr\n  var len = b64.length\n  placeHolders = placeHoldersCount(b64)\n\n  arr = new Arr(len * 3 / 4 - placeHolders)\n\n  // if there are placeholders, only get up to the last complete 4 chars\n  l = placeHolders > 0 ? len - 4 : len\n\n  var L = 0\n\n  for (i = 0, j = 0; i < l; i += 4, j += 3) {\n    tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]\n    arr[L++] = (tmp >> 16) & 0xFF\n    arr[L++] = (tmp >> 8) & 0xFF\n    arr[L++] = tmp & 0xFF\n  }\n\n  if (placeHolders === 2) {\n    tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)\n    arr[L++] = tmp & 0xFF\n  } else if (placeHolders === 1) {\n    tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)\n    arr[L++] = (tmp >> 8) & 0xFF\n    arr[L++] = tmp & 0xFF\n  }\n\n  return arr\n}\n\nfunction tripletToBase64 (num) {\n  return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n  var tmp\n  var output = []\n  for (var i = start; i < end; i += 3) {\n    tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])\n    output.push(tripletToBase64(tmp))\n  }\n  return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n  var tmp\n  var len = uint8.length\n  var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n  var output = ''\n  var parts = []\n  var maxChunkLength = 16383 // must be multiple of 3\n\n  // go through the array every three bytes, we'll deal with trailing stuff later\n  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n    parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n  }\n\n  // pad the end with zeros, but make sure to not forget the extra bytes\n  if (extraBytes === 1) {\n    tmp = uint8[len - 1]\n    output += lookup[tmp >> 2]\n    output += lookup[(tmp << 4) & 0x3F]\n    output += '=='\n  } else if (extraBytes === 2) {\n    tmp = (uint8[len - 2] << 8) + (uint8[len - 1])\n    output += lookup[tmp >> 10]\n    output += lookup[(tmp >> 4) & 0x3F]\n    output += lookup[(tmp << 2) & 0x3F]\n    output += '='\n  }\n\n  parts.push(output)\n\n  return parts.join('')\n}\n\n},{}],4:[function(require,module,exports){\n(function (module, exports) {\n  'use strict';\n\n  // Utils\n  function assert (val, msg) {\n    if (!val) throw new Error(msg || 'Assertion failed');\n  }\n\n  // Could use `inherits` module, but don't want to move from single file\n  // architecture yet.\n  function inherits (ctor, superCtor) {\n    ctor.super_ = superCtor;\n    var TempCtor = function () {};\n    TempCtor.prototype = superCtor.prototype;\n    ctor.prototype = new TempCtor();\n    ctor.prototype.constructor = ctor;\n  }\n\n  // BN\n\n  function BN (number, base, endian) {\n    if (BN.isBN(number)) {\n      return number;\n    }\n\n    this.negative = 0;\n    this.words = null;\n    this.length = 0;\n\n    // Reduction context\n    this.red = null;\n\n    if (number !== null) {\n      if (base === 'le' || base === 'be') {\n        endian = base;\n        base = 10;\n      }\n\n      this._init(number || 0, base || 10, endian || 'be');\n    }\n  }\n  if (typeof module === 'object') {\n    module.exports = BN;\n  } else {\n    exports.BN = BN;\n  }\n\n  BN.BN = BN;\n  BN.wordSize = 26;\n\n  var Buffer;\n  try {\n    Buffer = require('buf' + 'fer').Buffer;\n  } catch (e) {\n  }\n\n  BN.isBN = function isBN (num) {\n    if (num instanceof BN) {\n      return true;\n    }\n\n    return num !== null && typeof num === 'object' &&\n      num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);\n  };\n\n  BN.max = function max (left, right) {\n    if (left.cmp(right) > 0) return left;\n    return right;\n  };\n\n  BN.min = function min (left, right) {\n    if (left.cmp(right) < 0) return left;\n    return right;\n  };\n\n  BN.prototype._init = function init (number, base, endian) {\n    if (typeof number === 'number') {\n      return this._initNumber(number, base, endian);\n    }\n\n    if (typeof number === 'object') {\n      return this._initArray(number, base, endian);\n    }\n\n    if (base === 'hex') {\n      base = 16;\n    }\n    assert(base === (base | 0) && base >= 2 && base <= 36);\n\n    number = number.toString().replace(/\\s+/g, '');\n    var start = 0;\n    if (number[0] === '-') {\n      start++;\n    }\n\n    if (base === 16) {\n      this._parseHex(number, start);\n    } else {\n      this._parseBase(number, base, start);\n    }\n\n    if (number[0] === '-') {\n      this.negative = 1;\n    }\n\n    this.strip();\n\n    if (endian !== 'le') return;\n\n    this._initArray(this.toArray(), base, endian);\n  };\n\n  BN.prototype._initNumber = function _initNumber (number, base, endian) {\n    if (number < 0) {\n      this.negative = 1;\n      number = -number;\n    }\n    if (number < 0x4000000) {\n      this.words = [ number & 0x3ffffff ];\n      this.length = 1;\n    } else if (number < 0x10000000000000) {\n      this.words = [\n        number & 0x3ffffff,\n        (number / 0x4000000) & 0x3ffffff\n      ];\n      this.length = 2;\n    } else {\n      assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)\n      this.words = [\n        number & 0x3ffffff,\n        (number / 0x4000000) & 0x3ffffff,\n        1\n      ];\n      this.length = 3;\n    }\n\n    if (endian !== 'le') return;\n\n    // Reverse the bytes\n    this._initArray(this.toArray(), base, endian);\n  };\n\n  BN.prototype._initArray = function _initArray (number, base, endian) {\n    // Perhaps a Uint8Array\n    assert(typeof number.length === 'number');\n    if (number.length <= 0) {\n      this.words = [ 0 ];\n      this.length = 1;\n      return this;\n    }\n\n    this.length = Math.ceil(number.length / 3);\n    this.words = new Array(this.length);\n    for (var i = 0; i < this.length; i++) {\n      this.words[i] = 0;\n    }\n\n    var j, w;\n    var off = 0;\n    if (endian === 'be') {\n      for (i = number.length - 1, j = 0; i >= 0; i -= 3) {\n        w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);\n        this.words[j] |= (w << off) & 0x3ffffff;\n        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;\n        off += 24;\n        if (off >= 26) {\n          off -= 26;\n          j++;\n        }\n      }\n    } else if (endian === 'le') {\n      for (i = 0, j = 0; i < number.length; i += 3) {\n        w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);\n        this.words[j] |= (w << off) & 0x3ffffff;\n        this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;\n        off += 24;\n        if (off >= 26) {\n          off -= 26;\n          j++;\n        }\n      }\n    }\n    return this.strip();\n  };\n\n  function parseHex (str, start, end) {\n    var r = 0;\n    var len = Math.min(str.length, end);\n    for (var i = start; i < len; i++) {\n      var c = str.charCodeAt(i) - 48;\n\n      r <<= 4;\n\n      // 'a' - 'f'\n      if (c >= 49 && c <= 54) {\n        r |= c - 49 + 0xa;\n\n      // 'A' - 'F'\n      } else if (c >= 17 && c <= 22) {\n        r |= c - 17 + 0xa;\n\n      // '0' - '9'\n      } else {\n        r |= c & 0xf;\n      }\n    }\n    return r;\n  }\n\n  BN.prototype._parseHex = function _parseHex (number, start) {\n    // Create possibly bigger array to ensure that it fits the number\n    this.length = Math.ceil((number.length - start) / 6);\n    this.words = new Array(this.length);\n    for (var i = 0; i < this.length; i++) {\n      this.words[i] = 0;\n    }\n\n    var j, w;\n    // Scan 24-bit chunks and add them to the number\n    var off = 0;\n    for (i = number.length - 6, j = 0; i >= start; i -= 6) {\n      w = parseHex(number, i, i + 6);\n      this.words[j] |= (w << off) & 0x3ffffff;\n      // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb\n      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;\n      off += 24;\n      if (off >= 26) {\n        off -= 26;\n        j++;\n      }\n    }\n    if (i + 6 !== start) {\n      w = parseHex(number, start, i + 6);\n      this.words[j] |= (w << off) & 0x3ffffff;\n      this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;\n    }\n    this.strip();\n  };\n\n  function parseBase (str, start, end, mul) {\n    var r = 0;\n    var len = Math.min(str.length, end);\n    for (var i = start; i < len; i++) {\n      var c = str.charCodeAt(i) - 48;\n\n      r *= mul;\n\n      // 'a'\n      if (c >= 49) {\n        r += c - 49 + 0xa;\n\n      // 'A'\n      } else if (c >= 17) {\n        r += c - 17 + 0xa;\n\n      // '0' - '9'\n      } else {\n        r += c;\n      }\n    }\n    return r;\n  }\n\n  BN.prototype._parseBase = function _parseBase (number, base, start) {\n    // Initialize as zero\n    this.words = [ 0 ];\n    this.length = 1;\n\n    // Find length of limb in base\n    for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {\n      limbLen++;\n    }\n    limbLen--;\n    limbPow = (limbPow / base) | 0;\n\n    var total = number.length - start;\n    var mod = total % limbLen;\n    var end = Math.min(total, total - mod) + start;\n\n    var word = 0;\n    for (var i = start; i < end; i += limbLen) {\n      word = parseBase(number, i, i + limbLen, base);\n\n      this.imuln(limbPow);\n      if (this.words[0] + word < 0x4000000) {\n        this.words[0] += word;\n      } else {\n        this._iaddn(word);\n      }\n    }\n\n    if (mod !== 0) {\n      var pow = 1;\n      word = parseBase(number, i, number.length, base);\n\n      for (i = 0; i < mod; i++) {\n        pow *= base;\n      }\n\n      this.imuln(pow);\n      if (this.words[0] + word < 0x4000000) {\n        this.words[0] += word;\n      } else {\n        this._iaddn(word);\n      }\n    }\n  };\n\n  BN.prototype.copy = function copy (dest) {\n    dest.words = new Array(this.length);\n    for (var i = 0; i < this.length; i++) {\n      dest.words[i] = this.words[i];\n    }\n    dest.length = this.length;\n    dest.negative = this.negative;\n    dest.red = this.red;\n  };\n\n  BN.prototype.clone = function clone () {\n    var r = new BN(null);\n    this.copy(r);\n    return r;\n  };\n\n  BN.prototype._expand = function _expand (size) {\n    while (this.length < size) {\n      this.words[this.length++] = 0;\n    }\n    return this;\n  };\n\n  // Remove leading `0` from `this`\n  BN.prototype.strip = function strip () {\n    while (this.length > 1 && this.words[this.length - 1] === 0) {\n      this.length--;\n    }\n    return this._normSign();\n  };\n\n  BN.prototype._normSign = function _normSign () {\n    // -0 = 0\n    if (this.length === 1 && this.words[0] === 0) {\n      this.negative = 0;\n    }\n    return this;\n  };\n\n  BN.prototype.inspect = function inspect () {\n    return (this.red ? '<BN-R: ' : '<BN: ') + this.toString(16) + '>';\n  };\n\n  /*\n\n  var zeros = [];\n  var groupSizes = [];\n  var groupBases = [];\n\n  var s = '';\n  var i = -1;\n  while (++i < BN.wordSize) {\n    zeros[i] = s;\n    s += '0';\n  }\n  groupSizes[0] = 0;\n  groupSizes[1] = 0;\n  groupBases[0] = 0;\n  groupBases[1] = 0;\n  var base = 2 - 1;\n  while (++base < 36 + 1) {\n    var groupSize = 0;\n    var groupBase = 1;\n    while (groupBase < (1 << BN.wordSize) / base) {\n      groupBase *= base;\n      groupSize += 1;\n    }\n    groupSizes[base] = groupSize;\n    groupBases[base] = groupBase;\n  }\n\n  */\n\n  var zeros = [\n    '',\n    '0',\n    '00',\n    '000',\n    '0000',\n    '00000',\n    '000000',\n    '0000000',\n    '00000000',\n    '000000000',\n    '0000000000',\n    '00000000000',\n    '000000000000',\n    '0000000000000',\n    '00000000000000',\n    '000000000000000',\n    '0000000000000000',\n    '00000000000000000',\n    '000000000000000000',\n    '0000000000000000000',\n    '00000000000000000000',\n    '000000000000000000000',\n    '0000000000000000000000',\n    '00000000000000000000000',\n    '000000000000000000000000',\n    '0000000000000000000000000'\n  ];\n\n  var groupSizes = [\n    0, 0,\n    25, 16, 12, 11, 10, 9, 8,\n    8, 7, 7, 7, 7, 6, 6,\n    6, 6, 6, 6, 6, 5, 5,\n    5, 5, 5, 5, 5, 5, 5,\n    5, 5, 5, 5, 5, 5, 5\n  ];\n\n  var groupBases = [\n    0, 0,\n    33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,\n    43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,\n    16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,\n    6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,\n    24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176\n  ];\n\n  BN.prototype.toString = function toString (base, padding) {\n    base = base || 10;\n    padding = padding | 0 || 1;\n\n    var out;\n    if (base === 16 || base === 'hex') {\n      out = '';\n      var off = 0;\n      var carry = 0;\n      for (var i = 0; i < this.length; i++) {\n        var w = this.words[i];\n        var word = (((w << off) | carry) & 0xffffff).toString(16);\n        carry = (w >>> (24 - off)) & 0xffffff;\n        if (carry !== 0 || i !== this.length - 1) {\n          out = zeros[6 - word.length] + word + out;\n        } else {\n          out = word + out;\n        }\n        off += 2;\n        if (off >= 26) {\n          off -= 26;\n          i--;\n        }\n      }\n      if (carry !== 0) {\n        out = carry.toString(16) + out;\n      }\n      while (out.length % padding !== 0) {\n        out = '0' + out;\n      }\n      if (this.negative !== 0) {\n        out = '-' + out;\n      }\n      return out;\n    }\n\n    if (base === (base | 0) && base >= 2 && base <= 36) {\n      // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));\n      var groupSize = groupSizes[base];\n      // var groupBase = Math.pow(base, groupSize);\n      var groupBase = groupBases[base];\n      out = '';\n      var c = this.clone();\n      c.negative = 0;\n      while (!c.isZero()) {\n        var r = c.modn(groupBase).toString(base);\n        c = c.idivn(groupBase);\n\n        if (!c.isZero()) {\n          out = zeros[groupSize - r.length] + r + out;\n        } else {\n          out = r + out;\n        }\n      }\n      if (this.isZero()) {\n        out = '0' + out;\n      }\n      while (out.length % padding !== 0) {\n        out = '0' + out;\n      }\n      if (this.negative !== 0) {\n        out = '-' + out;\n      }\n      return out;\n    }\n\n    assert(false, 'Base should be between 2 and 36');\n  };\n\n  BN.prototype.toNumber = function toNumber () {\n    var ret = this.words[0];\n    if (this.length === 2) {\n      ret += this.words[1] * 0x4000000;\n    } else if (this.length === 3 && this.words[2] === 0x01) {\n      // NOTE: at this stage it is known that the top bit is set\n      ret += 0x10000000000000 + (this.words[1] * 0x4000000);\n    } else if (this.length > 2) {\n      assert(false, 'Number can only safely store up to 53 bits');\n    }\n    return (this.negative !== 0) ? -ret : ret;\n  };\n\n  BN.prototype.toJSON = function toJSON () {\n    return this.toString(16);\n  };\n\n  BN.prototype.toBuffer = function toBuffer (endian, length) {\n    assert(typeof Buffer !== 'undefined');\n    return this.toArrayLike(Buffer, endian, length);\n  };\n\n  BN.prototype.toArray = function toArray (endian, length) {\n    return this.toArrayLike(Array, endian, length);\n  };\n\n  BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {\n    var byteLength = this.byteLength();\n    var reqLength = length || Math.max(1, byteLength);\n    assert(byteLength <= reqLength, 'byte array longer than desired length');\n    assert(reqLength > 0, 'Requested array length <= 0');\n\n    this.strip();\n    var littleEndian = endian === 'le';\n    var res = new ArrayType(reqLength);\n\n    var b, i;\n    var q = this.clone();\n    if (!littleEndian) {\n      // Assume big-endian\n      for (i = 0; i < reqLength - byteLength; i++) {\n        res[i] = 0;\n      }\n\n      for (i = 0; !q.isZero(); i++) {\n        b = q.andln(0xff);\n        q.iushrn(8);\n\n        res[reqLength - i - 1] = b;\n      }\n    } else {\n      for (i = 0; !q.isZero(); i++) {\n        b = q.andln(0xff);\n        q.iushrn(8);\n\n        res[i] = b;\n      }\n\n      for (; i < reqLength; i++) {\n        res[i] = 0;\n      }\n    }\n\n    return res;\n  };\n\n  if (Math.clz32) {\n    BN.prototype._countBits = function _countBits (w) {\n      return 32 - Math.clz32(w);\n    };\n  } else {\n    BN.prototype._countBits = function _countBits (w) {\n      var t = w;\n      var r = 0;\n      if (t >= 0x1000) {\n        r += 13;\n        t >>>= 13;\n      }\n      if (t >= 0x40) {\n        r += 7;\n        t >>>= 7;\n      }\n      if (t >= 0x8) {\n        r += 4;\n        t >>>= 4;\n      }\n      if (t >= 0x02) {\n        r += 2;\n        t >>>= 2;\n      }\n      return r + t;\n    };\n  }\n\n  BN.prototype._zeroBits = function _zeroBits (w) {\n    // Short-cut\n    if (w === 0) return 26;\n\n    var t = w;\n    var r = 0;\n    if ((t & 0x1fff) === 0) {\n      r += 13;\n      t >>>= 13;\n    }\n    if ((t & 0x7f) === 0) {\n      r += 7;\n      t >>>= 7;\n    }\n    if ((t & 0xf) === 0) {\n      r += 4;\n      t >>>= 4;\n    }\n    if ((t & 0x3) === 0) {\n      r += 2;\n      t >>>= 2;\n    }\n    if ((t & 0x1) === 0) {\n      r++;\n    }\n    return r;\n  };\n\n  // Return number of used bits in a BN\n  BN.prototype.bitLength = function bitLength () {\n    var w = this.words[this.length - 1];\n    var hi = this._countBits(w);\n    return (this.length - 1) * 26 + hi;\n  };\n\n  function toBitArray (num) {\n    var w = new Array(num.bitLength());\n\n    for (var bit = 0; bit < w.length; bit++) {\n      var off = (bit / 26) | 0;\n      var wbit = bit % 26;\n\n      w[bit] = (num.words[off] & (1 << wbit)) >>> wbit;\n    }\n\n    return w;\n  }\n\n  // Number of trailing zero bits\n  BN.prototype.zeroBits = function zeroBits () {\n    if (this.isZero()) return 0;\n\n    var r = 0;\n    for (var i = 0; i < this.length; i++) {\n      var b = this._zeroBits(this.words[i]);\n      r += b;\n      if (b !== 26) break;\n    }\n    return r;\n  };\n\n  BN.prototype.byteLength = function byteLength () {\n    return Math.ceil(this.bitLength() / 8);\n  };\n\n  BN.prototype.toTwos = function toTwos (width) {\n    if (this.negative !== 0) {\n      return this.abs().inotn(width).iaddn(1);\n    }\n    return this.clone();\n  };\n\n  BN.prototype.fromTwos = function fromTwos (width) {\n    if (this.testn(width - 1)) {\n      return this.notn(width).iaddn(1).ineg();\n    }\n    return this.clone();\n  };\n\n  BN.prototype.isNeg = function isNeg () {\n    return this.negative !== 0;\n  };\n\n  // Return negative clone of `this`\n  BN.prototype.neg = function neg () {\n    return this.clone().ineg();\n  };\n\n  BN.prototype.ineg = function ineg () {\n    if (!this.isZero()) {\n      this.negative ^= 1;\n    }\n\n    return this;\n  };\n\n  // Or `num` with `this` in-place\n  BN.prototype.iuor = function iuor (num) {\n    while (this.length < num.length) {\n      this.words[this.length++] = 0;\n    }\n\n    for (var i = 0; i < num.length; i++) {\n      this.words[i] = this.words[i] | num.words[i];\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.ior = function ior (num) {\n    assert((this.negative | num.negative) === 0);\n    return this.iuor(num);\n  };\n\n  // Or `num` with `this`\n  BN.prototype.or = function or (num) {\n    if (this.length > num.length) return this.clone().ior(num);\n    return num.clone().ior(this);\n  };\n\n  BN.prototype.uor = function uor (num) {\n    if (this.length > num.length) return this.clone().iuor(num);\n    return num.clone().iuor(this);\n  };\n\n  // And `num` with `this` in-place\n  BN.prototype.iuand = function iuand (num) {\n    // b = min-length(num, this)\n    var b;\n    if (this.length > num.length) {\n      b = num;\n    } else {\n      b = this;\n    }\n\n    for (var i = 0; i < b.length; i++) {\n      this.words[i] = this.words[i] & num.words[i];\n    }\n\n    this.length = b.length;\n\n    return this.strip();\n  };\n\n  BN.prototype.iand = function iand (num) {\n    assert((this.negative | num.negative) === 0);\n    return this.iuand(num);\n  };\n\n  // And `num` with `this`\n  BN.prototype.and = function and (num) {\n    if (this.length > num.length) return this.clone().iand(num);\n    return num.clone().iand(this);\n  };\n\n  BN.prototype.uand = function uand (num) {\n    if (this.length > num.length) return this.clone().iuand(num);\n    return num.clone().iuand(this);\n  };\n\n  // Xor `num` with `this` in-place\n  BN.prototype.iuxor = function iuxor (num) {\n    // a.length > b.length\n    var a;\n    var b;\n    if (this.length > num.length) {\n      a = this;\n      b = num;\n    } else {\n      a = num;\n      b = this;\n    }\n\n    for (var i = 0; i < b.length; i++) {\n      this.words[i] = a.words[i] ^ b.words[i];\n    }\n\n    if (this !== a) {\n      for (; i < a.length; i++) {\n        this.words[i] = a.words[i];\n      }\n    }\n\n    this.length = a.length;\n\n    return this.strip();\n  };\n\n  BN.prototype.ixor = function ixor (num) {\n    assert((this.negative | num.negative) === 0);\n    return this.iuxor(num);\n  };\n\n  // Xor `num` with `this`\n  BN.prototype.xor = function xor (num) {\n    if (this.length > num.length) return this.clone().ixor(num);\n    return num.clone().ixor(this);\n  };\n\n  BN.prototype.uxor = function uxor (num) {\n    if (this.length > num.length) return this.clone().iuxor(num);\n    return num.clone().iuxor(this);\n  };\n\n  // Not ``this`` with ``width`` bitwidth\n  BN.prototype.inotn = function inotn (width) {\n    assert(typeof width === 'number' && width >= 0);\n\n    var bytesNeeded = Math.ceil(width / 26) | 0;\n    var bitsLeft = width % 26;\n\n    // Extend the buffer with leading zeroes\n    this._expand(bytesNeeded);\n\n    if (bitsLeft > 0) {\n      bytesNeeded--;\n    }\n\n    // Handle complete words\n    for (var i = 0; i < bytesNeeded; i++) {\n      this.words[i] = ~this.words[i] & 0x3ffffff;\n    }\n\n    // Handle the residue\n    if (bitsLeft > 0) {\n      this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));\n    }\n\n    // And remove leading zeroes\n    return this.strip();\n  };\n\n  BN.prototype.notn = function notn (width) {\n    return this.clone().inotn(width);\n  };\n\n  // Set `bit` of `this`\n  BN.prototype.setn = function setn (bit, val) {\n    assert(typeof bit === 'number' && bit >= 0);\n\n    var off = (bit / 26) | 0;\n    var wbit = bit % 26;\n\n    this._expand(off + 1);\n\n    if (val) {\n      this.words[off] = this.words[off] | (1 << wbit);\n    } else {\n      this.words[off] = this.words[off] & ~(1 << wbit);\n    }\n\n    return this.strip();\n  };\n\n  // Add `num` to `this` in-place\n  BN.prototype.iadd = function iadd (num) {\n    var r;\n\n    // negative + positive\n    if (this.negative !== 0 && num.negative === 0) {\n      this.negative = 0;\n      r = this.isub(num);\n      this.negative ^= 1;\n      return this._normSign();\n\n    // positive + negative\n    } else if (this.negative === 0 && num.negative !== 0) {\n      num.negative = 0;\n      r = this.isub(num);\n      num.negative = 1;\n      return r._normSign();\n    }\n\n    // a.length > b.length\n    var a, b;\n    if (this.length > num.length) {\n      a = this;\n      b = num;\n    } else {\n      a = num;\n      b = this;\n    }\n\n    var carry = 0;\n    for (var i = 0; i < b.length; i++) {\n      r = (a.words[i] | 0) + (b.words[i] | 0) + carry;\n      this.words[i] = r & 0x3ffffff;\n      carry = r >>> 26;\n    }\n    for (; carry !== 0 && i < a.length; i++) {\n      r = (a.words[i] | 0) + carry;\n      this.words[i] = r & 0x3ffffff;\n      carry = r >>> 26;\n    }\n\n    this.length = a.length;\n    if (carry !== 0) {\n      this.words[this.length] = carry;\n      this.length++;\n    // Copy the rest of the words\n    } else if (a !== this) {\n      for (; i < a.length; i++) {\n        this.words[i] = a.words[i];\n      }\n    }\n\n    return this;\n  };\n\n  // Add `num` to `this`\n  BN.prototype.add = function add (num) {\n    var res;\n    if (num.negative !== 0 && this.negative === 0) {\n      num.negative = 0;\n      res = this.sub(num);\n      num.negative ^= 1;\n      return res;\n    } else if (num.negative === 0 && this.negative !== 0) {\n      this.negative = 0;\n      res = num.sub(this);\n      this.negative = 1;\n      return res;\n    }\n\n    if (this.length > num.length) return this.clone().iadd(num);\n\n    return num.clone().iadd(this);\n  };\n\n  // Subtract `num` from `this` in-place\n  BN.prototype.isub = function isub (num) {\n    // this - (-num) = this + num\n    if (num.negative !== 0) {\n      num.negative = 0;\n      var r = this.iadd(num);\n      num.negative = 1;\n      return r._normSign();\n\n    // -this - num = -(this + num)\n    } else if (this.negative !== 0) {\n      this.negative = 0;\n      this.iadd(num);\n      this.negative = 1;\n      return this._normSign();\n    }\n\n    // At this point both numbers are positive\n    var cmp = this.cmp(num);\n\n    // Optimization - zeroify\n    if (cmp === 0) {\n      this.negative = 0;\n      this.length = 1;\n      this.words[0] = 0;\n      return this;\n    }\n\n    // a > b\n    var a, b;\n    if (cmp > 0) {\n      a = this;\n      b = num;\n    } else {\n      a = num;\n      b = this;\n    }\n\n    var carry = 0;\n    for (var i = 0; i < b.length; i++) {\n      r = (a.words[i] | 0) - (b.words[i] | 0) + carry;\n      carry = r >> 26;\n      this.words[i] = r & 0x3ffffff;\n    }\n    for (; carry !== 0 && i < a.length; i++) {\n      r = (a.words[i] | 0) + carry;\n      carry = r >> 26;\n      this.words[i] = r & 0x3ffffff;\n    }\n\n    // Copy rest of the words\n    if (carry === 0 && i < a.length && a !== this) {\n      for (; i < a.length; i++) {\n        this.words[i] = a.words[i];\n      }\n    }\n\n    this.length = Math.max(this.length, i);\n\n    if (a !== this) {\n      this.negative = 1;\n    }\n\n    return this.strip();\n  };\n\n  // Subtract `num` from `this`\n  BN.prototype.sub = function sub (num) {\n    return this.clone().isub(num);\n  };\n\n  function smallMulTo (self, num, out) {\n    out.negative = num.negative ^ self.negative;\n    var len = (self.length + num.length) | 0;\n    out.length = len;\n    len = (len - 1) | 0;\n\n    // Peel one iteration (compiler can't do it, because of code complexity)\n    var a = self.words[0] | 0;\n    var b = num.words[0] | 0;\n    var r = a * b;\n\n    var lo = r & 0x3ffffff;\n    var carry = (r / 0x4000000) | 0;\n    out.words[0] = lo;\n\n    for (var k = 1; k < len; k++) {\n      // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n      // note that ncarry could be >= 0x3ffffff\n      var ncarry = carry >>> 26;\n      var rword = carry & 0x3ffffff;\n      var maxJ = Math.min(k, num.length - 1);\n      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {\n        var i = (k - j) | 0;\n        a = self.words[i] | 0;\n        b = num.words[j] | 0;\n        r = a * b + rword;\n        ncarry += (r / 0x4000000) | 0;\n        rword = r & 0x3ffffff;\n      }\n      out.words[k] = rword | 0;\n      carry = ncarry | 0;\n    }\n    if (carry !== 0) {\n      out.words[k] = carry | 0;\n    } else {\n      out.length--;\n    }\n\n    return out.strip();\n  }\n\n  // TODO(indutny): it may be reasonable to omit it for users who don't need\n  // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit\n  // multiplication (like elliptic secp256k1).\n  var comb10MulTo = function comb10MulTo (self, num, out) {\n    var a = self.words;\n    var b = num.words;\n    var o = out.words;\n    var c = 0;\n    var lo;\n    var mid;\n    var hi;\n    var a0 = a[0] | 0;\n    var al0 = a0 & 0x1fff;\n    var ah0 = a0 >>> 13;\n    var a1 = a[1] | 0;\n    var al1 = a1 & 0x1fff;\n    var ah1 = a1 >>> 13;\n    var a2 = a[2] | 0;\n    var al2 = a2 & 0x1fff;\n    var ah2 = a2 >>> 13;\n    var a3 = a[3] | 0;\n    var al3 = a3 & 0x1fff;\n    var ah3 = a3 >>> 13;\n    var a4 = a[4] | 0;\n    var al4 = a4 & 0x1fff;\n    var ah4 = a4 >>> 13;\n    var a5 = a[5] | 0;\n    var al5 = a5 & 0x1fff;\n    var ah5 = a5 >>> 13;\n    var a6 = a[6] | 0;\n    var al6 = a6 & 0x1fff;\n    var ah6 = a6 >>> 13;\n    var a7 = a[7] | 0;\n    var al7 = a7 & 0x1fff;\n    var ah7 = a7 >>> 13;\n    var a8 = a[8] | 0;\n    var al8 = a8 & 0x1fff;\n    var ah8 = a8 >>> 13;\n    var a9 = a[9] | 0;\n    var al9 = a9 & 0x1fff;\n    var ah9 = a9 >>> 13;\n    var b0 = b[0] | 0;\n    var bl0 = b0 & 0x1fff;\n    var bh0 = b0 >>> 13;\n    var b1 = b[1] | 0;\n    var bl1 = b1 & 0x1fff;\n    var bh1 = b1 >>> 13;\n    var b2 = b[2] | 0;\n    var bl2 = b2 & 0x1fff;\n    var bh2 = b2 >>> 13;\n    var b3 = b[3] | 0;\n    var bl3 = b3 & 0x1fff;\n    var bh3 = b3 >>> 13;\n    var b4 = b[4] | 0;\n    var bl4 = b4 & 0x1fff;\n    var bh4 = b4 >>> 13;\n    var b5 = b[5] | 0;\n    var bl5 = b5 & 0x1fff;\n    var bh5 = b5 >>> 13;\n    var b6 = b[6] | 0;\n    var bl6 = b6 & 0x1fff;\n    var bh6 = b6 >>> 13;\n    var b7 = b[7] | 0;\n    var bl7 = b7 & 0x1fff;\n    var bh7 = b7 >>> 13;\n    var b8 = b[8] | 0;\n    var bl8 = b8 & 0x1fff;\n    var bh8 = b8 >>> 13;\n    var b9 = b[9] | 0;\n    var bl9 = b9 & 0x1fff;\n    var bh9 = b9 >>> 13;\n\n    out.negative = self.negative ^ num.negative;\n    out.length = 19;\n    /* k = 0 */\n    lo = Math.imul(al0, bl0);\n    mid = Math.imul(al0, bh0);\n    mid = (mid + Math.imul(ah0, bl0)) | 0;\n    hi = Math.imul(ah0, bh0);\n    var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;\n    w0 &= 0x3ffffff;\n    /* k = 1 */\n    lo = Math.imul(al1, bl0);\n    mid = Math.imul(al1, bh0);\n    mid = (mid + Math.imul(ah1, bl0)) | 0;\n    hi = Math.imul(ah1, bh0);\n    lo = (lo + Math.imul(al0, bl1)) | 0;\n    mid = (mid + Math.imul(al0, bh1)) | 0;\n    mid = (mid + Math.imul(ah0, bl1)) | 0;\n    hi = (hi + Math.imul(ah0, bh1)) | 0;\n    var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;\n    w1 &= 0x3ffffff;\n    /* k = 2 */\n    lo = Math.imul(al2, bl0);\n    mid = Math.imul(al2, bh0);\n    mid = (mid + Math.imul(ah2, bl0)) | 0;\n    hi = Math.imul(ah2, bh0);\n    lo = (lo + Math.imul(al1, bl1)) | 0;\n    mid = (mid + Math.imul(al1, bh1)) | 0;\n    mid = (mid + Math.imul(ah1, bl1)) | 0;\n    hi = (hi + Math.imul(ah1, bh1)) | 0;\n    lo = (lo + Math.imul(al0, bl2)) | 0;\n    mid = (mid + Math.imul(al0, bh2)) | 0;\n    mid = (mid + Math.imul(ah0, bl2)) | 0;\n    hi = (hi + Math.imul(ah0, bh2)) | 0;\n    var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;\n    w2 &= 0x3ffffff;\n    /* k = 3 */\n    lo = Math.imul(al3, bl0);\n    mid = Math.imul(al3, bh0);\n    mid = (mid + Math.imul(ah3, bl0)) | 0;\n    hi = Math.imul(ah3, bh0);\n    lo = (lo + Math.imul(al2, bl1)) | 0;\n    mid = (mid + Math.imul(al2, bh1)) | 0;\n    mid = (mid + Math.imul(ah2, bl1)) | 0;\n    hi = (hi + Math.imul(ah2, bh1)) | 0;\n    lo = (lo + Math.imul(al1, bl2)) | 0;\n    mid = (mid + Math.imul(al1, bh2)) | 0;\n    mid = (mid + Math.imul(ah1, bl2)) | 0;\n    hi = (hi + Math.imul(ah1, bh2)) | 0;\n    lo = (lo + Math.imul(al0, bl3)) | 0;\n    mid = (mid + Math.imul(al0, bh3)) | 0;\n    mid = (mid + Math.imul(ah0, bl3)) | 0;\n    hi = (hi + Math.imul(ah0, bh3)) | 0;\n    var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;\n    w3 &= 0x3ffffff;\n    /* k = 4 */\n    lo = Math.imul(al4, bl0);\n    mid = Math.imul(al4, bh0);\n    mid = (mid + Math.imul(ah4, bl0)) | 0;\n    hi = Math.imul(ah4, bh0);\n    lo = (lo + Math.imul(al3, bl1)) | 0;\n    mid = (mid + Math.imul(al3, bh1)) | 0;\n    mid = (mid + Math.imul(ah3, bl1)) | 0;\n    hi = (hi + Math.imul(ah3, bh1)) | 0;\n    lo = (lo + Math.imul(al2, bl2)) | 0;\n    mid = (mid + Math.imul(al2, bh2)) | 0;\n    mid = (mid + Math.imul(ah2, bl2)) | 0;\n    hi = (hi + Math.imul(ah2, bh2)) | 0;\n    lo = (lo + Math.imul(al1, bl3)) | 0;\n    mid = (mid + Math.imul(al1, bh3)) | 0;\n    mid = (mid + Math.imul(ah1, bl3)) | 0;\n    hi = (hi + Math.imul(ah1, bh3)) | 0;\n    lo = (lo + Math.imul(al0, bl4)) | 0;\n    mid = (mid + Math.imul(al0, bh4)) | 0;\n    mid = (mid + Math.imul(ah0, bl4)) | 0;\n    hi = (hi + Math.imul(ah0, bh4)) | 0;\n    var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;\n    w4 &= 0x3ffffff;\n    /* k = 5 */\n    lo = Math.imul(al5, bl0);\n    mid = Math.imul(al5, bh0);\n    mid = (mid + Math.imul(ah5, bl0)) | 0;\n    hi = Math.imul(ah5, bh0);\n    lo = (lo + Math.imul(al4, bl1)) | 0;\n    mid = (mid + Math.imul(al4, bh1)) | 0;\n    mid = (mid + Math.imul(ah4, bl1)) | 0;\n    hi = (hi + Math.imul(ah4, bh1)) | 0;\n    lo = (lo + Math.imul(al3, bl2)) | 0;\n    mid = (mid + Math.imul(al3, bh2)) | 0;\n    mid = (mid + Math.imul(ah3, bl2)) | 0;\n    hi = (hi + Math.imul(ah3, bh2)) | 0;\n    lo = (lo + Math.imul(al2, bl3)) | 0;\n    mid = (mid + Math.imul(al2, bh3)) | 0;\n    mid = (mid + Math.imul(ah2, bl3)) | 0;\n    hi = (hi + Math.imul(ah2, bh3)) | 0;\n    lo = (lo + Math.imul(al1, bl4)) | 0;\n    mid = (mid + Math.imul(al1, bh4)) | 0;\n    mid = (mid + Math.imul(ah1, bl4)) | 0;\n    hi = (hi + Math.imul(ah1, bh4)) | 0;\n    lo = (lo + Math.imul(al0, bl5)) | 0;\n    mid = (mid + Math.imul(al0, bh5)) | 0;\n    mid = (mid + Math.imul(ah0, bl5)) | 0;\n    hi = (hi + Math.imul(ah0, bh5)) | 0;\n    var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;\n    w5 &= 0x3ffffff;\n    /* k = 6 */\n    lo = Math.imul(al6, bl0);\n    mid = Math.imul(al6, bh0);\n    mid = (mid + Math.imul(ah6, bl0)) | 0;\n    hi = Math.imul(ah6, bh0);\n    lo = (lo + Math.imul(al5, bl1)) | 0;\n    mid = (mid + Math.imul(al5, bh1)) | 0;\n    mid = (mid + Math.imul(ah5, bl1)) | 0;\n    hi = (hi + Math.imul(ah5, bh1)) | 0;\n    lo = (lo + Math.imul(al4, bl2)) | 0;\n    mid = (mid + Math.imul(al4, bh2)) | 0;\n    mid = (mid + Math.imul(ah4, bl2)) | 0;\n    hi = (hi + Math.imul(ah4, bh2)) | 0;\n    lo = (lo + Math.imul(al3, bl3)) | 0;\n    mid = (mid + Math.imul(al3, bh3)) | 0;\n    mid = (mid + Math.imul(ah3, bl3)) | 0;\n    hi = (hi + Math.imul(ah3, bh3)) | 0;\n    lo = (lo + Math.imul(al2, bl4)) | 0;\n    mid = (mid + Math.imul(al2, bh4)) | 0;\n    mid = (mid + Math.imul(ah2, bl4)) | 0;\n    hi = (hi + Math.imul(ah2, bh4)) | 0;\n    lo = (lo + Math.imul(al1, bl5)) | 0;\n    mid = (mid + Math.imul(al1, bh5)) | 0;\n    mid = (mid + Math.imul(ah1, bl5)) | 0;\n    hi = (hi + Math.imul(ah1, bh5)) | 0;\n    lo = (lo + Math.imul(al0, bl6)) | 0;\n    mid = (mid + Math.imul(al0, bh6)) | 0;\n    mid = (mid + Math.imul(ah0, bl6)) | 0;\n    hi = (hi + Math.imul(ah0, bh6)) | 0;\n    var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;\n    w6 &= 0x3ffffff;\n    /* k = 7 */\n    lo = Math.imul(al7, bl0);\n    mid = Math.imul(al7, bh0);\n    mid = (mid + Math.imul(ah7, bl0)) | 0;\n    hi = Math.imul(ah7, bh0);\n    lo = (lo + Math.imul(al6, bl1)) | 0;\n    mid = (mid + Math.imul(al6, bh1)) | 0;\n    mid = (mid + Math.imul(ah6, bl1)) | 0;\n    hi = (hi + Math.imul(ah6, bh1)) | 0;\n    lo = (lo + Math.imul(al5, bl2)) | 0;\n    mid = (mid + Math.imul(al5, bh2)) | 0;\n    mid = (mid + Math.imul(ah5, bl2)) | 0;\n    hi = (hi + Math.imul(ah5, bh2)) | 0;\n    lo = (lo + Math.imul(al4, bl3)) | 0;\n    mid = (mid + Math.imul(al4, bh3)) | 0;\n    mid = (mid + Math.imul(ah4, bl3)) | 0;\n    hi = (hi + Math.imul(ah4, bh3)) | 0;\n    lo = (lo + Math.imul(al3, bl4)) | 0;\n    mid = (mid + Math.imul(al3, bh4)) | 0;\n    mid = (mid + Math.imul(ah3, bl4)) | 0;\n    hi = (hi + Math.imul(ah3, bh4)) | 0;\n    lo = (lo + Math.imul(al2, bl5)) | 0;\n    mid = (mid + Math.imul(al2, bh5)) | 0;\n    mid = (mid + Math.imul(ah2, bl5)) | 0;\n    hi = (hi + Math.imul(ah2, bh5)) | 0;\n    lo = (lo + Math.imul(al1, bl6)) | 0;\n    mid = (mid + Math.imul(al1, bh6)) | 0;\n    mid = (mid + Math.imul(ah1, bl6)) | 0;\n    hi = (hi + Math.imul(ah1, bh6)) | 0;\n    lo = (lo + Math.imul(al0, bl7)) | 0;\n    mid = (mid + Math.imul(al0, bh7)) | 0;\n    mid = (mid + Math.imul(ah0, bl7)) | 0;\n    hi = (hi + Math.imul(ah0, bh7)) | 0;\n    var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;\n    w7 &= 0x3ffffff;\n    /* k = 8 */\n    lo = Math.imul(al8, bl0);\n    mid = Math.imul(al8, bh0);\n    mid = (mid + Math.imul(ah8, bl0)) | 0;\n    hi = Math.imul(ah8, bh0);\n    lo = (lo + Math.imul(al7, bl1)) | 0;\n    mid = (mid + Math.imul(al7, bh1)) | 0;\n    mid = (mid + Math.imul(ah7, bl1)) | 0;\n    hi = (hi + Math.imul(ah7, bh1)) | 0;\n    lo = (lo + Math.imul(al6, bl2)) | 0;\n    mid = (mid + Math.imul(al6, bh2)) | 0;\n    mid = (mid + Math.imul(ah6, bl2)) | 0;\n    hi = (hi + Math.imul(ah6, bh2)) | 0;\n    lo = (lo + Math.imul(al5, bl3)) | 0;\n    mid = (mid + Math.imul(al5, bh3)) | 0;\n    mid = (mid + Math.imul(ah5, bl3)) | 0;\n    hi = (hi + Math.imul(ah5, bh3)) | 0;\n    lo = (lo + Math.imul(al4, bl4)) | 0;\n    mid = (mid + Math.imul(al4, bh4)) | 0;\n    mid = (mid + Math.imul(ah4, bl4)) | 0;\n    hi = (hi + Math.imul(ah4, bh4)) | 0;\n    lo = (lo + Math.imul(al3, bl5)) | 0;\n    mid = (mid + Math.imul(al3, bh5)) | 0;\n    mid = (mid + Math.imul(ah3, bl5)) | 0;\n    hi = (hi + Math.imul(ah3, bh5)) | 0;\n    lo = (lo + Math.imul(al2, bl6)) | 0;\n    mid = (mid + Math.imul(al2, bh6)) | 0;\n    mid = (mid + Math.imul(ah2, bl6)) | 0;\n    hi = (hi + Math.imul(ah2, bh6)) | 0;\n    lo = (lo + Math.imul(al1, bl7)) | 0;\n    mid = (mid + Math.imul(al1, bh7)) | 0;\n    mid = (mid + Math.imul(ah1, bl7)) | 0;\n    hi = (hi + Math.imul(ah1, bh7)) | 0;\n    lo = (lo + Math.imul(al0, bl8)) | 0;\n    mid = (mid + Math.imul(al0, bh8)) | 0;\n    mid = (mid + Math.imul(ah0, bl8)) | 0;\n    hi = (hi + Math.imul(ah0, bh8)) | 0;\n    var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;\n    w8 &= 0x3ffffff;\n    /* k = 9 */\n    lo = Math.imul(al9, bl0);\n    mid = Math.imul(al9, bh0);\n    mid = (mid + Math.imul(ah9, bl0)) | 0;\n    hi = Math.imul(ah9, bh0);\n    lo = (lo + Math.imul(al8, bl1)) | 0;\n    mid = (mid + Math.imul(al8, bh1)) | 0;\n    mid = (mid + Math.imul(ah8, bl1)) | 0;\n    hi = (hi + Math.imul(ah8, bh1)) | 0;\n    lo = (lo + Math.imul(al7, bl2)) | 0;\n    mid = (mid + Math.imul(al7, bh2)) | 0;\n    mid = (mid + Math.imul(ah7, bl2)) | 0;\n    hi = (hi + Math.imul(ah7, bh2)) | 0;\n    lo = (lo + Math.imul(al6, bl3)) | 0;\n    mid = (mid + Math.imul(al6, bh3)) | 0;\n    mid = (mid + Math.imul(ah6, bl3)) | 0;\n    hi = (hi + Math.imul(ah6, bh3)) | 0;\n    lo = (lo + Math.imul(al5, bl4)) | 0;\n    mid = (mid + Math.imul(al5, bh4)) | 0;\n    mid = (mid + Math.imul(ah5, bl4)) | 0;\n    hi = (hi + Math.imul(ah5, bh4)) | 0;\n    lo = (lo + Math.imul(al4, bl5)) | 0;\n    mid = (mid + Math.imul(al4, bh5)) | 0;\n    mid = (mid + Math.imul(ah4, bl5)) | 0;\n    hi = (hi + Math.imul(ah4, bh5)) | 0;\n    lo = (lo + Math.imul(al3, bl6)) | 0;\n    mid = (mid + Math.imul(al3, bh6)) | 0;\n    mid = (mid + Math.imul(ah3, bl6)) | 0;\n    hi = (hi + Math.imul(ah3, bh6)) | 0;\n    lo = (lo + Math.imul(al2, bl7)) | 0;\n    mid = (mid + Math.imul(al2, bh7)) | 0;\n    mid = (mid + Math.imul(ah2, bl7)) | 0;\n    hi = (hi + Math.imul(ah2, bh7)) | 0;\n    lo = (lo + Math.imul(al1, bl8)) | 0;\n    mid = (mid + Math.imul(al1, bh8)) | 0;\n    mid = (mid + Math.imul(ah1, bl8)) | 0;\n    hi = (hi + Math.imul(ah1, bh8)) | 0;\n    lo = (lo + Math.imul(al0, bl9)) | 0;\n    mid = (mid + Math.imul(al0, bh9)) | 0;\n    mid = (mid + Math.imul(ah0, bl9)) | 0;\n    hi = (hi + Math.imul(ah0, bh9)) | 0;\n    var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;\n    w9 &= 0x3ffffff;\n    /* k = 10 */\n    lo = Math.imul(al9, bl1);\n    mid = Math.imul(al9, bh1);\n    mid = (mid + Math.imul(ah9, bl1)) | 0;\n    hi = Math.imul(ah9, bh1);\n    lo = (lo + Math.imul(al8, bl2)) | 0;\n    mid = (mid + Math.imul(al8, bh2)) | 0;\n    mid = (mid + Math.imul(ah8, bl2)) | 0;\n    hi = (hi + Math.imul(ah8, bh2)) | 0;\n    lo = (lo + Math.imul(al7, bl3)) | 0;\n    mid = (mid + Math.imul(al7, bh3)) | 0;\n    mid = (mid + Math.imul(ah7, bl3)) | 0;\n    hi = (hi + Math.imul(ah7, bh3)) | 0;\n    lo = (lo + Math.imul(al6, bl4)) | 0;\n    mid = (mid + Math.imul(al6, bh4)) | 0;\n    mid = (mid + Math.imul(ah6, bl4)) | 0;\n    hi = (hi + Math.imul(ah6, bh4)) | 0;\n    lo = (lo + Math.imul(al5, bl5)) | 0;\n    mid = (mid + Math.imul(al5, bh5)) | 0;\n    mid = (mid + Math.imul(ah5, bl5)) | 0;\n    hi = (hi + Math.imul(ah5, bh5)) | 0;\n    lo = (lo + Math.imul(al4, bl6)) | 0;\n    mid = (mid + Math.imul(al4, bh6)) | 0;\n    mid = (mid + Math.imul(ah4, bl6)) | 0;\n    hi = (hi + Math.imul(ah4, bh6)) | 0;\n    lo = (lo + Math.imul(al3, bl7)) | 0;\n    mid = (mid + Math.imul(al3, bh7)) | 0;\n    mid = (mid + Math.imul(ah3, bl7)) | 0;\n    hi = (hi + Math.imul(ah3, bh7)) | 0;\n    lo = (lo + Math.imul(al2, bl8)) | 0;\n    mid = (mid + Math.imul(al2, bh8)) | 0;\n    mid = (mid + Math.imul(ah2, bl8)) | 0;\n    hi = (hi + Math.imul(ah2, bh8)) | 0;\n    lo = (lo + Math.imul(al1, bl9)) | 0;\n    mid = (mid + Math.imul(al1, bh9)) | 0;\n    mid = (mid + Math.imul(ah1, bl9)) | 0;\n    hi = (hi + Math.imul(ah1, bh9)) | 0;\n    var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;\n    w10 &= 0x3ffffff;\n    /* k = 11 */\n    lo = Math.imul(al9, bl2);\n    mid = Math.imul(al9, bh2);\n    mid = (mid + Math.imul(ah9, bl2)) | 0;\n    hi = Math.imul(ah9, bh2);\n    lo = (lo + Math.imul(al8, bl3)) | 0;\n    mid = (mid + Math.imul(al8, bh3)) | 0;\n    mid = (mid + Math.imul(ah8, bl3)) | 0;\n    hi = (hi + Math.imul(ah8, bh3)) | 0;\n    lo = (lo + Math.imul(al7, bl4)) | 0;\n    mid = (mid + Math.imul(al7, bh4)) | 0;\n    mid = (mid + Math.imul(ah7, bl4)) | 0;\n    hi = (hi + Math.imul(ah7, bh4)) | 0;\n    lo = (lo + Math.imul(al6, bl5)) | 0;\n    mid = (mid + Math.imul(al6, bh5)) | 0;\n    mid = (mid + Math.imul(ah6, bl5)) | 0;\n    hi = (hi + Math.imul(ah6, bh5)) | 0;\n    lo = (lo + Math.imul(al5, bl6)) | 0;\n    mid = (mid + Math.imul(al5, bh6)) | 0;\n    mid = (mid + Math.imul(ah5, bl6)) | 0;\n    hi = (hi + Math.imul(ah5, bh6)) | 0;\n    lo = (lo + Math.imul(al4, bl7)) | 0;\n    mid = (mid + Math.imul(al4, bh7)) | 0;\n    mid = (mid + Math.imul(ah4, bl7)) | 0;\n    hi = (hi + Math.imul(ah4, bh7)) | 0;\n    lo = (lo + Math.imul(al3, bl8)) | 0;\n    mid = (mid + Math.imul(al3, bh8)) | 0;\n    mid = (mid + Math.imul(ah3, bl8)) | 0;\n    hi = (hi + Math.imul(ah3, bh8)) | 0;\n    lo = (lo + Math.imul(al2, bl9)) | 0;\n    mid = (mid + Math.imul(al2, bh9)) | 0;\n    mid = (mid + Math.imul(ah2, bl9)) | 0;\n    hi = (hi + Math.imul(ah2, bh9)) | 0;\n    var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;\n    w11 &= 0x3ffffff;\n    /* k = 12 */\n    lo = Math.imul(al9, bl3);\n    mid = Math.imul(al9, bh3);\n    mid = (mid + Math.imul(ah9, bl3)) | 0;\n    hi = Math.imul(ah9, bh3);\n    lo = (lo + Math.imul(al8, bl4)) | 0;\n    mid = (mid + Math.imul(al8, bh4)) | 0;\n    mid = (mid + Math.imul(ah8, bl4)) | 0;\n    hi = (hi + Math.imul(ah8, bh4)) | 0;\n    lo = (lo + Math.imul(al7, bl5)) | 0;\n    mid = (mid + Math.imul(al7, bh5)) | 0;\n    mid = (mid + Math.imul(ah7, bl5)) | 0;\n    hi = (hi + Math.imul(ah7, bh5)) | 0;\n    lo = (lo + Math.imul(al6, bl6)) | 0;\n    mid = (mid + Math.imul(al6, bh6)) | 0;\n    mid = (mid + Math.imul(ah6, bl6)) | 0;\n    hi = (hi + Math.imul(ah6, bh6)) | 0;\n    lo = (lo + Math.imul(al5, bl7)) | 0;\n    mid = (mid + Math.imul(al5, bh7)) | 0;\n    mid = (mid + Math.imul(ah5, bl7)) | 0;\n    hi = (hi + Math.imul(ah5, bh7)) | 0;\n    lo = (lo + Math.imul(al4, bl8)) | 0;\n    mid = (mid + Math.imul(al4, bh8)) | 0;\n    mid = (mid + Math.imul(ah4, bl8)) | 0;\n    hi = (hi + Math.imul(ah4, bh8)) | 0;\n    lo = (lo + Math.imul(al3, bl9)) | 0;\n    mid = (mid + Math.imul(al3, bh9)) | 0;\n    mid = (mid + Math.imul(ah3, bl9)) | 0;\n    hi = (hi + Math.imul(ah3, bh9)) | 0;\n    var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;\n    w12 &= 0x3ffffff;\n    /* k = 13 */\n    lo = Math.imul(al9, bl4);\n    mid = Math.imul(al9, bh4);\n    mid = (mid + Math.imul(ah9, bl4)) | 0;\n    hi = Math.imul(ah9, bh4);\n    lo = (lo + Math.imul(al8, bl5)) | 0;\n    mid = (mid + Math.imul(al8, bh5)) | 0;\n    mid = (mid + Math.imul(ah8, bl5)) | 0;\n    hi = (hi + Math.imul(ah8, bh5)) | 0;\n    lo = (lo + Math.imul(al7, bl6)) | 0;\n    mid = (mid + Math.imul(al7, bh6)) | 0;\n    mid = (mid + Math.imul(ah7, bl6)) | 0;\n    hi = (hi + Math.imul(ah7, bh6)) | 0;\n    lo = (lo + Math.imul(al6, bl7)) | 0;\n    mid = (mid + Math.imul(al6, bh7)) | 0;\n    mid = (mid + Math.imul(ah6, bl7)) | 0;\n    hi = (hi + Math.imul(ah6, bh7)) | 0;\n    lo = (lo + Math.imul(al5, bl8)) | 0;\n    mid = (mid + Math.imul(al5, bh8)) | 0;\n    mid = (mid + Math.imul(ah5, bl8)) | 0;\n    hi = (hi + Math.imul(ah5, bh8)) | 0;\n    lo = (lo + Math.imul(al4, bl9)) | 0;\n    mid = (mid + Math.imul(al4, bh9)) | 0;\n    mid = (mid + Math.imul(ah4, bl9)) | 0;\n    hi = (hi + Math.imul(ah4, bh9)) | 0;\n    var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;\n    w13 &= 0x3ffffff;\n    /* k = 14 */\n    lo = Math.imul(al9, bl5);\n    mid = Math.imul(al9, bh5);\n    mid = (mid + Math.imul(ah9, bl5)) | 0;\n    hi = Math.imul(ah9, bh5);\n    lo = (lo + Math.imul(al8, bl6)) | 0;\n    mid = (mid + Math.imul(al8, bh6)) | 0;\n    mid = (mid + Math.imul(ah8, bl6)) | 0;\n    hi = (hi + Math.imul(ah8, bh6)) | 0;\n    lo = (lo + Math.imul(al7, bl7)) | 0;\n    mid = (mid + Math.imul(al7, bh7)) | 0;\n    mid = (mid + Math.imul(ah7, bl7)) | 0;\n    hi = (hi + Math.imul(ah7, bh7)) | 0;\n    lo = (lo + Math.imul(al6, bl8)) | 0;\n    mid = (mid + Math.imul(al6, bh8)) | 0;\n    mid = (mid + Math.imul(ah6, bl8)) | 0;\n    hi = (hi + Math.imul(ah6, bh8)) | 0;\n    lo = (lo + Math.imul(al5, bl9)) | 0;\n    mid = (mid + Math.imul(al5, bh9)) | 0;\n    mid = (mid + Math.imul(ah5, bl9)) | 0;\n    hi = (hi + Math.imul(ah5, bh9)) | 0;\n    var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;\n    w14 &= 0x3ffffff;\n    /* k = 15 */\n    lo = Math.imul(al9, bl6);\n    mid = Math.imul(al9, bh6);\n    mid = (mid + Math.imul(ah9, bl6)) | 0;\n    hi = Math.imul(ah9, bh6);\n    lo = (lo + Math.imul(al8, bl7)) | 0;\n    mid = (mid + Math.imul(al8, bh7)) | 0;\n    mid = (mid + Math.imul(ah8, bl7)) | 0;\n    hi = (hi + Math.imul(ah8, bh7)) | 0;\n    lo = (lo + Math.imul(al7, bl8)) | 0;\n    mid = (mid + Math.imul(al7, bh8)) | 0;\n    mid = (mid + Math.imul(ah7, bl8)) | 0;\n    hi = (hi + Math.imul(ah7, bh8)) | 0;\n    lo = (lo + Math.imul(al6, bl9)) | 0;\n    mid = (mid + Math.imul(al6, bh9)) | 0;\n    mid = (mid + Math.imul(ah6, bl9)) | 0;\n    hi = (hi + Math.imul(ah6, bh9)) | 0;\n    var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;\n    w15 &= 0x3ffffff;\n    /* k = 16 */\n    lo = Math.imul(al9, bl7);\n    mid = Math.imul(al9, bh7);\n    mid = (mid + Math.imul(ah9, bl7)) | 0;\n    hi = Math.imul(ah9, bh7);\n    lo = (lo + Math.imul(al8, bl8)) | 0;\n    mid = (mid + Math.imul(al8, bh8)) | 0;\n    mid = (mid + Math.imul(ah8, bl8)) | 0;\n    hi = (hi + Math.imul(ah8, bh8)) | 0;\n    lo = (lo + Math.imul(al7, bl9)) | 0;\n    mid = (mid + Math.imul(al7, bh9)) | 0;\n    mid = (mid + Math.imul(ah7, bl9)) | 0;\n    hi = (hi + Math.imul(ah7, bh9)) | 0;\n    var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;\n    w16 &= 0x3ffffff;\n    /* k = 17 */\n    lo = Math.imul(al9, bl8);\n    mid = Math.imul(al9, bh8);\n    mid = (mid + Math.imul(ah9, bl8)) | 0;\n    hi = Math.imul(ah9, bh8);\n    lo = (lo + Math.imul(al8, bl9)) | 0;\n    mid = (mid + Math.imul(al8, bh9)) | 0;\n    mid = (mid + Math.imul(ah8, bl9)) | 0;\n    hi = (hi + Math.imul(ah8, bh9)) | 0;\n    var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;\n    w17 &= 0x3ffffff;\n    /* k = 18 */\n    lo = Math.imul(al9, bl9);\n    mid = Math.imul(al9, bh9);\n    mid = (mid + Math.imul(ah9, bl9)) | 0;\n    hi = Math.imul(ah9, bh9);\n    var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n    c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;\n    w18 &= 0x3ffffff;\n    o[0] = w0;\n    o[1] = w1;\n    o[2] = w2;\n    o[3] = w3;\n    o[4] = w4;\n    o[5] = w5;\n    o[6] = w6;\n    o[7] = w7;\n    o[8] = w8;\n    o[9] = w9;\n    o[10] = w10;\n    o[11] = w11;\n    o[12] = w12;\n    o[13] = w13;\n    o[14] = w14;\n    o[15] = w15;\n    o[16] = w16;\n    o[17] = w17;\n    o[18] = w18;\n    if (c !== 0) {\n      o[19] = c;\n      out.length++;\n    }\n    return out;\n  };\n\n  // Polyfill comb\n  if (!Math.imul) {\n    comb10MulTo = smallMulTo;\n  }\n\n  function bigMulTo (self, num, out) {\n    out.negative = num.negative ^ self.negative;\n    out.length = self.length + num.length;\n\n    var carry = 0;\n    var hncarry = 0;\n    for (var k = 0; k < out.length - 1; k++) {\n      // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n      // note that ncarry could be >= 0x3ffffff\n      var ncarry = hncarry;\n      hncarry = 0;\n      var rword = carry & 0x3ffffff;\n      var maxJ = Math.min(k, num.length - 1);\n      for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {\n        var i = k - j;\n        var a = self.words[i] | 0;\n        var b = num.words[j] | 0;\n        var r = a * b;\n\n        var lo = r & 0x3ffffff;\n        ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;\n        lo = (lo + rword) | 0;\n        rword = lo & 0x3ffffff;\n        ncarry = (ncarry + (lo >>> 26)) | 0;\n\n        hncarry += ncarry >>> 26;\n        ncarry &= 0x3ffffff;\n      }\n      out.words[k] = rword;\n      carry = ncarry;\n      ncarry = hncarry;\n    }\n    if (carry !== 0) {\n      out.words[k] = carry;\n    } else {\n      out.length--;\n    }\n\n    return out.strip();\n  }\n\n  function jumboMulTo (self, num, out) {\n    var fftm = new FFTM();\n    return fftm.mulp(self, num, out);\n  }\n\n  BN.prototype.mulTo = function mulTo (num, out) {\n    var res;\n    var len = this.length + num.length;\n    if (this.length === 10 && num.length === 10) {\n      res = comb10MulTo(this, num, out);\n    } else if (len < 63) {\n      res = smallMulTo(this, num, out);\n    } else if (len < 1024) {\n      res = bigMulTo(this, num, out);\n    } else {\n      res = jumboMulTo(this, num, out);\n    }\n\n    return res;\n  };\n\n  // Cooley-Tukey algorithm for FFT\n  // slightly revisited to rely on looping instead of recursion\n\n  function FFTM (x, y) {\n    this.x = x;\n    this.y = y;\n  }\n\n  FFTM.prototype.makeRBT = function makeRBT (N) {\n    var t = new Array(N);\n    var l = BN.prototype._countBits(N) - 1;\n    for (var i = 0; i < N; i++) {\n      t[i] = this.revBin(i, l, N);\n    }\n\n    return t;\n  };\n\n  // Returns binary-reversed representation of `x`\n  FFTM.prototype.revBin = function revBin (x, l, N) {\n    if (x === 0 || x === N - 1) return x;\n\n    var rb = 0;\n    for (var i = 0; i < l; i++) {\n      rb |= (x & 1) << (l - i - 1);\n      x >>= 1;\n    }\n\n    return rb;\n  };\n\n  // Performs \"tweedling\" phase, therefore 'emulating'\n  // behaviour of the recursive algorithm\n  FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {\n    for (var i = 0; i < N; i++) {\n      rtws[i] = rws[rbt[i]];\n      itws[i] = iws[rbt[i]];\n    }\n  };\n\n  FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {\n    this.permute(rbt, rws, iws, rtws, itws, N);\n\n    for (var s = 1; s < N; s <<= 1) {\n      var l = s << 1;\n\n      var rtwdf = Math.cos(2 * Math.PI / l);\n      var itwdf = Math.sin(2 * Math.PI / l);\n\n      for (var p = 0; p < N; p += l) {\n        var rtwdf_ = rtwdf;\n        var itwdf_ = itwdf;\n\n        for (var j = 0; j < s; j++) {\n          var re = rtws[p + j];\n          var ie = itws[p + j];\n\n          var ro = rtws[p + j + s];\n          var io = itws[p + j + s];\n\n          var rx = rtwdf_ * ro - itwdf_ * io;\n\n          io = rtwdf_ * io + itwdf_ * ro;\n          ro = rx;\n\n          rtws[p + j] = re + ro;\n          itws[p + j] = ie + io;\n\n          rtws[p + j + s] = re - ro;\n          itws[p + j + s] = ie - io;\n\n          /* jshint maxdepth : false */\n          if (j !== l) {\n            rx = rtwdf * rtwdf_ - itwdf * itwdf_;\n\n            itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;\n            rtwdf_ = rx;\n          }\n        }\n      }\n    }\n  };\n\n  FFTM.prototype.guessLen13b = function guessLen13b (n, m) {\n    var N = Math.max(m, n) | 1;\n    var odd = N & 1;\n    var i = 0;\n    for (N = N / 2 | 0; N; N = N >>> 1) {\n      i++;\n    }\n\n    return 1 << i + 1 + odd;\n  };\n\n  FFTM.prototype.conjugate = function conjugate (rws, iws, N) {\n    if (N <= 1) return;\n\n    for (var i = 0; i < N / 2; i++) {\n      var t = rws[i];\n\n      rws[i] = rws[N - i - 1];\n      rws[N - i - 1] = t;\n\n      t = iws[i];\n\n      iws[i] = -iws[N - i - 1];\n      iws[N - i - 1] = -t;\n    }\n  };\n\n  FFTM.prototype.normalize13b = function normalize13b (ws, N) {\n    var carry = 0;\n    for (var i = 0; i < N / 2; i++) {\n      var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +\n        Math.round(ws[2 * i] / N) +\n        carry;\n\n      ws[i] = w & 0x3ffffff;\n\n      if (w < 0x4000000) {\n        carry = 0;\n      } else {\n        carry = w / 0x4000000 | 0;\n      }\n    }\n\n    return ws;\n  };\n\n  FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {\n    var carry = 0;\n    for (var i = 0; i < len; i++) {\n      carry = carry + (ws[i] | 0);\n\n      rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;\n      rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;\n    }\n\n    // Pad with zeroes\n    for (i = 2 * len; i < N; ++i) {\n      rws[i] = 0;\n    }\n\n    assert(carry === 0);\n    assert((carry & ~0x1fff) === 0);\n  };\n\n  FFTM.prototype.stub = function stub (N) {\n    var ph = new Array(N);\n    for (var i = 0; i < N; i++) {\n      ph[i] = 0;\n    }\n\n    return ph;\n  };\n\n  FFTM.prototype.mulp = function mulp (x, y, out) {\n    var N = 2 * this.guessLen13b(x.length, y.length);\n\n    var rbt = this.makeRBT(N);\n\n    var _ = this.stub(N);\n\n    var rws = new Array(N);\n    var rwst = new Array(N);\n    var iwst = new Array(N);\n\n    var nrws = new Array(N);\n    var nrwst = new Array(N);\n    var niwst = new Array(N);\n\n    var rmws = out.words;\n    rmws.length = N;\n\n    this.convert13b(x.words, x.length, rws, N);\n    this.convert13b(y.words, y.length, nrws, N);\n\n    this.transform(rws, _, rwst, iwst, N, rbt);\n    this.transform(nrws, _, nrwst, niwst, N, rbt);\n\n    for (var i = 0; i < N; i++) {\n      var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];\n      iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];\n      rwst[i] = rx;\n    }\n\n    this.conjugate(rwst, iwst, N);\n    this.transform(rwst, iwst, rmws, _, N, rbt);\n    this.conjugate(rmws, _, N);\n    this.normalize13b(rmws, N);\n\n    out.negative = x.negative ^ y.negative;\n    out.length = x.length + y.length;\n    return out.strip();\n  };\n\n  // Multiply `this` by `num`\n  BN.prototype.mul = function mul (num) {\n    var out = new BN(null);\n    out.words = new Array(this.length + num.length);\n    return this.mulTo(num, out);\n  };\n\n  // Multiply employing FFT\n  BN.prototype.mulf = function mulf (num) {\n    var out = new BN(null);\n    out.words = new Array(this.length + num.length);\n    return jumboMulTo(this, num, out);\n  };\n\n  // In-place Multiplication\n  BN.prototype.imul = function imul (num) {\n    return this.clone().mulTo(num, this);\n  };\n\n  BN.prototype.imuln = function imuln (num) {\n    assert(typeof num === 'number');\n    assert(num < 0x4000000);\n\n    // Carry\n    var carry = 0;\n    for (var i = 0; i < this.length; i++) {\n      var w = (this.words[i] | 0) * num;\n      var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);\n      carry >>= 26;\n      carry += (w / 0x4000000) | 0;\n      // NOTE: lo is 27bit maximum\n      carry += lo >>> 26;\n      this.words[i] = lo & 0x3ffffff;\n    }\n\n    if (carry !== 0) {\n      this.words[i] = carry;\n      this.length++;\n    }\n\n    return this;\n  };\n\n  BN.prototype.muln = function muln (num) {\n    return this.clone().imuln(num);\n  };\n\n  // `this` * `this`\n  BN.prototype.sqr = function sqr () {\n    return this.mul(this);\n  };\n\n  // `this` * `this` in-place\n  BN.prototype.isqr = function isqr () {\n    return this.imul(this.clone());\n  };\n\n  // Math.pow(`this`, `num`)\n  BN.prototype.pow = function pow (num) {\n    var w = toBitArray(num);\n    if (w.length === 0) return new BN(1);\n\n    // Skip leading zeroes\n    var res = this;\n    for (var i = 0; i < w.length; i++, res = res.sqr()) {\n      if (w[i] !== 0) break;\n    }\n\n    if (++i < w.length) {\n      for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {\n        if (w[i] === 0) continue;\n\n        res = res.mul(q);\n      }\n    }\n\n    return res;\n  };\n\n  // Shift-left in-place\n  BN.prototype.iushln = function iushln (bits) {\n    assert(typeof bits === 'number' && bits >= 0);\n    var r = bits % 26;\n    var s = (bits - r) / 26;\n    var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);\n    var i;\n\n    if (r !== 0) {\n      var carry = 0;\n\n      for (i = 0; i < this.length; i++) {\n        var newCarry = this.words[i] & carryMask;\n        var c = ((this.words[i] | 0) - newCarry) << r;\n        this.words[i] = c | carry;\n        carry = newCarry >>> (26 - r);\n      }\n\n      if (carry) {\n        this.words[i] = carry;\n        this.length++;\n      }\n    }\n\n    if (s !== 0) {\n      for (i = this.length - 1; i >= 0; i--) {\n        this.words[i + s] = this.words[i];\n      }\n\n      for (i = 0; i < s; i++) {\n        this.words[i] = 0;\n      }\n\n      this.length += s;\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.ishln = function ishln (bits) {\n    // TODO(indutny): implement me\n    assert(this.negative === 0);\n    return this.iushln(bits);\n  };\n\n  // Shift-right in-place\n  // NOTE: `hint` is a lowest bit before trailing zeroes\n  // NOTE: if `extended` is present - it will be filled with destroyed bits\n  BN.prototype.iushrn = function iushrn (bits, hint, extended) {\n    assert(typeof bits === 'number' && bits >= 0);\n    var h;\n    if (hint) {\n      h = (hint - (hint % 26)) / 26;\n    } else {\n      h = 0;\n    }\n\n    var r = bits % 26;\n    var s = Math.min((bits - r) / 26, this.length);\n    var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);\n    var maskedWords = extended;\n\n    h -= s;\n    h = Math.max(0, h);\n\n    // Extended mode, copy masked part\n    if (maskedWords) {\n      for (var i = 0; i < s; i++) {\n        maskedWords.words[i] = this.words[i];\n      }\n      maskedWords.length = s;\n    }\n\n    if (s === 0) {\n      // No-op, we should not move anything at all\n    } else if (this.length > s) {\n      this.length -= s;\n      for (i = 0; i < this.length; i++) {\n        this.words[i] = this.words[i + s];\n      }\n    } else {\n      this.words[0] = 0;\n      this.length = 1;\n    }\n\n    var carry = 0;\n    for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {\n      var word = this.words[i] | 0;\n      this.words[i] = (carry << (26 - r)) | (word >>> r);\n      carry = word & mask;\n    }\n\n    // Push carried bits as a mask\n    if (maskedWords && carry !== 0) {\n      maskedWords.words[maskedWords.length++] = carry;\n    }\n\n    if (this.length === 0) {\n      this.words[0] = 0;\n      this.length = 1;\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.ishrn = function ishrn (bits, hint, extended) {\n    // TODO(indutny): implement me\n    assert(this.negative === 0);\n    return this.iushrn(bits, hint, extended);\n  };\n\n  // Shift-left\n  BN.prototype.shln = function shln (bits) {\n    return this.clone().ishln(bits);\n  };\n\n  BN.prototype.ushln = function ushln (bits) {\n    return this.clone().iushln(bits);\n  };\n\n  // Shift-right\n  BN.prototype.shrn = function shrn (bits) {\n    return this.clone().ishrn(bits);\n  };\n\n  BN.prototype.ushrn = function ushrn (bits) {\n    return this.clone().iushrn(bits);\n  };\n\n  // Test if n bit is set\n  BN.prototype.testn = function testn (bit) {\n    assert(typeof bit === 'number' && bit >= 0);\n    var r = bit % 26;\n    var s = (bit - r) / 26;\n    var q = 1 << r;\n\n    // Fast case: bit is much higher than all existing words\n    if (this.length <= s) return false;\n\n    // Check bit and return\n    var w = this.words[s];\n\n    return !!(w & q);\n  };\n\n  // Return only lowers bits of number (in-place)\n  BN.prototype.imaskn = function imaskn (bits) {\n    assert(typeof bits === 'number' && bits >= 0);\n    var r = bits % 26;\n    var s = (bits - r) / 26;\n\n    assert(this.negative === 0, 'imaskn works only with positive numbers');\n\n    if (this.length <= s) {\n      return this;\n    }\n\n    if (r !== 0) {\n      s++;\n    }\n    this.length = Math.min(s, this.length);\n\n    if (r !== 0) {\n      var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);\n      this.words[this.length - 1] &= mask;\n    }\n\n    return this.strip();\n  };\n\n  // Return only lowers bits of number\n  BN.prototype.maskn = function maskn (bits) {\n    return this.clone().imaskn(bits);\n  };\n\n  // Add plain number `num` to `this`\n  BN.prototype.iaddn = function iaddn (num) {\n    assert(typeof num === 'number');\n    assert(num < 0x4000000);\n    if (num < 0) return this.isubn(-num);\n\n    // Possible sign change\n    if (this.negative !== 0) {\n      if (this.length === 1 && (this.words[0] | 0) < num) {\n        this.words[0] = num - (this.words[0] | 0);\n        this.negative = 0;\n        return this;\n      }\n\n      this.negative = 0;\n      this.isubn(num);\n      this.negative = 1;\n      return this;\n    }\n\n    // Add without checks\n    return this._iaddn(num);\n  };\n\n  BN.prototype._iaddn = function _iaddn (num) {\n    this.words[0] += num;\n\n    // Carry\n    for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {\n      this.words[i] -= 0x4000000;\n      if (i === this.length - 1) {\n        this.words[i + 1] = 1;\n      } else {\n        this.words[i + 1]++;\n      }\n    }\n    this.length = Math.max(this.length, i + 1);\n\n    return this;\n  };\n\n  // Subtract plain number `num` from `this`\n  BN.prototype.isubn = function isubn (num) {\n    assert(typeof num === 'number');\n    assert(num < 0x4000000);\n    if (num < 0) return this.iaddn(-num);\n\n    if (this.negative !== 0) {\n      this.negative = 0;\n      this.iaddn(num);\n      this.negative = 1;\n      return this;\n    }\n\n    this.words[0] -= num;\n\n    if (this.length === 1 && this.words[0] < 0) {\n      this.words[0] = -this.words[0];\n      this.negative = 1;\n    } else {\n      // Carry\n      for (var i = 0; i < this.length && this.words[i] < 0; i++) {\n        this.words[i] += 0x4000000;\n        this.words[i + 1] -= 1;\n      }\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.addn = function addn (num) {\n    return this.clone().iaddn(num);\n  };\n\n  BN.prototype.subn = function subn (num) {\n    return this.clone().isubn(num);\n  };\n\n  BN.prototype.iabs = function iabs () {\n    this.negative = 0;\n\n    return this;\n  };\n\n  BN.prototype.abs = function abs () {\n    return this.clone().iabs();\n  };\n\n  BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {\n    var len = num.length + shift;\n    var i;\n\n    this._expand(len);\n\n    var w;\n    var carry = 0;\n    for (i = 0; i < num.length; i++) {\n      w = (this.words[i + shift] | 0) + carry;\n      var right = (num.words[i] | 0) * mul;\n      w -= right & 0x3ffffff;\n      carry = (w >> 26) - ((right / 0x4000000) | 0);\n      this.words[i + shift] = w & 0x3ffffff;\n    }\n    for (; i < this.length - shift; i++) {\n      w = (this.words[i + shift] | 0) + carry;\n      carry = w >> 26;\n      this.words[i + shift] = w & 0x3ffffff;\n    }\n\n    if (carry === 0) return this.strip();\n\n    // Subtraction overflow\n    assert(carry === -1);\n    carry = 0;\n    for (i = 0; i < this.length; i++) {\n      w = -(this.words[i] | 0) + carry;\n      carry = w >> 26;\n      this.words[i] = w & 0x3ffffff;\n    }\n    this.negative = 1;\n\n    return this.strip();\n  };\n\n  BN.prototype._wordDiv = function _wordDiv (num, mode) {\n    var shift = this.length - num.length;\n\n    var a = this.clone();\n    var b = num;\n\n    // Normalize\n    var bhi = b.words[b.length - 1] | 0;\n    var bhiBits = this._countBits(bhi);\n    shift = 26 - bhiBits;\n    if (shift !== 0) {\n      b = b.ushln(shift);\n      a.iushln(shift);\n      bhi = b.words[b.length - 1] | 0;\n    }\n\n    // Initialize quotient\n    var m = a.length - b.length;\n    var q;\n\n    if (mode !== 'mod') {\n      q = new BN(null);\n      q.length = m + 1;\n      q.words = new Array(q.length);\n      for (var i = 0; i < q.length; i++) {\n        q.words[i] = 0;\n      }\n    }\n\n    var diff = a.clone()._ishlnsubmul(b, 1, m);\n    if (diff.negative === 0) {\n      a = diff;\n      if (q) {\n        q.words[m] = 1;\n      }\n    }\n\n    for (var j = m - 1; j >= 0; j--) {\n      var qj = (a.words[b.length + j] | 0) * 0x4000000 +\n        (a.words[b.length + j - 1] | 0);\n\n      // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max\n      // (0x7ffffff)\n      qj = Math.min((qj / bhi) | 0, 0x3ffffff);\n\n      a._ishlnsubmul(b, qj, j);\n      while (a.negative !== 0) {\n        qj--;\n        a.negative = 0;\n        a._ishlnsubmul(b, 1, j);\n        if (!a.isZero()) {\n          a.negative ^= 1;\n        }\n      }\n      if (q) {\n        q.words[j] = qj;\n      }\n    }\n    if (q) {\n      q.strip();\n    }\n    a.strip();\n\n    // Denormalize\n    if (mode !== 'div' && shift !== 0) {\n      a.iushrn(shift);\n    }\n\n    return {\n      div: q || null,\n      mod: a\n    };\n  };\n\n  // NOTE: 1) `mode` can be set to `mod` to request mod only,\n  //       to `div` to request div only, or be absent to\n  //       request both div & mod\n  //       2) `positive` is true if unsigned mod is requested\n  BN.prototype.divmod = function divmod (num, mode, positive) {\n    assert(!num.isZero());\n\n    if (this.isZero()) {\n      return {\n        div: new BN(0),\n        mod: new BN(0)\n      };\n    }\n\n    var div, mod, res;\n    if (this.negative !== 0 && num.negative === 0) {\n      res = this.neg().divmod(num, mode);\n\n      if (mode !== 'mod') {\n        div = res.div.neg();\n      }\n\n      if (mode !== 'div') {\n        mod = res.mod.neg();\n        if (positive && mod.negative !== 0) {\n          mod.iadd(num);\n        }\n      }\n\n      return {\n        div: div,\n        mod: mod\n      };\n    }\n\n    if (this.negative === 0 && num.negative !== 0) {\n      res = this.divmod(num.neg(), mode);\n\n      if (mode !== 'mod') {\n        div = res.div.neg();\n      }\n\n      return {\n        div: div,\n        mod: res.mod\n      };\n    }\n\n    if ((this.negative & num.negative) !== 0) {\n      res = this.neg().divmod(num.neg(), mode);\n\n      if (mode !== 'div') {\n        mod = res.mod.neg();\n        if (positive && mod.negative !== 0) {\n          mod.isub(num);\n        }\n      }\n\n      return {\n        div: res.div,\n        mod: mod\n      };\n    }\n\n    // Both numbers are positive at this point\n\n    // Strip both numbers to approximate shift value\n    if (num.length > this.length || this.cmp(num) < 0) {\n      return {\n        div: new BN(0),\n        mod: this\n      };\n    }\n\n    // Very short reduction\n    if (num.length === 1) {\n      if (mode === 'div') {\n        return {\n          div: this.divn(num.words[0]),\n          mod: null\n        };\n      }\n\n      if (mode === 'mod') {\n        return {\n          div: null,\n          mod: new BN(this.modn(num.words[0]))\n        };\n      }\n\n      return {\n        div: this.divn(num.words[0]),\n        mod: new BN(this.modn(num.words[0]))\n      };\n    }\n\n    return this._wordDiv(num, mode);\n  };\n\n  // Find `this` / `num`\n  BN.prototype.div = function div (num) {\n    return this.divmod(num, 'div', false).div;\n  };\n\n  // Find `this` % `num`\n  BN.prototype.mod = function mod (num) {\n    return this.divmod(num, 'mod', false).mod;\n  };\n\n  BN.prototype.umod = function umod (num) {\n    return this.divmod(num, 'mod', true).mod;\n  };\n\n  // Find Round(`this` / `num`)\n  BN.prototype.divRound = function divRound (num) {\n    var dm = this.divmod(num);\n\n    // Fast case - exact division\n    if (dm.mod.isZero()) return dm.div;\n\n    var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;\n\n    var half = num.ushrn(1);\n    var r2 = num.andln(1);\n    var cmp = mod.cmp(half);\n\n    // Round down\n    if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;\n\n    // Round up\n    return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);\n  };\n\n  BN.prototype.modn = function modn (num) {\n    assert(num <= 0x3ffffff);\n    var p = (1 << 26) % num;\n\n    var acc = 0;\n    for (var i = this.length - 1; i >= 0; i--) {\n      acc = (p * acc + (this.words[i] | 0)) % num;\n    }\n\n    return acc;\n  };\n\n  // In-place division by number\n  BN.prototype.idivn = function idivn (num) {\n    assert(num <= 0x3ffffff);\n\n    var carry = 0;\n    for (var i = this.length - 1; i >= 0; i--) {\n      var w = (this.words[i] | 0) + carry * 0x4000000;\n      this.words[i] = (w / num) | 0;\n      carry = w % num;\n    }\n\n    return this.strip();\n  };\n\n  BN.prototype.divn = function divn (num) {\n    return this.clone().idivn(num);\n  };\n\n  BN.prototype.egcd = function egcd (p) {\n    assert(p.negative === 0);\n    assert(!p.isZero());\n\n    var x = this;\n    var y = p.clone();\n\n    if (x.negative !== 0) {\n      x = x.umod(p);\n    } else {\n      x = x.clone();\n    }\n\n    // A * x + B * y = x\n    var A = new BN(1);\n    var B = new BN(0);\n\n    // C * x + D * y = y\n    var C = new BN(0);\n    var D = new BN(1);\n\n    var g = 0;\n\n    while (x.isEven() && y.isEven()) {\n      x.iushrn(1);\n      y.iushrn(1);\n      ++g;\n    }\n\n    var yp = y.clone();\n    var xp = x.clone();\n\n    while (!x.isZero()) {\n      for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n      if (i > 0) {\n        x.iushrn(i);\n        while (i-- > 0) {\n          if (A.isOdd() || B.isOdd()) {\n            A.iadd(yp);\n            B.isub(xp);\n          }\n\n          A.iushrn(1);\n          B.iushrn(1);\n        }\n      }\n\n      for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n      if (j > 0) {\n        y.iushrn(j);\n        while (j-- > 0) {\n          if (C.isOdd() || D.isOdd()) {\n            C.iadd(yp);\n            D.isub(xp);\n          }\n\n          C.iushrn(1);\n          D.iushrn(1);\n        }\n      }\n\n      if (x.cmp(y) >= 0) {\n        x.isub(y);\n        A.isub(C);\n        B.isub(D);\n      } else {\n        y.isub(x);\n        C.isub(A);\n        D.isub(B);\n      }\n    }\n\n    return {\n      a: C,\n      b: D,\n      gcd: y.iushln(g)\n    };\n  };\n\n  // This is reduced incarnation of the binary EEA\n  // above, designated to invert members of the\n  // _prime_ fields F(p) at a maximal speed\n  BN.prototype._invmp = function _invmp (p) {\n    assert(p.negative === 0);\n    assert(!p.isZero());\n\n    var a = this;\n    var b = p.clone();\n\n    if (a.negative !== 0) {\n      a = a.umod(p);\n    } else {\n      a = a.clone();\n    }\n\n    var x1 = new BN(1);\n    var x2 = new BN(0);\n\n    var delta = b.clone();\n\n    while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {\n      for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n      if (i > 0) {\n        a.iushrn(i);\n        while (i-- > 0) {\n          if (x1.isOdd()) {\n            x1.iadd(delta);\n          }\n\n          x1.iushrn(1);\n        }\n      }\n\n      for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n      if (j > 0) {\n        b.iushrn(j);\n        while (j-- > 0) {\n          if (x2.isOdd()) {\n            x2.iadd(delta);\n          }\n\n          x2.iushrn(1);\n        }\n      }\n\n      if (a.cmp(b) >= 0) {\n        a.isub(b);\n        x1.isub(x2);\n      } else {\n        b.isub(a);\n        x2.isub(x1);\n      }\n    }\n\n    var res;\n    if (a.cmpn(1) === 0) {\n      res = x1;\n    } else {\n      res = x2;\n    }\n\n    if (res.cmpn(0) < 0) {\n      res.iadd(p);\n    }\n\n    return res;\n  };\n\n  BN.prototype.gcd = function gcd (num) {\n    if (this.isZero()) return num.abs();\n    if (num.isZero()) return this.abs();\n\n    var a = this.clone();\n    var b = num.clone();\n    a.negative = 0;\n    b.negative = 0;\n\n    // Remove common factor of two\n    for (var shift = 0; a.isEven() && b.isEven(); shift++) {\n      a.iushrn(1);\n      b.iushrn(1);\n    }\n\n    do {\n      while (a.isEven()) {\n        a.iushrn(1);\n      }\n      while (b.isEven()) {\n        b.iushrn(1);\n      }\n\n      var r = a.cmp(b);\n      if (r < 0) {\n        // Swap `a` and `b` to make `a` always bigger than `b`\n        var t = a;\n        a = b;\n        b = t;\n      } else if (r === 0 || b.cmpn(1) === 0) {\n        break;\n      }\n\n      a.isub(b);\n    } while (true);\n\n    return b.iushln(shift);\n  };\n\n  // Invert number in the field F(num)\n  BN.prototype.invm = function invm (num) {\n    return this.egcd(num).a.umod(num);\n  };\n\n  BN.prototype.isEven = function isEven () {\n    return (this.words[0] & 1) === 0;\n  };\n\n  BN.prototype.isOdd = function isOdd () {\n    return (this.words[0] & 1) === 1;\n  };\n\n  // And first word and num\n  BN.prototype.andln = function andln (num) {\n    return this.words[0] & num;\n  };\n\n  // Increment at the bit position in-line\n  BN.prototype.bincn = function bincn (bit) {\n    assert(typeof bit === 'number');\n    var r = bit % 26;\n    var s = (bit - r) / 26;\n    var q = 1 << r;\n\n    // Fast case: bit is much higher than all existing words\n    if (this.length <= s) {\n      this._expand(s + 1);\n      this.words[s] |= q;\n      return this;\n    }\n\n    // Add bit and propagate, if needed\n    var carry = q;\n    for (var i = s; carry !== 0 && i < this.length; i++) {\n      var w = this.words[i] | 0;\n      w += carry;\n      carry = w >>> 26;\n      w &= 0x3ffffff;\n      this.words[i] = w;\n    }\n    if (carry !== 0) {\n      this.words[i] = carry;\n      this.length++;\n    }\n    return this;\n  };\n\n  BN.prototype.isZero = function isZero () {\n    return this.length === 1 && this.words[0] === 0;\n  };\n\n  BN.prototype.cmpn = function cmpn (num) {\n    var negative = num < 0;\n\n    if (this.negative !== 0 && !negative) return -1;\n    if (this.negative === 0 && negative) return 1;\n\n    this.strip();\n\n    var res;\n    if (this.length > 1) {\n      res = 1;\n    } else {\n      if (negative) {\n        num = -num;\n      }\n\n      assert(num <= 0x3ffffff, 'Number is too big');\n\n      var w = this.words[0] | 0;\n      res = w === num ? 0 : w < num ? -1 : 1;\n    }\n    if (this.negative !== 0) return -res | 0;\n    return res;\n  };\n\n  // Compare two numbers and return:\n  // 1 - if `this` > `num`\n  // 0 - if `this` == `num`\n  // -1 - if `this` < `num`\n  BN.prototype.cmp = function cmp (num) {\n    if (this.negative !== 0 && num.negative === 0) return -1;\n    if (this.negative === 0 && num.negative !== 0) return 1;\n\n    var res = this.ucmp(num);\n    if (this.negative !== 0) return -res | 0;\n    return res;\n  };\n\n  // Unsigned comparison\n  BN.prototype.ucmp = function ucmp (num) {\n    // At this point both numbers have the same sign\n    if (this.length > num.length) return 1;\n    if (this.length < num.length) return -1;\n\n    var res = 0;\n    for (var i = this.length - 1; i >= 0; i--) {\n      var a = this.words[i] | 0;\n      var b = num.words[i] | 0;\n\n      if (a === b) continue;\n      if (a < b) {\n        res = -1;\n      } else if (a > b) {\n        res = 1;\n      }\n      break;\n    }\n    return res;\n  };\n\n  BN.prototype.gtn = function gtn (num) {\n    return this.cmpn(num) === 1;\n  };\n\n  BN.prototype.gt = function gt (num) {\n    return this.cmp(num) === 1;\n  };\n\n  BN.prototype.gten = function gten (num) {\n    return this.cmpn(num) >= 0;\n  };\n\n  BN.prototype.gte = function gte (num) {\n    return this.cmp(num) >= 0;\n  };\n\n  BN.prototype.ltn = function ltn (num) {\n    return this.cmpn(num) === -1;\n  };\n\n  BN.prototype.lt = function lt (num) {\n    return this.cmp(num) === -1;\n  };\n\n  BN.prototype.lten = function lten (num) {\n    return this.cmpn(num) <= 0;\n  };\n\n  BN.prototype.lte = function lte (num) {\n    return this.cmp(num) <= 0;\n  };\n\n  BN.prototype.eqn = function eqn (num) {\n    return this.cmpn(num) === 0;\n  };\n\n  BN.prototype.eq = function eq (num) {\n    return this.cmp(num) === 0;\n  };\n\n  //\n  // A reduce context, could be using montgomery or something better, depending\n  // on the `m` itself.\n  //\n  BN.red = function red (num) {\n    return new Red(num);\n  };\n\n  BN.prototype.toRed = function toRed (ctx) {\n    assert(!this.red, 'Already a number in reduction context');\n    assert(this.negative === 0, 'red works only with positives');\n    return ctx.convertTo(this)._forceRed(ctx);\n  };\n\n  BN.prototype.fromRed = function fromRed () {\n    assert(this.red, 'fromRed works only with numbers in reduction context');\n    return this.red.convertFrom(this);\n  };\n\n  BN.prototype._forceRed = function _forceRed (ctx) {\n    this.red = ctx;\n    return this;\n  };\n\n  BN.prototype.forceRed = function forceRed (ctx) {\n    assert(!this.red, 'Already a number in reduction context');\n    return this._forceRed(ctx);\n  };\n\n  BN.prototype.redAdd = function redAdd (num) {\n    assert(this.red, 'redAdd works only with red numbers');\n    return this.red.add(this, num);\n  };\n\n  BN.prototype.redIAdd = function redIAdd (num) {\n    assert(this.red, 'redIAdd works only with red numbers');\n    return this.red.iadd(this, num);\n  };\n\n  BN.prototype.redSub = function redSub (num) {\n    assert(this.red, 'redSub works only with red numbers');\n    return this.red.sub(this, num);\n  };\n\n  BN.prototype.redISub = function redISub (num) {\n    assert(this.red, 'redISub works only with red numbers');\n    return this.red.isub(this, num);\n  };\n\n  BN.prototype.redShl = function redShl (num) {\n    assert(this.red, 'redShl works only with red numbers');\n    return this.red.shl(this, num);\n  };\n\n  BN.prototype.redMul = function redMul (num) {\n    assert(this.red, 'redMul works only with red numbers');\n    this.red._verify2(this, num);\n    return this.red.mul(this, num);\n  };\n\n  BN.prototype.redIMul = function redIMul (num) {\n    assert(this.red, 'redMul works only with red numbers');\n    this.red._verify2(this, num);\n    return this.red.imul(this, num);\n  };\n\n  BN.prototype.redSqr = function redSqr () {\n    assert(this.red, 'redSqr works only with red numbers');\n    this.red._verify1(this);\n    return this.red.sqr(this);\n  };\n\n  BN.prototype.redISqr = function redISqr () {\n    assert(this.red, 'redISqr works only with red numbers');\n    this.red._verify1(this);\n    return this.red.isqr(this);\n  };\n\n  // Square root over p\n  BN.prototype.redSqrt = function redSqrt () {\n    assert(this.red, 'redSqrt works only with red numbers');\n    this.red._verify1(this);\n    return this.red.sqrt(this);\n  };\n\n  BN.prototype.redInvm = function redInvm () {\n    assert(this.red, 'redInvm works only with red numbers');\n    this.red._verify1(this);\n    return this.red.invm(this);\n  };\n\n  // Return negative clone of `this` % `red modulo`\n  BN.prototype.redNeg = function redNeg () {\n    assert(this.red, 'redNeg works only with red numbers');\n    this.red._verify1(this);\n    return this.red.neg(this);\n  };\n\n  BN.prototype.redPow = function redPow (num) {\n    assert(this.red && !num.red, 'redPow(normalNum)');\n    this.red._verify1(this);\n    return this.red.pow(this, num);\n  };\n\n  // Prime numbers with efficient reduction\n  var primes = {\n    k256: null,\n    p224: null,\n    p192: null,\n    p25519: null\n  };\n\n  // Pseudo-Mersenne prime\n  function MPrime (name, p) {\n    // P = 2 ^ N - K\n    this.name = name;\n    this.p = new BN(p, 16);\n    this.n = this.p.bitLength();\n    this.k = new BN(1).iushln(this.n).isub(this.p);\n\n    this.tmp = this._tmp();\n  }\n\n  MPrime.prototype._tmp = function _tmp () {\n    var tmp = new BN(null);\n    tmp.words = new Array(Math.ceil(this.n / 13));\n    return tmp;\n  };\n\n  MPrime.prototype.ireduce = function ireduce (num) {\n    // Assumes that `num` is less than `P^2`\n    // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)\n    var r = num;\n    var rlen;\n\n    do {\n      this.split(r, this.tmp);\n      r = this.imulK(r);\n      r = r.iadd(this.tmp);\n      rlen = r.bitLength();\n    } while (rlen > this.n);\n\n    var cmp = rlen < this.n ? -1 : r.ucmp(this.p);\n    if (cmp === 0) {\n      r.words[0] = 0;\n      r.length = 1;\n    } else if (cmp > 0) {\n      r.isub(this.p);\n    } else {\n      r.strip();\n    }\n\n    return r;\n  };\n\n  MPrime.prototype.split = function split (input, out) {\n    input.iushrn(this.n, 0, out);\n  };\n\n  MPrime.prototype.imulK = function imulK (num) {\n    return num.imul(this.k);\n  };\n\n  function K256 () {\n    MPrime.call(\n      this,\n      'k256',\n      'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');\n  }\n  inherits(K256, MPrime);\n\n  K256.prototype.split = function split (input, output) {\n    // 256 = 9 * 26 + 22\n    var mask = 0x3fffff;\n\n    var outLen = Math.min(input.length, 9);\n    for (var i = 0; i < outLen; i++) {\n      output.words[i] = input.words[i];\n    }\n    output.length = outLen;\n\n    if (input.length <= 9) {\n      input.words[0] = 0;\n      input.length = 1;\n      return;\n    }\n\n    // Shift by 9 limbs\n    var prev = input.words[9];\n    output.words[output.length++] = prev & mask;\n\n    for (i = 10; i < input.length; i++) {\n      var next = input.words[i] | 0;\n      input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);\n      prev = next;\n    }\n    prev >>>= 22;\n    input.words[i - 10] = prev;\n    if (prev === 0 && input.length > 10) {\n      input.length -= 10;\n    } else {\n      input.length -= 9;\n    }\n  };\n\n  K256.prototype.imulK = function imulK (num) {\n    // K = 0x1000003d1 = [ 0x40, 0x3d1 ]\n    num.words[num.length] = 0;\n    num.words[num.length + 1] = 0;\n    num.length += 2;\n\n    // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390\n    var lo = 0;\n    for (var i = 0; i < num.length; i++) {\n      var w = num.words[i] | 0;\n      lo += w * 0x3d1;\n      num.words[i] = lo & 0x3ffffff;\n      lo = w * 0x40 + ((lo / 0x4000000) | 0);\n    }\n\n    // Fast length reduction\n    if (num.words[num.length - 1] === 0) {\n      num.length--;\n      if (num.words[num.length - 1] === 0) {\n        num.length--;\n      }\n    }\n    return num;\n  };\n\n  function P224 () {\n    MPrime.call(\n      this,\n      'p224',\n      'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');\n  }\n  inherits(P224, MPrime);\n\n  function P192 () {\n    MPrime.call(\n      this,\n      'p192',\n      'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');\n  }\n  inherits(P192, MPrime);\n\n  function P25519 () {\n    // 2 ^ 255 - 19\n    MPrime.call(\n      this,\n      '25519',\n      '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');\n  }\n  inherits(P25519, MPrime);\n\n  P25519.prototype.imulK = function imulK (num) {\n    // K = 0x13\n    var carry = 0;\n    for (var i = 0; i < num.length; i++) {\n      var hi = (num.words[i] | 0) * 0x13 + carry;\n      var lo = hi & 0x3ffffff;\n      hi >>>= 26;\n\n      num.words[i] = lo;\n      carry = hi;\n    }\n    if (carry !== 0) {\n      num.words[num.length++] = carry;\n    }\n    return num;\n  };\n\n  // Exported mostly for testing purposes, use plain name instead\n  BN._prime = function prime (name) {\n    // Cached version of prime\n    if (primes[name]) return primes[name];\n\n    var prime;\n    if (name === 'k256') {\n      prime = new K256();\n    } else if (name === 'p224') {\n      prime = new P224();\n    } else if (name === 'p192') {\n      prime = new P192();\n    } else if (name === 'p25519') {\n      prime = new P25519();\n    } else {\n      throw new Error('Unknown prime ' + name);\n    }\n    primes[name] = prime;\n\n    return prime;\n  };\n\n  //\n  // Base reduction engine\n  //\n  function Red (m) {\n    if (typeof m === 'string') {\n      var prime = BN._prime(m);\n      this.m = prime.p;\n      this.prime = prime;\n    } else {\n      assert(m.gtn(1), 'modulus must be greater than 1');\n      this.m = m;\n      this.prime = null;\n    }\n  }\n\n  Red.prototype._verify1 = function _verify1 (a) {\n    assert(a.negative === 0, 'red works only with positives');\n    assert(a.red, 'red works only with red numbers');\n  };\n\n  Red.prototype._verify2 = function _verify2 (a, b) {\n    assert((a.negative | b.negative) === 0, 'red works only with positives');\n    assert(a.red && a.red === b.red,\n      'red works only with red numbers');\n  };\n\n  Red.prototype.imod = function imod (a) {\n    if (this.prime) return this.prime.ireduce(a)._forceRed(this);\n    return a.umod(this.m)._forceRed(this);\n  };\n\n  Red.prototype.neg = function neg (a) {\n    if (a.isZero()) {\n      return a.clone();\n    }\n\n    return this.m.sub(a)._forceRed(this);\n  };\n\n  Red.prototype.add = function add (a, b) {\n    this._verify2(a, b);\n\n    var res = a.add(b);\n    if (res.cmp(this.m) >= 0) {\n      res.isub(this.m);\n    }\n    return res._forceRed(this);\n  };\n\n  Red.prototype.iadd = function iadd (a, b) {\n    this._verify2(a, b);\n\n    var res = a.iadd(b);\n    if (res.cmp(this.m) >= 0) {\n      res.isub(this.m);\n    }\n    return res;\n  };\n\n  Red.prototype.sub = function sub (a, b) {\n    this._verify2(a, b);\n\n    var res = a.sub(b);\n    if (res.cmpn(0) < 0) {\n      res.iadd(this.m);\n    }\n    return res._forceRed(this);\n  };\n\n  Red.prototype.isub = function isub (a, b) {\n    this._verify2(a, b);\n\n    var res = a.isub(b);\n    if (res.cmpn(0) < 0) {\n      res.iadd(this.m);\n    }\n    return res;\n  };\n\n  Red.prototype.shl = function shl (a, num) {\n    this._verify1(a);\n    return this.imod(a.ushln(num));\n  };\n\n  Red.prototype.imul = function imul (a, b) {\n    this._verify2(a, b);\n    return this.imod(a.imul(b));\n  };\n\n  Red.prototype.mul = function mul (a, b) {\n    this._verify2(a, b);\n    return this.imod(a.mul(b));\n  };\n\n  Red.prototype.isqr = function isqr (a) {\n    return this.imul(a, a.clone());\n  };\n\n  Red.prototype.sqr = function sqr (a) {\n    return this.mul(a, a);\n  };\n\n  Red.prototype.sqrt = function sqrt (a) {\n    if (a.isZero()) return a.clone();\n\n    var mod3 = this.m.andln(3);\n    assert(mod3 % 2 === 1);\n\n    // Fast case\n    if (mod3 === 3) {\n      var pow = this.m.add(new BN(1)).iushrn(2);\n      return this.pow(a, pow);\n    }\n\n    // Tonelli-Shanks algorithm (Totally unoptimized and slow)\n    //\n    // Find Q and S, that Q * 2 ^ S = (P - 1)\n    var q = this.m.subn(1);\n    var s = 0;\n    while (!q.isZero() && q.andln(1) === 0) {\n      s++;\n      q.iushrn(1);\n    }\n    assert(!q.isZero());\n\n    var one = new BN(1).toRed(this);\n    var nOne = one.redNeg();\n\n    // Find quadratic non-residue\n    // NOTE: Max is such because of generalized Riemann hypothesis.\n    var lpow = this.m.subn(1).iushrn(1);\n    var z = this.m.bitLength();\n    z = new BN(2 * z * z).toRed(this);\n\n    while (this.pow(z, lpow).cmp(nOne) !== 0) {\n      z.redIAdd(nOne);\n    }\n\n    var c = this.pow(z, q);\n    var r = this.pow(a, q.addn(1).iushrn(1));\n    var t = this.pow(a, q);\n    var m = s;\n    while (t.cmp(one) !== 0) {\n      var tmp = t;\n      for (var i = 0; tmp.cmp(one) !== 0; i++) {\n        tmp = tmp.redSqr();\n      }\n      assert(i < m);\n      var b = this.pow(c, new BN(1).iushln(m - i - 1));\n\n      r = r.redMul(b);\n      c = b.redSqr();\n      t = t.redMul(c);\n      m = i;\n    }\n\n    return r;\n  };\n\n  Red.prototype.invm = function invm (a) {\n    var inv = a._invmp(this.m);\n    if (inv.negative !== 0) {\n      inv.negative = 0;\n      return this.imod(inv).redNeg();\n    } else {\n      return this.imod(inv);\n    }\n  };\n\n  Red.prototype.pow = function pow (a, num) {\n    if (num.isZero()) return new BN(1);\n    if (num.cmpn(1) === 0) return a.clone();\n\n    var windowSize = 4;\n    var wnd = new Array(1 << windowSize);\n    wnd[0] = new BN(1).toRed(this);\n    wnd[1] = a;\n    for (var i = 2; i < wnd.length; i++) {\n      wnd[i] = this.mul(wnd[i - 1], a);\n    }\n\n    var res = wnd[0];\n    var current = 0;\n    var currentLen = 0;\n    var start = num.bitLength() % 26;\n    if (start === 0) {\n      start = 26;\n    }\n\n    for (i = num.length - 1; i >= 0; i--) {\n      var word = num.words[i];\n      for (var j = start - 1; j >= 0; j--) {\n        var bit = (word >> j) & 1;\n        if (res !== wnd[0]) {\n          res = this.sqr(res);\n        }\n\n        if (bit === 0 && current === 0) {\n          currentLen = 0;\n          continue;\n        }\n\n        current <<= 1;\n        current |= bit;\n        currentLen++;\n        if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;\n\n        res = this.mul(res, wnd[current]);\n        currentLen = 0;\n        current = 0;\n      }\n      start = 26;\n    }\n\n    return res;\n  };\n\n  Red.prototype.convertTo = function convertTo (num) {\n    var r = num.umod(this.m);\n\n    return r === num ? r.clone() : r;\n  };\n\n  Red.prototype.convertFrom = function convertFrom (num) {\n    var res = num.clone();\n    res.red = null;\n    return res;\n  };\n\n  //\n  // Montgomery method engine\n  //\n\n  BN.mont = function mont (num) {\n    return new Mont(num);\n  };\n\n  function Mont (m) {\n    Red.call(this, m);\n\n    this.shift = this.m.bitLength();\n    if (this.shift % 26 !== 0) {\n      this.shift += 26 - (this.shift % 26);\n    }\n\n    this.r = new BN(1).iushln(this.shift);\n    this.r2 = this.imod(this.r.sqr());\n    this.rinv = this.r._invmp(this.m);\n\n    this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);\n    this.minv = this.minv.umod(this.r);\n    this.minv = this.r.sub(this.minv);\n  }\n  inherits(Mont, Red);\n\n  Mont.prototype.convertTo = function convertTo (num) {\n    return this.imod(num.ushln(this.shift));\n  };\n\n  Mont.prototype.convertFrom = function convertFrom (num) {\n    var r = this.imod(num.mul(this.rinv));\n    r.red = null;\n    return r;\n  };\n\n  Mont.prototype.imul = function imul (a, b) {\n    if (a.isZero() || b.isZero()) {\n      a.words[0] = 0;\n      a.length = 1;\n      return a;\n    }\n\n    var t = a.imul(b);\n    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n    var u = t.isub(c).iushrn(this.shift);\n    var res = u;\n\n    if (u.cmp(this.m) >= 0) {\n      res = u.isub(this.m);\n    } else if (u.cmpn(0) < 0) {\n      res = u.iadd(this.m);\n    }\n\n    return res._forceRed(this);\n  };\n\n  Mont.prototype.mul = function mul (a, b) {\n    if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);\n\n    var t = a.mul(b);\n    var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n    var u = t.isub(c).iushrn(this.shift);\n    var res = u;\n    if (u.cmp(this.m) >= 0) {\n      res = u.isub(this.m);\n    } else if (u.cmpn(0) < 0) {\n      res = u.iadd(this.m);\n    }\n\n    return res._forceRed(this);\n  };\n\n  Mont.prototype.invm = function invm (a) {\n    // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R\n    var res = this.imod(a._invmp(this.m).mul(this.r2));\n    return res._forceRed(this);\n  };\n})(typeof module === 'undefined' || module, this);\n\n},{}],5:[function(require,module,exports){\n\n},{}],6:[function(require,module,exports){\n/*!\n * The buffer module from node.js, for the browser.\n *\n * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>\n * @license  MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nvar K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n *   === true    Use Uint8Array implementation (fastest)\n *   === false   Print warning and recommend using `buffer` v4.x which has an Object\n *               implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT) {\n  console.error(\n    'This browser lacks typed array (Uint8Array) support which is required by ' +\n    '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.')\n}\n\nfunction typedArraySupport () {\n  // Can typed array instances can be augmented?\n  try {\n    var arr = new Uint8Array(1)\n    arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n    return arr.foo() === 42\n  } catch (e) {\n    return false\n  }\n}\n\nfunction createBuffer (length) {\n  if (length > K_MAX_LENGTH) {\n    throw new RangeError('Invalid typed array length')\n  }\n  // Return an augmented `Uint8Array` instance\n  var buf = new Uint8Array(length)\n  buf.__proto__ = Buffer.prototype\n  return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n  // Common case.\n  if (typeof arg === 'number') {\n    if (typeof encodingOrOffset === 'string') {\n      throw new Error(\n        'If encoding is specified then the first argument must be a string'\n      )\n    }\n    return allocUnsafe(arg)\n  }\n  return from(arg, encodingOrOffset, length)\n}\n\n// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\nif (typeof Symbol !== 'undefined' && Symbol.species &&\n    Buffer[Symbol.species] === Buffer) {\n  Object.defineProperty(Buffer, Symbol.species, {\n    value: null,\n    configurable: true,\n    enumerable: false,\n    writable: false\n  })\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n  if (typeof value === 'number') {\n    throw new TypeError('\"value\" argument must not be a number')\n  }\n\n  if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n    return fromArrayBuffer(value, encodingOrOffset, length)\n  }\n\n  if (typeof value === 'string') {\n    return fromString(value, encodingOrOffset)\n  }\n\n  return fromObject(value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n  return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nBuffer.prototype.__proto__ = Uint8Array.prototype\nBuffer.__proto__ = Uint8Array\n\nfunction assertSize (size) {\n  if (typeof size !== 'number') {\n    throw new TypeError('\"size\" argument must be a number')\n  } else if (size < 0) {\n    throw new RangeError('\"size\" argument must not be negative')\n  }\n}\n\nfunction alloc (size, fill, encoding) {\n  assertSize(size)\n  if (size <= 0) {\n    return createBuffer(size)\n  }\n  if (fill !== undefined) {\n    // Only pay attention to encoding if it's a string. This\n    // prevents accidentally sending in a number that would\n    // be interpretted as a start offset.\n    return typeof encoding === 'string'\n      ? createBuffer(size).fill(fill, encoding)\n      : createBuffer(size).fill(fill)\n  }\n  return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n  return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n  assertSize(size)\n  return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n  return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n  return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n  if (typeof encoding !== 'string' || encoding === '') {\n    encoding = 'utf8'\n  }\n\n  if (!Buffer.isEncoding(encoding)) {\n    throw new TypeError('\"encoding\" must be a valid string encoding')\n  }\n\n  var length = byteLength(string, encoding) | 0\n  var buf = createBuffer(length)\n\n  var actual = buf.write(string, encoding)\n\n  if (actual !== length) {\n    // Writing a hex string, for example, that contains invalid characters will\n    // cause everything after the first invalid character to be ignored. (e.g.\n    // 'abxxcd' will be treated as 'ab')\n    buf = buf.slice(0, actual)\n  }\n\n  return buf\n}\n\nfunction fromArrayLike (array) {\n  var length = array.length < 0 ? 0 : checked(array.length) | 0\n  var buf = createBuffer(length)\n  for (var i = 0; i < length; i += 1) {\n    buf[i] = array[i] & 255\n  }\n  return buf\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n  array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n  if (byteOffset < 0 || array.byteLength < byteOffset) {\n    throw new RangeError('\\'offset\\' is out of bounds')\n  }\n\n  if (array.byteLength < byteOffset + (length || 0)) {\n    throw new RangeError('\\'length\\' is out of bounds')\n  }\n\n  var buf\n  if (byteOffset === undefined && length === undefined) {\n    buf = new Uint8Array(array)\n  } else if (length === undefined) {\n    buf = new Uint8Array(array, byteOffset)\n  } else {\n    buf = new Uint8Array(array, byteOffset, length)\n  }\n\n  // Return an augmented `Uint8Array` instance\n  buf.__proto__ = Buffer.prototype\n  return buf\n}\n\nfunction fromObject (obj) {\n  if (Buffer.isBuffer(obj)) {\n    var len = checked(obj.length) | 0\n    var buf = createBuffer(len)\n\n    if (buf.length === 0) {\n      return buf\n    }\n\n    obj.copy(buf, 0, 0, len)\n    return buf\n  }\n\n  if (obj) {\n    if ((typeof ArrayBuffer !== 'undefined' &&\n        obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n      if (typeof obj.length !== 'number' || isnan(obj.length)) {\n        return createBuffer(0)\n      }\n      return fromArrayLike(obj)\n    }\n\n    if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n      return fromArrayLike(obj.data)\n    }\n  }\n\n  throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n  // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n  // length is NaN (which is otherwise coerced to zero.)\n  if (length >= K_MAX_LENGTH) {\n    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n                         'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n  }\n  return length | 0\n}\n\nfunction SlowBuffer (length) {\n  if (+length != length) { // eslint-disable-line eqeqeq\n    length = 0\n  }\n  return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n  return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n    throw new TypeError('Arguments must be Buffers')\n  }\n\n  if (a === b) return 0\n\n  var x = a.length\n  var y = b.length\n\n  for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n    if (a[i] !== b[i]) {\n      x = a[i]\n      y = b[i]\n      break\n    }\n  }\n\n  if (x < y) return -1\n  if (y < x) return 1\n  return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n  switch (String(encoding).toLowerCase()) {\n    case 'hex':\n    case 'utf8':\n    case 'utf-8':\n    case 'ascii':\n    case 'latin1':\n    case 'binary':\n    case 'base64':\n    case 'ucs2':\n    case 'ucs-2':\n    case 'utf16le':\n    case 'utf-16le':\n      return true\n    default:\n      return false\n  }\n}\n\nBuffer.concat = function concat (list, length) {\n  if (!Array.isArray(list)) {\n    throw new TypeError('\"list\" argument must be an Array of Buffers')\n  }\n\n  if (list.length === 0) {\n    return Buffer.alloc(0)\n  }\n\n  var i\n  if (length === undefined) {\n    length = 0\n    for (i = 0; i < list.length; ++i) {\n      length += list[i].length\n    }\n  }\n\n  var buffer = Buffer.allocUnsafe(length)\n  var pos = 0\n  for (i = 0; i < list.length; ++i) {\n    var buf = list[i]\n    if (!Buffer.isBuffer(buf)) {\n      throw new TypeError('\"list\" argument must be an Array of Buffers')\n    }\n    buf.copy(buffer, pos)\n    pos += buf.length\n  }\n  return buffer\n}\n\nfunction byteLength (string, encoding) {\n  if (Buffer.isBuffer(string)) {\n    return string.length\n  }\n  if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n      (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n    return string.byteLength\n  }\n  if (typeof string !== 'string') {\n    string = '' + string\n  }\n\n  var len = string.length\n  if (len === 0) return 0\n\n  // Use a for loop to avoid recursion\n  var loweredCase = false\n  for (;;) {\n    switch (encoding) {\n      case 'ascii':\n      case 'latin1':\n      case 'binary':\n        return len\n      case 'utf8':\n      case 'utf-8':\n      case undefined:\n        return utf8ToBytes(string).length\n      case 'ucs2':\n      case 'ucs-2':\n      case 'utf16le':\n      case 'utf-16le':\n        return len * 2\n      case 'hex':\n        return len >>> 1\n      case 'base64':\n        return base64ToBytes(string).length\n      default:\n        if (loweredCase) return utf8ToBytes(string).length // assume utf8\n        encoding = ('' + encoding).toLowerCase()\n        loweredCase = true\n    }\n  }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n  var loweredCase = false\n\n  // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n  // property of a typed array.\n\n  // This behaves neither like String nor Uint8Array in that we set start/end\n  // to their upper/lower bounds if the value passed is out of range.\n  // undefined is handled specially as per ECMA-262 6th Edition,\n  // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n  if (start === undefined || start < 0) {\n    start = 0\n  }\n  // Return early if start > this.length. Done here to prevent potential uint32\n  // coercion fail below.\n  if (start > this.length) {\n    return ''\n  }\n\n  if (end === undefined || end > this.length) {\n    end = this.length\n  }\n\n  if (end <= 0) {\n    return ''\n  }\n\n  // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n  end >>>= 0\n  start >>>= 0\n\n  if (end <= start) {\n    return ''\n  }\n\n  if (!encoding) encoding = 'utf8'\n\n  while (true) {\n    switch (encoding) {\n      case 'hex':\n        return hexSlice(this, start, end)\n\n      case 'utf8':\n      case 'utf-8':\n        return utf8Slice(this, start, end)\n\n      case 'ascii':\n        return asciiSlice(this, start, end)\n\n      case 'latin1':\n      case 'binary':\n        return latin1Slice(this, start, end)\n\n      case 'base64':\n        return base64Slice(this, start, end)\n\n      case 'ucs2':\n      case 'ucs-2':\n      case 'utf16le':\n      case 'utf-16le':\n        return utf16leSlice(this, start, end)\n\n      default:\n        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n        encoding = (encoding + '').toLowerCase()\n        loweredCase = true\n    }\n  }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n  var i = b[n]\n  b[n] = b[m]\n  b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n  var len = this.length\n  if (len % 2 !== 0) {\n    throw new RangeError('Buffer size must be a multiple of 16-bits')\n  }\n  for (var i = 0; i < len; i += 2) {\n    swap(this, i, i + 1)\n  }\n  return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n  var len = this.length\n  if (len % 4 !== 0) {\n    throw new RangeError('Buffer size must be a multiple of 32-bits')\n  }\n  for (var i = 0; i < len; i += 4) {\n    swap(this, i, i + 3)\n    swap(this, i + 1, i + 2)\n  }\n  return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n  var len = this.length\n  if (len % 8 !== 0) {\n    throw new RangeError('Buffer size must be a multiple of 64-bits')\n  }\n  for (var i = 0; i < len; i += 8) {\n    swap(this, i, i + 7)\n    swap(this, i + 1, i + 6)\n    swap(this, i + 2, i + 5)\n    swap(this, i + 3, i + 4)\n  }\n  return this\n}\n\nBuffer.prototype.toString = function toString () {\n  var length = this.length\n  if (length === 0) return ''\n  if (arguments.length === 0) return utf8Slice(this, 0, length)\n  return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n  if (this === b) return true\n  return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n  var str = ''\n  var max = exports.INSPECT_MAX_BYTES\n  if (this.length > 0) {\n    str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n    if (this.length > max) str += ' ... '\n  }\n  return '<Buffer ' + str + '>'\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n  if (!Buffer.isBuffer(target)) {\n    throw new TypeError('Argument must be a Buffer')\n  }\n\n  if (start === undefined) {\n    start = 0\n  }\n  if (end === undefined) {\n    end = target ? target.length : 0\n  }\n  if (thisStart === undefined) {\n    thisStart = 0\n  }\n  if (thisEnd === undefined) {\n    thisEnd = this.length\n  }\n\n  if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n    throw new RangeError('out of range index')\n  }\n\n  if (thisStart >= thisEnd && start >= end) {\n    return 0\n  }\n  if (thisStart >= thisEnd) {\n    return -1\n  }\n  if (start >= end) {\n    return 1\n  }\n\n  start >>>= 0\n  end >>>= 0\n  thisStart >>>= 0\n  thisEnd >>>= 0\n\n  if (this === target) return 0\n\n  var x = thisEnd - thisStart\n  var y = end - start\n  var len = Math.min(x, y)\n\n  var thisCopy = this.slice(thisStart, thisEnd)\n  var targetCopy = target.slice(start, end)\n\n  for (var i = 0; i < len; ++i) {\n    if (thisCopy[i] !== targetCopy[i]) {\n      x = thisCopy[i]\n      y = targetCopy[i]\n      break\n    }\n  }\n\n  if (x < y) return -1\n  if (y < x) return 1\n  return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n  // Empty buffer means no match\n  if (buffer.length === 0) return -1\n\n  // Normalize byteOffset\n  if (typeof byteOffset === 'string') {\n    encoding = byteOffset\n    byteOffset = 0\n  } else if (byteOffset > 0x7fffffff) {\n    byteOffset = 0x7fffffff\n  } else if (byteOffset < -0x80000000) {\n    byteOffset = -0x80000000\n  }\n  byteOffset = +byteOffset  // Coerce to Number.\n  if (isNaN(byteOffset)) {\n    // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n    byteOffset = dir ? 0 : (buffer.length - 1)\n  }\n\n  // Normalize byteOffset: negative offsets start from the end of the buffer\n  if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n  if (byteOffset >= buffer.length) {\n    if (dir) return -1\n    else byteOffset = buffer.length - 1\n  } else if (byteOffset < 0) {\n    if (dir) byteOffset = 0\n    else return -1\n  }\n\n  // Normalize val\n  if (typeof val === 'string') {\n    val = Buffer.from(val, encoding)\n  }\n\n  // Finally, search either indexOf (if dir is true) or lastIndexOf\n  if (Buffer.isBuffer(val)) {\n    // Special case: looking for empty string/buffer always fails\n    if (val.length === 0) {\n      return -1\n    }\n    return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n  } else if (typeof val === 'number') {\n    val = val & 0xFF // Search for a byte value [0-255]\n    if (typeof Uint8Array.prototype.indexOf === 'function') {\n      if (dir) {\n        return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n      } else {\n        return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n      }\n    }\n    return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n  }\n\n  throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n  var indexSize = 1\n  var arrLength = arr.length\n  var valLength = val.length\n\n  if (encoding !== undefined) {\n    encoding = String(encoding).toLowerCase()\n    if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n        encoding === 'utf16le' || encoding === 'utf-16le') {\n      if (arr.length < 2 || val.length < 2) {\n        return -1\n      }\n      indexSize = 2\n      arrLength /= 2\n      valLength /= 2\n      byteOffset /= 2\n    }\n  }\n\n  function read (buf, i) {\n    if (indexSize === 1) {\n      return buf[i]\n    } else {\n      return buf.readUInt16BE(i * indexSize)\n    }\n  }\n\n  var i\n  if (dir) {\n    var foundIndex = -1\n    for (i = byteOffset; i < arrLength; i++) {\n      if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n        if (foundIndex === -1) foundIndex = i\n        if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n      } else {\n        if (foundIndex !== -1) i -= i - foundIndex\n        foundIndex = -1\n      }\n    }\n  } else {\n    if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n    for (i = byteOffset; i >= 0; i--) {\n      var found = true\n      for (var j = 0; j < valLength; j++) {\n        if (read(arr, i + j) !== read(val, j)) {\n          found = false\n          break\n        }\n      }\n      if (found) return i\n    }\n  }\n\n  return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n  return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n  return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n  return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n  offset = Number(offset) || 0\n  var remaining = buf.length - offset\n  if (!length) {\n    length = remaining\n  } else {\n    length = Number(length)\n    if (length > remaining) {\n      length = remaining\n    }\n  }\n\n  // must be an even number of digits\n  var strLen = string.length\n  if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n  if (length > strLen / 2) {\n    length = strLen / 2\n  }\n  for (var i = 0; i < length; ++i) {\n    var parsed = parseInt(string.substr(i * 2, 2), 16)\n    if (isNaN(parsed)) return i\n    buf[offset + i] = parsed\n  }\n  return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n  return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n  return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n  return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n  return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n  return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n  // Buffer#write(string)\n  if (offset === undefined) {\n    encoding = 'utf8'\n    length = this.length\n    offset = 0\n  // Buffer#write(string, encoding)\n  } else if (length === undefined && typeof offset === 'string') {\n    encoding = offset\n    length = this.length\n    offset = 0\n  // Buffer#write(string, offset[, length][, encoding])\n  } else if (isFinite(offset)) {\n    offset = offset >>> 0\n    if (isFinite(length)) {\n      length = length >>> 0\n      if (encoding === undefined) encoding = 'utf8'\n    } else {\n      encoding = length\n      length = undefined\n    }\n  // legacy write(string, encoding, offset, length) - remove in v0.13\n  } else {\n    throw new Error(\n      'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n    )\n  }\n\n  var remaining = this.length - offset\n  if (length === undefined || length > remaining) length = remaining\n\n  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n    throw new RangeError('Attempt to write outside buffer bounds')\n  }\n\n  if (!encoding) encoding = 'utf8'\n\n  var loweredCase = false\n  for (;;) {\n    switch (encoding) {\n      case 'hex':\n        return hexWrite(this, string, offset, length)\n\n      case 'utf8':\n      case 'utf-8':\n        return utf8Write(this, string, offset, length)\n\n      case 'ascii':\n        return asciiWrite(this, string, offset, length)\n\n      case 'latin1':\n      case 'binary':\n        return latin1Write(this, string, offset, length)\n\n      case 'base64':\n        // Warning: maxLength not taken into account in base64Write\n        return base64Write(this, string, offset, length)\n\n      case 'ucs2':\n      case 'ucs-2':\n      case 'utf16le':\n      case 'utf-16le':\n        return ucs2Write(this, string, offset, length)\n\n      default:\n        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n        encoding = ('' + encoding).toLowerCase()\n        loweredCase = true\n    }\n  }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n  return {\n    type: 'Buffer',\n    data: Array.prototype.slice.call(this._arr || this, 0)\n  }\n}\n\nfunction base64Slice (buf, start, end) {\n  if (start === 0 && end === buf.length) {\n    return base64.fromByteArray(buf)\n  } else {\n    return base64.fromByteArray(buf.slice(start, end))\n  }\n}\n\nfunction utf8Slice (buf, start, end) {\n  end = Math.min(buf.length, end)\n  var res = []\n\n  var i = start\n  while (i < end) {\n    var firstByte = buf[i]\n    var codePoint = null\n    var bytesPerSequence = (firstByte > 0xEF) ? 4\n      : (firstByte > 0xDF) ? 3\n      : (firstByte > 0xBF) ? 2\n      : 1\n\n    if (i + bytesPerSequence <= end) {\n      var secondByte, thirdByte, fourthByte, tempCodePoint\n\n      switch (bytesPerSequence) {\n        case 1:\n          if (firstByte < 0x80) {\n            codePoint = firstByte\n          }\n          break\n        case 2:\n          secondByte = buf[i + 1]\n          if ((secondByte & 0xC0) === 0x80) {\n            tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n            if (tempCodePoint > 0x7F) {\n              codePoint = tempCodePoint\n            }\n          }\n          break\n        case 3:\n          secondByte = buf[i + 1]\n          thirdByte = buf[i + 2]\n          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n            tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n            if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n              codePoint = tempCodePoint\n            }\n          }\n          break\n        case 4:\n          secondByte = buf[i + 1]\n          thirdByte = buf[i + 2]\n          fourthByte = buf[i + 3]\n          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n            tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n            if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n              codePoint = tempCodePoint\n            }\n          }\n      }\n    }\n\n    if (codePoint === null) {\n      // we did not generate a valid codePoint so insert a\n      // replacement char (U+FFFD) and advance only 1 byte\n      codePoint = 0xFFFD\n      bytesPerSequence = 1\n    } else if (codePoint > 0xFFFF) {\n      // encode to utf16 (surrogate pair dance)\n      codePoint -= 0x10000\n      res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n      codePoint = 0xDC00 | codePoint & 0x3FF\n    }\n\n    res.push(codePoint)\n    i += bytesPerSequence\n  }\n\n  return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n  var len = codePoints.length\n  if (len <= MAX_ARGUMENTS_LENGTH) {\n    return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n  }\n\n  // Decode in chunks to avoid \"call stack size exceeded\".\n  var res = ''\n  var i = 0\n  while (i < len) {\n    res += String.fromCharCode.apply(\n      String,\n      codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n    )\n  }\n  return res\n}\n\nfunction asciiSlice (buf, start, end) {\n  var ret = ''\n  end = Math.min(buf.length, end)\n\n  for (var i = start; i < end; ++i) {\n    ret += String.fromCharCode(buf[i] & 0x7F)\n  }\n  return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n  var ret = ''\n  end = Math.min(buf.length, end)\n\n  for (var i = start; i < end; ++i) {\n    ret += String.fromCharCode(buf[i])\n  }\n  return ret\n}\n\nfunction hexSlice (buf, start, end) {\n  var len = buf.length\n\n  if (!start || start < 0) start = 0\n  if (!end || end < 0 || end > len) end = len\n\n  var out = ''\n  for (var i = start; i < end; ++i) {\n    out += toHex(buf[i])\n  }\n  return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n  var bytes = buf.slice(start, end)\n  var res = ''\n  for (var i = 0; i < bytes.length; i += 2) {\n    res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n  }\n  return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n  var len = this.length\n  start = ~~start\n  end = end === undefined ? len : ~~end\n\n  if (start < 0) {\n    start += len\n    if (start < 0) start = 0\n  } else if (start > len) {\n    start = len\n  }\n\n  if (end < 0) {\n    end += len\n    if (end < 0) end = 0\n  } else if (end > len) {\n    end = len\n  }\n\n  if (end < start) end = start\n\n  var newBuf = this.subarray(start, end)\n  // Return an augmented `Uint8Array` instance\n  newBuf.__proto__ = Buffer.prototype\n  return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n  if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n  var val = this[offset]\n  var mul = 1\n  var i = 0\n  while (++i < byteLength && (mul *= 0x100)) {\n    val += this[offset + i] * mul\n  }\n\n  return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) {\n    checkOffset(offset, byteLength, this.length)\n  }\n\n  var val = this[offset + --byteLength]\n  var mul = 1\n  while (byteLength > 0 && (mul *= 0x100)) {\n    val += this[offset + --byteLength] * mul\n  }\n\n  return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 1, this.length)\n  return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return ((this[offset]) |\n      (this[offset + 1] << 8) |\n      (this[offset + 2] << 16)) +\n      (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return (this[offset] * 0x1000000) +\n    ((this[offset + 1] << 16) |\n    (this[offset + 2] << 8) |\n    this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n  var val = this[offset]\n  var mul = 1\n  var i = 0\n  while (++i < byteLength && (mul *= 0x100)) {\n    val += this[offset + i] * mul\n  }\n  mul *= 0x80\n\n  if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n  return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n  var i = byteLength\n  var mul = 1\n  var val = this[offset + --i]\n  while (i > 0 && (mul *= 0x100)) {\n    val += this[offset + --i] * mul\n  }\n  mul *= 0x80\n\n  if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n  return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 1, this.length)\n  if (!(this[offset] & 0x80)) return (this[offset])\n  return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  var val = this[offset] | (this[offset + 1] << 8)\n  return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 2, this.length)\n  var val = this[offset + 1] | (this[offset] << 8)\n  return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return (this[offset]) |\n    (this[offset + 1] << 8) |\n    (this[offset + 2] << 16) |\n    (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n\n  return (this[offset] << 24) |\n    (this[offset + 1] << 16) |\n    (this[offset + 2] << 8) |\n    (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n  return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 4, this.length)\n  return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 8, this.length)\n  return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n  offset = offset >>> 0\n  if (!noAssert) checkOffset(offset, 8, this.length)\n  return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n  if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n  if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n  if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) {\n    var maxBytes = Math.pow(2, 8 * byteLength) - 1\n    checkInt(this, value, offset, byteLength, maxBytes, 0)\n  }\n\n  var mul = 1\n  var i = 0\n  this[offset] = value & 0xFF\n  while (++i < byteLength && (mul *= 0x100)) {\n    this[offset + i] = (value / mul) & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  byteLength = byteLength >>> 0\n  if (!noAssert) {\n    var maxBytes = Math.pow(2, 8 * byteLength) - 1\n    checkInt(this, value, offset, byteLength, maxBytes, 0)\n  }\n\n  var i = byteLength - 1\n  var mul = 1\n  this[offset + i] = value & 0xFF\n  while (--i >= 0 && (mul *= 0x100)) {\n    this[offset + i] = (value / mul) & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n  this[offset] = (value & 0xff)\n  return offset + 1\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n  this[offset] = (value & 0xff)\n  this[offset + 1] = (value >>> 8)\n  return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n  this[offset] = (value >>> 8)\n  this[offset + 1] = (value & 0xff)\n  return offset + 2\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n  this[offset + 3] = (value >>> 24)\n  this[offset + 2] = (value >>> 16)\n  this[offset + 1] = (value >>> 8)\n  this[offset] = (value & 0xff)\n  return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n  this[offset] = (value >>> 24)\n  this[offset + 1] = (value >>> 16)\n  this[offset + 2] = (value >>> 8)\n  this[offset + 3] = (value & 0xff)\n  return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    var limit = Math.pow(2, 8 * byteLength - 1)\n\n    checkInt(this, value, offset, byteLength, limit - 1, -limit)\n  }\n\n  var i = 0\n  var mul = 1\n  var sub = 0\n  this[offset] = value & 0xFF\n  while (++i < byteLength && (mul *= 0x100)) {\n    if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n      sub = 1\n    }\n    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    var limit = Math.pow(2, 8 * byteLength - 1)\n\n    checkInt(this, value, offset, byteLength, limit - 1, -limit)\n  }\n\n  var i = byteLength - 1\n  var mul = 1\n  var sub = 0\n  this[offset + i] = value & 0xFF\n  while (--i >= 0 && (mul *= 0x100)) {\n    if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n      sub = 1\n    }\n    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n  }\n\n  return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n  if (value < 0) value = 0xff + value + 1\n  this[offset] = (value & 0xff)\n  return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n  this[offset] = (value & 0xff)\n  this[offset + 1] = (value >>> 8)\n  return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n  this[offset] = (value >>> 8)\n  this[offset + 1] = (value & 0xff)\n  return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n  this[offset] = (value & 0xff)\n  this[offset + 1] = (value >>> 8)\n  this[offset + 2] = (value >>> 16)\n  this[offset + 3] = (value >>> 24)\n  return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n  if (value < 0) value = 0xffffffff + value + 1\n  this[offset] = (value >>> 24)\n  this[offset + 1] = (value >>> 16)\n  this[offset + 2] = (value >>> 8)\n  this[offset + 3] = (value & 0xff)\n  return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n  if (offset + ext > buf.length) throw new RangeError('Index out of range')\n  if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n  }\n  ieee754.write(buf, value, offset, littleEndian, 23, 4)\n  return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n  return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n  return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n  value = +value\n  offset = offset >>> 0\n  if (!noAssert) {\n    checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n  }\n  ieee754.write(buf, value, offset, littleEndian, 52, 8)\n  return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n  return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n  return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n  if (!start) start = 0\n  if (!end && end !== 0) end = this.length\n  if (targetStart >= target.length) targetStart = target.length\n  if (!targetStart) targetStart = 0\n  if (end > 0 && end < start) end = start\n\n  // Copy 0 bytes; we're done\n  if (end === start) return 0\n  if (target.length === 0 || this.length === 0) return 0\n\n  // Fatal error conditions\n  if (targetStart < 0) {\n    throw new RangeError('targetStart out of bounds')\n  }\n  if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n  if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n  // Are we oob?\n  if (end > this.length) end = this.length\n  if (target.length - targetStart < end - start) {\n    end = target.length - targetStart + start\n  }\n\n  var len = end - start\n  var i\n\n  if (this === target && start < targetStart && targetStart < end) {\n    // descending copy from end\n    for (i = len - 1; i >= 0; --i) {\n      target[i + targetStart] = this[i + start]\n    }\n  } else if (len < 1000) {\n    // ascending copy from start\n    for (i = 0; i < len; ++i) {\n      target[i + targetStart] = this[i + start]\n    }\n  } else {\n    Uint8Array.prototype.set.call(\n      target,\n      this.subarray(start, start + len),\n      targetStart\n    )\n  }\n\n  return len\n}\n\n// Usage:\n//    buffer.fill(number[, offset[, end]])\n//    buffer.fill(buffer[, offset[, end]])\n//    buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n  // Handle string cases:\n  if (typeof val === 'string') {\n    if (typeof start === 'string') {\n      encoding = start\n      start = 0\n      end = this.length\n    } else if (typeof end === 'string') {\n      encoding = end\n      end = this.length\n    }\n    if (val.length === 1) {\n      var code = val.charCodeAt(0)\n      if (code < 256) {\n        val = code\n      }\n    }\n    if (encoding !== undefined && typeof encoding !== 'string') {\n      throw new TypeError('encoding must be a string')\n    }\n    if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n      throw new TypeError('Unknown encoding: ' + encoding)\n    }\n  } else if (typeof val === 'number') {\n    val = val & 255\n  }\n\n  // Invalid ranges are not set to a default, so can range check early.\n  if (start < 0 || this.length < start || this.length < end) {\n    throw new RangeError('Out of range index')\n  }\n\n  if (end <= start) {\n    return this\n  }\n\n  start = start >>> 0\n  end = end === undefined ? this.length : end >>> 0\n\n  if (!val) val = 0\n\n  var i\n  if (typeof val === 'number') {\n    for (i = start; i < end; ++i) {\n      this[i] = val\n    }\n  } else {\n    var bytes = Buffer.isBuffer(val)\n      ? val\n      : new Buffer(val, encoding)\n    var len = bytes.length\n    for (i = 0; i < end - start; ++i) {\n      this[i + start] = bytes[i % len]\n    }\n  }\n\n  return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n  // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n  str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n  // Node converts strings with length < 2 to ''\n  if (str.length < 2) return ''\n  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n  while (str.length % 4 !== 0) {\n    str = str + '='\n  }\n  return str\n}\n\nfunction stringtrim (str) {\n  if (str.trim) return str.trim()\n  return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n  if (n < 16) return '0' + n.toString(16)\n  return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n  units = units || Infinity\n  var codePoint\n  var length = string.length\n  var leadSurrogate = null\n  var bytes = []\n\n  for (var i = 0; i < length; ++i) {\n    codePoint = string.charCodeAt(i)\n\n    // is surrogate component\n    if (codePoint > 0xD7FF && codePoint < 0xE000) {\n      // last char was a lead\n      if (!leadSurrogate) {\n        // no lead yet\n        if (codePoint > 0xDBFF) {\n          // unexpected trail\n          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n          continue\n        } else if (i + 1 === length) {\n          // unpaired lead\n          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n          continue\n        }\n\n        // valid lead\n        leadSurrogate = codePoint\n\n        continue\n      }\n\n      // 2 leads in a row\n      if (codePoint < 0xDC00) {\n        if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n        leadSurrogate = codePoint\n        continue\n      }\n\n      // valid surrogate pair\n      codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n    } else if (leadSurrogate) {\n      // valid bmp char, but last char was a lead\n      if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n    }\n\n    leadSurrogate = null\n\n    // encode utf8\n    if (codePoint < 0x80) {\n      if ((units -= 1) < 0) break\n      bytes.push(codePoint)\n    } else if (codePoint < 0x800) {\n      if ((units -= 2) < 0) break\n      bytes.push(\n        codePoint >> 0x6 | 0xC0,\n        codePoint & 0x3F | 0x80\n      )\n    } else if (codePoint < 0x10000) {\n      if ((units -= 3) < 0) break\n      bytes.push(\n        codePoint >> 0xC | 0xE0,\n        codePoint >> 0x6 & 0x3F | 0x80,\n        codePoint & 0x3F | 0x80\n      )\n    } else if (codePoint < 0x110000) {\n      if ((units -= 4) < 0) break\n      bytes.push(\n        codePoint >> 0x12 | 0xF0,\n        codePoint >> 0xC & 0x3F | 0x80,\n        codePoint >> 0x6 & 0x3F | 0x80,\n        codePoint & 0x3F | 0x80\n      )\n    } else {\n      throw new Error('Invalid code point')\n    }\n  }\n\n  return bytes\n}\n\nfunction asciiToBytes (str) {\n  var byteArray = []\n  for (var i = 0; i < str.length; ++i) {\n    // Node's code seems to be doing this and not & 0x7F..\n    byteArray.push(str.charCodeAt(i) & 0xFF)\n  }\n  return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n  var c, hi, lo\n  var byteArray = []\n  for (var i = 0; i < str.length; ++i) {\n    if ((units -= 2) < 0) break\n\n    c = str.charCodeAt(i)\n    hi = c >> 8\n    lo = c % 256\n    byteArray.push(lo)\n    byteArray.push(hi)\n  }\n\n  return byteArray\n}\n\nfunction base64ToBytes (str) {\n  return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n  for (var i = 0; i < length; ++i) {\n    if ((i + offset >= dst.length) || (i >= src.length)) break\n    dst[i + offset] = src[i]\n  }\n  return i\n}\n\nfunction isnan (val) {\n  return val !== val // eslint-disable-line no-self-compare\n}\n\n},{\"base64-js\":3,\"ieee754\":9}],7:[function(require,module,exports){\n(function (Buffer){\n'use strict';\n\n/* eslint-disable */\n\nvar utils = require('./utils/index.js');\nvar uint256Coder = utils.uint256Coder;\nvar coderBoolean = utils.coderBoolean;\nvar coderFixedBytes = utils.coderFixedBytes;\nvar coderAddress = utils.coderAddress;\nvar coderDynamicBytes = utils.coderDynamicBytes;\nvar coderString = utils.coderString;\nvar coderArray = utils.coderArray;\nvar paramTypePart = utils.paramTypePart;\nvar getParamCoder = utils.getParamCoder;\n\nfunction Result() {}\n\nfunction encodeParams(types, values) {\n  if (types.length !== values.length) {\n    throw new Error('[ethjs-abi] while encoding params, types/values mismatch, types length ' + types.length + ' should be ' + values.length);\n  }\n\n  var parts = [];\n\n  types.forEach(function (type, index) {\n    var coder = getParamCoder(type);\n    parts.push({ dynamic: coder.dynamic, value: coder.encode(values[index]) });\n  });\n\n  function alignSize(size) {\n    return parseInt(32 * Math.ceil(size / 32));\n  }\n\n  var staticSize = 0,\n      dynamicSize = 0;\n  parts.forEach(function (part) {\n    if (part.dynamic) {\n      staticSize += 32;\n      dynamicSize += alignSize(part.value.length);\n    } else {\n      staticSize += alignSize(part.value.length);\n    }\n  });\n\n  var offset = 0,\n      dynamicOffset = staticSize;\n  var data = new Buffer(staticSize + dynamicSize);\n\n  parts.forEach(function (part, index) {\n    if (part.dynamic) {\n      uint256Coder.encode(dynamicOffset).copy(data, offset);\n      offset += 32;\n\n      part.value.copy(data, dynamicOffset);\n      dynamicOffset += alignSize(part.value.length);\n    } else {\n      part.value.copy(data, offset);\n      offset += alignSize(part.value.length);\n    }\n  });\n\n  return '0x' + data.toString('hex');\n}\n\n// decode bytecode data from output names and types\nfunction decodeParams(names, types, data) {\n  // Names is optional, so shift over all the parameters if not provided\n  if (arguments.length < 3) {\n    data = types;\n    types = names;\n    names = [];\n  }\n\n  data = utils.hexOrBuffer(data);\n  var values = new Result();\n\n  var offset = 0;\n  types.forEach(function (type, index) {\n    var coder = getParamCoder(type);\n    if (coder.dynamic) {\n      var dynamicOffset = uint256Coder.decode(data, offset);\n      var result = coder.decode(data, dynamicOffset.value.toNumber());\n      offset += dynamicOffset.consumed;\n    } else {\n      var result = coder.decode(data, offset);\n      offset += result.consumed;\n    }\n    values[index] = result.value;\n    if (names[index]) {\n      values[names[index]] = result.value;\n    }\n  });\n  return values;\n}\n\n// encode method ABI object with values in an array, output bytecode\nfunction encodeMethod(method, values) {\n  var signature = method.name + '(' + utils.getKeys(method.inputs, 'type').join(',') + ')';\n  var signatureEncoded = '0x' + new Buffer(utils.keccak256(signature), 'hex').slice(0, 4).toString('hex');\n  var paramsEncoded = encodeParams(utils.getKeys(method.inputs, 'type'), values).substring(2);\n\n  return '' + signatureEncoded + paramsEncoded;\n}\n\n// decode method data bytecode, from method ABI object\nfunction decodeMethod(method, data) {\n  var outputNames = utils.getKeys(method.outputs, 'name', true);\n  var outputTypes = utils.getKeys(method.outputs, 'type');\n\n  return decodeParams(outputNames, outputTypes, utils.hexOrBuffer(data));\n}\n\n// decode method data bytecode, from method ABI object\nfunction encodeEvent(eventObject, values) {\n  return encodeMethod(eventObject, values);\n}\n\n// decode method data bytecode, from method ABI object\nfunction decodeEvent(eventObject, data) {\n  var inputNames = utils.getKeys(eventObject.inputs, 'name', true);\n  var inputTypes = utils.getKeys(eventObject.inputs, 'type');\n\n  return decodeParams(inputNames, inputTypes, utils.hexOrBuffer(data));\n}\n\nmodule.exports = {\n  encodeParams: encodeParams,\n  decodeParams: decodeParams,\n  encodeMethod: encodeMethod,\n  decodeMethod: decodeMethod,\n  encodeEvent: encodeEvent,\n  decodeEvent: decodeEvent\n};\n}).call(this,require(\"buffer\").Buffer)\n},{\"./utils/index.js\":8,\"buffer\":6}],8:[function(require,module,exports){\n(function (Buffer){\n'use strict';\n\nvar BN = require('bn.js');\nvar numberToBN = require('number-to-bn');\nvar keccak256 = require('js-sha3').keccak_256;\n\n// from ethereumjs-util\nfunction stripZeros(aInput) {\n  var a = aInput; // eslint-disable-line\n  var first = a[0]; // eslint-disable-line\n  while (a.length > 0 && first.toString() === '0') {\n    a = a.slice(1);\n    first = a[0];\n  }\n  return a;\n}\n\nfunction bnToBuffer(bnInput) {\n  var bn = bnInput; // eslint-disable-line\n  var hex = bn.toString(16); // eslint-disable-line\n  if (hex.length % 2) {\n    hex = '0' + hex;\n  }\n  return stripZeros(new Buffer(hex, 'hex'));\n}\n\nfunction isHexString(value, length) {\n  if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {\n    return false;\n  }\n  if (length && value.length !== 2 + 2 * length) {\n    return false;\n  }\n  return true;\n}\n\nfunction hexOrBuffer(valueInput, name) {\n  var value = valueInput; // eslint-disable-line\n  if (!Buffer.isBuffer(value)) {\n    if (!isHexString(value)) {\n      var error = new Error(name ? '[ethjs-abi] invalid ' + name : '[ethjs-abi] invalid hex or buffer, must be a prefixed alphanumeric even length hex string');\n      error.reason = '[ethjs-abi] invalid hex string, hex must be prefixed and alphanumeric (e.g. 0x023..)';\n      error.value = value;\n      throw error;\n    }\n\n    value = value.substring(2);\n    if (value.length % 2) {\n      value = '0' + value;\n    }\n    value = new Buffer(value, 'hex');\n  }\n\n  return value;\n}\n\nfunction hexlify(value) {\n  if (typeof value === 'number') {\n    return '0x' + bnToBuffer(new BN(value)).toString('hex');\n  } else if (value.mod || value.modulo) {\n    return '0x' + bnToBuffer(value).toString('hex');\n  } else {\n    // eslint-disable-line\n    return '0x' + hexOrBuffer(value).toString('hex');\n  }\n}\n\n// getKeys([{a: 1, b: 2}, {a: 3, b: 4}], 'a') => [1, 3]\nfunction getKeys(params, key, allowEmpty) {\n  var result = []; // eslint-disable-line\n\n  if (!Array.isArray(params)) {\n    throw new Error('[ethjs-abi] while getting keys, invalid params value ' + JSON.stringify(params));\n  }\n\n  for (var i = 0; i < params.length; i++) {\n    // eslint-disable-line\n    var value = params[i][key]; // eslint-disable-line\n    if (allowEmpty && !value) {\n      value = '';\n    } else if (typeof value !== 'string') {\n      throw new Error('[ethjs-abi] while getKeys found invalid ABI data structure, type value not string');\n    }\n    result.push(value);\n  }\n\n  return result;\n}\n\nfunction coderNumber(size, signed) {\n  return {\n    encode: function encodeNumber(valueInput) {\n      var value = valueInput; // eslint-disable-line\n\n      if (typeof value === 'object' && value.toString && (value.toTwos || value.dividedToIntegerBy)) {\n        value = value.toString(10).split('.')[0];\n      }\n\n      if (typeof value === 'string' || typeof value === 'number') {\n        value = String(value).split('.')[0];\n      }\n\n      value = numberToBN(value);\n      value = value.toTwos(size * 8).maskn(size * 8);\n      if (signed) {\n        value = value.fromTwos(size * 8).toTwos(256);\n      }\n      return value.toArrayLike(Buffer, 'be', 32);\n    },\n    decode: function decodeNumber(data, offset) {\n      var junkLength = 32 - size; // eslint-disable-line\n      var value = new BN(data.slice(offset + junkLength, offset + 32)); // eslint-disable-line\n      if (signed) {\n        value = value.fromTwos(size * 8);\n      } else {\n        value = value.maskn(size * 8);\n      }\n      return {\n        consumed: 32,\n        value: new BN(value.toString(10))\n      };\n    }\n  };\n}\nvar uint256Coder = coderNumber(32, false);\n\nvar coderBoolean = {\n  encode: function encodeBoolean(value) {\n    return uint256Coder.encode(value ? 1 : 0);\n  },\n  decode: function decodeBoolean(data, offset) {\n    var result = uint256Coder.decode(data, offset); // eslint-disable-line\n    return {\n      consumed: result.consumed,\n      value: !result.value.isZero()\n    };\n  }\n};\n\nfunction coderFixedBytes(length) {\n  return {\n    encode: function encodeFixedBytes(valueInput) {\n      var value = valueInput; // eslint-disable-line\n      value = hexOrBuffer(value);\n\n      if (value.length === 32) {\n        return value;\n      }\n\n      var result = new Buffer(32); // eslint-disable-line\n      result.fill(0);\n      value.copy(result);\n      return result;\n    },\n    decode: function decodeFixedBytes(data, offset) {\n      if (data.length < offset + 32) {\n        throw new Error('[ethjs-abi] while decoding fixed bytes, invalid bytes data length: ' + length);\n      }\n\n      return {\n        consumed: 32,\n        value: '0x' + data.slice(offset, offset + length).toString('hex')\n      };\n    }\n  };\n}\n\nvar coderAddress = {\n  encode: function encodeAddress(valueInput) {\n    var value = valueInput; // eslint-disable-line\n    var result = new Buffer(32); // eslint-disable-line\n    if (!isHexString(value, 20)) {\n      throw new Error('[ethjs-abi] while encoding address, invalid address value, not alphanumeric 20 byte hex string');\n    }\n    value = hexOrBuffer(value);\n    result.fill(0);\n    value.copy(result, 12);\n    return result;\n  },\n  decode: function decodeAddress(data, offset) {\n    if (data.length === 0) {\n      return {\n        consumed: 32,\n        value: '0x'\n      };\n    }\n    if (data.length < offset + 32) {\n      throw new Error('[ethjs-abi] while decoding address data, invalid address data, invalid byte length ' + data.length);\n    }\n    return {\n      consumed: 32,\n      value: '0x' + data.slice(offset + 12, offset + 32).toString('hex')\n    };\n  }\n};\n\nfunction encodeDynamicBytesHelper(value) {\n  var dataLength = parseInt(32 * Math.ceil(value.length / 32)); // eslint-disable-line\n  var padding = new Buffer(dataLength - value.length); // eslint-disable-line\n  padding.fill(0);\n\n  return Buffer.concat([uint256Coder.encode(value.length), value, padding]);\n}\n\nfunction decodeDynamicBytesHelper(data, offset) {\n  if (data.length < offset + 32) {\n    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32));\n  }\n\n  var length = uint256Coder.decode(data, offset).value; // eslint-disable-line\n  length = length.toNumber();\n  if (data.length < offset + 32 + length) {\n    throw new Error('[ethjs-abi] while decoding dynamic bytes data, invalid bytes length: ' + data.length + ' should be less than ' + (offset + 32 + length));\n  }\n\n  return {\n    consumed: parseInt(32 + 32 * Math.ceil(length / 32), 10),\n    value: data.slice(offset + 32, offset + 32 + length)\n  };\n}\n\nvar coderDynamicBytes = {\n  encode: function encodeDynamicBytes(value) {\n    return encodeDynamicBytesHelper(hexOrBuffer(value));\n  },\n  decode: function decodeDynamicBytes(data, offset) {\n    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line\n    result.value = '0x' + result.value.toString('hex');\n    return result;\n  },\n  dynamic: true\n};\n\nvar coderString = {\n  encode: function encodeString(value) {\n    return encodeDynamicBytesHelper(new Buffer(value, 'utf8'));\n  },\n  decode: function decodeString(data, offset) {\n    var result = decodeDynamicBytesHelper(data, offset); // eslint-disable-line\n    result.value = result.value.toString('utf8');\n    return result;\n  },\n  dynamic: true\n};\n\nfunction coderArray(coder, lengthInput) {\n  return {\n    encode: function encodeArray(value) {\n      var result = new Buffer(0); // eslint-disable-line\n      var length = lengthInput; // eslint-disable-line\n\n      if (!Array.isArray(value)) {\n        throw new Error('[ethjs-abi] while encoding array, invalid array data, not type Object (Array)');\n      }\n\n      if (length === -1) {\n        length = value.length;\n        result = uint256Coder.encode(length);\n      }\n\n      if (length !== value.length) {\n        throw new Error('[ethjs-abi] while encoding array, size mismatch array length ' + length + ' does not equal ' + value.length);\n      }\n\n      value.forEach(function (resultValue) {\n        result = Buffer.concat([result, coder.encode(resultValue)]);\n      });\n\n      return result;\n    },\n    decode: function decodeArray(data, offsetInput) {\n      var length = lengthInput; // eslint-disable-line\n      var offset = offsetInput; // eslint-disable-line\n      // @TODO:\n      // if (data.length < offset + length * 32) { throw new Error('invalid array'); }\n\n      var consumed = 0; // eslint-disable-line\n      var decodeResult; // eslint-disable-line\n\n      if (length === -1) {\n        decodeResult = uint256Coder.decode(data, offset);\n        length = decodeResult.value.toNumber();\n        consumed += decodeResult.consumed;\n        offset += decodeResult.consumed;\n      }\n\n      var value = []; // eslint-disable-line\n\n      for (var i = 0; i < length; i++) {\n        // eslint-disable-line\n        var loopResult = coder.decode(data, offset);\n        consumed += loopResult.consumed;\n        offset += loopResult.consumed;\n        value.push(loopResult.value);\n      }\n\n      return {\n        consumed: consumed,\n        value: value\n      };\n    },\n    dynamic: lengthInput === -1\n  };\n}\n\n// Break the type up into [staticType][staticArray]*[dynamicArray]? | [dynamicType] and\n// build the coder up from its parts\nvar paramTypePart = new RegExp(/^((u?int|bytes)([0-9]*)|(address|bool|string)|(\\[([0-9]*)\\]))/);\n\nfunction getParamCoder(typeInput) {\n  var type = typeInput; // eslint-disable-line\n  var coder = null; // eslint-disable-line\n  var invalidTypeErrorMessage = '[ethjs-abi] while getting param coder (getParamCoder) type value ' + JSON.stringify(type) + ' is either invalid or unsupported by ethjs-abi.';\n\n  while (type) {\n    var part = type.match(paramTypePart); // eslint-disable-line\n    if (!part) {\n      throw new Error(invalidTypeErrorMessage);\n    }\n    type = type.substring(part[0].length);\n\n    var prefix = part[2] || part[4] || part[5]; // eslint-disable-line\n    switch (prefix) {\n      case 'int':case 'uint':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        var intSize = parseInt(part[3] || 256); // eslint-disable-line\n        if (intSize === 0 || intSize > 256 || intSize % 8 !== 0) {\n          throw new Error('[ethjs-abi] while getting param coder for type ' + type + ', invalid ' + prefix + '<N> width: ' + type);\n        }\n\n        coder = coderNumber(intSize / 8, prefix === 'int');\n        break;\n\n      case 'bool':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderBoolean;\n        break;\n\n      case 'string':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderString;\n        break;\n\n      case 'bytes':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        if (part[3]) {\n          var size = parseInt(part[3]); // eslint-disable-line\n          if (size === 0 || size > 32) {\n            throw new Error('[ethjs-abi] while getting param coder for prefix bytes, invalid type ' + type + ', size ' + size + ' should be 0 or greater than 32');\n          }\n          coder = coderFixedBytes(size);\n        } else {\n          coder = coderDynamicBytes;\n        }\n        break;\n\n      case 'address':\n        if (coder) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderAddress;\n        break;\n\n      case '[]':\n        if (!coder || coder.dynamic) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        coder = coderArray(coder, -1);\n        break;\n\n      // \"[0-9+]\"\n      default:\n        if (!coder || coder.dynamic) {\n          throw new Error(invalidTypeErrorMessage);\n        }\n        var defaultSize = parseInt(part[6]); // eslint-disable-line\n        coder = coderArray(coder, defaultSize);\n    }\n  }\n\n  if (!coder) {\n    throw new Error(invalidTypeErrorMessage);\n  }\n  return coder;\n}\n\nmodule.exports = {\n  BN: BN,\n  bnToBuffer: bnToBuffer,\n  isHexString: isHexString,\n  hexOrBuffer: hexOrBuffer,\n  hexlify: hexlify,\n  stripZeros: stripZeros,\n\n  keccak256: keccak256,\n\n  getKeys: getKeys,\n  numberToBN: numberToBN,\n  coderNumber: coderNumber,\n  uint256Coder: uint256Coder,\n  coderBoolean: coderBoolean,\n  coderFixedBytes: coderFixedBytes,\n  coderAddress: coderAddress,\n  coderDynamicBytes: coderDynamicBytes,\n  coderString: coderString,\n  coderArray: coderArray,\n  paramTypePart: paramTypePart,\n  getParamCoder: getParamCoder\n};\n}).call(this,require(\"buffer\").Buffer)\n},{\"bn.js\":4,\"buffer\":6,\"js-sha3\":11,\"number-to-bn\":12}],9:[function(require,module,exports){\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n  var e, m\n  var eLen = nBytes * 8 - mLen - 1\n  var eMax = (1 << eLen) - 1\n  var eBias = eMax >> 1\n  var nBits = -7\n  var i = isLE ? (nBytes - 1) : 0\n  var d = isLE ? -1 : 1\n  var s = buffer[offset + i]\n\n  i += d\n\n  e = s & ((1 << (-nBits)) - 1)\n  s >>= (-nBits)\n  nBits += eLen\n  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}\n\n  m = e & ((1 << (-nBits)) - 1)\n  e >>= (-nBits)\n  nBits += mLen\n  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}\n\n  if (e === 0) {\n    e = 1 - eBias\n  } else if (e === eMax) {\n    return m ? NaN : ((s ? -1 : 1) * Infinity)\n  } else {\n    m = m + Math.pow(2, mLen)\n    e = e - eBias\n  }\n  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n  var e, m, c\n  var eLen = nBytes * 8 - mLen - 1\n  var eMax = (1 << eLen) - 1\n  var eBias = eMax >> 1\n  var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n  var i = isLE ? 0 : (nBytes - 1)\n  var d = isLE ? 1 : -1\n  var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n  value = Math.abs(value)\n\n  if (isNaN(value) || value === Infinity) {\n    m = isNaN(value) ? 1 : 0\n    e = eMax\n  } else {\n    e = Math.floor(Math.log(value) / Math.LN2)\n    if (value * (c = Math.pow(2, -e)) < 1) {\n      e--\n      c *= 2\n    }\n    if (e + eBias >= 1) {\n      value += rt / c\n    } else {\n      value += rt * Math.pow(2, 1 - eBias)\n    }\n    if (value * c >= 2) {\n      e++\n      c /= 2\n    }\n\n    if (e + eBias >= eMax) {\n      m = 0\n      e = eMax\n    } else if (e + eBias >= 1) {\n      m = (value * c - 1) * Math.pow(2, mLen)\n      e = e + eBias\n    } else {\n      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n      e = 0\n    }\n  }\n\n  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n  e = (e << mLen) | m\n  eLen += mLen\n  for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n  buffer[offset + i - d] |= s * 128\n}\n\n},{}],10:[function(require,module,exports){\n/**\n * Returns a `Boolean` on whether or not the a `String` starts with '0x'\n * @param {String} str the string input value\n * @return {Boolean} a boolean if it is or is not hex prefixed\n * @throws if the str input is not a string\n */\nmodule.exports = function isHexPrefixed(str) {\n  if (typeof str !== 'string') {\n    throw new Error(\"[is-hex-prefixed] value must be type 'string', is currently type \" + (typeof str) + \", while checking isHexPrefixed.\");\n  }\n\n  return str.slice(0, 2) === '0x';\n}\n\n},{}],11:[function(require,module,exports){\n(function (process,global){\n/**\r\n * [js-sha3]{@link https://github.com/emn178/js-sha3}\r\n *\r\n * @version 0.5.5\r\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\r\n * @copyright Chen, Yi-Cyuan 2015-2016\r\n * @license MIT\r\n */\r\n(function (root) {\r\n  'use strict';\r\n\r\n  var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;\r\n  if (NODE_JS) {\r\n    root = global;\r\n  }\r\n  var COMMON_JS = !root.JS_SHA3_TEST && typeof module == 'object' && module.exports;\r\n  var HEX_CHARS = '0123456789abcdef'.split('');\r\n  var SHAKE_PADDING = [31, 7936, 2031616, 520093696];\r\n  var KECCAK_PADDING = [1, 256, 65536, 16777216];\r\n  var PADDING = [6, 1536, 393216, 100663296];\r\n  var SHIFT = [0, 8, 16, 24];\r\n  var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,\r\n            0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, \r\n            2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, \r\n            2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,\r\n            2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];\r\n  var BITS = [224, 256, 384, 512];\r\n  var SHAKE_BITS = [128, 256];\r\n  var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array'];\r\n\r\n  var createOutputMethod = function (bits, padding, outputType) {\r\n    return function (message) {\r\n      return new Keccak(bits, padding, bits).update(message)[outputType]();\r\n    }\r\n  };\r\n\r\n  var createShakeOutputMethod = function (bits, padding, outputType) {\r\n    return function (message, outputBits) {\r\n      return new Keccak(bits, padding, outputBits).update(message)[outputType]();\r\n    }\r\n  };\r\n\r\n  var createMethod = function (bits, padding) {\r\n    var method = createOutputMethod(bits, padding, 'hex');\r\n    method.create = function () {\r\n      return new Keccak(bits, padding, bits);\r\n    };\r\n    method.update = function (message) {\r\n      return method.create().update(message);\r\n    };\r\n    for (var i = 0;i < OUTPUT_TYPES.length;++i) {\r\n      var type = OUTPUT_TYPES[i];\r\n      method[type] = createOutputMethod(bits, padding, type);\r\n    }\r\n    return method;\r\n  };\r\n\r\n  var createShakeMethod = function (bits, padding) {\r\n    var method = createShakeOutputMethod(bits, padding, 'hex');\r\n    method.create = function (outputBits) {\r\n      return new Keccak(bits, padding, outputBits);\r\n    };\r\n    method.update = function (message, outputBits) {\r\n      return method.create(outputBits).update(message);\r\n    };\r\n    for (var i = 0;i < OUTPUT_TYPES.length;++i) {\r\n      var type = OUTPUT_TYPES[i];\r\n      method[type] = createShakeOutputMethod(bits, padding, type);\r\n    }\r\n    return method;\r\n  };\r\n\r\n  var algorithms = [\r\n    {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod},\r\n    {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod},\r\n    {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod}\r\n  ];\r\n\r\n  var methods = {};\r\n\r\n  for (var i = 0;i < algorithms.length;++i) {\r\n    var algorithm = algorithms[i];\r\n    var bits  = algorithm.bits;\r\n    for (var j = 0;j < bits.length;++j) {\r\n      methods[algorithm.name +'_' + bits[j]] = algorithm.createMethod(bits[j], algorithm.padding);\r\n    }\r\n  }\r\n\r\n  function Keccak(bits, padding, outputBits) {\r\n    this.blocks = [];\r\n    this.s = [];\r\n    this.padding = padding;\r\n    this.outputBits = outputBits;\r\n    this.reset = true;\r\n    this.block = 0;\r\n    this.start = 0;\r\n    this.blockCount = (1600 - (bits << 1)) >> 5;\r\n    this.byteCount = this.blockCount << 2;\r\n    this.outputBlocks = outputBits >> 5;\r\n    this.extraBytes = (outputBits & 31) >> 3;\r\n\r\n    for (var i = 0;i < 50;++i) {\r\n      this.s[i] = 0;\r\n    }\r\n  };\r\n\r\n  Keccak.prototype.update = function (message) {\r\n    var notString = typeof message != 'string';\r\n    if (notString && message.constructor == root.ArrayBuffer) {\r\n      message = new Uint8Array(message);\r\n    }\r\n    var length = message.length, blocks = this.blocks, byteCount = this.byteCount, \r\n        blockCount = this.blockCount, index = 0, s = this.s, i, code;\r\n    \r\n    while (index < length) {\r\n      if (this.reset) {\r\n        this.reset = false;\r\n        blocks[0] = this.block;\r\n        for (i = 1;i < blockCount + 1;++i) {\r\n          blocks[i] = 0;\r\n        }\r\n      }\r\n      if (notString) {\r\n        for (i = this.start;index < length && i < byteCount;++index) {\r\n          blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];\r\n        }\r\n      } else {\r\n        for (i = this.start;index < length && i < byteCount;++index) {\r\n          code = message.charCodeAt(index);\r\n          if (code < 0x80) {\r\n            blocks[i >> 2] |= code << SHIFT[i++ & 3];\r\n          } else if (code < 0x800) {\r\n            blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\r\n          } else if (code < 0xd800 || code >= 0xe000) {\r\n            blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\r\n          } else {\r\n            code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\r\n            blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\r\n            blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\r\n          }\r\n        }\r\n      }\r\n      this.lastByteIndex = i;\r\n      if (i >= byteCount) {\r\n        this.start = i - byteCount;\r\n        this.block = blocks[blockCount];\r\n        for (i = 0;i < blockCount;++i) {\r\n          s[i] ^= blocks[i];\r\n        }\r\n        f(s);\r\n        this.reset = true;\r\n      } else {\r\n        this.start = i;\r\n      }\r\n    }\r\n    return this;\r\n  };\r\n\r\n  Keccak.prototype.finalize = function () {\r\n    var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;\r\n    blocks[i >> 2] |= this.padding[i & 3];\r\n    if (this.lastByteIndex == this.byteCount) {\r\n      blocks[0] = blocks[blockCount];\r\n      for (i = 1;i < blockCount + 1;++i) {\r\n        blocks[i] = 0;\r\n      }\r\n    }\r\n    blocks[blockCount - 1] |= 0x80000000;\r\n    for (i = 0;i < blockCount;++i) {\r\n      s[i] ^= blocks[i];\r\n    }\r\n    f(s);\r\n  };\r\n\r\n  Keccak.prototype.toString = Keccak.prototype.hex = function () {\r\n    this.finalize();\r\n\r\n    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, \r\n        extraBytes = this.extraBytes, i = 0, j = 0;\r\n    var hex = '', block;\r\n    while (j < outputBlocks) {\r\n      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {\r\n        block = s[i];\r\n        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +\r\n               HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +\r\n               HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +\r\n               HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];\r\n      }\r\n      if (j % blockCount == 0) {\r\n        f(s);\r\n        i = 0;\r\n      }\r\n    }\r\n    if (extraBytes) {\r\n      block = s[i];\r\n      if (extraBytes > 0) {\r\n        hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];\r\n      }\r\n      if (extraBytes > 1) {\r\n        hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];\r\n      }\r\n      if (extraBytes > 2) {\r\n        hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];\r\n      }\r\n    }\r\n    return hex;\r\n  };\r\n\r\n  Keccak.prototype.arrayBuffer = function () {\r\n    this.finalize();\r\n\r\n    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, \r\n        extraBytes = this.extraBytes, i = 0, j = 0;\r\n    var bytes = this.outputBits >> 3;\r\n    var buffer;\r\n    if (extraBytes) {\r\n      buffer = new ArrayBuffer((outputBlocks + 1) << 2);\r\n    } else {\r\n      buffer = new ArrayBuffer(bytes);\r\n    }\r\n    var array = new Uint32Array(buffer);\r\n    while (j < outputBlocks) {\r\n      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {\r\n        array[j] = s[i];\r\n      }\r\n      if (j % blockCount == 0) {\r\n        f(s);\r\n      }\r\n    }\r\n    if (extraBytes) {\r\n      array[i] = s[i];\r\n      buffer = buffer.slice(0, bytes);\r\n    }\r\n    return buffer;\r\n  };\r\n\r\n  Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;\r\n\r\n  Keccak.prototype.digest = Keccak.prototype.array = function () {\r\n    this.finalize();\r\n\r\n    var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, \r\n        extraBytes = this.extraBytes, i = 0, j = 0;\r\n    var array = [], offset, block;\r\n    while (j < outputBlocks) {\r\n      for (i = 0;i < blockCount && j < outputBlocks;++i, ++j) {\r\n        offset = j << 2;\r\n        block = s[i];\r\n        array[offset] = block & 0xFF;\r\n        array[offset + 1] = (block >> 8) & 0xFF;\r\n        array[offset + 2] = (block >> 16) & 0xFF;\r\n        array[offset + 3] = (block >> 24) & 0xFF;\r\n      }\r\n      if (j % blockCount == 0) {\r\n        f(s);\r\n      }\r\n    }\r\n    if (extraBytes) {\r\n      offset = j << 2;\r\n      block = s[i];\r\n      if (extraBytes > 0) {\r\n        array[offset] = block & 0xFF;\r\n      }\r\n      if (extraBytes > 1) {\r\n        array[offset + 1] = (block >> 8) & 0xFF;\r\n      }\r\n      if (extraBytes > 2) {\r\n        array[offset + 2] = (block >> 16) & 0xFF;\r\n      }\r\n    }\r\n    return array;\r\n  };\r\n\r\n  var f = function (s) {\r\n    var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, \r\n        b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, \r\n        b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, \r\n        b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;\r\n    for (n = 0;n < 48;n += 2) {\r\n      c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];\r\n      c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];\r\n      c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];\r\n      c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];\r\n      c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];\r\n      c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];\r\n      c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];\r\n      c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];\r\n      c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];\r\n      c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];\r\n\r\n      h = c8 ^ ((c2 << 1) | (c3 >>> 31));\r\n      l = c9 ^ ((c3 << 1) | (c2 >>> 31));\r\n      s[0] ^= h;\r\n      s[1] ^= l;\r\n      s[10] ^= h;\r\n      s[11] ^= l;\r\n      s[20] ^= h;\r\n      s[21] ^= l;\r\n      s[30] ^= h;\r\n      s[31] ^= l;\r\n      s[40] ^= h;\r\n      s[41] ^= l;\r\n      h = c0 ^ ((c4 << 1) | (c5 >>> 31));\r\n      l = c1 ^ ((c5 << 1) | (c4 >>> 31));\r\n      s[2] ^= h;\r\n      s[3] ^= l;\r\n      s[12] ^= h;\r\n      s[13] ^= l;\r\n      s[22] ^= h;\r\n      s[23] ^= l;\r\n      s[32] ^= h;\r\n      s[33] ^= l;\r\n      s[42] ^= h;\r\n      s[43] ^= l;\r\n      h = c2 ^ ((c6 << 1) | (c7 >>> 31));\r\n      l = c3 ^ ((c7 << 1) | (c6 >>> 31));\r\n      s[4] ^= h;\r\n      s[5] ^= l;\r\n      s[14] ^= h;\r\n      s[15] ^= l;\r\n      s[24] ^= h;\r\n      s[25] ^= l;\r\n      s[34] ^= h;\r\n      s[35] ^= l;\r\n      s[44] ^= h;\r\n      s[45] ^= l;\r\n      h = c4 ^ ((c8 << 1) | (c9 >>> 31));\r\n      l = c5 ^ ((c9 << 1) | (c8 >>> 31));\r\n      s[6] ^= h;\r\n      s[7] ^= l;\r\n      s[16] ^= h;\r\n      s[17] ^= l;\r\n      s[26] ^= h;\r\n      s[27] ^= l;\r\n      s[36] ^= h;\r\n      s[37] ^= l;\r\n      s[46] ^= h;\r\n      s[47] ^= l;\r\n      h = c6 ^ ((c0 << 1) | (c1 >>> 31));\r\n      l = c7 ^ ((c1 << 1) | (c0 >>> 31));\r\n      s[8] ^= h;\r\n      s[9] ^= l;\r\n      s[18] ^= h;\r\n      s[19] ^= l;\r\n      s[28] ^= h;\r\n      s[29] ^= l;\r\n      s[38] ^= h;\r\n      s[39] ^= l;\r\n      s[48] ^= h;\r\n      s[49] ^= l;\r\n\r\n      b0 = s[0];\r\n      b1 = s[1];\r\n      b32 = (s[11] << 4) | (s[10] >>> 28);\r\n      b33 = (s[10] << 4) | (s[11] >>> 28);\r\n      b14 = (s[20] << 3) | (s[21] >>> 29);\r\n      b15 = (s[21] << 3) | (s[20] >>> 29);\r\n      b46 = (s[31] << 9) | (s[30] >>> 23);\r\n      b47 = (s[30] << 9) | (s[31] >>> 23);\r\n      b28 = (s[40] << 18) | (s[41] >>> 14);\r\n      b29 = (s[41] << 18) | (s[40] >>> 14);\r\n      b20 = (s[2] << 1) | (s[3] >>> 31);\r\n      b21 = (s[3] << 1) | (s[2] >>> 31);\r\n      b2 = (s[13] << 12) | (s[12] >>> 20);\r\n      b3 = (s[12] << 12) | (s[13] >>> 20);\r\n      b34 = (s[22] << 10) | (s[23] >>> 22);\r\n      b35 = (s[23] << 10) | (s[22] >>> 22);\r\n      b16 = (s[33] << 13) | (s[32] >>> 19);\r\n      b17 = (s[32] << 13) | (s[33] >>> 19);\r\n      b48 = (s[42] << 2) | (s[43] >>> 30);\r\n      b49 = (s[43] << 2) | (s[42] >>> 30);\r\n      b40 = (s[5] << 30) | (s[4] >>> 2);\r\n      b41 = (s[4] << 30) | (s[5] >>> 2);\r\n      b22 = (s[14] << 6) | (s[15] >>> 26);\r\n      b23 = (s[15] << 6) | (s[14] >>> 26);\r\n      b4 = (s[25] << 11) | (s[24] >>> 21);\r\n      b5 = (s[24] << 11) | (s[25] >>> 21);\r\n      b36 = (s[34] << 15) | (s[35] >>> 17);\r\n      b37 = (s[35] << 15) | (s[34] >>> 17);\r\n      b18 = (s[45] << 29) | (s[44] >>> 3);\r\n      b19 = (s[44] << 29) | (s[45] >>> 3);\r\n      b10 = (s[6] << 28) | (s[7] >>> 4);\r\n      b11 = (s[7] << 28) | (s[6] >>> 4);\r\n      b42 = (s[17] << 23) | (s[16] >>> 9);\r\n      b43 = (s[16] << 23) | (s[17] >>> 9);\r\n      b24 = (s[26] << 25) | (s[27] >>> 7);\r\n      b25 = (s[27] << 25) | (s[26] >>> 7);\r\n      b6 = (s[36] << 21) | (s[37] >>> 11);\r\n      b7 = (s[37] << 21) | (s[36] >>> 11);\r\n      b38 = (s[47] << 24) | (s[46] >>> 8);\r\n      b39 = (s[46] << 24) | (s[47] >>> 8);\r\n      b30 = (s[8] << 27) | (s[9] >>> 5);\r\n      b31 = (s[9] << 27) | (s[8] >>> 5);\r\n      b12 = (s[18] << 20) | (s[19] >>> 12);\r\n      b13 = (s[19] << 20) | (s[18] >>> 12);\r\n      b44 = (s[29] << 7) | (s[28] >>> 25);\r\n      b45 = (s[28] << 7) | (s[29] >>> 25);\r\n      b26 = (s[38] << 8) | (s[39] >>> 24);\r\n      b27 = (s[39] << 8) | (s[38] >>> 24);\r\n      b8 = (s[48] << 14) | (s[49] >>> 18);\r\n      b9 = (s[49] << 14) | (s[48] >>> 18);\r\n\r\n      s[0] = b0 ^ (~b2 & b4);\r\n      s[1] = b1 ^ (~b3 & b5);\r\n      s[10] = b10 ^ (~b12 & b14);\r\n      s[11] = b11 ^ (~b13 & b15);\r\n      s[20] = b20 ^ (~b22 & b24);\r\n      s[21] = b21 ^ (~b23 & b25);\r\n      s[30] = b30 ^ (~b32 & b34);\r\n      s[31] = b31 ^ (~b33 & b35);\r\n      s[40] = b40 ^ (~b42 & b44);\r\n      s[41] = b41 ^ (~b43 & b45);\r\n      s[2] = b2 ^ (~b4 & b6);\r\n      s[3] = b3 ^ (~b5 & b7);\r\n      s[12] = b12 ^ (~b14 & b16);\r\n      s[13] = b13 ^ (~b15 & b17);\r\n      s[22] = b22 ^ (~b24 & b26);\r\n      s[23] = b23 ^ (~b25 & b27);\r\n      s[32] = b32 ^ (~b34 & b36);\r\n      s[33] = b33 ^ (~b35 & b37);\r\n      s[42] = b42 ^ (~b44 & b46);\r\n      s[43] = b43 ^ (~b45 & b47);\r\n      s[4] = b4 ^ (~b6 & b8);\r\n      s[5] = b5 ^ (~b7 & b9);\r\n      s[14] = b14 ^ (~b16 & b18);\r\n      s[15] = b15 ^ (~b17 & b19);\r\n      s[24] = b24 ^ (~b26 & b28);\r\n      s[25] = b25 ^ (~b27 & b29);\r\n      s[34] = b34 ^ (~b36 & b38);\r\n      s[35] = b35 ^ (~b37 & b39);\r\n      s[44] = b44 ^ (~b46 & b48);\r\n      s[45] = b45 ^ (~b47 & b49);\r\n      s[6] = b6 ^ (~b8 & b0);\r\n      s[7] = b7 ^ (~b9 & b1);\r\n      s[16] = b16 ^ (~b18 & b10);\r\n      s[17] = b17 ^ (~b19 & b11);\r\n      s[26] = b26 ^ (~b28 & b20);\r\n      s[27] = b27 ^ (~b29 & b21);\r\n      s[36] = b36 ^ (~b38 & b30);\r\n      s[37] = b37 ^ (~b39 & b31);\r\n      s[46] = b46 ^ (~b48 & b40);\r\n      s[47] = b47 ^ (~b49 & b41);\r\n      s[8] = b8 ^ (~b0 & b2);\r\n      s[9] = b9 ^ (~b1 & b3);\r\n      s[18] = b18 ^ (~b10 & b12);\r\n      s[19] = b19 ^ (~b11 & b13);\r\n      s[28] = b28 ^ (~b20 & b22);\r\n      s[29] = b29 ^ (~b21 & b23);\r\n      s[38] = b38 ^ (~b30 & b32);\r\n      s[39] = b39 ^ (~b31 & b33);\r\n      s[48] = b48 ^ (~b40 & b42);\r\n      s[49] = b49 ^ (~b41 & b43);\r\n\r\n      s[0] ^= RC[n];\r\n      s[1] ^= RC[n + 1];\r\n    }\r\n  }\r\n\r\n  if (COMMON_JS) {\r\n    module.exports = methods;\r\n  } else if (root) {\r\n    for (var key in methods) {\r\n      root[key] = methods[key];\r\n    }\r\n  }\r\n}(this));\r\n\n}).call(this,require('_process'),typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"_process\":13}],12:[function(require,module,exports){\nvar BN = require('bn.js');\nvar stripHexPrefix = require('strip-hex-prefix');\n\n/**\n * Returns a BN object, converts a number value to a BN\n * @param {String|Number|Object} `arg` input a string number, hex string number, number, BigNumber or BN object\n * @return {Object} `output` BN object of the number\n * @throws if the argument is not an array, object that isn't a bignumber, not a string number or number\n */\nmodule.exports = function numberToBN(arg) {\n  if (typeof arg === 'string' || typeof arg === 'number') {\n    var multiplier = new BN(1); // eslint-disable-line\n    var formattedString = String(arg).toLowerCase().trim();\n    var isHexPrefixed = formattedString.substr(0, 2) === '0x' || formattedString.substr(0, 3) === '-0x';\n    var stringArg = stripHexPrefix(formattedString); // eslint-disable-line\n    if (stringArg.substr(0, 1) === '-') {\n      stringArg = stripHexPrefix(stringArg.slice(1));\n      multiplier = new BN(-1, 10);\n    }\n    stringArg = stringArg === '' ? '0' : stringArg;\n\n    if ((!stringArg.match(/^-?[0-9]+$/) && stringArg.match(/^[0-9A-Fa-f]+$/))\n      || stringArg.match(/^[a-fA-F]+$/)\n      || (isHexPrefixed === true && stringArg.match(/^[0-9A-Fa-f]+$/))) {\n      return new BN(stringArg, 16).mul(multiplier);\n    }\n\n    if ((stringArg.match(/^-?[0-9]+$/) || stringArg === '') && isHexPrefixed === false) {\n      return new BN(stringArg, 10).mul(multiplier);\n    }\n  } else if (typeof arg === 'object' && arg.toString && (!arg.pop && !arg.push)) {\n    if (arg.toString(10).match(/^-?[0-9]+$/) && (arg.mul || arg.dividedToIntegerBy)) {\n      return new BN(arg.toString(10), 10);\n    }\n  }\n\n  throw new Error('[number-to-bn] while converting number ' + JSON.stringify(arg) + ' to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.');\n}\n\n},{\"bn.js\":4,\"strip-hex-prefix\":14}],13:[function(require,module,exports){\n// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things.  But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals.  It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n    throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n    throw new Error('clearTimeout has not been defined');\n}\n(function () {\n    try {\n        if (typeof setTimeout === 'function') {\n            cachedSetTimeout = setTimeout;\n        } else {\n            cachedSetTimeout = defaultSetTimout;\n        }\n    } catch (e) {\n        cachedSetTimeout = defaultSetTimout;\n    }\n    try {\n        if (typeof clearTimeout === 'function') {\n            cachedClearTimeout = clearTimeout;\n        } else {\n            cachedClearTimeout = defaultClearTimeout;\n        }\n    } catch (e) {\n        cachedClearTimeout = defaultClearTimeout;\n    }\n} ())\nfunction runTimeout(fun) {\n    if (cachedSetTimeout === setTimeout) {\n        //normal enviroments in sane situations\n        return setTimeout(fun, 0);\n    }\n    // if setTimeout wasn't available but was latter defined\n    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n        cachedSetTimeout = setTimeout;\n        return setTimeout(fun, 0);\n    }\n    try {\n        // when when somebody has screwed with setTimeout but no I.E. maddness\n        return cachedSetTimeout(fun, 0);\n    } catch(e){\n        try {\n            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n            return cachedSetTimeout.call(null, fun, 0);\n        } catch(e){\n            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n            return cachedSetTimeout.call(this, fun, 0);\n        }\n    }\n\n\n}\nfunction runClearTimeout(marker) {\n    if (cachedClearTimeout === clearTimeout) {\n        //normal enviroments in sane situations\n        return clearTimeout(marker);\n    }\n    // if clearTimeout wasn't available but was latter defined\n    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n        cachedClearTimeout = clearTimeout;\n        return clearTimeout(marker);\n    }\n    try {\n        // when when somebody has screwed with setTimeout but no I.E. maddness\n        return cachedClearTimeout(marker);\n    } catch (e){\n        try {\n            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally\n            return cachedClearTimeout.call(null, marker);\n        } catch (e){\n            // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n            // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n            return cachedClearTimeout.call(this, marker);\n        }\n    }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n    if (!draining || !currentQueue) {\n        return;\n    }\n    draining = false;\n    if (currentQueue.length) {\n        queue = currentQueue.concat(queue);\n    } else {\n        queueIndex = -1;\n    }\n    if (queue.length) {\n        drainQueue();\n    }\n}\n\nfunction drainQueue() {\n    if (draining) {\n        return;\n    }\n    var timeout = runTimeout(cleanUpNextTick);\n    draining = true;\n\n    var len = queue.length;\n    while(len) {\n        currentQueue = queue;\n        queue = [];\n        while (++queueIndex < len) {\n            if (currentQueue) {\n                currentQueue[queueIndex].run();\n            }\n        }\n        queueIndex = -1;\n        len = queue.length;\n    }\n    currentQueue = null;\n    draining = false;\n    runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n    var args = new Array(arguments.length - 1);\n    if (arguments.length > 1) {\n        for (var i = 1; i < arguments.length; i++) {\n            args[i - 1] = arguments[i];\n        }\n    }\n    queue.push(new Item(fun, args));\n    if (queue.length === 1 && !draining) {\n        runTimeout(drainQueue);\n    }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n    this.fun = fun;\n    this.array = array;\n}\nItem.prototype.run = function () {\n    this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n    throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n    throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n},{}],14:[function(require,module,exports){\nvar isHexPrefixed = require('is-hex-prefixed');\n\n/**\n * Removes '0x' from a given `String` is present\n * @param {String} str the string value\n * @return {String|Optional} a string by pass if necessary\n */\nmodule.exports = function stripHexPrefix(str) {\n  if (typeof str !== 'string') {\n    return str;\n  }\n\n  return isHexPrefixed(str) ? str.slice(2) : str;\n}\n\n},{\"is-hex-prefixed\":10}],15:[function(require,module,exports){\n// TODO: remove web3 requirement\n// Call functions directly on the provider.\nvar Web3 = require(\"web3\");\n\nvar Blockchain = {\n  parse: function(uri) {\n    var parsed = {};\n    if (uri.indexOf(\"blockchain://\") != 0) return parsed;\n\n    uri = uri.replace(\"blockchain://\", \"\");\n\n    var pieces = uri.split(\"/block/\");\n\n    parsed.genesis_hash = \"0x\" + pieces[0];\n    parsed.block_hash = \"0x\" + pieces[1];\n\n    return parsed;\n  },\n\n  asURI: function(provider, callback) {\n    var web3 = new Web3(provider);\n\n    web3.eth.getBlock(0, function(err, genesis) {\n      if (err) return callback(err);\n\n      web3.eth.getBlock(\"latest\", function(err, latest) {\n        if (err) return callback(err);\n\n        var url = \"blockchain://\" + genesis.hash.replace(\"0x\", \"\") + \"/block/\" + latest.hash.replace(\"0x\", \"\");\n\n        callback(null, url);\n      });\n    });\n  },\n\n  matches: function(uri, provider, callback) {\n    uri = this.parse(uri);\n\n    var expected_genesis = uri.genesis_hash;\n    var expected_block = uri.block_hash;\n\n    var web3 = new Web3(provider);\n\n    web3.eth.getBlock(0, function(err, block) {\n      if (err) return callback(err);\n      if (block.hash != expected_genesis) return callback(null, false);\n\n      web3.eth.getBlock(expected_block, function(err, block) {\n        // Treat an error as if the block didn't exist. This is because\n        // some clients respond differently.\n        if (err || block == null) {\n          return callback(null, false);\n        }\n\n        callback(null, true);\n      });\n    });\n  }\n};\n\nmodule.exports = Blockchain;\n\n},{\"web3\":5}],16:[function(require,module,exports){\nvar sha3 = require(\"crypto-js/sha3\");\nvar schema_version = require(\"./package.json\").version;\n\nvar TruffleSchema = {\n  // Normalize options passed in to be the exact options required\n  // for truffle-contract.\n  //\n  // options can be three things:\n  // - normal object\n  // - contract object\n  // - solc output\n  //\n  // TODO: Is extra_options still necessary?\n  normalizeOptions: function(options, extra_options) {\n    extra_options = extra_options || {};\n    var normalized = {};\n    var expected_keys = [\n      \"contract_name\",\n      \"abi\",\n      \"binary\",\n      \"unlinked_binary\",\n      \"address\",\n      \"networks\",\n      \"links\",\n      \"events\",\n      \"network_id\",\n      \"default_network\",\n      \"updated_at\"\n    ];\n\n    // Merge options/contract object first, then extra_options\n    expected_keys.forEach(function(key) {\n      var value;\n\n      try {\n        // Will throw an error if key == address and address doesn't exist.\n        value = options[key];\n\n        if (value != undefined) {\n          normalized[key] = value;\n        }\n      } catch (e) {\n        // Do nothing.\n      }\n\n      try {\n        // Will throw an error if key == address and address doesn't exist.\n        value = extra_options[key];\n\n        if (value != undefined) {\n          normalized[key] = value;\n        }\n      } catch (e) {\n        // Do nothing.\n      }\n    });\n\n    // Now look for solc specific items.\n    if (options.interface != null) {\n      normalized.abi = JSON.parse(options.interface);\n    }\n\n    if (options.bytecode != null) {\n      normalized.unlinked_binary = options.bytecode\n    }\n\n    // Assume any binary passed is the unlinked binary\n    if (normalized.unlinked_binary == null && normalized.binary) {\n      normalized.unlinked_binary = normalized.binary;\n    }\n\n    delete normalized.binary;\n\n    this.copyCustomOptions(options, normalized);\n\n    return normalized;\n  },\n\n  // Generate a proper binary from normalized options, and optionally\n  // merge it with an existing binary.\n  generateBinary: function(options, existing_binary, extra_options) {\n    extra_options = extra_options || {};\n\n    existing_binary = existing_binary || {};\n\n    if (options.overwrite == true) {\n      existing_binary = {};\n    }\n\n    existing_binary.contract_name = options.contract_name || existing_binary.contract_name || \"Contract\";\n    existing_binary.default_network = options.default_network || existing_binary.default_network;\n\n    existing_binary.abi = options.abi || existing_binary.abi;\n    existing_binary.unlinked_binary = options.unlinked_binary || existing_binary.unlinked_binary;\n\n    // Ensure unlinked binary starts with a 0x\n    if (existing_binary.unlinked_binary && existing_binary.unlinked_binary.indexOf(\"0x\") < 0) {\n      existing_binary.unlinked_binary = \"0x\" + existing_binary.unlinked_binary;\n    }\n\n    // Merge existing networks with any passed in networks.\n    existing_binary.networks = existing_binary.networks || {};\n    options.networks = options.networks || {};\n    Object.keys(options.networks).forEach(function(network_id) {\n      existing_binary.networks[network_id] = options.networks[network_id];\n    });\n\n    var updated_at = new Date().getTime();\n\n    if (options.network_id) {\n      // Ensure an object exists for this network.\n      existing_binary.networks[options.network_id] = existing_binary.networks[options.network_id] || {};\n\n      var network = existing_binary.networks[options.network_id];\n\n      // Override specific keys\n      network.address = options.address || network.address;\n      network.links = options.links;\n\n      // merge events with any that previously existed\n      network.events = network.events || {};\n      options.events = options.events || {};\n      Object.keys(options.events).forEach(function(event_id) {\n        options.events[event_id] = options.events[event_id];\n      });\n\n      // Now overwrite any events with the most recent data from the ABI.\n      existing_binary.abi.forEach(function(item) {\n        if (item.type != \"event\") return;\n\n        var signature = item.name + \"(\" + item.inputs.map(function(param) {return param.type;}).join(\",\") + \")\";\n        network.events[\"0x\" + sha3(signature, {outputLength: 256})] = item;\n      });\n\n      if (extra_options.dirty !== false) {\n        network.updated_at = updated_at;\n      }\n    } else {\n      if (options.address) {\n        throw new Error(\"Cannot set address without network id\");\n      }\n    }\n\n    // Ensure all networks have a `links` object.\n    Object.keys(existing_binary.networks).forEach(function(network_id) {\n      var network = existing_binary.networks[network_id];\n      network.links = network.links || {};\n    });\n\n    existing_binary.schema_version = schema_version;\n\n    if (extra_options.dirty !== false) {\n      existing_binary.updated_at = updated_at;\n    } else {\n      existing_binary.updated_at = options.updated_at || existing_binary.updated_at || updated_at;\n    }\n\n    this.copyCustomOptions(options, existing_binary);\n\n    return existing_binary;\n  },\n\n  copyCustomOptions: function(from, to) {\n    // Now let all x- options through.\n    Object.keys(from).forEach(function(key) {\n      if (key.indexOf(\"x-\") != 0) return;\n\n      try {\n        value = from[key];\n\n        if (value != undefined) {\n          to[key] = value;\n        }\n      } catch (e) {\n        // Do nothing.\n      }\n    });\n  }\n};\n\nmodule.exports = TruffleSchema;\n\n},{\"./package.json\":20,\"crypto-js/sha3\":18}],17:[function(require,module,exports){\n;(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory();\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\troot.CryptoJS = factory();\n\t}\n}(this, function () {\n\n\t/**\n\t * CryptoJS core components.\n\t */\n\tvar CryptoJS = CryptoJS || (function (Math, undefined) {\n\t    /*\n\t     * Local polyfil of Object.create\n\t     */\n\t    var create = Object.create || (function () {\n\t        function F() {};\n\n\t        return function (obj) {\n\t            var subtype;\n\n\t            F.prototype = obj;\n\n\t            subtype = new F();\n\n\t            F.prototype = null;\n\n\t            return subtype;\n\t        };\n\t    }())\n\n\t    /**\n\t     * CryptoJS namespace.\n\t     */\n\t    var C = {};\n\n\t    /**\n\t     * Library namespace.\n\t     */\n\t    var C_lib = C.lib = {};\n\n\t    /**\n\t     * Base object for prototypal inheritance.\n\t     */\n\t    var Base = C_lib.Base = (function () {\n\n\n\t        return {\n\t            /**\n\t             * Creates a new object that inherits from this object.\n\t             *\n\t             * @param {Object} overrides Properties to copy into the new object.\n\t             *\n\t             * @return {Object} The new object.\n\t             *\n\t             * @static\n\t             *\n\t             * @example\n\t             *\n\t             *     var MyType = CryptoJS.lib.Base.extend({\n\t             *         field: 'value',\n\t             *\n\t             *         method: function () {\n\t             *         }\n\t             *     });\n\t             */\n\t            extend: function (overrides) {\n\t                // Spawn\n\t                var subtype = create(this);\n\n\t                // Augment\n\t                if (overrides) {\n\t                    subtype.mixIn(overrides);\n\t                }\n\n\t                // Create default initializer\n\t                if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {\n\t                    subtype.init = function () {\n\t                        subtype.$super.init.apply(this, arguments);\n\t                    };\n\t                }\n\n\t                // Initializer's prototype is the subtype object\n\t                subtype.init.prototype = subtype;\n\n\t                // Reference supertype\n\t                subtype.$super = this;\n\n\t                return subtype;\n\t            },\n\n\t            /**\n\t             * Extends this object and runs the init method.\n\t             * Arguments to create() will be passed to init().\n\t             *\n\t             * @return {Object} The new object.\n\t             *\n\t             * @static\n\t             *\n\t             * @example\n\t             *\n\t             *     var instance = MyType.create();\n\t             */\n\t            create: function () {\n\t                var instance = this.extend();\n\t                instance.init.apply(instance, arguments);\n\n\t                return instance;\n\t            },\n\n\t            /**\n\t             * Initializes a newly created object.\n\t             * Override this method to add some logic when your objects are created.\n\t             *\n\t             * @example\n\t             *\n\t             *     var MyType = CryptoJS.lib.Base.extend({\n\t             *         init: function () {\n\t             *             // ...\n\t             *         }\n\t             *     });\n\t             */\n\t            init: function () {\n\t            },\n\n\t            /**\n\t             * Copies properties into this object.\n\t             *\n\t             * @param {Object} properties The properties to mix in.\n\t             *\n\t             * @example\n\t             *\n\t             *     MyType.mixIn({\n\t             *         field: 'value'\n\t             *     });\n\t             */\n\t            mixIn: function (properties) {\n\t                for (var propertyName in properties) {\n\t                    if (properties.hasOwnProperty(propertyName)) {\n\t                        this[propertyName] = properties[propertyName];\n\t                    }\n\t                }\n\n\t                // IE won't copy toString using the loop above\n\t                if (properties.hasOwnProperty('toString')) {\n\t                    this.toString = properties.toString;\n\t                }\n\t            },\n\n\t            /**\n\t             * Creates a copy of this object.\n\t             *\n\t             * @return {Object} The clone.\n\t             *\n\t             * @example\n\t             *\n\t             *     var clone = instance.clone();\n\t             */\n\t            clone: function () {\n\t                return this.init.prototype.extend(this);\n\t            }\n\t        };\n\t    }());\n\n\t    /**\n\t     * An array of 32-bit words.\n\t     *\n\t     * @property {Array} words The array of 32-bit words.\n\t     * @property {number} sigBytes The number of significant bytes in this word array.\n\t     */\n\t    var WordArray = C_lib.WordArray = Base.extend({\n\t        /**\n\t         * Initializes a newly created word array.\n\t         *\n\t         * @param {Array} words (Optional) An array of 32-bit words.\n\t         * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.lib.WordArray.create();\n\t         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);\n\t         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);\n\t         */\n\t        init: function (words, sigBytes) {\n\t            words = this.words = words || [];\n\n\t            if (sigBytes != undefined) {\n\t                this.sigBytes = sigBytes;\n\t            } else {\n\t                this.sigBytes = words.length * 4;\n\t            }\n\t        },\n\n\t        /**\n\t         * Converts this word array to a string.\n\t         *\n\t         * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex\n\t         *\n\t         * @return {string} The stringified word array.\n\t         *\n\t         * @example\n\t         *\n\t         *     var string = wordArray + '';\n\t         *     var string = wordArray.toString();\n\t         *     var string = wordArray.toString(CryptoJS.enc.Utf8);\n\t         */\n\t        toString: function (encoder) {\n\t            return (encoder || Hex).stringify(this);\n\t        },\n\n\t        /**\n\t         * Concatenates a word array to this word array.\n\t         *\n\t         * @param {WordArray} wordArray The word array to append.\n\t         *\n\t         * @return {WordArray} This word array.\n\t         *\n\t         * @example\n\t         *\n\t         *     wordArray1.concat(wordArray2);\n\t         */\n\t        concat: function (wordArray) {\n\t            // Shortcuts\n\t            var thisWords = this.words;\n\t            var thatWords = wordArray.words;\n\t            var thisSigBytes = this.sigBytes;\n\t            var thatSigBytes = wordArray.sigBytes;\n\n\t            // Clamp excess bits\n\t            this.clamp();\n\n\t            // Concat\n\t            if (thisSigBytes % 4) {\n\t                // Copy one byte at a time\n\t                for (var i = 0; i < thatSigBytes; i++) {\n\t                    var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t                    thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);\n\t                }\n\t            } else {\n\t                // Copy one word at a time\n\t                for (var i = 0; i < thatSigBytes; i += 4) {\n\t                    thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];\n\t                }\n\t            }\n\t            this.sigBytes += thatSigBytes;\n\n\t            // Chainable\n\t            return this;\n\t        },\n\n\t        /**\n\t         * Removes insignificant bits.\n\t         *\n\t         * @example\n\t         *\n\t         *     wordArray.clamp();\n\t         */\n\t        clamp: function () {\n\t            // Shortcuts\n\t            var words = this.words;\n\t            var sigBytes = this.sigBytes;\n\n\t            // Clamp\n\t            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);\n\t            words.length = Math.ceil(sigBytes / 4);\n\t        },\n\n\t        /**\n\t         * Creates a copy of this word array.\n\t         *\n\t         * @return {WordArray} The clone.\n\t         *\n\t         * @example\n\t         *\n\t         *     var clone = wordArray.clone();\n\t         */\n\t        clone: function () {\n\t            var clone = Base.clone.call(this);\n\t            clone.words = this.words.slice(0);\n\n\t            return clone;\n\t        },\n\n\t        /**\n\t         * Creates a word array filled with random bytes.\n\t         *\n\t         * @param {number} nBytes The number of random bytes to generate.\n\t         *\n\t         * @return {WordArray} The random word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.lib.WordArray.random(16);\n\t         */\n\t        random: function (nBytes) {\n\t            var words = [];\n\n\t            var r = (function (m_w) {\n\t                var m_w = m_w;\n\t                var m_z = 0x3ade68b1;\n\t                var mask = 0xffffffff;\n\n\t                return function () {\n\t                    m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;\n\t                    m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;\n\t                    var result = ((m_z << 0x10) + m_w) & mask;\n\t                    result /= 0x100000000;\n\t                    result += 0.5;\n\t                    return result * (Math.random() > .5 ? 1 : -1);\n\t                }\n\t            });\n\n\t            for (var i = 0, rcache; i < nBytes; i += 4) {\n\t                var _r = r((rcache || Math.random()) * 0x100000000);\n\n\t                rcache = _r() * 0x3ade67b7;\n\t                words.push((_r() * 0x100000000) | 0);\n\t            }\n\n\t            return new WordArray.init(words, nBytes);\n\t        }\n\t    });\n\n\t    /**\n\t     * Encoder namespace.\n\t     */\n\t    var C_enc = C.enc = {};\n\n\t    /**\n\t     * Hex encoding strategy.\n\t     */\n\t    var Hex = C_enc.Hex = {\n\t        /**\n\t         * Converts a word array to a hex string.\n\t         *\n\t         * @param {WordArray} wordArray The word array.\n\t         *\n\t         * @return {string} The hex string.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);\n\t         */\n\t        stringify: function (wordArray) {\n\t            // Shortcuts\n\t            var words = wordArray.words;\n\t            var sigBytes = wordArray.sigBytes;\n\n\t            // Convert\n\t            var hexChars = [];\n\t            for (var i = 0; i < sigBytes; i++) {\n\t                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t                hexChars.push((bite >>> 4).toString(16));\n\t                hexChars.push((bite & 0x0f).toString(16));\n\t            }\n\n\t            return hexChars.join('');\n\t        },\n\n\t        /**\n\t         * Converts a hex string to a word array.\n\t         *\n\t         * @param {string} hexStr The hex string.\n\t         *\n\t         * @return {WordArray} The word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.enc.Hex.parse(hexString);\n\t         */\n\t        parse: function (hexStr) {\n\t            // Shortcut\n\t            var hexStrLength = hexStr.length;\n\n\t            // Convert\n\t            var words = [];\n\t            for (var i = 0; i < hexStrLength; i += 2) {\n\t                words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);\n\t            }\n\n\t            return new WordArray.init(words, hexStrLength / 2);\n\t        }\n\t    };\n\n\t    /**\n\t     * Latin1 encoding strategy.\n\t     */\n\t    var Latin1 = C_enc.Latin1 = {\n\t        /**\n\t         * Converts a word array to a Latin1 string.\n\t         *\n\t         * @param {WordArray} wordArray The word array.\n\t         *\n\t         * @return {string} The Latin1 string.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);\n\t         */\n\t        stringify: function (wordArray) {\n\t            // Shortcuts\n\t            var words = wordArray.words;\n\t            var sigBytes = wordArray.sigBytes;\n\n\t            // Convert\n\t            var latin1Chars = [];\n\t            for (var i = 0; i < sigBytes; i++) {\n\t                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t                latin1Chars.push(String.fromCharCode(bite));\n\t            }\n\n\t            return latin1Chars.join('');\n\t        },\n\n\t        /**\n\t         * Converts a Latin1 string to a word array.\n\t         *\n\t         * @param {string} latin1Str The Latin1 string.\n\t         *\n\t         * @return {WordArray} The word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);\n\t         */\n\t        parse: function (latin1Str) {\n\t            // Shortcut\n\t            var latin1StrLength = latin1Str.length;\n\n\t            // Convert\n\t            var words = [];\n\t            for (var i = 0; i < latin1StrLength; i++) {\n\t                words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);\n\t            }\n\n\t            return new WordArray.init(words, latin1StrLength);\n\t        }\n\t    };\n\n\t    /**\n\t     * UTF-8 encoding strategy.\n\t     */\n\t    var Utf8 = C_enc.Utf8 = {\n\t        /**\n\t         * Converts a word array to a UTF-8 string.\n\t         *\n\t         * @param {WordArray} wordArray The word array.\n\t         *\n\t         * @return {string} The UTF-8 string.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);\n\t         */\n\t        stringify: function (wordArray) {\n\t            try {\n\t                return decodeURIComponent(escape(Latin1.stringify(wordArray)));\n\t            } catch (e) {\n\t                throw new Error('Malformed UTF-8 data');\n\t            }\n\t        },\n\n\t        /**\n\t         * Converts a UTF-8 string to a word array.\n\t         *\n\t         * @param {string} utf8Str The UTF-8 string.\n\t         *\n\t         * @return {WordArray} The word array.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);\n\t         */\n\t        parse: function (utf8Str) {\n\t            return Latin1.parse(unescape(encodeURIComponent(utf8Str)));\n\t        }\n\t    };\n\n\t    /**\n\t     * Abstract buffered block algorithm template.\n\t     *\n\t     * The property blockSize must be implemented in a concrete subtype.\n\t     *\n\t     * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0\n\t     */\n\t    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({\n\t        /**\n\t         * Resets this block algorithm's data buffer to its initial state.\n\t         *\n\t         * @example\n\t         *\n\t         *     bufferedBlockAlgorithm.reset();\n\t         */\n\t        reset: function () {\n\t            // Initial values\n\t            this._data = new WordArray.init();\n\t            this._nDataBytes = 0;\n\t        },\n\n\t        /**\n\t         * Adds new data to this block algorithm's buffer.\n\t         *\n\t         * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.\n\t         *\n\t         * @example\n\t         *\n\t         *     bufferedBlockAlgorithm._append('data');\n\t         *     bufferedBlockAlgorithm._append(wordArray);\n\t         */\n\t        _append: function (data) {\n\t            // Convert string to WordArray, else assume WordArray already\n\t            if (typeof data == 'string') {\n\t                data = Utf8.parse(data);\n\t            }\n\n\t            // Append\n\t            this._data.concat(data);\n\t            this._nDataBytes += data.sigBytes;\n\t        },\n\n\t        /**\n\t         * Processes available data blocks.\n\t         *\n\t         * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.\n\t         *\n\t         * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.\n\t         *\n\t         * @return {WordArray} The processed data.\n\t         *\n\t         * @example\n\t         *\n\t         *     var processedData = bufferedBlockAlgorithm._process();\n\t         *     var processedData = bufferedBlockAlgorithm._process(!!'flush');\n\t         */\n\t        _process: function (doFlush) {\n\t            // Shortcuts\n\t            var data = this._data;\n\t            var dataWords = data.words;\n\t            var dataSigBytes = data.sigBytes;\n\t            var blockSize = this.blockSize;\n\t            var blockSizeBytes = blockSize * 4;\n\n\t            // Count blocks ready\n\t            var nBlocksReady = dataSigBytes / blockSizeBytes;\n\t            if (doFlush) {\n\t                // Round up to include partial blocks\n\t                nBlocksReady = Math.ceil(nBlocksReady);\n\t            } else {\n\t                // Round down to include only full blocks,\n\t                // less the number of blocks that must remain in the buffer\n\t                nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);\n\t            }\n\n\t            // Count words ready\n\t            var nWordsReady = nBlocksReady * blockSize;\n\n\t            // Count bytes ready\n\t            var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);\n\n\t            // Process blocks\n\t            if (nWordsReady) {\n\t                for (var offset = 0; offset < nWordsReady; offset += blockSize) {\n\t                    // Perform concrete-algorithm logic\n\t                    this._doProcessBlock(dataWords, offset);\n\t                }\n\n\t                // Remove processed words\n\t                var processedWords = dataWords.splice(0, nWordsReady);\n\t                data.sigBytes -= nBytesReady;\n\t            }\n\n\t            // Return processed words\n\t            return new WordArray.init(processedWords, nBytesReady);\n\t        },\n\n\t        /**\n\t         * Creates a copy of this object.\n\t         *\n\t         * @return {Object} The clone.\n\t         *\n\t         * @example\n\t         *\n\t         *     var clone = bufferedBlockAlgorithm.clone();\n\t         */\n\t        clone: function () {\n\t            var clone = Base.clone.call(this);\n\t            clone._data = this._data.clone();\n\n\t            return clone;\n\t        },\n\n\t        _minBufferSize: 0\n\t    });\n\n\t    /**\n\t     * Abstract hasher template.\n\t     *\n\t     * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)\n\t     */\n\t    var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({\n\t        /**\n\t         * Configuration options.\n\t         */\n\t        cfg: Base.extend(),\n\n\t        /**\n\t         * Initializes a newly created hasher.\n\t         *\n\t         * @param {Object} cfg (Optional) The configuration options to use for this hash computation.\n\t         *\n\t         * @example\n\t         *\n\t         *     var hasher = CryptoJS.algo.SHA256.create();\n\t         */\n\t        init: function (cfg) {\n\t            // Apply config defaults\n\t            this.cfg = this.cfg.extend(cfg);\n\n\t            // Set initial values\n\t            this.reset();\n\t        },\n\n\t        /**\n\t         * Resets this hasher to its initial state.\n\t         *\n\t         * @example\n\t         *\n\t         *     hasher.reset();\n\t         */\n\t        reset: function () {\n\t            // Reset data buffer\n\t            BufferedBlockAlgorithm.reset.call(this);\n\n\t            // Perform concrete-hasher logic\n\t            this._doReset();\n\t        },\n\n\t        /**\n\t         * Updates this hasher with a message.\n\t         *\n\t         * @param {WordArray|string} messageUpdate The message to append.\n\t         *\n\t         * @return {Hasher} This hasher.\n\t         *\n\t         * @example\n\t         *\n\t         *     hasher.update('message');\n\t         *     hasher.update(wordArray);\n\t         */\n\t        update: function (messageUpdate) {\n\t            // Append\n\t            this._append(messageUpdate);\n\n\t            // Update the hash\n\t            this._process();\n\n\t            // Chainable\n\t            return this;\n\t        },\n\n\t        /**\n\t         * Finalizes the hash computation.\n\t         * Note that the finalize operation is effectively a destructive, read-once operation.\n\t         *\n\t         * @param {WordArray|string} messageUpdate (Optional) A final message update.\n\t         *\n\t         * @return {WordArray} The hash.\n\t         *\n\t         * @example\n\t         *\n\t         *     var hash = hasher.finalize();\n\t         *     var hash = hasher.finalize('message');\n\t         *     var hash = hasher.finalize(wordArray);\n\t         */\n\t        finalize: function (messageUpdate) {\n\t            // Final message update\n\t            if (messageUpdate) {\n\t                this._append(messageUpdate);\n\t            }\n\n\t            // Perform concrete-hasher logic\n\t            var hash = this._doFinalize();\n\n\t            return hash;\n\t        },\n\n\t        blockSize: 512/32,\n\n\t        /**\n\t         * Creates a shortcut function to a hasher's object interface.\n\t         *\n\t         * @param {Hasher} hasher The hasher to create a helper for.\n\t         *\n\t         * @return {Function} The shortcut function.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);\n\t         */\n\t        _createHelper: function (hasher) {\n\t            return function (message, cfg) {\n\t                return new hasher.init(cfg).finalize(message);\n\t            };\n\t        },\n\n\t        /**\n\t         * Creates a shortcut function to the HMAC's object interface.\n\t         *\n\t         * @param {Hasher} hasher The hasher to use in this HMAC helper.\n\t         *\n\t         * @return {Function} The shortcut function.\n\t         *\n\t         * @static\n\t         *\n\t         * @example\n\t         *\n\t         *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);\n\t         */\n\t        _createHmacHelper: function (hasher) {\n\t            return function (message, key) {\n\t                return new C_algo.HMAC.init(hasher, key).finalize(message);\n\t            };\n\t        }\n\t    });\n\n\t    /**\n\t     * Algorithm namespace.\n\t     */\n\t    var C_algo = C.algo = {};\n\n\t    return C;\n\t}(Math));\n\n\n\treturn CryptoJS;\n\n}));\n},{}],18:[function(require,module,exports){\n;(function (root, factory, undef) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"), require(\"./x64-core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\", \"./x64-core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (Math) {\n\t    // Shortcuts\n\t    var C = CryptoJS;\n\t    var C_lib = C.lib;\n\t    var WordArray = C_lib.WordArray;\n\t    var Hasher = C_lib.Hasher;\n\t    var C_x64 = C.x64;\n\t    var X64Word = C_x64.Word;\n\t    var C_algo = C.algo;\n\n\t    // Constants tables\n\t    var RHO_OFFSETS = [];\n\t    var PI_INDEXES  = [];\n\t    var ROUND_CONSTANTS = [];\n\n\t    // Compute Constants\n\t    (function () {\n\t        // Compute rho offset constants\n\t        var x = 1, y = 0;\n\t        for (var t = 0; t < 24; t++) {\n\t            RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;\n\n\t            var newX = y % 5;\n\t            var newY = (2 * x + 3 * y) % 5;\n\t            x = newX;\n\t            y = newY;\n\t        }\n\n\t        // Compute pi index constants\n\t        for (var x = 0; x < 5; x++) {\n\t            for (var y = 0; y < 5; y++) {\n\t                PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;\n\t            }\n\t        }\n\n\t        // Compute round constants\n\t        var LFSR = 0x01;\n\t        for (var i = 0; i < 24; i++) {\n\t            var roundConstantMsw = 0;\n\t            var roundConstantLsw = 0;\n\n\t            for (var j = 0; j < 7; j++) {\n\t                if (LFSR & 0x01) {\n\t                    var bitPosition = (1 << j) - 1;\n\t                    if (bitPosition < 32) {\n\t                        roundConstantLsw ^= 1 << bitPosition;\n\t                    } else /* if (bitPosition >= 32) */ {\n\t                        roundConstantMsw ^= 1 << (bitPosition - 32);\n\t                    }\n\t                }\n\n\t                // Compute next LFSR\n\t                if (LFSR & 0x80) {\n\t                    // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1\n\t                    LFSR = (LFSR << 1) ^ 0x71;\n\t                } else {\n\t                    LFSR <<= 1;\n\t                }\n\t            }\n\n\t            ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);\n\t        }\n\t    }());\n\n\t    // Reusable objects for temporary values\n\t    var T = [];\n\t    (function () {\n\t        for (var i = 0; i < 25; i++) {\n\t            T[i] = X64Word.create();\n\t        }\n\t    }());\n\n\t    /**\n\t     * SHA-3 hash algorithm.\n\t     */\n\t    var SHA3 = C_algo.SHA3 = Hasher.extend({\n\t        /**\n\t         * Configuration options.\n\t         *\n\t         * @property {number} outputLength\n\t         *   The desired number of bits in the output hash.\n\t         *   Only values permitted are: 224, 256, 384, 512.\n\t         *   Default: 512\n\t         */\n\t        cfg: Hasher.cfg.extend({\n\t            outputLength: 512\n\t        }),\n\n\t        _doReset: function () {\n\t            var state = this._state = []\n\t            for (var i = 0; i < 25; i++) {\n\t                state[i] = new X64Word.init();\n\t            }\n\n\t            this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;\n\t        },\n\n\t        _doProcessBlock: function (M, offset) {\n\t            // Shortcuts\n\t            var state = this._state;\n\t            var nBlockSizeLanes = this.blockSize / 2;\n\n\t            // Absorb\n\t            for (var i = 0; i < nBlockSizeLanes; i++) {\n\t                // Shortcuts\n\t                var M2i  = M[offset + 2 * i];\n\t                var M2i1 = M[offset + 2 * i + 1];\n\n\t                // Swap endian\n\t                M2i = (\n\t                    (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |\n\t                    (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)\n\t                );\n\t                M2i1 = (\n\t                    (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |\n\t                    (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)\n\t                );\n\n\t                // Absorb message into state\n\t                var lane = state[i];\n\t                lane.high ^= M2i1;\n\t                lane.low  ^= M2i;\n\t            }\n\n\t            // Rounds\n\t            for (var round = 0; round < 24; round++) {\n\t                // Theta\n\t                for (var x = 0; x < 5; x++) {\n\t                    // Mix column lanes\n\t                    var tMsw = 0, tLsw = 0;\n\t                    for (var y = 0; y < 5; y++) {\n\t                        var lane = state[x + 5 * y];\n\t                        tMsw ^= lane.high;\n\t                        tLsw ^= lane.low;\n\t                    }\n\n\t                    // Temporary values\n\t                    var Tx = T[x];\n\t                    Tx.high = tMsw;\n\t                    Tx.low  = tLsw;\n\t                }\n\t                for (var x = 0; x < 5; x++) {\n\t                    // Shortcuts\n\t                    var Tx4 = T[(x + 4) % 5];\n\t                    var Tx1 = T[(x + 1) % 5];\n\t                    var Tx1Msw = Tx1.high;\n\t                    var Tx1Lsw = Tx1.low;\n\n\t                    // Mix surrounding columns\n\t                    var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));\n\t                    var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));\n\t                    for (var y = 0; y < 5; y++) {\n\t                        var lane = state[x + 5 * y];\n\t                        lane.high ^= tMsw;\n\t                        lane.low  ^= tLsw;\n\t                    }\n\t                }\n\n\t                // Rho Pi\n\t                for (var laneIndex = 1; laneIndex < 25; laneIndex++) {\n\t                    // Shortcuts\n\t                    var lane = state[laneIndex];\n\t                    var laneMsw = lane.high;\n\t                    var laneLsw = lane.low;\n\t                    var rhoOffset = RHO_OFFSETS[laneIndex];\n\n\t                    // Rotate lanes\n\t                    if (rhoOffset < 32) {\n\t                        var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));\n\t                        var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));\n\t                    } else /* if (rhoOffset >= 32) */ {\n\t                        var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));\n\t                        var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));\n\t                    }\n\n\t                    // Transpose lanes\n\t                    var TPiLane = T[PI_INDEXES[laneIndex]];\n\t                    TPiLane.high = tMsw;\n\t                    TPiLane.low  = tLsw;\n\t                }\n\n\t                // Rho pi at x = y = 0\n\t                var T0 = T[0];\n\t                var state0 = state[0];\n\t                T0.high = state0.high;\n\t                T0.low  = state0.low;\n\n\t                // Chi\n\t                for (var x = 0; x < 5; x++) {\n\t                    for (var y = 0; y < 5; y++) {\n\t                        // Shortcuts\n\t                        var laneIndex = x + 5 * y;\n\t                        var lane = state[laneIndex];\n\t                        var TLane = T[laneIndex];\n\t                        var Tx1Lane = T[((x + 1) % 5) + 5 * y];\n\t                        var Tx2Lane = T[((x + 2) % 5) + 5 * y];\n\n\t                        // Mix rows\n\t                        lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);\n\t                        lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);\n\t                    }\n\t                }\n\n\t                // Iota\n\t                var lane = state[0];\n\t                var roundConstant = ROUND_CONSTANTS[round];\n\t                lane.high ^= roundConstant.high;\n\t                lane.low  ^= roundConstant.low;;\n\t            }\n\t        },\n\n\t        _doFinalize: function () {\n\t            // Shortcuts\n\t            var data = this._data;\n\t            var dataWords = data.words;\n\t            var nBitsTotal = this._nDataBytes * 8;\n\t            var nBitsLeft = data.sigBytes * 8;\n\t            var blockSizeBits = this.blockSize * 32;\n\n\t            // Add padding\n\t            dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);\n\t            dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;\n\t            data.sigBytes = dataWords.length * 4;\n\n\t            // Hash final blocks\n\t            this._process();\n\n\t            // Shortcuts\n\t            var state = this._state;\n\t            var outputLengthBytes = this.cfg.outputLength / 8;\n\t            var outputLengthLanes = outputLengthBytes / 8;\n\n\t            // Squeeze\n\t            var hashWords = [];\n\t            for (var i = 0; i < outputLengthLanes; i++) {\n\t                // Shortcuts\n\t                var lane = state[i];\n\t                var laneMsw = lane.high;\n\t                var laneLsw = lane.low;\n\n\t                // Swap endian\n\t                laneMsw = (\n\t                    (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |\n\t                    (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)\n\t                );\n\t                laneLsw = (\n\t                    (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |\n\t                    (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)\n\t                );\n\n\t                // Squeeze state to retrieve hash\n\t                hashWords.push(laneLsw);\n\t                hashWords.push(laneMsw);\n\t            }\n\n\t            // Return final computed hash\n\t            return new WordArray.init(hashWords, outputLengthBytes);\n\t        },\n\n\t        clone: function () {\n\t            var clone = Hasher.clone.call(this);\n\n\t            var state = clone._state = this._state.slice(0);\n\t            for (var i = 0; i < 25; i++) {\n\t                state[i] = state[i].clone();\n\t            }\n\n\t            return clone;\n\t        }\n\t    });\n\n\t    /**\n\t     * Shortcut function to the hasher's object interface.\n\t     *\n\t     * @param {WordArray|string} message The message to hash.\n\t     *\n\t     * @return {WordArray} The hash.\n\t     *\n\t     * @static\n\t     *\n\t     * @example\n\t     *\n\t     *     var hash = CryptoJS.SHA3('message');\n\t     *     var hash = CryptoJS.SHA3(wordArray);\n\t     */\n\t    C.SHA3 = Hasher._createHelper(SHA3);\n\n\t    /**\n\t     * Shortcut function to the HMAC's object interface.\n\t     *\n\t     * @param {WordArray|string} message The message to hash.\n\t     * @param {WordArray|string} key The secret key.\n\t     *\n\t     * @return {WordArray} The HMAC.\n\t     *\n\t     * @static\n\t     *\n\t     * @example\n\t     *\n\t     *     var hmac = CryptoJS.HmacSHA3(message, key);\n\t     */\n\t    C.HmacSHA3 = Hasher._createHmacHelper(SHA3);\n\t}(Math));\n\n\n\treturn CryptoJS.SHA3;\n\n}));\n},{\"./core\":17,\"./x64-core\":19}],19:[function(require,module,exports){\n;(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (undefined) {\n\t    // Shortcuts\n\t    var C = CryptoJS;\n\t    var C_lib = C.lib;\n\t    var Base = C_lib.Base;\n\t    var X32WordArray = C_lib.WordArray;\n\n\t    /**\n\t     * x64 namespace.\n\t     */\n\t    var C_x64 = C.x64 = {};\n\n\t    /**\n\t     * A 64-bit word.\n\t     */\n\t    var X64Word = C_x64.Word = Base.extend({\n\t        /**\n\t         * Initializes a newly created 64-bit word.\n\t         *\n\t         * @param {number} high The high 32 bits.\n\t         * @param {number} low The low 32 bits.\n\t         *\n\t         * @example\n\t         *\n\t         *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);\n\t         */\n\t        init: function (high, low) {\n\t            this.high = high;\n\t            this.low = low;\n\t        }\n\n\t        /**\n\t         * Bitwise NOTs this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after negating.\n\t         *\n\t         * @example\n\t         *\n\t         *     var negated = x64Word.not();\n\t         */\n\t        // not: function () {\n\t            // var high = ~this.high;\n\t            // var low = ~this.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Bitwise ANDs this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to AND with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after ANDing.\n\t         *\n\t         * @example\n\t         *\n\t         *     var anded = x64Word.and(anotherX64Word);\n\t         */\n\t        // and: function (word) {\n\t            // var high = this.high & word.high;\n\t            // var low = this.low & word.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Bitwise ORs this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to OR with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after ORing.\n\t         *\n\t         * @example\n\t         *\n\t         *     var ored = x64Word.or(anotherX64Word);\n\t         */\n\t        // or: function (word) {\n\t            // var high = this.high | word.high;\n\t            // var low = this.low | word.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Bitwise XORs this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to XOR with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after XORing.\n\t         *\n\t         * @example\n\t         *\n\t         *     var xored = x64Word.xor(anotherX64Word);\n\t         */\n\t        // xor: function (word) {\n\t            // var high = this.high ^ word.high;\n\t            // var low = this.low ^ word.low;\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Shifts this word n bits to the left.\n\t         *\n\t         * @param {number} n The number of bits to shift.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after shifting.\n\t         *\n\t         * @example\n\t         *\n\t         *     var shifted = x64Word.shiftL(25);\n\t         */\n\t        // shiftL: function (n) {\n\t            // if (n < 32) {\n\t                // var high = (this.high << n) | (this.low >>> (32 - n));\n\t                // var low = this.low << n;\n\t            // } else {\n\t                // var high = this.low << (n - 32);\n\t                // var low = 0;\n\t            // }\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Shifts this word n bits to the right.\n\t         *\n\t         * @param {number} n The number of bits to shift.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after shifting.\n\t         *\n\t         * @example\n\t         *\n\t         *     var shifted = x64Word.shiftR(7);\n\t         */\n\t        // shiftR: function (n) {\n\t            // if (n < 32) {\n\t                // var low = (this.low >>> n) | (this.high << (32 - n));\n\t                // var high = this.high >>> n;\n\t            // } else {\n\t                // var low = this.high >>> (n - 32);\n\t                // var high = 0;\n\t            // }\n\n\t            // return X64Word.create(high, low);\n\t        // },\n\n\t        /**\n\t         * Rotates this word n bits to the left.\n\t         *\n\t         * @param {number} n The number of bits to rotate.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after rotating.\n\t         *\n\t         * @example\n\t         *\n\t         *     var rotated = x64Word.rotL(25);\n\t         */\n\t        // rotL: function (n) {\n\t            // return this.shiftL(n).or(this.shiftR(64 - n));\n\t        // },\n\n\t        /**\n\t         * Rotates this word n bits to the right.\n\t         *\n\t         * @param {number} n The number of bits to rotate.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after rotating.\n\t         *\n\t         * @example\n\t         *\n\t         *     var rotated = x64Word.rotR(7);\n\t         */\n\t        // rotR: function (n) {\n\t            // return this.shiftR(n).or(this.shiftL(64 - n));\n\t        // },\n\n\t        /**\n\t         * Adds this word with the passed word.\n\t         *\n\t         * @param {X64Word} word The x64-Word to add with this word.\n\t         *\n\t         * @return {X64Word} A new x64-Word object after adding.\n\t         *\n\t         * @example\n\t         *\n\t         *     var added = x64Word.add(anotherX64Word);\n\t         */\n\t        // add: function (word) {\n\t            // var low = (this.low + word.low) | 0;\n\t            // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;\n\t            // var high = (this.high + word.high + carry) | 0;\n\n\t            // return X64Word.create(high, low);\n\t        // }\n\t    });\n\n\t    /**\n\t     * An array of 64-bit words.\n\t     *\n\t     * @property {Array} words The array of CryptoJS.x64.Word objects.\n\t     * @property {number} sigBytes The number of significant bytes in this word array.\n\t     */\n\t    var X64WordArray = C_x64.WordArray = Base.extend({\n\t        /**\n\t         * Initializes a newly created word array.\n\t         *\n\t         * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.\n\t         * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t         *\n\t         * @example\n\t         *\n\t         *     var wordArray = CryptoJS.x64.WordArray.create();\n\t         *\n\t         *     var wordArray = CryptoJS.x64.WordArray.create([\n\t         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),\n\t         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)\n\t         *     ]);\n\t         *\n\t         *     var wordArray = CryptoJS.x64.WordArray.create([\n\t         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),\n\t         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)\n\t         *     ], 10);\n\t         */\n\t        init: function (words, sigBytes) {\n\t            words = this.words = words || [];\n\n\t            if (sigBytes != undefined) {\n\t                this.sigBytes = sigBytes;\n\t            } else {\n\t                this.sigBytes = words.length * 8;\n\t            }\n\t        },\n\n\t        /**\n\t         * Converts this 64-bit word array to a 32-bit word array.\n\t         *\n\t         * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.\n\t         *\n\t         * @example\n\t         *\n\t         *     var x32WordArray = x64WordArray.toX32();\n\t         */\n\t        toX32: function () {\n\t            // Shortcuts\n\t            var x64Words = this.words;\n\t            var x64WordsLength = x64Words.length;\n\n\t            // Convert\n\t            var x32Words = [];\n\t            for (var i = 0; i < x64WordsLength; i++) {\n\t                var x64Word = x64Words[i];\n\t                x32Words.push(x64Word.high);\n\t                x32Words.push(x64Word.low);\n\t            }\n\n\t            return X32WordArray.create(x32Words, this.sigBytes);\n\t        },\n\n\t        /**\n\t         * Creates a copy of this word array.\n\t         *\n\t         * @return {X64WordArray} The clone.\n\t         *\n\t         * @example\n\t         *\n\t         *     var clone = x64WordArray.clone();\n\t         */\n\t        clone: function () {\n\t            var clone = Base.clone.call(this);\n\n\t            // Clone \"words\" array\n\t            var words = clone.words = this.words.slice(0);\n\n\t            // Clone each X64Word object\n\t            var wordsLength = words.length;\n\t            for (var i = 0; i < wordsLength; i++) {\n\t                words[i] = words[i].clone();\n\t            }\n\n\t            return clone;\n\t        }\n\t    });\n\t}());\n\n\n\treturn CryptoJS;\n\n}));\n},{\"./core\":17}],20:[function(require,module,exports){\nmodule.exports={\n  \"_args\": [\n    [\n      {\n        \"raw\": \"truffle-contract-schema@0.0.5\",\n        \"scope\": null,\n        \"escapedName\": \"truffle-contract-schema\",\n        \"name\": \"truffle-contract-schema\",\n        \"rawSpec\": \"0.0.5\",\n        \"spec\": \"0.0.5\",\n        \"type\": \"version\"\n      },\n      \"/Users/tim/Documents/workspace/Consensys/truffle-contract\"\n    ]\n  ],\n  \"_from\": \"truffle-contract-schema@0.0.5\",\n  \"_id\": \"truffle-contract-schema@0.0.5\",\n  \"_inCache\": true,\n  \"_location\": \"/truffle-contract-schema\",\n  \"_nodeVersion\": \"6.9.1\",\n  \"_npmOperationalInternal\": {\n    \"host\": \"packages-12-west.internal.npmjs.com\",\n    \"tmp\": \"tmp/truffle-contract-schema-0.0.5.tgz_1485557985137_0.46875762194395065\"\n  },\n  \"_npmUser\": {\n    \"name\": \"tcoulter\",\n    \"email\": \"tim@timothyjcoulter.com\"\n  },\n  \"_npmVersion\": \"3.10.8\",\n  \"_phantomChildren\": {},\n  \"_requested\": {\n    \"raw\": \"truffle-contract-schema@0.0.5\",\n    \"scope\": null,\n    \"escapedName\": \"truffle-contract-schema\",\n    \"name\": \"truffle-contract-schema\",\n    \"rawSpec\": \"0.0.5\",\n    \"spec\": \"0.0.5\",\n    \"type\": \"version\"\n  },\n  \"_requiredBy\": [\n    \"/\"\n  ],\n  \"_resolved\": \"https://registry.npmjs.org/truffle-contract-schema/-/truffle-contract-schema-0.0.5.tgz\",\n  \"_shasum\": \"5e9d20bd0bf2a27fe94310748249d484eee49961\",\n  \"_shrinkwrap\": null,\n  \"_spec\": \"truffle-contract-schema@0.0.5\",\n  \"_where\": \"/Users/tim/Documents/workspace/Consensys/truffle-contract\",\n  \"author\": {\n    \"name\": \"Tim Coulter\",\n    \"email\": \"tim.coulter@consensys.net\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/trufflesuite/truffle-schema/issues\"\n  },\n  \"dependencies\": {\n    \"crypto-js\": \"^3.1.9-1\"\n  },\n  \"description\": \"JSON schema for contract artifacts\",\n  \"devDependencies\": {\n    \"mocha\": \"^3.2.0\"\n  },\n  \"directories\": {},\n  \"dist\": {\n    \"shasum\": \"5e9d20bd0bf2a27fe94310748249d484eee49961\",\n    \"tarball\": \"https://registry.npmjs.org/truffle-contract-schema/-/truffle-contract-schema-0.0.5.tgz\"\n  },\n  \"gitHead\": \"cfa4313bd4bb95bf5b94f85185203ead418f9ee6\",\n  \"homepage\": \"https://github.com/trufflesuite/truffle-schema#readme\",\n  \"keywords\": [\n    \"ethereum\",\n    \"json\",\n    \"schema\",\n    \"contract\",\n    \"artifacts\"\n  ],\n  \"license\": \"MIT\",\n  \"main\": \"index.js\",\n  \"maintainers\": [\n    {\n      \"name\": \"tcoulter\",\n      \"email\": \"tim@timothyjcoulter.com\"\n    }\n  ],\n  \"name\": \"truffle-contract-schema\",\n  \"optionalDependencies\": {},\n  \"readme\": \"ERROR: No README data found!\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/trufflesuite/truffle-schema.git\"\n  },\n  \"scripts\": {\n    \"test\": \"mocha\"\n  },\n  \"version\": \"0.0.5\"\n}\n\n},{}]},{},[2]);\n"
  },
  {
    "path": "truffle/tpetshop/src/pets.json",
    "content": "[\n  {\n    \"id\": 0,\n    \"name\": \"Frieda\",\n    \"picture\": \"images/scottish-terrier.jpeg\",\n    \"age\": 3,\n    \"breed\": \"Scottish Terrier\",\n    \"location\": \"Lisco, Alabama\"\n  },\n  {\n    \"id\": 1,\n    \"name\": \"Gina\",\n    \"picture\": \"images/scottish-terrier.jpeg\",\n    \"age\": 3,\n    \"breed\": \"Scottish Terrier\",\n    \"location\": \"Tooleville, West Virginia\"\n  },\n  {\n    \"id\": 2,\n    \"name\": \"Collins\",\n    \"picture\": \"images/french-bulldog.jpeg\",\n    \"age\": 2,\n    \"breed\": \"French Bulldog\",\n    \"location\": \"Freeburn, Idaho\"\n  },\n  {\n    \"id\": 3,\n    \"name\": \"Melissa\",\n    \"picture\": \"images/boxer.jpeg\",\n    \"age\": 2,\n    \"breed\": \"Boxer\",\n    \"location\": \"Camas, Pennsylvania\"\n  },\n  {\n    \"id\": 4,\n    \"name\": \"Jeanine\",\n    \"picture\": \"images/french-bulldog.jpeg\",\n    \"age\": 2,\n    \"breed\": \"French Bulldog\",\n    \"location\": \"Gerber, South Dakota\"\n  },\n  {\n    \"id\": 5,\n    \"name\": \"Elvia\",\n    \"picture\": \"images/french-bulldog.jpeg\",\n    \"age\": 3,\n    \"breed\": \"French Bulldog\",\n    \"location\": \"Innsbrook, Illinois\"\n  },\n  {\n    \"id\": 6,\n    \"name\": \"Latisha\",\n    \"picture\": \"images/golden-retriever.jpeg\",\n    \"age\": 3,\n    \"breed\": \"Golden Retriever\",\n    \"location\": \"Soudan, Louisiana\"\n  },\n  {\n    \"id\": 7,\n    \"name\": \"Coleman\",\n    \"picture\": \"images/golden-retriever.jpeg\",\n    \"age\": 3,\n    \"breed\": \"Golden Retriever\",\n    \"location\": \"Jacksonwald, Palau\"\n  },\n  {\n    \"id\": 8,\n    \"name\": \"Nichole\",\n    \"picture\": \"images/french-bulldog.jpeg\",\n    \"age\": 2,\n    \"breed\": \"French Bulldog\",\n    \"location\": \"Honolulu, Hawaii\"\n  },\n  {\n    \"id\": 9,\n    \"name\": \"Fran\",\n    \"picture\": \"images/boxer.jpeg\",\n    \"age\": 3,\n    \"breed\": \"Boxer\",\n    \"location\": \"Matheny, Utah\"\n  },\n  {\n    \"id\": 10,\n    \"name\": \"Leonor\",\n    \"picture\": \"images/boxer.jpeg\",\n    \"age\": 2,\n    \"breed\": \"Boxer\",\n    \"location\": \"Tyhee, Indiana\"\n  },\n  {\n    \"id\": 11,\n    \"name\": \"Dean\",\n    \"picture\": \"images/scottish-terrier.jpeg\",\n    \"age\": 3,\n    \"breed\": \"Golden Retriever\",\n    \"location\": \"Windsor, Montana\"\n  },\n  {\n    \"id\": 12,\n    \"name\": \"Stevenson\",\n    \"picture\": \"images/french-bulldog.jpeg\",\n    \"age\": 3,\n    \"breed\": \"French Bulldog\",\n    \"location\": \"Kingstowne, Nevada\"\n  },\n  {\n    \"id\": 13,\n    \"name\": \"Kristina\",\n    \"picture\": \"images/golden-retriever.jpeg\",\n    \"age\": 4,\n    \"breed\": \"Golden Retriever\",\n    \"location\": \"Sultana, Massachusetts\"\n  },\n  {\n    \"id\": 14,\n    \"name\": \"Ethel\",\n    \"picture\": \"images/golden-retriever.jpeg\",\n    \"age\": 2,\n    \"breed\": \"Golden Retriever\",\n    \"location\": \"Broadlands, Oregon\"\n  },\n  {\n    \"id\": 15,\n    \"name\": \"Terry\",\n    \"picture\": \"images/golden-retriever.jpeg\",\n    \"age\": 2,\n    \"breed\": \"Golden Retriever\",\n    \"location\": \"Dawn, Wisconsin\"\n  }\n]\n"
  },
  {
    "path": "truffle/tpetshop/test/.gitkeep",
    "content": ""
  },
  {
    "path": "truffle/tpetshop/test/TestAdoption.sol",
    "content": "import \"truffle/Assert.sol\";\r\nimport \"truffle/DeployedAddresses.sol\";\r\nimport \"../contracts/Adoption.sol\";\r\n\r\ncontract TestAdoption {\r\n  Adoption adoption = Adoption(DeployedAddresses.Adoption());\r\n\r\n\t// Testing the adopt() function\r\n\tfunction testUserCanAdoptPet() {\r\n\t  uint returnedId = adoption.adopt(8);\r\n\r\n\t  uint expected = 8;\r\n\r\n\t  Assert.equal(returnedId, expected, \"Adoption of pet ID 8 should be recorded.\");\r\n\t}\r\n\r\n\t// Testing retrieval of a single pet's owner\r\n\tfunction testGetAdopterAddressByPetId() {\r\n\t  // Expected owner is this contract\r\n\t  address expected = this;\r\n\r\n\t  address adopter = adoption.adopters(8);\r\n\r\n\t  Assert.equal(adopter, expected, \"Owner of pet ID 8 should be recorded.\");\r\n\t}\r\n\r\n\t// Testing retrieval of all pet owners\r\n\tfunction testGetAdopterAddressByPetIdInArray() {\r\n\t  // Expected owner is this contract\r\n\t  address expected = this;\r\n\r\n\t  // Store adopters in memory rather than contract's storage\r\n\t  address[16] memory adopters = adoption.getAdopters();\r\n\r\n\t  Assert.equal(adopters[8], expected, \"Owner of pet ID 8 should be recorded.\");\r\n\t}\r\n}\r\n\r\n"
  },
  {
    "path": "truffle/tpetshop/truffle-config.js",
    "content": "module.exports = {\n  networks: {\n    development: {\n      host: \"localhost\",\n      port: 8545,\n      network_id: \"*\" // Match any network id\n    }\n  }\n};"
  },
  {
    "path": "truffle/webapp/.babelrc",
    "content": "{\n  \"presets\": [\"env\"]\n}\n"
  },
  {
    "path": "truffle/webapp/.eslintignore",
    "content": "tmp/**\nbuild/**\nnode_modules/**\ncontracts/**\nmigrations/1_initial_migration.js\nmigrations/2_deploy_contracts.js\ntest/metacoin.js\n"
  },
  {
    "path": "truffle/webapp/.eslintrc",
    "content": "{\n  \"parser\": \"babel-eslint\",\n    \"extends\": [\n      \"standard\"\n    ],\n    \"plugins\": [\n      \"babel\"\n    ],\n    \"rules\": {\n      \"key-spacing\"          : 0,\n      \"jsx-quotes\"           : [2, \"prefer-single\"],\n      \"max-len\"              : [2, 120, 2],\n      \"object-curly-spacing\" : [2, \"always\"]\n    }\n}\n"
  },
  {
    "path": "truffle/webapp/.gitignore",
    "content": "build\nnode_modules\nyarn-error.log\n"
  },
  {
    "path": "truffle/webapp/ORIGINALREADME.md",
    "content": "# Webpack Truffle Box\n\nThis box it our most bare official implementation with Webpack. Includes contracts, migrations, tests, user interface and webpack build pipeline.\n\n## Installation\n\n1. Install Truffle globally.\n    ```javascript\n    npm install -g truffle\n    ```\n\n2. Download the box. This also takes care of installing the necessary dependencies.\n    ```javascript\n    truffle unbox webpack\n    ```\n\n3. Run the development console.\n    ```javascript\n    truffle develop\n    ```\n\n4. Compile and migrate the smart contracts. Note inside the development console we don't preface commands with `truffle`.\n    ```javascript\n    compile\n    migrate\n    ```\n\n5. Run the webpack server for front-end hot reloading (outside the development console). Smart contract changes must be manually recompiled and migrated.\n    ```javascript\n    // Serves the front-end on http://localhost:8080\n    npm run dev\n    ```\n\n6. Truffle can run tests written in Solidity or JavaScript against your smart contracts. Note the command varies slightly if you're in or outside of the development console.\n  ```javascript\n  // If inside the development console.\n  test\n\n  // If outside the development console..\n  truffle test\n  ```\n\n## FAQ\n\n* __How do I use this with the EthereumJS TestRPC?__\n\n    It's as easy as modifying the config file! [Check out our documentation on adding network configurations](http://truffleframework.com/docs/advanced/configuration#networks). Depending on the port you're using, you'll also need to update lines 96 and 98 of `app/javascripts/app.js`.\n\n* __I'm encountering this error: Error: Can't resolve '../build/contracts/MetaCoin.json'__\n\n  This means you haven't compiled or migrated your contracts yet. Run `truffle develop`, `compile` and `migrate` first.\n\n  Full error:\n\n  ```\n  ERROR in ./app/main.js\n  Module not found: Error: Can't resolve '../build/contracts/MetaCoin.json' in '/Users/tim/Documents/workspace/Consensys/test3/app'\n   @ ./app/main.js 11:16-59\n  ```\n"
  },
  {
    "path": "truffle/webapp/README.md",
    "content": "# Webpack Truffle Demo\r\n\r\nFrom http://truffleframework.com/tutorials/building-testing-frontend-app-truffle-3\r\n\r\nLaunch an Ethereum client, like TestRPC, RPC entry point at http://127.0.0.1:8545. If you need to change the address\r\nedit the file `app\\javascripts\\app.js`.\r\n\r\nRun\r\n```\r\ntruffle compile\r\ntruffle deploy\r\nnpm run build\r\nnpm run dev\r\n```\r\n\r\nIn Windows you must use `truffle.cmd` instead of `truffle`\r\n\r\nIt was tested using Truffle v3.4.9, installed globally:\r\n\r\n```\r\nnpm install -g truffle@3.4.9\r\n```\r\n\r\n\r\n\r\n\r\n"
  },
  {
    "path": "truffle/webapp/app/index.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <title>MetaCoin - Truffle Webpack Demo w/ Frontend</title>\n  <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>\n  <script src=\"./app.js\"></script>\n</head>\n<body>\n  <h1>MetaCoin</h1>\n  <h2>Example Truffle Dapp</h2>\n  <h3>You have <span class=\"black\"><span id=\"balance\"></span> META</span></h3>\n\n  <br>\n  <h1>Send MetaCoin</h1>\n  <br><label for=\"amount\">Amount:</label><input type=\"text\" id=\"amount\" placeholder=\"e.g., 95\"></input>\n  <br><label for=\"receiver\">To Address:</label><input type=\"text\" id=\"receiver\" placeholder=\"e.g., 0x93e66d9baea28c17d9fc393b53e3fbdd76899dae\"></input>\n  <br><br><button id=\"send\" onclick=\"App.sendCoin()\">Send MetaCoin</button>\n  <br><br>\n  <span id=\"status\"></span>\n  <br>\n  <span class=\"hint\"><strong>Hint:</strong> open the browser developer console to view any errors and warnings.</span>\n</body>\n</html>\n"
  },
  {
    "path": "truffle/webapp/app/javascripts/app.js",
    "content": "// Import the page's CSS. Webpack will know what to do with it.\nimport \"../stylesheets/app.css\";\n\n// Import libraries we need.\nimport { default as Web3} from 'web3';\nimport { default as contract } from 'truffle-contract'\n\n// Import our contract artifacts and turn them into usable abstractions.\nimport metacoin_artifacts from '../../build/contracts/MetaCoin.json'\n\n// MetaCoin is our usable abstraction, which we'll use through the code below.\nvar MetaCoin = contract(metacoin_artifacts);\n\n// The following code is simple to show off interacting with your contracts.\n// As your needs grow you will likely need to change its form and structure.\n// For application bootstrapping, check out window.addEventListener below.\nvar accounts;\nvar account;\n\nwindow.App = {\n  start: function() {\n    var self = this;\n\n    // Bootstrap the MetaCoin abstraction for Use.\n    MetaCoin.setProvider(web3.currentProvider);\n\n    // Get the initial account balance so it can be displayed.\n    web3.eth.getAccounts(function(err, accs) {\n      if (err != null) {\n        alert(\"There was an error fetching your accounts.\");\n        return;\n      }\n\n      if (accs.length == 0) {\n        alert(\"Couldn't get any accounts! Make sure your Ethereum client is configured correctly.\");\n        return;\n      }\n\n      accounts = accs;\n      account = accounts[0];\n\n      self.refreshBalance();\n    });\n  },\n\n  setStatus: function(message) {\n    var status = document.getElementById(\"status\");\n    status.innerHTML = message;\n  },\n\n  refreshBalance: function() {\n    var self = this;\n\n    var meta;\n    MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(account, {from: account});\n    }).then(function(value) {\n      var balance_element = document.getElementById(\"balance\");\n      balance_element.innerHTML = value.valueOf();\n    }).catch(function(e) {\n      console.log(e);\n      self.setStatus(\"Error getting balance; see log.\");\n    });\n  },\n\n  sendCoin: function() {\n    var self = this;\n\n    var amount = parseInt(document.getElementById(\"amount\").value);\n    var receiver = document.getElementById(\"receiver\").value;\n\n    this.setStatus(\"Initiating transaction... (please wait)\");\n\n    var meta;\n    MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.sendCoin(receiver, amount, {from: account});\n    }).then(function() {\n      self.setStatus(\"Transaction complete!\");\n      self.refreshBalance();\n    }).catch(function(e) {\n      console.log(e);\n      self.setStatus(\"Error sending coin; see log.\");\n    });\n  }\n};\n\nwindow.addEventListener('load', function() {\n  // Checking if Web3 has been injected by the browser (Mist/MetaMask)\n  if (typeof web3 !== 'undefined') {\n    console.warn(\"Using web3 detected from external source. If you find that your accounts don't appear or you have 0 MetaCoin, ensure you've configured that source properly. If using MetaMask, see the following link. Feel free to delete this warning. :) http://truffleframework.com/tutorials/truffle-and-metamask\")\n    // Use Mist/MetaMask's provider\n    window.web3 = new Web3(web3.currentProvider);\n  } else {\n    console.warn(\"No web3 detected. Falling back to http://127.0.0.1:8545. You should remove this fallback when you deploy live, as it's inherently insecure. Consider switching to Metamask for development. More info here: http://truffleframework.com/tutorials/truffle-and-metamask\");\n    // fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail)\n    window.web3 = new Web3(new Web3.providers.HttpProvider(\"http://127.0.0.1:8545\"));\n  }\n\n  App.start();\n});\n"
  },
  {
    "path": "truffle/webapp/app/stylesheets/app.css",
    "content": "body {\n  margin-left: 25%;\n  margin-right: 25%;\n  margin-top: 10%;\n  font-family: \"Open Sans\", sans-serif;\n}\n\nlabel {\n  display: inline-block;\n  width: 100px;\n}\n\ninput {\n  width: 500px;\n  padding: 5px;\n  font-size: 16px;\n}\n\nbutton {\n  font-size: 16px;\n  padding: 5px;\n}\n\nh1, h2 {\n  display: inline-block;\n  vertical-align: middle;\n  margin-top: 0px;\n  margin-bottom: 10px;\n}\n\nh2 {\n  color: #AAA;\n  font-size: 32px;\n}\n\nh3 {\n  font-weight: normal;\n  color: #AAA;\n  font-size: 24px;\n}\n\n.black {\n  color: black;\n}\n\n#balance {\n  color: black;\n}\n\n.hint {\n  color: #666;\n}\n"
  },
  {
    "path": "truffle/webapp/contracts/ConvertLib.sol",
    "content": "pragma solidity ^0.4.2;\n\nlibrary ConvertLib{\n\tfunction convert(uint amount,uint conversionRate) returns (uint convertedAmount)\n\t{\n\t\treturn amount * conversionRate;\n\t}\n}\n"
  },
  {
    "path": "truffle/webapp/contracts/MetaCoin.sol",
    "content": "pragma solidity ^0.4.2;\n\nimport \"./ConvertLib.sol\";\n\n// This is just a simple example of a coin-like contract.\n// It is not standards compatible and cannot be expected to talk to other\n// coin/token contracts. If you want to create a standards-compliant\n// token, see: https://github.com/ConsenSys/Tokens. Cheers!\n\ncontract MetaCoin {\n\tmapping (address => uint) balances;\n\n\tevent Transfer(address indexed _from, address indexed _to, uint256 _value);\n\n\tfunction MetaCoin() {\n\t\tbalances[tx.origin] = 10000;\n\t}\n\n\tfunction sendCoin(address receiver, uint amount) returns(bool sufficient) {\n\t\tif (balances[msg.sender] < amount) return false;\n\t\tbalances[msg.sender] -= amount;\n\t\tbalances[receiver] += amount;\n\t\tTransfer(msg.sender, receiver, amount);\n\t\treturn true;\n\t}\n\n\tfunction getBalanceInEth(address addr) returns(uint){\n\t\treturn ConvertLib.convert(getBalance(addr),2);\n\t}\n\n\tfunction getBalance(address addr) returns(uint) {\n\t\treturn balances[addr];\n\t}\n}\n"
  },
  {
    "path": "truffle/webapp/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.2;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function Migrations() {\n    owner = msg.sender;\n  }\n\n  function setCompleted(uint completed) restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/webapp/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/webapp/migrations/2_deploy_contracts.js",
    "content": "var ConvertLib = artifacts.require(\"./ConvertLib.sol\");\nvar MetaCoin = artifacts.require(\"./MetaCoin.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(ConvertLib);\n  deployer.link(ConvertLib, MetaCoin);\n  deployer.deploy(MetaCoin);\n};\n"
  },
  {
    "path": "truffle/webapp/package.json",
    "content": "{\n  \"name\": \"truffle-init-webpack\",\n  \"version\": \"0.0.2\",\n  \"description\": \"Frontend example using truffle v3\",\n  \"scripts\": {\n    \"lint\": \"eslint ./\",\n    \"build\": \"webpack\",\n    \"dev\": \"webpack-dev-server\"\n  },\n  \"author\": \"Douglas von Kohorn\",\n  \"license\": \"MIT\",\n  \"devDependencies\": {\n    \"babel-cli\": \"^6.22.2\",\n    \"babel-core\": \"^6.22.1\",\n    \"babel-eslint\": \"^6.1.2\",\n    \"babel-loader\": \"^6.2.10\",\n    \"babel-plugin-transform-runtime\": \"^6.22.0\",\n    \"babel-preset-env\": \"^1.1.8\",\n    \"babel-preset-es2015\": \"^6.22.0\",\n    \"babel-register\": \"^6.22.0\",\n    \"copy-webpack-plugin\": \"^4.0.1\",\n    \"css-loader\": \"^0.26.1\",\n    \"eslint\": \"^3.14.0\",\n    \"eslint-config-standard\": \"^6.0.0\",\n    \"eslint-plugin-babel\": \"^4.0.0\",\n    \"eslint-plugin-mocha\": \"^4.8.0\",\n    \"eslint-plugin-promise\": \"^3.0.0\",\n    \"eslint-plugin-standard\": \"^2.0.0\",\n    \"html-webpack-plugin\": \"^2.28.0\",\n    \"json-loader\": \"^0.5.4\",\n    \"style-loader\": \"^0.13.1\",\n    \"truffle-contract\": \"^1.1.11\",\n    \"web3\": \"^0.20.0\",\n    \"webpack\": \"^2.2.1\",\n    \"webpack-dev-server\": \"^2.3.0\"\n  }\n}\n"
  },
  {
    "path": "truffle/webapp/test/TestMetacoin.sol",
    "content": "pragma solidity ^0.4.2;\n\nimport \"truffle/Assert.sol\";\nimport \"truffle/DeployedAddresses.sol\";\nimport \"../contracts/MetaCoin.sol\";\n\ncontract TestMetacoin {\n\n  function testInitialBalanceUsingDeployedContract() {\n    MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());\n\n    uint expected = 10000;\n\n    Assert.equal(meta.getBalance(tx.origin), expected, \"Owner should have 10000 MetaCoin initially\");\n  }\n\n  function testInitialBalanceWithNewMetaCoin() {\n    MetaCoin meta = new MetaCoin();\n\n    uint expected = 10000;\n\n    Assert.equal(meta.getBalance(tx.origin), expected, \"Owner should have 10000 MetaCoin initially\");\n  }\n\n}\n"
  },
  {
    "path": "truffle/webapp/test/metacoin.js",
    "content": "var MetaCoin = artifacts.require(\"./MetaCoin.sol\");\n\ncontract('MetaCoin', function(accounts) {\n  it(\"should put 10000 MetaCoin in the first account\", function() {\n    return MetaCoin.deployed().then(function(instance) {\n      return instance.getBalance.call(accounts[0]);\n    }).then(function(balance) {\n      assert.equal(balance.valueOf(), 10000, \"10000 wasn't in the first account\");\n    });\n  });\n  it(\"should call a function that depends on a linked library\", function() {\n    var meta;\n    var metaCoinBalance;\n    var metaCoinEthBalance;\n\n    return MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(accounts[0]);\n    }).then(function(outCoinBalance) {\n      metaCoinBalance = outCoinBalance.toNumber();\n      return meta.getBalanceInEth.call(accounts[0]);\n    }).then(function(outCoinBalanceEth) {\n      metaCoinEthBalance = outCoinBalanceEth.toNumber();\n    }).then(function() {\n      assert.equal(metaCoinEthBalance, 2 * metaCoinBalance, \"Library function returned unexpeced function, linkage may be broken\");\n    });\n  });\n\n  it(\"should send coin correctly\", function() {\n    var meta;\n\n    //    Get initial balances of first and second account.\n    var account_one = accounts[0];\n    var account_two = accounts[1];\n\n    var account_one_starting_balance;\n    var account_two_starting_balance;\n    var account_one_ending_balance;\n    var account_two_ending_balance;\n\n    var amount = 10;\n\n    return MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(account_one);\n    }).then(function(balance) {\n      account_one_starting_balance = balance.toNumber();\n      return meta.getBalance.call(account_two);\n    }).then(function(balance) {\n      account_two_starting_balance = balance.toNumber();\n      return meta.sendCoin(account_two, amount, {from: account_one});\n    }).then(function() {\n      return meta.getBalance.call(account_one);\n    }).then(function(balance) {\n      account_one_ending_balance = balance.toNumber();\n      return meta.getBalance.call(account_two);\n    }).then(function(balance) {\n      account_two_ending_balance = balance.toNumber();\n\n      assert.equal(account_one_ending_balance, account_one_starting_balance - amount, \"Amount wasn't correctly taken from the sender\");\n      assert.equal(account_two_ending_balance, account_two_starting_balance + amount, \"Amount wasn't correctly sent to the receiver\");\n    });\n  });\n});\n"
  },
  {
    "path": "truffle/webapp/truffle-box.json",
    "content": "{\n  \"ignore\": [\n    \"README.md\",\n    \".gitignore\"\n  ],\n  \"commands\": {\n    \"Compile\": \"truffle compile\",\n    \"Migrate\": \"truffle migrate\",\n    \"Test contracts\": \"truffle test\",\n    \"Run linter\": \"npm run lint\",\n    \"Run dev server\": \"npm run dev\",\n    \"Build for production\": \"npm run build\"\n  },\n  \"hooks\": {\n    \"post-unpack\": \"npm install\"\n  }\n}\n"
  },
  {
    "path": "truffle/webapp/truffle.js",
    "content": "// Allows us to use ES6 in our migrations and tests.\nrequire('babel-register')\n\nmodule.exports = {\n  networks: {\n    development: {\n      host: 'localhost',\n      port: 8545,\n      network_id: '*' // Match any network id\n    }\n  }\n}\n"
  },
  {
    "path": "truffle/webapp/webpack.config.js",
    "content": "const path = require('path');\nconst CopyWebpackPlugin = require('copy-webpack-plugin');\n\nmodule.exports = {\n  entry: './app/javascripts/app.js',\n  output: {\n    path: path.resolve(__dirname, 'build'),\n    filename: 'app.js'\n  },\n  plugins: [\n    // Copy our app's index.html to the build folder.\n    new CopyWebpackPlugin([\n      { from: './app/index.html', to: \"index.html\" }\n    ])\n  ],\n  module: {\n    rules: [\n      {\n       test: /\\.css$/,\n       use: [ 'style-loader', 'css-loader' ]\n      }\n    ],\n    loaders: [\n      { test: /\\.json$/, use: 'json-loader' },\n      {\n        test: /\\.js$/,\n        exclude: /(node_modules|bower_components)/,\n        loader: 'babel-loader',\n        query: {\n          presets: ['es2015'],\n          plugins: ['transform-runtime']\n        }\n      }\n    ]\n  }\n}\n"
  },
  {
    "path": "truffle/zero/contracts/ConvertLib.sol",
    "content": "pragma solidity ^0.4.4;\n\nlibrary ConvertLib{\n\tfunction convert(uint amount,uint conversionRate) returns (uint convertedAmount)\n\t{\n\t\treturn amount * conversionRate;\n\t}\n}\n"
  },
  {
    "path": "truffle/zero/contracts/MetaCoin.sol",
    "content": "pragma solidity ^0.4.4;\n\nimport \"./ConvertLib.sol\";\n\n// This is just a simple example of a coin-like contract.\n// It is not standards compatible and cannot be expected to talk to other\n// coin/token contracts. If you want to create a standards-compliant\n// token, see: https://github.com/ConsenSys/Tokens. Cheers!\n\ncontract MetaCoin {\n\tmapping (address => uint) balances;\n\n\tevent Transfer(address indexed _from, address indexed _to, uint256 _value);\n\n\tfunction MetaCoin() {\n\t\tbalances[tx.origin] = 10000;\n\t}\n\n\tfunction sendCoin(address receiver, uint amount) returns(bool sufficient) {\n\t\tif (balances[msg.sender] < amount) return false;\n\t\tbalances[msg.sender] -= amount;\n\t\tbalances[receiver] += amount;\n\t\tTransfer(msg.sender, receiver, amount);\n\t\treturn true;\n\t}\n\n\tfunction getBalanceInEth(address addr) returns(uint){\n\t\treturn ConvertLib.convert(getBalance(addr),2);\n\t}\n\n\tfunction getBalance(address addr) returns(uint) {\n\t\treturn balances[addr];\n\t}\n}\n"
  },
  {
    "path": "truffle/zero/contracts/Migrations.sol",
    "content": "pragma solidity ^0.4.4;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  modifier restricted() {\n    if (msg.sender == owner) _;\n  }\n\n  function Migrations() {\n    owner = msg.sender;\n  }\n\n  function setCompleted(uint completed) restricted {\n    last_completed_migration = completed;\n  }\n\n  function upgrade(address new_address) restricted {\n    Migrations upgraded = Migrations(new_address);\n    upgraded.setCompleted(last_completed_migration);\n  }\n}\n"
  },
  {
    "path": "truffle/zero/migrations/1_initial_migration.js",
    "content": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(Migrations);\n};\n"
  },
  {
    "path": "truffle/zero/migrations/2_deploy_contracts.js",
    "content": "var ConvertLib = artifacts.require(\"./ConvertLib.sol\");\nvar MetaCoin = artifacts.require(\"./MetaCoin.sol\");\n\nmodule.exports = function(deployer) {\n  deployer.deploy(ConvertLib);\n  deployer.link(ConvertLib, MetaCoin);\n  deployer.deploy(MetaCoin);\n};\n"
  },
  {
    "path": "truffle/zero/test/TestMetacoin.sol",
    "content": "pragma solidity ^0.4.2;\n\nimport \"truffle/Assert.sol\";\nimport \"truffle/DeployedAddresses.sol\";\nimport \"../contracts/MetaCoin.sol\";\n\ncontract TestMetacoin {\n\n  function testInitialBalanceUsingDeployedContract() {\n    MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());\n\n    uint expected = 10000;\n\n    Assert.equal(meta.getBalance(tx.origin), expected, \"Owner should have 10000 MetaCoin initially\");\n  }\n\n  function testInitialBalanceWithNewMetaCoin() {\n    MetaCoin meta = new MetaCoin();\n\n    uint expected = 10000;\n\n    Assert.equal(meta.getBalance(tx.origin), expected, \"Owner should have 10000 MetaCoin initially\");\n  }\n\n}\n"
  },
  {
    "path": "truffle/zero/test/metacoin.js",
    "content": "var MetaCoin = artifacts.require(\"./MetaCoin.sol\");\n\ncontract('MetaCoin', function(accounts) {\n  it(\"should put 10000 MetaCoin in the first account\", function() {\n    return MetaCoin.deployed().then(function(instance) {\n      return instance.getBalance.call(accounts[0]);\n    }).then(function(balance) {\n      assert.equal(balance.valueOf(), 10000, \"10000 wasn't in the first account\");\n    });\n  });\n  it(\"should call a function that depends on a linked library\", function() {\n    var meta;\n    var metaCoinBalance;\n    var metaCoinEthBalance;\n\n    return MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(accounts[0]);\n    }).then(function(outCoinBalance) {\n      metaCoinBalance = outCoinBalance.toNumber();\n      return meta.getBalanceInEth.call(accounts[0]);\n    }).then(function(outCoinBalanceEth) {\n      metaCoinEthBalance = outCoinBalanceEth.toNumber();\n    }).then(function() {\n      assert.equal(metaCoinEthBalance, 2 * metaCoinBalance, \"Library function returned unexpected function, linkage may be broken\");\n    });\n  });\n  it(\"should send coin correctly\", function() {\n    var meta;\n\n    // Get initial balances of first and second account.\n    var account_one = accounts[0];\n    var account_two = accounts[1];\n\n    var account_one_starting_balance;\n    var account_two_starting_balance;\n    var account_one_ending_balance;\n    var account_two_ending_balance;\n\n    var amount = 10;\n\n    return MetaCoin.deployed().then(function(instance) {\n      meta = instance;\n      return meta.getBalance.call(account_one);\n    }).then(function(balance) {\n      account_one_starting_balance = balance.toNumber();\n      return meta.getBalance.call(account_two);\n    }).then(function(balance) {\n      account_two_starting_balance = balance.toNumber();\n      return meta.sendCoin(account_two, amount, {from: account_one});\n    }).then(function() {\n      return meta.getBalance.call(account_one);\n    }).then(function(balance) {\n      account_one_ending_balance = balance.toNumber();\n      return meta.getBalance.call(account_two);\n    }).then(function(balance) {\n      account_two_ending_balance = balance.toNumber();\n\n      assert.equal(account_one_ending_balance, account_one_starting_balance - amount, \"Amount wasn't correctly taken from the sender\");\n      assert.equal(account_two_ending_balance, account_two_starting_balance + amount, \"Amount wasn't correctly sent to the receiver\");\n    });\n  });\n});\n"
  },
  {
    "path": "web31/abiencoding.js",
    "content": "\r\nvar Web3 = require('web3');\r\n\r\nvar web = new Web3();\r\n\r\nconsole.log(web.eth.abi.encodeParameter('int[]', [1, 2, 3]));\r\n\r\nconsole.log(web.eth.abi.encodeParameter('string[]', ['hello adsad asdsa asdsa asdsa hello adsad asdsa asdsa asdsa hello adsad asdsa asdsa asdsa', 'world']));\r\n\r\nweb.eth.abi.decodeParameter('string[]', web.eth.abi.encodeParameter('string[]', ['hello', 'world']));\r\n\r\n"
  },
  {
    "path": "web31/accounts.js",
    "content": "\r\nvar Web3 = require('web3');\r\n\r\nvar web = new Web3('http://localhost:8545');\r\n\r\nweb.eth.getAccounts(function (err, accounts) {\r\n\tif (err)\r\n\t\tconsole.error(err);\r\n\telse\r\n\t\tconsole.dir(accounts);\r\n});\r\n"
  },
  {
    "path": "web31/accounts2.js",
    "content": "\r\nvar Web3 = require('web3');\r\n\r\nvar web = new Web3('http://localhost:8545');\r\n\r\nasync function run() {\r\n    var accounts = await web.eth.getAccounts();\r\n    console.log(accounts);\r\n}\r\n\r\nrun();\r\n"
  },
  {
    "path": "web31/ballot.sol",
    "content": "pragma solidity ^0.4.11;\r\n\r\n/// @title Voting with delegation.\r\ncontract Ballot {\r\n    // This declares a new complex type which will\r\n    // be used for variables later.\r\n    // It will represent a single voter.\r\n    struct Voter {\r\n        uint weight; // weight is accumulated by delegation\r\n        bool voted;  // if true, that person already voted\r\n        address delegate; // person delegated to\r\n        uint vote;   // index of the voted proposal\r\n    }\r\n\r\n    // This is a type for a single proposal.\r\n    struct Proposal {\r\n        bytes32 name;   // short name (up to 32 bytes)\r\n        uint voteCount; // number of accumulated votes\r\n    }\r\n\r\n    address public chairperson;\r\n\r\n    // This declares a state variable that\r\n    // stores a `Voter` struct for each possible address.\r\n    mapping(address => Voter) public voters;\r\n\r\n    // A dynamically-sized array of `Proposal` structs.\r\n    Proposal[] public proposals;\r\n\r\n    /// Create a new ballot to choose one of `proposalNames`.\r\n    function Ballot(bytes32[] proposalNames) {\r\n        chairperson = msg.sender;\r\n        voters[chairperson].weight = 1;\r\n\r\n        // For each of the provided proposal names,\r\n        // create a new proposal object and add it\r\n        // to the end of the array.\r\n        for (uint i = 0; i < proposalNames.length; i++) {\r\n            // `Proposal({...})` creates a temporary\r\n            // Proposal object and `proposals.push(...)`\r\n            // appends it to the end of `proposals`.\r\n            proposals.push(Proposal({\r\n                name: proposalNames[i],\r\n                voteCount: 0\r\n            }));\r\n        }\r\n    }\r\n\r\n    // Give `voter` the right to vote on this ballot.\r\n    // May only be called by `chairperson`.\r\n    function giveRightToVote(address voter) {\r\n        // If the argument of `require` evaluates to `false`,\r\n        // it terminates and reverts all changes to\r\n        // the state and to Ether balances. It is often\r\n        // a good idea to use this if functions are\r\n        // called incorrectly. But watch out, this\r\n        // will currently also consume all provided gas\r\n        // (this is planned to change in the future).\r\n        require((msg.sender == chairperson) && !voters[voter].voted && (voters[voter].weight == 0));\r\n        voters[voter].weight = 1;\r\n    }\r\n\r\n    /// Delegate your vote to the voter `to`.\r\n    function delegate(address to) {\r\n        // assigns reference\r\n        Voter storage sender = voters[msg.sender];\r\n        require(!sender.voted);\r\n\r\n        // Self-delegation is not allowed.\r\n        require(to != msg.sender);\r\n\r\n        // Forward the delegation as long as\r\n        // `to` also delegated.\r\n        // In general, such loops are very dangerous,\r\n        // because if they run too long, they might\r\n        // need more gas than is available in a block.\r\n        // In this case, the delegation will not be executed,\r\n        // but in other situations, such loops might\r\n        // cause a contract to get \"stuck\" completely.\r\n        while (voters[to].delegate != address(0)) {\r\n            to = voters[to].delegate;\r\n\r\n            // We found a loop in the delegation, not allowed.\r\n            require(to != msg.sender);\r\n        }\r\n\r\n        // Since `sender` is a reference, this\r\n        // modifies `voters[msg.sender].voted`\r\n        sender.voted = true;\r\n        sender.delegate = to;\r\n        Voter storage delegate = voters[to];\r\n        if (delegate.voted) {\r\n            // If the delegate already voted,\r\n            // directly add to the number of votes\r\n            proposals[delegate.vote].voteCount += sender.weight;\r\n        } else {\r\n            // If the delegate did not vote yet,\r\n            // add to her weight.\r\n            delegate.weight += sender.weight;\r\n        }\r\n    }\r\n\r\n    /// Give your vote (including votes delegated to you)\r\n    /// to proposal `proposals[proposal].name`.\r\n    function vote(uint proposal) {\r\n        Voter storage sender = voters[msg.sender];\r\n        require(!sender.voted);\r\n        sender.voted = true;\r\n        sender.vote = proposal;\r\n\r\n        // If `proposal` is out of the range of the array,\r\n        // this will throw automatically and revert all\r\n        // changes.\r\n        proposals[proposal].voteCount += sender.weight;\r\n    }\r\n\r\n    /// @dev Computes the winning proposal taking all\r\n    /// previous votes into account.\r\n    function winningProposal() constant\r\n            returns (uint winningProposal)\r\n    {\r\n        uint winningVoteCount = 0;\r\n        for (uint p = 0; p < proposals.length; p++) {\r\n            if (proposals[p].voteCount > winningVoteCount) {\r\n                winningVoteCount = proposals[p].voteCount;\r\n                winningProposal = p;\r\n            }\r\n        }\r\n    }\r\n\r\n    // Calls winningProposal() function to get the index\r\n    // of the winner contained in the proposals array and then\r\n    // returns the name of the winner\r\n    function winnerName() constant\r\n            returns (bytes32 winnerName)\r\n    {\r\n        winnerName = proposals[winningProposal()].name;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "web31/compile.js",
    "content": "\r\nvar fs = require('fs');\r\nvar solc = require('solc');\r\n\r\nfunction findImports(path) {\r\n    return { contents: fs.readFileSync('./' + path).toString() };\r\n    // return { error: 'File not found' }\r\n}\r\n\r\nfunction compileContract(filename) {\r\n    var input = fs.readFileSync(filename).toString();\r\n    var sources = {};\r\n    sources[filename] = input;\r\n\t\r\n    var output = solc.compile({ sources: sources }, 1, findImports); // 1 activates the optimiser\r\n\r\n\treturn output.contracts;\r\n}\r\n\r\nvar contracts = compileContract(process.argv[2]);\r\n\r\nconsole.dir(Object.keys(contracts));\r\n\r\nfor (var n in contracts) {\r\n    console.log(Object.keys(contracts[n]));\r\n    console.log(contracts[n].functionHashes);\r\n    console.log(contracts[n].assembly);\r\n    console.log(contracts[n].gasEstimates);\r\n    console.log(contracts[n].opcodes);\r\n    console.log(contracts[n].interface);\r\n    console.log(contracts[n].bytecode);\r\n    console.log(contracts[n].runtimeBytecode);\r\n}\r\n"
  },
  {
    "path": "web31/config.json",
    "content": "{\r\n\t\"host\": \"http://localhost:8545\"\r\n}\r\n\r\n"
  },
  {
    "path": "web31/counter.js",
    "content": "\r\nvar solc = require('solc');\r\nvar Web3 = require('web3');\r\nvar fs = require('fs');\r\n\r\nvar config = require('./config.json');\r\n\r\nvar sargs = require('simpleargs');\r\n\r\nsargs\r\n    .define('h', 'host', config.host, 'Host JSON RPC entry point')\r\n    .define('f', 'from', config.from, 'From account address or number')\r\n\t.define('l', 'logging', false, 'Enable logging', { flag: true })\r\n\r\nvar options = sargs(process.argv.slice(2));\r\nvar args = options._;\r\n\r\nvar web3 = new Web3(options.host);\r\n\r\nfunction findImports(path) {\r\n    return { contents: fs.readFileSync('./' + path).toString() };\r\n    // return { error: 'File not found' }\r\n}\r\n\r\nfunction compileContract(filename) {\r\n    var input = fs.readFileSync(filename).toString();\r\n    var sources = {};\r\n    sources[filename] = input;\r\n\t\r\n    var output = solc.compile({ sources: sources }, 1, findImports); // 1 activates the optimiser\r\n\r\n\treturn output.contracts;\r\n}\r\n\r\nvar contracts = compileContract('counter.sol');\r\nvar contractnames = Object.keys(contracts);\r\nvar contractdef = contracts[contractnames[contractnames.length - 1]];\r\nvar contract = new web3.eth.Contract(JSON.parse(contractdef.interface));\r\n\r\nvar accounts;\r\n\r\nvar run = async () => {\r\n    const accounts = await web3.eth.getAccounts();    \r\n\t\r\n\tvar tx = contract.deploy({ data: contractdef.bytecode });\r\n\r\n   \tconsole.log('transaction data');\r\n\tconsole.log(tx.encodeABI());\r\n\r\n\tvar transactionHash = await tx.send({\r\n\t\tfrom: options.from || accounts[0],\r\n\t\tgas: 3000000,\r\n\t\tgasPrice: 0\r\n\t}).on('receipt', async function (receipt) {\r\n\t\tconsole.log('transaction receipt');\r\n\t\tconsole.dir(receipt);\r\n\t\tconsole.log('contract address', receipt.contractAddress);\r\n        var counter = new web3.eth.Contract(JSON.parse(contractdef.interface), receipt.contractAddress);\r\n        console.log(Object.keys(counter.methods));\r\n        \r\n        const c = await counter.methods.getCounter().call();\r\n        \r\n        console.log('counter', c);\r\n        \r\n        await counter.methods.increment().send({\r\n            from: options.from || accounts[0],\r\n            gas: 3000000,\r\n            gasPrice: 0\r\n        });\r\n        \r\n        const c2 = await counter.methods.getCounter().call();\r\n        \r\n        console.log('counter', c2);\r\n        \r\n        await counter.methods.add(40).send({\r\n            from: options.from || accounts[0],\r\n            gas: 3000000,\r\n            gasPrice: 0\r\n        });\r\n        \r\n        const c3 = await counter.methods.getCounter().call();\r\n        \r\n        console.log('counter', c3);\r\n\t})\r\n\t.on('confirmation', function (confirmationNumber, receipt) {\r\n\t\tconsole.log('confirmation number', confirmationNumber);\r\n\t\tconsole.log('transaction receipt');\r\n\t\tconsole.dir(receipt);\r\n\t\tconsole.log('contract address', receipt.contractAddress);\r\n\t});\r\n}\r\n\r\nrun();\r\n\r\n\r\n"
  },
  {
    "path": "web31/counter.json",
    "content": "[{\"constant\":false,\"inputs\":[{\"name\":\"v\",\"type\":\"uint256\"}],\"name\":\"add\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getCounter\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"increment\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"inputs\":[],\"type\":\"constructor\"}]\r\n\r\n"
  },
  {
    "path": "web31/counter.sol",
    "content": "\r\n// Simple counter contract\r\n\r\ncontract Counter {\r\n    uint counter;\r\n\t\r\n    function Counter() {\r\n        counter = 1;\r\n    }\r\n    \r\n    function increment() {\r\n        counter++;\r\n    }\r\n\t\r\n    function add(uint v) {\r\n        counter += v;\r\n    }\r\n\t\r\n    function getCounter() constant returns (uint) {\r\n        return counter;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "web31/counter1.js",
    "content": "\r\nvar Web3 = require('web3');\r\n\r\nvar web = new Web3('http://localhost:8545');\r\n\r\nvar json = require('./counter.json');\r\n\r\nvar contract = new web.eth.Contract(json);\r\n\r\nconsole.dir(contract.methods);\r\nconsole.dir(contract.options);\r\n\r\nconsole.log(contract.methods.add(1).encodeABI());\r\n\r\n"
  },
  {
    "path": "web31/deploy.js",
    "content": "\r\nvar solc = require('solc');\r\nvar Web3 = require('web3');\r\nvar sasync = require('simpleasync');\r\nvar fs = require('fs');\r\n\r\n\r\nvar config = require('./config.json');\r\n\r\nvar sargs = require('simpleargs');\r\n\r\nsargs\r\n    .define('h', 'host', config.host, 'Host JSON RPC entry point')\r\n    .define('f', 'from', config.from, 'From account address or number')\r\n\t.define('l', 'logging', false, 'Enable logging', { flag: true })\r\n\r\nvar options = sargs(process.argv.slice(2));\r\nvar args = options._;\r\n\r\nvar web3 = new Web3(options.host);\r\n\r\nfunction findImports(path) {\r\n    return { contents: fs.readFileSync('./' + path).toString() };\r\n    // return { error: 'File not found' }\r\n}\r\n\r\nfunction compileContract(filename) {\r\n    var input = fs.readFileSync(filename).toString();\r\n    var sources = {};\r\n    sources[filename] = input;\r\n\t\r\n    var output = solc.compile({ sources: sources }, 1, findImports); // 1 activates the optimiser\r\n\r\n\treturn output.contracts;\r\n}\r\n\r\n\r\nvar contracts = compileContract(args[0]);\r\nvar contractnames = Object.keys(contracts);\r\nvar contractdef = contracts[contractnames[contractnames.length -1]];\r\n\r\nvar contract = new web3.eth.Contract(JSON.parse(contractdef.interface));\r\n\r\nvar accounts;\r\n\r\nsasync()\r\n.exec(function (next) {\r\n\tweb3.eth.getAccounts(next)\r\n})\r\n.then(function (data, next) {\r\n\taccounts = data;\r\n\t\r\n\tvar tx = contract.deploy({ data: contractdef.bytecode });\r\n\r\n\ttx.send({\r\n\t\tfrom: options.from || accounts[0],\r\n\t\tgas: 3000000,\r\n\t\tgasPrice: 0\r\n\t}, function (err, transactionHash) {\r\n\t\tif (err)\r\n\t\t\treturn console.error(err);\r\n\t\t\r\n\t\tconsole.log('transaction hash');\r\n\t\tconsole.dir(transactionHash);\r\n\t})\r\n\t.on('receipt', function (receipt) {\r\n\t\tconsole.log('transaction receipt');\r\n\t\tconsole.dir(receipt);\r\n\t\tconsole.log('contract address', receipt.contractAddress);\r\n\t})\r\n\t.on('confirmation', function (confirmationNumber, receipt) {\r\n\t\tconsole.log('confirmation number', confirmationNumber);\r\n\t\tconsole.log('transaction receipt');\r\n\t\tconsole.dir(receipt);\r\n\t\tconsole.log('contract address', receipt.contractAddress);\r\n\t});\r\n\r\n\tconsole.log('transaction data');\r\n\tconsole.log(tx.encodeABI());\r\n\r\n\t\r\n});\r\n\r\n"
  },
  {
    "path": "web31/deploy1.js",
    "content": "\r\nvar Web3 = require('web3');\r\n\r\nvar web = new Web3('http://localhost:8545');\r\n\r\nvar json = require('./counter.json');\r\n\r\nvar contract = new web.eth.Contract(json);\r\n\r\nconsole.dir(web.eth.getAccounts);\r\n\r\nvar tx = contract.deploy({ data: '60606040525b60016000600050819055505b60db80601d6000396000f360606040526000357c0100000000000000000000000000000000000000000000000000000000900480631003e2d214604d5780638ada066e146067578063d09de08a14608c576049565b6002565b3460025760656004808035906020019091905050609d565b005b346002576076600480505060b3565b6040518082815260200191505060405180910390f35b34600257609b600480505060c4565b005b8060006000828282505401925050819055505b50565b6000600060005054905060c1565b90565b60006000818150548092919060010191905055505b56' });\r\n\r\ntx.send({\r\n\tfrom: '0xda5ac26b293ea206d31b1b8ec1f4250798a184d6',\r\n\tgas: 3000000,\r\n\tgasPrice: 0\r\n}, function (err, transactionHash) {\r\n\tif (err)\r\n\t\treturn console.error(err);\r\n\t\r\n\tconsole.log('transaction hash');\r\n\tconsole.dir(transactionHash);\r\n})\r\n.on('receipt', function (receipt) {\r\n\tconsole.log('transaction receipt');\r\n\tconsole.dir(receipt);\r\n\tconsole.log('contract address', receipt.contractAddress);\r\n})\r\n.on('confirmation', function (confirmationNumber, receipt) {\r\n\tconsole.log('confirmation number', confirmationNumber);\r\n\tconsole.log('transaction receipt');\r\n\tconsole.dir(receipt);\r\n\tconsole.log('contract address', receipt.contractAddress);\r\n});\r\n\r\nconsole.log('transaction data');\r\nconsole.log(tx.encodeABI());\r\n\r\nconsole.log('add method data');\r\nconsole.log(contract.methods.add(42).encodeABI());\r\n\r\n"
  },
  {
    "path": "web31/deploy2.js",
    "content": "\r\nvar solc = require('solc');\r\nvar Web3 = require('web3');\r\nvar fs = require('fs');\r\n\r\nvar config = require('./config.json');\r\n\r\nvar sargs = require('simpleargs');\r\n\r\nsargs\r\n    .define('h', 'host', config.host, 'Host JSON RPC entry point')\r\n    .define('f', 'from', config.from, 'From account address or number')\r\n\t.define('l', 'logging', false, 'Enable logging', { flag: true })\r\n\r\nvar options = sargs(process.argv.slice(2));\r\nvar args = options._;\r\n\r\nvar web3 = new Web3(options.host);\r\n\r\nfunction findImports(path) {\r\n    return { contents: fs.readFileSync('./' + path).toString() };\r\n    // return { error: 'File not found' }\r\n}\r\n\r\nfunction compileContract(filename) {\r\n    var input = fs.readFileSync(filename).toString();\r\n    var sources = {};\r\n    sources[filename] = input;\r\n\t\r\n    var output = solc.compile({ sources: sources }, 1, findImports); // 1 activates the optimiser\r\n\r\n\treturn output.contracts;\r\n}\r\n\r\nvar contracts = compileContract(args[0]);\r\nvar contractnames = Object.keys(contracts);\r\nvar contractdef = contracts[contractnames[contractnames.length -1]];\r\n\r\nvar contract = new web3.eth.Contract(JSON.parse(contractdef.interface));\r\n\r\nvar accounts;\r\n\r\nvar run = async () => {\r\n    const accounts = await web3.eth.getAccounts();    \r\n\t\r\n\tvar tx = contract.deploy({ data: contractdef.bytecode });\r\n\r\n   \tconsole.log('transaction data');\r\n\tconsole.log(tx.encodeABI());\r\n\r\n\tvar transactionHash = await tx.send({\r\n\t\tfrom: options.from || accounts[0],\r\n\t\tgas: 3000000,\r\n\t\tgasPrice: 0\r\n\t}).on('receipt', function (receipt) {\r\n\t\tconsole.log('transaction receipt');\r\n\t\tconsole.dir(receipt);\r\n\t\tconsole.log('contract address', receipt.contractAddress);\r\n\t})\r\n\t.on('confirmation', function (confirmationNumber, receipt) {\r\n\t\tconsole.log('confirmation number', confirmationNumber);\r\n\t\tconsole.log('transaction receipt');\r\n\t\tconsole.dir(receipt);\r\n\t\tconsole.log('contract address', receipt.contractAddress);\r\n\t});\r\n}\r\n\r\nrun();\r\n\r\n\r\n"
  },
  {
    "path": "web31/greeter.sol",
    "content": "\r\ncontract Greeter {\r\n    string public message;\r\n\r\n    function Greeter() {\r\n        message = \"Hello, Contract\";\r\n    }\r\n    \r\n    function setMessage(string msg) {\r\n        message = msg;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "web31/message.json",
    "content": "[{\"constant\":false,\"inputs\":[{\"name\":\"msg\",\"type\":\"string\"}],\"name\":\"setMessage\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"message\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"msg\",\"type\":\"string\"}],\"type\":\"constructor\"}]\r\n\r\n"
  },
  {
    "path": "web31/message.sol",
    "content": "\r\ncontract Message {\r\n    string public message;\r\n\r\n    function Message(string msg) {\r\n        message = msg;\r\n    }\r\n    \r\n    function setMessage(string msg) {\r\n        message = msg;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "web31/package.json",
    "content": "{\n  \"name\": \"web31_samples\",\n  \"private\": true,\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"test.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"simpleargs\": \"0.0.3\",\n    \"simpleasync\": \"0.0.8\",\n    \"solc\": \"^0.4.18\",\n    \"web3\": \"^1.0.0-beta.24\"\n  }\n}\n"
  }
]