[
  {
    "path": ".gitignore",
    "content": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.idea/\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# BlockchainWallet-Crypto\n[![](https://jitpack.io/v/QuincySx/BlockchainWallet-Crypto.svg)](https://jitpack.io/#QuincySx/BlockchainWallet-Crypto)\n\n# 长时间不维护可移步 https://github.com/QuincySx/ChainWallet\n\n#### 简介\n##### 这个库到底能干什么\n1. 生成比特币公私钥地址\n2. 生成以太坊公私钥地址\n3. 根据 UTXO 信息打包比特币交易\n4. 根据 nonce 信息打包以太坊交易\n5. 对比特币交易进行签名\n6. 对以太坊交易进行签名\n7. 支持 BIP39 助记词\n8. 支持 BIP32 子私钥\n9. 支持 BIP44 多币种管理\n10. 支持 BIP38 加密私钥导入导出\n11. 支持以太坊 keystore 导入导出\n12. 生成以太坊调用智能合约的参数\n13. 生成 EOS 公私钥\n\n#### EOS 从助记词生成私钥\n现在 EOS 从助记词生成私钥有两种方式\n1. 12 个助记词之间用空格隔开拼接成字符串，然后 Hash 得到私钥\n2. 采用 Bip44 标准的生成方案，EOS 的币种序号详见最下方⎡相关资料⎦中的⎡Bip44 注册币种列表⎦\n\n经过国内大部分钱包商议统一使用第二种方案解决 EOS 从助记词生成私钥的问题\n\n#### 欢迎给位提设计上的 lssues 和 pr\n\n#### 引入项目\n\n```\nallprojects {\n  repositories {\n    ...\n\t\tmaven { url 'https://jitpack.io' }\n  }\n}\n  \ndependencies {\n  implementation 'com.github.QuincySx:BlockchainWallet-Crypto:last-version'\n}\n```\n\n#### 使用说明\n[简单使用说明](https://github.com/QuincySx/BlockchainWallet-Crypto/wiki)\n\n## 相关资料\n[Bip44 注册币种列表](https://github.com/satoshilabs/slips/blob/master/slip-0044.md)\n\n## LICENSE\n[开源协议](LICENSE)\n"
  },
  {
    "path": "build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n    \n    repositories {\n        google()\n        jcenter()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:3.1.2'\n        \n\n        // NOTE: Do not place your application dependencies here; they belong\n        // in the individual module build.gradle files\n    }\n}\n\nallprojects {\n    repositories {\n        google()\n        jcenter()\n    }\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Tue Mar 27 20:02:31 CST 2018\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-4.4-all.zip\n"
  },
  {
    "path": "gradle.properties",
    "content": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\norg.gradle.jvmargs=-Xmx1536m\n\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@rem  Gradle startup script for Windows\r\n@rem\r\n@rem ##########################################################################\r\n\r\n@rem Set local scope for the variables with windows NT shell\r\nif \"%OS%\"==\"Windows_NT\" setlocal\r\n\r\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r\nset DEFAULT_JVM_OPTS=\r\n\r\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\r\n\r\n@rem Find java.exe\r\nif defined JAVA_HOME goto findJavaFromJavaHome\r\n\r\nset JAVA_EXE=java.exe\r\n%JAVA_EXE% -version >NUL 2>&1\r\nif \"%ERRORLEVEL%\" == \"0\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:findJavaFromJavaHome\r\nset JAVA_HOME=%JAVA_HOME:\"=%\r\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\r\n\r\nif exist \"%JAVA_EXE%\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:init\r\n@rem Get command-line arguments, handling Windowz variants\r\n\r\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\r\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\r\n\r\n:win9xME_args\r\n@rem Slurp the command line arguments.\r\nset CMD_LINE_ARGS=\r\nset _SKIP=2\r\n\r\n:win9xME_args_slurp\r\nif \"x%~1\" == \"x\" goto execute\r\n\r\nset CMD_LINE_ARGS=%*\r\ngoto execute\r\n\r\n:4NT_args\r\n@rem Get arguments from the 4NT Shell from JP Software\r\nset CMD_LINE_ARGS=%$\r\n\r\n:execute\r\n@rem Setup the command line\r\n\r\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\r\n\r\n@rem Execute Gradle\r\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\r\n\r\n:end\r\n@rem End local scope for the variables with windows NT shell\r\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\r\n\r\n:fail\r\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r\nrem the _cmd.exe /c_ return code!\r\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\r\nexit /b 1\r\n\r\n:mainEnd\r\nif \"%OS%\"==\"Windows_NT\" endlocal\r\n\r\n:omega\r\n"
  },
  {
    "path": "library/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "library/build.gradle",
    "content": "apply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion 27\n\n\n\n    defaultConfig {\n        minSdkVersion 15\n        targetSdkVersion 27\n        versionCode 1\n        versionName \"1.0\"\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n\n}\n\ndependencies {\n    api fileTree(dir: 'libs', include: ['*.jar'])\n    api \"com.cedarsoftware:java-util:1.8.0\"\n    api \"com.fasterxml.jackson.core:jackson-databind:2.8.5\"\n    api 'com.madgag.spongycastle:core:1.58.0.0'\n    api 'com.madgag.spongycastle:prov:1.58.0.0'\n    api 'com.lambdaworks:scrypt:1.4.0'\n\n}\n"
  },
  {
    "path": "library/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "library/src/androidTest/java/com/quincysx/crypto/ExampleInstrumentedTest.java",
    "content": "package com.quincysx.crypto;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimport android.support.test.runner.AndroidJUnit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport static org.junit.Assert.*;\n\n/**\n * Instrumented test, which will execute on an Android device.\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\n@RunWith(AndroidJUnit4.class)\npublic class ExampleInstrumentedTest {\n    @Test\n    public void useAppContext() throws Exception {\n        // Context of the app under test.\n        Context appContext = InstrumentationRegistry.getTargetContext();\n\n        assertEquals(\"com.quincysx.crypto.test\", appContext.getPackageName());\n    }\n}\n"
  },
  {
    "path": "library/src/main/AndroidManifest.xml",
    "content": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.quincysx.crypto\" />\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/CoinTypes.java",
    "content": "package com.quincysx.crypto;\n\nimport com.quincysx.crypto.exception.CoinNotFindException;\n\n/**\n * Created by q7728 on 2018/3/18.\n */\n\npublic enum CoinTypes {\n    Bitcoin(0, \"BTC\"),\n    BitcoinTest(1, \"BTC\"),\n    Litecoin(2, \"LTC\"),\n    Dogecoin(3, \"DOGE\"),\n    Ethereum(60, \"ETH\"),\n    EOS(194, \"EOS\");\n\n    private int coinType;\n    private String coinName;\n\n    CoinTypes(int i, String name) {\n        coinType = i;\n        coinName = name;\n    }\n\n    public int coinType() {\n        return coinType;\n    }\n\n    public String coinName() {\n        return coinName;\n    }\n\n    public static CoinTypes parseCoinType(int type) throws CoinNotFindException {\n        for (CoinTypes e : CoinTypes.values()) {\n            if (e.coinType == type) {\n                return e;\n            }\n        }\n        throw new CoinNotFindException(\"The currency is not supported for the time being\");\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ECKeyPair.java",
    "content": "/*\n * Copyright 2013 bits of proof zrt.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *    http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.quincysx.crypto;\n\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.utils.RIPEMD160;\n\nimport org.spongycastle.asn1.ASN1InputStream;\nimport org.spongycastle.asn1.DERInteger;\nimport org.spongycastle.asn1.DLSequence;\nimport org.spongycastle.asn1.sec.SECNamedCurves;\nimport org.spongycastle.asn1.x9.X9ECParameters;\nimport org.spongycastle.crypto.AsymmetricCipherKeyPair;\nimport org.spongycastle.crypto.generators.ECKeyPairGenerator;\nimport org.spongycastle.crypto.params.ECDomainParameters;\nimport org.spongycastle.crypto.params.ECKeyGenerationParameters;\nimport org.spongycastle.crypto.params.ECPrivateKeyParameters;\nimport org.spongycastle.crypto.params.ECPublicKeyParameters;\nimport org.spongycastle.crypto.signers.ECDSASigner;\nimport org.spongycastle.math.ec.ECPoint;\nimport org.spongycastle.util.Arrays;\n\nimport java.io.IOException;\nimport java.math.BigInteger;\nimport java.security.SecureRandom;\n\n\npublic class ECKeyPair implements Key {\n    protected static final SecureRandom secureRandom = new SecureRandom();\n    protected static final X9ECParameters CURVE = SECNamedCurves.getByName(\"secp256k1\");\n    protected static final ECDomainParameters domain = new ECDomainParameters(CURVE.getCurve(),\n            CURVE.getG(), CURVE.getN(), CURVE.getH());\n    protected static final BigInteger LARGEST_PRIVATE_KEY = new BigInteger\n            (\"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141\", 16);\n\n    protected BigInteger priv;\n    protected byte[] pub;\n    protected byte[] pubComp;\n    protected boolean compressed;\n\n    protected ECKeyPair() {\n    }\n\n    public ECKeyPair(byte[] p, boolean compressed) throws ValidationException {\n        this(new BigInteger(1, p), compressed);\n        if (!(p.length == 32 || p.length == 43 )) {\n            throw new ValidationException(\"Invalid private key\");\n        }\n    }\n\n    public ECKeyPair(BigInteger priv, boolean compressed) {\n        this.priv = priv;\n        this.compressed = compressed;\n\n        ECPoint multiply = CURVE.getG().multiply(priv);\n        this.pub = multiply.getEncoded(false);\n        this.pubComp = multiply.getEncoded(true);\n    }\n\n    protected ECKeyPair(Key keyPair) {\n        this.priv = new BigInteger(1, keyPair.getRawPrivateKey());\n        this.compressed = keyPair.isCompressed();\n        this.pub = Arrays.clone(keyPair.getRawPublicKey(false));\n        this.pubComp = Arrays.clone(keyPair.getRawPublicKey());\n    }\n\n    @Override\n    public boolean isCompressed() {\n        return compressed;\n    }\n\n    @Override\n    public ECKeyPair clone() throws CloneNotSupportedException {\n        ECKeyPair c = (ECKeyPair) super.clone();\n        c.priv = new BigInteger(c.priv.toByteArray());\n        c.pub = Arrays.clone(pub);\n        c.pubComp = Arrays.clone(pubComp);\n        c.compressed = compressed;\n        return c;\n    }\n\n    public static ECKeyPair createNew(boolean compressed) {\n        ECKeyPairGenerator generator = new ECKeyPairGenerator();\n        ECKeyGenerationParameters keygenParams = new ECKeyGenerationParameters(domain,\n                secureRandom);\n        generator.init(keygenParams);\n        AsymmetricCipherKeyPair keypair = generator.generateKeyPair();\n        ECPrivateKeyParameters privParams = (ECPrivateKeyParameters) keypair.getPrivate();\n        ECPublicKeyParameters pubParams = (ECPublicKeyParameters) keypair.getPublic();\n        ECKeyPair k = new ECKeyPair();\n        k.priv = privParams.getD();\n        k.compressed = compressed;\n        ECPoint multiply = CURVE.getG().multiply(k.priv);\n        k.pub = multiply.getEncoded(false);\n        k.pubComp = multiply.getEncoded(true);\n        return k;\n    }\n\n    public void setPublic(byte[] pub) throws ValidationException {\n        throw new ValidationException(\"Can not set public key if private is present\");\n    }\n\n    @Override\n    public byte[] getRawPrivateKey() {\n        byte[] p = priv.toByteArray();\n\n        if (p.length != 32) {\n            byte[] tmp = new byte[32];\n            System.arraycopy(p, Math.max(0, p.length - 32), tmp, Math.max(0, 32 - p.length), Math\n                    .min(32, p.length));\n            p = tmp;\n        }\n        return p;\n    }\n\n    @Override\n    public byte[] getRawPublicKey(boolean isCompressed) {\n        if (isCompressed) {\n            return Arrays.clone(pubComp);\n        } else {\n            return Arrays.clone(pub);\n        }\n    }\n\n    @Override\n    public byte[] getRawPublicKey() {\n        return getRawPublicKey(true);\n    }\n\n    @Override\n    public byte[] getRawAddress() {\n        return RIPEMD160.hash160(pubComp);\n    }\n\n    @Override\n    public String getPrivateKey() {\n        throw new RuntimeException(\"No formatted private Key\");\n    }\n\n    @Override\n    public String getPublicKey() {\n        throw new RuntimeException(\"No formatted public Key\");\n    }\n\n    @Override\n    public String getAddress() {\n        throw new RuntimeException(\"No formatted address\");\n    }\n\n    @Override\n    public <T> T sign(byte[] messageHash) throws ValidationException {\n        throw new ValidationException(\"Please convert to ECKeyPair subclass signature\");\n    }\n\n    public static boolean verify(byte[] hash, byte[] signature, byte[] pub) {\n        ASN1InputStream asn1 = new ASN1InputStream(signature);\n        try {\n            ECDSASigner signer = new ECDSASigner();\n            signer.init(false, new ECPublicKeyParameters(CURVE.getCurve().decodePoint(pub),\n                    domain));\n\n            DLSequence seq = (DLSequence) asn1.readObject();\n            BigInteger r = ((DERInteger) seq.getObjectAt(0)).getPositiveValue();\n            BigInteger s = ((DERInteger) seq.getObjectAt(1)).getPositiveValue();\n            return signer.verifySignature(hash, r, s);\n        } catch (Exception e) {\n            // threat format errors as invalid signatures\n            return false;\n        } finally {\n            try {\n                asn1.close();\n            } catch (IOException e) {\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ECPublicKey.java",
    "content": "/*\n * Copyright 2013 bits of proof zrt.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *    http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.quincysx.crypto;\n\n\nimport com.quincysx.crypto.utils.RIPEMD160;\n\nimport org.spongycastle.util.Arrays;\n\npublic class ECPublicKey implements Key {\n    private byte[] pub;\n    private boolean compressed;\n\n    public ECPublicKey(byte[] pub, boolean compressed) {\n        this.pub = pub;\n        this.compressed = compressed;\n    }\n\n    @Override\n    public boolean isCompressed() {\n        return compressed;\n    }\n\n    public void setCompressed(boolean compressed) {\n        this.compressed = compressed;\n    }\n\n    @Override\n    public byte[] getRawPrivateKey() {\n        throw new RuntimeException(\"Please use private key to sign signature\");\n    }\n\n    @Override\n    public byte[] getRawPublicKey(boolean isCompressed) {\n        if (!isCompressed) {\n            throw new RuntimeException(\"No compressed public key\");\n        }\n        return Arrays.clone(pub);\n    }\n\n    @Override\n    public byte[] getRawPublicKey() {\n        return Arrays.clone(pub);\n    }\n\n    @Override\n    public byte[] getRawAddress() {\n        return RIPEMD160.hash160(pub);\n    }\n\n    @Override\n    public String getPrivateKey() {\n        throw new RuntimeException(\"Please use private key to sign signature\");\n    }\n\n    @Override\n    public String getPublicKey() {\n        throw new RuntimeException(\"No formatted public Key\");\n    }\n\n    @Override\n    public String getAddress() {\n        throw new RuntimeException(\"No formatted address\");\n    }\n\n    @Override\n    public ECPublicKey clone() throws CloneNotSupportedException {\n        ECPublicKey c = (ECPublicKey) super.clone();\n        c.pub = Arrays.clone(pub);\n        return c;\n    }\n\n    @Override\n    public <T> T sign(byte[] messageHash) {\n        throw new RuntimeException(\"Please use private key to sign signature\");\n    }\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/Key.java",
    "content": "/*\n * Copyright 2013 bits of proof zrt.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *    http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.quincysx.crypto;\n\n\nimport com.quincysx.crypto.bip32.ValidationException;\n\npublic interface Key extends Cloneable {\n    /**\n     * 获取原生私钥\n     *\n     * @return\n     */\n    public byte[] getRawPrivateKey();\n\n    /**\n     * 获取公钥\n     *\n     * @param isCompressed 是否压缩\n     * @return 原生公钥\n     */\n    public byte[] getRawPublicKey(boolean isCompressed);\n\n    /**\n     * 获取原生压缩公钥\n     *\n     * @return\n     */\n    public byte[] getRawPublicKey();\n\n    /**\n     * 获取地址\n     *\n     * @return\n     */\n    public byte[] getRawAddress();\n\n    /**\n     * 获取格式化的私钥\n     *\n     * @return\n     */\n    public String getPrivateKey();\n\n    /**\n     * 获取格式化的公钥\n     *\n     * @return\n     */\n    public String getPublicKey();\n\n    /**\n     * 获取格式化的地址\n     *\n     * @return\n     */\n    public String getAddress();\n\n    /**\n     * 获取判断公钥是否是压缩格式\n     *\n     * @return\n     */\n    public boolean isCompressed();\n\n    public Key clone() throws CloneNotSupportedException;\n\n    public <T extends Object> T sign(byte[] messageHash) throws ValidationException;\n\n}"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/SecureCharSequence.java",
    "content": "package com.quincysx.crypto;\n\nimport java.security.SecureRandom;\nimport java.util.Arrays;\n\n/**\n * @author QuincySx\n * @date 2018/3/9 下午2:57\n */\npublic class SecureCharSequence implements CharSequence {\n    private char[] chars;\n\n    public SecureCharSequence(CharSequence charSequence) {\n        this(charSequence, 0, charSequence.length());\n    }\n\n    public SecureCharSequence(char[] chars) {\n        wipe();\n        this.chars = chars;\n    }\n\n    private SecureCharSequence(CharSequence charSequence, int start, int end) {\n        // pulled from http://stackoverflow.com/a/15844273\n        wipe();\n        int length = end - start;\n        chars = new char[length];\n        for (int i = start;\n             i < end;\n             i++) {\n            chars[i - start] = charSequence.charAt(i);\n        }\n    }\n\n    public void wipe() {\n        if (chars != null) {\n            Arrays.fill(chars, ' ');\n            SecureRandom r = new SecureRandom();\n            byte[] bytes = new byte[chars.length];\n            r.nextBytes(bytes);\n            for (int i = 0;\n                 i < chars.length;\n                 i++) {\n                chars[i] = (char) bytes[i];\n            }\n            Arrays.fill(chars, ' ');\n        }\n    }\n\n    protected void finalize() {\n        wipe();\n    }\n\n    @Override\n    public int length() {\n        if (chars != null) {\n            return chars.length;\n        }\n        return 0;\n    }\n\n    @Override\n    public char charAt(int index) {\n        if (chars != null) {\n            return chars[index];\n        }\n        return 0;\n    }\n\n    @Override\n    public String toString() {\n        return String.valueOf(this.chars);\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (o instanceof SecureCharSequence) {\n            return Arrays.equals(chars, ((SecureCharSequence) o).chars);\n        }\n        return false;\n    }\n\n    @Override\n    public CharSequence subSequence(int start, int end) {\n        SecureCharSequence s = new SecureCharSequence(this, start, end);\n        return s;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/Transaction.java",
    "content": "package com.quincysx.crypto;\n\nimport com.quincysx.crypto.bip32.ValidationException;\n\n/**\n * @author QuincySx\n * @date 2018/3/8 下午1:56\n */\npublic interface Transaction {\n    byte[] sign(ECKeyPair key) throws ValidationException;\n\n    public byte[] getSignBytes();\n\n    /**\n     * Eth 使用的方法\n     *\n     * @return\n     */\n    public byte[] getData();\n\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/TrulySecureRandom.java",
    "content": "/*\n The MIT License (MIT)\n\n Copyright (c) 2013 Valentin Konovalov\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.*/\npackage com.quincysx.crypto;\n\nimport android.os.Build;\nimport android.os.SystemClock;\nimport android.util.Log;\n\nimport com.quincysx.crypto.utils.HexUtils;\n\nimport org.spongycastle.crypto.digests.SHA256Digest;\nimport org.spongycastle.crypto.prng.DigestRandomGenerator;\nimport org.spongycastle.crypto.prng.ThreadedSeedGenerator;\n\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.IOException;\nimport java.util.concurrent.ExecutionException;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.Future;\nimport java.util.concurrent.TimeUnit;\nimport java.util.concurrent.TimeoutException;\n\npublic class TrulySecureRandom extends java.security.SecureRandom {\n    private static final String TAG = \"SecureRandom\";\n    private final DigestRandomGenerator generator;\n    private boolean initialized;\n\n\n    public TrulySecureRandom() {\n        generator = new DigestRandomGenerator(new SHA256Digest());\n    }\n\n    public void addSeedMaterial(long seed) {\n        generator.addSeedMaterial(seed);\n    }\n\n    private void addSeedMaterial(byte[] seed) {\n        generator.addSeedMaterial(seed);\n    }\n\n    @Override\n    public int nextInt() {\n        byte[] buf = new byte[4];\n        nextBytes(buf);\n        return ((buf[0] & 0xff) << 24) | ((buf[1] & 0xff) << 16) | ((buf[2] & 0xff) << 8) | (buf[3] & 0xff);\n    }\n\n    @Override\n    public int nextInt(int n) {\n        return Math.abs(nextInt()) % n;\n    }\n\n    @Override\n    public synchronized void nextBytes(byte[] bytes) {\n        if (!initialized) {\n            long start = System.currentTimeMillis();\n            ThreadedSeedGenerator threadedSeedGenerator = new ThreadedSeedGenerator();\n            do {\n                addSeedMaterial(threadedSeedGenerator.generateSeed(64, true));\n                try {\n                    Thread.sleep(1);\n                } catch (InterruptedException ignored) {\n                }\n                addSeedMaterial(threadedSeedGenerator.generateSeed(32, false));\n            } while (Math.abs(System.currentTimeMillis() - start) < 1000);\n            addSeedMaterial(System.nanoTime());\n            addSeedMaterial(System.currentTimeMillis());\n            addSeedMaterial(SystemClock.elapsedRealtime());\n            addSeedMaterial(SystemClock.currentThreadTimeMillis());\n            addSeedMaterial(new java.security.SecureRandom().generateSeed(128));\n            addSeedMaterial((\"\" + Build.DEVICE + Build.MODEL + Build.TIME + Build.VERSION.SDK_INT).getBytes());\n\n            ExecutorService executor = Executors.newSingleThreadExecutor();\n            try {\n                Future future = executor.submit(new Runnable() {\n                    @Override\n                    public void run() {\n                        byte[] devRandomSeed = getDevRandomSeed();\n                        if (devRandomSeed != null) {\n                            addSeedMaterial(devRandomSeed);\n                        }\n                    }\n                });\n\n                future.get(3, TimeUnit.SECONDS);\n            } catch (InterruptedException e) {\n                Log.v(TAG, \"/dev/random read interrupted\");\n            } catch (ExecutionException e) {\n                Log.e(TAG, \"/dev/random read error\");\n            } catch (TimeoutException e) {\n                Log.w(TAG, \"/dev/random read timeout\");\n            } finally {\n                executor.shutdownNow();\n            }\n            initialized = true;\n        }\n        generator.nextBytes(bytes);\n    }\n\n\n    @Override\n    public String getAlgorithm() {\n        return \"BouncyCastle\";\n    }\n\n    private byte[] getDevRandomSeed() {\n        byte[] buf = null;\n        File file = new File(\"/dev/random\");\n        FileInputStream inputStream = null;\n        try {\n            inputStream = new FileInputStream(file);\n            buf = new byte[16];\n            for (int i = 0; i < buf.length; i++) {\n                int ch = inputStream.read();\n                if (ch == -1) {\n                    return null;\n                }\n                buf[i] = (byte) ch;\n            }\n        } catch (Exception ignored) {\n        } finally {\n            if (inputStream != null) {\n                try {\n                    inputStream.close();\n                } catch (IOException ignored) {\n\n                }\n            }\n        }\n        return buf;\n    }\n\n    @Override\n    public void setSeed(byte[] seed) {\n        Log.w(\"SecureRandom\", \"setting seed \" + HexUtils.toHex(seed) + \" was ignored\");\n    }\n\n    @Override\n    public void setSeed(long seed) {\n        Log.w(\"SecureRandom\", \"setting seed \" + seed + \" was ignored\");\n    }\n\n    @Override\n    public byte[] generateSeed(int numBytes) {\n        throw new RuntimeException(\"not supported\");\n    }\n\n    @Override\n    public boolean nextBoolean() {\n        throw new RuntimeException(\"not supported\");\n    }\n\n    @Override\n    public double nextDouble() {\n        throw new RuntimeException(\"not supported\");\n    }\n\n    @Override\n    public float nextFloat() {\n        throw new RuntimeException(\"not supported\");\n    }\n\n    @Override\n    public synchronized double nextGaussian() {\n        throw new RuntimeException(\"not supported\");\n    }\n\n    @Override\n    public long nextLong() {\n        throw new RuntimeException(\"not supported\");\n    }\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip32/ExtendedKey.java",
    "content": "/*\n * Copyright 2013 bits of proof zrt.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *    http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.quincysx.crypto.bip32;\n\nimport com.quincysx.crypto.ECKeyPair;\nimport com.quincysx.crypto.ECPublicKey;\nimport com.quincysx.crypto.Key;\nimport com.quincysx.crypto.utils.Base58Check;\n\nimport org.spongycastle.asn1.sec.SECNamedCurves;\nimport org.spongycastle.asn1.x9.X9ECParameters;\nimport org.spongycastle.crypto.generators.SCrypt;\nimport org.spongycastle.math.ec.ECPoint;\nimport org.spongycastle.util.Arrays;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\nimport java.io.UnsupportedEncodingException;\nimport java.math.BigInteger;\nimport java.security.InvalidAlgorithmParameterException;\nimport java.security.InvalidKeyException;\nimport java.security.NoSuchAlgorithmException;\nimport java.security.NoSuchProviderException;\nimport java.security.SecureRandom;\n\nimport javax.crypto.BadPaddingException;\nimport javax.crypto.Cipher;\nimport javax.crypto.IllegalBlockSizeException;\nimport javax.crypto.Mac;\nimport javax.crypto.NoSuchPaddingException;\nimport javax.crypto.SecretKey;\nimport javax.crypto.spec.IvParameterSpec;\nimport javax.crypto.spec.SecretKeySpec;\n\n/**\n * Key Generator following BIP32 https://en.bitcoin.it/wiki/BIP_0032\n */\npublic class ExtendedKey {\n    private static final SecureRandom rnd = new SecureRandom();\n    private static final X9ECParameters curve = SECNamedCurves.getByName(\"secp256k1\");\n\n    private final Key master;\n    private final byte[] chainCode;\n    private final int depth;\n    private final int parent;\n    private final int sequence;\n\n    private static final byte[] BITCOIN_SEED = \"Bitcoin seed\".getBytes();\n\n    public static ExtendedKey createFromPassphrase(String passphrase, byte[] encrypted) throws\n            ValidationException {\n        try {\n            byte[] key = SCrypt.generate(passphrase.getBytes(\"UTF-8\"), BITCOIN_SEED, 16384, 8, 8,\n                    32);\n            SecretKeySpec keyspec = new SecretKeySpec(key, \"AES\");\n            if (encrypted.length == 32) {\n                // asssume encrypted is seed\n                Cipher cipher = Cipher.getInstance(\"AES/ECB/NoPadding\", \"BC\");\n                cipher.init(Cipher.DECRYPT_MODE, keyspec);\n                return create(cipher.doFinal(encrypted));\n            } else {\n                // assume encrypted serialization of a key\n                Cipher cipher = Cipher.getInstance(\"AES/CBC/PKCS5Padding\", \"BC\");\n                byte[] iv = Arrays.copyOfRange(encrypted, 0, 16);\n                byte[] data = Arrays.copyOfRange(encrypted, 16, encrypted.length);\n                cipher.init(Cipher.DECRYPT_MODE, keyspec, new IvParameterSpec(iv));\n                return ExtendedKey.parse(new String(cipher.doFinal(data)));\n            }\n        } catch (UnsupportedEncodingException e) {\n            throw new ValidationException(e);\n        } catch (IllegalBlockSizeException e) {\n            throw new ValidationException(e);\n        } catch (BadPaddingException e) {\n            throw new ValidationException(e);\n        } catch (InvalidKeyException e) {\n            throw new ValidationException(e);\n        } catch (NoSuchAlgorithmException e) {\n            throw new ValidationException(e);\n        } catch (NoSuchProviderException e) {\n            throw new ValidationException(e);\n        } catch (NoSuchPaddingException e) {\n            throw new ValidationException(e);\n        } catch (InvalidAlgorithmParameterException e) {\n            throw new ValidationException(e);\n        }\n    }\n\n    public byte[] encrypt(String passphrase, boolean production) throws ValidationException {\n        try {\n            byte[] key = SCrypt.generate(passphrase.getBytes(\"UTF-8\"), BITCOIN_SEED, 16384, 8, 8,\n                    32);\n            SecretKeySpec keyspec = new SecretKeySpec(key, \"AES\");\n            Cipher cipher = Cipher.getInstance(\"AES/CBC/PKCS5Padding\", \"BC\");\n            cipher.init(Cipher.ENCRYPT_MODE, keyspec);\n            byte[] iv = cipher.getIV();\n            byte[] c = cipher.doFinal(serialize(production).getBytes());\n            byte[] result = new byte[iv.length + c.length];\n            System.arraycopy(iv, 0, result, 0, iv.length);\n            System.arraycopy(c, 0, result, iv.length, c.length);\n            return result;\n        } catch (UnsupportedEncodingException | NoSuchAlgorithmException |\n                NoSuchProviderException | NoSuchPaddingException | InvalidKeyException\n                | IllegalBlockSizeException | BadPaddingException e) {\n            throw new ValidationException(e);\n        }\n    }\n\n    public static ExtendedKey create(byte[] seed) throws ValidationException {\n        try {\n            Mac mac = Mac.getInstance(\"HmacSHA512\", \"BC\");\n            SecretKey seedkey = new SecretKeySpec(BITCOIN_SEED, \"HmacSHA512\");\n            mac.init(seedkey);\n            byte[] lr = mac.doFinal(seed);\n            byte[] l = Arrays.copyOfRange(lr, 0, 32);\n            byte[] r = Arrays.copyOfRange(lr, 32, 64);\n            BigInteger m = new BigInteger(1, l);\n            if (m.compareTo(curve.getN()) >= 0) {\n                throw new ValidationException(\"This is rather unlikely, but it did just happen\");\n            }\n            ECKeyPair keyPair = new ECKeyPair(l, true);\n            return new ExtendedKey(keyPair, r, 0, 0, 0);\n        } catch (NoSuchAlgorithmException e) {\n            throw new ValidationException(e);\n        } catch (NoSuchProviderException e) {\n            throw new ValidationException(e);\n        } catch (InvalidKeyException e) {\n            throw new ValidationException(e);\n        }\n    }\n\n    public static ExtendedKey createNew() {\n        Key key = ECKeyPair.createNew(true);\n        byte[] chainCode = new byte[32];\n        rnd.nextBytes(chainCode);\n        return new ExtendedKey(key, chainCode, 0, 0, 0);\n    }\n\n    /**\n     * @param bytes\n     * @return\n     * @throws ValidationException\n     * @deprecated\n     */\n    public static ExtendedKey parsePrivateKey(byte[] bytes) throws ValidationException {\n        Key key = new ECKeyPair(bytes, true);\n        byte[] chainCode = new byte[32];\n        rnd.nextBytes(chainCode);\n        return new ExtendedKey(key, chainCode, 0, 0, 0);\n    }\n\n    public ExtendedKey(Key key, byte[] chainCode, int depth, int parent, int sequence) {\n        this.master = key;\n        this.chainCode = chainCode;\n        this.parent = parent;\n        this.depth = depth;\n        this.sequence = sequence;\n    }\n\n    public Key getMaster() {\n        return master;\n    }\n\n    public byte[] getChainCode() {\n        return Arrays.clone(chainCode);\n    }\n\n    public int getDepth() {\n        return depth;\n    }\n\n    public int getParent() {\n        return parent;\n    }\n\n    public int getSequence() {\n        return sequence;\n    }\n\n    public int getFingerPrint() {\n        int fingerprint = 0;\n        byte[] address = master.getRawAddress();\n        for (int i = 0; i < 4; ++i) {\n            fingerprint <<= 8;\n            fingerprint |= address[i] & 0xff;\n        }\n        return fingerprint;\n    }\n\n    public Key getKey(int sequence) throws ValidationException {\n        return generateKey(sequence).getMaster();\n    }\n\n    public ExtendedKey getChild(int sequence) throws ValidationException {\n        ExtendedKey sub = generateKey(sequence);\n        return new ExtendedKey(sub.getMaster(), sub.getChainCode(), sub.getDepth() + 1,\n                getFingerPrint(), sequence);\n    }\n\n    public ExtendedKey getReadOnly() {\n        return new ExtendedKey(new ECPublicKey(master.getRawPublicKey(), true), chainCode, depth,\n                parent, sequence);\n    }\n\n    public boolean isReadOnly() {\n        return master.getRawPrivateKey() == null;\n    }\n\n    private ExtendedKey generateKey(int sequence) throws ValidationException {\n        try {\n            if ((sequence & 0x80000000) != 0 && master.getRawPrivateKey() == null) {\n                throw new ValidationException(\"need private key for private generation\");\n            }\n            Mac mac = Mac.getInstance(\"HmacSHA512\", \"BC\");\n            SecretKey key = new SecretKeySpec(chainCode, \"HmacSHA512\");\n            mac.init(key);\n\n            byte[] extended;\n            byte[] pub = master.getRawPublicKey();\n            if ((sequence & 0x80000000) == 0) {\n                extended = new byte[pub.length + 4];\n                System.arraycopy(pub, 0, extended, 0, pub.length);\n                extended[pub.length] = (byte) ((sequence >>> 24) & 0xff);\n                extended[pub.length + 1] = (byte) ((sequence >>> 16) & 0xff);\n                extended[pub.length + 2] = (byte) ((sequence >>> 8) & 0xff);\n                extended[pub.length + 3] = (byte) (sequence & 0xff);\n            } else {\n                byte[] priv = master.getRawPrivateKey();\n                extended = new byte[priv.length + 5];\n                System.arraycopy(priv, 0, extended, 1, priv.length);\n                extended[priv.length + 1] = (byte) ((sequence >>> 24) & 0xff);\n                extended[priv.length + 2] = (byte) ((sequence >>> 16) & 0xff);\n                extended[priv.length + 3] = (byte) ((sequence >>> 8) & 0xff);\n                extended[priv.length + 4] = (byte) (sequence & 0xff);\n            }\n            byte[] lr = mac.doFinal(extended);\n            byte[] l = Arrays.copyOfRange(lr, 0, 32);\n            byte[] r = Arrays.copyOfRange(lr, 32, 64);\n\n            BigInteger m = new BigInteger(1, l);\n            if (m.compareTo(curve.getN()) >= 0) {\n                throw new ValidationException(\"This is rather unlikely, but it did just happen\");\n            }\n            if (master.getRawPrivateKey() != null) {\n                BigInteger k = m.add(new BigInteger(1, master.getRawPrivateKey())).mod(curve.getN\n                        ());\n                if (k.equals(BigInteger.ZERO)) {\n                    throw new ValidationException(\"This is rather unlikely, but it did just \" +\n                            \"happen\");\n                }\n                return new ExtendedKey(new ECKeyPair(k, true), r, depth, parent, sequence);\n            } else {\n                ECPoint q = curve.getG().multiply(m).add(curve.getCurve().decodePoint(pub));\n                if (q.isInfinity()) {\n                    throw new ValidationException(\"This is rather unlikely, but it did just \" +\n                            \"happen\");\n                }\n                pub = new ECPoint.Fp(curve.getCurve(), q.getX(), q.getY(), true).getEncoded();\n                return new ExtendedKey(new ECPublicKey(pub, true), r, depth, parent, sequence);\n            }\n        } catch (NoSuchAlgorithmException e) {\n            throw new ValidationException(e);\n        } catch (NoSuchProviderException e) {\n            throw new ValidationException(e);\n        } catch (InvalidKeyException e) {\n            throw new ValidationException(e);\n        }\n    }\n\n    private static final byte[] xprv = new byte[]{0x04, (byte) 0x88, (byte) 0xAD, (byte) 0xE4};\n    private static final byte[] xpub = new byte[]{0x04, (byte) 0x88, (byte) 0xB2, (byte) 0x1E};\n    private static final byte[] tprv = new byte[]{0x04, (byte) 0x35, (byte) 0x83, (byte) 0x94};\n    private static final byte[] tpub = new byte[]{0x04, (byte) 0x35, (byte) 0x87, (byte) 0xCF};\n\n    public String serialize(boolean production) {\n        ByteArrayOutputStream out = new ByteArrayOutputStream();\n        try {\n            if (master.getRawPrivateKey() != null) {\n                if (production) {\n                    out.write(xprv);\n                } else {\n                    out.write(tprv);\n                }\n            } else {\n                if (production) {\n                    out.write(xpub);\n                } else {\n                    out.write(tpub);\n                }\n            }\n            out.write(depth & 0xff);\n            out.write((parent >>> 24) & 0xff);\n            out.write((parent >>> 16) & 0xff);\n            out.write((parent >>> 8) & 0xff);\n            out.write(parent & 0xff);\n            out.write((sequence >>> 24) & 0xff);\n            out.write((sequence >>> 16) & 0xff);\n            out.write((sequence >>> 8) & 0xff);\n            out.write(sequence & 0xff);\n            out.write(chainCode);\n            if (master.getRawPrivateKey() != null) {\n                out.write(0x00);\n                out.write(master.getRawPrivateKey());\n            } else {\n                out.write(master.getRawPublicKey());\n            }\n        } catch (IOException e) {\n        }\n        return Base58Check.bytesToBase58(out.toByteArray());\n    }\n\n    public static ExtendedKey parse(String serialized) throws ValidationException {\n        byte[] data = Base58Check.base58ToBytes(serialized);\n        if (data.length != 78) {\n            throw new ValidationException(\"invalid extended key\");\n        }\n        byte[] type = Arrays.copyOf(data, 4);\n        boolean hasPrivate;\n        if (Arrays.areEqual(type, xprv) || Arrays.areEqual(type, tprv)) {\n            hasPrivate = true;\n        } else if (Arrays.areEqual(type, xpub) || Arrays.areEqual(type, tpub)) {\n            hasPrivate = false;\n        } else {\n            throw new ValidationException(\"invalid magic number for an extended key\");\n        }\n\n        int depth = data[4] & 0xff;\n\n        int parent = data[5] & 0xff;\n        parent <<= 8;\n        parent |= data[6] & 0xff;\n        parent <<= 8;\n        parent |= data[7] & 0xff;\n        parent <<= 8;\n        parent |= data[8] & 0xff;\n\n        int sequence = data[9] & 0xff;\n        sequence <<= 8;\n        sequence |= data[10] & 0xff;\n        sequence <<= 8;\n        sequence |= data[11] & 0xff;\n        sequence <<= 8;\n        sequence |= data[12] & 0xff;\n\n        byte[] chainCode = Arrays.copyOfRange(data, 13, 13 + 32);\n        byte[] pubOrPriv = Arrays.copyOfRange(data, 13 + 32, data.length);\n        Key key;\n        if (hasPrivate) {\n            key = new ECKeyPair(new BigInteger(1, pubOrPriv), true);\n        } else {\n            key = new ECPublicKey(pubOrPriv, true);\n        }\n        return new ExtendedKey(key, chainCode, depth, parent, sequence);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip32/Index.java",
    "content": "package com.quincysx.crypto.bip32;\n\n/**\n * @author QuincySx\n * @date 2018/3/5 下午4:29\n */\npublic final class Index {\n    Index() {\n    }\n\n    public static int hard(final int index) {\n        return index | 0x80000000;\n    }\n\n    public static boolean isHardened(final int i) {\n        return (i & 0x80000000) != 0;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip32/ValidationException.java",
    "content": "/*\n * Copyright 2013 bits of proof zrt.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *    http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.quincysx.crypto.bip32;\n\npublic class ValidationException extends Exception\n{\n\tprivate static final long serialVersionUID = 1L;\n\n\tpublic ValidationException(Throwable cause)\n\t{\n\t\tsuper (cause);\n\t}\n\n\tpublic ValidationException(String message, Throwable cause)\n\t{\n\t\tsuper (message, cause);\n\t}\n\n\tpublic ValidationException(String message)\n\t{\n\t\tsuper (message);\n\t}\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip38/Bip38.java",
    "content": "package com.quincysx.crypto.bip38;\n\n\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.bitcoin.BitCoinECKeyPair;\nimport com.quincysx.crypto.utils.Base58;\nimport com.quincysx.crypto.utils.HexUtils;\nimport com.quincysx.crypto.utils.SHA256;\n\nimport org.spongycastle.crypto.generators.SCrypt;\n\nimport java.math.BigInteger;\nimport java.nio.ByteBuffer;\nimport java.nio.CharBuffer;\nimport java.nio.charset.Charset;\nimport java.util.Arrays;\n\n/**\n * @author QuincySx\n * @date 2018/3/8 下午2:41\n */\npublic class Bip38 {\n    //官方推荐参数 性能差的手机耗时特别长\n    private static final int SCRYPT_N = 16384;\n    private static final int SCRYPT_R = 8;\n    private static final int SCRYPT_P = 8;\n\n    //性能差的手机也秒出，安全性差\n//    private static final int SCRYPT_N = 1024;\n//    private static final int SCRYPT_R = 1;\n//    private static final int SCRYPT_P = 1;\n\n    private static final int SCRYPT_LENGTH = 64;\n\n    private static final BigInteger n = new BigInteger(1, HexUtils.fromHex(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"));\n\n    /**\n     * Encrypt a SIPA formatted private key with a passphrase using BIP38.\n     * <p/>\n     * This is a helper function that does everything in one go. You can call the\n     * individual functions if you wish to separate it into more phases.\n     *\n     * @throws InterruptedException\n     */\n    public static String encryptNoEcMultiply(CharSequence passphrase, String base58EncodedPrivateKey) throws ValidationException, InterruptedException {\n        byte[] tmp = Base58.decode(base58EncodedPrivateKey);\n\n        int version = tmp[0] & 0xFF;\n\n        byte[] bytes = new byte[tmp.length - 4 - 1];\n        System.arraycopy(tmp, 1, bytes, 0, bytes.length);\n        boolean compressed = true;\n        if (bytes.length == 33 && bytes[32] == 1) {\n            compressed = true;\n            bytes = java.util.Arrays.copyOf(bytes, 32);  // Chop off the additional marker byte.\n        } else if (bytes.length == 32) {\n            compressed = false;\n        }\n\n        boolean testNet = false;\n        if (version == BitCoinECKeyPair.TEST_NET_PRIVATE_KEY_PREFIX) {\n            testNet = true;\n        } else if (version == BitCoinECKeyPair.MAIN_NET_PRIVATE_KEY_PREFIX) {\n            testNet = false;\n        }\n\n        Arrays.fill(tmp, (byte) 0);\n\n        BitCoinECKeyPair bitCoinECKeyPair = new BitCoinECKeyPair(bytes, testNet, compressed);\n\n        byte[] salt = Bip38.calculateScryptSalt(bitCoinECKeyPair.getAddress());\n        byte[] stretchedKeyMaterial = bip38Stretch1(passphrase, salt, SCRYPT_LENGTH);\n\n        return encryptNoEcMultiply(stretchedKeyMaterial, bitCoinECKeyPair, salt);\n    }\n\n    /**\n     * Perform BIP38 compatible password stretching on a password to derive the\n     * BIP38 key material\n     *\n     * @throws InterruptedException\n     */\n    public static byte[] bip38Stretch1(CharSequence passphrase, byte[] salt, int outputSize)\n            throws InterruptedException {\n        byte[] passwordBytes = null;\n        byte[] derived;\n        try {\n            passwordBytes = convertToByteArray(passphrase);\n            derived = SCrypt.generate(passwordBytes, salt, SCRYPT_N, SCRYPT_R, SCRYPT_P, outputSize\n            );\n            return derived;\n        } finally {\n            // Zero the password bytes.\n            if (passwordBytes != null) {\n                java.util.Arrays.fill(passwordBytes, (byte) 0);\n            }\n        }\n    }\n\n    private static byte[] convertToByteArray(CharSequence charSequence) {\n        if (charSequence == null) {\n            throw new RuntimeException(\"charSequence not NULL\");\n        }\n        ByteBuffer bb = Charset.forName(\"UTF-8\").encode(CharBuffer.wrap(charSequence));\n        byte[] result = new byte[bb.remaining()];\n        bb.get(result);\n        bb.clear();\n        byte[] clearTest = new byte[bb.remaining()];\n        java.util.Arrays.fill(clearTest, (byte) 0);\n        bb.put(clearTest);\n        return result;\n    }\n\n    public static String encryptNoEcMultiply(byte[] stretcedKeyMaterial, BitCoinECKeyPair key, byte[] salt) {\n        int checksumLength = 4;\n        byte[] encoded = new byte[39 + checksumLength];\n        int index = 0;\n        encoded[index++] = (byte) 0x01;\n        encoded[index++] = (byte) 0x42;\n\n        byte non_EC_multiplied = (byte) 0xC0;\n        byte compressedPublicKey = key.isCompressed() ? (byte) 0x20 : (byte) 0;\n        encoded[index++] = (byte) (non_EC_multiplied | compressedPublicKey);\n\n        // Salt\n        System.arraycopy(salt, 0, encoded, index, salt.length);\n        index += salt.length;\n\n        // Derive Keys\n        byte[] derivedHalf1 = new byte[32];\n        System.arraycopy(stretcedKeyMaterial, 0, derivedHalf1, 0, 32);\n        byte[] derivedHalf2 = new byte[32];\n        System.arraycopy(stretcedKeyMaterial, 32, derivedHalf2, 0, 32);\n\n        // Initialize AES key\n        Rijndael aes = new Rijndael();\n        aes.makeKey(derivedHalf2, 256);\n\n        // Get private key bytes\n        byte[] complete = key.getRawPrivateKey();\n\n        // Insert first encrypted key part\n        byte[] toEncryptPart1 = new byte[16];\n        for (int i = 0; i < 16; i++) {\n            toEncryptPart1[i] = (byte) ((((int) complete[i]) & 0xFF) ^ (((int) derivedHalf1[i]) & 0xFF));\n        }\n        byte[] encryptedHalf1 = new byte[16];\n        aes.encrypt(toEncryptPart1, encryptedHalf1);\n        System.arraycopy(encryptedHalf1, 0, encoded, index, encryptedHalf1.length);\n        index += encryptedHalf1.length;\n\n        // Insert second encrypted key part\n        byte[] toEncryptPart2 = new byte[16];\n        for (int i = 0; i < 16; i++) {\n            toEncryptPart2[i] = (byte) ((((int) complete[16 + i]) & 0xFF) ^ (((int) derivedHalf1[16 + i]) & 0xFF));\n        }\n        byte[] encryptedHalf2 = new byte[16];\n        aes.encrypt(toEncryptPart2, encryptedHalf2);\n        System.arraycopy(encryptedHalf2, 0, encoded, index, encryptedHalf2.length);\n        index += encryptedHalf2.length;\n\n        // Checksum\n        byte[] checkSum = SHA256.doubleSha256(encoded, 0, 39);\n\n        byte[] start = new byte[4];\n        System.arraycopy(checkSum, 0, start, 0, 4);\n\n        System.arraycopy(start, 0, encoded, 39, checksumLength);\n\n        // Base58 encode\n        return Base58.encode(encoded);\n    }\n\n    public static boolean isBip38PrivateKey(String bip38PrivateKey) {\n        return parseBip38PrivateKey(bip38PrivateKey) != null;\n    }\n\n    public static class Bip38PrivateKey {\n        public boolean ecMultiply;\n        public boolean compressed;\n        public boolean lotSequence;\n        public byte[] salt;\n        public byte[] data;\n\n        public Bip38PrivateKey(boolean ecMultiply, boolean compressed, boolean lotSequence, byte[] salt, byte[] data) {\n            this.ecMultiply = ecMultiply;\n            this.compressed = compressed;\n            this.lotSequence = lotSequence;\n            this.salt = salt;\n            this.data = data;\n        }\n    }\n\n    public static Bip38PrivateKey parseBip38PrivateKey(String bip38PrivateKey) {\n        // Decode Base 58\n        byte[] decoded = Base58.decode(bip38PrivateKey);\n        if (decoded == null) {\n            return null;\n        }\n\n        //Validate length\n        if (!(decoded.length == 39 || decoded.length == 43)) {\n            return null;\n        }\n\n        int index = 0;\n\n        // Validate BIP 38 prefix\n        if (decoded[index++] != (byte) 0x01) {\n            return null;\n        }\n        boolean ecMultiply;\n        if (decoded[index] == (byte) 0x42) {\n            ecMultiply = false;\n        } else if (decoded[index] == (byte) 0x43) {\n            ecMultiply = true;\n        } else {\n            return null;\n        }\n        index++;\n\n        // Validate flags and determine whether we have a compressed key\n        int flags = ((int) decoded[index++]) & 0x00ff;\n\n        boolean lotSequence;\n\n        if (ecMultiply) {\n            if ((flags | 0x0024) != 0x24) {\n                // Only bit 3 and 6 can be set for EC-multiply keys\n                return null;\n            }\n            lotSequence = (flags & 0x0004) == 0 ? false : true;\n        } else {\n            if ((flags | 0x00E0) != 0xE0) {\n                // Only bit 6 7 and 8 can be set for non-EC-multiply keys\n                return null;\n            }\n            if ((flags & 0x00c0) != 0x00c0) {\n                // Upper two bits must be set for non-EC-multiplied key\n                return null;\n            }\n            lotSequence = false;\n        }\n\n        boolean compressed = (flags & 0x0020) == 0 ? false : true;\n\n        // Fetch salt\n        byte[] salt = new byte[4];\n        salt[0] = decoded[index++];\n        salt[1] = decoded[index++];\n        salt[2] = decoded[index++];\n        salt[3] = decoded[index++];\n\n        // Fetch data\n        byte[] data = new byte[32];\n        System.arraycopy(decoded, index, data, 0, data.length);\n        index += data.length;\n\n        return new Bip38PrivateKey(ecMultiply, compressed, lotSequence, salt, data);\n    }\n\n    /**\n     * 可能为 Null ，Null 代表密码不正确\n     */\n    public static BitCoinECKeyPair decrypt(String bip38PrivateKeyString, CharSequence passphrase) throws InterruptedException, ValidationException {\n        Bip38PrivateKey bip38Key = parseBip38PrivateKey(bip38PrivateKeyString);\n        if (bip38Key == null) {\n            return null;\n        }\n        if (bip38Key.ecMultiply) {\n            return decryptEcMultiply(bip38Key, passphrase);\n        } else {\n            byte[] stretcedKeyMaterial = bip38Stretch1(passphrase, bip38Key.salt, SCRYPT_LENGTH);\n            return decryptNoEcMultiply(bip38Key, stretcedKeyMaterial);\n        }\n    }\n\n    public static BitCoinECKeyPair decryptEcMultiply(Bip38PrivateKey bip38Key, CharSequence passphrase\n    ) throws InterruptedException, ValidationException {\n        // Get 8 byte Owner Salt\n        byte[] ownerEntropy = new byte[8];\n        System.arraycopy(bip38Key.data, 0, ownerEntropy, 0, 8);\n\n        byte[] ownerSalt = ownerEntropy;\n        if (bip38Key.lotSequence) {\n            ownerSalt = new byte[4];\n            System.arraycopy(ownerEntropy, 0, ownerSalt, 0, 4);\n        }\n\n        // Stretch to get Pass Factor\n        byte[] passFactor = bip38Stretch1(passphrase, ownerSalt, 32);\n\n        if (bip38Key.lotSequence) {\n            byte[] tmp = new byte[40];\n            System.arraycopy(passFactor, 0, tmp, 0, 32);\n            System.arraycopy(ownerEntropy, 0, tmp, 32, 8);\n            //we convert to byte[] here since this can be a sha256 or Scrypt result.\n            // might make sense to introduce a 32 byte scrypt type\n            passFactor = SHA256.doubleSha256(tmp);\n        }\n        // Determine Pass Point\n\n        BitCoinECKeyPair bitCoinECKeyPair = new BitCoinECKeyPair(passFactor, false, bip38Key.compressed);\n        byte[] passPoint = bitCoinECKeyPair.getRawPublicKey();\n\n        // Get 8 byte encrypted part 1, only first half of encrypted part 1\n        // (the rest is encrypted within encryptedpart2)\n        byte[] encryptedPart1 = new byte[16];\n        System.arraycopy(bip38Key.data, 8, encryptedPart1, 0, 8);\n        // Get 16 byte encrypted part 2\n        byte[] encryptedPart2 = new byte[16];\n        System.arraycopy(bip38Key.data, 16, encryptedPart2, 0, 16);\n\n        // Second stretch to derive decryption key\n        byte[] saltPlusOwnerSalt = new byte[12];\n        System.arraycopy(bip38Key.salt, 0, saltPlusOwnerSalt, 0, 4);\n        System.arraycopy(ownerEntropy, 0, saltPlusOwnerSalt, 4, 8);\n//        byte[] derived = SCrypt.generate(passPoint, saltPlusOwnerSalt, 1024, 1, 1, 64);\n        byte[] derived = SCrypt.generate(passPoint, saltPlusOwnerSalt, SCRYPT_N, SCRYPT_R, SCRYPT_P, SCRYPT_LENGTH);\n        byte[] derivedQuater1 = new byte[16];\n        System.arraycopy(derived, 0, derivedQuater1, 0, 16);\n        byte[] derivedQuater2 = new byte[16];\n        System.arraycopy(derived, 16, derivedQuater2, 0, 16);\n        byte[] derivedHalf2 = new byte[32];\n        System.arraycopy(derived, 32, derivedHalf2, 0, 32);\n\n        Rijndael aes = new Rijndael();\n        aes.makeKey(derivedHalf2, 256);\n\n        byte[] unencryptedPart2 = new byte[16];\n        aes.decrypt(encryptedPart2, unencryptedPart2);\n        xorBytes(derivedQuater2, unencryptedPart2);\n\n        // Get second half of encrypted half 1\n        System.arraycopy(unencryptedPart2, 0, encryptedPart1, 8, 8);\n\n        // Decrypt part 1\n        byte[] unencryptedPart1 = new byte[16];\n        aes.decrypt(encryptedPart1, unencryptedPart1);\n        xorBytes(derivedQuater1, unencryptedPart1);\n\n        // Recover seedB\n        byte[] seedB = new byte[24];\n        System.arraycopy(unencryptedPart1, 0, seedB, 0, 16);\n        System.arraycopy(unencryptedPart2, 8, seedB, 16, 8);\n\n        // Generate factorB\n        byte[] factorB = SHA256.doubleSha256(seedB);\n\n        BigInteger privateKey = new BigInteger(1, passFactor).multiply(new BigInteger(1, factorB).mod(n));\n        byte[] keyBytes = new byte[32];\n        byte[] bytes = privateKey.toByteArray();\n        if (bytes.length <= keyBytes.length) {\n            System.arraycopy(bytes, 0, keyBytes, keyBytes.length - bytes.length, bytes.length);\n        } else {\n            assert bytes.length == 33 && bytes[0] == 0;\n            System.arraycopy(bytes, 1, keyBytes, 0, bytes.length - 1);\n        }\n\n        BitCoinECKeyPair ecKeyPair = verify(keyBytes, bip38Key.salt, false, bip38Key.compressed);\n        if (ecKeyPair == null) {\n            return verify(keyBytes, bip38Key.salt, true, bip38Key.compressed);\n        }\n        return ecKeyPair;\n    }\n\n    public static BitCoinECKeyPair decryptNoEcMultiply(Bip38PrivateKey bip38Key, byte[] stretcedKeyMaterial) throws ValidationException {\n        // Derive Keys\n        byte[] derivedHalf1 = new byte[32];\n        System.arraycopy(stretcedKeyMaterial, 0, derivedHalf1, 0, 32);\n        byte[] derivedHalf2 = new byte[32];\n        System.arraycopy(stretcedKeyMaterial, 32, derivedHalf2, 0, 32);\n\n        // Initialize AES key\n        Rijndael aes = new Rijndael();\n        aes.makeKey(derivedHalf2, 256);\n\n        // Fetch first encrypted half\n        byte[] encryptedHalf1 = new byte[16];\n        System.arraycopy(bip38Key.data, 0, encryptedHalf1, 0, encryptedHalf1.length);\n\n        // Fetch second encrypted half\n        byte[] encryptedHalf2 = new byte[16];\n        System.arraycopy(bip38Key.data, 16, encryptedHalf2, 0, encryptedHalf2.length);\n\n        byte[] decryptedHalf1 = new byte[16];\n        aes.decrypt(encryptedHalf1, decryptedHalf1);\n\n        byte[] decryptedHalf2 = new byte[16];\n        aes.decrypt(encryptedHalf2, decryptedHalf2);\n\n        byte[] complete = new byte[32];\n        for (int i = 0; i < 16; i++) {\n            complete[i] = (byte) ((((int) decryptedHalf1[i]) & 0xFF) ^ (((int) derivedHalf1[i]) & 0xFF));\n            complete[i + 16] = (byte) ((((int) decryptedHalf2[i]) & 0xFF) ^ (((int) derivedHalf1[i + 16]) & 0xFF));\n        }\n\n        BitCoinECKeyPair bitCoinECKeyPair = verify(complete, bip38Key.salt, false, bip38Key.compressed);\n        if (bitCoinECKeyPair == null) {\n            return verify(complete, bip38Key.salt, true, bip38Key.compressed);\n        }\n        return bitCoinECKeyPair;\n    }\n\n    private static BitCoinECKeyPair verify(byte[] complete, byte[] salt, boolean testNet, boolean compress) throws ValidationException {\n        BitCoinECKeyPair bitCoinECKeyPair = new BitCoinECKeyPair(complete, testNet, compress);\n\n        byte[] newSalt = calculateScryptSalt(bitCoinECKeyPair.getAddress());\n        if (!java.util.Arrays.equals(salt, newSalt)) {\n            // The passphrase is either invalid or we are on the wrong network\n            return null;\n        }\n        return bitCoinECKeyPair;\n    }\n\n\n    public static byte[] calculateScryptSalt(String address) {\n        byte[] hash = SHA256.doubleSha256(address.getBytes());\n        byte[] ret = new byte[4];\n        System.arraycopy(hash, 0, ret, 0, 4);\n        return ret;\n    }\n\n    private static void xorBytes(byte[] toApply, byte[] target) {\n        if (toApply.length != target.length) {\n            throw new RuntimeException();\n        }\n        for (int i = 0; i < toApply.length; i++) {\n            target[i] = (byte) (target[i] ^ toApply[i]);\n        }\n    }\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip38/Rijndael.java",
    "content": "package com.quincysx.crypto.bip38;\n\n/**\n * @author QuincySx\n * @date 2018/3/9 下午2:09\n */\npublic final class Rijndael {\n\n    public Rijndael() {\n    }\n\n    /**\n     * Flag to setup the encryption key schedule.\n     */\n    public static final int DIR_ENCRYPT = 1;\n\n    /**\n     * Flag to setup the decryption key schedule.\n     */\n    public static final int DIR_DECRYPT = 2;\n\n    /**\n     * Flag to setup both key schedules (encryption/decryption).\n     */\n    public static final int DIR_BOTH = (DIR_ENCRYPT | DIR_DECRYPT);\n\n    /**\n     * AES block size in bits\n     * (N.B. the Rijndael algorithm itself allows for other sizes).\n     */\n    public static final int BLOCK_BITS = 128;\n\n    /**\n     * AES block size in bytes\n     * (N.B. the Rijndael algorithm itself allows for other sizes).\n     */\n    public static final int BLOCK_SIZE = (BLOCK_BITS >>> 3);\n\n    /**\n     * Substitution table (S-box).\n     */\n    private static final String SS =\n            \"\\u637C\\u777B\\uF26B\\u6FC5\\u3001\\u672B\\uFED7\\uAB76\" +\n                    \"\\uCA82\\uC97D\\uFA59\\u47F0\\uADD4\\uA2AF\\u9CA4\\u72C0\" +\n                    \"\\uB7FD\\u9326\\u363F\\uF7CC\\u34A5\\uE5F1\\u71D8\\u3115\" +\n                    \"\\u04C7\\u23C3\\u1896\\u059A\\u0712\\u80E2\\uEB27\\uB275\" +\n                    \"\\u0983\\u2C1A\\u1B6E\\u5AA0\\u523B\\uD6B3\\u29E3\\u2F84\" +\n                    \"\\u53D1\\u00ED\\u20FC\\uB15B\\u6ACB\\uBE39\\u4A4C\\u58CF\" +\n                    \"\\uD0EF\\uAAFB\\u434D\\u3385\\u45F9\\u027F\\u503C\\u9FA8\" +\n                    \"\\u51A3\\u408F\\u929D\\u38F5\\uBCB6\\uDA21\\u10FF\\uF3D2\" +\n                    \"\\uCD0C\\u13EC\\u5F97\\u4417\\uC4A7\\u7E3D\\u645D\\u1973\" +\n                    \"\\u6081\\u4FDC\\u222A\\u9088\\u46EE\\uB814\\uDE5E\\u0BDB\" +\n                    \"\\uE032\\u3A0A\\u4906\\u245C\\uC2D3\\uAC62\\u9195\\uE479\" +\n                    \"\\uE7C8\\u376D\\u8DD5\\u4EA9\\u6C56\\uF4EA\\u657A\\uAE08\" +\n                    \"\\uBA78\\u252E\\u1CA6\\uB4C6\\uE8DD\\u741F\\u4BBD\\u8B8A\" +\n                    \"\\u703E\\uB566\\u4803\\uF60E\\u6135\\u57B9\\u86C1\\u1D9E\" +\n                    \"\\uE1F8\\u9811\\u69D9\\u8E94\\u9B1E\\u87E9\\uCE55\\u28DF\" +\n                    \"\\u8CA1\\u890D\\uBFE6\\u4268\\u4199\\u2D0F\\uB054\\uBB16\";\n\n    private static final byte[]\n            Se = new byte[256];\n\n    private static final int[]\n            Te0 = new int[256],\n            Te1 = new int[256],\n            Te2 = new int[256],\n            Te3 = new int[256];\n\n    private static final byte[]\n            Sd = new byte[256];\n\n    private static final int[]\n            Td0 = new int[256],\n            Td1 = new int[256],\n            Td2 = new int[256],\n            Td3 = new int[256];\n\n    /**\n     * Round constants\n     */\n    private static final int[]\n            rcon = new int[10]; /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */\n\n    /**\n     * Number of rounds (depends on key size).\n     */\n    private int Nr = 0;\n\n    private int Nk = 0;\n\n    private int Nw = 0;\n\n    /**\n     * Encryption key schedule\n     */\n    private int rek[] = null;\n\n    /**\n     * Decryption key schedule\n     */\n    private int rdk[] = null;\n\n    static {\n        /*\n            Te0[x] = Se[x].[02, 01, 01, 03];\n            Te1[x] = Se[x].[03, 02, 01, 01];\n            Te2[x] = Se[x].[01, 03, 02, 01];\n            Te3[x] = Se[x].[01, 01, 03, 02];\n            Td0[x] = Sd[x].[0e, 09, 0d, 0b];\n            Td1[x] = Sd[x].[0b, 0e, 09, 0d];\n            Td2[x] = Sd[x].[0d, 0b, 0e, 09];\n            Td3[x] = Sd[x].[09, 0d, 0b, 0e];\n        */\n        int ROOT = 0x11B;\n        int s1, s2, s3, i1, i2, i4, i8, i9, ib, id, ie, t;\n        for (i1 = 0; i1 < 256; i1++) {\n            char c = SS.charAt(i1 >>> 1);\n            s1 = (byte) ((i1 & 1) == 0 ? c >>> 8 : c) & 0xff;\n            s2 = s1 << 1;\n            if (s2 >= 0x100) {\n                s2 ^= ROOT;\n            }\n            s3 = s2 ^ s1;\n            i2 = i1 << 1;\n            if (i2 >= 0x100) {\n                i2 ^= ROOT;\n            }\n            i4 = i2 << 1;\n            if (i4 >= 0x100) {\n                i4 ^= ROOT;\n            }\n            i8 = i4 << 1;\n            if (i8 >= 0x100) {\n                i8 ^= ROOT;\n            }\n            i9 = i8 ^ i1;\n            ib = i9 ^ i2;\n            id = i9 ^ i4;\n            ie = i8 ^ i4 ^ i2;\n\n            Se[i1] = (byte) s1;\n            Te0[i1] = t = (s2 << 24) | (s1 << 16) | (s1 << 8) | s3;\n            Te1[i1] = (t >>> 8) | (t << 24);\n            Te2[i1] = (t >>> 16) | (t << 16);\n            Te3[i1] = (t >>> 24) | (t << 8);\n\n            Sd[s1] = (byte) i1;\n            Td0[s1] = t = (ie << 24) | (i9 << 16) | (id << 8) | ib;\n            Td1[s1] = (t >>> 8) | (t << 24);\n            Td2[s1] = (t >>> 16) | (t << 16);\n            Td3[s1] = (t >>> 24) | (t << 8);\n        }\n        /*\n         * round constants\n         */\n        int r = 1;\n        rcon[0] = r << 24;\n        for (int i = 1; i < 10; i++) {\n            r <<= 1;\n            if (r >= 0x100) {\n                r ^= ROOT;\n            }\n            rcon[i] = r << 24;\n        }\n    }\n\n    /**\n     * Expand a cipher key into a full encryption key schedule.\n     *\n     * @param cipherKey the cipher key (128, 192, or 256 bits).\n     */\n    private void expandKey(byte[] cipherKey) {\n        int temp, r = 0;\n        for (int i = 0, k = 0; i < Nk; i++, k += 4) {\n            rek[i] =\n                    ((cipherKey[k]) << 24) |\n                            ((cipherKey[k + 1] & 0xff) << 16) |\n                            ((cipherKey[k + 2] & 0xff) << 8) |\n                            ((cipherKey[k + 3] & 0xff));\n        }\n        for (int i = Nk, n = 0; i < Nw; i++, n--) {\n            temp = rek[i - 1];\n            if (n == 0) {\n                n = Nk;\n                temp =\n                        ((Se[(temp >>> 16) & 0xff]) << 24) |\n                                ((Se[(temp >>> 8) & 0xff] & 0xff) << 16) |\n                                ((Se[(temp) & 0xff] & 0xff) << 8) |\n                                ((Se[(temp >>> 24)] & 0xff));\n                temp ^= rcon[r++];\n            } else if (Nk == 8 && n == 4) {\n                temp =\n                        ((Se[(temp >>> 24)]) << 24) |\n                                ((Se[(temp >>> 16) & 0xff] & 0xff) << 16) |\n                                ((Se[(temp >>> 8) & 0xff] & 0xff) << 8) |\n                                ((Se[(temp) & 0xff] & 0xff));\n            }\n            rek[i] = rek[i - Nk] ^ temp;\n        }\n        temp = 0;\n    }\n\n    /*\n      * Faster implementation of the key expansion\n      * (only worthwhile in Rijndael is used in a hashing function mode).\n      */\n    /*\n    private void expandKey(byte[] cipherKey) {\n        int keyOffset = 0;\n           int i = 0;\n        int temp;\n        rek[0] =\n            (cipherKey[ 0]       ) << 24 |\n            (cipherKey[ 1] & 0xff) << 16 |\n            (cipherKey[ 2] & 0xff) <<  8 |\n            (cipherKey[ 3] & 0xff);\n        rek[1] =\n            (cipherKey[ 4]       ) << 24 |\n            (cipherKey[ 5] & 0xff) << 16 |\n            (cipherKey[ 6] & 0xff) <<  8 |\n            (cipherKey[ 7] & 0xff);\n        rek[2] =\n            (cipherKey[ 8]       ) << 24 |\n            (cipherKey[ 9] & 0xff) << 16 |\n            (cipherKey[10] & 0xff) <<  8 |\n            (cipherKey[11] & 0xff);\n        rek[3] =\n            (cipherKey[12]       ) << 24 |\n            (cipherKey[13] & 0xff) << 16 |\n            (cipherKey[14] & 0xff) <<  8 |\n            (cipherKey[15] & 0xff);\n        if (Nk == 4) {\n            for (;;) {\n                temp = rek[keyOffset + 3];\n                rek[keyOffset + 4] = rek[keyOffset] ^\n                    ((Se[(temp >>> 16) & 0xff]       ) << 24) ^\n                    ((Se[(temp >>>  8) & 0xff] & 0xff) << 16) ^\n                    ((Se[(temp       ) & 0xff] & 0xff) <<  8) ^\n                    ((Se[(temp >>> 24)       ] & 0xff)      ) ^\n                    rcon[i];\n                rek[keyOffset + 5] = rek[keyOffset + 1] ^ rek[keyOffset + 4];\n                rek[keyOffset + 6] = rek[keyOffset + 2] ^ rek[keyOffset + 5];\n                rek[keyOffset + 7] = rek[keyOffset + 3] ^ rek[keyOffset + 6];\n                if (++i == 10) {\n                    return;\n                }\n                keyOffset += 4;\n            }\n        }\n        rek[keyOffset + 4] =\n            (cipherKey[16]       ) << 24 |\n            (cipherKey[17] & 0xff) << 16 |\n            (cipherKey[18] & 0xff) <<  8 |\n            (cipherKey[19] & 0xff);\n        rek[keyOffset + 5] =\n            (cipherKey[20]       ) << 24 |\n            (cipherKey[21] & 0xff) << 16 |\n            (cipherKey[22] & 0xff) <<  8 |\n            (cipherKey[23] & 0xff);\n        if (Nk == 6) {\n            for (;;) {\n                temp = rek[keyOffset + 5];\n                rek[keyOffset +  6] = rek[keyOffset] ^\n                    ((Se[(temp >>> 16) & 0xff]       ) << 24) ^\n                    ((Se[(temp >>>  8) & 0xff] & 0xff) << 16) ^\n                    ((Se[(temp       ) & 0xff] & 0xff) <<  8) ^\n                    ((Se[(temp >>> 24)       ] & 0xff)      ) ^\n                    rcon[i];\n                rek[keyOffset +  7] = rek[keyOffset +  1] ^ rek[keyOffset +  6];\n                rek[keyOffset +  8] = rek[keyOffset +  2] ^ rek[keyOffset +  7];\n                rek[keyOffset +  9] = rek[keyOffset +  3] ^ rek[keyOffset +  8];\n                if (++i == 8) {\n                    return;\n                }\n                rek[keyOffset + 10] = rek[keyOffset +  4] ^ rek[keyOffset +  9];\n                rek[keyOffset + 11] = rek[keyOffset +  5] ^ rek[keyOffset + 10];\n                keyOffset += 6;\n            }\n        }\n        rek[keyOffset + 6] =\n            (cipherKey[24]       ) << 24 |\n            (cipherKey[25] & 0xff) << 16 |\n            (cipherKey[26] & 0xff) <<  8 |\n            (cipherKey[27] & 0xff);\n        rek[keyOffset + 7] =\n            (cipherKey[28]       ) << 24 |\n            (cipherKey[29] & 0xff) << 16 |\n            (cipherKey[30] & 0xff) <<  8 |\n            (cipherKey[31] & 0xff);\n        if (Nk == 8) {\n            for (;;) {\n                temp = rek[keyOffset +  7];\n                rek[keyOffset +  8] = rek[keyOffset] ^\n                    ((Se[(temp >>> 16) & 0xff]       ) << 24) ^\n                    ((Se[(temp >>>  8) & 0xff] & 0xff) << 16) ^\n                    ((Se[(temp       ) & 0xff] & 0xff) <<  8) ^\n                    ((Se[(temp >>> 24)       ] & 0xff)      ) ^\n                    rcon[i];\n                rek[keyOffset +  9] = rek[keyOffset +  1] ^ rek[keyOffset +  8];\n                rek[keyOffset + 10] = rek[keyOffset +  2] ^ rek[keyOffset +  9];\n                rek[keyOffset + 11] = rek[keyOffset +  3] ^ rek[keyOffset + 10];\n                if (++i == 7) {\n                    return;\n                }\n                temp = rek[keyOffset + 11];\n                rek[keyOffset + 12] = rek[keyOffset +  4] ^\n                    ((Se[(temp >>> 24)       ]       ) << 24) ^\n                    ((Se[(temp >>> 16) & 0xff] & 0xff) << 16) ^\n                    ((Se[(temp >>>  8) & 0xff] & 0xff) <<  8) ^\n                    ((Se[(temp       ) & 0xff] & 0xff));\n                rek[keyOffset + 13] = rek[keyOffset +  5] ^ rek[keyOffset + 12];\n                rek[keyOffset + 14] = rek[keyOffset +  6] ^ rek[keyOffset + 13];\n                rek[keyOffset + 15] = rek[keyOffset +  7] ^ rek[keyOffset + 14];\n                keyOffset += 8;\n            }\n        }\n    }\n    */\n\n    /**\n     * Compute the decryption schedule from the encryption schedule .\n     */\n    private void invertKey() {\n        int d = 0, e = 4 * Nr, w;\n        /*\n        * apply the inverse MixColumn transform to all round keys\n        * but the first and the last:\n        */\n        rdk[d] = rek[e];\n        rdk[d + 1] = rek[e + 1];\n        rdk[d + 2] = rek[e + 2];\n        rdk[d + 3] = rek[e + 3];\n        d += 4;\n        e -= 4;\n        for (int r = 1; r < Nr; r++) {\n            w = rek[e];\n            rdk[d] =\n                    Td0[Se[(w >>> 24)] & 0xff] ^\n                            Td1[Se[(w >>> 16) & 0xff] & 0xff] ^\n                            Td2[Se[(w >>> 8) & 0xff] & 0xff] ^\n                            Td3[Se[(w) & 0xff] & 0xff];\n            w = rek[e + 1];\n            rdk[d + 1] =\n                    Td0[Se[(w >>> 24)] & 0xff] ^\n                            Td1[Se[(w >>> 16) & 0xff] & 0xff] ^\n                            Td2[Se[(w >>> 8) & 0xff] & 0xff] ^\n                            Td3[Se[(w) & 0xff] & 0xff];\n            w = rek[e + 2];\n            rdk[d + 2] =\n                    Td0[Se[(w >>> 24)] & 0xff] ^\n                            Td1[Se[(w >>> 16) & 0xff] & 0xff] ^\n                            Td2[Se[(w >>> 8) & 0xff] & 0xff] ^\n                            Td3[Se[(w) & 0xff] & 0xff];\n            w = rek[e + 3];\n            rdk[d + 3] =\n                    Td0[Se[(w >>> 24)] & 0xff] ^\n                            Td1[Se[(w >>> 16) & 0xff] & 0xff] ^\n                            Td2[Se[(w >>> 8) & 0xff] & 0xff] ^\n                            Td3[Se[(w) & 0xff] & 0xff];\n            d += 4;\n            e -= 4;\n        }\n        rdk[d] = rek[e];\n        rdk[d + 1] = rek[e + 1];\n        rdk[d + 2] = rek[e + 2];\n        rdk[d + 3] = rek[e + 3];\n    }\n\n    /**\n     * Setup the AES key schedule for encryption, decryption, or both.\n     *\n     * @param cipherKey the cipher key (128, 192, or 256 bits).\n     * @param keyBits   size of the cipher key in bits.\n     * @param direction cipher direction (DIR_ENCRYPT, DIR_DECRYPT, or DIR_BOTH).\n     */\n    public void makeKey(byte[] cipherKey, int keyBits, int direction)\n            throws RuntimeException {\n        // check key size:\n        if (keyBits != 128 && keyBits != 192 && keyBits != 256) {\n            throw new RuntimeException(\"Invalid AES key size (\" + keyBits + \" bits)\");\n        }\n        Nk = keyBits >>> 5;\n        Nr = Nk + 6;\n        Nw = 4 * (Nr + 1);\n        rek = new int[Nw];\n        rdk = new int[Nw];\n        if ((direction & DIR_BOTH) != 0) {\n            expandKey(cipherKey);\n            /*\n            for (int r = 0; r <= Nr; r++) {\n            \tSystem.out.print(\"RK\" + r + \"=\");\n            \tfor (int i = 0; i < 4; i++) {\n            \t\tint w = rek[4*r + i];\n            \t\tSystem.out.print(\" \" + Integer.toHexString(w));\n            \t}\n            \tSystem.out.println();\n            }\n            */\n            if ((direction & DIR_DECRYPT) != 0) {\n                invertKey();\n            }\n        }\n    }\n\n    /**\n     * Setup the AES key schedule (any cipher direction).\n     *\n     * @param cipherKey the cipher key (128, 192, or 256 bits).\n     * @param keyBits   size of the cipher key in bits.\n     */\n    public void makeKey(byte[] cipherKey, int keyBits)\n            throws RuntimeException {\n        makeKey(cipherKey, keyBits, DIR_BOTH);\n    }\n\n    /**\n     * Encrypt exactly one block (BLOCK_SIZE bytes) of plaintext.\n     *\n     * @param pt plaintext block.\n     * @param ct ciphertext block.\n     */\n    public void encrypt(byte[] pt, byte[] ct) {\n        /*\n         * map byte array block to cipher state\n\t     * and add initial round key:\n\t     */\n        int k = 0, v;\n        int t0 = ((pt[0]) << 24 |\n                (pt[1] & 0xff) << 16 |\n                (pt[2] & 0xff) << 8 |\n                (pt[3] & 0xff)) ^ rek[0];\n        int t1 = ((pt[4]) << 24 |\n                (pt[5] & 0xff) << 16 |\n                (pt[6] & 0xff) << 8 |\n                (pt[7] & 0xff)) ^ rek[1];\n        int t2 = ((pt[8]) << 24 |\n                (pt[9] & 0xff) << 16 |\n                (pt[10] & 0xff) << 8 |\n                (pt[11] & 0xff)) ^ rek[2];\n        int t3 = ((pt[12]) << 24 |\n                (pt[13] & 0xff) << 16 |\n                (pt[14] & 0xff) << 8 |\n                (pt[15] & 0xff)) ^ rek[3];\n        /*\n         * Nr - 1 full rounds:\n\t     */\n        for (int r = 1; r < Nr; r++) {\n            k += 4;\n            int a0 =\n                    Te0[(t0 >>> 24)] ^\n                            Te1[(t1 >>> 16) & 0xff] ^\n                            Te2[(t2 >>> 8) & 0xff] ^\n                            Te3[(t3) & 0xff] ^\n                            rek[k];\n            int a1 =\n                    Te0[(t1 >>> 24)] ^\n                            Te1[(t2 >>> 16) & 0xff] ^\n                            Te2[(t3 >>> 8) & 0xff] ^\n                            Te3[(t0) & 0xff] ^\n                            rek[k + 1];\n            int a2 =\n                    Te0[(t2 >>> 24)] ^\n                            Te1[(t3 >>> 16) & 0xff] ^\n                            Te2[(t0 >>> 8) & 0xff] ^\n                            Te3[(t1) & 0xff] ^\n                            rek[k + 2];\n            int a3 =\n                    Te0[(t3 >>> 24)] ^\n                            Te1[(t0 >>> 16) & 0xff] ^\n                            Te2[(t1 >>> 8) & 0xff] ^\n                            Te3[(t2) & 0xff] ^\n                            rek[k + 3];\n            t0 = a0;\n            t1 = a1;\n            t2 = a2;\n            t3 = a3;\n        }\n        /*\n         * last round lacks MixColumn:\n         */\n        k += 4;\n\n        v = rek[k];\n        ct[0] = (byte) (Se[(t0 >>> 24)] ^ (v >>> 24));\n        ct[1] = (byte) (Se[(t1 >>> 16) & 0xff] ^ (v >>> 16));\n        ct[2] = (byte) (Se[(t2 >>> 8) & 0xff] ^ (v >>> 8));\n        ct[3] = (byte) (Se[(t3) & 0xff] ^ (v));\n\n        v = rek[k + 1];\n        ct[4] = (byte) (Se[(t1 >>> 24)] ^ (v >>> 24));\n        ct[5] = (byte) (Se[(t2 >>> 16) & 0xff] ^ (v >>> 16));\n        ct[6] = (byte) (Se[(t3 >>> 8) & 0xff] ^ (v >>> 8));\n        ct[7] = (byte) (Se[(t0) & 0xff] ^ (v));\n\n        v = rek[k + 2];\n        ct[8] = (byte) (Se[(t2 >>> 24)] ^ (v >>> 24));\n        ct[9] = (byte) (Se[(t3 >>> 16) & 0xff] ^ (v >>> 16));\n        ct[10] = (byte) (Se[(t0 >>> 8) & 0xff] ^ (v >>> 8));\n        ct[11] = (byte) (Se[(t1) & 0xff] ^ (v));\n\n        v = rek[k + 3];\n        ct[12] = (byte) (Se[(t3 >>> 24)] ^ (v >>> 24));\n        ct[13] = (byte) (Se[(t0 >>> 16) & 0xff] ^ (v >>> 16));\n        ct[14] = (byte) (Se[(t1 >>> 8) & 0xff] ^ (v >>> 8));\n        ct[15] = (byte) (Se[(t2) & 0xff] ^ (v));\n    }\n\n    /**\n     * Decrypt exactly one block (BLOCK_SIZE bytes) of ciphertext.\n     *\n     * @param ct ciphertext block.\n     * @param pt plaintext block.\n     */\n    public void decrypt(byte[] ct, byte[] pt) {\n        /*\n         * map byte array block to cipher state\n\t     * and add initial round key:\n\t     */\n        int k = 0, v;\n        int t0 = ((ct[0]) << 24 |\n                (ct[1] & 0xff) << 16 |\n                (ct[2] & 0xff) << 8 |\n                (ct[3] & 0xff)) ^ rdk[0];\n        int t1 = ((ct[4]) << 24 |\n                (ct[5] & 0xff) << 16 |\n                (ct[6] & 0xff) << 8 |\n                (ct[7] & 0xff)) ^ rdk[1];\n        int t2 = ((ct[8]) << 24 |\n                (ct[9] & 0xff) << 16 |\n                (ct[10] & 0xff) << 8 |\n                (ct[11] & 0xff)) ^ rdk[2];\n        int t3 = ((ct[12]) << 24 |\n                (ct[13] & 0xff) << 16 |\n                (ct[14] & 0xff) << 8 |\n                (ct[15] & 0xff)) ^ rdk[3];\n        /*\n         * Nr - 1 full rounds:\n\t     */\n        for (int r = 1; r < Nr; r++) {\n            k += 4;\n            int a0 =\n                    Td0[(t0 >>> 24)] ^\n                            Td1[(t3 >>> 16) & 0xff] ^\n                            Td2[(t2 >>> 8) & 0xff] ^\n                            Td3[(t1) & 0xff] ^\n                            rdk[k];\n            int a1 =\n                    Td0[(t1 >>> 24)] ^\n                            Td1[(t0 >>> 16) & 0xff] ^\n                            Td2[(t3 >>> 8) & 0xff] ^\n                            Td3[(t2) & 0xff] ^\n                            rdk[k + 1];\n            int a2 =\n                    Td0[(t2 >>> 24)] ^\n                            Td1[(t1 >>> 16) & 0xff] ^\n                            Td2[(t0 >>> 8) & 0xff] ^\n                            Td3[(t3) & 0xff] ^\n                            rdk[k + 2];\n            int a3 =\n                    Td0[(t3 >>> 24)] ^\n                            Td1[(t2 >>> 16) & 0xff] ^\n                            Td2[(t1 >>> 8) & 0xff] ^\n                            Td3[(t0) & 0xff] ^\n                            rdk[k + 3];\n            t0 = a0;\n            t1 = a1;\n            t2 = a2;\n            t3 = a3;\n        }\n        /*\n         * last round lacks MixColumn:\n         */\n        k += 4;\n\n        v = rdk[k];\n        pt[0] = (byte) (Sd[(t0 >>> 24)] ^ (v >>> 24));\n        pt[1] = (byte) (Sd[(t3 >>> 16) & 0xff] ^ (v >>> 16));\n        pt[2] = (byte) (Sd[(t2 >>> 8) & 0xff] ^ (v >>> 8));\n        pt[3] = (byte) (Sd[(t1) & 0xff] ^ (v));\n\n        v = rdk[k + 1];\n        pt[4] = (byte) (Sd[(t1 >>> 24)] ^ (v >>> 24));\n        pt[5] = (byte) (Sd[(t0 >>> 16) & 0xff] ^ (v >>> 16));\n        pt[6] = (byte) (Sd[(t3 >>> 8) & 0xff] ^ (v >>> 8));\n        pt[7] = (byte) (Sd[(t2) & 0xff] ^ (v));\n\n        v = rdk[k + 2];\n        pt[8] = (byte) (Sd[(t2 >>> 24)] ^ (v >>> 24));\n        pt[9] = (byte) (Sd[(t1 >>> 16) & 0xff] ^ (v >>> 16));\n        pt[10] = (byte) (Sd[(t0 >>> 8) & 0xff] ^ (v >>> 8));\n        pt[11] = (byte) (Sd[(t3) & 0xff] ^ (v));\n\n        v = rdk[k + 3];\n        pt[12] = (byte) (Sd[(t3 >>> 24)] ^ (v >>> 24));\n        pt[13] = (byte) (Sd[(t2 >>> 16) & 0xff] ^ (v >>> 16));\n        pt[14] = (byte) (Sd[(t1 >>> 8) & 0xff] ^ (v >>> 8));\n        pt[15] = (byte) (Sd[(t0) & 0xff] ^ (v));\n    }\n\n    /**\n     * Destroy all sensitive information in this object.\n     */\n    protected final void finalize() {\n        if (rek != null) {\n            for (int i = 0; i < rek.length; i++) {\n                rek[i] = 0;\n            }\n            rek = null;\n        }\n        if (rdk != null) {\n            for (int i = 0; i < rdk.length; i++) {\n                rdk[i] = 0;\n            }\n            rdk = null;\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/ByteUtils.java",
    "content": "package com.quincysx.crypto.bip39;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午10:34\n */\nfinal class ByteUtils {\n    static int next11Bits(byte[] bytes, int offset) {\n        final int skip = offset / 8;\n        final int lowerBitsToRemove = (3 * 8 - 11) - (offset % 8);\n        return (((int) bytes[skip] & 0xff) << 16 |\n                ((int) bytes[skip + 1] & 0xff) << 8 |\n                (lowerBitsToRemove < 8\n                        ? ((int) bytes[skip + 2] & 0xff)\n                        : 0)) >> lowerBitsToRemove & (1 << 11) - 1;\n    }\n\n    static void writeNext11(byte[] bytes, int value, int offset) {\n        int skip = offset / 8;\n        int bitSkip = offset % 8;\n        {//byte 0\n            byte firstValue = bytes[skip];\n            byte toWrite = (byte) (value >> (3 + bitSkip));\n            bytes[skip] = (byte) (firstValue | toWrite);\n        }\n\n        {//byte 1\n            byte valueInByte = bytes[skip + 1];\n            final int i = 5 - bitSkip;\n            byte toWrite = (byte) (i > 0 ? (value << i) : (value >> -i));\n            bytes[skip + 1] = (byte) (valueInByte | toWrite);\n        }\n\n        if (bitSkip >= 6) {//byte 2\n            byte valueInByte = bytes[skip + 2];\n            byte toWrite = (byte) (value << 13 - bitSkip);\n            bytes[skip + 2] = (byte) (valueInByte | toWrite);\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/CharSequenceComparators.java",
    "content": "package com.quincysx.crypto.bip39;\n\nimport java.util.Comparator;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午11:25\n */\nenum CharSequenceComparators implements Comparator<CharSequence> {\n\n    ALPHABETICAL {\n        @Override\n        public int compare(final CharSequence o1, final CharSequence o2) {\n            final int length1 = o1.length();\n            final int length2 = o2.length();\n            final int length = Math.min(length1, length2);\n            for (int i = 0; i < length; i++) {\n                final int compare = Character.compare(o1.charAt(i), o2.charAt(i));\n                if (compare != 0) return compare;\n            }\n            return Integer.compare(length1, length2);\n        }\n    }\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/CharSequenceSplitter.java",
    "content": "package com.quincysx.crypto.bip39;\n\nimport java.util.LinkedList;\nimport java.util.List;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午11:15\n */\nfinal class CharSequenceSplitter {\n    private final char separator1;\n    private final char separator2;\n\n    CharSequenceSplitter(final char separator1, final char separator2) {\n        this.separator1 = separator1;\n        this.separator2 = separator2;\n    }\n\n    List<CharSequence> split(final CharSequence charSequence) {\n        final LinkedList<CharSequence> list = new LinkedList<>();\n        int start = 0;\n        final int length = charSequence.length();\n        for (int i = 0; i < length; i++) {\n            final char c = charSequence.charAt(i);\n            if (c == separator1 || c == separator2) {\n                list.add(charSequence.subSequence(start, i));\n                start = i + 1;\n            }\n        }\n        list.add(charSequence.subSequence(start, length));\n        return list;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/MnemonicGenerator.java",
    "content": "package com.quincysx.crypto.bip39;\n\nimport com.quincysx.crypto.utils.SHA256;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午10:21\n */\npublic final class MnemonicGenerator {\n    private final WordList wordList;\n\n    /**\n     * Create a generator using the given word list.\n     *\n     * @param wordList A known ordered list of 2048 words to select from.\n     */\n    public MnemonicGenerator(final WordList wordList) {\n        this.wordList = wordList;\n    }\n\n    public List<String> createMnemonic(\n            final CharSequence entropyHex) {\n        final int length = entropyHex.length();\n        if (length % 2 == 1)\n            throw new RuntimeException(\"Length of hex chars must be divisible by 2\");\n        final byte[] entropy = new byte[length / 2];\n        try {\n            for (int i = 0, j = 0; i < length; i += 2, j++) {\n                entropy[j] = (byte) (parseHex(entropyHex.charAt(i)) << 4 | parseHex(entropyHex.charAt(i + 1)));\n            }\n            return createMnemonic(entropy);\n        } finally {\n            Arrays.fill(entropy, (byte) 0);\n        }\n    }\n\n    public List<String> createMnemonic(\n            final byte[] entropy) {\n        final int[] wordIndexes = wordIndexes(entropy);\n        try {\n            return createMnemonic(wordIndexes);\n        } finally {\n            Arrays.fill(wordIndexes, 0);\n        }\n    }\n\n    private List<String> createMnemonic(\n            final int[] wordIndexes) {\n        List<String> mnemonicList = new ArrayList<>();\n        final String space = String.valueOf(wordList.getSpace());\n        for (int i = 0; i < wordIndexes.length; i++) {\n            mnemonicList.add(wordList.getWord(wordIndexes[i]));\n        }\n        return mnemonicList;\n    }\n\n    private static int[] wordIndexes(byte[] entropy) {\n        final int ent = entropy.length * 8;\n        entropyLengthPreChecks(ent);\n\n        final byte[] entropyWithChecksum = Arrays.copyOf(entropy, entropy.length + 1);\n        entropyWithChecksum[entropy.length] = firstByteOfSha256(entropy);\n\n        //checksum length\n        final int cs = ent / 32;\n        //mnemonic length\n        final int ms = (ent + cs) / 11;\n\n        //get the indexes into the word list\n        final int[] wordIndexes = new int[ms];\n        for (int i = 0, wi = 0; wi < ms; i += 11, wi++) {\n            wordIndexes[wi] = ByteUtils.next11Bits(entropyWithChecksum, i);\n        }\n        return wordIndexes;\n    }\n\n    static byte firstByteOfSha256(final byte[] entropy) {\n        final byte[] hash = SHA256.sha256(entropy);\n        final byte firstByte = hash[0];\n        Arrays.fill(hash, (byte) 0);\n        return firstByte;\n    }\n\n    private static void entropyLengthPreChecks(final int ent) {\n        if (ent < 128)\n            throw new RuntimeException(\"Entropy too low, 128-256 bits allowed\");\n        if (ent > 256)\n            throw new RuntimeException(\"Entropy too high, 128-256 bits allowed\");\n        if (ent % 32 > 0)\n            throw new RuntimeException(\"Number of entropy bits must be divisible by 32\");\n    }\n\n    private static int parseHex(char c) {\n        if (c >= '0' && c <= '9') return c - '0';\n        if (c >= 'a' && c <= 'f') return (c - 'a') + 10;\n        if (c >= 'A' && c <= 'F') return (c - 'A') + 10;\n        throw new RuntimeException(\"Invalid hex char '\" + c + '\\'');\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/MnemonicValidator.java",
    "content": "package com.quincysx.crypto.bip39;\n\nimport com.quincysx.crypto.bip39.validation.InvalidChecksumException;\nimport com.quincysx.crypto.bip39.validation.InvalidWordCountException;\nimport com.quincysx.crypto.bip39.validation.UnexpectedWhiteSpaceException;\nimport com.quincysx.crypto.bip39.validation.WordNotFoundException;\n\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Comparator;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午11:14\n */\npublic final class MnemonicValidator {\n    private final WordAndIndex[] words;\n    private final CharSequenceSplitter charSequenceSplitter;\n    private final NFKDNormalizer normalizer;\n\n    private MnemonicValidator(final WordList wordList) {\n        normalizer = new WordListMapNormalization(wordList);\n        words = new WordAndIndex[1 << 11];\n        for (int i = 0; i < 1 << 11; i++) {\n            words[i] = new WordAndIndex(i, wordList.getWord(i));\n        }\n        charSequenceSplitter = new CharSequenceSplitter(wordList.getSpace(), Normalization.normalizeNFKD(wordList.getSpace()));\n        Arrays.sort(words, wordListSortOrder);\n    }\n\n    /**\n     * Get a Mnemonic validator for the given word list.\n     * No normalization is currently performed, this is an open issue: https://github.com/NovaCrypto/BIP39/issues/13\n     *\n     * @param wordList A WordList implementation\n     * @return A validator\n     */\n    public static MnemonicValidator ofWordList(final WordList wordList) {\n        return new MnemonicValidator(wordList);\n    }\n\n    /**\n     * Check that the supplied mnemonic fits the BIP0039 spec.\n     *\n     * @param mnemonic The memorable list of words\n     * @throws InvalidChecksumException      If the last bytes don't match the expected last bytes\n     * @throws InvalidWordCountException     If the number of words is not a multiple of 3, 24 or fewer\n     * @throws WordNotFoundException         If a word in the mnemonic is not present in the word list\n     * @throws UnexpectedWhiteSpaceException Occurs if one of the supplied words is empty, e.g. a double space\n     */\n    public void validate(final CharSequence mnemonic) throws\n            InvalidChecksumException,\n            InvalidWordCountException,\n            WordNotFoundException,\n            UnexpectedWhiteSpaceException {\n        validate(charSequenceSplitter.split(mnemonic));\n    }\n\n    /**\n     * Check that the supplied mnemonic fits the BIP0039 spec.\n     * <p>\n     * The purpose of this method overload is to avoid constructing a mnemonic String if you have gathered a list of\n     * words from the user.\n     *\n     * @param mnemonic The memorable list of words\n     * @throws InvalidChecksumException      If the last bytes don't match the expected last bytes\n     * @throws InvalidWordCountException     If the number of words is not a multiple of 3, 24 or fewer\n     * @throws WordNotFoundException         If a word in the mnemonic is not present in the word list\n     * @throws UnexpectedWhiteSpaceException Occurs if one of the supplied words is empty\n     */\n    public void validate(final Collection<? extends CharSequence> mnemonic) throws\n            InvalidChecksumException,\n            InvalidWordCountException,\n            WordNotFoundException,\n            UnexpectedWhiteSpaceException {\n        final int[] wordIndexes = findWordIndexes(mnemonic);\n        try {\n            validate(wordIndexes);\n        } finally {\n            Arrays.fill(wordIndexes, 0);\n        }\n    }\n\n    private static void validate(final int[] wordIndexes) throws\n            InvalidWordCountException,\n            InvalidChecksumException {\n        final int ms = wordIndexes.length;\n\n        final int entPlusCs = ms * 11;\n        final int ent = (entPlusCs * 32) / 33;\n        final int cs = ent / 32;\n        if (entPlusCs != ent + cs)\n            throw new InvalidWordCountException();\n//        final byte[] entropyWithChecksum = new byte[(entPlusCs + 7) / 8];\n//\n//        wordIndexesToEntropyWithCheckSum(wordIndexes, entropyWithChecksum);\n//        Arrays.fill(wordIndexes, 0);\n//\n//        final byte[] entropy = Arrays.copyOf(entropyWithChecksum, entropyWithChecksum.length - 1);\n//        final byte lastByte = entropyWithChecksum[entropyWithChecksum.length - 1];\n//        Arrays.fill(entropyWithChecksum, (byte) 0);\n\n//        final byte sha = MnemonicGenerator.firstByteOfSha256(entropy);\n//\n//        final byte mask = maskOfFirstNBits(cs);\n//\n//        if (((sha ^ lastByte) & mask) != 0)\n//            throw new InvalidChecksumException();\n    }\n\n    private int[] findWordIndexes(final Collection<? extends CharSequence> split) throws\n            UnexpectedWhiteSpaceException,\n            WordNotFoundException {\n        final int ms = split.size();\n        final int[] result = new int[ms];\n        int i = 0;\n        for (final CharSequence buffer : split) {\n            if (buffer.length() == 0) {\n                throw new UnexpectedWhiteSpaceException();\n            }\n            result[i++] = findWordIndex(buffer);\n        }\n        return result;\n    }\n\n    private int findWordIndex(final CharSequence buffer) throws WordNotFoundException {\n        final WordAndIndex key = new WordAndIndex(-1, buffer);\n        final int index = Arrays.binarySearch(words, key, wordListSortOrder);\n        if (index < 0) {\n            final int insertionPoint = -index - 1;\n            int suggestion = insertionPoint == 0 ? insertionPoint : insertionPoint - 1;\n            if (suggestion + 1 == words.length) suggestion--;\n            throw new WordNotFoundException(buffer, words[suggestion].word, words[suggestion + 1].word);\n\n        }\n        return words[index].index;\n    }\n\n    private static void wordIndexesToEntropyWithCheckSum(final int[] wordIndexes, final byte[] entropyWithChecksum) {\n        for (int i = 0, bi = 0; i < wordIndexes.length; i++, bi += 11) {\n            ByteUtils.writeNext11(entropyWithChecksum, wordIndexes[i], bi);\n        }\n    }\n\n    private static byte maskOfFirstNBits(final int n) {\n        return (byte) ~((1 << (8 - n)) - 1);\n    }\n\n    private static final Comparator<WordAndIndex> wordListSortOrder = new Comparator<WordAndIndex>() {\n        @Override\n        public int compare(final WordAndIndex o1, final WordAndIndex o2) {\n            return CharSequenceComparators.ALPHABETICAL.compare(o1.normalized, o2.normalized);\n        }\n    };\n\n    private class WordAndIndex {\n        final CharSequence word;\n        final String normalized;\n        final int index;\n\n        WordAndIndex(final int i, final CharSequence word) {\n            this.word = word;\n            normalized = normalizer.normalize(word);\n            index = i;\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/NFKDNormalizer.java",
    "content": "package com.quincysx.crypto.bip39;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午10:41\n */\npublic interface NFKDNormalizer {\n    String normalize(CharSequence charSequence);\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/Normalization.java",
    "content": "package com.quincysx.crypto.bip39;\n\nimport java.text.Normalizer;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午10:40\n */\nfinal class Normalization {\n    static String normalizeNFKD(final String string) {\n        return Normalizer.normalize(string, Normalizer.Form.NFKD);\n    }\n\n    static char normalizeNFKD(final char c) {\n        return normalizeNFKD(\"\" + c).charAt(0);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/PBKDF2WithHmacSHA512.java",
    "content": "package com.quincysx.crypto.bip39;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午10:18\n */\npublic interface PBKDF2WithHmacSHA512 {\n    byte[] hash(final char[] chars, final byte[] salt);\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/RandomSeed.java",
    "content": "package com.quincysx.crypto.bip39;\n\nimport java.security.SecureRandom;\nimport java.util.Random;\n\n/**\n * @author QuincySx\n * @date 2018/3/13 上午11:06\n */\npublic class RandomSeed {\n    public static byte[] random(WordCount words) {\n        return random(words, new SecureRandom());\n    }\n\n    public static byte[] random(WordCount words, Random random) {\n        byte[] randomSeed = new byte[words.byteLength()];\n        random.nextBytes(randomSeed);\n        return randomSeed;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/SeedCalculator.java",
    "content": "package com.quincysx.crypto.bip39;\n\nimport android.util.Log;\n\nimport com.quincysx.crypto.utils.HexUtils;\n\nimport java.io.UnsupportedEncodingException;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport static com.quincysx.crypto.bip39.Normalization.normalizeNFKD;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午10:38\n */\npublic final class SeedCalculator {\n    private final byte[] fixedSalt = getUtf8Bytes(\"mnemonic\");\n    private final PBKDF2WithHmacSHA512 hashAlgorithm;\n\n    public SeedCalculator(final PBKDF2WithHmacSHA512 hashAlgorithm) {\n        this.hashAlgorithm = hashAlgorithm;\n    }\n\n    /**\n     * Creates a seed calculator using {@link SpongyCastlePBKDF2WithHmacSHA512} which is the most compatible.\n     * Use {@link SeedCalculator#SeedCalculator(PBKDF2WithHmacSHA512)} to supply another.\n     */\n    public SeedCalculator() {\n        this(SpongyCastlePBKDF2WithHmacSHA512.INSTANCE);\n    }\n\n    public byte[] calculateSeed(final List<String> mnemonicList, final String passphrase) {\n        if (mnemonicList == null || mnemonicList.size() < 3) {\n            throw new RuntimeException(\"The dictionary cannot be empty and the number of words must not be less than 3\");\n        }\n        StringBuilder stringBuilder = new StringBuilder();\n        for (String str : mnemonicList) {\n            stringBuilder.append(str).append(\" \");\n        }\n        String mnemonic = stringBuilder.substring(0, stringBuilder.length() - 1).toString();\n        return calculateSeed(mnemonic, passphrase);\n    }\n\n    /**\n     * Calculate the seed given a mnemonic and corresponding passphrase.\n     * The phrase is not checked for validity here, for that use a {@link MnemonicValidator}.\n     * <p>\n     * Due to normalization, these need to be {@link String}, and not {@link CharSequence}, this is an open issue:\n     * https://github.com/NovaCrypto/BIP39/issues/7\n     * <p>\n     * If you have a list of words selected from a word list, you can use {@link #withWordsFromWordList} then\n     * {@link SeedCalculatorByWordListLookUp#calculateSeed}\n     *\n     * @param mnemonic   The memorable list of words\n     * @param passphrase An optional passphrase, use \"\" if not required\n     * @return a seed for HD wallet generation\n     */\n    public byte[] calculateSeed(final String mnemonic, final String passphrase) {\n        final char[] chars = normalizeNFKD(mnemonic).toCharArray();\n        try {\n            return calculateSeed(chars, passphrase);\n        } finally {\n            Arrays.fill(chars, '\\0');\n        }\n    }\n\n    byte[] calculateSeed(final char[] mnemonicChars, final String passphrase) {\n        final String normalizedPassphrase = normalizeNFKD(passphrase);\n        final byte[] salt2 = getUtf8Bytes(normalizedPassphrase);\n        final byte[] salt = combine(fixedSalt, salt2);\n        clear(salt2);\n        final byte[] encoded = hash(mnemonicChars, salt);\n        clear(salt);\n        return encoded;\n    }\n\n    public SeedCalculatorByWordListLookUp withWordsFromWordList(final WordList wordList) {\n        return new SeedCalculatorByWordListLookUp(this, wordList);\n    }\n\n    private static byte[] combine(final byte[] array1, final byte[] array2) {\n        final byte[] bytes = new byte[array1.length + array2.length];\n        System.arraycopy(array1, 0, bytes, 0, array1.length);\n        System.arraycopy(array2, 0, bytes, array1.length, bytes.length - array1.length);\n        return bytes;\n    }\n\n    private static void clear(final byte[] salt) {\n        Arrays.fill(salt, (byte) 0);\n    }\n\n    private byte[] hash(final char[] chars, final byte[] salt) {\n        return hashAlgorithm.hash(chars, salt);\n    }\n\n    private static byte[] getUtf8Bytes(final String string) {\n        try {\n            return string.getBytes(\"UTF-8\");\n        } catch (UnsupportedEncodingException e) {\n            e.printStackTrace();\n        }\n        return null;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/SeedCalculatorByWordListLookUp.java",
    "content": "package com.quincysx.crypto.bip39;\n\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.HashMap;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Map;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午10:39\n */\npublic final class SeedCalculatorByWordListLookUp {\n    private final SeedCalculator seedCalculator;\n    private final Map<CharSequence, char[]> map = new HashMap<>();\n    private final NFKDNormalizer normalizer;\n\n    SeedCalculatorByWordListLookUp(final SeedCalculator seedCalculator, final WordList wordList) {\n        this.seedCalculator = seedCalculator;\n        normalizer = new WordListMapNormalization(wordList);\n        for (int i = 0; i < 1 << 11; i++) {\n            final String word = normalizer.normalize(wordList.getWord(i));\n            map.put(word, word.toCharArray());\n        }\n    }\n\n    /**\n     * Calculate the seed given a mnemonic and corresponding passphrase.\n     * The phrase is not checked for validity here, for that use a {@link MnemonicValidator}.\n     * <p>\n     * The purpose of this method is to avoid constructing a mnemonic String if you have gathered a list of\n     * words from the user and also to avoid having to normalize it, all words in the {@link WordList} are normalized\n     * instead.\n     * <p>\n     * Due to normalization, the passphrase still needs to be {@link String}, and not {@link CharSequence}, this is an\n     * open issue: https://github.com/NovaCrypto/BIP39/issues/7\n     *\n     * @param mnemonic   The memorable list of words, ideally selected from the word list that was supplied while creating this object.\n     * @param passphrase An optional passphrase, use \"\" if not required\n     * @return a seed for HD wallet generation\n     */\n    public byte[] calculateSeed(final Collection<? extends CharSequence> mnemonic, final String passphrase) {\n        final int words = mnemonic.size();\n        final char[][] chars = new char[words][];\n        final List<char[]> toClear = new LinkedList<>();\n        int count = 0;\n        int wordIndex = 0;\n        for (final CharSequence word : mnemonic) {\n            char[] wordChars = map.get(normalizer.normalize(word));\n            if (wordChars == null) {\n                wordChars = normalizer.normalize(word).toCharArray();\n                toClear.add(wordChars);\n            }\n            chars[wordIndex++] = wordChars;\n            count += wordChars.length;\n        }\n        count += words - 1;\n        final char[] mnemonicChars = new char[count];\n        try {\n            int index = 0;\n            for (int i = 0; i < chars.length; i++) {\n                System.arraycopy(chars[i], 0, mnemonicChars, index, chars[i].length);\n                index += chars[i].length;\n                if (i < chars.length - 1) {\n                    mnemonicChars[index++] = ' ';\n                }\n            }\n            return seedCalculator.calculateSeed(mnemonicChars, passphrase);\n        } finally {\n            Arrays.fill(mnemonicChars, '\\0');\n            Arrays.fill(chars, null);\n            for (final char[] charsToClear : toClear)\n                Arrays.fill(charsToClear, '\\0');\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/SpongyCastlePBKDF2WithHmacSHA512.java",
    "content": "package com.quincysx.crypto.bip39;\n\nimport org.spongycastle.crypto.PBEParametersGenerator;\nimport org.spongycastle.crypto.digests.SHA512Digest;\nimport org.spongycastle.crypto.generators.PKCS5S2ParametersGenerator;\nimport org.spongycastle.crypto.params.KeyParameter;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午10:20\n */\npublic enum SpongyCastlePBKDF2WithHmacSHA512 implements PBKDF2WithHmacSHA512 {\n    INSTANCE;\n\n    @Override\n    public byte[] hash(char[] chars, byte[] salt) {\n        PKCS5S2ParametersGenerator generator = new PKCS5S2ParametersGenerator(new SHA512Digest());\n        generator.init(PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(chars), salt, 2048);\n        KeyParameter key = (KeyParameter) generator.generateDerivedMacParameters(512);\n        return key.getKey();\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/WordCount.java",
    "content": "package com.quincysx.crypto.bip39;\n\n/**\n * @author QuincySx\n * @date 2018/3/2 下午4:27\n * 词语个数的枚举\n */\npublic enum WordCount {\n    /**\n     * 3个助记词\n     */\n//    THREE(27),\n    /**\n     * 6个助记词\n     */\n//    SIX(54),\n    /**\n     * 9个助记词\n     */\n//    NINE(72),\n    /**\n     * 12个助记词\n     */\n    TWELVE(128),\n    /**\n     * 15个助记词\n     */\n    FIFTEEN(160),\n    /**\n     * 18个助记词\n     */\n    EIGHTEEN(192),\n    /**\n     * 21个助记词\n     */\n    TWENTY_ONE(224),\n    /**\n     * 24个助记词\n     */\n    TWENTY_FOUR(256);\n\n    private final int bitLength;\n\n    WordCount(int bitLength) {\n        this.bitLength = bitLength;\n    }\n\n    public int bitLength() {\n        return bitLength;\n    }\n\n    public int byteLength() {\n        return bitLength / 8;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/WordList.java",
    "content": "/*\n *  BIP39 library, a Java implementation of BIP39\n *  Copyright (C) 2017 Alan Evans, NovaCrypto\n *\n *  This program is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <https://www.gnu.org/licenses/>.\n *\n *  Original source: https://github.com/NovaCrypto/BIP39\n *  You can contact the authors via github issues.\n */\n\npackage com.quincysx.crypto.bip39;\n\npublic interface WordList {\n\n    /**\n     * Get a word in the word list.\n     *\n     * @param index Index of word in the word list [0..2047] inclusive.\n     * @return the word from the list.\n     */\n    String getWord(final int index);\n\n    int getIndex(final String word);\n\n    /**\n     * Get the space character for this language.\n     *\n     * @return a whitespace character.\n     */\n    char getSpace();\n}"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/WordListMapNormalization.java",
    "content": "package com.quincysx.crypto.bip39;\n\nimport java.text.Normalizer;\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午10:41\n */\npublic class WordListMapNormalization implements NFKDNormalizer {\n    private final Map<CharSequence, String> normalizedMap = new HashMap<>();\n\n    WordListMapNormalization(final WordList wordList) {\n        for (int i = 0; i < 1 << 11; i++) {\n            final String word = wordList.getWord(i);\n            final String normalized = Normalizer.normalize(word, Normalizer.Form.NFKD);\n            normalizedMap.put(word, normalized);\n            normalizedMap.put(normalized, normalized);\n            normalizedMap.put(Normalizer.normalize(word, Normalizer.Form.NFC), normalized);\n        }\n    }\n\n    @Override\n    public String normalize(final CharSequence charSequence) {\n        final String normalized = normalizedMap.get(charSequence);\n        if (normalized != null)\n            return normalized;\n        return Normalizer.normalize(charSequence, Normalizer.Form.NFKD);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/exception/MnemonicException.java",
    "content": "/*\n *\n *  * Copyright 2014 http://Bither.net\n *  *\n *  * Licensed under the Apache License, Version 2.0 (the \"License\");\n *  * you may not use this file except in compliance with the License.\n *  * You may obtain a copy of the License at\n *  *\n *  *    http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  * Unless required by applicable law or agreed to in writing, software\n *  * distributed under the License is distributed on an \"AS IS\" BASIS,\n *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  * See the License for the specific language governing permissions and\n *  * limitations under the License.\n *\n */\n\npackage com.quincysx.crypto.bip39.exception;\n\n/**\n * Exceptions thrown by the MnemonicCode module.\n */\n@SuppressWarnings(\"serial\")\npublic class MnemonicException extends Exception {\n    public MnemonicException() {\n        super();\n    }\n\n    public MnemonicException(String msg) {\n        super(msg);\n    }\n\n    /**\n     * Thrown when an argument to MnemonicCode is the wrong length.\n     */\n    public static class MnemonicLengthException extends MnemonicException {\n        public MnemonicLengthException(String msg) {\n            super(msg);\n        }\n    }\n\n    /**\n     * Thrown when a list of MnemonicCode words fails the checksum check.\n     */\n    public static class MnemonicChecksumException extends MnemonicException {\n        public MnemonicChecksumException() {\n            super();\n        }\n    }\n\n    /**\n     * Thrown when a word is encountered which is not in the MnemonicCode's word list.\n     */\n    public static class MnemonicWordException extends MnemonicException {\n        /**\n         * Contains the word that was not found in the word list.\n         */\n        public final String badWord;\n\n        public MnemonicWordException(String badWord) {\n            super();\n            this.badWord = badWord;\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/validation/InvalidChecksumException.java",
    "content": "package com.quincysx.crypto.bip39.validation;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午11:19\n */\npublic class InvalidChecksumException extends Exception {\n    public InvalidChecksumException() {\n        super(\"Invalid checksum\");\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/validation/InvalidWordCountException.java",
    "content": "package com.quincysx.crypto.bip39.validation;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午11:20\n */\npublic class InvalidWordCountException extends Exception {\n    public InvalidWordCountException() {\n        super(\"Not a correct number of words\");\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/validation/UnexpectedWhiteSpaceException.java",
    "content": "package com.quincysx.crypto.bip39.validation;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午11:20\n */\npublic class UnexpectedWhiteSpaceException extends Exception {\n    public UnexpectedWhiteSpaceException() {\n        super(\"Unexpected whitespace\");\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/validation/WordNotFoundException.java",
    "content": "package com.quincysx.crypto.bip39.validation;\n\n/**\n * @author QuincySx\n * @date 2018/5/15 上午11:20\n */\npublic class WordNotFoundException extends Exception {\n    private final CharSequence word;\n    private final CharSequence suggestion1;\n    private final CharSequence suggestion2;\n\n    public WordNotFoundException(\n            final CharSequence word,\n            final CharSequence suggestion1,\n            final CharSequence suggestion2) {\n        super(String.format(\n                \"Word not found in word list \\\"%s\\\", suggestions \\\"%s\\\", \\\"%s\\\"\",\n                word,\n                suggestion1,\n                suggestion2));\n        this.word = word;\n        this.suggestion1 = suggestion1;\n        this.suggestion2 = suggestion2;\n    }\n\n    public CharSequence getWord() {\n        return word;\n    }\n\n    public CharSequence getSuggestion1() {\n        return suggestion1;\n    }\n\n    public CharSequence getSuggestion2() {\n        return suggestion2;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/wordlists/English.java",
    "content": "/*\n *  BIP39 library, a Java implementation of BIP39\n *  Copyright (C) 2017 Alan Evans, NovaCrypto\n *\n *  This program is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <https://www.gnu.org/licenses/>.\n *\n *  Original source: https://github.com/NovaCrypto/BIP39\n *  You can contact the authors via github issues.\n */\n\npackage com.quincysx.crypto.bip39.wordlists;\n\n\nimport com.quincysx.crypto.bip39.WordList;\n\n/**\n * Source: https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt\n */\npublic enum English implements WordList {\n    INSTANCE;\n\n    @Override\n    public String getWord(final int index) {\n        return words[index];\n    }\n\n    @Override\n    public int getIndex(final String word) {\n        int size = words.length;\n        if (word == null) {\n            for (int i = 0; i < size; i++)\n                if (words[i] == null)\n                    return i;\n        } else {\n            for (int i = 0; i < size; i++)\n                if (word.equals(words[i]))\n                    return i;\n        }\n        return -1;\n    }\n\n    @Override\n    public char getSpace() {\n        return ' ';\n    }\n\n    private final static String[] words = new String[]{\n            \"abandon\",\n            \"ability\",\n            \"able\",\n            \"about\",\n            \"above\",\n            \"absent\",\n            \"absorb\",\n            \"abstract\",\n            \"absurd\",\n            \"abuse\",\n            \"access\",\n            \"accident\",\n            \"account\",\n            \"accuse\",\n            \"achieve\",\n            \"acid\",\n            \"acoustic\",\n            \"acquire\",\n            \"across\",\n            \"act\",\n            \"action\",\n            \"actor\",\n            \"actress\",\n            \"actual\",\n            \"adapt\",\n            \"add\",\n            \"addict\",\n            \"address\",\n            \"adjust\",\n            \"admit\",\n            \"adult\",\n            \"advance\",\n            \"advice\",\n            \"aerobic\",\n            \"affair\",\n            \"afford\",\n            \"afraid\",\n            \"again\",\n            \"age\",\n            \"agent\",\n            \"agree\",\n            \"ahead\",\n            \"aim\",\n            \"air\",\n            \"airport\",\n            \"aisle\",\n            \"alarm\",\n            \"album\",\n            \"alcohol\",\n            \"alert\",\n            \"alien\",\n            \"all\",\n            \"alley\",\n            \"allow\",\n            \"almost\",\n            \"alone\",\n            \"alpha\",\n            \"already\",\n            \"also\",\n            \"alter\",\n            \"always\",\n            \"amateur\",\n            \"amazing\",\n            \"among\",\n            \"amount\",\n            \"amused\",\n            \"analyst\",\n            \"anchor\",\n            \"ancient\",\n            \"anger\",\n            \"angle\",\n            \"angry\",\n            \"animal\",\n            \"ankle\",\n            \"announce\",\n            \"annual\",\n            \"another\",\n            \"answer\",\n            \"antenna\",\n            \"antique\",\n            \"anxiety\",\n            \"any\",\n            \"apart\",\n            \"apology\",\n            \"appear\",\n            \"apple\",\n            \"approve\",\n            \"april\",\n            \"arch\",\n            \"arctic\",\n            \"area\",\n            \"arena\",\n            \"argue\",\n            \"arm\",\n            \"armed\",\n            \"armor\",\n            \"army\",\n            \"around\",\n            \"arrange\",\n            \"arrest\",\n            \"arrive\",\n            \"arrow\",\n            \"art\",\n            \"artefact\",\n            \"artist\",\n            \"artwork\",\n            \"ask\",\n            \"aspect\",\n            \"assault\",\n            \"asset\",\n            \"assist\",\n            \"assume\",\n            \"asthma\",\n            \"athlete\",\n            \"atom\",\n            \"attack\",\n            \"attend\",\n            \"attitude\",\n            \"attract\",\n            \"auction\",\n            \"audit\",\n            \"august\",\n            \"aunt\",\n            \"author\",\n            \"auto\",\n            \"autumn\",\n            \"average\",\n            \"avocado\",\n            \"avoid\",\n            \"awake\",\n            \"aware\",\n            \"away\",\n            \"awesome\",\n            \"awful\",\n            \"awkward\",\n            \"axis\",\n            \"baby\",\n            \"bachelor\",\n            \"bacon\",\n            \"badge\",\n            \"bag\",\n            \"balance\",\n            \"balcony\",\n            \"ball\",\n            \"bamboo\",\n            \"banana\",\n            \"banner\",\n            \"bar\",\n            \"barely\",\n            \"bargain\",\n            \"barrel\",\n            \"base\",\n            \"basic\",\n            \"basket\",\n            \"battle\",\n            \"beach\",\n            \"bean\",\n            \"beauty\",\n            \"because\",\n            \"become\",\n            \"beef\",\n            \"before\",\n            \"begin\",\n            \"behave\",\n            \"behind\",\n            \"believe\",\n            \"below\",\n            \"belt\",\n            \"bench\",\n            \"benefit\",\n            \"best\",\n            \"betray\",\n            \"better\",\n            \"between\",\n            \"beyond\",\n            \"bicycle\",\n            \"bid\",\n            \"bike\",\n            \"bind\",\n            \"biology\",\n            \"bird\",\n            \"birth\",\n            \"bitter\",\n            \"black\",\n            \"blade\",\n            \"blame\",\n            \"blanket\",\n            \"blast\",\n            \"bleak\",\n            \"bless\",\n            \"blind\",\n            \"blood\",\n            \"blossom\",\n            \"blouse\",\n            \"blue\",\n            \"blur\",\n            \"blush\",\n            \"board\",\n            \"boat\",\n            \"body\",\n            \"boil\",\n            \"bomb\",\n            \"bone\",\n            \"bonus\",\n            \"book\",\n            \"boost\",\n            \"border\",\n            \"boring\",\n            \"borrow\",\n            \"boss\",\n            \"bottom\",\n            \"bounce\",\n            \"box\",\n            \"boy\",\n            \"bracket\",\n            \"brain\",\n            \"brand\",\n            \"brass\",\n            \"brave\",\n            \"bread\",\n            \"breeze\",\n            \"brick\",\n            \"bridge\",\n            \"brief\",\n            \"bright\",\n            \"bring\",\n            \"brisk\",\n            \"broccoli\",\n            \"broken\",\n            \"bronze\",\n            \"broom\",\n            \"brother\",\n            \"brown\",\n            \"brush\",\n            \"bubble\",\n            \"buddy\",\n            \"budget\",\n            \"buffalo\",\n            \"build\",\n            \"bulb\",\n            \"bulk\",\n            \"bullet\",\n            \"bundle\",\n            \"bunker\",\n            \"burden\",\n            \"burger\",\n            \"burst\",\n            \"bus\",\n            \"business\",\n            \"busy\",\n            \"butter\",\n            \"buyer\",\n            \"buzz\",\n            \"cabbage\",\n            \"cabin\",\n            \"cable\",\n            \"cactus\",\n            \"cage\",\n            \"cake\",\n            \"call\",\n            \"calm\",\n            \"camera\",\n            \"camp\",\n            \"can\",\n            \"canal\",\n            \"cancel\",\n            \"candy\",\n            \"cannon\",\n            \"canoe\",\n            \"canvas\",\n            \"canyon\",\n            \"capable\",\n            \"capital\",\n            \"captain\",\n            \"car\",\n            \"carbon\",\n            \"card\",\n            \"cargo\",\n            \"carpet\",\n            \"carry\",\n            \"cart\",\n            \"case\",\n            \"cash\",\n            \"casino\",\n            \"castle\",\n            \"casual\",\n            \"cat\",\n            \"catalog\",\n            \"catch\",\n            \"category\",\n            \"cattle\",\n            \"caught\",\n            \"cause\",\n            \"caution\",\n            \"cave\",\n            \"ceiling\",\n            \"celery\",\n            \"cement\",\n            \"census\",\n            \"century\",\n            \"cereal\",\n            \"certain\",\n            \"chair\",\n            \"chalk\",\n            \"champion\",\n            \"change\",\n            \"chaos\",\n            \"chapter\",\n            \"charge\",\n            \"chase\",\n            \"chat\",\n            \"cheap\",\n            \"check\",\n            \"cheese\",\n            \"chef\",\n            \"cherry\",\n            \"chest\",\n            \"chicken\",\n            \"chief\",\n            \"child\",\n            \"chimney\",\n            \"choice\",\n            \"choose\",\n            \"chronic\",\n            \"chuckle\",\n            \"chunk\",\n            \"churn\",\n            \"cigar\",\n            \"cinnamon\",\n            \"circle\",\n            \"citizen\",\n            \"city\",\n            \"civil\",\n            \"claim\",\n            \"clap\",\n            \"clarify\",\n            \"claw\",\n            \"clay\",\n            \"clean\",\n            \"clerk\",\n            \"clever\",\n            \"click\",\n            \"client\",\n            \"cliff\",\n            \"climb\",\n            \"clinic\",\n            \"clip\",\n            \"clock\",\n            \"clog\",\n            \"close\",\n            \"cloth\",\n            \"cloud\",\n            \"clown\",\n            \"club\",\n            \"clump\",\n            \"cluster\",\n            \"clutch\",\n            \"coach\",\n            \"coast\",\n            \"coconut\",\n            \"code\",\n            \"coffee\",\n            \"coil\",\n            \"coin\",\n            \"collect\",\n            \"color\",\n            \"column\",\n            \"combine\",\n            \"come\",\n            \"comfort\",\n            \"comic\",\n            \"common\",\n            \"company\",\n            \"concert\",\n            \"conduct\",\n            \"confirm\",\n            \"congress\",\n            \"connect\",\n            \"consider\",\n            \"control\",\n            \"convince\",\n            \"cook\",\n            \"cool\",\n            \"copper\",\n            \"copy\",\n            \"coral\",\n            \"core\",\n            \"corn\",\n            \"correct\",\n            \"cost\",\n            \"cotton\",\n            \"couch\",\n            \"country\",\n            \"couple\",\n            \"course\",\n            \"cousin\",\n            \"cover\",\n            \"coyote\",\n            \"crack\",\n            \"cradle\",\n            \"craft\",\n            \"cram\",\n            \"crane\",\n            \"crash\",\n            \"crater\",\n            \"crawl\",\n            \"crazy\",\n            \"cream\",\n            \"credit\",\n            \"creek\",\n            \"crew\",\n            \"cricket\",\n            \"crime\",\n            \"crisp\",\n            \"critic\",\n            \"crop\",\n            \"cross\",\n            \"crouch\",\n            \"crowd\",\n            \"crucial\",\n            \"cruel\",\n            \"cruise\",\n            \"crumble\",\n            \"crunch\",\n            \"crush\",\n            \"cry\",\n            \"crystal\",\n            \"cube\",\n            \"culture\",\n            \"cup\",\n            \"cupboard\",\n            \"curious\",\n            \"current\",\n            \"curtain\",\n            \"curve\",\n            \"cushion\",\n            \"custom\",\n            \"cute\",\n            \"cycle\",\n            \"dad\",\n            \"damage\",\n            \"damp\",\n            \"dance\",\n            \"danger\",\n            \"daring\",\n            \"dash\",\n            \"daughter\",\n            \"dawn\",\n            \"day\",\n            \"deal\",\n            \"debate\",\n            \"debris\",\n            \"decade\",\n            \"december\",\n            \"decide\",\n            \"decline\",\n            \"decorate\",\n            \"decrease\",\n            \"deer\",\n            \"defense\",\n            \"define\",\n            \"defy\",\n            \"degree\",\n            \"delay\",\n            \"deliver\",\n            \"demand\",\n            \"demise\",\n            \"denial\",\n            \"dentist\",\n            \"deny\",\n            \"depart\",\n            \"depend\",\n            \"deposit\",\n            \"depth\",\n            \"deputy\",\n            \"derive\",\n            \"describe\",\n            \"desert\",\n            \"design\",\n            \"desk\",\n            \"despair\",\n            \"destroy\",\n            \"detail\",\n            \"detect\",\n            \"develop\",\n            \"device\",\n            \"devote\",\n            \"diagram\",\n            \"dial\",\n            \"diamond\",\n            \"diary\",\n            \"dice\",\n            \"diesel\",\n            \"diet\",\n            \"differ\",\n            \"digital\",\n            \"dignity\",\n            \"dilemma\",\n            \"dinner\",\n            \"dinosaur\",\n            \"direct\",\n            \"dirt\",\n            \"disagree\",\n            \"discover\",\n            \"disease\",\n            \"dish\",\n            \"dismiss\",\n            \"disorder\",\n            \"display\",\n            \"distance\",\n            \"divert\",\n            \"divide\",\n            \"divorce\",\n            \"dizzy\",\n            \"doctor\",\n            \"document\",\n            \"dog\",\n            \"doll\",\n            \"dolphin\",\n            \"domain\",\n            \"donate\",\n            \"donkey\",\n            \"donor\",\n            \"door\",\n            \"dose\",\n            \"double\",\n            \"dove\",\n            \"draft\",\n            \"dragon\",\n            \"drama\",\n            \"drastic\",\n            \"draw\",\n            \"dream\",\n            \"dress\",\n            \"drift\",\n            \"drill\",\n            \"drink\",\n            \"drip\",\n            \"drive\",\n            \"drop\",\n            \"drum\",\n            \"dry\",\n            \"duck\",\n            \"dumb\",\n            \"dune\",\n            \"during\",\n            \"dust\",\n            \"dutch\",\n            \"duty\",\n            \"dwarf\",\n            \"dynamic\",\n            \"eager\",\n            \"eagle\",\n            \"early\",\n            \"earn\",\n            \"earth\",\n            \"easily\",\n            \"east\",\n            \"easy\",\n            \"echo\",\n            \"ecology\",\n            \"economy\",\n            \"edge\",\n            \"edit\",\n            \"educate\",\n            \"effort\",\n            \"egg\",\n            \"eight\",\n            \"either\",\n            \"elbow\",\n            \"elder\",\n            \"electric\",\n            \"elegant\",\n            \"element\",\n            \"elephant\",\n            \"elevator\",\n            \"elite\",\n            \"else\",\n            \"embark\",\n            \"embody\",\n            \"embrace\",\n            \"emerge\",\n            \"emotion\",\n            \"employ\",\n            \"empower\",\n            \"empty\",\n            \"enable\",\n            \"enact\",\n            \"end\",\n            \"endless\",\n            \"endorse\",\n            \"enemy\",\n            \"energy\",\n            \"enforce\",\n            \"engage\",\n            \"engine\",\n            \"enhance\",\n            \"enjoy\",\n            \"enlist\",\n            \"enough\",\n            \"enrich\",\n            \"enroll\",\n            \"ensure\",\n            \"enter\",\n            \"entire\",\n            \"entry\",\n            \"envelope\",\n            \"episode\",\n            \"equal\",\n            \"equip\",\n            \"era\",\n            \"erase\",\n            \"erode\",\n            \"erosion\",\n            \"error\",\n            \"erupt\",\n            \"escape\",\n            \"essay\",\n            \"essence\",\n            \"estate\",\n            \"eternal\",\n            \"ethics\",\n            \"evidence\",\n            \"evil\",\n            \"evoke\",\n            \"evolve\",\n            \"exact\",\n            \"example\",\n            \"excess\",\n            \"exchange\",\n            \"excite\",\n            \"exclude\",\n            \"excuse\",\n            \"execute\",\n            \"exercise\",\n            \"exhaust\",\n            \"exhibit\",\n            \"exile\",\n            \"exist\",\n            \"exit\",\n            \"exotic\",\n            \"expand\",\n            \"expect\",\n            \"expire\",\n            \"explain\",\n            \"expose\",\n            \"express\",\n            \"extend\",\n            \"extra\",\n            \"eye\",\n            \"eyebrow\",\n            \"fabric\",\n            \"face\",\n            \"faculty\",\n            \"fade\",\n            \"faint\",\n            \"faith\",\n            \"fall\",\n            \"false\",\n            \"fame\",\n            \"family\",\n            \"famous\",\n            \"fan\",\n            \"fancy\",\n            \"fantasy\",\n            \"farm\",\n            \"fashion\",\n            \"fat\",\n            \"fatal\",\n            \"father\",\n            \"fatigue\",\n            \"fault\",\n            \"favorite\",\n            \"feature\",\n            \"february\",\n            \"federal\",\n            \"fee\",\n            \"feed\",\n            \"feel\",\n            \"female\",\n            \"fence\",\n            \"festival\",\n            \"fetch\",\n            \"fever\",\n            \"few\",\n            \"fiber\",\n            \"fiction\",\n            \"field\",\n            \"figure\",\n            \"file\",\n            \"film\",\n            \"filter\",\n            \"final\",\n            \"find\",\n            \"fine\",\n            \"finger\",\n            \"finish\",\n            \"fire\",\n            \"firm\",\n            \"first\",\n            \"fiscal\",\n            \"fish\",\n            \"fit\",\n            \"fitness\",\n            \"fix\",\n            \"flag\",\n            \"flame\",\n            \"flash\",\n            \"flat\",\n            \"flavor\",\n            \"flee\",\n            \"flight\",\n            \"flip\",\n            \"float\",\n            \"flock\",\n            \"floor\",\n            \"flower\",\n            \"fluid\",\n            \"flush\",\n            \"fly\",\n            \"foam\",\n            \"focus\",\n            \"fog\",\n            \"foil\",\n            \"fold\",\n            \"follow\",\n            \"food\",\n            \"foot\",\n            \"force\",\n            \"forest\",\n            \"forget\",\n            \"fork\",\n            \"fortune\",\n            \"forum\",\n            \"forward\",\n            \"fossil\",\n            \"foster\",\n            \"found\",\n            \"fox\",\n            \"fragile\",\n            \"frame\",\n            \"frequent\",\n            \"fresh\",\n            \"friend\",\n            \"fringe\",\n            \"frog\",\n            \"front\",\n            \"frost\",\n            \"frown\",\n            \"frozen\",\n            \"fruit\",\n            \"fuel\",\n            \"fun\",\n            \"funny\",\n            \"furnace\",\n            \"fury\",\n            \"future\",\n            \"gadget\",\n            \"gain\",\n            \"galaxy\",\n            \"gallery\",\n            \"game\",\n            \"gap\",\n            \"garage\",\n            \"garbage\",\n            \"garden\",\n            \"garlic\",\n            \"garment\",\n            \"gas\",\n            \"gasp\",\n            \"gate\",\n            \"gather\",\n            \"gauge\",\n            \"gaze\",\n            \"general\",\n            \"genius\",\n            \"genre\",\n            \"gentle\",\n            \"genuine\",\n            \"gesture\",\n            \"ghost\",\n            \"giant\",\n            \"gift\",\n            \"giggle\",\n            \"ginger\",\n            \"giraffe\",\n            \"girl\",\n            \"give\",\n            \"glad\",\n            \"glance\",\n            \"glare\",\n            \"glass\",\n            \"glide\",\n            \"glimpse\",\n            \"globe\",\n            \"gloom\",\n            \"glory\",\n            \"glove\",\n            \"glow\",\n            \"glue\",\n            \"goat\",\n            \"goddess\",\n            \"gold\",\n            \"good\",\n            \"goose\",\n            \"gorilla\",\n            \"gospel\",\n            \"gossip\",\n            \"govern\",\n            \"gown\",\n            \"grab\",\n            \"grace\",\n            \"grain\",\n            \"grant\",\n            \"grape\",\n            \"grass\",\n            \"gravity\",\n            \"great\",\n            \"green\",\n            \"grid\",\n            \"grief\",\n            \"grit\",\n            \"grocery\",\n            \"group\",\n            \"grow\",\n            \"grunt\",\n            \"guard\",\n            \"guess\",\n            \"guide\",\n            \"guilt\",\n            \"guitar\",\n            \"gun\",\n            \"gym\",\n            \"habit\",\n            \"hair\",\n            \"half\",\n            \"hammer\",\n            \"hamster\",\n            \"hand\",\n            \"happy\",\n            \"harbor\",\n            \"hard\",\n            \"harsh\",\n            \"harvest\",\n            \"hat\",\n            \"have\",\n            \"hawk\",\n            \"hazard\",\n            \"head\",\n            \"health\",\n            \"heart\",\n            \"heavy\",\n            \"hedgehog\",\n            \"height\",\n            \"hello\",\n            \"helmet\",\n            \"help\",\n            \"hen\",\n            \"hero\",\n            \"hidden\",\n            \"high\",\n            \"hill\",\n            \"hint\",\n            \"hip\",\n            \"hire\",\n            \"history\",\n            \"hobby\",\n            \"hockey\",\n            \"hold\",\n            \"hole\",\n            \"holiday\",\n            \"hollow\",\n            \"home\",\n            \"honey\",\n            \"hood\",\n            \"hope\",\n            \"horn\",\n            \"horror\",\n            \"horse\",\n            \"hospital\",\n            \"host\",\n            \"hotel\",\n            \"hour\",\n            \"hover\",\n            \"hub\",\n            \"huge\",\n            \"human\",\n            \"humble\",\n            \"humor\",\n            \"hundred\",\n            \"hungry\",\n            \"hunt\",\n            \"hurdle\",\n            \"hurry\",\n            \"hurt\",\n            \"husband\",\n            \"hybrid\",\n            \"ice\",\n            \"icon\",\n            \"idea\",\n            \"identify\",\n            \"idle\",\n            \"ignore\",\n            \"ill\",\n            \"illegal\",\n            \"illness\",\n            \"image\",\n            \"imitate\",\n            \"immense\",\n            \"immune\",\n            \"impact\",\n            \"impose\",\n            \"improve\",\n            \"impulse\",\n            \"inch\",\n            \"include\",\n            \"income\",\n            \"increase\",\n            \"index\",\n            \"indicate\",\n            \"indoor\",\n            \"industry\",\n            \"infant\",\n            \"inflict\",\n            \"inform\",\n            \"inhale\",\n            \"inherit\",\n            \"initial\",\n            \"inject\",\n            \"injury\",\n            \"inmate\",\n            \"inner\",\n            \"innocent\",\n            \"input\",\n            \"inquiry\",\n            \"insane\",\n            \"insect\",\n            \"inside\",\n            \"inspire\",\n            \"install\",\n            \"intact\",\n            \"interest\",\n            \"into\",\n            \"invest\",\n            \"invite\",\n            \"involve\",\n            \"iron\",\n            \"island\",\n            \"isolate\",\n            \"issue\",\n            \"item\",\n            \"ivory\",\n            \"jacket\",\n            \"jaguar\",\n            \"jar\",\n            \"jazz\",\n            \"jealous\",\n            \"jeans\",\n            \"jelly\",\n            \"jewel\",\n            \"job\",\n            \"join\",\n            \"joke\",\n            \"journey\",\n            \"joy\",\n            \"judge\",\n            \"juice\",\n            \"jump\",\n            \"jungle\",\n            \"junior\",\n            \"junk\",\n            \"just\",\n            \"kangaroo\",\n            \"keen\",\n            \"keep\",\n            \"ketchup\",\n            \"key\",\n            \"kick\",\n            \"kid\",\n            \"kidney\",\n            \"kind\",\n            \"kingdom\",\n            \"kiss\",\n            \"kit\",\n            \"kitchen\",\n            \"kite\",\n            \"kitten\",\n            \"kiwi\",\n            \"knee\",\n            \"knife\",\n            \"knock\",\n            \"know\",\n            \"lab\",\n            \"label\",\n            \"labor\",\n            \"ladder\",\n            \"lady\",\n            \"lake\",\n            \"lamp\",\n            \"language\",\n            \"laptop\",\n            \"large\",\n            \"later\",\n            \"latin\",\n            \"laugh\",\n            \"laundry\",\n            \"lava\",\n            \"law\",\n            \"lawn\",\n            \"lawsuit\",\n            \"layer\",\n            \"lazy\",\n            \"leader\",\n            \"leaf\",\n            \"learn\",\n            \"leave\",\n            \"lecture\",\n            \"left\",\n            \"leg\",\n            \"legal\",\n            \"legend\",\n            \"leisure\",\n            \"lemon\",\n            \"lend\",\n            \"length\",\n            \"lens\",\n            \"leopard\",\n            \"lesson\",\n            \"letter\",\n            \"level\",\n            \"liar\",\n            \"liberty\",\n            \"library\",\n            \"license\",\n            \"life\",\n            \"lift\",\n            \"light\",\n            \"like\",\n            \"limb\",\n            \"limit\",\n            \"link\",\n            \"lion\",\n            \"liquid\",\n            \"list\",\n            \"little\",\n            \"live\",\n            \"lizard\",\n            \"load\",\n            \"loan\",\n            \"lobster\",\n            \"local\",\n            \"lock\",\n            \"logic\",\n            \"lonely\",\n            \"long\",\n            \"loop\",\n            \"lottery\",\n            \"loud\",\n            \"lounge\",\n            \"love\",\n            \"loyal\",\n            \"lucky\",\n            \"luggage\",\n            \"lumber\",\n            \"lunar\",\n            \"lunch\",\n            \"luxury\",\n            \"lyrics\",\n            \"machine\",\n            \"mad\",\n            \"magic\",\n            \"magnet\",\n            \"maid\",\n            \"mail\",\n            \"main\",\n            \"major\",\n            \"make\",\n            \"mammal\",\n            \"man\",\n            \"manage\",\n            \"mandate\",\n            \"mango\",\n            \"mansion\",\n            \"manual\",\n            \"maple\",\n            \"marble\",\n            \"march\",\n            \"margin\",\n            \"marine\",\n            \"market\",\n            \"marriage\",\n            \"mask\",\n            \"mass\",\n            \"master\",\n            \"match\",\n            \"material\",\n            \"math\",\n            \"matrix\",\n            \"matter\",\n            \"maximum\",\n            \"maze\",\n            \"meadow\",\n            \"mean\",\n            \"measure\",\n            \"meat\",\n            \"mechanic\",\n            \"medal\",\n            \"media\",\n            \"melody\",\n            \"melt\",\n            \"member\",\n            \"memory\",\n            \"mention\",\n            \"menu\",\n            \"mercy\",\n            \"merge\",\n            \"merit\",\n            \"merry\",\n            \"mesh\",\n            \"message\",\n            \"metal\",\n            \"method\",\n            \"middle\",\n            \"midnight\",\n            \"milk\",\n            \"million\",\n            \"mimic\",\n            \"mind\",\n            \"minimum\",\n            \"minor\",\n            \"minute\",\n            \"miracle\",\n            \"mirror\",\n            \"misery\",\n            \"miss\",\n            \"mistake\",\n            \"mix\",\n            \"mixed\",\n            \"mixture\",\n            \"mobile\",\n            \"model\",\n            \"modify\",\n            \"mom\",\n            \"moment\",\n            \"monitor\",\n            \"monkey\",\n            \"monster\",\n            \"month\",\n            \"moon\",\n            \"moral\",\n            \"more\",\n            \"morning\",\n            \"mosquito\",\n            \"mother\",\n            \"motion\",\n            \"motor\",\n            \"mountain\",\n            \"mouse\",\n            \"move\",\n            \"movie\",\n            \"much\",\n            \"muffin\",\n            \"mule\",\n            \"multiply\",\n            \"muscle\",\n            \"museum\",\n            \"mushroom\",\n            \"music\",\n            \"must\",\n            \"mutual\",\n            \"myself\",\n            \"mystery\",\n            \"myth\",\n            \"naive\",\n            \"name\",\n            \"napkin\",\n            \"narrow\",\n            \"nasty\",\n            \"nation\",\n            \"nature\",\n            \"near\",\n            \"neck\",\n            \"need\",\n            \"negative\",\n            \"neglect\",\n            \"neither\",\n            \"nephew\",\n            \"nerve\",\n            \"nest\",\n            \"net\",\n            \"network\",\n            \"neutral\",\n            \"never\",\n            \"news\",\n            \"next\",\n            \"nice\",\n            \"night\",\n            \"noble\",\n            \"noise\",\n            \"nominee\",\n            \"noodle\",\n            \"normal\",\n            \"north\",\n            \"nose\",\n            \"notable\",\n            \"note\",\n            \"nothing\",\n            \"notice\",\n            \"novel\",\n            \"now\",\n            \"nuclear\",\n            \"number\",\n            \"nurse\",\n            \"nut\",\n            \"oak\",\n            \"obey\",\n            \"object\",\n            \"oblige\",\n            \"obscure\",\n            \"observe\",\n            \"obtain\",\n            \"obvious\",\n            \"occur\",\n            \"ocean\",\n            \"october\",\n            \"odor\",\n            \"off\",\n            \"offer\",\n            \"office\",\n            \"often\",\n            \"oil\",\n            \"okay\",\n            \"old\",\n            \"olive\",\n            \"olympic\",\n            \"omit\",\n            \"once\",\n            \"one\",\n            \"onion\",\n            \"online\",\n            \"only\",\n            \"open\",\n            \"opera\",\n            \"opinion\",\n            \"oppose\",\n            \"option\",\n            \"orange\",\n            \"orbit\",\n            \"orchard\",\n            \"order\",\n            \"ordinary\",\n            \"organ\",\n            \"orient\",\n            \"original\",\n            \"orphan\",\n            \"ostrich\",\n            \"other\",\n            \"outdoor\",\n            \"outer\",\n            \"output\",\n            \"outside\",\n            \"oval\",\n            \"oven\",\n            \"over\",\n            \"own\",\n            \"owner\",\n            \"oxygen\",\n            \"oyster\",\n            \"ozone\",\n            \"pact\",\n            \"paddle\",\n            \"page\",\n            \"pair\",\n            \"palace\",\n            \"palm\",\n            \"panda\",\n            \"panel\",\n            \"panic\",\n            \"panther\",\n            \"paper\",\n            \"parade\",\n            \"parent\",\n            \"park\",\n            \"parrot\",\n            \"party\",\n            \"pass\",\n            \"patch\",\n            \"path\",\n            \"patient\",\n            \"patrol\",\n            \"pattern\",\n            \"pause\",\n            \"pave\",\n            \"payment\",\n            \"peace\",\n            \"peanut\",\n            \"pear\",\n            \"peasant\",\n            \"pelican\",\n            \"pen\",\n            \"penalty\",\n            \"pencil\",\n            \"people\",\n            \"pepper\",\n            \"perfect\",\n            \"permit\",\n            \"person\",\n            \"pet\",\n            \"phone\",\n            \"photo\",\n            \"phrase\",\n            \"physical\",\n            \"piano\",\n            \"picnic\",\n            \"picture\",\n            \"piece\",\n            \"pig\",\n            \"pigeon\",\n            \"pill\",\n            \"pilot\",\n            \"pink\",\n            \"pioneer\",\n            \"pipe\",\n            \"pistol\",\n            \"pitch\",\n            \"pizza\",\n            \"place\",\n            \"planet\",\n            \"plastic\",\n            \"plate\",\n            \"play\",\n            \"please\",\n            \"pledge\",\n            \"pluck\",\n            \"plug\",\n            \"plunge\",\n            \"poem\",\n            \"poet\",\n            \"point\",\n            \"polar\",\n            \"pole\",\n            \"police\",\n            \"pond\",\n            \"pony\",\n            \"pool\",\n            \"popular\",\n            \"portion\",\n            \"position\",\n            \"possible\",\n            \"post\",\n            \"potato\",\n            \"pottery\",\n            \"poverty\",\n            \"powder\",\n            \"power\",\n            \"practice\",\n            \"praise\",\n            \"predict\",\n            \"prefer\",\n            \"prepare\",\n            \"present\",\n            \"pretty\",\n            \"prevent\",\n            \"price\",\n            \"pride\",\n            \"primary\",\n            \"print\",\n            \"priority\",\n            \"prison\",\n            \"private\",\n            \"prize\",\n            \"problem\",\n            \"process\",\n            \"produce\",\n            \"profit\",\n            \"program\",\n            \"project\",\n            \"promote\",\n            \"proof\",\n            \"property\",\n            \"prosper\",\n            \"protect\",\n            \"proud\",\n            \"provide\",\n            \"public\",\n            \"pudding\",\n            \"pull\",\n            \"pulp\",\n            \"pulse\",\n            \"pumpkin\",\n            \"punch\",\n            \"pupil\",\n            \"puppy\",\n            \"purchase\",\n            \"purity\",\n            \"purpose\",\n            \"purse\",\n            \"push\",\n            \"put\",\n            \"puzzle\",\n            \"pyramid\",\n            \"quality\",\n            \"quantum\",\n            \"quarter\",\n            \"question\",\n            \"quick\",\n            \"quit\",\n            \"quiz\",\n            \"quote\",\n            \"rabbit\",\n            \"raccoon\",\n            \"race\",\n            \"rack\",\n            \"radar\",\n            \"radio\",\n            \"rail\",\n            \"rain\",\n            \"raise\",\n            \"rally\",\n            \"ramp\",\n            \"ranch\",\n            \"random\",\n            \"range\",\n            \"rapid\",\n            \"rare\",\n            \"rate\",\n            \"rather\",\n            \"raven\",\n            \"raw\",\n            \"razor\",\n            \"ready\",\n            \"real\",\n            \"reason\",\n            \"rebel\",\n            \"rebuild\",\n            \"recall\",\n            \"receive\",\n            \"recipe\",\n            \"record\",\n            \"recycle\",\n            \"reduce\",\n            \"reflect\",\n            \"reform\",\n            \"refuse\",\n            \"region\",\n            \"regret\",\n            \"regular\",\n            \"reject\",\n            \"relax\",\n            \"release\",\n            \"relief\",\n            \"rely\",\n            \"remain\",\n            \"remember\",\n            \"remind\",\n            \"remove\",\n            \"render\",\n            \"renew\",\n            \"rent\",\n            \"reopen\",\n            \"repair\",\n            \"repeat\",\n            \"replace\",\n            \"report\",\n            \"require\",\n            \"rescue\",\n            \"resemble\",\n            \"resist\",\n            \"resource\",\n            \"response\",\n            \"result\",\n            \"retire\",\n            \"retreat\",\n            \"return\",\n            \"reunion\",\n            \"reveal\",\n            \"review\",\n            \"reward\",\n            \"rhythm\",\n            \"rib\",\n            \"ribbon\",\n            \"rice\",\n            \"rich\",\n            \"ride\",\n            \"ridge\",\n            \"rifle\",\n            \"right\",\n            \"rigid\",\n            \"ring\",\n            \"riot\",\n            \"ripple\",\n            \"risk\",\n            \"ritual\",\n            \"rival\",\n            \"river\",\n            \"road\",\n            \"roast\",\n            \"robot\",\n            \"robust\",\n            \"rocket\",\n            \"romance\",\n            \"roof\",\n            \"rookie\",\n            \"room\",\n            \"rose\",\n            \"rotate\",\n            \"rough\",\n            \"round\",\n            \"route\",\n            \"royal\",\n            \"rubber\",\n            \"rude\",\n            \"rug\",\n            \"rule\",\n            \"run\",\n            \"runway\",\n            \"rural\",\n            \"sad\",\n            \"saddle\",\n            \"sadness\",\n            \"safe\",\n            \"sail\",\n            \"salad\",\n            \"salmon\",\n            \"salon\",\n            \"salt\",\n            \"salute\",\n            \"same\",\n            \"sample\",\n            \"sand\",\n            \"satisfy\",\n            \"satoshi\",\n            \"sauce\",\n            \"sausage\",\n            \"save\",\n            \"say\",\n            \"scale\",\n            \"scan\",\n            \"scare\",\n            \"scatter\",\n            \"scene\",\n            \"scheme\",\n            \"school\",\n            \"science\",\n            \"scissors\",\n            \"scorpion\",\n            \"scout\",\n            \"scrap\",\n            \"screen\",\n            \"script\",\n            \"scrub\",\n            \"sea\",\n            \"search\",\n            \"season\",\n            \"seat\",\n            \"second\",\n            \"secret\",\n            \"section\",\n            \"security\",\n            \"seed\",\n            \"seek\",\n            \"segment\",\n            \"select\",\n            \"sell\",\n            \"seminar\",\n            \"senior\",\n            \"sense\",\n            \"sentence\",\n            \"series\",\n            \"service\",\n            \"session\",\n            \"settle\",\n            \"setup\",\n            \"seven\",\n            \"shadow\",\n            \"shaft\",\n            \"shallow\",\n            \"share\",\n            \"shed\",\n            \"shell\",\n            \"sheriff\",\n            \"shield\",\n            \"shift\",\n            \"shine\",\n            \"ship\",\n            \"shiver\",\n            \"shock\",\n            \"shoe\",\n            \"shoot\",\n            \"shop\",\n            \"short\",\n            \"shoulder\",\n            \"shove\",\n            \"shrimp\",\n            \"shrug\",\n            \"shuffle\",\n            \"shy\",\n            \"sibling\",\n            \"sick\",\n            \"side\",\n            \"siege\",\n            \"sight\",\n            \"sign\",\n            \"silent\",\n            \"silk\",\n            \"silly\",\n            \"silver\",\n            \"similar\",\n            \"simple\",\n            \"since\",\n            \"sing\",\n            \"siren\",\n            \"sister\",\n            \"situate\",\n            \"six\",\n            \"size\",\n            \"skate\",\n            \"sketch\",\n            \"ski\",\n            \"skill\",\n            \"skin\",\n            \"skirt\",\n            \"skull\",\n            \"slab\",\n            \"slam\",\n            \"sleep\",\n            \"slender\",\n            \"slice\",\n            \"slide\",\n            \"slight\",\n            \"slim\",\n            \"slogan\",\n            \"slot\",\n            \"slow\",\n            \"slush\",\n            \"small\",\n            \"smart\",\n            \"smile\",\n            \"smoke\",\n            \"smooth\",\n            \"snack\",\n            \"snake\",\n            \"snap\",\n            \"sniff\",\n            \"snow\",\n            \"soap\",\n            \"soccer\",\n            \"social\",\n            \"sock\",\n            \"soda\",\n            \"soft\",\n            \"solar\",\n            \"soldier\",\n            \"solid\",\n            \"solution\",\n            \"solve\",\n            \"someone\",\n            \"song\",\n            \"soon\",\n            \"sorry\",\n            \"sort\",\n            \"soul\",\n            \"sound\",\n            \"soup\",\n            \"source\",\n            \"south\",\n            \"space\",\n            \"spare\",\n            \"spatial\",\n            \"spawn\",\n            \"speak\",\n            \"special\",\n            \"speed\",\n            \"spell\",\n            \"spend\",\n            \"sphere\",\n            \"spice\",\n            \"spider\",\n            \"spike\",\n            \"spin\",\n            \"spirit\",\n            \"split\",\n            \"spoil\",\n            \"sponsor\",\n            \"spoon\",\n            \"sport\",\n            \"spot\",\n            \"spray\",\n            \"spread\",\n            \"spring\",\n            \"spy\",\n            \"square\",\n            \"squeeze\",\n            \"squirrel\",\n            \"stable\",\n            \"stadium\",\n            \"staff\",\n            \"stage\",\n            \"stairs\",\n            \"stamp\",\n            \"stand\",\n            \"start\",\n            \"state\",\n            \"stay\",\n            \"steak\",\n            \"steel\",\n            \"stem\",\n            \"step\",\n            \"stereo\",\n            \"stick\",\n            \"still\",\n            \"sting\",\n            \"stock\",\n            \"stomach\",\n            \"stone\",\n            \"stool\",\n            \"story\",\n            \"stove\",\n            \"strategy\",\n            \"street\",\n            \"strike\",\n            \"strong\",\n            \"struggle\",\n            \"student\",\n            \"stuff\",\n            \"stumble\",\n            \"style\",\n            \"subject\",\n            \"submit\",\n            \"subway\",\n            \"success\",\n            \"such\",\n            \"sudden\",\n            \"suffer\",\n            \"sugar\",\n            \"suggest\",\n            \"suit\",\n            \"summer\",\n            \"sun\",\n            \"sunny\",\n            \"sunset\",\n            \"super\",\n            \"supply\",\n            \"supreme\",\n            \"sure\",\n            \"surface\",\n            \"surge\",\n            \"surprise\",\n            \"surround\",\n            \"survey\",\n            \"suspect\",\n            \"sustain\",\n            \"swallow\",\n            \"swamp\",\n            \"swap\",\n            \"swarm\",\n            \"swear\",\n            \"sweet\",\n            \"swift\",\n            \"swim\",\n            \"swing\",\n            \"switch\",\n            \"sword\",\n            \"symbol\",\n            \"symptom\",\n            \"syrup\",\n            \"system\",\n            \"table\",\n            \"tackle\",\n            \"tag\",\n            \"tail\",\n            \"talent\",\n            \"talk\",\n            \"tank\",\n            \"tape\",\n            \"target\",\n            \"task\",\n            \"taste\",\n            \"tattoo\",\n            \"taxi\",\n            \"teach\",\n            \"team\",\n            \"tell\",\n            \"ten\",\n            \"tenant\",\n            \"tennis\",\n            \"tent\",\n            \"term\",\n            \"test\",\n            \"text\",\n            \"thank\",\n            \"that\",\n            \"theme\",\n            \"then\",\n            \"theory\",\n            \"there\",\n            \"they\",\n            \"thing\",\n            \"this\",\n            \"thought\",\n            \"three\",\n            \"thrive\",\n            \"throw\",\n            \"thumb\",\n            \"thunder\",\n            \"ticket\",\n            \"tide\",\n            \"tiger\",\n            \"tilt\",\n            \"timber\",\n            \"time\",\n            \"tiny\",\n            \"tip\",\n            \"tired\",\n            \"tissue\",\n            \"title\",\n            \"toast\",\n            \"tobacco\",\n            \"today\",\n            \"toddler\",\n            \"toe\",\n            \"together\",\n            \"toilet\",\n            \"token\",\n            \"tomato\",\n            \"tomorrow\",\n            \"tone\",\n            \"tongue\",\n            \"tonight\",\n            \"tool\",\n            \"tooth\",\n            \"top\",\n            \"topic\",\n            \"topple\",\n            \"torch\",\n            \"tornado\",\n            \"tortoise\",\n            \"toss\",\n            \"total\",\n            \"tourist\",\n            \"toward\",\n            \"tower\",\n            \"town\",\n            \"toy\",\n            \"track\",\n            \"trade\",\n            \"traffic\",\n            \"tragic\",\n            \"train\",\n            \"transfer\",\n            \"trap\",\n            \"trash\",\n            \"travel\",\n            \"tray\",\n            \"treat\",\n            \"tree\",\n            \"trend\",\n            \"trial\",\n            \"tribe\",\n            \"trick\",\n            \"trigger\",\n            \"trim\",\n            \"trip\",\n            \"trophy\",\n            \"trouble\",\n            \"truck\",\n            \"true\",\n            \"truly\",\n            \"trumpet\",\n            \"trust\",\n            \"truth\",\n            \"try\",\n            \"tube\",\n            \"tuition\",\n            \"tumble\",\n            \"tuna\",\n            \"tunnel\",\n            \"turkey\",\n            \"turn\",\n            \"turtle\",\n            \"twelve\",\n            \"twenty\",\n            \"twice\",\n            \"twin\",\n            \"twist\",\n            \"two\",\n            \"type\",\n            \"typical\",\n            \"ugly\",\n            \"umbrella\",\n            \"unable\",\n            \"unaware\",\n            \"uncle\",\n            \"uncover\",\n            \"under\",\n            \"undo\",\n            \"unfair\",\n            \"unfold\",\n            \"unhappy\",\n            \"uniform\",\n            \"unique\",\n            \"unit\",\n            \"universe\",\n            \"unknown\",\n            \"unlock\",\n            \"until\",\n            \"unusual\",\n            \"unveil\",\n            \"update\",\n            \"upgrade\",\n            \"uphold\",\n            \"upon\",\n            \"upper\",\n            \"upset\",\n            \"urban\",\n            \"urge\",\n            \"usage\",\n            \"use\",\n            \"used\",\n            \"useful\",\n            \"useless\",\n            \"usual\",\n            \"utility\",\n            \"vacant\",\n            \"vacuum\",\n            \"vague\",\n            \"valid\",\n            \"valley\",\n            \"valve\",\n            \"van\",\n            \"vanish\",\n            \"vapor\",\n            \"various\",\n            \"vast\",\n            \"vault\",\n            \"vehicle\",\n            \"velvet\",\n            \"vendor\",\n            \"venture\",\n            \"venue\",\n            \"verb\",\n            \"verify\",\n            \"version\",\n            \"very\",\n            \"vessel\",\n            \"veteran\",\n            \"viable\",\n            \"vibrant\",\n            \"vicious\",\n            \"victory\",\n            \"video\",\n            \"view\",\n            \"village\",\n            \"vintage\",\n            \"violin\",\n            \"virtual\",\n            \"virus\",\n            \"visa\",\n            \"visit\",\n            \"visual\",\n            \"vital\",\n            \"vivid\",\n            \"vocal\",\n            \"voice\",\n            \"void\",\n            \"volcano\",\n            \"volume\",\n            \"vote\",\n            \"voyage\",\n            \"wage\",\n            \"wagon\",\n            \"wait\",\n            \"walk\",\n            \"wall\",\n            \"walnut\",\n            \"want\",\n            \"warfare\",\n            \"warm\",\n            \"warrior\",\n            \"wash\",\n            \"wasp\",\n            \"waste\",\n            \"water\",\n            \"wave\",\n            \"way\",\n            \"wealth\",\n            \"weapon\",\n            \"wear\",\n            \"weasel\",\n            \"weather\",\n            \"web\",\n            \"wedding\",\n            \"weekend\",\n            \"weird\",\n            \"welcome\",\n            \"west\",\n            \"wet\",\n            \"whale\",\n            \"what\",\n            \"wheat\",\n            \"wheel\",\n            \"when\",\n            \"where\",\n            \"whip\",\n            \"whisper\",\n            \"wide\",\n            \"width\",\n            \"wife\",\n            \"wild\",\n            \"will\",\n            \"win\",\n            \"window\",\n            \"wine\",\n            \"wing\",\n            \"wink\",\n            \"winner\",\n            \"winter\",\n            \"wire\",\n            \"wisdom\",\n            \"wise\",\n            \"wish\",\n            \"witness\",\n            \"wolf\",\n            \"woman\",\n            \"wonder\",\n            \"wood\",\n            \"wool\",\n            \"word\",\n            \"work\",\n            \"world\",\n            \"worry\",\n            \"worth\",\n            \"wrap\",\n            \"wreck\",\n            \"wrestle\",\n            \"wrist\",\n            \"write\",\n            \"wrong\",\n            \"yard\",\n            \"year\",\n            \"yellow\",\n            \"you\",\n            \"young\",\n            \"youth\",\n            \"zebra\",\n            \"zero\",\n            \"zone\",\n            \"zoo\"\n    };\n}"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/wordlists/French.java",
    "content": "/*\n *  BIP39 library, a Java implementation of BIP39\n *  Copyright (C) 2017 Alan Evans, NovaCrypto\n *\n *  This program is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <https://www.gnu.org/licenses/>.\n *\n *  Original source: https://github.com/NovaCrypto/BIP39\n *  You can contact the authors via github issues.\n */\n\npackage com.quincysx.crypto.bip39.wordlists;\n\nimport com.quincysx.crypto.bip39.WordList;\n\n/**\n * Source: https://github.com/bitcoin/bips/blob/master/bip-0039/french.txt\n */\npublic enum French implements WordList {\n    INSTANCE;\n\n    @Override\n    public String getWord(final int index) {\n        return words[index];\n    }\n\n    @Override\n    public int getIndex(final String word) {\n        int size = words.length;\n        if (word == null) {\n            for (int i = 0; i < size; i++)\n                if (words[i] == null)\n                    return i;\n        } else {\n            for (int i = 0; i < size; i++)\n                if (word.equals(words[i]))\n                    return i;\n        }\n        return -1;\n    }\n\n    @Override\n    public char getSpace() {\n        return ' ';\n    }\n\n    private final static String[] words = new String[]{\n            \"abaisser\",\n            \"abandon\",\n            \"abdiquer\",\n            \"abeille\",\n            \"abolir\",\n            \"aborder\",\n            \"aboutir\",\n            \"aboyer\",\n            \"abrasif\",\n            \"abreuver\",\n            \"abriter\",\n            \"abroger\",\n            \"abrupt\",\n            \"absence\",\n            \"absolu\",\n            \"absurde\",\n            \"abusif\",\n            \"abyssal\",\n            \"académie\",\n            \"acajou\",\n            \"acarien\",\n            \"accabler\",\n            \"accepter\",\n            \"acclamer\",\n            \"accolade\",\n            \"accroche\",\n            \"accuser\",\n            \"acerbe\",\n            \"achat\",\n            \"acheter\",\n            \"aciduler\",\n            \"acier\",\n            \"acompte\",\n            \"acquérir\",\n            \"acronyme\",\n            \"acteur\",\n            \"actif\",\n            \"actuel\",\n            \"adepte\",\n            \"adéquat\",\n            \"adhésif\",\n            \"adjectif\",\n            \"adjuger\",\n            \"admettre\",\n            \"admirer\",\n            \"adopter\",\n            \"adorer\",\n            \"adoucir\",\n            \"adresse\",\n            \"adroit\",\n            \"adulte\",\n            \"adverbe\",\n            \"aérer\",\n            \"aéronef\",\n            \"affaire\",\n            \"affecter\",\n            \"affiche\",\n            \"affreux\",\n            \"affubler\",\n            \"agacer\",\n            \"agencer\",\n            \"agile\",\n            \"agiter\",\n            \"agrafer\",\n            \"agréable\",\n            \"agrume\",\n            \"aider\",\n            \"aiguille\",\n            \"ailier\",\n            \"aimable\",\n            \"aisance\",\n            \"ajouter\",\n            \"ajuster\",\n            \"alarmer\",\n            \"alchimie\",\n            \"alerte\",\n            \"algèbre\",\n            \"algue\",\n            \"aliéner\",\n            \"aliment\",\n            \"alléger\",\n            \"alliage\",\n            \"allouer\",\n            \"allumer\",\n            \"alourdir\",\n            \"alpaga\",\n            \"altesse\",\n            \"alvéole\",\n            \"amateur\",\n            \"ambigu\",\n            \"ambre\",\n            \"aménager\",\n            \"amertume\",\n            \"amidon\",\n            \"amiral\",\n            \"amorcer\",\n            \"amour\",\n            \"amovible\",\n            \"amphibie\",\n            \"ampleur\",\n            \"amusant\",\n            \"analyse\",\n            \"anaphore\",\n            \"anarchie\",\n            \"anatomie\",\n            \"ancien\",\n            \"anéantir\",\n            \"angle\",\n            \"angoisse\",\n            \"anguleux\",\n            \"animal\",\n            \"annexer\",\n            \"annonce\",\n            \"annuel\",\n            \"anodin\",\n            \"anomalie\",\n            \"anonyme\",\n            \"anormal\",\n            \"antenne\",\n            \"antidote\",\n            \"anxieux\",\n            \"apaiser\",\n            \"apéritif\",\n            \"aplanir\",\n            \"apologie\",\n            \"appareil\",\n            \"appeler\",\n            \"apporter\",\n            \"appuyer\",\n            \"aquarium\",\n            \"aqueduc\",\n            \"arbitre\",\n            \"arbuste\",\n            \"ardeur\",\n            \"ardoise\",\n            \"argent\",\n            \"arlequin\",\n            \"armature\",\n            \"armement\",\n            \"armoire\",\n            \"armure\",\n            \"arpenter\",\n            \"arracher\",\n            \"arriver\",\n            \"arroser\",\n            \"arsenic\",\n            \"artériel\",\n            \"article\",\n            \"aspect\",\n            \"asphalte\",\n            \"aspirer\",\n            \"assaut\",\n            \"asservir\",\n            \"assiette\",\n            \"associer\",\n            \"assurer\",\n            \"asticot\",\n            \"astre\",\n            \"astuce\",\n            \"atelier\",\n            \"atome\",\n            \"atrium\",\n            \"atroce\",\n            \"attaque\",\n            \"attentif\",\n            \"attirer\",\n            \"attraper\",\n            \"aubaine\",\n            \"auberge\",\n            \"audace\",\n            \"audible\",\n            \"augurer\",\n            \"aurore\",\n            \"automne\",\n            \"autruche\",\n            \"avaler\",\n            \"avancer\",\n            \"avarice\",\n            \"avenir\",\n            \"averse\",\n            \"aveugle\",\n            \"aviateur\",\n            \"avide\",\n            \"avion\",\n            \"aviser\",\n            \"avoine\",\n            \"avouer\",\n            \"avril\",\n            \"axial\",\n            \"axiome\",\n            \"badge\",\n            \"bafouer\",\n            \"bagage\",\n            \"baguette\",\n            \"baignade\",\n            \"balancer\",\n            \"balcon\",\n            \"baleine\",\n            \"balisage\",\n            \"bambin\",\n            \"bancaire\",\n            \"bandage\",\n            \"banlieue\",\n            \"bannière\",\n            \"banquier\",\n            \"barbier\",\n            \"baril\",\n            \"baron\",\n            \"barque\",\n            \"barrage\",\n            \"bassin\",\n            \"bastion\",\n            \"bataille\",\n            \"bateau\",\n            \"batterie\",\n            \"baudrier\",\n            \"bavarder\",\n            \"belette\",\n            \"bélier\",\n            \"belote\",\n            \"bénéfice\",\n            \"berceau\",\n            \"berger\",\n            \"berline\",\n            \"bermuda\",\n            \"besace\",\n            \"besogne\",\n            \"bétail\",\n            \"beurre\",\n            \"biberon\",\n            \"bicycle\",\n            \"bidule\",\n            \"bijou\",\n            \"bilan\",\n            \"bilingue\",\n            \"billard\",\n            \"binaire\",\n            \"biologie\",\n            \"biopsie\",\n            \"biotype\",\n            \"biscuit\",\n            \"bison\",\n            \"bistouri\",\n            \"bitume\",\n            \"bizarre\",\n            \"blafard\",\n            \"blague\",\n            \"blanchir\",\n            \"blessant\",\n            \"blinder\",\n            \"blond\",\n            \"bloquer\",\n            \"blouson\",\n            \"bobard\",\n            \"bobine\",\n            \"boire\",\n            \"boiser\",\n            \"bolide\",\n            \"bonbon\",\n            \"bondir\",\n            \"bonheur\",\n            \"bonifier\",\n            \"bonus\",\n            \"bordure\",\n            \"borne\",\n            \"botte\",\n            \"boucle\",\n            \"boueux\",\n            \"bougie\",\n            \"boulon\",\n            \"bouquin\",\n            \"bourse\",\n            \"boussole\",\n            \"boutique\",\n            \"boxeur\",\n            \"branche\",\n            \"brasier\",\n            \"brave\",\n            \"brebis\",\n            \"brèche\",\n            \"breuvage\",\n            \"bricoler\",\n            \"brigade\",\n            \"brillant\",\n            \"brioche\",\n            \"brique\",\n            \"brochure\",\n            \"broder\",\n            \"bronzer\",\n            \"brousse\",\n            \"broyeur\",\n            \"brume\",\n            \"brusque\",\n            \"brutal\",\n            \"bruyant\",\n            \"buffle\",\n            \"buisson\",\n            \"bulletin\",\n            \"bureau\",\n            \"burin\",\n            \"bustier\",\n            \"butiner\",\n            \"butoir\",\n            \"buvable\",\n            \"buvette\",\n            \"cabanon\",\n            \"cabine\",\n            \"cachette\",\n            \"cadeau\",\n            \"cadre\",\n            \"caféine\",\n            \"caillou\",\n            \"caisson\",\n            \"calculer\",\n            \"calepin\",\n            \"calibre\",\n            \"calmer\",\n            \"calomnie\",\n            \"calvaire\",\n            \"camarade\",\n            \"caméra\",\n            \"camion\",\n            \"campagne\",\n            \"canal\",\n            \"caneton\",\n            \"canon\",\n            \"cantine\",\n            \"canular\",\n            \"capable\",\n            \"caporal\",\n            \"caprice\",\n            \"capsule\",\n            \"capter\",\n            \"capuche\",\n            \"carabine\",\n            \"carbone\",\n            \"caresser\",\n            \"caribou\",\n            \"carnage\",\n            \"carotte\",\n            \"carreau\",\n            \"carton\",\n            \"cascade\",\n            \"casier\",\n            \"casque\",\n            \"cassure\",\n            \"causer\",\n            \"caution\",\n            \"cavalier\",\n            \"caverne\",\n            \"caviar\",\n            \"cédille\",\n            \"ceinture\",\n            \"céleste\",\n            \"cellule\",\n            \"cendrier\",\n            \"censurer\",\n            \"central\",\n            \"cercle\",\n            \"cérébral\",\n            \"cerise\",\n            \"cerner\",\n            \"cerveau\",\n            \"cesser\",\n            \"chagrin\",\n            \"chaise\",\n            \"chaleur\",\n            \"chambre\",\n            \"chance\",\n            \"chapitre\",\n            \"charbon\",\n            \"chasseur\",\n            \"chaton\",\n            \"chausson\",\n            \"chavirer\",\n            \"chemise\",\n            \"chenille\",\n            \"chéquier\",\n            \"chercher\",\n            \"cheval\",\n            \"chien\",\n            \"chiffre\",\n            \"chignon\",\n            \"chimère\",\n            \"chiot\",\n            \"chlorure\",\n            \"chocolat\",\n            \"choisir\",\n            \"chose\",\n            \"chouette\",\n            \"chrome\",\n            \"chute\",\n            \"cigare\",\n            \"cigogne\",\n            \"cimenter\",\n            \"cinéma\",\n            \"cintrer\",\n            \"circuler\",\n            \"cirer\",\n            \"cirque\",\n            \"citerne\",\n            \"citoyen\",\n            \"citron\",\n            \"civil\",\n            \"clairon\",\n            \"clameur\",\n            \"claquer\",\n            \"classe\",\n            \"clavier\",\n            \"client\",\n            \"cligner\",\n            \"climat\",\n            \"clivage\",\n            \"cloche\",\n            \"clonage\",\n            \"cloporte\",\n            \"cobalt\",\n            \"cobra\",\n            \"cocasse\",\n            \"cocotier\",\n            \"coder\",\n            \"codifier\",\n            \"coffre\",\n            \"cogner\",\n            \"cohésion\",\n            \"coiffer\",\n            \"coincer\",\n            \"colère\",\n            \"colibri\",\n            \"colline\",\n            \"colmater\",\n            \"colonel\",\n            \"combat\",\n            \"comédie\",\n            \"commande\",\n            \"compact\",\n            \"concert\",\n            \"conduire\",\n            \"confier\",\n            \"congeler\",\n            \"connoter\",\n            \"consonne\",\n            \"contact\",\n            \"convexe\",\n            \"copain\",\n            \"copie\",\n            \"corail\",\n            \"corbeau\",\n            \"cordage\",\n            \"corniche\",\n            \"corpus\",\n            \"correct\",\n            \"cortège\",\n            \"cosmique\",\n            \"costume\",\n            \"coton\",\n            \"coude\",\n            \"coupure\",\n            \"courage\",\n            \"couteau\",\n            \"couvrir\",\n            \"coyote\",\n            \"crabe\",\n            \"crainte\",\n            \"cravate\",\n            \"crayon\",\n            \"créature\",\n            \"créditer\",\n            \"crémeux\",\n            \"creuser\",\n            \"crevette\",\n            \"cribler\",\n            \"crier\",\n            \"cristal\",\n            \"critère\",\n            \"croire\",\n            \"croquer\",\n            \"crotale\",\n            \"crucial\",\n            \"cruel\",\n            \"crypter\",\n            \"cubique\",\n            \"cueillir\",\n            \"cuillère\",\n            \"cuisine\",\n            \"cuivre\",\n            \"culminer\",\n            \"cultiver\",\n            \"cumuler\",\n            \"cupide\",\n            \"curatif\",\n            \"curseur\",\n            \"cyanure\",\n            \"cycle\",\n            \"cylindre\",\n            \"cynique\",\n            \"daigner\",\n            \"damier\",\n            \"danger\",\n            \"danseur\",\n            \"dauphin\",\n            \"débattre\",\n            \"débiter\",\n            \"déborder\",\n            \"débrider\",\n            \"débutant\",\n            \"décaler\",\n            \"décembre\",\n            \"déchirer\",\n            \"décider\",\n            \"déclarer\",\n            \"décorer\",\n            \"décrire\",\n            \"décupler\",\n            \"dédale\",\n            \"déductif\",\n            \"déesse\",\n            \"défensif\",\n            \"défiler\",\n            \"défrayer\",\n            \"dégager\",\n            \"dégivrer\",\n            \"déglutir\",\n            \"dégrafer\",\n            \"déjeuner\",\n            \"délice\",\n            \"déloger\",\n            \"demander\",\n            \"demeurer\",\n            \"démolir\",\n            \"dénicher\",\n            \"dénouer\",\n            \"dentelle\",\n            \"dénuder\",\n            \"départ\",\n            \"dépenser\",\n            \"déphaser\",\n            \"déplacer\",\n            \"déposer\",\n            \"déranger\",\n            \"dérober\",\n            \"désastre\",\n            \"descente\",\n            \"désert\",\n            \"désigner\",\n            \"désobéir\",\n            \"dessiner\",\n            \"destrier\",\n            \"détacher\",\n            \"détester\",\n            \"détourer\",\n            \"détresse\",\n            \"devancer\",\n            \"devenir\",\n            \"deviner\",\n            \"devoir\",\n            \"diable\",\n            \"dialogue\",\n            \"diamant\",\n            \"dicter\",\n            \"différer\",\n            \"digérer\",\n            \"digital\",\n            \"digne\",\n            \"diluer\",\n            \"dimanche\",\n            \"diminuer\",\n            \"dioxyde\",\n            \"directif\",\n            \"diriger\",\n            \"discuter\",\n            \"disposer\",\n            \"dissiper\",\n            \"distance\",\n            \"divertir\",\n            \"diviser\",\n            \"docile\",\n            \"docteur\",\n            \"dogme\",\n            \"doigt\",\n            \"domaine\",\n            \"domicile\",\n            \"dompter\",\n            \"donateur\",\n            \"donjon\",\n            \"donner\",\n            \"dopamine\",\n            \"dortoir\",\n            \"dorure\",\n            \"dosage\",\n            \"doseur\",\n            \"dossier\",\n            \"dotation\",\n            \"douanier\",\n            \"double\",\n            \"douceur\",\n            \"douter\",\n            \"doyen\",\n            \"dragon\",\n            \"draper\",\n            \"dresser\",\n            \"dribbler\",\n            \"droiture\",\n            \"duperie\",\n            \"duplexe\",\n            \"durable\",\n            \"durcir\",\n            \"dynastie\",\n            \"éblouir\",\n            \"écarter\",\n            \"écharpe\",\n            \"échelle\",\n            \"éclairer\",\n            \"éclipse\",\n            \"éclore\",\n            \"écluse\",\n            \"école\",\n            \"économie\",\n            \"écorce\",\n            \"écouter\",\n            \"écraser\",\n            \"écrémer\",\n            \"écrivain\",\n            \"écrou\",\n            \"écume\",\n            \"écureuil\",\n            \"édifier\",\n            \"éduquer\",\n            \"effacer\",\n            \"effectif\",\n            \"effigie\",\n            \"effort\",\n            \"effrayer\",\n            \"effusion\",\n            \"égaliser\",\n            \"égarer\",\n            \"éjecter\",\n            \"élaborer\",\n            \"élargir\",\n            \"électron\",\n            \"élégant\",\n            \"éléphant\",\n            \"élève\",\n            \"éligible\",\n            \"élitisme\",\n            \"éloge\",\n            \"élucider\",\n            \"éluder\",\n            \"emballer\",\n            \"embellir\",\n            \"embryon\",\n            \"émeraude\",\n            \"émission\",\n            \"emmener\",\n            \"émotion\",\n            \"émouvoir\",\n            \"empereur\",\n            \"employer\",\n            \"emporter\",\n            \"emprise\",\n            \"émulsion\",\n            \"encadrer\",\n            \"enchère\",\n            \"enclave\",\n            \"encoche\",\n            \"endiguer\",\n            \"endosser\",\n            \"endroit\",\n            \"enduire\",\n            \"énergie\",\n            \"enfance\",\n            \"enfermer\",\n            \"enfouir\",\n            \"engager\",\n            \"engin\",\n            \"englober\",\n            \"énigme\",\n            \"enjamber\",\n            \"enjeu\",\n            \"enlever\",\n            \"ennemi\",\n            \"ennuyeux\",\n            \"enrichir\",\n            \"enrobage\",\n            \"enseigne\",\n            \"entasser\",\n            \"entendre\",\n            \"entier\",\n            \"entourer\",\n            \"entraver\",\n            \"énumérer\",\n            \"envahir\",\n            \"enviable\",\n            \"envoyer\",\n            \"enzyme\",\n            \"éolien\",\n            \"épaissir\",\n            \"épargne\",\n            \"épatant\",\n            \"épaule\",\n            \"épicerie\",\n            \"épidémie\",\n            \"épier\",\n            \"épilogue\",\n            \"épine\",\n            \"épisode\",\n            \"épitaphe\",\n            \"époque\",\n            \"épreuve\",\n            \"éprouver\",\n            \"épuisant\",\n            \"équerre\",\n            \"équipe\",\n            \"ériger\",\n            \"érosion\",\n            \"erreur\",\n            \"éruption\",\n            \"escalier\",\n            \"espadon\",\n            \"espèce\",\n            \"espiègle\",\n            \"espoir\",\n            \"esprit\",\n            \"esquiver\",\n            \"essayer\",\n            \"essence\",\n            \"essieu\",\n            \"essorer\",\n            \"estime\",\n            \"estomac\",\n            \"estrade\",\n            \"étagère\",\n            \"étaler\",\n            \"étanche\",\n            \"étatique\",\n            \"éteindre\",\n            \"étendoir\",\n            \"éternel\",\n            \"éthanol\",\n            \"éthique\",\n            \"ethnie\",\n            \"étirer\",\n            \"étoffer\",\n            \"étoile\",\n            \"étonnant\",\n            \"étourdir\",\n            \"étrange\",\n            \"étroit\",\n            \"étude\",\n            \"euphorie\",\n            \"évaluer\",\n            \"évasion\",\n            \"éventail\",\n            \"évidence\",\n            \"éviter\",\n            \"évolutif\",\n            \"évoquer\",\n            \"exact\",\n            \"exagérer\",\n            \"exaucer\",\n            \"exceller\",\n            \"excitant\",\n            \"exclusif\",\n            \"excuse\",\n            \"exécuter\",\n            \"exemple\",\n            \"exercer\",\n            \"exhaler\",\n            \"exhorter\",\n            \"exigence\",\n            \"exiler\",\n            \"exister\",\n            \"exotique\",\n            \"expédier\",\n            \"explorer\",\n            \"exposer\",\n            \"exprimer\",\n            \"exquis\",\n            \"extensif\",\n            \"extraire\",\n            \"exulter\",\n            \"fable\",\n            \"fabuleux\",\n            \"facette\",\n            \"facile\",\n            \"facture\",\n            \"faiblir\",\n            \"falaise\",\n            \"fameux\",\n            \"famille\",\n            \"farceur\",\n            \"farfelu\",\n            \"farine\",\n            \"farouche\",\n            \"fasciner\",\n            \"fatal\",\n            \"fatigue\",\n            \"faucon\",\n            \"fautif\",\n            \"faveur\",\n            \"favori\",\n            \"fébrile\",\n            \"féconder\",\n            \"fédérer\",\n            \"félin\",\n            \"femme\",\n            \"fémur\",\n            \"fendoir\",\n            \"féodal\",\n            \"fermer\",\n            \"féroce\",\n            \"ferveur\",\n            \"festival\",\n            \"feuille\",\n            \"feutre\",\n            \"février\",\n            \"fiasco\",\n            \"ficeler\",\n            \"fictif\",\n            \"fidèle\",\n            \"figure\",\n            \"filature\",\n            \"filetage\",\n            \"filière\",\n            \"filleul\",\n            \"filmer\",\n            \"filou\",\n            \"filtrer\",\n            \"financer\",\n            \"finir\",\n            \"fiole\",\n            \"firme\",\n            \"fissure\",\n            \"fixer\",\n            \"flairer\",\n            \"flamme\",\n            \"flasque\",\n            \"flatteur\",\n            \"fléau\",\n            \"flèche\",\n            \"fleur\",\n            \"flexion\",\n            \"flocon\",\n            \"flore\",\n            \"fluctuer\",\n            \"fluide\",\n            \"fluvial\",\n            \"folie\",\n            \"fonderie\",\n            \"fongible\",\n            \"fontaine\",\n            \"forcer\",\n            \"forgeron\",\n            \"formuler\",\n            \"fortune\",\n            \"fossile\",\n            \"foudre\",\n            \"fougère\",\n            \"fouiller\",\n            \"foulure\",\n            \"fourmi\",\n            \"fragile\",\n            \"fraise\",\n            \"franchir\",\n            \"frapper\",\n            \"frayeur\",\n            \"frégate\",\n            \"freiner\",\n            \"frelon\",\n            \"frémir\",\n            \"frénésie\",\n            \"frère\",\n            \"friable\",\n            \"friction\",\n            \"frisson\",\n            \"frivole\",\n            \"froid\",\n            \"fromage\",\n            \"frontal\",\n            \"frotter\",\n            \"fruit\",\n            \"fugitif\",\n            \"fuite\",\n            \"fureur\",\n            \"furieux\",\n            \"furtif\",\n            \"fusion\",\n            \"futur\",\n            \"gagner\",\n            \"galaxie\",\n            \"galerie\",\n            \"gambader\",\n            \"garantir\",\n            \"gardien\",\n            \"garnir\",\n            \"garrigue\",\n            \"gazelle\",\n            \"gazon\",\n            \"géant\",\n            \"gélatine\",\n            \"gélule\",\n            \"gendarme\",\n            \"général\",\n            \"génie\",\n            \"genou\",\n            \"gentil\",\n            \"géologie\",\n            \"géomètre\",\n            \"géranium\",\n            \"germe\",\n            \"gestuel\",\n            \"geyser\",\n            \"gibier\",\n            \"gicler\",\n            \"girafe\",\n            \"givre\",\n            \"glace\",\n            \"glaive\",\n            \"glisser\",\n            \"globe\",\n            \"gloire\",\n            \"glorieux\",\n            \"golfeur\",\n            \"gomme\",\n            \"gonfler\",\n            \"gorge\",\n            \"gorille\",\n            \"goudron\",\n            \"gouffre\",\n            \"goulot\",\n            \"goupille\",\n            \"gourmand\",\n            \"goutte\",\n            \"graduel\",\n            \"graffiti\",\n            \"graine\",\n            \"grand\",\n            \"grappin\",\n            \"gratuit\",\n            \"gravir\",\n            \"grenat\",\n            \"griffure\",\n            \"griller\",\n            \"grimper\",\n            \"grogner\",\n            \"gronder\",\n            \"grotte\",\n            \"groupe\",\n            \"gruger\",\n            \"grutier\",\n            \"gruyère\",\n            \"guépard\",\n            \"guerrier\",\n            \"guide\",\n            \"guimauve\",\n            \"guitare\",\n            \"gustatif\",\n            \"gymnaste\",\n            \"gyrostat\",\n            \"habitude\",\n            \"hachoir\",\n            \"halte\",\n            \"hameau\",\n            \"hangar\",\n            \"hanneton\",\n            \"haricot\",\n            \"harmonie\",\n            \"harpon\",\n            \"hasard\",\n            \"hélium\",\n            \"hématome\",\n            \"herbe\",\n            \"hérisson\",\n            \"hermine\",\n            \"héron\",\n            \"hésiter\",\n            \"heureux\",\n            \"hiberner\",\n            \"hibou\",\n            \"hilarant\",\n            \"histoire\",\n            \"hiver\",\n            \"homard\",\n            \"hommage\",\n            \"homogène\",\n            \"honneur\",\n            \"honorer\",\n            \"honteux\",\n            \"horde\",\n            \"horizon\",\n            \"horloge\",\n            \"hormone\",\n            \"horrible\",\n            \"houleux\",\n            \"housse\",\n            \"hublot\",\n            \"huileux\",\n            \"humain\",\n            \"humble\",\n            \"humide\",\n            \"humour\",\n            \"hurler\",\n            \"hydromel\",\n            \"hygiène\",\n            \"hymne\",\n            \"hypnose\",\n            \"idylle\",\n            \"ignorer\",\n            \"iguane\",\n            \"illicite\",\n            \"illusion\",\n            \"image\",\n            \"imbiber\",\n            \"imiter\",\n            \"immense\",\n            \"immobile\",\n            \"immuable\",\n            \"impact\",\n            \"impérial\",\n            \"implorer\",\n            \"imposer\",\n            \"imprimer\",\n            \"imputer\",\n            \"incarner\",\n            \"incendie\",\n            \"incident\",\n            \"incliner\",\n            \"incolore\",\n            \"indexer\",\n            \"indice\",\n            \"inductif\",\n            \"inédit\",\n            \"ineptie\",\n            \"inexact\",\n            \"infini\",\n            \"infliger\",\n            \"informer\",\n            \"infusion\",\n            \"ingérer\",\n            \"inhaler\",\n            \"inhiber\",\n            \"injecter\",\n            \"injure\",\n            \"innocent\",\n            \"inoculer\",\n            \"inonder\",\n            \"inscrire\",\n            \"insecte\",\n            \"insigne\",\n            \"insolite\",\n            \"inspirer\",\n            \"instinct\",\n            \"insulter\",\n            \"intact\",\n            \"intense\",\n            \"intime\",\n            \"intrigue\",\n            \"intuitif\",\n            \"inutile\",\n            \"invasion\",\n            \"inventer\",\n            \"inviter\",\n            \"invoquer\",\n            \"ironique\",\n            \"irradier\",\n            \"irréel\",\n            \"irriter\",\n            \"isoler\",\n            \"ivoire\",\n            \"ivresse\",\n            \"jaguar\",\n            \"jaillir\",\n            \"jambe\",\n            \"janvier\",\n            \"jardin\",\n            \"jauger\",\n            \"jaune\",\n            \"javelot\",\n            \"jetable\",\n            \"jeton\",\n            \"jeudi\",\n            \"jeunesse\",\n            \"joindre\",\n            \"joncher\",\n            \"jongler\",\n            \"joueur\",\n            \"jouissif\",\n            \"journal\",\n            \"jovial\",\n            \"joyau\",\n            \"joyeux\",\n            \"jubiler\",\n            \"jugement\",\n            \"junior\",\n            \"jupon\",\n            \"juriste\",\n            \"justice\",\n            \"juteux\",\n            \"juvénile\",\n            \"kayak\",\n            \"kimono\",\n            \"kiosque\",\n            \"label\",\n            \"labial\",\n            \"labourer\",\n            \"lacérer\",\n            \"lactose\",\n            \"lagune\",\n            \"laine\",\n            \"laisser\",\n            \"laitier\",\n            \"lambeau\",\n            \"lamelle\",\n            \"lampe\",\n            \"lanceur\",\n            \"langage\",\n            \"lanterne\",\n            \"lapin\",\n            \"largeur\",\n            \"larme\",\n            \"laurier\",\n            \"lavabo\",\n            \"lavoir\",\n            \"lecture\",\n            \"légal\",\n            \"léger\",\n            \"légume\",\n            \"lessive\",\n            \"lettre\",\n            \"levier\",\n            \"lexique\",\n            \"lézard\",\n            \"liasse\",\n            \"libérer\",\n            \"libre\",\n            \"licence\",\n            \"licorne\",\n            \"liège\",\n            \"lièvre\",\n            \"ligature\",\n            \"ligoter\",\n            \"ligue\",\n            \"limer\",\n            \"limite\",\n            \"limonade\",\n            \"limpide\",\n            \"linéaire\",\n            \"lingot\",\n            \"lionceau\",\n            \"liquide\",\n            \"lisière\",\n            \"lister\",\n            \"lithium\",\n            \"litige\",\n            \"littoral\",\n            \"livreur\",\n            \"logique\",\n            \"lointain\",\n            \"loisir\",\n            \"lombric\",\n            \"loterie\",\n            \"louer\",\n            \"lourd\",\n            \"loutre\",\n            \"louve\",\n            \"loyal\",\n            \"lubie\",\n            \"lucide\",\n            \"lucratif\",\n            \"lueur\",\n            \"lugubre\",\n            \"luisant\",\n            \"lumière\",\n            \"lunaire\",\n            \"lundi\",\n            \"luron\",\n            \"lutter\",\n            \"luxueux\",\n            \"machine\",\n            \"magasin\",\n            \"magenta\",\n            \"magique\",\n            \"maigre\",\n            \"maillon\",\n            \"maintien\",\n            \"mairie\",\n            \"maison\",\n            \"majorer\",\n            \"malaxer\",\n            \"maléfice\",\n            \"malheur\",\n            \"malice\",\n            \"mallette\",\n            \"mammouth\",\n            \"mandater\",\n            \"maniable\",\n            \"manquant\",\n            \"manteau\",\n            \"manuel\",\n            \"marathon\",\n            \"marbre\",\n            \"marchand\",\n            \"mardi\",\n            \"maritime\",\n            \"marqueur\",\n            \"marron\",\n            \"marteler\",\n            \"mascotte\",\n            \"massif\",\n            \"matériel\",\n            \"matière\",\n            \"matraque\",\n            \"maudire\",\n            \"maussade\",\n            \"mauve\",\n            \"maximal\",\n            \"méchant\",\n            \"méconnu\",\n            \"médaille\",\n            \"médecin\",\n            \"méditer\",\n            \"méduse\",\n            \"meilleur\",\n            \"mélange\",\n            \"mélodie\",\n            \"membre\",\n            \"mémoire\",\n            \"menacer\",\n            \"mener\",\n            \"menhir\",\n            \"mensonge\",\n            \"mentor\",\n            \"mercredi\",\n            \"mérite\",\n            \"merle\",\n            \"messager\",\n            \"mesure\",\n            \"métal\",\n            \"météore\",\n            \"méthode\",\n            \"métier\",\n            \"meuble\",\n            \"miauler\",\n            \"microbe\",\n            \"miette\",\n            \"mignon\",\n            \"migrer\",\n            \"milieu\",\n            \"million\",\n            \"mimique\",\n            \"mince\",\n            \"minéral\",\n            \"minimal\",\n            \"minorer\",\n            \"minute\",\n            \"miracle\",\n            \"miroiter\",\n            \"missile\",\n            \"mixte\",\n            \"mobile\",\n            \"moderne\",\n            \"moelleux\",\n            \"mondial\",\n            \"moniteur\",\n            \"monnaie\",\n            \"monotone\",\n            \"monstre\",\n            \"montagne\",\n            \"monument\",\n            \"moqueur\",\n            \"morceau\",\n            \"morsure\",\n            \"mortier\",\n            \"moteur\",\n            \"motif\",\n            \"mouche\",\n            \"moufle\",\n            \"moulin\",\n            \"mousson\",\n            \"mouton\",\n            \"mouvant\",\n            \"multiple\",\n            \"munition\",\n            \"muraille\",\n            \"murène\",\n            \"murmure\",\n            \"muscle\",\n            \"muséum\",\n            \"musicien\",\n            \"mutation\",\n            \"muter\",\n            \"mutuel\",\n            \"myriade\",\n            \"myrtille\",\n            \"mystère\",\n            \"mythique\",\n            \"nageur\",\n            \"nappe\",\n            \"narquois\",\n            \"narrer\",\n            \"natation\",\n            \"nation\",\n            \"nature\",\n            \"naufrage\",\n            \"nautique\",\n            \"navire\",\n            \"nébuleux\",\n            \"nectar\",\n            \"néfaste\",\n            \"négation\",\n            \"négliger\",\n            \"négocier\",\n            \"neige\",\n            \"nerveux\",\n            \"nettoyer\",\n            \"neurone\",\n            \"neutron\",\n            \"neveu\",\n            \"niche\",\n            \"nickel\",\n            \"nitrate\",\n            \"niveau\",\n            \"noble\",\n            \"nocif\",\n            \"nocturne\",\n            \"noirceur\",\n            \"noisette\",\n            \"nomade\",\n            \"nombreux\",\n            \"nommer\",\n            \"normatif\",\n            \"notable\",\n            \"notifier\",\n            \"notoire\",\n            \"nourrir\",\n            \"nouveau\",\n            \"novateur\",\n            \"novembre\",\n            \"novice\",\n            \"nuage\",\n            \"nuancer\",\n            \"nuire\",\n            \"nuisible\",\n            \"numéro\",\n            \"nuptial\",\n            \"nuque\",\n            \"nutritif\",\n            \"obéir\",\n            \"objectif\",\n            \"obliger\",\n            \"obscur\",\n            \"observer\",\n            \"obstacle\",\n            \"obtenir\",\n            \"obturer\",\n            \"occasion\",\n            \"occuper\",\n            \"océan\",\n            \"octobre\",\n            \"octroyer\",\n            \"octupler\",\n            \"oculaire\",\n            \"odeur\",\n            \"odorant\",\n            \"offenser\",\n            \"officier\",\n            \"offrir\",\n            \"ogive\",\n            \"oiseau\",\n            \"oisillon\",\n            \"olfactif\",\n            \"olivier\",\n            \"ombrage\",\n            \"omettre\",\n            \"onctueux\",\n            \"onduler\",\n            \"onéreux\",\n            \"onirique\",\n            \"opale\",\n            \"opaque\",\n            \"opérer\",\n            \"opinion\",\n            \"opportun\",\n            \"opprimer\",\n            \"opter\",\n            \"optique\",\n            \"orageux\",\n            \"orange\",\n            \"orbite\",\n            \"ordonner\",\n            \"oreille\",\n            \"organe\",\n            \"orgueil\",\n            \"orifice\",\n            \"ornement\",\n            \"orque\",\n            \"ortie\",\n            \"osciller\",\n            \"osmose\",\n            \"ossature\",\n            \"otarie\",\n            \"ouragan\",\n            \"ourson\",\n            \"outil\",\n            \"outrager\",\n            \"ouvrage\",\n            \"ovation\",\n            \"oxyde\",\n            \"oxygène\",\n            \"ozone\",\n            \"paisible\",\n            \"palace\",\n            \"palmarès\",\n            \"palourde\",\n            \"palper\",\n            \"panache\",\n            \"panda\",\n            \"pangolin\",\n            \"paniquer\",\n            \"panneau\",\n            \"panorama\",\n            \"pantalon\",\n            \"papaye\",\n            \"papier\",\n            \"papoter\",\n            \"papyrus\",\n            \"paradoxe\",\n            \"parcelle\",\n            \"paresse\",\n            \"parfumer\",\n            \"parler\",\n            \"parole\",\n            \"parrain\",\n            \"parsemer\",\n            \"partager\",\n            \"parure\",\n            \"parvenir\",\n            \"passion\",\n            \"pastèque\",\n            \"paternel\",\n            \"patience\",\n            \"patron\",\n            \"pavillon\",\n            \"pavoiser\",\n            \"payer\",\n            \"paysage\",\n            \"peigne\",\n            \"peintre\",\n            \"pelage\",\n            \"pélican\",\n            \"pelle\",\n            \"pelouse\",\n            \"peluche\",\n            \"pendule\",\n            \"pénétrer\",\n            \"pénible\",\n            \"pensif\",\n            \"pénurie\",\n            \"pépite\",\n            \"péplum\",\n            \"perdrix\",\n            \"perforer\",\n            \"période\",\n            \"permuter\",\n            \"perplexe\",\n            \"persil\",\n            \"perte\",\n            \"peser\",\n            \"pétale\",\n            \"petit\",\n            \"pétrir\",\n            \"peuple\",\n            \"pharaon\",\n            \"phobie\",\n            \"phoque\",\n            \"photon\",\n            \"phrase\",\n            \"physique\",\n            \"piano\",\n            \"pictural\",\n            \"pièce\",\n            \"pierre\",\n            \"pieuvre\",\n            \"pilote\",\n            \"pinceau\",\n            \"pipette\",\n            \"piquer\",\n            \"pirogue\",\n            \"piscine\",\n            \"piston\",\n            \"pivoter\",\n            \"pixel\",\n            \"pizza\",\n            \"placard\",\n            \"plafond\",\n            \"plaisir\",\n            \"planer\",\n            \"plaque\",\n            \"plastron\",\n            \"plateau\",\n            \"pleurer\",\n            \"plexus\",\n            \"pliage\",\n            \"plomb\",\n            \"plonger\",\n            \"pluie\",\n            \"plumage\",\n            \"pochette\",\n            \"poésie\",\n            \"poète\",\n            \"pointe\",\n            \"poirier\",\n            \"poisson\",\n            \"poivre\",\n            \"polaire\",\n            \"policier\",\n            \"pollen\",\n            \"polygone\",\n            \"pommade\",\n            \"pompier\",\n            \"ponctuel\",\n            \"pondérer\",\n            \"poney\",\n            \"portique\",\n            \"position\",\n            \"posséder\",\n            \"posture\",\n            \"potager\",\n            \"poteau\",\n            \"potion\",\n            \"pouce\",\n            \"poulain\",\n            \"poumon\",\n            \"pourpre\",\n            \"poussin\",\n            \"pouvoir\",\n            \"prairie\",\n            \"pratique\",\n            \"précieux\",\n            \"prédire\",\n            \"préfixe\",\n            \"prélude\",\n            \"prénom\",\n            \"présence\",\n            \"prétexte\",\n            \"prévoir\",\n            \"primitif\",\n            \"prince\",\n            \"prison\",\n            \"priver\",\n            \"problème\",\n            \"procéder\",\n            \"prodige\",\n            \"profond\",\n            \"progrès\",\n            \"proie\",\n            \"projeter\",\n            \"prologue\",\n            \"promener\",\n            \"propre\",\n            \"prospère\",\n            \"protéger\",\n            \"prouesse\",\n            \"proverbe\",\n            \"prudence\",\n            \"pruneau\",\n            \"psychose\",\n            \"public\",\n            \"puceron\",\n            \"puiser\",\n            \"pulpe\",\n            \"pulsar\",\n            \"punaise\",\n            \"punitif\",\n            \"pupitre\",\n            \"purifier\",\n            \"puzzle\",\n            \"pyramide\",\n            \"quasar\",\n            \"querelle\",\n            \"question\",\n            \"quiétude\",\n            \"quitter\",\n            \"quotient\",\n            \"racine\",\n            \"raconter\",\n            \"radieux\",\n            \"ragondin\",\n            \"raideur\",\n            \"raisin\",\n            \"ralentir\",\n            \"rallonge\",\n            \"ramasser\",\n            \"rapide\",\n            \"rasage\",\n            \"ratisser\",\n            \"ravager\",\n            \"ravin\",\n            \"rayonner\",\n            \"réactif\",\n            \"réagir\",\n            \"réaliser\",\n            \"réanimer\",\n            \"recevoir\",\n            \"réciter\",\n            \"réclamer\",\n            \"récolter\",\n            \"recruter\",\n            \"reculer\",\n            \"recycler\",\n            \"rédiger\",\n            \"redouter\",\n            \"refaire\",\n            \"réflexe\",\n            \"réformer\",\n            \"refrain\",\n            \"refuge\",\n            \"régalien\",\n            \"région\",\n            \"réglage\",\n            \"régulier\",\n            \"réitérer\",\n            \"rejeter\",\n            \"rejouer\",\n            \"relatif\",\n            \"relever\",\n            \"relief\",\n            \"remarque\",\n            \"remède\",\n            \"remise\",\n            \"remonter\",\n            \"remplir\",\n            \"remuer\",\n            \"renard\",\n            \"renfort\",\n            \"renifler\",\n            \"renoncer\",\n            \"rentrer\",\n            \"renvoi\",\n            \"replier\",\n            \"reporter\",\n            \"reprise\",\n            \"reptile\",\n            \"requin\",\n            \"réserve\",\n            \"résineux\",\n            \"résoudre\",\n            \"respect\",\n            \"rester\",\n            \"résultat\",\n            \"rétablir\",\n            \"retenir\",\n            \"réticule\",\n            \"retomber\",\n            \"retracer\",\n            \"réunion\",\n            \"réussir\",\n            \"revanche\",\n            \"revivre\",\n            \"révolte\",\n            \"révulsif\",\n            \"richesse\",\n            \"rideau\",\n            \"rieur\",\n            \"rigide\",\n            \"rigoler\",\n            \"rincer\",\n            \"riposter\",\n            \"risible\",\n            \"risque\",\n            \"rituel\",\n            \"rival\",\n            \"rivière\",\n            \"rocheux\",\n            \"romance\",\n            \"rompre\",\n            \"ronce\",\n            \"rondin\",\n            \"roseau\",\n            \"rosier\",\n            \"rotatif\",\n            \"rotor\",\n            \"rotule\",\n            \"rouge\",\n            \"rouille\",\n            \"rouleau\",\n            \"routine\",\n            \"royaume\",\n            \"ruban\",\n            \"rubis\",\n            \"ruche\",\n            \"ruelle\",\n            \"rugueux\",\n            \"ruiner\",\n            \"ruisseau\",\n            \"ruser\",\n            \"rustique\",\n            \"rythme\",\n            \"sabler\",\n            \"saboter\",\n            \"sabre\",\n            \"sacoche\",\n            \"safari\",\n            \"sagesse\",\n            \"saisir\",\n            \"salade\",\n            \"salive\",\n            \"salon\",\n            \"saluer\",\n            \"samedi\",\n            \"sanction\",\n            \"sanglier\",\n            \"sarcasme\",\n            \"sardine\",\n            \"saturer\",\n            \"saugrenu\",\n            \"saumon\",\n            \"sauter\",\n            \"sauvage\",\n            \"savant\",\n            \"savonner\",\n            \"scalpel\",\n            \"scandale\",\n            \"scélérat\",\n            \"scénario\",\n            \"sceptre\",\n            \"schéma\",\n            \"science\",\n            \"scinder\",\n            \"score\",\n            \"scrutin\",\n            \"sculpter\",\n            \"séance\",\n            \"sécable\",\n            \"sécher\",\n            \"secouer\",\n            \"sécréter\",\n            \"sédatif\",\n            \"séduire\",\n            \"seigneur\",\n            \"séjour\",\n            \"sélectif\",\n            \"semaine\",\n            \"sembler\",\n            \"semence\",\n            \"séminal\",\n            \"sénateur\",\n            \"sensible\",\n            \"sentence\",\n            \"séparer\",\n            \"séquence\",\n            \"serein\",\n            \"sergent\",\n            \"sérieux\",\n            \"serrure\",\n            \"sérum\",\n            \"service\",\n            \"sésame\",\n            \"sévir\",\n            \"sevrage\",\n            \"sextuple\",\n            \"sidéral\",\n            \"siècle\",\n            \"siéger\",\n            \"siffler\",\n            \"sigle\",\n            \"signal\",\n            \"silence\",\n            \"silicium\",\n            \"simple\",\n            \"sincère\",\n            \"sinistre\",\n            \"siphon\",\n            \"sirop\",\n            \"sismique\",\n            \"situer\",\n            \"skier\",\n            \"social\",\n            \"socle\",\n            \"sodium\",\n            \"soigneux\",\n            \"soldat\",\n            \"soleil\",\n            \"solitude\",\n            \"soluble\",\n            \"sombre\",\n            \"sommeil\",\n            \"somnoler\",\n            \"sonde\",\n            \"songeur\",\n            \"sonnette\",\n            \"sonore\",\n            \"sorcier\",\n            \"sortir\",\n            \"sosie\",\n            \"sottise\",\n            \"soucieux\",\n            \"soudure\",\n            \"souffle\",\n            \"soulever\",\n            \"soupape\",\n            \"source\",\n            \"soutirer\",\n            \"souvenir\",\n            \"spacieux\",\n            \"spatial\",\n            \"spécial\",\n            \"sphère\",\n            \"spiral\",\n            \"stable\",\n            \"station\",\n            \"sternum\",\n            \"stimulus\",\n            \"stipuler\",\n            \"strict\",\n            \"studieux\",\n            \"stupeur\",\n            \"styliste\",\n            \"sublime\",\n            \"substrat\",\n            \"subtil\",\n            \"subvenir\",\n            \"succès\",\n            \"sucre\",\n            \"suffixe\",\n            \"suggérer\",\n            \"suiveur\",\n            \"sulfate\",\n            \"superbe\",\n            \"supplier\",\n            \"surface\",\n            \"suricate\",\n            \"surmener\",\n            \"surprise\",\n            \"sursaut\",\n            \"survie\",\n            \"suspect\",\n            \"syllabe\",\n            \"symbole\",\n            \"symétrie\",\n            \"synapse\",\n            \"syntaxe\",\n            \"système\",\n            \"tabac\",\n            \"tablier\",\n            \"tactile\",\n            \"tailler\",\n            \"talent\",\n            \"talisman\",\n            \"talonner\",\n            \"tambour\",\n            \"tamiser\",\n            \"tangible\",\n            \"tapis\",\n            \"taquiner\",\n            \"tarder\",\n            \"tarif\",\n            \"tartine\",\n            \"tasse\",\n            \"tatami\",\n            \"tatouage\",\n            \"taupe\",\n            \"taureau\",\n            \"taxer\",\n            \"témoin\",\n            \"temporel\",\n            \"tenaille\",\n            \"tendre\",\n            \"teneur\",\n            \"tenir\",\n            \"tension\",\n            \"terminer\",\n            \"terne\",\n            \"terrible\",\n            \"tétine\",\n            \"texte\",\n            \"thème\",\n            \"théorie\",\n            \"thérapie\",\n            \"thorax\",\n            \"tibia\",\n            \"tiède\",\n            \"timide\",\n            \"tirelire\",\n            \"tiroir\",\n            \"tissu\",\n            \"titane\",\n            \"titre\",\n            \"tituber\",\n            \"toboggan\",\n            \"tolérant\",\n            \"tomate\",\n            \"tonique\",\n            \"tonneau\",\n            \"toponyme\",\n            \"torche\",\n            \"tordre\",\n            \"tornade\",\n            \"torpille\",\n            \"torrent\",\n            \"torse\",\n            \"tortue\",\n            \"totem\",\n            \"toucher\",\n            \"tournage\",\n            \"tousser\",\n            \"toxine\",\n            \"traction\",\n            \"trafic\",\n            \"tragique\",\n            \"trahir\",\n            \"train\",\n            \"trancher\",\n            \"travail\",\n            \"trèfle\",\n            \"tremper\",\n            \"trésor\",\n            \"treuil\",\n            \"triage\",\n            \"tribunal\",\n            \"tricoter\",\n            \"trilogie\",\n            \"triomphe\",\n            \"tripler\",\n            \"triturer\",\n            \"trivial\",\n            \"trombone\",\n            \"tronc\",\n            \"tropical\",\n            \"troupeau\",\n            \"tuile\",\n            \"tulipe\",\n            \"tumulte\",\n            \"tunnel\",\n            \"turbine\",\n            \"tuteur\",\n            \"tutoyer\",\n            \"tuyau\",\n            \"tympan\",\n            \"typhon\",\n            \"typique\",\n            \"tyran\",\n            \"ubuesque\",\n            \"ultime\",\n            \"ultrason\",\n            \"unanime\",\n            \"unifier\",\n            \"union\",\n            \"unique\",\n            \"unitaire\",\n            \"univers\",\n            \"uranium\",\n            \"urbain\",\n            \"urticant\",\n            \"usage\",\n            \"usine\",\n            \"usuel\",\n            \"usure\",\n            \"utile\",\n            \"utopie\",\n            \"vacarme\",\n            \"vaccin\",\n            \"vagabond\",\n            \"vague\",\n            \"vaillant\",\n            \"vaincre\",\n            \"vaisseau\",\n            \"valable\",\n            \"valise\",\n            \"vallon\",\n            \"valve\",\n            \"vampire\",\n            \"vanille\",\n            \"vapeur\",\n            \"varier\",\n            \"vaseux\",\n            \"vassal\",\n            \"vaste\",\n            \"vecteur\",\n            \"vedette\",\n            \"végétal\",\n            \"véhicule\",\n            \"veinard\",\n            \"véloce\",\n            \"vendredi\",\n            \"vénérer\",\n            \"venger\",\n            \"venimeux\",\n            \"ventouse\",\n            \"verdure\",\n            \"vérin\",\n            \"vernir\",\n            \"verrou\",\n            \"verser\",\n            \"vertu\",\n            \"veston\",\n            \"vétéran\",\n            \"vétuste\",\n            \"vexant\",\n            \"vexer\",\n            \"viaduc\",\n            \"viande\",\n            \"victoire\",\n            \"vidange\",\n            \"vidéo\",\n            \"vignette\",\n            \"vigueur\",\n            \"vilain\",\n            \"village\",\n            \"vinaigre\",\n            \"violon\",\n            \"vipère\",\n            \"virement\",\n            \"virtuose\",\n            \"virus\",\n            \"visage\",\n            \"viseur\",\n            \"vision\",\n            \"visqueux\",\n            \"visuel\",\n            \"vital\",\n            \"vitesse\",\n            \"viticole\",\n            \"vitrine\",\n            \"vivace\",\n            \"vivipare\",\n            \"vocation\",\n            \"voguer\",\n            \"voile\",\n            \"voisin\",\n            \"voiture\",\n            \"volaille\",\n            \"volcan\",\n            \"voltiger\",\n            \"volume\",\n            \"vorace\",\n            \"vortex\",\n            \"voter\",\n            \"vouloir\",\n            \"voyage\",\n            \"voyelle\",\n            \"wagon\",\n            \"xénon\",\n            \"yacht\",\n            \"zèbre\",\n            \"zénith\",\n            \"zeste\",\n            \"zoologie\"\n    };\n}"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/wordlists/Japanese.java",
    "content": "/*\n *  BIP39 library, a Java implementation of BIP39\n *  Copyright (C) 2017 Alan Evans, NovaCrypto\n *\n *  This program is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <https://www.gnu.org/licenses/>.\n *\n *  Original source: https://github.com/NovaCrypto/BIP39\n *  You can contact the authors via github issues.\n */\n\npackage com.quincysx.crypto.bip39.wordlists;\n\n\nimport com.quincysx.crypto.bip39.WordList;\n\n/**\n * Source: https://github.com/bitcoin/bips/blob/master/bip-0039/japanese.txt\n */\npublic enum Japanese implements WordList {\n    INSTANCE;\n\n    @Override\n    public String getWord(final int index) {\n        return words[index];\n    }\n\n    @Override\n    public int getIndex(final String word) {\n        int size = words.length;\n        if (word == null) {\n            for (int i = 0; i < size; i++)\n                if (words[i] == null)\n                    return i;\n        } else {\n            for (int i = 0; i < size; i++)\n                if (word.equals(words[i]))\n                    return i;\n        }\n        return -1;\n    }\n\n    @Override\n    public char getSpace() {\n        return '\\u3000'; //IDEOGRAPHIC SPACE\n    }\n\n    private final static String[] words = new String[]{\n            \"あいこくしん\",\n            \"あいさつ\",\n            \"あいだ\",\n            \"あおぞら\",\n            \"あかちゃん\",\n            \"あきる\",\n            \"あけがた\",\n            \"あける\",\n            \"あこがれる\",\n            \"あさい\",\n            \"あさひ\",\n            \"あしあと\",\n            \"あじわう\",\n            \"あずかる\",\n            \"あずき\",\n            \"あそぶ\",\n            \"あたえる\",\n            \"あたためる\",\n            \"あたりまえ\",\n            \"あたる\",\n            \"あつい\",\n            \"あつかう\",\n            \"あっしゅく\",\n            \"あつまり\",\n            \"あつめる\",\n            \"あてな\",\n            \"あてはまる\",\n            \"あひる\",\n            \"あぶら\",\n            \"あぶる\",\n            \"あふれる\",\n            \"あまい\",\n            \"あまど\",\n            \"あまやかす\",\n            \"あまり\",\n            \"あみもの\",\n            \"あめりか\",\n            \"あやまる\",\n            \"あゆむ\",\n            \"あらいぐま\",\n            \"あらし\",\n            \"あらすじ\",\n            \"あらためる\",\n            \"あらゆる\",\n            \"あらわす\",\n            \"ありがとう\",\n            \"あわせる\",\n            \"あわてる\",\n            \"あんい\",\n            \"あんがい\",\n            \"あんこ\",\n            \"あんぜん\",\n            \"あんてい\",\n            \"あんない\",\n            \"あんまり\",\n            \"いいだす\",\n            \"いおん\",\n            \"いがい\",\n            \"いがく\",\n            \"いきおい\",\n            \"いきなり\",\n            \"いきもの\",\n            \"いきる\",\n            \"いくじ\",\n            \"いくぶん\",\n            \"いけばな\",\n            \"いけん\",\n            \"いこう\",\n            \"いこく\",\n            \"いこつ\",\n            \"いさましい\",\n            \"いさん\",\n            \"いしき\",\n            \"いじゅう\",\n            \"いじょう\",\n            \"いじわる\",\n            \"いずみ\",\n            \"いずれ\",\n            \"いせい\",\n            \"いせえび\",\n            \"いせかい\",\n            \"いせき\",\n            \"いぜん\",\n            \"いそうろう\",\n            \"いそがしい\",\n            \"いだい\",\n            \"いだく\",\n            \"いたずら\",\n            \"いたみ\",\n            \"いたりあ\",\n            \"いちおう\",\n            \"いちじ\",\n            \"いちど\",\n            \"いちば\",\n            \"いちぶ\",\n            \"いちりゅう\",\n            \"いつか\",\n            \"いっしゅん\",\n            \"いっせい\",\n            \"いっそう\",\n            \"いったん\",\n            \"いっち\",\n            \"いってい\",\n            \"いっぽう\",\n            \"いてざ\",\n            \"いてん\",\n            \"いどう\",\n            \"いとこ\",\n            \"いない\",\n            \"いなか\",\n            \"いねむり\",\n            \"いのち\",\n            \"いのる\",\n            \"いはつ\",\n            \"いばる\",\n            \"いはん\",\n            \"いびき\",\n            \"いひん\",\n            \"いふく\",\n            \"いへん\",\n            \"いほう\",\n            \"いみん\",\n            \"いもうと\",\n            \"いもたれ\",\n            \"いもり\",\n            \"いやがる\",\n            \"いやす\",\n            \"いよかん\",\n            \"いよく\",\n            \"いらい\",\n            \"いらすと\",\n            \"いりぐち\",\n            \"いりょう\",\n            \"いれい\",\n            \"いれもの\",\n            \"いれる\",\n            \"いろえんぴつ\",\n            \"いわい\",\n            \"いわう\",\n            \"いわかん\",\n            \"いわば\",\n            \"いわゆる\",\n            \"いんげんまめ\",\n            \"いんさつ\",\n            \"いんしょう\",\n            \"いんよう\",\n            \"うえき\",\n            \"うえる\",\n            \"うおざ\",\n            \"うがい\",\n            \"うかぶ\",\n            \"うかべる\",\n            \"うきわ\",\n            \"うくらいな\",\n            \"うくれれ\",\n            \"うけたまわる\",\n            \"うけつけ\",\n            \"うけとる\",\n            \"うけもつ\",\n            \"うける\",\n            \"うごかす\",\n            \"うごく\",\n            \"うこん\",\n            \"うさぎ\",\n            \"うしなう\",\n            \"うしろがみ\",\n            \"うすい\",\n            \"うすぎ\",\n            \"うすぐらい\",\n            \"うすめる\",\n            \"うせつ\",\n            \"うちあわせ\",\n            \"うちがわ\",\n            \"うちき\",\n            \"うちゅう\",\n            \"うっかり\",\n            \"うつくしい\",\n            \"うったえる\",\n            \"うつる\",\n            \"うどん\",\n            \"うなぎ\",\n            \"うなじ\",\n            \"うなずく\",\n            \"うなる\",\n            \"うねる\",\n            \"うのう\",\n            \"うぶげ\",\n            \"うぶごえ\",\n            \"うまれる\",\n            \"うめる\",\n            \"うもう\",\n            \"うやまう\",\n            \"うよく\",\n            \"うらがえす\",\n            \"うらぐち\",\n            \"うらない\",\n            \"うりあげ\",\n            \"うりきれ\",\n            \"うるさい\",\n            \"うれしい\",\n            \"うれゆき\",\n            \"うれる\",\n            \"うろこ\",\n            \"うわき\",\n            \"うわさ\",\n            \"うんこう\",\n            \"うんちん\",\n            \"うんてん\",\n            \"うんどう\",\n            \"えいえん\",\n            \"えいが\",\n            \"えいきょう\",\n            \"えいご\",\n            \"えいせい\",\n            \"えいぶん\",\n            \"えいよう\",\n            \"えいわ\",\n            \"えおり\",\n            \"えがお\",\n            \"えがく\",\n            \"えきたい\",\n            \"えくせる\",\n            \"えしゃく\",\n            \"えすて\",\n            \"えつらん\",\n            \"えのぐ\",\n            \"えほうまき\",\n            \"えほん\",\n            \"えまき\",\n            \"えもじ\",\n            \"えもの\",\n            \"えらい\",\n            \"えらぶ\",\n            \"えりあ\",\n            \"えんえん\",\n            \"えんかい\",\n            \"えんぎ\",\n            \"えんげき\",\n            \"えんしゅう\",\n            \"えんぜつ\",\n            \"えんそく\",\n            \"えんちょう\",\n            \"えんとつ\",\n            \"おいかける\",\n            \"おいこす\",\n            \"おいしい\",\n            \"おいつく\",\n            \"おうえん\",\n            \"おうさま\",\n            \"おうじ\",\n            \"おうせつ\",\n            \"おうたい\",\n            \"おうふく\",\n            \"おうべい\",\n            \"おうよう\",\n            \"おえる\",\n            \"おおい\",\n            \"おおう\",\n            \"おおどおり\",\n            \"おおや\",\n            \"おおよそ\",\n            \"おかえり\",\n            \"おかず\",\n            \"おがむ\",\n            \"おかわり\",\n            \"おぎなう\",\n            \"おきる\",\n            \"おくさま\",\n            \"おくじょう\",\n            \"おくりがな\",\n            \"おくる\",\n            \"おくれる\",\n            \"おこす\",\n            \"おこなう\",\n            \"おこる\",\n            \"おさえる\",\n            \"おさない\",\n            \"おさめる\",\n            \"おしいれ\",\n            \"おしえる\",\n            \"おじぎ\",\n            \"おじさん\",\n            \"おしゃれ\",\n            \"おそらく\",\n            \"おそわる\",\n            \"おたがい\",\n            \"おたく\",\n            \"おだやか\",\n            \"おちつく\",\n            \"おっと\",\n            \"おつり\",\n            \"おでかけ\",\n            \"おとしもの\",\n            \"おとなしい\",\n            \"おどり\",\n            \"おどろかす\",\n            \"おばさん\",\n            \"おまいり\",\n            \"おめでとう\",\n            \"おもいで\",\n            \"おもう\",\n            \"おもたい\",\n            \"おもちゃ\",\n            \"おやつ\",\n            \"おやゆび\",\n            \"およぼす\",\n            \"おらんだ\",\n            \"おろす\",\n            \"おんがく\",\n            \"おんけい\",\n            \"おんしゃ\",\n            \"おんせん\",\n            \"おんだん\",\n            \"おんちゅう\",\n            \"おんどけい\",\n            \"かあつ\",\n            \"かいが\",\n            \"がいき\",\n            \"がいけん\",\n            \"がいこう\",\n            \"かいさつ\",\n            \"かいしゃ\",\n            \"かいすいよく\",\n            \"かいぜん\",\n            \"かいぞうど\",\n            \"かいつう\",\n            \"かいてん\",\n            \"かいとう\",\n            \"かいふく\",\n            \"がいへき\",\n            \"かいほう\",\n            \"かいよう\",\n            \"がいらい\",\n            \"かいわ\",\n            \"かえる\",\n            \"かおり\",\n            \"かかえる\",\n            \"かがく\",\n            \"かがし\",\n            \"かがみ\",\n            \"かくご\",\n            \"かくとく\",\n            \"かざる\",\n            \"がぞう\",\n            \"かたい\",\n            \"かたち\",\n            \"がちょう\",\n            \"がっきゅう\",\n            \"がっこう\",\n            \"がっさん\",\n            \"がっしょう\",\n            \"かなざわし\",\n            \"かのう\",\n            \"がはく\",\n            \"かぶか\",\n            \"かほう\",\n            \"かほご\",\n            \"かまう\",\n            \"かまぼこ\",\n            \"かめれおん\",\n            \"かゆい\",\n            \"かようび\",\n            \"からい\",\n            \"かるい\",\n            \"かろう\",\n            \"かわく\",\n            \"かわら\",\n            \"がんか\",\n            \"かんけい\",\n            \"かんこう\",\n            \"かんしゃ\",\n            \"かんそう\",\n            \"かんたん\",\n            \"かんち\",\n            \"がんばる\",\n            \"きあい\",\n            \"きあつ\",\n            \"きいろ\",\n            \"ぎいん\",\n            \"きうい\",\n            \"きうん\",\n            \"きえる\",\n            \"きおう\",\n            \"きおく\",\n            \"きおち\",\n            \"きおん\",\n            \"きかい\",\n            \"きかく\",\n            \"きかんしゃ\",\n            \"ききて\",\n            \"きくばり\",\n            \"きくらげ\",\n            \"きけんせい\",\n            \"きこう\",\n            \"きこえる\",\n            \"きこく\",\n            \"きさい\",\n            \"きさく\",\n            \"きさま\",\n            \"きさらぎ\",\n            \"ぎじかがく\",\n            \"ぎしき\",\n            \"ぎじたいけん\",\n            \"ぎじにってい\",\n            \"ぎじゅつしゃ\",\n            \"きすう\",\n            \"きせい\",\n            \"きせき\",\n            \"きせつ\",\n            \"きそう\",\n            \"きぞく\",\n            \"きぞん\",\n            \"きたえる\",\n            \"きちょう\",\n            \"きつえん\",\n            \"ぎっちり\",\n            \"きつつき\",\n            \"きつね\",\n            \"きてい\",\n            \"きどう\",\n            \"きどく\",\n            \"きない\",\n            \"きなが\",\n            \"きなこ\",\n            \"きぬごし\",\n            \"きねん\",\n            \"きのう\",\n            \"きのした\",\n            \"きはく\",\n            \"きびしい\",\n            \"きひん\",\n            \"きふく\",\n            \"きぶん\",\n            \"きぼう\",\n            \"きほん\",\n            \"きまる\",\n            \"きみつ\",\n            \"きむずかしい\",\n            \"きめる\",\n            \"きもだめし\",\n            \"きもち\",\n            \"きもの\",\n            \"きゃく\",\n            \"きやく\",\n            \"ぎゅうにく\",\n            \"きよう\",\n            \"きょうりゅう\",\n            \"きらい\",\n            \"きらく\",\n            \"きりん\",\n            \"きれい\",\n            \"きれつ\",\n            \"きろく\",\n            \"ぎろん\",\n            \"きわめる\",\n            \"ぎんいろ\",\n            \"きんかくじ\",\n            \"きんじょ\",\n            \"きんようび\",\n            \"ぐあい\",\n            \"くいず\",\n            \"くうかん\",\n            \"くうき\",\n            \"くうぐん\",\n            \"くうこう\",\n            \"ぐうせい\",\n            \"くうそう\",\n            \"ぐうたら\",\n            \"くうふく\",\n            \"くうぼ\",\n            \"くかん\",\n            \"くきょう\",\n            \"くげん\",\n            \"ぐこう\",\n            \"くさい\",\n            \"くさき\",\n            \"くさばな\",\n            \"くさる\",\n            \"くしゃみ\",\n            \"くしょう\",\n            \"くすのき\",\n            \"くすりゆび\",\n            \"くせげ\",\n            \"くせん\",\n            \"ぐたいてき\",\n            \"くださる\",\n            \"くたびれる\",\n            \"くちこみ\",\n            \"くちさき\",\n            \"くつした\",\n            \"ぐっすり\",\n            \"くつろぐ\",\n            \"くとうてん\",\n            \"くどく\",\n            \"くなん\",\n            \"くねくね\",\n            \"くのう\",\n            \"くふう\",\n            \"くみあわせ\",\n            \"くみたてる\",\n            \"くめる\",\n            \"くやくしょ\",\n            \"くらす\",\n            \"くらべる\",\n            \"くるま\",\n            \"くれる\",\n            \"くろう\",\n            \"くわしい\",\n            \"ぐんかん\",\n            \"ぐんしょく\",\n            \"ぐんたい\",\n            \"ぐんて\",\n            \"けあな\",\n            \"けいかく\",\n            \"けいけん\",\n            \"けいこ\",\n            \"けいさつ\",\n            \"げいじゅつ\",\n            \"けいたい\",\n            \"げいのうじん\",\n            \"けいれき\",\n            \"けいろ\",\n            \"けおとす\",\n            \"けおりもの\",\n            \"げきか\",\n            \"げきげん\",\n            \"げきだん\",\n            \"げきちん\",\n            \"げきとつ\",\n            \"げきは\",\n            \"げきやく\",\n            \"げこう\",\n            \"げこくじょう\",\n            \"げざい\",\n            \"けさき\",\n            \"げざん\",\n            \"けしき\",\n            \"けしごむ\",\n            \"けしょう\",\n            \"げすと\",\n            \"けたば\",\n            \"けちゃっぷ\",\n            \"けちらす\",\n            \"けつあつ\",\n            \"けつい\",\n            \"けつえき\",\n            \"けっこん\",\n            \"けつじょ\",\n            \"けっせき\",\n            \"けってい\",\n            \"けつまつ\",\n            \"げつようび\",\n            \"げつれい\",\n            \"けつろん\",\n            \"げどく\",\n            \"けとばす\",\n            \"けとる\",\n            \"けなげ\",\n            \"けなす\",\n            \"けなみ\",\n            \"けぬき\",\n            \"げねつ\",\n            \"けねん\",\n            \"けはい\",\n            \"げひん\",\n            \"けぶかい\",\n            \"げぼく\",\n            \"けまり\",\n            \"けみかる\",\n            \"けむし\",\n            \"けむり\",\n            \"けもの\",\n            \"けらい\",\n            \"けろけろ\",\n            \"けわしい\",\n            \"けんい\",\n            \"けんえつ\",\n            \"けんお\",\n            \"けんか\",\n            \"げんき\",\n            \"けんげん\",\n            \"けんこう\",\n            \"けんさく\",\n            \"けんしゅう\",\n            \"けんすう\",\n            \"げんそう\",\n            \"けんちく\",\n            \"けんてい\",\n            \"けんとう\",\n            \"けんない\",\n            \"けんにん\",\n            \"げんぶつ\",\n            \"けんま\",\n            \"けんみん\",\n            \"けんめい\",\n            \"けんらん\",\n            \"けんり\",\n            \"こあくま\",\n            \"こいぬ\",\n            \"こいびと\",\n            \"ごうい\",\n            \"こうえん\",\n            \"こうおん\",\n            \"こうかん\",\n            \"ごうきゅう\",\n            \"ごうけい\",\n            \"こうこう\",\n            \"こうさい\",\n            \"こうじ\",\n            \"こうすい\",\n            \"ごうせい\",\n            \"こうそく\",\n            \"こうたい\",\n            \"こうちゃ\",\n            \"こうつう\",\n            \"こうてい\",\n            \"こうどう\",\n            \"こうない\",\n            \"こうはい\",\n            \"ごうほう\",\n            \"ごうまん\",\n            \"こうもく\",\n            \"こうりつ\",\n            \"こえる\",\n            \"こおり\",\n            \"ごかい\",\n            \"ごがつ\",\n            \"ごかん\",\n            \"こくご\",\n            \"こくさい\",\n            \"こくとう\",\n            \"こくない\",\n            \"こくはく\",\n            \"こぐま\",\n            \"こけい\",\n            \"こける\",\n            \"ここのか\",\n            \"こころ\",\n            \"こさめ\",\n            \"こしつ\",\n            \"こすう\",\n            \"こせい\",\n            \"こせき\",\n            \"こぜん\",\n            \"こそだて\",\n            \"こたい\",\n            \"こたえる\",\n            \"こたつ\",\n            \"こちょう\",\n            \"こっか\",\n            \"こつこつ\",\n            \"こつばん\",\n            \"こつぶ\",\n            \"こてい\",\n            \"こてん\",\n            \"ことがら\",\n            \"ことし\",\n            \"ことば\",\n            \"ことり\",\n            \"こなごな\",\n            \"こねこね\",\n            \"このまま\",\n            \"このみ\",\n            \"このよ\",\n            \"ごはん\",\n            \"こひつじ\",\n            \"こふう\",\n            \"こふん\",\n            \"こぼれる\",\n            \"ごまあぶら\",\n            \"こまかい\",\n            \"ごますり\",\n            \"こまつな\",\n            \"こまる\",\n            \"こむぎこ\",\n            \"こもじ\",\n            \"こもち\",\n            \"こもの\",\n            \"こもん\",\n            \"こやく\",\n            \"こやま\",\n            \"こゆう\",\n            \"こゆび\",\n            \"こよい\",\n            \"こよう\",\n            \"こりる\",\n            \"これくしょん\",\n            \"ころっけ\",\n            \"こわもて\",\n            \"こわれる\",\n            \"こんいん\",\n            \"こんかい\",\n            \"こんき\",\n            \"こんしゅう\",\n            \"こんすい\",\n            \"こんだて\",\n            \"こんとん\",\n            \"こんなん\",\n            \"こんびに\",\n            \"こんぽん\",\n            \"こんまけ\",\n            \"こんや\",\n            \"こんれい\",\n            \"こんわく\",\n            \"ざいえき\",\n            \"さいかい\",\n            \"さいきん\",\n            \"ざいげん\",\n            \"ざいこ\",\n            \"さいしょ\",\n            \"さいせい\",\n            \"ざいたく\",\n            \"ざいちゅう\",\n            \"さいてき\",\n            \"ざいりょう\",\n            \"さうな\",\n            \"さかいし\",\n            \"さがす\",\n            \"さかな\",\n            \"さかみち\",\n            \"さがる\",\n            \"さぎょう\",\n            \"さくし\",\n            \"さくひん\",\n            \"さくら\",\n            \"さこく\",\n            \"さこつ\",\n            \"さずかる\",\n            \"ざせき\",\n            \"さたん\",\n            \"さつえい\",\n            \"ざつおん\",\n            \"ざっか\",\n            \"ざつがく\",\n            \"さっきょく\",\n            \"ざっし\",\n            \"さつじん\",\n            \"ざっそう\",\n            \"さつたば\",\n            \"さつまいも\",\n            \"さてい\",\n            \"さといも\",\n            \"さとう\",\n            \"さとおや\",\n            \"さとし\",\n            \"さとる\",\n            \"さのう\",\n            \"さばく\",\n            \"さびしい\",\n            \"さべつ\",\n            \"さほう\",\n            \"さほど\",\n            \"さます\",\n            \"さみしい\",\n            \"さみだれ\",\n            \"さむけ\",\n            \"さめる\",\n            \"さやえんどう\",\n            \"さゆう\",\n            \"さよう\",\n            \"さよく\",\n            \"さらだ\",\n            \"ざるそば\",\n            \"さわやか\",\n            \"さわる\",\n            \"さんいん\",\n            \"さんか\",\n            \"さんきゃく\",\n            \"さんこう\",\n            \"さんさい\",\n            \"ざんしょ\",\n            \"さんすう\",\n            \"さんせい\",\n            \"さんそ\",\n            \"さんち\",\n            \"さんま\",\n            \"さんみ\",\n            \"さんらん\",\n            \"しあい\",\n            \"しあげ\",\n            \"しあさって\",\n            \"しあわせ\",\n            \"しいく\",\n            \"しいん\",\n            \"しうち\",\n            \"しえい\",\n            \"しおけ\",\n            \"しかい\",\n            \"しかく\",\n            \"じかん\",\n            \"しごと\",\n            \"しすう\",\n            \"じだい\",\n            \"したうけ\",\n            \"したぎ\",\n            \"したて\",\n            \"したみ\",\n            \"しちょう\",\n            \"しちりん\",\n            \"しっかり\",\n            \"しつじ\",\n            \"しつもん\",\n            \"してい\",\n            \"してき\",\n            \"してつ\",\n            \"じてん\",\n            \"じどう\",\n            \"しなぎれ\",\n            \"しなもの\",\n            \"しなん\",\n            \"しねま\",\n            \"しねん\",\n            \"しのぐ\",\n            \"しのぶ\",\n            \"しはい\",\n            \"しばかり\",\n            \"しはつ\",\n            \"しはらい\",\n            \"しはん\",\n            \"しひょう\",\n            \"しふく\",\n            \"じぶん\",\n            \"しへい\",\n            \"しほう\",\n            \"しほん\",\n            \"しまう\",\n            \"しまる\",\n            \"しみん\",\n            \"しむける\",\n            \"じむしょ\",\n            \"しめい\",\n            \"しめる\",\n            \"しもん\",\n            \"しゃいん\",\n            \"しゃうん\",\n            \"しゃおん\",\n            \"じゃがいも\",\n            \"しやくしょ\",\n            \"しゃくほう\",\n            \"しゃけん\",\n            \"しゃこ\",\n            \"しゃざい\",\n            \"しゃしん\",\n            \"しゃせん\",\n            \"しゃそう\",\n            \"しゃたい\",\n            \"しゃちょう\",\n            \"しゃっきん\",\n            \"じゃま\",\n            \"しゃりん\",\n            \"しゃれい\",\n            \"じゆう\",\n            \"じゅうしょ\",\n            \"しゅくはく\",\n            \"じゅしん\",\n            \"しゅっせき\",\n            \"しゅみ\",\n            \"しゅらば\",\n            \"じゅんばん\",\n            \"しょうかい\",\n            \"しょくたく\",\n            \"しょっけん\",\n            \"しょどう\",\n            \"しょもつ\",\n            \"しらせる\",\n            \"しらべる\",\n            \"しんか\",\n            \"しんこう\",\n            \"じんじゃ\",\n            \"しんせいじ\",\n            \"しんちく\",\n            \"しんりん\",\n            \"すあげ\",\n            \"すあし\",\n            \"すあな\",\n            \"ずあん\",\n            \"すいえい\",\n            \"すいか\",\n            \"すいとう\",\n            \"ずいぶん\",\n            \"すいようび\",\n            \"すうがく\",\n            \"すうじつ\",\n            \"すうせん\",\n            \"すおどり\",\n            \"すきま\",\n            \"すくう\",\n            \"すくない\",\n            \"すける\",\n            \"すごい\",\n            \"すこし\",\n            \"ずさん\",\n            \"すずしい\",\n            \"すすむ\",\n            \"すすめる\",\n            \"すっかり\",\n            \"ずっしり\",\n            \"ずっと\",\n            \"すてき\",\n            \"すてる\",\n            \"すねる\",\n            \"すのこ\",\n            \"すはだ\",\n            \"すばらしい\",\n            \"ずひょう\",\n            \"ずぶぬれ\",\n            \"すぶり\",\n            \"すふれ\",\n            \"すべて\",\n            \"すべる\",\n            \"ずほう\",\n            \"すぼん\",\n            \"すまい\",\n            \"すめし\",\n            \"すもう\",\n            \"すやき\",\n            \"すらすら\",\n            \"するめ\",\n            \"すれちがう\",\n            \"すろっと\",\n            \"すわる\",\n            \"すんぜん\",\n            \"すんぽう\",\n            \"せあぶら\",\n            \"せいかつ\",\n            \"せいげん\",\n            \"せいじ\",\n            \"せいよう\",\n            \"せおう\",\n            \"せかいかん\",\n            \"せきにん\",\n            \"せきむ\",\n            \"せきゆ\",\n            \"せきらんうん\",\n            \"せけん\",\n            \"せこう\",\n            \"せすじ\",\n            \"せたい\",\n            \"せたけ\",\n            \"せっかく\",\n            \"せっきゃく\",\n            \"ぜっく\",\n            \"せっけん\",\n            \"せっこつ\",\n            \"せっさたくま\",\n            \"せつぞく\",\n            \"せつだん\",\n            \"せつでん\",\n            \"せっぱん\",\n            \"せつび\",\n            \"せつぶん\",\n            \"せつめい\",\n            \"せつりつ\",\n            \"せなか\",\n            \"せのび\",\n            \"せはば\",\n            \"せびろ\",\n            \"せぼね\",\n            \"せまい\",\n            \"せまる\",\n            \"せめる\",\n            \"せもたれ\",\n            \"せりふ\",\n            \"ぜんあく\",\n            \"せんい\",\n            \"せんえい\",\n            \"せんか\",\n            \"せんきょ\",\n            \"せんく\",\n            \"せんげん\",\n            \"ぜんご\",\n            \"せんさい\",\n            \"せんしゅ\",\n            \"せんすい\",\n            \"せんせい\",\n            \"せんぞ\",\n            \"せんたく\",\n            \"せんちょう\",\n            \"せんてい\",\n            \"せんとう\",\n            \"せんぬき\",\n            \"せんねん\",\n            \"せんぱい\",\n            \"ぜんぶ\",\n            \"ぜんぽう\",\n            \"せんむ\",\n            \"せんめんじょ\",\n            \"せんもん\",\n            \"せんやく\",\n            \"せんゆう\",\n            \"せんよう\",\n            \"ぜんら\",\n            \"ぜんりゃく\",\n            \"せんれい\",\n            \"せんろ\",\n            \"そあく\",\n            \"そいとげる\",\n            \"そいね\",\n            \"そうがんきょう\",\n            \"そうき\",\n            \"そうご\",\n            \"そうしん\",\n            \"そうだん\",\n            \"そうなん\",\n            \"そうび\",\n            \"そうめん\",\n            \"そうり\",\n            \"そえもの\",\n            \"そえん\",\n            \"そがい\",\n            \"そげき\",\n            \"そこう\",\n            \"そこそこ\",\n            \"そざい\",\n            \"そしな\",\n            \"そせい\",\n            \"そせん\",\n            \"そそぐ\",\n            \"そだてる\",\n            \"そつう\",\n            \"そつえん\",\n            \"そっかん\",\n            \"そつぎょう\",\n            \"そっけつ\",\n            \"そっこう\",\n            \"そっせん\",\n            \"そっと\",\n            \"そとがわ\",\n            \"そとづら\",\n            \"そなえる\",\n            \"そなた\",\n            \"そふぼ\",\n            \"そぼく\",\n            \"そぼろ\",\n            \"そまつ\",\n            \"そまる\",\n            \"そむく\",\n            \"そむりえ\",\n            \"そめる\",\n            \"そもそも\",\n            \"そよかぜ\",\n            \"そらまめ\",\n            \"そろう\",\n            \"そんかい\",\n            \"そんけい\",\n            \"そんざい\",\n            \"そんしつ\",\n            \"そんぞく\",\n            \"そんちょう\",\n            \"ぞんび\",\n            \"ぞんぶん\",\n            \"そんみん\",\n            \"たあい\",\n            \"たいいん\",\n            \"たいうん\",\n            \"たいえき\",\n            \"たいおう\",\n            \"だいがく\",\n            \"たいき\",\n            \"たいぐう\",\n            \"たいけん\",\n            \"たいこ\",\n            \"たいざい\",\n            \"だいじょうぶ\",\n            \"だいすき\",\n            \"たいせつ\",\n            \"たいそう\",\n            \"だいたい\",\n            \"たいちょう\",\n            \"たいてい\",\n            \"だいどころ\",\n            \"たいない\",\n            \"たいねつ\",\n            \"たいのう\",\n            \"たいはん\",\n            \"だいひょう\",\n            \"たいふう\",\n            \"たいへん\",\n            \"たいほ\",\n            \"たいまつばな\",\n            \"たいみんぐ\",\n            \"たいむ\",\n            \"たいめん\",\n            \"たいやき\",\n            \"たいよう\",\n            \"たいら\",\n            \"たいりょく\",\n            \"たいる\",\n            \"たいわん\",\n            \"たうえ\",\n            \"たえる\",\n            \"たおす\",\n            \"たおる\",\n            \"たおれる\",\n            \"たかい\",\n            \"たかね\",\n            \"たきび\",\n            \"たくさん\",\n            \"たこく\",\n            \"たこやき\",\n            \"たさい\",\n            \"たしざん\",\n            \"だじゃれ\",\n            \"たすける\",\n            \"たずさわる\",\n            \"たそがれ\",\n            \"たたかう\",\n            \"たたく\",\n            \"ただしい\",\n            \"たたみ\",\n            \"たちばな\",\n            \"だっかい\",\n            \"だっきゃく\",\n            \"だっこ\",\n            \"だっしゅつ\",\n            \"だったい\",\n            \"たてる\",\n            \"たとえる\",\n            \"たなばた\",\n            \"たにん\",\n            \"たぬき\",\n            \"たのしみ\",\n            \"たはつ\",\n            \"たぶん\",\n            \"たべる\",\n            \"たぼう\",\n            \"たまご\",\n            \"たまる\",\n            \"だむる\",\n            \"ためいき\",\n            \"ためす\",\n            \"ためる\",\n            \"たもつ\",\n            \"たやすい\",\n            \"たよる\",\n            \"たらす\",\n            \"たりきほんがん\",\n            \"たりょう\",\n            \"たりる\",\n            \"たると\",\n            \"たれる\",\n            \"たれんと\",\n            \"たろっと\",\n            \"たわむれる\",\n            \"だんあつ\",\n            \"たんい\",\n            \"たんおん\",\n            \"たんか\",\n            \"たんき\",\n            \"たんけん\",\n            \"たんご\",\n            \"たんさん\",\n            \"たんじょうび\",\n            \"だんせい\",\n            \"たんそく\",\n            \"たんたい\",\n            \"だんち\",\n            \"たんてい\",\n            \"たんとう\",\n            \"だんな\",\n            \"たんにん\",\n            \"だんねつ\",\n            \"たんのう\",\n            \"たんぴん\",\n            \"だんぼう\",\n            \"たんまつ\",\n            \"たんめい\",\n            \"だんれつ\",\n            \"だんろ\",\n            \"だんわ\",\n            \"ちあい\",\n            \"ちあん\",\n            \"ちいき\",\n            \"ちいさい\",\n            \"ちえん\",\n            \"ちかい\",\n            \"ちから\",\n            \"ちきゅう\",\n            \"ちきん\",\n            \"ちけいず\",\n            \"ちけん\",\n            \"ちこく\",\n            \"ちさい\",\n            \"ちしき\",\n            \"ちしりょう\",\n            \"ちせい\",\n            \"ちそう\",\n            \"ちたい\",\n            \"ちたん\",\n            \"ちちおや\",\n            \"ちつじょ\",\n            \"ちてき\",\n            \"ちてん\",\n            \"ちぬき\",\n            \"ちぬり\",\n            \"ちのう\",\n            \"ちひょう\",\n            \"ちへいせん\",\n            \"ちほう\",\n            \"ちまた\",\n            \"ちみつ\",\n            \"ちみどろ\",\n            \"ちめいど\",\n            \"ちゃんこなべ\",\n            \"ちゅうい\",\n            \"ちゆりょく\",\n            \"ちょうし\",\n            \"ちょさくけん\",\n            \"ちらし\",\n            \"ちらみ\",\n            \"ちりがみ\",\n            \"ちりょう\",\n            \"ちるど\",\n            \"ちわわ\",\n            \"ちんたい\",\n            \"ちんもく\",\n            \"ついか\",\n            \"ついたち\",\n            \"つうか\",\n            \"つうじょう\",\n            \"つうはん\",\n            \"つうわ\",\n            \"つかう\",\n            \"つかれる\",\n            \"つくね\",\n            \"つくる\",\n            \"つけね\",\n            \"つける\",\n            \"つごう\",\n            \"つたえる\",\n            \"つづく\",\n            \"つつじ\",\n            \"つつむ\",\n            \"つとめる\",\n            \"つながる\",\n            \"つなみ\",\n            \"つねづね\",\n            \"つのる\",\n            \"つぶす\",\n            \"つまらない\",\n            \"つまる\",\n            \"つみき\",\n            \"つめたい\",\n            \"つもり\",\n            \"つもる\",\n            \"つよい\",\n            \"つるぼ\",\n            \"つるみく\",\n            \"つわもの\",\n            \"つわり\",\n            \"てあし\",\n            \"てあて\",\n            \"てあみ\",\n            \"ていおん\",\n            \"ていか\",\n            \"ていき\",\n            \"ていけい\",\n            \"ていこく\",\n            \"ていさつ\",\n            \"ていし\",\n            \"ていせい\",\n            \"ていたい\",\n            \"ていど\",\n            \"ていねい\",\n            \"ていひょう\",\n            \"ていへん\",\n            \"ていぼう\",\n            \"てうち\",\n            \"ておくれ\",\n            \"てきとう\",\n            \"てくび\",\n            \"でこぼこ\",\n            \"てさぎょう\",\n            \"てさげ\",\n            \"てすり\",\n            \"てそう\",\n            \"てちがい\",\n            \"てちょう\",\n            \"てつがく\",\n            \"てつづき\",\n            \"でっぱ\",\n            \"てつぼう\",\n            \"てつや\",\n            \"でぬかえ\",\n            \"てぬき\",\n            \"てぬぐい\",\n            \"てのひら\",\n            \"てはい\",\n            \"てぶくろ\",\n            \"てふだ\",\n            \"てほどき\",\n            \"てほん\",\n            \"てまえ\",\n            \"てまきずし\",\n            \"てみじか\",\n            \"てみやげ\",\n            \"てらす\",\n            \"てれび\",\n            \"てわけ\",\n            \"てわたし\",\n            \"でんあつ\",\n            \"てんいん\",\n            \"てんかい\",\n            \"てんき\",\n            \"てんぐ\",\n            \"てんけん\",\n            \"てんごく\",\n            \"てんさい\",\n            \"てんし\",\n            \"てんすう\",\n            \"でんち\",\n            \"てんてき\",\n            \"てんとう\",\n            \"てんない\",\n            \"てんぷら\",\n            \"てんぼうだい\",\n            \"てんめつ\",\n            \"てんらんかい\",\n            \"でんりょく\",\n            \"でんわ\",\n            \"どあい\",\n            \"といれ\",\n            \"どうかん\",\n            \"とうきゅう\",\n            \"どうぐ\",\n            \"とうし\",\n            \"とうむぎ\",\n            \"とおい\",\n            \"とおか\",\n            \"とおく\",\n            \"とおす\",\n            \"とおる\",\n            \"とかい\",\n            \"とかす\",\n            \"ときおり\",\n            \"ときどき\",\n            \"とくい\",\n            \"とくしゅう\",\n            \"とくてん\",\n            \"とくに\",\n            \"とくべつ\",\n            \"とけい\",\n            \"とける\",\n            \"とこや\",\n            \"とさか\",\n            \"としょかん\",\n            \"とそう\",\n            \"とたん\",\n            \"とちゅう\",\n            \"とっきゅう\",\n            \"とっくん\",\n            \"とつぜん\",\n            \"とつにゅう\",\n            \"とどける\",\n            \"ととのえる\",\n            \"とない\",\n            \"となえる\",\n            \"となり\",\n            \"とのさま\",\n            \"とばす\",\n            \"どぶがわ\",\n            \"とほう\",\n            \"とまる\",\n            \"とめる\",\n            \"ともだち\",\n            \"ともる\",\n            \"どようび\",\n            \"とらえる\",\n            \"とんかつ\",\n            \"どんぶり\",\n            \"ないかく\",\n            \"ないこう\",\n            \"ないしょ\",\n            \"ないす\",\n            \"ないせん\",\n            \"ないそう\",\n            \"なおす\",\n            \"ながい\",\n            \"なくす\",\n            \"なげる\",\n            \"なこうど\",\n            \"なさけ\",\n            \"なたでここ\",\n            \"なっとう\",\n            \"なつやすみ\",\n            \"ななおし\",\n            \"なにごと\",\n            \"なにもの\",\n            \"なにわ\",\n            \"なのか\",\n            \"なふだ\",\n            \"なまいき\",\n            \"なまえ\",\n            \"なまみ\",\n            \"なみだ\",\n            \"なめらか\",\n            \"なめる\",\n            \"なやむ\",\n            \"ならう\",\n            \"ならび\",\n            \"ならぶ\",\n            \"なれる\",\n            \"なわとび\",\n            \"なわばり\",\n            \"にあう\",\n            \"にいがた\",\n            \"にうけ\",\n            \"におい\",\n            \"にかい\",\n            \"にがて\",\n            \"にきび\",\n            \"にくしみ\",\n            \"にくまん\",\n            \"にげる\",\n            \"にさんかたんそ\",\n            \"にしき\",\n            \"にせもの\",\n            \"にちじょう\",\n            \"にちようび\",\n            \"にっか\",\n            \"にっき\",\n            \"にっけい\",\n            \"にっこう\",\n            \"にっさん\",\n            \"にっしょく\",\n            \"にっすう\",\n            \"にっせき\",\n            \"にってい\",\n            \"になう\",\n            \"にほん\",\n            \"にまめ\",\n            \"にもつ\",\n            \"にやり\",\n            \"にゅういん\",\n            \"にりんしゃ\",\n            \"にわとり\",\n            \"にんい\",\n            \"にんか\",\n            \"にんき\",\n            \"にんげん\",\n            \"にんしき\",\n            \"にんずう\",\n            \"にんそう\",\n            \"にんたい\",\n            \"にんち\",\n            \"にんてい\",\n            \"にんにく\",\n            \"にんぷ\",\n            \"にんまり\",\n            \"にんむ\",\n            \"にんめい\",\n            \"にんよう\",\n            \"ぬいくぎ\",\n            \"ぬかす\",\n            \"ぬぐいとる\",\n            \"ぬぐう\",\n            \"ぬくもり\",\n            \"ぬすむ\",\n            \"ぬまえび\",\n            \"ぬめり\",\n            \"ぬらす\",\n            \"ぬんちゃく\",\n            \"ねあげ\",\n            \"ねいき\",\n            \"ねいる\",\n            \"ねいろ\",\n            \"ねぐせ\",\n            \"ねくたい\",\n            \"ねくら\",\n            \"ねこぜ\",\n            \"ねこむ\",\n            \"ねさげ\",\n            \"ねすごす\",\n            \"ねそべる\",\n            \"ねだん\",\n            \"ねつい\",\n            \"ねっしん\",\n            \"ねつぞう\",\n            \"ねったいぎょ\",\n            \"ねぶそく\",\n            \"ねふだ\",\n            \"ねぼう\",\n            \"ねほりはほり\",\n            \"ねまき\",\n            \"ねまわし\",\n            \"ねみみ\",\n            \"ねむい\",\n            \"ねむたい\",\n            \"ねもと\",\n            \"ねらう\",\n            \"ねわざ\",\n            \"ねんいり\",\n            \"ねんおし\",\n            \"ねんかん\",\n            \"ねんきん\",\n            \"ねんぐ\",\n            \"ねんざ\",\n            \"ねんし\",\n            \"ねんちゃく\",\n            \"ねんど\",\n            \"ねんぴ\",\n            \"ねんぶつ\",\n            \"ねんまつ\",\n            \"ねんりょう\",\n            \"ねんれい\",\n            \"のいず\",\n            \"のおづま\",\n            \"のがす\",\n            \"のきなみ\",\n            \"のこぎり\",\n            \"のこす\",\n            \"のこる\",\n            \"のせる\",\n            \"のぞく\",\n            \"のぞむ\",\n            \"のたまう\",\n            \"のちほど\",\n            \"のっく\",\n            \"のばす\",\n            \"のはら\",\n            \"のべる\",\n            \"のぼる\",\n            \"のみもの\",\n            \"のやま\",\n            \"のらいぬ\",\n            \"のらねこ\",\n            \"のりもの\",\n            \"のりゆき\",\n            \"のれん\",\n            \"のんき\",\n            \"ばあい\",\n            \"はあく\",\n            \"ばあさん\",\n            \"ばいか\",\n            \"ばいく\",\n            \"はいけん\",\n            \"はいご\",\n            \"はいしん\",\n            \"はいすい\",\n            \"はいせん\",\n            \"はいそう\",\n            \"はいち\",\n            \"ばいばい\",\n            \"はいれつ\",\n            \"はえる\",\n            \"はおる\",\n            \"はかい\",\n            \"ばかり\",\n            \"はかる\",\n            \"はくしゅ\",\n            \"はけん\",\n            \"はこぶ\",\n            \"はさみ\",\n            \"はさん\",\n            \"はしご\",\n            \"ばしょ\",\n            \"はしる\",\n            \"はせる\",\n            \"ぱそこん\",\n            \"はそん\",\n            \"はたん\",\n            \"はちみつ\",\n            \"はつおん\",\n            \"はっかく\",\n            \"はづき\",\n            \"はっきり\",\n            \"はっくつ\",\n            \"はっけん\",\n            \"はっこう\",\n            \"はっさん\",\n            \"はっしん\",\n            \"はったつ\",\n            \"はっちゅう\",\n            \"はってん\",\n            \"はっぴょう\",\n            \"はっぽう\",\n            \"はなす\",\n            \"はなび\",\n            \"はにかむ\",\n            \"はぶらし\",\n            \"はみがき\",\n            \"はむかう\",\n            \"はめつ\",\n            \"はやい\",\n            \"はやし\",\n            \"はらう\",\n            \"はろうぃん\",\n            \"はわい\",\n            \"はんい\",\n            \"はんえい\",\n            \"はんおん\",\n            \"はんかく\",\n            \"はんきょう\",\n            \"ばんぐみ\",\n            \"はんこ\",\n            \"はんしゃ\",\n            \"はんすう\",\n            \"はんだん\",\n            \"ぱんち\",\n            \"ぱんつ\",\n            \"はんてい\",\n            \"はんとし\",\n            \"はんのう\",\n            \"はんぱ\",\n            \"はんぶん\",\n            \"はんぺん\",\n            \"はんぼうき\",\n            \"はんめい\",\n            \"はんらん\",\n            \"はんろん\",\n            \"ひいき\",\n            \"ひうん\",\n            \"ひえる\",\n            \"ひかく\",\n            \"ひかり\",\n            \"ひかる\",\n            \"ひかん\",\n            \"ひくい\",\n            \"ひけつ\",\n            \"ひこうき\",\n            \"ひこく\",\n            \"ひさい\",\n            \"ひさしぶり\",\n            \"ひさん\",\n            \"びじゅつかん\",\n            \"ひしょ\",\n            \"ひそか\",\n            \"ひそむ\",\n            \"ひたむき\",\n            \"ひだり\",\n            \"ひたる\",\n            \"ひつぎ\",\n            \"ひっこし\",\n            \"ひっし\",\n            \"ひつじゅひん\",\n            \"ひっす\",\n            \"ひつぜん\",\n            \"ぴったり\",\n            \"ぴっちり\",\n            \"ひつよう\",\n            \"ひてい\",\n            \"ひとごみ\",\n            \"ひなまつり\",\n            \"ひなん\",\n            \"ひねる\",\n            \"ひはん\",\n            \"ひびく\",\n            \"ひひょう\",\n            \"ひほう\",\n            \"ひまわり\",\n            \"ひまん\",\n            \"ひみつ\",\n            \"ひめい\",\n            \"ひめじし\",\n            \"ひやけ\",\n            \"ひやす\",\n            \"ひよう\",\n            \"びょうき\",\n            \"ひらがな\",\n            \"ひらく\",\n            \"ひりつ\",\n            \"ひりょう\",\n            \"ひるま\",\n            \"ひるやすみ\",\n            \"ひれい\",\n            \"ひろい\",\n            \"ひろう\",\n            \"ひろき\",\n            \"ひろゆき\",\n            \"ひんかく\",\n            \"ひんけつ\",\n            \"ひんこん\",\n            \"ひんしゅ\",\n            \"ひんそう\",\n            \"ぴんち\",\n            \"ひんぱん\",\n            \"びんぼう\",\n            \"ふあん\",\n            \"ふいうち\",\n            \"ふうけい\",\n            \"ふうせん\",\n            \"ぷうたろう\",\n            \"ふうとう\",\n            \"ふうふ\",\n            \"ふえる\",\n            \"ふおん\",\n            \"ふかい\",\n            \"ふきん\",\n            \"ふくざつ\",\n            \"ふくぶくろ\",\n            \"ふこう\",\n            \"ふさい\",\n            \"ふしぎ\",\n            \"ふじみ\",\n            \"ふすま\",\n            \"ふせい\",\n            \"ふせぐ\",\n            \"ふそく\",\n            \"ぶたにく\",\n            \"ふたん\",\n            \"ふちょう\",\n            \"ふつう\",\n            \"ふつか\",\n            \"ふっかつ\",\n            \"ふっき\",\n            \"ふっこく\",\n            \"ぶどう\",\n            \"ふとる\",\n            \"ふとん\",\n            \"ふのう\",\n            \"ふはい\",\n            \"ふひょう\",\n            \"ふへん\",\n            \"ふまん\",\n            \"ふみん\",\n            \"ふめつ\",\n            \"ふめん\",\n            \"ふよう\",\n            \"ふりこ\",\n            \"ふりる\",\n            \"ふるい\",\n            \"ふんいき\",\n            \"ぶんがく\",\n            \"ぶんぐ\",\n            \"ふんしつ\",\n            \"ぶんせき\",\n            \"ふんそう\",\n            \"ぶんぽう\",\n            \"へいあん\",\n            \"へいおん\",\n            \"へいがい\",\n            \"へいき\",\n            \"へいげん\",\n            \"へいこう\",\n            \"へいさ\",\n            \"へいしゃ\",\n            \"へいせつ\",\n            \"へいそ\",\n            \"へいたく\",\n            \"へいてん\",\n            \"へいねつ\",\n            \"へいわ\",\n            \"へきが\",\n            \"へこむ\",\n            \"べにいろ\",\n            \"べにしょうが\",\n            \"へらす\",\n            \"へんかん\",\n            \"べんきょう\",\n            \"べんごし\",\n            \"へんさい\",\n            \"へんたい\",\n            \"べんり\",\n            \"ほあん\",\n            \"ほいく\",\n            \"ぼうぎょ\",\n            \"ほうこく\",\n            \"ほうそう\",\n            \"ほうほう\",\n            \"ほうもん\",\n            \"ほうりつ\",\n            \"ほえる\",\n            \"ほおん\",\n            \"ほかん\",\n            \"ほきょう\",\n            \"ぼきん\",\n            \"ほくろ\",\n            \"ほけつ\",\n            \"ほけん\",\n            \"ほこう\",\n            \"ほこる\",\n            \"ほしい\",\n            \"ほしつ\",\n            \"ほしゅ\",\n            \"ほしょう\",\n            \"ほせい\",\n            \"ほそい\",\n            \"ほそく\",\n            \"ほたて\",\n            \"ほたる\",\n            \"ぽちぶくろ\",\n            \"ほっきょく\",\n            \"ほっさ\",\n            \"ほったん\",\n            \"ほとんど\",\n            \"ほめる\",\n            \"ほんい\",\n            \"ほんき\",\n            \"ほんけ\",\n            \"ほんしつ\",\n            \"ほんやく\",\n            \"まいにち\",\n            \"まかい\",\n            \"まかせる\",\n            \"まがる\",\n            \"まける\",\n            \"まこと\",\n            \"まさつ\",\n            \"まじめ\",\n            \"ますく\",\n            \"まぜる\",\n            \"まつり\",\n            \"まとめ\",\n            \"まなぶ\",\n            \"まぬけ\",\n            \"まねく\",\n            \"まほう\",\n            \"まもる\",\n            \"まゆげ\",\n            \"まよう\",\n            \"まろやか\",\n            \"まわす\",\n            \"まわり\",\n            \"まわる\",\n            \"まんが\",\n            \"まんきつ\",\n            \"まんぞく\",\n            \"まんなか\",\n            \"みいら\",\n            \"みうち\",\n            \"みえる\",\n            \"みがく\",\n            \"みかた\",\n            \"みかん\",\n            \"みけん\",\n            \"みこん\",\n            \"みじかい\",\n            \"みすい\",\n            \"みすえる\",\n            \"みせる\",\n            \"みっか\",\n            \"みつかる\",\n            \"みつける\",\n            \"みてい\",\n            \"みとめる\",\n            \"みなと\",\n            \"みなみかさい\",\n            \"みねらる\",\n            \"みのう\",\n            \"みのがす\",\n            \"みほん\",\n            \"みもと\",\n            \"みやげ\",\n            \"みらい\",\n            \"みりょく\",\n            \"みわく\",\n            \"みんか\",\n            \"みんぞく\",\n            \"むいか\",\n            \"むえき\",\n            \"むえん\",\n            \"むかい\",\n            \"むかう\",\n            \"むかえ\",\n            \"むかし\",\n            \"むぎちゃ\",\n            \"むける\",\n            \"むげん\",\n            \"むさぼる\",\n            \"むしあつい\",\n            \"むしば\",\n            \"むじゅん\",\n            \"むしろ\",\n            \"むすう\",\n            \"むすこ\",\n            \"むすぶ\",\n            \"むすめ\",\n            \"むせる\",\n            \"むせん\",\n            \"むちゅう\",\n            \"むなしい\",\n            \"むのう\",\n            \"むやみ\",\n            \"むよう\",\n            \"むらさき\",\n            \"むりょう\",\n            \"むろん\",\n            \"めいあん\",\n            \"めいうん\",\n            \"めいえん\",\n            \"めいかく\",\n            \"めいきょく\",\n            \"めいさい\",\n            \"めいし\",\n            \"めいそう\",\n            \"めいぶつ\",\n            \"めいれい\",\n            \"めいわく\",\n            \"めぐまれる\",\n            \"めざす\",\n            \"めした\",\n            \"めずらしい\",\n            \"めだつ\",\n            \"めまい\",\n            \"めやす\",\n            \"めんきょ\",\n            \"めんせき\",\n            \"めんどう\",\n            \"もうしあげる\",\n            \"もうどうけん\",\n            \"もえる\",\n            \"もくし\",\n            \"もくてき\",\n            \"もくようび\",\n            \"もちろん\",\n            \"もどる\",\n            \"もらう\",\n            \"もんく\",\n            \"もんだい\",\n            \"やおや\",\n            \"やける\",\n            \"やさい\",\n            \"やさしい\",\n            \"やすい\",\n            \"やすたろう\",\n            \"やすみ\",\n            \"やせる\",\n            \"やそう\",\n            \"やたい\",\n            \"やちん\",\n            \"やっと\",\n            \"やっぱり\",\n            \"やぶる\",\n            \"やめる\",\n            \"ややこしい\",\n            \"やよい\",\n            \"やわらかい\",\n            \"ゆうき\",\n            \"ゆうびんきょく\",\n            \"ゆうべ\",\n            \"ゆうめい\",\n            \"ゆけつ\",\n            \"ゆしゅつ\",\n            \"ゆせん\",\n            \"ゆそう\",\n            \"ゆたか\",\n            \"ゆちゃく\",\n            \"ゆでる\",\n            \"ゆにゅう\",\n            \"ゆびわ\",\n            \"ゆらい\",\n            \"ゆれる\",\n            \"ようい\",\n            \"ようか\",\n            \"ようきゅう\",\n            \"ようじ\",\n            \"ようす\",\n            \"ようちえん\",\n            \"よかぜ\",\n            \"よかん\",\n            \"よきん\",\n            \"よくせい\",\n            \"よくぼう\",\n            \"よけい\",\n            \"よごれる\",\n            \"よさん\",\n            \"よしゅう\",\n            \"よそう\",\n            \"よそく\",\n            \"よっか\",\n            \"よてい\",\n            \"よどがわく\",\n            \"よねつ\",\n            \"よやく\",\n            \"よゆう\",\n            \"よろこぶ\",\n            \"よろしい\",\n            \"らいう\",\n            \"らくがき\",\n            \"らくご\",\n            \"らくさつ\",\n            \"らくだ\",\n            \"らしんばん\",\n            \"らせん\",\n            \"らぞく\",\n            \"らたい\",\n            \"らっか\",\n            \"られつ\",\n            \"りえき\",\n            \"りかい\",\n            \"りきさく\",\n            \"りきせつ\",\n            \"りくぐん\",\n            \"りくつ\",\n            \"りけん\",\n            \"りこう\",\n            \"りせい\",\n            \"りそう\",\n            \"りそく\",\n            \"りてん\",\n            \"りねん\",\n            \"りゆう\",\n            \"りゅうがく\",\n            \"りよう\",\n            \"りょうり\",\n            \"りょかん\",\n            \"りょくちゃ\",\n            \"りょこう\",\n            \"りりく\",\n            \"りれき\",\n            \"りろん\",\n            \"りんご\",\n            \"るいけい\",\n            \"るいさい\",\n            \"るいじ\",\n            \"るいせき\",\n            \"るすばん\",\n            \"るりがわら\",\n            \"れいかん\",\n            \"れいぎ\",\n            \"れいせい\",\n            \"れいぞうこ\",\n            \"れいとう\",\n            \"れいぼう\",\n            \"れきし\",\n            \"れきだい\",\n            \"れんあい\",\n            \"れんけい\",\n            \"れんこん\",\n            \"れんさい\",\n            \"れんしゅう\",\n            \"れんぞく\",\n            \"れんらく\",\n            \"ろうか\",\n            \"ろうご\",\n            \"ろうじん\",\n            \"ろうそく\",\n            \"ろくが\",\n            \"ろこつ\",\n            \"ろじうら\",\n            \"ろしゅつ\",\n            \"ろせん\",\n            \"ろてん\",\n            \"ろめん\",\n            \"ろれつ\",\n            \"ろんぎ\",\n            \"ろんぱ\",\n            \"ろんぶん\",\n            \"ろんり\",\n            \"わかす\",\n            \"わかめ\",\n            \"わかやま\",\n            \"わかれる\",\n            \"わしつ\",\n            \"わじまし\",\n            \"わすれもの\",\n            \"わらう\",\n            \"われる\"\n    };\n}"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip39/wordlists/Spanish.java",
    "content": "/*\n *  BIP39 library, a Java implementation of BIP39\n *  Copyright (C) 2017 Alan Evans, NovaCrypto\n *\n *  This program is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <https://www.gnu.org/licenses/>.\n *\n *  Original source: https://github.com/NovaCrypto/BIP39\n *  You can contact the authors via github issues.\n */\n\npackage com.quincysx.crypto.bip39.wordlists;\n\n\nimport com.quincysx.crypto.bip39.WordList;\n\n/**\n * Source: https://github.com/bitcoin/bips/blob/master/bip-0039/spanish.txt\n */\npublic enum Spanish implements WordList {\n    INSTANCE;\n\n    @Override\n    public String getWord(final int index) {\n        return words[index];\n    }\n\n    @Override\n    public int getIndex(final String word) {\n        int size = words.length;\n        if (word == null) {\n            for (int i = 0; i < size; i++)\n                if (words[i] == null)\n                    return i;\n        } else {\n            for (int i = 0; i < size; i++)\n                if (word.equals(words[i]))\n                    return i;\n        }\n        return -1;\n    }\n\n    @Override\n    public char getSpace() {\n        return ' ';\n    }\n\n    private final static String[] words = new String[]{\n            \"ábaco\",\n            \"abdomen\",\n            \"abeja\",\n            \"abierto\",\n            \"abogado\",\n            \"abono\",\n            \"aborto\",\n            \"abrazo\",\n            \"abrir\",\n            \"abuelo\",\n            \"abuso\",\n            \"acabar\",\n            \"academia\",\n            \"acceso\",\n            \"acción\",\n            \"aceite\",\n            \"acelga\",\n            \"acento\",\n            \"aceptar\",\n            \"ácido\",\n            \"aclarar\",\n            \"acné\",\n            \"acoger\",\n            \"acoso\",\n            \"activo\",\n            \"acto\",\n            \"actriz\",\n            \"actuar\",\n            \"acudir\",\n            \"acuerdo\",\n            \"acusar\",\n            \"adicto\",\n            \"admitir\",\n            \"adoptar\",\n            \"adorno\",\n            \"aduana\",\n            \"adulto\",\n            \"aéreo\",\n            \"afectar\",\n            \"afición\",\n            \"afinar\",\n            \"afirmar\",\n            \"ágil\",\n            \"agitar\",\n            \"agonía\",\n            \"agosto\",\n            \"agotar\",\n            \"agregar\",\n            \"agrio\",\n            \"agua\",\n            \"agudo\",\n            \"águila\",\n            \"aguja\",\n            \"ahogo\",\n            \"ahorro\",\n            \"aire\",\n            \"aislar\",\n            \"ajedrez\",\n            \"ajeno\",\n            \"ajuste\",\n            \"alacrán\",\n            \"alambre\",\n            \"alarma\",\n            \"alba\",\n            \"álbum\",\n            \"alcalde\",\n            \"aldea\",\n            \"alegre\",\n            \"alejar\",\n            \"alerta\",\n            \"aleta\",\n            \"alfiler\",\n            \"alga\",\n            \"algodón\",\n            \"aliado\",\n            \"aliento\",\n            \"alivio\",\n            \"alma\",\n            \"almeja\",\n            \"almíbar\",\n            \"altar\",\n            \"alteza\",\n            \"altivo\",\n            \"alto\",\n            \"altura\",\n            \"alumno\",\n            \"alzar\",\n            \"amable\",\n            \"amante\",\n            \"amapola\",\n            \"amargo\",\n            \"amasar\",\n            \"ámbar\",\n            \"ámbito\",\n            \"ameno\",\n            \"amigo\",\n            \"amistad\",\n            \"amor\",\n            \"amparo\",\n            \"amplio\",\n            \"ancho\",\n            \"anciano\",\n            \"ancla\",\n            \"andar\",\n            \"andén\",\n            \"anemia\",\n            \"ángulo\",\n            \"anillo\",\n            \"ánimo\",\n            \"anís\",\n            \"anotar\",\n            \"antena\",\n            \"antiguo\",\n            \"antojo\",\n            \"anual\",\n            \"anular\",\n            \"anuncio\",\n            \"añadir\",\n            \"añejo\",\n            \"año\",\n            \"apagar\",\n            \"aparato\",\n            \"apetito\",\n            \"apio\",\n            \"aplicar\",\n            \"apodo\",\n            \"aporte\",\n            \"apoyo\",\n            \"aprender\",\n            \"aprobar\",\n            \"apuesta\",\n            \"apuro\",\n            \"arado\",\n            \"araña\",\n            \"arar\",\n            \"árbitro\",\n            \"árbol\",\n            \"arbusto\",\n            \"archivo\",\n            \"arco\",\n            \"arder\",\n            \"ardilla\",\n            \"arduo\",\n            \"área\",\n            \"árido\",\n            \"aries\",\n            \"armonía\",\n            \"arnés\",\n            \"aroma\",\n            \"arpa\",\n            \"arpón\",\n            \"arreglo\",\n            \"arroz\",\n            \"arruga\",\n            \"arte\",\n            \"artista\",\n            \"asa\",\n            \"asado\",\n            \"asalto\",\n            \"ascenso\",\n            \"asegurar\",\n            \"aseo\",\n            \"asesor\",\n            \"asiento\",\n            \"asilo\",\n            \"asistir\",\n            \"asno\",\n            \"asombro\",\n            \"áspero\",\n            \"astilla\",\n            \"astro\",\n            \"astuto\",\n            \"asumir\",\n            \"asunto\",\n            \"atajo\",\n            \"ataque\",\n            \"atar\",\n            \"atento\",\n            \"ateo\",\n            \"ático\",\n            \"atleta\",\n            \"átomo\",\n            \"atraer\",\n            \"atroz\",\n            \"atún\",\n            \"audaz\",\n            \"audio\",\n            \"auge\",\n            \"aula\",\n            \"aumento\",\n            \"ausente\",\n            \"autor\",\n            \"aval\",\n            \"avance\",\n            \"avaro\",\n            \"ave\",\n            \"avellana\",\n            \"avena\",\n            \"avestruz\",\n            \"avión\",\n            \"aviso\",\n            \"ayer\",\n            \"ayuda\",\n            \"ayuno\",\n            \"azafrán\",\n            \"azar\",\n            \"azote\",\n            \"azúcar\",\n            \"azufre\",\n            \"azul\",\n            \"baba\",\n            \"babor\",\n            \"bache\",\n            \"bahía\",\n            \"baile\",\n            \"bajar\",\n            \"balanza\",\n            \"balcón\",\n            \"balde\",\n            \"bambú\",\n            \"banco\",\n            \"banda\",\n            \"baño\",\n            \"barba\",\n            \"barco\",\n            \"barniz\",\n            \"barro\",\n            \"báscula\",\n            \"bastón\",\n            \"basura\",\n            \"batalla\",\n            \"batería\",\n            \"batir\",\n            \"batuta\",\n            \"baúl\",\n            \"bazar\",\n            \"bebé\",\n            \"bebida\",\n            \"bello\",\n            \"besar\",\n            \"beso\",\n            \"bestia\",\n            \"bicho\",\n            \"bien\",\n            \"bingo\",\n            \"blanco\",\n            \"bloque\",\n            \"blusa\",\n            \"boa\",\n            \"bobina\",\n            \"bobo\",\n            \"boca\",\n            \"bocina\",\n            \"boda\",\n            \"bodega\",\n            \"boina\",\n            \"bola\",\n            \"bolero\",\n            \"bolsa\",\n            \"bomba\",\n            \"bondad\",\n            \"bonito\",\n            \"bono\",\n            \"bonsái\",\n            \"borde\",\n            \"borrar\",\n            \"bosque\",\n            \"bote\",\n            \"botín\",\n            \"bóveda\",\n            \"bozal\",\n            \"bravo\",\n            \"brazo\",\n            \"brecha\",\n            \"breve\",\n            \"brillo\",\n            \"brinco\",\n            \"brisa\",\n            \"broca\",\n            \"broma\",\n            \"bronce\",\n            \"brote\",\n            \"bruja\",\n            \"brusco\",\n            \"bruto\",\n            \"buceo\",\n            \"bucle\",\n            \"bueno\",\n            \"buey\",\n            \"bufanda\",\n            \"bufón\",\n            \"búho\",\n            \"buitre\",\n            \"bulto\",\n            \"burbuja\",\n            \"burla\",\n            \"burro\",\n            \"buscar\",\n            \"butaca\",\n            \"buzón\",\n            \"caballo\",\n            \"cabeza\",\n            \"cabina\",\n            \"cabra\",\n            \"cacao\",\n            \"cadáver\",\n            \"cadena\",\n            \"caer\",\n            \"café\",\n            \"caída\",\n            \"caimán\",\n            \"caja\",\n            \"cajón\",\n            \"cal\",\n            \"calamar\",\n            \"calcio\",\n            \"caldo\",\n            \"calidad\",\n            \"calle\",\n            \"calma\",\n            \"calor\",\n            \"calvo\",\n            \"cama\",\n            \"cambio\",\n            \"camello\",\n            \"camino\",\n            \"campo\",\n            \"cáncer\",\n            \"candil\",\n            \"canela\",\n            \"canguro\",\n            \"canica\",\n            \"canto\",\n            \"caña\",\n            \"cañón\",\n            \"caoba\",\n            \"caos\",\n            \"capaz\",\n            \"capitán\",\n            \"capote\",\n            \"captar\",\n            \"capucha\",\n            \"cara\",\n            \"carbón\",\n            \"cárcel\",\n            \"careta\",\n            \"carga\",\n            \"cariño\",\n            \"carne\",\n            \"carpeta\",\n            \"carro\",\n            \"carta\",\n            \"casa\",\n            \"casco\",\n            \"casero\",\n            \"caspa\",\n            \"castor\",\n            \"catorce\",\n            \"catre\",\n            \"caudal\",\n            \"causa\",\n            \"cazo\",\n            \"cebolla\",\n            \"ceder\",\n            \"cedro\",\n            \"celda\",\n            \"célebre\",\n            \"celoso\",\n            \"célula\",\n            \"cemento\",\n            \"ceniza\",\n            \"centro\",\n            \"cerca\",\n            \"cerdo\",\n            \"cereza\",\n            \"cero\",\n            \"cerrar\",\n            \"certeza\",\n            \"césped\",\n            \"cetro\",\n            \"chacal\",\n            \"chaleco\",\n            \"champú\",\n            \"chancla\",\n            \"chapa\",\n            \"charla\",\n            \"chico\",\n            \"chiste\",\n            \"chivo\",\n            \"choque\",\n            \"choza\",\n            \"chuleta\",\n            \"chupar\",\n            \"ciclón\",\n            \"ciego\",\n            \"cielo\",\n            \"cien\",\n            \"cierto\",\n            \"cifra\",\n            \"cigarro\",\n            \"cima\",\n            \"cinco\",\n            \"cine\",\n            \"cinta\",\n            \"ciprés\",\n            \"circo\",\n            \"ciruela\",\n            \"cisne\",\n            \"cita\",\n            \"ciudad\",\n            \"clamor\",\n            \"clan\",\n            \"claro\",\n            \"clase\",\n            \"clave\",\n            \"cliente\",\n            \"clima\",\n            \"clínica\",\n            \"cobre\",\n            \"cocción\",\n            \"cochino\",\n            \"cocina\",\n            \"coco\",\n            \"código\",\n            \"codo\",\n            \"cofre\",\n            \"coger\",\n            \"cohete\",\n            \"cojín\",\n            \"cojo\",\n            \"cola\",\n            \"colcha\",\n            \"colegio\",\n            \"colgar\",\n            \"colina\",\n            \"collar\",\n            \"colmo\",\n            \"columna\",\n            \"combate\",\n            \"comer\",\n            \"comida\",\n            \"cómodo\",\n            \"compra\",\n            \"conde\",\n            \"conejo\",\n            \"conga\",\n            \"conocer\",\n            \"consejo\",\n            \"contar\",\n            \"copa\",\n            \"copia\",\n            \"corazón\",\n            \"corbata\",\n            \"corcho\",\n            \"cordón\",\n            \"corona\",\n            \"correr\",\n            \"coser\",\n            \"cosmos\",\n            \"costa\",\n            \"cráneo\",\n            \"cráter\",\n            \"crear\",\n            \"crecer\",\n            \"creído\",\n            \"crema\",\n            \"cría\",\n            \"crimen\",\n            \"cripta\",\n            \"crisis\",\n            \"cromo\",\n            \"crónica\",\n            \"croqueta\",\n            \"crudo\",\n            \"cruz\",\n            \"cuadro\",\n            \"cuarto\",\n            \"cuatro\",\n            \"cubo\",\n            \"cubrir\",\n            \"cuchara\",\n            \"cuello\",\n            \"cuento\",\n            \"cuerda\",\n            \"cuesta\",\n            \"cueva\",\n            \"cuidar\",\n            \"culebra\",\n            \"culpa\",\n            \"culto\",\n            \"cumbre\",\n            \"cumplir\",\n            \"cuna\",\n            \"cuneta\",\n            \"cuota\",\n            \"cupón\",\n            \"cúpula\",\n            \"curar\",\n            \"curioso\",\n            \"curso\",\n            \"curva\",\n            \"cutis\",\n            \"dama\",\n            \"danza\",\n            \"dar\",\n            \"dardo\",\n            \"dátil\",\n            \"deber\",\n            \"débil\",\n            \"década\",\n            \"decir\",\n            \"dedo\",\n            \"defensa\",\n            \"definir\",\n            \"dejar\",\n            \"delfín\",\n            \"delgado\",\n            \"delito\",\n            \"demora\",\n            \"denso\",\n            \"dental\",\n            \"deporte\",\n            \"derecho\",\n            \"derrota\",\n            \"desayuno\",\n            \"deseo\",\n            \"desfile\",\n            \"desnudo\",\n            \"destino\",\n            \"desvío\",\n            \"detalle\",\n            \"detener\",\n            \"deuda\",\n            \"día\",\n            \"diablo\",\n            \"diadema\",\n            \"diamante\",\n            \"diana\",\n            \"diario\",\n            \"dibujo\",\n            \"dictar\",\n            \"diente\",\n            \"dieta\",\n            \"diez\",\n            \"difícil\",\n            \"digno\",\n            \"dilema\",\n            \"diluir\",\n            \"dinero\",\n            \"directo\",\n            \"dirigir\",\n            \"disco\",\n            \"diseño\",\n            \"disfraz\",\n            \"diva\",\n            \"divino\",\n            \"doble\",\n            \"doce\",\n            \"dolor\",\n            \"domingo\",\n            \"don\",\n            \"donar\",\n            \"dorado\",\n            \"dormir\",\n            \"dorso\",\n            \"dos\",\n            \"dosis\",\n            \"dragón\",\n            \"droga\",\n            \"ducha\",\n            \"duda\",\n            \"duelo\",\n            \"dueño\",\n            \"dulce\",\n            \"dúo\",\n            \"duque\",\n            \"durar\",\n            \"dureza\",\n            \"duro\",\n            \"ébano\",\n            \"ebrio\",\n            \"echar\",\n            \"eco\",\n            \"ecuador\",\n            \"edad\",\n            \"edición\",\n            \"edificio\",\n            \"editor\",\n            \"educar\",\n            \"efecto\",\n            \"eficaz\",\n            \"eje\",\n            \"ejemplo\",\n            \"elefante\",\n            \"elegir\",\n            \"elemento\",\n            \"elevar\",\n            \"elipse\",\n            \"élite\",\n            \"elixir\",\n            \"elogio\",\n            \"eludir\",\n            \"embudo\",\n            \"emitir\",\n            \"emoción\",\n            \"empate\",\n            \"empeño\",\n            \"empleo\",\n            \"empresa\",\n            \"enano\",\n            \"encargo\",\n            \"enchufe\",\n            \"encía\",\n            \"enemigo\",\n            \"enero\",\n            \"enfado\",\n            \"enfermo\",\n            \"engaño\",\n            \"enigma\",\n            \"enlace\",\n            \"enorme\",\n            \"enredo\",\n            \"ensayo\",\n            \"enseñar\",\n            \"entero\",\n            \"entrar\",\n            \"envase\",\n            \"envío\",\n            \"época\",\n            \"equipo\",\n            \"erizo\",\n            \"escala\",\n            \"escena\",\n            \"escolar\",\n            \"escribir\",\n            \"escudo\",\n            \"esencia\",\n            \"esfera\",\n            \"esfuerzo\",\n            \"espada\",\n            \"espejo\",\n            \"espía\",\n            \"esposa\",\n            \"espuma\",\n            \"esquí\",\n            \"estar\",\n            \"este\",\n            \"estilo\",\n            \"estufa\",\n            \"etapa\",\n            \"eterno\",\n            \"ética\",\n            \"etnia\",\n            \"evadir\",\n            \"evaluar\",\n            \"evento\",\n            \"evitar\",\n            \"exacto\",\n            \"examen\",\n            \"exceso\",\n            \"excusa\",\n            \"exento\",\n            \"exigir\",\n            \"exilio\",\n            \"existir\",\n            \"éxito\",\n            \"experto\",\n            \"explicar\",\n            \"exponer\",\n            \"extremo\",\n            \"fábrica\",\n            \"fábula\",\n            \"fachada\",\n            \"fácil\",\n            \"factor\",\n            \"faena\",\n            \"faja\",\n            \"falda\",\n            \"fallo\",\n            \"falso\",\n            \"faltar\",\n            \"fama\",\n            \"familia\",\n            \"famoso\",\n            \"faraón\",\n            \"farmacia\",\n            \"farol\",\n            \"farsa\",\n            \"fase\",\n            \"fatiga\",\n            \"fauna\",\n            \"favor\",\n            \"fax\",\n            \"febrero\",\n            \"fecha\",\n            \"feliz\",\n            \"feo\",\n            \"feria\",\n            \"feroz\",\n            \"fértil\",\n            \"fervor\",\n            \"festín\",\n            \"fiable\",\n            \"fianza\",\n            \"fiar\",\n            \"fibra\",\n            \"ficción\",\n            \"ficha\",\n            \"fideo\",\n            \"fiebre\",\n            \"fiel\",\n            \"fiera\",\n            \"fiesta\",\n            \"figura\",\n            \"fijar\",\n            \"fijo\",\n            \"fila\",\n            \"filete\",\n            \"filial\",\n            \"filtro\",\n            \"fin\",\n            \"finca\",\n            \"fingir\",\n            \"finito\",\n            \"firma\",\n            \"flaco\",\n            \"flauta\",\n            \"flecha\",\n            \"flor\",\n            \"flota\",\n            \"fluir\",\n            \"flujo\",\n            \"flúor\",\n            \"fobia\",\n            \"foca\",\n            \"fogata\",\n            \"fogón\",\n            \"folio\",\n            \"folleto\",\n            \"fondo\",\n            \"forma\",\n            \"forro\",\n            \"fortuna\",\n            \"forzar\",\n            \"fosa\",\n            \"foto\",\n            \"fracaso\",\n            \"frágil\",\n            \"franja\",\n            \"frase\",\n            \"fraude\",\n            \"freír\",\n            \"freno\",\n            \"fresa\",\n            \"frío\",\n            \"frito\",\n            \"fruta\",\n            \"fuego\",\n            \"fuente\",\n            \"fuerza\",\n            \"fuga\",\n            \"fumar\",\n            \"función\",\n            \"funda\",\n            \"furgón\",\n            \"furia\",\n            \"fusil\",\n            \"fútbol\",\n            \"futuro\",\n            \"gacela\",\n            \"gafas\",\n            \"gaita\",\n            \"gajo\",\n            \"gala\",\n            \"galería\",\n            \"gallo\",\n            \"gamba\",\n            \"ganar\",\n            \"gancho\",\n            \"ganga\",\n            \"ganso\",\n            \"garaje\",\n            \"garza\",\n            \"gasolina\",\n            \"gastar\",\n            \"gato\",\n            \"gavilán\",\n            \"gemelo\",\n            \"gemir\",\n            \"gen\",\n            \"género\",\n            \"genio\",\n            \"gente\",\n            \"geranio\",\n            \"gerente\",\n            \"germen\",\n            \"gesto\",\n            \"gigante\",\n            \"gimnasio\",\n            \"girar\",\n            \"giro\",\n            \"glaciar\",\n            \"globo\",\n            \"gloria\",\n            \"gol\",\n            \"golfo\",\n            \"goloso\",\n            \"golpe\",\n            \"goma\",\n            \"gordo\",\n            \"gorila\",\n            \"gorra\",\n            \"gota\",\n            \"goteo\",\n            \"gozar\",\n            \"grada\",\n            \"gráfico\",\n            \"grano\",\n            \"grasa\",\n            \"gratis\",\n            \"grave\",\n            \"grieta\",\n            \"grillo\",\n            \"gripe\",\n            \"gris\",\n            \"grito\",\n            \"grosor\",\n            \"grúa\",\n            \"grueso\",\n            \"grumo\",\n            \"grupo\",\n            \"guante\",\n            \"guapo\",\n            \"guardia\",\n            \"guerra\",\n            \"guía\",\n            \"guiño\",\n            \"guion\",\n            \"guiso\",\n            \"guitarra\",\n            \"gusano\",\n            \"gustar\",\n            \"haber\",\n            \"hábil\",\n            \"hablar\",\n            \"hacer\",\n            \"hacha\",\n            \"hada\",\n            \"hallar\",\n            \"hamaca\",\n            \"harina\",\n            \"haz\",\n            \"hazaña\",\n            \"hebilla\",\n            \"hebra\",\n            \"hecho\",\n            \"helado\",\n            \"helio\",\n            \"hembra\",\n            \"herir\",\n            \"hermano\",\n            \"héroe\",\n            \"hervir\",\n            \"hielo\",\n            \"hierro\",\n            \"hígado\",\n            \"higiene\",\n            \"hijo\",\n            \"himno\",\n            \"historia\",\n            \"hocico\",\n            \"hogar\",\n            \"hoguera\",\n            \"hoja\",\n            \"hombre\",\n            \"hongo\",\n            \"honor\",\n            \"honra\",\n            \"hora\",\n            \"hormiga\",\n            \"horno\",\n            \"hostil\",\n            \"hoyo\",\n            \"hueco\",\n            \"huelga\",\n            \"huerta\",\n            \"hueso\",\n            \"huevo\",\n            \"huida\",\n            \"huir\",\n            \"humano\",\n            \"húmedo\",\n            \"humilde\",\n            \"humo\",\n            \"hundir\",\n            \"huracán\",\n            \"hurto\",\n            \"icono\",\n            \"ideal\",\n            \"idioma\",\n            \"ídolo\",\n            \"iglesia\",\n            \"iglú\",\n            \"igual\",\n            \"ilegal\",\n            \"ilusión\",\n            \"imagen\",\n            \"imán\",\n            \"imitar\",\n            \"impar\",\n            \"imperio\",\n            \"imponer\",\n            \"impulso\",\n            \"incapaz\",\n            \"índice\",\n            \"inerte\",\n            \"infiel\",\n            \"informe\",\n            \"ingenio\",\n            \"inicio\",\n            \"inmenso\",\n            \"inmune\",\n            \"innato\",\n            \"insecto\",\n            \"instante\",\n            \"interés\",\n            \"íntimo\",\n            \"intuir\",\n            \"inútil\",\n            \"invierno\",\n            \"ira\",\n            \"iris\",\n            \"ironía\",\n            \"isla\",\n            \"islote\",\n            \"jabalí\",\n            \"jabón\",\n            \"jamón\",\n            \"jarabe\",\n            \"jardín\",\n            \"jarra\",\n            \"jaula\",\n            \"jazmín\",\n            \"jefe\",\n            \"jeringa\",\n            \"jinete\",\n            \"jornada\",\n            \"joroba\",\n            \"joven\",\n            \"joya\",\n            \"juerga\",\n            \"jueves\",\n            \"juez\",\n            \"jugador\",\n            \"jugo\",\n            \"juguete\",\n            \"juicio\",\n            \"junco\",\n            \"jungla\",\n            \"junio\",\n            \"juntar\",\n            \"júpiter\",\n            \"jurar\",\n            \"justo\",\n            \"juvenil\",\n            \"juzgar\",\n            \"kilo\",\n            \"koala\",\n            \"labio\",\n            \"lacio\",\n            \"lacra\",\n            \"lado\",\n            \"ladrón\",\n            \"lagarto\",\n            \"lágrima\",\n            \"laguna\",\n            \"laico\",\n            \"lamer\",\n            \"lámina\",\n            \"lámpara\",\n            \"lana\",\n            \"lancha\",\n            \"langosta\",\n            \"lanza\",\n            \"lápiz\",\n            \"largo\",\n            \"larva\",\n            \"lástima\",\n            \"lata\",\n            \"látex\",\n            \"latir\",\n            \"laurel\",\n            \"lavar\",\n            \"lazo\",\n            \"leal\",\n            \"lección\",\n            \"leche\",\n            \"lector\",\n            \"leer\",\n            \"legión\",\n            \"legumbre\",\n            \"lejano\",\n            \"lengua\",\n            \"lento\",\n            \"leña\",\n            \"león\",\n            \"leopardo\",\n            \"lesión\",\n            \"letal\",\n            \"letra\",\n            \"leve\",\n            \"leyenda\",\n            \"libertad\",\n            \"libro\",\n            \"licor\",\n            \"líder\",\n            \"lidiar\",\n            \"lienzo\",\n            \"liga\",\n            \"ligero\",\n            \"lima\",\n            \"límite\",\n            \"limón\",\n            \"limpio\",\n            \"lince\",\n            \"lindo\",\n            \"línea\",\n            \"lingote\",\n            \"lino\",\n            \"linterna\",\n            \"líquido\",\n            \"liso\",\n            \"lista\",\n            \"litera\",\n            \"litio\",\n            \"litro\",\n            \"llaga\",\n            \"llama\",\n            \"llanto\",\n            \"llave\",\n            \"llegar\",\n            \"llenar\",\n            \"llevar\",\n            \"llorar\",\n            \"llover\",\n            \"lluvia\",\n            \"lobo\",\n            \"loción\",\n            \"loco\",\n            \"locura\",\n            \"lógica\",\n            \"logro\",\n            \"lombriz\",\n            \"lomo\",\n            \"lonja\",\n            \"lote\",\n            \"lucha\",\n            \"lucir\",\n            \"lugar\",\n            \"lujo\",\n            \"luna\",\n            \"lunes\",\n            \"lupa\",\n            \"lustro\",\n            \"luto\",\n            \"luz\",\n            \"maceta\",\n            \"macho\",\n            \"madera\",\n            \"madre\",\n            \"maduro\",\n            \"maestro\",\n            \"mafia\",\n            \"magia\",\n            \"mago\",\n            \"maíz\",\n            \"maldad\",\n            \"maleta\",\n            \"malla\",\n            \"malo\",\n            \"mamá\",\n            \"mambo\",\n            \"mamut\",\n            \"manco\",\n            \"mando\",\n            \"manejar\",\n            \"manga\",\n            \"maniquí\",\n            \"manjar\",\n            \"mano\",\n            \"manso\",\n            \"manta\",\n            \"mañana\",\n            \"mapa\",\n            \"máquina\",\n            \"mar\",\n            \"marco\",\n            \"marea\",\n            \"marfil\",\n            \"margen\",\n            \"marido\",\n            \"mármol\",\n            \"marrón\",\n            \"martes\",\n            \"marzo\",\n            \"masa\",\n            \"máscara\",\n            \"masivo\",\n            \"matar\",\n            \"materia\",\n            \"matiz\",\n            \"matriz\",\n            \"máximo\",\n            \"mayor\",\n            \"mazorca\",\n            \"mecha\",\n            \"medalla\",\n            \"medio\",\n            \"médula\",\n            \"mejilla\",\n            \"mejor\",\n            \"melena\",\n            \"melón\",\n            \"memoria\",\n            \"menor\",\n            \"mensaje\",\n            \"mente\",\n            \"menú\",\n            \"mercado\",\n            \"merengue\",\n            \"mérito\",\n            \"mes\",\n            \"mesón\",\n            \"meta\",\n            \"meter\",\n            \"método\",\n            \"metro\",\n            \"mezcla\",\n            \"miedo\",\n            \"miel\",\n            \"miembro\",\n            \"miga\",\n            \"mil\",\n            \"milagro\",\n            \"militar\",\n            \"millón\",\n            \"mimo\",\n            \"mina\",\n            \"minero\",\n            \"mínimo\",\n            \"minuto\",\n            \"miope\",\n            \"mirar\",\n            \"misa\",\n            \"miseria\",\n            \"misil\",\n            \"mismo\",\n            \"mitad\",\n            \"mito\",\n            \"mochila\",\n            \"moción\",\n            \"moda\",\n            \"modelo\",\n            \"moho\",\n            \"mojar\",\n            \"molde\",\n            \"moler\",\n            \"molino\",\n            \"momento\",\n            \"momia\",\n            \"monarca\",\n            \"moneda\",\n            \"monja\",\n            \"monto\",\n            \"moño\",\n            \"morada\",\n            \"morder\",\n            \"moreno\",\n            \"morir\",\n            \"morro\",\n            \"morsa\",\n            \"mortal\",\n            \"mosca\",\n            \"mostrar\",\n            \"motivo\",\n            \"mover\",\n            \"móvil\",\n            \"mozo\",\n            \"mucho\",\n            \"mudar\",\n            \"mueble\",\n            \"muela\",\n            \"muerte\",\n            \"muestra\",\n            \"mugre\",\n            \"mujer\",\n            \"mula\",\n            \"muleta\",\n            \"multa\",\n            \"mundo\",\n            \"muñeca\",\n            \"mural\",\n            \"muro\",\n            \"músculo\",\n            \"museo\",\n            \"musgo\",\n            \"música\",\n            \"muslo\",\n            \"nácar\",\n            \"nación\",\n            \"nadar\",\n            \"naipe\",\n            \"naranja\",\n            \"nariz\",\n            \"narrar\",\n            \"nasal\",\n            \"natal\",\n            \"nativo\",\n            \"natural\",\n            \"náusea\",\n            \"naval\",\n            \"nave\",\n            \"navidad\",\n            \"necio\",\n            \"néctar\",\n            \"negar\",\n            \"negocio\",\n            \"negro\",\n            \"neón\",\n            \"nervio\",\n            \"neto\",\n            \"neutro\",\n            \"nevar\",\n            \"nevera\",\n            \"nicho\",\n            \"nido\",\n            \"niebla\",\n            \"nieto\",\n            \"niñez\",\n            \"niño\",\n            \"nítido\",\n            \"nivel\",\n            \"nobleza\",\n            \"noche\",\n            \"nómina\",\n            \"noria\",\n            \"norma\",\n            \"norte\",\n            \"nota\",\n            \"noticia\",\n            \"novato\",\n            \"novela\",\n            \"novio\",\n            \"nube\",\n            \"nuca\",\n            \"núcleo\",\n            \"nudillo\",\n            \"nudo\",\n            \"nuera\",\n            \"nueve\",\n            \"nuez\",\n            \"nulo\",\n            \"número\",\n            \"nutria\",\n            \"oasis\",\n            \"obeso\",\n            \"obispo\",\n            \"objeto\",\n            \"obra\",\n            \"obrero\",\n            \"observar\",\n            \"obtener\",\n            \"obvio\",\n            \"oca\",\n            \"ocaso\",\n            \"océano\",\n            \"ochenta\",\n            \"ocho\",\n            \"ocio\",\n            \"ocre\",\n            \"octavo\",\n            \"octubre\",\n            \"oculto\",\n            \"ocupar\",\n            \"ocurrir\",\n            \"odiar\",\n            \"odio\",\n            \"odisea\",\n            \"oeste\",\n            \"ofensa\",\n            \"oferta\",\n            \"oficio\",\n            \"ofrecer\",\n            \"ogro\",\n            \"oído\",\n            \"oír\",\n            \"ojo\",\n            \"ola\",\n            \"oleada\",\n            \"olfato\",\n            \"olivo\",\n            \"olla\",\n            \"olmo\",\n            \"olor\",\n            \"olvido\",\n            \"ombligo\",\n            \"onda\",\n            \"onza\",\n            \"opaco\",\n            \"opción\",\n            \"ópera\",\n            \"opinar\",\n            \"oponer\",\n            \"optar\",\n            \"óptica\",\n            \"opuesto\",\n            \"oración\",\n            \"orador\",\n            \"oral\",\n            \"órbita\",\n            \"orca\",\n            \"orden\",\n            \"oreja\",\n            \"órgano\",\n            \"orgía\",\n            \"orgullo\",\n            \"oriente\",\n            \"origen\",\n            \"orilla\",\n            \"oro\",\n            \"orquesta\",\n            \"oruga\",\n            \"osadía\",\n            \"oscuro\",\n            \"osezno\",\n            \"oso\",\n            \"ostra\",\n            \"otoño\",\n            \"otro\",\n            \"oveja\",\n            \"óvulo\",\n            \"óxido\",\n            \"oxígeno\",\n            \"oyente\",\n            \"ozono\",\n            \"pacto\",\n            \"padre\",\n            \"paella\",\n            \"página\",\n            \"pago\",\n            \"país\",\n            \"pájaro\",\n            \"palabra\",\n            \"palco\",\n            \"paleta\",\n            \"pálido\",\n            \"palma\",\n            \"paloma\",\n            \"palpar\",\n            \"pan\",\n            \"panal\",\n            \"pánico\",\n            \"pantera\",\n            \"pañuelo\",\n            \"papá\",\n            \"papel\",\n            \"papilla\",\n            \"paquete\",\n            \"parar\",\n            \"parcela\",\n            \"pared\",\n            \"parir\",\n            \"paro\",\n            \"párpado\",\n            \"parque\",\n            \"párrafo\",\n            \"parte\",\n            \"pasar\",\n            \"paseo\",\n            \"pasión\",\n            \"paso\",\n            \"pasta\",\n            \"pata\",\n            \"patio\",\n            \"patria\",\n            \"pausa\",\n            \"pauta\",\n            \"pavo\",\n            \"payaso\",\n            \"peatón\",\n            \"pecado\",\n            \"pecera\",\n            \"pecho\",\n            \"pedal\",\n            \"pedir\",\n            \"pegar\",\n            \"peine\",\n            \"pelar\",\n            \"peldaño\",\n            \"pelea\",\n            \"peligro\",\n            \"pellejo\",\n            \"pelo\",\n            \"peluca\",\n            \"pena\",\n            \"pensar\",\n            \"peñón\",\n            \"peón\",\n            \"peor\",\n            \"pepino\",\n            \"pequeño\",\n            \"pera\",\n            \"percha\",\n            \"perder\",\n            \"pereza\",\n            \"perfil\",\n            \"perico\",\n            \"perla\",\n            \"permiso\",\n            \"perro\",\n            \"persona\",\n            \"pesa\",\n            \"pesca\",\n            \"pésimo\",\n            \"pestaña\",\n            \"pétalo\",\n            \"petróleo\",\n            \"pez\",\n            \"pezuña\",\n            \"picar\",\n            \"pichón\",\n            \"pie\",\n            \"piedra\",\n            \"pierna\",\n            \"pieza\",\n            \"pijama\",\n            \"pilar\",\n            \"piloto\",\n            \"pimienta\",\n            \"pino\",\n            \"pintor\",\n            \"pinza\",\n            \"piña\",\n            \"piojo\",\n            \"pipa\",\n            \"pirata\",\n            \"pisar\",\n            \"piscina\",\n            \"piso\",\n            \"pista\",\n            \"pitón\",\n            \"pizca\",\n            \"placa\",\n            \"plan\",\n            \"plata\",\n            \"playa\",\n            \"plaza\",\n            \"pleito\",\n            \"pleno\",\n            \"plomo\",\n            \"pluma\",\n            \"plural\",\n            \"pobre\",\n            \"poco\",\n            \"poder\",\n            \"podio\",\n            \"poema\",\n            \"poesía\",\n            \"poeta\",\n            \"polen\",\n            \"policía\",\n            \"pollo\",\n            \"polvo\",\n            \"pomada\",\n            \"pomelo\",\n            \"pomo\",\n            \"pompa\",\n            \"poner\",\n            \"porción\",\n            \"portal\",\n            \"posada\",\n            \"poseer\",\n            \"posible\",\n            \"poste\",\n            \"potencia\",\n            \"potro\",\n            \"pozo\",\n            \"prado\",\n            \"precoz\",\n            \"pregunta\",\n            \"premio\",\n            \"prensa\",\n            \"preso\",\n            \"previo\",\n            \"primo\",\n            \"príncipe\",\n            \"prisión\",\n            \"privar\",\n            \"proa\",\n            \"probar\",\n            \"proceso\",\n            \"producto\",\n            \"proeza\",\n            \"profesor\",\n            \"programa\",\n            \"prole\",\n            \"promesa\",\n            \"pronto\",\n            \"propio\",\n            \"próximo\",\n            \"prueba\",\n            \"público\",\n            \"puchero\",\n            \"pudor\",\n            \"pueblo\",\n            \"puerta\",\n            \"puesto\",\n            \"pulga\",\n            \"pulir\",\n            \"pulmón\",\n            \"pulpo\",\n            \"pulso\",\n            \"puma\",\n            \"punto\",\n            \"puñal\",\n            \"puño\",\n            \"pupa\",\n            \"pupila\",\n            \"puré\",\n            \"quedar\",\n            \"queja\",\n            \"quemar\",\n            \"querer\",\n            \"queso\",\n            \"quieto\",\n            \"química\",\n            \"quince\",\n            \"quitar\",\n            \"rábano\",\n            \"rabia\",\n            \"rabo\",\n            \"ración\",\n            \"radical\",\n            \"raíz\",\n            \"rama\",\n            \"rampa\",\n            \"rancho\",\n            \"rango\",\n            \"rapaz\",\n            \"rápido\",\n            \"rapto\",\n            \"rasgo\",\n            \"raspa\",\n            \"rato\",\n            \"rayo\",\n            \"raza\",\n            \"razón\",\n            \"reacción\",\n            \"realidad\",\n            \"rebaño\",\n            \"rebote\",\n            \"recaer\",\n            \"receta\",\n            \"rechazo\",\n            \"recoger\",\n            \"recreo\",\n            \"recto\",\n            \"recurso\",\n            \"red\",\n            \"redondo\",\n            \"reducir\",\n            \"reflejo\",\n            \"reforma\",\n            \"refrán\",\n            \"refugio\",\n            \"regalo\",\n            \"regir\",\n            \"regla\",\n            \"regreso\",\n            \"rehén\",\n            \"reino\",\n            \"reír\",\n            \"reja\",\n            \"relato\",\n            \"relevo\",\n            \"relieve\",\n            \"relleno\",\n            \"reloj\",\n            \"remar\",\n            \"remedio\",\n            \"remo\",\n            \"rencor\",\n            \"rendir\",\n            \"renta\",\n            \"reparto\",\n            \"repetir\",\n            \"reposo\",\n            \"reptil\",\n            \"res\",\n            \"rescate\",\n            \"resina\",\n            \"respeto\",\n            \"resto\",\n            \"resumen\",\n            \"retiro\",\n            \"retorno\",\n            \"retrato\",\n            \"reunir\",\n            \"revés\",\n            \"revista\",\n            \"rey\",\n            \"rezar\",\n            \"rico\",\n            \"riego\",\n            \"rienda\",\n            \"riesgo\",\n            \"rifa\",\n            \"rígido\",\n            \"rigor\",\n            \"rincón\",\n            \"riñón\",\n            \"río\",\n            \"riqueza\",\n            \"risa\",\n            \"ritmo\",\n            \"rito\",\n            \"rizo\",\n            \"roble\",\n            \"roce\",\n            \"rociar\",\n            \"rodar\",\n            \"rodeo\",\n            \"rodilla\",\n            \"roer\",\n            \"rojizo\",\n            \"rojo\",\n            \"romero\",\n            \"romper\",\n            \"ron\",\n            \"ronco\",\n            \"ronda\",\n            \"ropa\",\n            \"ropero\",\n            \"rosa\",\n            \"rosca\",\n            \"rostro\",\n            \"rotar\",\n            \"rubí\",\n            \"rubor\",\n            \"rudo\",\n            \"rueda\",\n            \"rugir\",\n            \"ruido\",\n            \"ruina\",\n            \"ruleta\",\n            \"rulo\",\n            \"rumbo\",\n            \"rumor\",\n            \"ruptura\",\n            \"ruta\",\n            \"rutina\",\n            \"sábado\",\n            \"saber\",\n            \"sabio\",\n            \"sable\",\n            \"sacar\",\n            \"sagaz\",\n            \"sagrado\",\n            \"sala\",\n            \"saldo\",\n            \"salero\",\n            \"salir\",\n            \"salmón\",\n            \"salón\",\n            \"salsa\",\n            \"salto\",\n            \"salud\",\n            \"salvar\",\n            \"samba\",\n            \"sanción\",\n            \"sandía\",\n            \"sanear\",\n            \"sangre\",\n            \"sanidad\",\n            \"sano\",\n            \"santo\",\n            \"sapo\",\n            \"saque\",\n            \"sardina\",\n            \"sartén\",\n            \"sastre\",\n            \"satán\",\n            \"sauna\",\n            \"saxofón\",\n            \"sección\",\n            \"seco\",\n            \"secreto\",\n            \"secta\",\n            \"sed\",\n            \"seguir\",\n            \"seis\",\n            \"sello\",\n            \"selva\",\n            \"semana\",\n            \"semilla\",\n            \"senda\",\n            \"sensor\",\n            \"señal\",\n            \"señor\",\n            \"separar\",\n            \"sepia\",\n            \"sequía\",\n            \"ser\",\n            \"serie\",\n            \"sermón\",\n            \"servir\",\n            \"sesenta\",\n            \"sesión\",\n            \"seta\",\n            \"setenta\",\n            \"severo\",\n            \"sexo\",\n            \"sexto\",\n            \"sidra\",\n            \"siesta\",\n            \"siete\",\n            \"siglo\",\n            \"signo\",\n            \"sílaba\",\n            \"silbar\",\n            \"silencio\",\n            \"silla\",\n            \"símbolo\",\n            \"simio\",\n            \"sirena\",\n            \"sistema\",\n            \"sitio\",\n            \"situar\",\n            \"sobre\",\n            \"socio\",\n            \"sodio\",\n            \"sol\",\n            \"solapa\",\n            \"soldado\",\n            \"soledad\",\n            \"sólido\",\n            \"soltar\",\n            \"solución\",\n            \"sombra\",\n            \"sondeo\",\n            \"sonido\",\n            \"sonoro\",\n            \"sonrisa\",\n            \"sopa\",\n            \"soplar\",\n            \"soporte\",\n            \"sordo\",\n            \"sorpresa\",\n            \"sorteo\",\n            \"sostén\",\n            \"sótano\",\n            \"suave\",\n            \"subir\",\n            \"suceso\",\n            \"sudor\",\n            \"suegra\",\n            \"suelo\",\n            \"sueño\",\n            \"suerte\",\n            \"sufrir\",\n            \"sujeto\",\n            \"sultán\",\n            \"sumar\",\n            \"superar\",\n            \"suplir\",\n            \"suponer\",\n            \"supremo\",\n            \"sur\",\n            \"surco\",\n            \"sureño\",\n            \"surgir\",\n            \"susto\",\n            \"sutil\",\n            \"tabaco\",\n            \"tabique\",\n            \"tabla\",\n            \"tabú\",\n            \"taco\",\n            \"tacto\",\n            \"tajo\",\n            \"talar\",\n            \"talco\",\n            \"talento\",\n            \"talla\",\n            \"talón\",\n            \"tamaño\",\n            \"tambor\",\n            \"tango\",\n            \"tanque\",\n            \"tapa\",\n            \"tapete\",\n            \"tapia\",\n            \"tapón\",\n            \"taquilla\",\n            \"tarde\",\n            \"tarea\",\n            \"tarifa\",\n            \"tarjeta\",\n            \"tarot\",\n            \"tarro\",\n            \"tarta\",\n            \"tatuaje\",\n            \"tauro\",\n            \"taza\",\n            \"tazón\",\n            \"teatro\",\n            \"techo\",\n            \"tecla\",\n            \"técnica\",\n            \"tejado\",\n            \"tejer\",\n            \"tejido\",\n            \"tela\",\n            \"teléfono\",\n            \"tema\",\n            \"temor\",\n            \"templo\",\n            \"tenaz\",\n            \"tender\",\n            \"tener\",\n            \"tenis\",\n            \"tenso\",\n            \"teoría\",\n            \"terapia\",\n            \"terco\",\n            \"término\",\n            \"ternura\",\n            \"terror\",\n            \"tesis\",\n            \"tesoro\",\n            \"testigo\",\n            \"tetera\",\n            \"texto\",\n            \"tez\",\n            \"tibio\",\n            \"tiburón\",\n            \"tiempo\",\n            \"tienda\",\n            \"tierra\",\n            \"tieso\",\n            \"tigre\",\n            \"tijera\",\n            \"tilde\",\n            \"timbre\",\n            \"tímido\",\n            \"timo\",\n            \"tinta\",\n            \"tío\",\n            \"típico\",\n            \"tipo\",\n            \"tira\",\n            \"tirón\",\n            \"titán\",\n            \"títere\",\n            \"título\",\n            \"tiza\",\n            \"toalla\",\n            \"tobillo\",\n            \"tocar\",\n            \"tocino\",\n            \"todo\",\n            \"toga\",\n            \"toldo\",\n            \"tomar\",\n            \"tono\",\n            \"tonto\",\n            \"topar\",\n            \"tope\",\n            \"toque\",\n            \"tórax\",\n            \"torero\",\n            \"tormenta\",\n            \"torneo\",\n            \"toro\",\n            \"torpedo\",\n            \"torre\",\n            \"torso\",\n            \"tortuga\",\n            \"tos\",\n            \"tosco\",\n            \"toser\",\n            \"tóxico\",\n            \"trabajo\",\n            \"tractor\",\n            \"traer\",\n            \"tráfico\",\n            \"trago\",\n            \"traje\",\n            \"tramo\",\n            \"trance\",\n            \"trato\",\n            \"trauma\",\n            \"trazar\",\n            \"trébol\",\n            \"tregua\",\n            \"treinta\",\n            \"tren\",\n            \"trepar\",\n            \"tres\",\n            \"tribu\",\n            \"trigo\",\n            \"tripa\",\n            \"triste\",\n            \"triunfo\",\n            \"trofeo\",\n            \"trompa\",\n            \"tronco\",\n            \"tropa\",\n            \"trote\",\n            \"trozo\",\n            \"truco\",\n            \"trueno\",\n            \"trufa\",\n            \"tubería\",\n            \"tubo\",\n            \"tuerto\",\n            \"tumba\",\n            \"tumor\",\n            \"túnel\",\n            \"túnica\",\n            \"turbina\",\n            \"turismo\",\n            \"turno\",\n            \"tutor\",\n            \"ubicar\",\n            \"úlcera\",\n            \"umbral\",\n            \"unidad\",\n            \"unir\",\n            \"universo\",\n            \"uno\",\n            \"untar\",\n            \"uña\",\n            \"urbano\",\n            \"urbe\",\n            \"urgente\",\n            \"urna\",\n            \"usar\",\n            \"usuario\",\n            \"útil\",\n            \"utopía\",\n            \"uva\",\n            \"vaca\",\n            \"vacío\",\n            \"vacuna\",\n            \"vagar\",\n            \"vago\",\n            \"vaina\",\n            \"vajilla\",\n            \"vale\",\n            \"válido\",\n            \"valle\",\n            \"valor\",\n            \"válvula\",\n            \"vampiro\",\n            \"vara\",\n            \"variar\",\n            \"varón\",\n            \"vaso\",\n            \"vecino\",\n            \"vector\",\n            \"vehículo\",\n            \"veinte\",\n            \"vejez\",\n            \"vela\",\n            \"velero\",\n            \"veloz\",\n            \"vena\",\n            \"vencer\",\n            \"venda\",\n            \"veneno\",\n            \"vengar\",\n            \"venir\",\n            \"venta\",\n            \"venus\",\n            \"ver\",\n            \"verano\",\n            \"verbo\",\n            \"verde\",\n            \"vereda\",\n            \"verja\",\n            \"verso\",\n            \"verter\",\n            \"vía\",\n            \"viaje\",\n            \"vibrar\",\n            \"vicio\",\n            \"víctima\",\n            \"vida\",\n            \"vídeo\",\n            \"vidrio\",\n            \"viejo\",\n            \"viernes\",\n            \"vigor\",\n            \"vil\",\n            \"villa\",\n            \"vinagre\",\n            \"vino\",\n            \"viñedo\",\n            \"violín\",\n            \"viral\",\n            \"virgo\",\n            \"virtud\",\n            \"visor\",\n            \"víspera\",\n            \"vista\",\n            \"vitamina\",\n            \"viudo\",\n            \"vivaz\",\n            \"vivero\",\n            \"vivir\",\n            \"vivo\",\n            \"volcán\",\n            \"volumen\",\n            \"volver\",\n            \"voraz\",\n            \"votar\",\n            \"voto\",\n            \"voz\",\n            \"vuelo\",\n            \"vulgar\",\n            \"yacer\",\n            \"yate\",\n            \"yegua\",\n            \"yema\",\n            \"yerno\",\n            \"yeso\",\n            \"yodo\",\n            \"yoga\",\n            \"yogur\",\n            \"zafiro\",\n            \"zanja\",\n            \"zapato\",\n            \"zarza\",\n            \"zona\",\n            \"zorro\",\n            \"zumo\",\n            \"zurdo\"\n    };\n}"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip44/Account.java",
    "content": "package com.quincysx.crypto.bip44;\n\nimport com.quincysx.crypto.bip32.Index;\n\n/**\n * @author QuincySx\n * @date 2018/3/5 下午4:27\n */\npublic class Account {\n    private final CoinType coinType;\n    private final int account;\n    private final String string;\n\n    Account(final CoinType coinType, final int account) {\n        if (Index.isHardened(account))\n            throw new IllegalArgumentException();\n        this.coinType = coinType;\n        this.account = account;\n        string = String.format(\"%s/%d'\", coinType, account);\n    }\n\n    public int getValue() {\n        return account;\n    }\n\n    public CoinType getParent() {\n        return coinType;\n    }\n\n    @Override\n    public String toString() {\n        return string;\n    }\n\n    /**\n     * Create a {@link Change} for this purpose, coin type and account.\n     * <p>\n     * Constant 0 is used for external chain.\n     * External chain is used for addresses that are meant to be visible outside of the wallet (e.g. for receiving\n     * payments).\n     *\n     * @return A {@link Change} = 0 instance for this purpose, coin type and account\n     */\n    public Change external() {\n        return new Change(this, 0);\n    }\n\n    /**\n     * Create a {@link Change} for this purpose, coin type and account.\n     * <p>\n     * Constant 1 is used for internal chain (also known as change addresses).\n     * Internal chain is used for addresses which are not meant to be visible outside of the wallet and is used for\n     * return transaction change.\n     *\n     * @return A {@link Change} = 1 instance for this purpose, coin type and account\n     */\n    public Change internal() {\n        return new Change(this, 1);\n    }\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip44/AddressIndex.java",
    "content": "package com.quincysx.crypto.bip44;\n\nimport com.quincysx.crypto.bip32.Index;\n\n/**\n * @author QuincySx\n * @date 2018/3/5 下午4:28\n */\npublic class AddressIndex {\n    private final Change change;\n    private final int addressIndex;\n    private final boolean isHard;\n\n    private final String string;\n\n    AddressIndex(final Change change, final int addressIndex) {\n        this(change, addressIndex, false);\n    }\n\n    AddressIndex(final Change change, final int addressIndex, final boolean head) {\n        this.change = change;\n        this.addressIndex = addressIndex;\n        String s = \"%s/%d\";\n        if (head) {\n            s += \"'\";\n        }\n        string = String.format(s, change, addressIndex);\n        this.isHard = head;\n    }\n\n    public int getValue() {\n        if (isHard) {\n            return Index.hard(addressIndex);\n        }\n        return addressIndex;\n    }\n\n    public Change getParent() {\n        return change;\n    }\n\n    @Override\n    public String toString() {\n        return string;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip44/BIP44.java",
    "content": "package com.quincysx.crypto.bip44;\n\nimport android.util.Log;\n\nimport com.quincysx.crypto.CoinTypes;\nimport com.quincysx.crypto.exception.CoinNotFindException;\nimport com.quincysx.crypto.exception.NonSupportException;\n\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\n/**\n * @author QuincySx\n * @date 2018/3/5 下午3:36\n */\npublic final class BIP44 {\n\n    private static final M M = new M();\n\n    BIP44() {\n    }\n\n    /**\n     * Start creating a BIP44 path.\n     *\n     * @return A fluent factory for creating BIP44 paths\n     */\n    public static M m() {\n        return M;\n    }\n\n    public static AddressIndex parsePath(String path) throws NonSupportException,\n            CoinNotFindException {\n        // m/44'/60'/0'/0/0\n        String regEx = \"m(/\\\\d+'?){3}/[0,1]/\\\\d+'?\";\n        Pattern pattern = Pattern.compile(regEx);\n        Matcher matcher = pattern.matcher(path);\n        // 字符串是否与正则表达式相匹配\n        if (!matcher.matches()) {\n            throw new NonSupportException(\"Path format is not correct\");\n        }\n        String[] split = path.split(\"/\");\n        String purposeStr = split[1].substring(0, split[1].length() - 1);\n        String coinTypeStr = split[2].substring(0, split[2].length() - 1);\n        String accountStr = split[3].substring(0, split[3].length() - 1);\n        String changeStr = split[4];\n        String addressStr;\n        boolean addressHard = false;\n        if (split[5].contains(\"'\")) {\n            addressStr = split[5].substring(0, split[5].length() - 1);\n            addressHard = true;\n        } else {\n            addressStr = split[5];\n        }\n\n        if ((Integer.parseInt(purposeStr)) != 44) {\n            throw new NonSupportException(\"Only support the 44 protocol\");\n        }\n        Log.e(\"++++def\", \"ddddd  \" + Integer.parseInt(accountStr));\n        Account account = BIP44.m()\n                .purpose44()\n                .coinType(CoinTypes.parseCoinType(Integer.parseInt(coinTypeStr)))\n                .account(Integer.parseInt(accountStr));\n\n        Change change;\n        if (Integer.parseInt(changeStr) == 0) {\n            change = account.external();\n        } else {\n            change = account.internal();\n        }\n\n        return change.address(Integer.parseInt(addressStr), addressHard);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip44/Change.java",
    "content": "package com.quincysx.crypto.bip44;\n\n/**\n * @author QuincySx\n * @date 2018/3/5 下午4:28\n */\npublic class Change {\n    private final Account account;\n    private final int change;\n    private final String string;\n\n    Change(final Account account, final int change) {\n        this.account = account;\n        this.change = change;\n        string = String.format(\"%s/%d\", account, change);\n    }\n\n    public int getValue() {\n        return change;\n    }\n\n    public Account getParent() {\n        return account;\n    }\n\n    @Override\n    public String toString() {\n        return string;\n    }\n\n    /**\n     * Create a {@link AddressIndex} for this purpose, coin type, account and change.\n     *\n     * @param addressIndex The index of the child\n     * @return A coin type instance for this purpose, coin type, account and change.\n     */\n    public AddressIndex address(final int addressIndex) {\n        return address(addressIndex, false);\n    }\n\n    public AddressIndex address(final int addressIndex, final boolean hard) {\n        return new AddressIndex(this, addressIndex, hard);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip44/CoinPairDerive.java",
    "content": "package com.quincysx.crypto.bip44;\n\nimport android.util.Log;\n\nimport com.quincysx.crypto.CoinTypes;\nimport com.quincysx.crypto.ECKeyPair;\nimport com.quincysx.crypto.bip32.ExtendedKey;\nimport com.quincysx.crypto.bip32.Index;\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.bitcoin.BitCoinECKeyPair;\nimport com.quincysx.crypto.eos.EOSECKeyPair;\nimport com.quincysx.crypto.ethereum.EthECKeyPair;\nimport com.quincysx.crypto.utils.HexUtils;\nimport com.quincysx.crypto.utils.SHA256;\n\nimport org.spongycastle.crypto.digests.MD5Digest;\nimport org.spongycastle.jcajce.provider.digest.MD5;\n\nimport java.util.Map;\nimport java.util.WeakHashMap;\n\n/**\n * @author QuincySx\n * @date 2018/3/5 下午3:48\n */\npublic class CoinPairDerive {\n    private ExtendedKey mExtendedKey;\n\n    public CoinPairDerive(ExtendedKey extendedKey) {\n        mExtendedKey = extendedKey;\n    }\n\n    public ExtendedKey deriveByExtendedKey(AddressIndex addressIndex) throws ValidationException {\n        int address = addressIndex.getValue();\n        int change = addressIndex.getParent().getValue();\n        int account = addressIndex.getParent().getParent().getValue();\n        CoinTypes coinType = addressIndex.getParent().getParent().getParent().getValue();\n        int purpose = addressIndex.getParent().getParent().getParent().getParent().getValue();\n\n        ExtendedKey child = mExtendedKey\n                .getChild(Index.hard(purpose))\n                .getChild(Index.hard(coinType.coinType()))\n                .getChild(Index.hard(account))\n                .getChild(change)\n                .getChild(address);\n        return child;\n    }\n\n    public ECKeyPair derive(AddressIndex addressIndex) throws ValidationException {\n        CoinTypes coinType = addressIndex.getParent().getParent().getParent().getValue();\n        ExtendedKey child = deriveByExtendedKey(addressIndex);\n        ECKeyPair ecKeyPair = convertKeyPair(child, coinType);\n        return ecKeyPair;\n    }\n\n    public ECKeyPair convertKeyPair(ExtendedKey child, CoinTypes coinType) throws ValidationException {\n        switch (coinType) {\n            case BitcoinTest:\n                return BitCoinECKeyPair.parse(child.getMaster(), true);// convertBitcoinKeyPair(new BigInteger(1, child.getMaster().getPrivate()), true);\n            case Ethereum:\n                return EthECKeyPair.parse(child.getMaster());//convertEthKeyPair(new BigInteger(1, child.getMaster().getPrivate()));\n            case EOS:\n                return EOSECKeyPair.parse(child.getMaster());\n            case Bitcoin:\n            default:\n                return BitCoinECKeyPair.parse(child.getMaster(), false);//convertBitcoinKeyPair(new BigInteger(1, child.getMaster().getPrivate()), false);\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip44/CoinType.java",
    "content": "package com.quincysx.crypto.bip44;\n\n\nimport com.quincysx.crypto.CoinTypes;\n\n/**\n * @author QuincySx\n * @date 2018/3/5 下午4:26\n */\npublic class CoinType {\n    private final Purpose purpose;\n    private final CoinTypes coinType;\n    private final String string;\n\n    CoinType(final Purpose purpose, final CoinTypes coinType) {\n        this.purpose = purpose;\n        this.coinType = coinType;\n        string = String.format(\"%s/%d'\", purpose, coinType.coinType());\n    }\n\n    public CoinTypes getValue() {\n        return coinType;\n    }\n\n    public Purpose getParent() {\n        return purpose;\n    }\n\n    @Override\n    public String toString() {\n        return string;\n    }\n\n    /**\n     * Create a {@link Account} for this purpose and coin type.\n     *\n     * @param account The account number\n     * @return An {@link Account} instance for this purpose and coin type\n     */\n    public Account account(final int account) {\n        return new Account(this, account);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip44/M.java",
    "content": "package com.quincysx.crypto.bip44;\n\n/**\n * @author QuincySx\n * @date 2018/3/5 下午4:25\n */\npublic final class M {\n    private final Purpose PURPOSE_44 = new Purpose(this, 44);\n    private final Purpose PURPOSE_49 = new Purpose(this, 49);\n\n    M() {\n    }\n\n    /**\n     * Create a {@link Purpose}.\n     * For 44 and 49 this function is guaranteed to return the same instance.\n     *\n     * @param purpose The purpose number.\n     * @return A purpose object.\n     */\n    public Purpose purpose(final int purpose) {\n        switch (purpose) {\n            case 44:\n                return PURPOSE_44;\n            case 49:\n                return PURPOSE_49;\n            default:\n                return new Purpose(this, purpose);\n        }\n    }\n\n    public Purpose purpose44() {\n        return PURPOSE_44;\n    }\n\n    public Purpose purpose49() {\n        return PURPOSE_49;\n    }\n\n    @Override\n    public String toString() {\n        return \"m\";\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bip44/Purpose.java",
    "content": "package com.quincysx.crypto.bip44;\n\nimport com.quincysx.crypto.CoinTypes;\nimport com.quincysx.crypto.bip32.Index;\n\n/**\n * @author QuincySx\n * @date 2018/3/5 下午4:26\n */\npublic final class Purpose {\n    private final M m;\n    private final int purpose;\n    private final String toString;\n\n    Purpose(final M m, final int purpose) {\n        this.m = m;\n        if (purpose == 0 || Index.isHardened(purpose))\n            throw new IllegalArgumentException();\n        this.purpose = purpose;\n        toString = String.format(\"%s/%d'\", m, purpose);\n    }\n\n    public int getValue() {\n        return purpose;\n    }\n\n    @Override\n    public String toString() {\n        return toString;\n    }\n\n    /**\n     * Create a {@link CoinType} for this purpose.\n     *\n     * @param coinType The coin type\n     * @return A coin type instance for this purpose\n     */\n    public CoinType coinType(final CoinTypes coinType) {\n        return new CoinType(this, coinType);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bitcoin/BTCTransaction.java",
    "content": "/*\n The MIT License (MIT)\n\n Copyright (c) 2013 Valentin Konovalov\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.*/\n\npackage com.quincysx.crypto.bitcoin;\n\nimport com.quincysx.crypto.ECKeyPair;\nimport com.quincysx.crypto.Transaction;\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.utils.BTCUtils;\nimport com.quincysx.crypto.utils.Base58;\nimport com.quincysx.crypto.utils.HexUtils;\nimport com.quincysx.crypto.utils.RIPEMD160;\nimport com.quincysx.crypto.utils.SHA256;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.EOFException;\nimport java.io.IOException;\nimport java.security.MessageDigest;\nimport java.security.NoSuchAlgorithmException;\nimport java.util.Arrays;\nimport java.util.Stack;\n\n@SuppressWarnings(\"WeakerAccess\")\npublic final class BTCTransaction implements Transaction {\n    public final int version;\n    public final Input[] inputs;\n    public final Output[] outputs;\n    public final int lockTime;\n\n    public BTCTransaction(byte[] rawBytes) throws BitcoinException {\n        if (rawBytes == null) {\n            throw new BitcoinException(BitcoinException.ERR_NO_INPUT, \"empty input\");\n        }\n        BitcoinInputStream bais = null;\n        try {\n            bais = new BitcoinInputStream(rawBytes);\n            version = bais.readInt32();\n            if (version != 1 && version != 2 && version != 3) {\n                throw new BitcoinException(BitcoinException.ERR_UNSUPPORTED, \"Unsupported TX \" +\n                        \"version\", version);\n            }\n            int inputsCount = (int) bais.readVarInt();\n            inputs = new Input[inputsCount];\n            for (int i = 0; i < inputsCount; i++) {\n                OutPoint outPoint = new OutPoint(BTCUtils.reverse(bais.readChars(32)), bais\n                        .readInt32());\n                byte[] script = bais.readChars((int) bais.readVarInt());\n                int sequence = bais.readInt32();\n                inputs[i] = new Input(outPoint, new Script(script), sequence);\n            }\n            int outputsCount = (int) bais.readVarInt();\n            outputs = new Output[outputsCount];\n            for (int i = 0; i < outputsCount; i++) {\n                long value = bais.readInt64();\n                long scriptSize = bais.readVarInt();\n                if (scriptSize < 0 || scriptSize > 10_000_000) {\n                    throw new BitcoinException(BitcoinException.ERR_BAD_FORMAT, \"Script size for \" +\n                            \"output \" + i +\n                            \" is strange (\" + scriptSize + \" bytes).\");\n                }\n                byte[] script = bais.readChars((int) scriptSize);\n                outputs[i] = new Output(value, new Script(script));\n            }\n            lockTime = bais.readInt32();\n        } catch (EOFException e) {\n            throw new BitcoinException(BitcoinException.ERR_BAD_FORMAT, \"TX incomplete\");\n        } catch (IOException e) {\n            throw new IllegalArgumentException(\"Unable to read TX\");\n        } catch (Error e) {\n            throw new IllegalArgumentException(\"Unable to read TX: \" + e);\n        } finally {\n            if (bais != null) {\n                try {\n                    bais.close();\n                } catch (IOException e) {\n                    e.printStackTrace();\n                }\n            }\n        }\n    }\n\n    public BTCTransaction(Input[] inputs, Output[] outputs, int lockTime) {\n        this.version = 2;\n        this.inputs = inputs;\n        this.outputs = outputs;\n        this.lockTime = lockTime;\n    }\n\n    @Override\n    public byte[] getSignBytes() {\n        return getBytes();\n    }\n\n    public byte[] getBytes() {\n        BitcoinOutputStream baos = new BitcoinOutputStream();\n        try {\n            baos.writeInt32(version);\n            baos.writeVarInt(inputs.length);\n            for (Input input : inputs) {\n                baos.write(BTCUtils.reverse(input.outPoint.hash));\n                baos.writeInt32(input.outPoint.index);\n                int scriptLen = input.script == null ? 0 : input.script.bytes.length;\n                baos.writeVarInt(scriptLen);\n                if (scriptLen > 0) {\n                    baos.write(input.script.bytes);\n                }\n                baos.writeInt32(input.sequence);\n            }\n            baos.writeVarInt(outputs.length);\n            for (Output output : outputs) {\n                baos.writeInt64(output.value);\n                int scriptLen = output.script == null ? 0 : output.script.bytes.length;\n                baos.writeVarInt(scriptLen);\n                if (scriptLen > 0) {\n                    baos.write(output.script.bytes);\n                }\n            }\n            baos.writeInt32(lockTime);\n        } catch (IOException e) {\n            e.printStackTrace();\n        } finally {\n            try {\n                baos.close();\n            } catch (IOException e) {\n                e.printStackTrace();\n            }\n        }\n        return baos.toByteArray();\n    }\n\n    @Override\n    public byte[] getData() {\n        return new byte[0];\n    }\n\n    @Override\n    public String toString() {\n        return \"{\" +\n                \"\\n\\\"inputs\\\":\\n\" + printAsJsonArray(inputs) +\n                \",\\n\\\"outputs\\\":\\n\" + printAsJsonArray(outputs) +\n                \",\\n\\\"lockTime\\\":\\\"\" + lockTime + \"\\\"\\n\" +\n                \",\\n\\\"version\\\":\\\"\" + version + \"\\\"}\\n\";\n    }\n\n    private String printAsJsonArray(Object[] a) {\n        if (a == null) {\n            return \"null\";\n        }\n        if (a.length == 0) {\n            return \"[]\";\n        }\n        int iMax = a.length - 1;\n        StringBuilder sb = new StringBuilder();\n        sb.append('[');\n        for (int i = 0; ; i++) {\n            sb.append(String.valueOf(a[i]));\n            if (i == iMax)\n                return sb.append(']').toString();\n            sb.append(\",\\n\");\n        }\n    }\n\n    public static class Input {\n        public final OutPoint outPoint;\n        public final Script script;\n        public final int sequence;\n\n        public Input(OutPoint outPoint, Script script, int sequence) {\n            this.outPoint = outPoint;\n            this.script = script;\n            this.sequence = sequence;\n        }\n\n        @Override\n        public String toString() {\n            return \"{\\n\\\"outPoint\\\":\" + outPoint + \",\\n\\\"script\\\":\\\"\" + script + \"\\\",\" +\n                    \"\\n\\\"sequence\\\":\\\"\" + Integer.toHexString(sequence) + \"\\\"\\n}\\n\";\n        }\n    }\n\n    public static class OutPoint {\n        public final byte[] hash;//32-byte hash of the transaction from which we want to redeem\n        // an output\n        public final int index;//Four-byte field denoting the output index we want to redeem from\n        // the transaction with the above hash (output number 2 = output index 1)\n\n        public OutPoint(byte[] hash, int index) {\n            this.hash = hash;\n            this.index = index;\n        }\n\n        @Override\n        public String toString() {\n            return \"{\" + \"\\\"hash\\\":\\\"\" + HexUtils.toHex(hash) + \"\\\", \\\"index\\\":\\\"\" + index + \"\\\"}\";\n        }\n    }\n\n    public static class Output {\n        public final long value;\n        public final Script script;\n\n        public Output(long value, Script script) {\n            this.value = value;\n            this.script = script;\n        }\n\n        @Override\n        public String toString() {\n            return \"{\\n\\\"value\\\":\\\"\" + value * 1e-8 + \"\\\",\\\"script\\\":\\\"\" + script + \"\\\"\\n}\";\n        }\n    }\n\n    public static final class Script {\n\n        public static class ScriptInvalidException extends Exception {\n            public ScriptInvalidException() {\n            }\n\n            public ScriptInvalidException(String s) {\n                super(s);\n            }\n        }\n\n        public static final byte OP_FALSE = 0;\n        public static final byte OP_TRUE = 0x51;\n        public static final byte OP_PUSHDATA1 = 0x4c;\n        public static final byte OP_PUSHDATA2 = 0x4d;\n        public static final byte OP_PUSHDATA4 = 0x4e;\n        public static final byte OP_DUP = 0x76;//Duplicates the top stack item.\n        public static final byte OP_DROP = 0x75;\n        public static final byte OP_HASH160 = (byte) 0xA9;//The input is hashed twice: first with\n        // SHA-256 and then with RIPEMD-160.\n        public static final byte OP_VERIFY = 0x69;//Marks transaction as invalid if top stack\n        // value is not true. True is removed, but false is not.\n        public static final byte OP_EQUAL = (byte) 0x87;//Returns 1 if the inputs are exactly\n        // equal, 0 otherwise.\n        public static final byte OP_EQUALVERIFY = (byte) 0x88;//Same as OP_EQUAL, but runs\n        // OP_VERIFY afterward.\n        public static final byte OP_CHECKSIG = (byte) 0xAC;//The entire transaction's outputs,\n        // inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are\n        // hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and\n        // public key. If it is, 1 is returned, 0 otherwise.\n        public static final byte OP_CHECKSIGVERIFY = (byte) 0xAD;\n        public static final byte OP_NOP = 0x61;\n\n        public static final byte OP_RETURN = 0x6a;\n\n        public static final byte SIGHASH_ALL = 1;\n\n        public final byte[] bytes;\n\n        public Script(byte[] rawBytes) {\n            bytes = rawBytes;\n        }\n\n        public Script(byte[] data1, byte[] data2) {\n            ByteArrayOutputStream baos = new ByteArrayOutputStream(data1.length + data2.length + 2);\n            try {\n                writeBytes(data1, baos);\n                writeBytes(data2, baos);\n                baos.close();\n            } catch (IOException e) {\n                throw new RuntimeException(e);\n            }\n            bytes = baos.toByteArray();\n        }\n\n        private static void writeBytes(byte[] data, ByteArrayOutputStream baos) throws IOException {\n            if (data.length < OP_PUSHDATA1) {\n                baos.write(data.length);\n            } else if (data.length < 0xff) {\n                baos.write(OP_PUSHDATA1);\n                baos.write(data.length);\n            } else if (data.length < 0xffff) {\n//                baos.write(OP_PUSHDATA2);\n//                baos.write(data.length);\n                baos.write(OP_PUSHDATA2);\n                baos.write(data.length & 0xff);\n                baos.write((data.length >> 8) & 0xff);\n            } else {\n//                baos.write(OP_PUSHDATA4);\n//                baos.write(data.length);\n                baos.write(OP_PUSHDATA4);\n                baos.write(data.length & 0xff);\n                baos.write((data.length >> 8) & 0xff);\n                baos.write((data.length >> 16) & 0xff);\n                baos.write((data.length >>> 24) & 0xff);\n            }\n            baos.write(data);\n        }\n\n        public void run(Stack<byte[]> stack) throws ScriptInvalidException {\n            run(0, null, stack);\n        }\n\n        public void run(int inputIndex, BTCTransaction tx, Stack<byte[]> stack) throws\n                ScriptInvalidException {\n            for (int pos = 0; pos < bytes.length; pos++) {\n                switch (bytes[pos]) {\n                    case OP_NOP:\n                        break;\n                    case OP_DROP:\n                        if (stack.isEmpty()) {\n                            throw new IllegalArgumentException(\"stack empty on OP_DROP\");\n                        }\n                        stack.pop();\n                        break;\n                    case OP_DUP:\n                        if (stack.isEmpty()) {\n                            throw new IllegalArgumentException(\"stack empty on OP_DUP\");\n                        }\n                        stack.push(stack.peek());\n                        break;\n                    case OP_HASH160:\n                        if (stack.isEmpty()) {\n                            throw new IllegalArgumentException(\"stack empty on OP_HASH160\");\n                        }\n                        stack.push(RIPEMD160.hash160(stack.pop()));\n                        break;\n                    case OP_EQUAL:\n                    case OP_EQUALVERIFY:\n                        if (stack.size() < 2) {\n                            throw new IllegalArgumentException(\"not enough elements to perform \" +\n                                    \"OP_EQUAL\");\n                        }\n                        stack.push(new byte[]{(byte) (Arrays.equals(stack.pop(), stack.pop()) ? 1\n                                : 0)});\n                        if (bytes[pos] == OP_EQUALVERIFY) {\n                            if (verifyFails(stack)) {\n                                throw new ScriptInvalidException(\"wrong address\");\n                            }\n                        }\n                        break;\n                    case OP_VERIFY:\n                        if (verifyFails(stack)) {\n                            throw new ScriptInvalidException();\n                        }\n                        break;\n                    case OP_CHECKSIG:\n                    case OP_CHECKSIGVERIFY:\n                        byte[] publicKey = stack.pop();\n                        byte[] signatureAndHashType = stack.pop();\n                        if (signatureAndHashType[signatureAndHashType.length - 1] != SIGHASH_ALL) {\n                            throw new IllegalArgumentException(\"I cannot check this sig type: \" +\n                                    signatureAndHashType[signatureAndHashType.length - 1]);\n                        }\n                        byte[] signature = new byte[signatureAndHashType.length - 1];\n                        System.arraycopy(signatureAndHashType, 0, signature, 0, signature.length);\n                        byte[] hash = hashTransaction(inputIndex, bytes, tx);\n                        boolean valid = BTCUtils.verify(publicKey, signature, hash);\n                        if (bytes[pos] == OP_CHECKSIG) {\n                            stack.push(new byte[]{(byte) (valid ? 1 : 0)});\n                        } else {\n                            if (verifyFails(stack)) {\n                                throw new ScriptInvalidException(\"Bad signature\");\n                            }\n                            if (!stack.empty()) {\n                                throw new ScriptInvalidException(\"Bad signature - superfluous \" +\n                                        \"scriptSig operations\");\n                            }\n                        }\n                        break;\n                    case OP_FALSE:\n                        stack.push(new byte[]{0});\n                        break;\n                    case OP_TRUE:\n                        stack.push(new byte[]{1});\n                        break;\n                    default:\n                        int op = bytes[pos] & 0xff;\n                        int len;\n                        if (op < OP_PUSHDATA1) {\n                            len = op;\n                            byte[] data = new byte[len];\n                            System.arraycopy(bytes, pos + 1, data, 0, len);\n                            stack.push(data);\n                            pos += data.length;\n                        } else if (op == OP_PUSHDATA1) {\n                            len = bytes[pos + 1] & 0xff;\n                            byte[] data = new byte[len];\n                            System.arraycopy(bytes, pos + 1, data, 0, len);\n                            stack.push(data);\n                            pos += 1 + data.length;\n                        } else {\n                            throw new IllegalArgumentException(\"I cannot read this data: \" +\n                                    Integer.toHexString(bytes[pos]));\n                        }\n                        break;\n                }\n            }\n        }\n\n        public static byte[] hashTransaction(int inputIndex, byte[] subscript, BTCTransaction tx) {\n            Input[] unsignedInputs = new Input[tx.inputs.length];\n            for (int i = 0; i < tx.inputs.length; i++) {\n                Input txInput = tx.inputs[i];\n                if (i == inputIndex) {\n                    unsignedInputs[i] = new Input(txInput.outPoint, new Script(subscript),\n                            txInput.sequence);\n                } else {\n                    unsignedInputs[i] = new Input(txInput.outPoint, new Script(new byte[0]),\n                            txInput.sequence);\n                }\n            }\n            BTCTransaction unsignedTransaction = new BTCTransaction(unsignedInputs, tx.outputs,\n                    tx.lockTime);\n            return hashTransactionForSigning(unsignedTransaction);\n        }\n\n        public static byte[] hashTransactionForSigning(BTCTransaction unsignedTransaction) {\n            byte[] txUnsignedBytes = unsignedTransaction.getSignBytes();\n            BitcoinOutputStream baos = new BitcoinOutputStream();\n            try {\n                baos.write(txUnsignedBytes);\n                baos.writeInt32(BTCTransaction.Script.SIGHASH_ALL);\n                baos.close();\n            } catch (Exception e) {\n                throw new RuntimeException(e);\n            }\n            return SHA256.doubleSha256(baos.toByteArray());\n        }\n\n        public static boolean verifyFails(Stack<byte[]> stack) {\n            byte[] input;\n            boolean valid;\n            input = stack.pop();\n            if (input.length == 0 || (input.length == 1 && input[0] == OP_FALSE)) {\n                //false\n                stack.push(new byte[]{OP_FALSE});\n                valid = false;\n            } else {\n                //true\n                valid = true;\n            }\n            return !valid;\n        }\n\n\n        @Override\n        public String toString() {\n            return convertBytesToReadableString(bytes);\n        }\n\n        //converts something like \"OP_DUP OP_HASH160 ba507bae8f1643d2556000ca26b9301b9069dc6b\n        // OP_EQUALVERIFY OP_CHECKSIG\" into bytes\n        public static byte[] convertReadableStringToBytes(String readableString) {\n            String[] tokens = readableString.trim().split(\"\\\\s+\");\n            ByteArrayOutputStream os = new ByteArrayOutputStream();\n            for (String token : tokens) {\n                switch (token) {\n                    case \"OP_NOP\":\n                        os.write(OP_NOP);\n                        break;\n                    case \"OP_DROP\":\n                        os.write(OP_DROP);\n                        break;\n                    case \"OP_DUP\":\n                        os.write(OP_DUP);\n                        break;\n                    case \"OP_HASH160\":\n                        os.write(OP_HASH160);\n                        break;\n                    case \"OP_EQUAL\":\n                        os.write(OP_EQUAL);\n                        break;\n                    case \"OP_EQUALVERIFY\":\n                        os.write(OP_EQUALVERIFY);\n                        break;\n                    case \"OP_VERIFY\":\n                        os.write(OP_VERIFY);\n                        break;\n                    case \"OP_CHECKSIG\":\n                        os.write(OP_CHECKSIG);\n                        break;\n                    case \"OP_CHECKSIGVERIFY\":\n                        os.write(OP_CHECKSIGVERIFY);\n                        break;\n                    case \"OP_FALSE\":\n                        os.write(OP_FALSE);\n                        break;\n                    case \"OP_TRUE\":\n                        os.write(OP_TRUE);\n                        break;\n                    default:\n                        if (token.startsWith(\"OP_\")) {\n                            throw new IllegalArgumentException(\"I don't know this operation: \" +\n                                    token);\n                        }\n                        byte[] data = HexUtils.fromHex(token);\n                        if (data == null) {\n                            throw new IllegalArgumentException(\"I don't know what's this: \" +\n                                    token);\n                        }\n                        if (data.length < OP_PUSHDATA1) {\n                            os.write(data.length);\n                            try {\n                                os.write(data);\n                            } catch (IOException e) {\n                                throw new RuntimeException(\"ByteArrayOutputStream behaves weird: \" +\n                                        \"\" + e);\n                            }\n                        } else if (data.length <= 255) {\n                            os.write(OP_PUSHDATA1);\n                            os.write(data.length);\n                            try {\n                                os.write(data);\n                            } catch (IOException e) {\n                                throw new RuntimeException(\"ByteArrayOutputStream behaves weird: \" +\n                                        \"\" + e);\n                            }\n                        } else {\n                            throw new IllegalArgumentException(\"OP_PUSHDATA2 & OP_PUSHDATA4 are \" +\n                                    \"not supported\");\n                        }\n                        break;\n                }\n            }\n            try {\n                os.close();\n            } catch (IOException e) {\n                e.printStackTrace();\n            }\n            return os.toByteArray();\n        }\n\n        public static String convertBytesToReadableString(byte[] bytes) {\n            StringBuilder sb = new StringBuilder();\n            for (int pos = 0; pos < bytes.length; pos++) {\n                if (sb.length() > 0) {\n                    sb.append(' ');\n                }\n                switch (bytes[pos]) {\n                    case OP_NOP:\n                        sb.append(\"OP_NOP\");\n                        break;\n                    case OP_DROP:\n                        sb.append(\"OP_DROP\");\n                        break;\n                    case OP_DUP:\n                        sb.append(\"OP_DUP\");\n                        break;\n                    case OP_HASH160:\n                        sb.append(\"OP_HASH160\");\n                        break;\n                    case OP_EQUAL:\n                        sb.append(\"OP_EQUAL\");\n                        break;\n                    case OP_EQUALVERIFY:\n                        sb.append(\"OP_EQUALVERIFY\");\n                        break;\n                    case OP_VERIFY:\n                        sb.append(\"OP_VERIFY\");\n                        break;\n                    case OP_CHECKSIG:\n                        sb.append(\"OP_CHECKSIG\");\n                        break;\n                    case OP_CHECKSIGVERIFY:\n                        sb.append(\"OP_CHECKSIGVERIFY\");\n                        break;\n                    case OP_FALSE:\n                        sb.append(\"OP_FALSE\");\n                        break;\n                    case OP_TRUE:\n                        sb.append(\"OP_TRUE\");\n                        break;\n                    default:\n                        int op = bytes[pos] & 0xff;\n                        int len;\n                        if (op < OP_PUSHDATA1) {\n                            len = op;\n                            byte[] data = new byte[len];\n                            System.arraycopy(bytes, pos + 1, data, 0, len);\n                            sb.append(HexUtils.toHex(data));\n                            pos += data.length;\n                        } else if (op == OP_PUSHDATA1) {\n                            len = bytes[pos + 1] & 0xff;\n                            byte[] data = new byte[len];\n                            System.arraycopy(bytes, pos + 1, data, 0, len);//FIXME I suspect\n                            // there is off by one error...\n                            sb.append(HexUtils.toHex(data));\n                            pos += 1 + data.length;\n                        } else {\n                            throw new IllegalArgumentException(\"I cannot read this data: \" +\n                                    Integer.toHexString(bytes[pos]) + \" at \" + pos);\n                        }\n                        break;\n                }\n            }\n            return sb.toString();\n        }\n\n        @Override\n        public boolean equals(Object o) {\n            return this == o || !(o == null || getClass() != o.getClass()) && Arrays.equals\n                    (bytes, ((Script) o).bytes);\n        }\n\n        @Override\n        public int hashCode() {\n            return Arrays.hashCode(bytes);\n        }\n\n        public static Script buildOutput(String address) throws BitcoinException {\n            //noinspection TryWithIdenticalCatches\n            try {\n                byte[] addressWithCheckSumAndNetworkCode = Base58.decode(address);\n                if (addressWithCheckSumAndNetworkCode[0] != 0\n                        && addressWithCheckSumAndNetworkCode[0] != 111\n                        && addressWithCheckSumAndNetworkCode[0] != 5) {\n                    throw new BitcoinException(BitcoinException.ERR_UNSUPPORTED, \"Unknown address\" +\n                            \" type\", address);\n                }\n                byte[] bareAddress = new byte[20];\n                System.arraycopy(addressWithCheckSumAndNetworkCode, 1, bareAddress, 0,\n                        bareAddress.length);\n                MessageDigest digestSha = MessageDigest.getInstance(\"SHA-256\");\n                digestSha.update(addressWithCheckSumAndNetworkCode, 0,\n                        addressWithCheckSumAndNetworkCode.length - 4);\n                byte[] calculatedDigest = digestSha.digest(digestSha.digest());\n                for (int i = 0; i < 4; i++) {\n                    if (calculatedDigest[i] !=\n                            addressWithCheckSumAndNetworkCode[addressWithCheckSumAndNetworkCode\n                                    .length - 4 + i]) {\n                        throw new BitcoinException(BitcoinException.ERR_BAD_FORMAT, \"Bad \" +\n                                \"address\", address);\n                    }\n                }\n\n                if (addressWithCheckSumAndNetworkCode[0] == 5) {\n                    //P2SH 的锁定脚本\n                    ByteArrayOutputStream buf = new ByteArrayOutputStream();\n                    buf.write(OP_HASH160);\n                    writeBytes(bareAddress, buf);\n                    buf.write(OP_EQUAL);\n                    return new Script(buf.toByteArray());\n                } else {\n                    //P2PKH 的锁定脚本\n                    ByteArrayOutputStream buf = new ByteArrayOutputStream(25);\n                    buf.write(OP_DUP);\n                    buf.write(OP_HASH160);\n                    writeBytes(bareAddress, buf);\n                    buf.write(OP_EQUALVERIFY);\n                    buf.write(OP_CHECKSIG);\n                    return new Script(buf.toByteArray());\n                }\n            } catch (NoSuchAlgorithmException e) {\n                throw new RuntimeException(e);\n            } catch (IOException e) {\n                throw new RuntimeException(e);\n            }\n        }\n\n    }\n\n    @Override\n    public byte[] sign(ECKeyPair key) throws ValidationException {\n        BTCTransaction sign = key.sign(this.getSignBytes());\n        int length = sign.inputs.length;\n        for (int i = 0; i < length; i++) {\n            this.inputs[i] = sign.inputs[i];\n        }\n//        return sign.getSignBytes();\n        return getSignBytes();\n    }\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bitcoin/BitCoinECKeyPair.java",
    "content": "package com.quincysx.crypto.bitcoin;\n\nimport com.quincysx.crypto.ECKeyPair;\nimport com.quincysx.crypto.Key;\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.utils.Base58;\nimport com.quincysx.crypto.utils.Base58Check;\nimport com.quincysx.crypto.utils.HexUtils;\nimport com.quincysx.crypto.utils.RIPEMD160;\nimport com.quincysx.crypto.utils.SHA256;\n\nimport org.spongycastle.asn1.ASN1Integer;\nimport org.spongycastle.asn1.DERInteger;\nimport org.spongycastle.asn1.DERSequenceGenerator;\nimport org.spongycastle.crypto.digests.SHA256Digest;\nimport org.spongycastle.crypto.params.ECPrivateKeyParameters;\nimport org.spongycastle.crypto.params.ParametersWithRandom;\nimport org.spongycastle.crypto.signers.ECDSASigner;\nimport org.spongycastle.crypto.signers.HMacDSAKCalculator;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\nimport java.math.BigInteger;\nimport java.util.Arrays;\n\n/**\n * @author QuincySx\n * @date 2018/3/8 上午10:56\n */\npublic class BitCoinECKeyPair extends ECKeyPair {\n    private static final int TEST_NET_ADDRESS_SUFFIX = 0x6f;\n    private static final int MAIN_NET_ADDRESS_SUFFIX = 0x00;\n\n    public static final int MAIN_NET_PRIVATE_KEY_PREFIX = 0x80;\n    public static final int TEST_NET_PRIVATE_KEY_PREFIX = 0xef;\n    private static final int MAIN_NET_PRIVATE_KEY_SUFFIX = 0x01;\n\n    private static final int RAW_PRIVATE_KEY_COMPRESSED_LENGTH = 38;\n    private static final int RAW_PRIVATE_KEY_NO_COMPRESSED_LENGTH = 37;\n\n    private final boolean testNet;\n\n    public static BitCoinECKeyPair parse(Key keyPair, boolean testNet) {\n        return new BitCoinECKeyPair(keyPair, testNet);\n    }\n\n    public static BitCoinECKeyPair parseWIF(String wif) throws ValidationException {\n        byte[] decode = Base58.decode(wif);\n\n        //判断私钥格式\n        byte[] check = new byte[4];\n        System.arraycopy(decode, decode.length - 4, check, 0, check.length);\n        byte[] privateCheck = SHA256.doubleSha256(decode, 0, decode.length - 4);\n        for (int i = 0; i < 4; i++) {\n            if (check[i] != privateCheck[i]) {\n                throw new ValidationException(\"WIF Private Key Incorrect format\");\n            }\n        }\n\n        boolean isCompressed = false;\n        if (decode.length == RAW_PRIVATE_KEY_COMPRESSED_LENGTH) {\n            isCompressed = true;\n        }\n\n        boolean isTestNet = false;\n        if ((decode[0] & 0xFF) == TEST_NET_PRIVATE_KEY_PREFIX) {\n            isTestNet = true;\n        }\n\n        byte[] bytes = new byte[32];\n        System.arraycopy(decode, 1, bytes, 0, bytes.length);\n\n        return new BitCoinECKeyPair(bytes, isTestNet, isCompressed);\n    }\n\n    public BitCoinECKeyPair(byte[] p, boolean testNet, boolean compressed) throws\n            ValidationException {\n        super(p, compressed);\n        this.testNet = testNet;\n    }\n\n    public BitCoinECKeyPair(BigInteger priv, boolean testNet, boolean compressed) {\n        super(priv, compressed);\n        this.testNet = testNet;\n    }\n\n    public BitCoinECKeyPair(Key keyPair, boolean testNet) {\n        super(keyPair);\n        this.testNet = testNet;\n    }\n\n    protected BitCoinECKeyPair(BigInteger priv, boolean compressed) throws ValidationException {\n        super(priv, compressed);\n        this.testNet = false;\n    }\n\n    public boolean isTestNet() {\n        return testNet;\n    }\n\n    @Override\n    public String getPrivateKey() {\n        byte[] bytes = getRawPrivateKey();\n        byte[] rawPrivateKey = new byte[isCompressed() ? RAW_PRIVATE_KEY_COMPRESSED_LENGTH :\n                RAW_PRIVATE_KEY_NO_COMPRESSED_LENGTH];\n        System.arraycopy(bytes, 0, rawPrivateKey, 1, bytes.length);\n\n        rawPrivateKey[0] = (byte) (isTestNet() ? TEST_NET_PRIVATE_KEY_PREFIX :\n                MAIN_NET_PRIVATE_KEY_PREFIX);\n        if (isCompressed()) {\n            rawPrivateKey[rawPrivateKey.length - 5] = MAIN_NET_PRIVATE_KEY_SUFFIX;\n        }\n\n        byte[] check = SHA256.doubleSha256(rawPrivateKey, 0, rawPrivateKey.length - 4);\n        System.arraycopy(check, 0, rawPrivateKey, rawPrivateKey.length - 4, 4);\n        return Base58.encode(rawPrivateKey);\n    }\n\n    @Override\n    public String getPublicKey() {\n        return HexUtils.toHex(getRawPublicKey());\n    }\n\n    @Override\n    public String getAddress() {\n        return Base58.encode(getRawAddress());\n    }\n\n    @Override\n    public byte[] getRawPublicKey() {\n        return getRawPublicKey(isCompressed());\n    }\n\n    @Override\n    public byte[] getRawAddress() {\n        byte[] hashedPublicKey;\n        //进行 Sha256 Ripemd160 运算\n        if (isCompressed()) {\n            hashedPublicKey = RIPEMD160.hash160(pubComp);\n        } else {\n            hashedPublicKey = RIPEMD160.hash160(pub);\n        }\n        byte[] addressBytes = new byte[1 + hashedPublicKey.length + 4];\n        //拼接测试网络或正式网络前缀\n        addressBytes[0] = (byte) (testNet ? TEST_NET_ADDRESS_SUFFIX : MAIN_NET_ADDRESS_SUFFIX);\n\n        System.arraycopy(hashedPublicKey, 0, addressBytes, 1, hashedPublicKey.length);\n        //进行双 Sha256 运算\n        byte[] check = SHA256.doubleSha256(addressBytes, 0, addressBytes.length - 4);\n\n        //将双 Sha256 运算的结果前 4位 拼接到尾部\n        System.arraycopy(check, 0, addressBytes, hashedPublicKey.length + 1, 4);\n\n        Arrays.fill(hashedPublicKey, (byte) 0);\n        Arrays.fill(check, (byte) 0);\n        return addressBytes;\n    }\n\n    @Override\n    public BTCTransaction sign(byte[] messageHash) throws ValidationException {\n        try {\n            BTCTransaction btcTransaction = new BTCTransaction(messageHash);\n            return signTransaction(btcTransaction, priv, getRawPublicKey(), getAddress());\n        } catch (BitcoinException e) {\n            e.printStackTrace();\n            throw new ValidationException(e);\n        }\n    }\n\n    public byte[] signBTC(byte[] hash) {\n        ECDSASigner signer = new ECDSASigner();\n        signer.init(true, new ECPrivateKeyParameters(priv, domain));\n        BigInteger[] signature = signer.generateSignature(hash);\n        ByteArrayOutputStream s = new ByteArrayOutputStream();\n        try {\n            DERSequenceGenerator seq = new DERSequenceGenerator(s);\n            seq.addObject(new DERInteger(signature[0]));\n            seq.addObject(new DERInteger(signature[1]));\n            seq.close();\n            return s.toByteArray();\n        } catch (IOException e) {\n        }\n        return null;\n    }\n\n    public boolean verifyBTC(byte[] hash, byte[] signature) {\n        return verify(hash, signature, pubComp);\n    }\n\n    private static void checkChecksum(byte[] store) throws ValidationException {\n        byte[] checksum = new byte[4];\n        System.arraycopy(store, store.length - 4, checksum, 0, 4);\n        byte[] ekey = new byte[store.length - 4];\n        System.arraycopy(store, 0, ekey, 0, store.length - 4);\n        byte[] hash = SHA256.doubleSha256(ekey);\n        for (int i = 0; i < 4; ++i) {\n            if (hash[i] != checksum[i]) {\n                throw new ValidationException(\"checksum mismatch\");\n            }\n        }\n    }\n\n    public static BTCTransaction signTransaction(BTCTransaction transaction, BigInteger\n            privateKeyBigInteger, byte[] publicKey, String address) {\n        BTCTransaction.Input[] signedInput = new BTCTransaction.Input[transaction.inputs.length];\n        for (int i = 0; i < transaction.inputs.length; i++) {\n            signedInput[i] = sign(transaction, i, privateKeyBigInteger, publicKey, address,\n                    BTCTransaction.Script.SIGHASH_ALL);\n        }\n        return new BTCTransaction(signedInput, transaction.outputs, transaction.lockTime);\n    }\n\n    /**\n     * 对单个Input进行签名\n     *\n     * @param transaction 交易\n     * @param index       Input索引\n     * @reture 签名完毕的Input\n     */\n    public static BTCTransaction.Input sign(BTCTransaction transaction, int index, BigInteger\n            privateKeyBigInteger, byte[] publicKey, String address, byte ScriptType) {\n        String publicScript = mkPubKeyScript(address);\n        //清空无关Input的Script,对相关Script进行签名\n        signatureForm(transaction, index, publicScript);\n\n        //双 Sha256 and 签名\n        byte[] signature = sign(privateKeyBigInteger, BTCTransaction.Script\n                .hashTransactionForSigning(transaction));\n\n        //拼版本\n        byte[] signatureAndHashType = new byte[signature.length + 1];\n        System.arraycopy(signature, 0, signatureAndHashType, 0, signature.length);\n        signatureAndHashType[signatureAndHashType.length - 1] = ScriptType;\n\n        //拼出新的input\n        return new BTCTransaction.Input(transaction.inputs[index].outPoint, new BTCTransaction\n                .Script(signatureAndHashType, publicKey), transaction.inputs[index].sequence);\n    }\n\n    /**\n     * 设置Input的地址签名\n     *\n     * @param transaction  交易\n     * @param index        索引\n     * @param publicScript 地址签名\n     * @return 新的交易\n     */\n    private static BTCTransaction signatureForm(BTCTransaction transaction, int index, String\n            publicScript) {\n        //存放清空地址签名的Input\n        for (int i = 0; i < transaction.inputs.length; i++) {\n            BTCTransaction.Script script = null;\n            if (i == index) {\n                //设置地址签名\n                script = new BTCTransaction.Script(HexUtils.fromHex(publicScript));\n\n            }\n            transaction.inputs[i] = new BTCTransaction.Input(transaction.inputs[i].outPoint,\n                    script, transaction.inputs[i].sequence);\n        }\n        return transaction;\n    }\n\n    /**\n     * 签署地址签名\n     *\n     * @param address 地址\n     * @return 签名\n     */\n    private static String mkPubKeyScript(String address) {\n        //设置加密格式\n        StringBuilder stringBuilder = new StringBuilder();\n        stringBuilder.append(\"76a914\");\n\n        //设置签名\n        byte[] bytes = Base58Check.base58ToBytes(address);\n        byte[] checkByte = new byte[bytes.length - 1];\n        System.arraycopy(bytes, 1, checkByte, 0, checkByte.length);\n        stringBuilder.append(HexUtils.toHex(checkByte));\n\n        Arrays.fill(bytes, (byte) 0);\n        Arrays.fill(checkByte, (byte) 0);\n\n        //设置签名后缀格式\n        stringBuilder.append(\"88ac\");\n        return stringBuilder.toString();\n    }\n\n    public static byte[] sign(BigInteger privateKey, byte[] input) {\n        synchronized (domain) {\n            ECDSASigner signer = new ECDSASigner(new HMacDSAKCalculator(new SHA256Digest()));\n            ECPrivateKeyParameters privateKeyParam = new ECPrivateKeyParameters(privateKey, domain);\n            signer.init(true, new ParametersWithRandom(privateKeyParam, secureRandom));\n            BigInteger[] sign = signer.generateSignature(input);\n            BigInteger r = sign[0];\n            BigInteger s = sign[1];\n            BigInteger largestAllowedS = new BigInteger\n                    (\"7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0\", 16);\n            //SECP256K1_N_DIV_2\n            if (s.compareTo(largestAllowedS) > 0) {\n                //https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki#low-s-values-in\n                // -signatures\n                s = LARGEST_PRIVATE_KEY.subtract(s);\n            }\n            try {\n                ByteArrayOutputStream baos = new ByteArrayOutputStream(72);\n                DERSequenceGenerator derGen = new DERSequenceGenerator(baos);\n                derGen.addObject(new ASN1Integer(r));\n                derGen.addObject(new ASN1Integer(s));\n                derGen.close();\n                return baos.toByteArray();\n            } catch (IOException e) {\n                throw new RuntimeException(e);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bitcoin/BitcoinException.java",
    "content": "/*\n The MIT License (MIT)\n\n Copyright (c) 2013-2014 Valentin Konovalov\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.*/\npackage com.quincysx.crypto.bitcoin;\n\n@SuppressWarnings(\"WeakerAccess\")\npublic final class BitcoinException extends Exception {\n    public static final int ERR_NO_SPENDABLE_OUTPUTS_FOR_THE_ADDRESS = 0;\n    public static final int ERR_INSUFFICIENT_FUNDS = 1;\n    public static final int ERR_WRONG_TYPE = 2;\n    public static final int ERR_BAD_FORMAT = 3;\n    public static final int ERR_INCORRECT_PASSWORD = 4;\n    public static final int ERR_MEANINGLESS_OPERATION = 5;\n    public static final int ERR_NO_INPUT = 6;\n    public static final int ERR_FEE_IS_TOO_BIG = 7;\n    public static final int ERR_FEE_IS_LESS_THEN_ZERO = 8;\n    public static final int ERR_CHANGE_IS_LESS_THEN_ZERO = 9;\n    public static final int ERR_AMOUNT_TO_SEND_IS_LESS_THEN_ZERO = 10;\n    public static final int ERR_UNSUPPORTED = 11;\n\n    public final int errorCode;\n    @SuppressWarnings({\"WeakerAccess\", \"unused\"})\n    public final Object extraInformation;\n\n    public BitcoinException(int errorCode, String detailMessage, Object extraInformation) {\n        super(detailMessage);\n        this.errorCode = errorCode;\n        this.extraInformation = extraInformation;\n    }\n\n    public BitcoinException(int errorCode, String detailMessage) {\n        this(errorCode, detailMessage, null);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bitcoin/BitcoinInputStream.java",
    "content": "/*\n The MIT License (MIT)\n\n Copyright (c) 2013 Valentin Konovalov\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.*/\npackage com.quincysx.crypto.bitcoin;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.EOFException;\nimport java.io.IOException;\n\n@SuppressWarnings(\"WeakerAccess\")\npublic class BitcoinInputStream extends ByteArrayInputStream {\n    public BitcoinInputStream(byte[] buf) {\n        super(buf);\n    }\n\n    @SuppressWarnings(\"unused\")\n    public BitcoinInputStream(byte[] buf, int offset, int length) {\n        super(buf, offset, length);\n    }\n\n    public int readInt16() throws EOFException {\n        return (readByte() & 0xff) | ((readByte() & 0xff) << 8);\n    }\n\n    public int readInt32() throws EOFException {\n        return (readByte() & 0xff) | ((readByte() & 0xff) << 8) | ((readByte() & 0xff) << 16) | ((readByte() & 0xff) << 24);\n    }\n\n    public long readInt64() throws EOFException {\n        return (readInt32() & 0xFFFFFFFFL )| ((readInt32() & 0xFFFFFFFFL) << 32);\n    }\n\n    public int readByte() throws EOFException {\n        int readedByte = super.read();\n        if (readedByte == -1) {\n            throw new EOFException();\n        }\n        return readedByte;\n    }\n\n    public long readVarInt() throws EOFException {\n        int readedByte = readByte();\n        if (readedByte < 0xfd) {\n            return readedByte;\n        } else if (readedByte == 0xfd) {\n            return readInt16();\n        } else if (readedByte == 0xfe) {\n            return readInt32();\n        } else {\n            return readInt64();\n        }\n    }\n\n    public byte[] readChars(final int count) throws IOException {\n        byte[] buf = new byte[count];\n        int off = 0;\n        while (off != count) {\n            int bytesReadCurr = read(buf, off, count - off);\n            if (bytesReadCurr == -1) {\n                throw new EOFException();\n            } else {\n                off += bytesReadCurr;\n            }\n        }\n        return buf;\n    }\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/bitcoin/BitcoinOutputStream.java",
    "content": "/*\n The MIT License (MIT)\n\n Copyright (c) 2013 Valentin Konovalov\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.*/\n\npackage com.quincysx.crypto.bitcoin;\n\nimport java.io.ByteArrayOutputStream;\n\n@SuppressWarnings(\"WeakerAccess\")\npublic final class BitcoinOutputStream extends ByteArrayOutputStream {\n\n    public void writeInt16(int value) {\n        write(value & 0xff);\n        write((value >> 8) & 0xff);\n    }\n\n    public void writeInt32(int value) {\n        write(value & 0xff);\n        write((value >> 8) & 0xff);\n        write((value >> 16) & 0xff);\n        write((value >>> 24) & 0xff);\n    }\n\n    public void writeInt64(long value) {\n        writeInt32((int) (value & 0xFFFFFFFFL));\n        writeInt32((int) ((value >>> 32) & 0xFFFFFFFFL));\n    }\n\n    public void writeVarInt(long value) {\n        if (value < 0xfd) {\n            write((int) (value & 0xff));\n        } else if (value < 0xffff) {\n            write(0xfd);\n            writeInt16((int) value);\n        } else if (value < 0xffffffffL) {\n            write(0xfe);\n            writeInt32((int) value);\n        } else {\n            write(0xff);\n            writeInt64(value);\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/eip55/EthCheckAddress.java",
    "content": "package com.quincysx.crypto.eip55;\n\nimport com.quincysx.crypto.utils.HexUtils;\nimport com.quincysx.crypto.utils.KECCAK256;\n\n/**\n * @author QuincySx\n * @date 2018/6/20 下午5:39\n */\npublic class EthCheckAddress {\n    /**\n     * 生成 Checksum 的地址\n     *\n     * @param address 普通地址\n     * @return Checksum 地址\n     */\n    public static String toChecksumAddress(String address) {\n        String lowercaseAddress = cleanHexPrefix(address).toLowerCase();\n        String addressHash = (HexUtils.toHex(KECCAK256.keccak256(lowercaseAddress.getBytes())));\n\n        StringBuilder result = new StringBuilder(lowercaseAddress.length() + 2);\n\n        if (containsHexPrefix(address)) {\n            result.append(\"0x\");\n        }\n\n        for (int i = 0; i < lowercaseAddress.length(); i++) {\n            if (Integer.parseInt(String.valueOf(addressHash.charAt(i)), 16) >= 8) {\n                result.append(String.valueOf(lowercaseAddress.charAt(i)).toUpperCase());\n            } else {\n                result.append(lowercaseAddress.charAt(i));\n            }\n        }\n\n        return result.toString();\n    }\n\n    /**\n     * 检查 ETH 地址是否合法\n     *\n     * @param address ETH 地址\n     * @return true：合法 false：不合法\n     */\n    public static boolean checksumAddress(String address) {\n        if (!containsHexPrefix(address)) {\n            //没有前缀 0x\n            return false;\n        } else if (checkUppercase(cleanHexPrefix(address))) {\n            String checksumAddress = toChecksumAddress(address);\n            if (checksumAddress.equals(address)) {\n                return true;\n            }\n            return false;\n        } else {\n            return true;\n        }\n    }\n\n    /**\n     * 检查字符串中是否有大写英文字母\n     *\n     * @param address ETH 地址\n     * @return true：大写 false：小写\n     */\n    private static boolean checkUppercase(String address) {\n        for (int i = 0; i < address.length(); i++) {\n            char c = address.charAt(i);\n            if (Character.isUpperCase(c)) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    /**\n     * 如果字符串 0x 开头则去掉\n     *\n     * @param input 要处理的字符串\n     * @return 处理完成的字符串\n     */\n    public static String cleanHexPrefix(String input) {\n        if (containsHexPrefix(input)) {\n            return input.substring(2);\n        } else {\n            return input;\n        }\n    }\n\n    /**\n     * 检查字符串是否是 0x 开头\n     *\n     * @param input 要检测的字符串\n     * @return true：0x 开头 false：不是 0x 开头\n     */\n    public static boolean containsHexPrefix(String input) {\n        return !isEmpty(input) && input.length() > 1\n                && input.charAt(0) == '0' && input.charAt(1) == 'x';\n    }\n\n    private static boolean isEmpty(String s) {\n        return s == null || s.length() == 0;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/eos/EOSECKeyPair.java",
    "content": "package com.quincysx.crypto.eos;\n\nimport com.quincysx.crypto.ECKeyPair;\nimport com.quincysx.crypto.Key;\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.utils.Base58;\nimport com.quincysx.crypto.utils.KECCAK256;\nimport com.quincysx.crypto.utils.RIPEMD160;\nimport com.quincysx.crypto.utils.SHA256;\n\nimport java.lang.reflect.Array;\nimport java.math.BigInteger;\nimport java.util.Arrays;\n\n/**\n * @author QuincySx\n * @date 2018/6/13 上午11:28\n */\npublic class EOSECKeyPair extends ECKeyPair {\n    public static final String address_prefix = \"EOS\";\n    public static final int PRIVATE_KEY_PREFIX = 0x80;\n\n    public static EOSECKeyPair parse(Key keyPair) {\n        return new EOSECKeyPair(keyPair);\n    }\n\n    public static EOSECKeyPair parse(String privateKey) throws ValidationException {\n        byte[] decode = Base58.decode(privateKey);\n        byte[] checksum = SHA256.doubleSha256(decode, 0, decode.length - 4);\n        for (int i = 0; i < 4; i++) {\n            if (decode[decode.length - 4 + i] != checksum[i]) {\n                throw new ValidationException(\"私钥验证失败\");\n            }\n        }\n        byte[] key = new byte[decode.length - 5];\n        System.arraycopy(decode, 1, key, 0, key.length);\n        BigInteger integer = new BigInteger(1, key);\n\n        Arrays.fill(key, (byte) 0);\n        Arrays.fill(decode, (byte) 0);\n        Arrays.fill(checksum, (byte) 0);\n        return new EOSECKeyPair(integer);\n    }\n\n    public EOSECKeyPair(byte[] p) throws ValidationException {\n        super(p, true);\n    }\n\n    public EOSECKeyPair(BigInteger priv) {\n        super(priv, true);\n    }\n\n    public EOSECKeyPair(Key keyPair) {\n        super(keyPair);\n    }\n\n    @Override\n    public byte[] getRawPrivateKey() {\n        return super.getRawPrivateKey();\n    }\n\n    @Override\n    public String getPrivateKey() {\n        byte[] rawPrivateKey = getRawPrivateKey();\n        byte[] privateKey = new byte[rawPrivateKey.length + 5];\n\n        privateKey[0] = (byte) PRIVATE_KEY_PREFIX;\n        System.arraycopy(rawPrivateKey, 0, privateKey, 1, rawPrivateKey.length);\n\n        byte[] checksum = SHA256.doubleSha256(privateKey, 0, privateKey.length - 4);\n        System.arraycopy(checksum, 0, privateKey, rawPrivateKey.length + 1, 4);\n\n        Arrays.fill(checksum, (byte) 0);\n        Arrays.fill(rawPrivateKey, (byte) 0);\n        return Base58.encode(privateKey);\n    }\n\n    @Override\n    public byte[] getRawPublicKey() {\n        byte[] publicKey = new byte[pubComp.length];\n        System.arraycopy(pubComp, 0, publicKey, 0, publicKey.length);\n        return publicKey;\n    }\n\n    @Override\n    public String getPublicKey() {\n        byte[] rawPublicKey = getRawPublicKey();\n        byte[] publicKey = new byte[rawPublicKey.length + 4];\n        System.arraycopy(rawPublicKey, 0, publicKey, 0, rawPublicKey.length);\n\n        byte[] bytes = RIPEMD160.ripemd160(rawPublicKey);\n        System.arraycopy(bytes, 0, publicKey, rawPublicKey.length, 4);\n\n        StringBuffer bf = new StringBuffer(address_prefix);\n        bf.append(Base58.encode(publicKey));\n\n        Arrays.fill(rawPublicKey, (byte) 0);\n        Arrays.fill(publicKey, (byte) 0);\n        Arrays.fill(bytes, (byte) 0);\n        return bf.toString();\n    }\n\n    @Override\n    public byte[] getRawAddress() {\n        byte[] byteAddress = KECCAK256.keccak256(getRawPublicKey());\n        byte[] address = new byte[20];\n        System.arraycopy(byteAddress, 12, address, 0, address.length);\n        return address;\n    }\n\n    @Override\n    public String getAddress() {\n        return getPublicKey();\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/Bloom.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum;\n\nimport com.quincysx.crypto.ethereum.utils.ByteUtil;\n\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.util.Arrays;\n\n/**\n * See http://www.herongyang.com/Java/Bit-String-Set-Bit-to-Byte-Array.html.\n *\n * @author Roman Mandeleil\n * @since 20.11.2014\n */\n\npublic class Bloom {\n\n    final static int _8STEPS = 8;\n    final static int _3LOW_BITS = 7;\n    final static int ENSURE_BYTE = 255;\n\n    byte[] data = new byte[256];\n\n\n    public Bloom() {\n    }\n\n    public Bloom(byte[] data) {\n        this.data = data;\n    }\n\n    public static Bloom create(byte[] toBloom) {\n\n        int mov1 = (((toBloom[0] & ENSURE_BYTE) & (_3LOW_BITS)) << _8STEPS) + ((toBloom[1]) & ENSURE_BYTE);\n        int mov2 = (((toBloom[2] & ENSURE_BYTE) & (_3LOW_BITS)) << _8STEPS) + ((toBloom[3]) & ENSURE_BYTE);\n        int mov3 = (((toBloom[4] & ENSURE_BYTE) & (_3LOW_BITS)) << _8STEPS) + ((toBloom[5]) & ENSURE_BYTE);\n\n        byte[] data = new byte[256];\n        Bloom bloom = new Bloom(data);\n\n        ByteUtil.setBit(data, mov1, 1);\n        ByteUtil.setBit(data, mov2, 1);\n        ByteUtil.setBit(data, mov3, 1);\n\n        return bloom;\n    }\n\n    public void or(Bloom bloom) {\n        for (int i = 0; i < data.length; ++i) {\n            data[i] |= bloom.data[i];\n        }\n    }\n\n    public boolean matches(Bloom topicBloom) {\n        Bloom copy = copy();\n        copy.or(topicBloom);\n        return this.equals(copy);\n    }\n\n    public byte[] getData() {\n        return data;\n    }\n\n    public Bloom copy() {\n        return new Bloom(Arrays.copyOf(getData(), getData().length));\n    }\n\n    @Override\n    public String toString() {\n        return Hex.toHexString(data);\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n\n        Bloom bloom = (Bloom) o;\n\n        return Arrays.equals(data, bloom.data);\n\n    }\n\n    @Override\n    public int hashCode() {\n        return data != null ? Arrays.hashCode(data) : 0;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/ByteArrayWrapper.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum;\n\nimport com.quincysx.crypto.ethereum.utils.FastByteComparisons;\n\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.io.Serializable;\nimport java.util.Arrays;\n\n/**\n * @author Roman Mandeleil\n * @since 11.06.2014\n */\npublic class ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable {\n\n    private final byte[] data;\n    private int hashCode = 0;\n\n    public ByteArrayWrapper(byte[] data) {\n        if (data == null)\n            throw new NullPointerException(\"Data must not be null\");\n        this.data = data;\n        this.hashCode = Arrays.hashCode(data);\n    }\n\n    public boolean equals(Object other) {\n        if (!(other instanceof ByteArrayWrapper))\n            return false;\n        byte[] otherData = ((ByteArrayWrapper) other).getData();\n        return FastByteComparisons.compareTo(\n                data, 0, data.length,\n                otherData, 0, otherData.length) == 0;\n    }\n\n    @Override\n    public int hashCode() {\n        return hashCode;\n    }\n\n    @Override\n    public int compareTo(ByteArrayWrapper o) {\n        return FastByteComparisons.compareTo(\n                data, 0, data.length,\n                o.getData(), 0, o.getData().length);\n    }\n\n    public byte[] getData() {\n        return data;\n    }\n\n    @Override\n    public String toString() {\n        return Hex.toHexString(data);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/CallTransaction.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum;\n\nimport static com.quincysx.crypto.ethereum.utils.ByteUtil.longToBytesNoLeadZeroes;\nimport static java.lang.String.format;\n\nimport static com.quincysx.crypto.ethereum.solidity.SolidityType.IntType;\n\nimport com.fasterxml.jackson.annotation.JsonGetter;\nimport com.fasterxml.jackson.annotation.JsonInclude;\nimport com.fasterxml.jackson.databind.DeserializationFeature;\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport com.quincysx.crypto.ethereum.solidity.SolidityType;\nimport com.quincysx.crypto.ethereum.utils.ByteUtil;\nimport com.quincysx.crypto.ethereum.utils.FastByteComparisons;\nimport com.quincysx.crypto.ethereum.vm.LogInfo;\nimport com.quincysx.crypto.utils.KECCAK256;\n\nimport java.io.IOException;\nimport java.math.BigInteger;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.function.Function;\n\nimport org.spongycastle.pqc.math.linearalgebra.ByteUtils;\nimport org.spongycastle.util.BigIntegers;\nimport org.spongycastle.util.encoders.Hex;\n\n/**\n * Creates a contract function call transaction.\n * Serializes arguments according to the function ABI .\n * <p>\n * Created by Anton Nashatyrev on 25.08.2015.\n */\npublic class CallTransaction {\n\n    private final static ObjectMapper DEFAULT_MAPPER = new ObjectMapper()\n            .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)\n            .enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL);\n\n    public static EthTransaction createRawTransaction(BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String toAddress,\n                                                      BigInteger value, byte[] data) {\n        EthTransaction tx = new EthTransaction(BigIntegers.asUnsignedByteArray(nonce),\n                BigIntegers.asUnsignedByteArray(gasPrice),\n                BigIntegers.asUnsignedByteArray(gasLimit),\n                toAddress == null ? null : Hex.decode(toAddress),\n                BigIntegers.asUnsignedByteArray(value),\n                data,\n                null);\n        return tx;\n    }\n\n\n    /**\n     * 创建交易\n     *\n     * @param nonce     nonce\n     * @param gasPrice  gasPrice\n     * @param gasLimit  gasLimit\n     * @param toAddress toAddress\n     * @param value     value\n     * @param callFunc  调用合约方法\n     * @param funcArgs  合约参数（Int 数值请使用BigInteger或字符串）\n     * @return 交易\n     */\n    public static EthTransaction createCallTransaction(BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String toAddress,\n                                                       BigInteger value, Function callFunc, Object... funcArgs) {\n        byte[] callData = callFunc.encode(funcArgs);\n        return createRawTransaction(nonce, gasPrice, gasLimit, toAddress, value, callData);\n    }\n\n    @JsonInclude(JsonInclude.Include.NON_NULL)\n    public static class Param {\n        public Boolean indexed;\n        public String name;\n        public SolidityType type;\n\n        @JsonGetter(\"type\")\n        public String getType() {\n            return type.getName();\n        }\n    }\n\n    public enum FunctionType {\n        constructor,\n        function,\n        event,\n        fallback\n    }\n\n    public static class Function {\n        public boolean anonymous;\n        public boolean constant;\n        public boolean payable;\n        public String name = \"\";\n        public Param[] inputs = new Param[0];\n        public Param[] outputs = new Param[0];\n        public FunctionType type;\n\n        private Function() {\n        }\n\n        public byte[] encode(Object... args) {\n            return ByteUtil.merge(encodeSignature(), encodeArguments(args));\n        }\n\n        public byte[] encodeArguments(Object... args) {\n            if (args.length > inputs.length)\n                throw new RuntimeException(\"Too many arguments: \" + args.length + \" > \" + inputs.length);\n\n            int staticSize = 0;\n            int dynamicCnt = 0;\n            // calculating static size and number of dynamic params\n            for (int i = 0; i < args.length; i++) {\n                Param param = inputs[i];\n                if (param.type.isDynamicType()) {\n                    dynamicCnt++;\n                }\n                staticSize += param.type.getFixedSize();\n            }\n\n            byte[][] bb = new byte[args.length + dynamicCnt][];\n\n            int curDynamicPtr = staticSize;\n            int curDynamicCnt = 0;\n            for (int i = 0; i < args.length; i++) {\n                if (inputs[i].type.isDynamicType()) {\n                    byte[] dynBB = inputs[i].type.encode(args[i]);\n                    bb[i] = SolidityType.IntType.encodeInt(curDynamicPtr);\n                    bb[args.length + curDynamicCnt] = dynBB;\n                    curDynamicCnt++;\n                    curDynamicPtr += dynBB.length;\n                } else {\n                    bb[i] = inputs[i].type.encode(args[i]);\n                }\n            }\n            return ByteUtil.merge(bb);\n        }\n\n        private Object[] decode(byte[] encoded, Param[] params) {\n            Object[] ret = new Object[params.length];\n\n            int off = 0;\n            for (int i = 0; i < params.length; i++) {\n                if (params[i].type.isDynamicType()) {\n                    ret[i] = params[i].type.decode(encoded, IntType.decodeInt(encoded, off).intValue());\n                } else {\n                    ret[i] = params[i].type.decode(encoded, off);\n                }\n                off += params[i].type.getFixedSize();\n            }\n            return ret;\n        }\n\n        public Object[] decode(byte[] encoded) {\n            //import static org.apache.commons.lang3.ArrayUtils.subarray;\n            //return decode(subarray(encoded, 4, encoded.length), inputs);\n            return decode(ByteUtils.subArray(encoded, 4, encoded.length), inputs);\n        }\n\n        public Object[] decodeResult(byte[] encodedRet) {\n            return decode(encodedRet, outputs);\n        }\n\n        public String formatSignature() {\n            StringBuilder paramsTypes = new StringBuilder();\n            for (Param param : inputs) {\n                paramsTypes.append(param.type.getCanonicalName()).append(\",\");\n            }\n            //import static org.apache.commons.lang3.StringUtils.stripEnd;\n            //return format(\"%s(%s)\", name, stripEnd(paramsTypes.toString(), \",\"));\n            return format(\"%s(%s)\", name, stripEnd(paramsTypes.toString(), \",\"));\n        }\n\n        public static String stripEnd(final String str, final String stripChars) {\n            int end;\n            if (str == null || (end = str.length()) == 0) {\n                return str;\n            }\n\n\n            if (stripChars == null) {\n                while (end != 0 && Character.isWhitespace(str.charAt(end - 1))) {\n                    end--;\n                }\n            } else if (stripChars.isEmpty()) {\n                return str;\n            } else {\n                while (end != 0 && stripChars.indexOf(str.charAt(end - 1)) != -1) {\n                    end--;\n                }\n            }\n            return str.substring(0, end);\n        }\n\n        public byte[] encodeSignatureLong() {\n            String signature = formatSignature();\n//            byte[] sha3Fingerprint = sha3(signature.getSignBytes());\n            byte[] sha3Fingerprint = KECCAK256.keccak256(signature.getBytes());\n            return sha3Fingerprint;\n        }\n\n        public byte[] encodeSignature() {\n            return Arrays.copyOfRange(encodeSignatureLong(), 0, 4);\n        }\n\n        @Override\n        public String toString() {\n            return formatSignature();\n        }\n\n        public static Function fromJsonInterface(String json) {\n            try {\n                return DEFAULT_MAPPER.readValue(json, Function.class);\n            } catch (IOException e) {\n                throw new RuntimeException(e);\n            }\n        }\n\n        public static Function fromSignature(String funcName, String... paramTypes) {\n            return fromSignature(funcName, paramTypes, new String[0]);\n        }\n\n        public static Function fromSignature(String funcName, String[] paramTypes, String[] resultTypes) {\n            Function ret = new Function();\n            ret.name = funcName;\n            ret.constant = false;\n            ret.type = FunctionType.function;\n            ret.inputs = new Param[paramTypes.length];\n            for (int i = 0; i < paramTypes.length; i++) {\n                ret.inputs[i] = new Param();\n                ret.inputs[i].name = \"param\" + i;\n                ret.inputs[i].type = SolidityType.getType(paramTypes[i]);\n            }\n            ret.outputs = new Param[resultTypes.length];\n            for (int i = 0; i < resultTypes.length; i++) {\n                ret.outputs[i] = new Param();\n                ret.outputs[i].name = \"res\" + i;\n                ret.outputs[i].type = SolidityType.getType(resultTypes[i]);\n            }\n            return ret;\n        }\n\n\n    }\n\n    public static class Contract {\n        public Contract(String jsonInterface) {\n            try {\n                functions = new ObjectMapper().readValue(jsonInterface, Function[].class);\n            } catch (IOException e) {\n                throw new RuntimeException(e);\n            }\n        }\n\n        public Function getByName(String name) {\n            for (Function function : functions) {\n                if (name.equals(function.name)) {\n                    return function;\n                }\n            }\n            return null;\n        }\n\n        public Function getConstructor() {\n            for (Function function : functions) {\n                if (function.type == FunctionType.constructor) {\n                    return function;\n                }\n            }\n            return null;\n        }\n\n        private Function getBySignatureHash(byte[] hash) {\n            if (hash.length == 4) {\n                for (Function function : functions) {\n                    if (FastByteComparisons.equal(function.encodeSignature(), hash)) {\n                        return function;\n                    }\n                }\n            } else if (hash.length == 32) {\n                for (Function function : functions) {\n                    if (FastByteComparisons.equal(function.encodeSignatureLong(), hash)) {\n                        return function;\n                    }\n                }\n            } else {\n                throw new RuntimeException(\"Function signature hash should be 4 or 32 bytes length\");\n            }\n            return null;\n        }\n\n        /**\n         * Parses function and its arguments from transaction invocation binary data\n         */\n        public Invocation parseInvocation(byte[] data) {\n            if (data.length < 4) throw new RuntimeException(\"Invalid data length: \" + data.length);\n            Function function = getBySignatureHash(Arrays.copyOfRange(data, 0, 4));\n            if (function == null)\n                throw new RuntimeException(\"Can't find function/event by it signature\");\n            Object[] args = function.decode(data);\n            return new Invocation(this, function, args);\n        }\n\n        /**\n         * Parses Solidity Event and its data members from transaction receipt LogInfo\n         */\n        public Invocation parseEvent(LogInfo eventLog) {\n            Function event = getBySignatureHash(eventLog.getTopics().get(0).getData());\n            int indexedArg = 1;\n            if (event == null) return null;\n            List<Object> indexedArgs = new ArrayList<>();\n            List<Param> unindexed = new ArrayList<>();\n            for (Param input : event.inputs) {\n                if (input.indexed) {\n                    indexedArgs.add(input.type.decode(eventLog.getTopics().get(indexedArg++).getData()));\n                    continue;\n                }\n                unindexed.add(input);\n            }\n\n            Object[] unindexedArgs = event.decode(eventLog.getData(), unindexed.toArray(new Param[unindexed.size()]));\n            Object[] args = new Object[event.inputs.length];\n            int unindexedIndex = 0;\n            int indexedIndex = 0;\n            for (int i = 0; i < args.length; i++) {\n                if (event.inputs[i].indexed) {\n                    args[i] = indexedArgs.get(indexedIndex++);\n                    continue;\n                }\n                args[i] = unindexedArgs[unindexedIndex++];\n            }\n            return new Invocation(this, event, args);\n        }\n\n        public Function[] functions;\n    }\n\n    /**\n     * Represents either function invocation with its arguments\n     * or Event instance with its data members\n     */\n    public static class Invocation {\n        public final Contract contract;\n        public final Function function;\n        public final Object[] args;\n\n        public Invocation(Contract contract, Function function, Object[] args) {\n            this.contract = contract;\n            this.function = function;\n            this.args = args;\n        }\n\n        @Override\n        public String toString() {\n            return \"[\" + \"contract=\" + contract +\n                    (function.type == FunctionType.event ? \", event=\" : \", function=\")\n                    + function + \", args=\" + Arrays.toString(args) + ']';\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/ECDSASignature.java",
    "content": "package com.quincysx.crypto.ethereum;\n\nimport com.quincysx.crypto.ethereum.config.Constants;\nimport com.quincysx.crypto.utils.Base64;\n\nimport org.spongycastle.asn1.ASN1InputStream;\nimport org.spongycastle.asn1.ASN1Integer;\nimport org.spongycastle.asn1.DLSequence;\nimport org.spongycastle.asn1.sec.SECNamedCurves;\nimport org.spongycastle.asn1.x9.X9ECParameters;\nimport org.spongycastle.crypto.params.ECDomainParameters;\nimport org.spongycastle.jce.spec.ECParameterSpec;\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.io.IOException;\nimport java.math.BigInteger;\nimport java.security.SecureRandom;\n\n/**\n * @author QuincySx\n * @date 2018/3/6 上午9:46\n */\npublic class ECDSASignature {\n    /**\n     * The parameters of the secp256k1 curve that Ethereum uses.\n     */\n    public static final ECDomainParameters CURVE;\n    public static final ECParameterSpec CURVE_SPEC;\n\n    /**\n     * Equal to CURVE.getN().shiftRight(1), used for canonicalising the S value of a signature.\n     * ECDSA signatures are mutable in the sense that for a given (R, S) pair,\n     * then both (R, S) and (R, N - S mod N) are valid signatures.\n     * Canonical signatures are those where 1 <= S <= N/2\n     * <p>\n     * See https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki#Low_S_values_in_signatures\n     */\n    public static final BigInteger HALF_CURVE_ORDER;\n\n    private static final SecureRandom secureRandom;\n\n    static {\n        // All clients must agree on the curve to use by agreement. Ethereum uses secp256k1.\n        X9ECParameters params = SECNamedCurves.getByName(\"secp256k1\");\n        CURVE = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH());\n        CURVE_SPEC = new ECParameterSpec(params.getCurve(), params.getG(), params.getN(), params.getH());\n        HALF_CURVE_ORDER = params.getN().shiftRight(1);\n        secureRandom = new SecureRandom();\n    }\n\n    /**\n     * The two components of the signature.\n     */\n    public final BigInteger r;\n    public final BigInteger s;\n    public byte v;\n\n    /**\n     * Constructs a signature with the given components. Does NOT automatically canonicalise the signature.\n     *\n     * @param r -\n     * @param s -\n     */\n    public ECDSASignature(BigInteger r, BigInteger s) {\n        this.r = r;\n        this.s = s;\n    }\n\n    /**\n     * t\n     *\n     * @param r\n     * @param s\n     * @return -\n     */\n    private static ECDSASignature fromComponents(byte[] r, byte[] s) {\n        return new ECDSASignature(new BigInteger(1, r), new BigInteger(1, s));\n    }\n\n    /**\n     * @param r -\n     * @param s -\n     * @param v -\n     * @return -\n     */\n    public static ECDSASignature fromComponents(byte[] r, byte[] s, byte v) {\n        ECDSASignature signature = fromComponents(r, s);\n        signature.v = v;\n        return signature;\n    }\n\n    public boolean validateComponents() {\n        return validateComponents(r, s, v);\n    }\n\n    public static boolean validateComponents(BigInteger r, BigInteger s, byte v) {\n\n        if (v != 27 && v != 28) return false;\n\n        if (isLessThan(r, BigInteger.ONE)) return false;\n        if (isLessThan(s, BigInteger.ONE)) return false;\n\n        if (!isLessThan(r, Constants.getSECP256K1N())) return false;\n        if (!isLessThan(s, Constants.getSECP256K1N())) return false;\n\n        return true;\n    }\n\n    public static ECDSASignature decodeFromDER(byte[] bytes) {\n        ASN1InputStream decoder = null;\n        try {\n            decoder = new ASN1InputStream(bytes);\n            DLSequence seq = (DLSequence) decoder.readObject();\n            if (seq == null)\n                throw new RuntimeException(\"Reached past end of ASN.1 stream.\");\n            ASN1Integer r, s;\n            try {\n                r = (ASN1Integer) seq.getObjectAt(0);\n                s = (ASN1Integer) seq.getObjectAt(1);\n            } catch (ClassCastException e) {\n                throw new IllegalArgumentException(e);\n            }\n            // OpenSSL deviates from the DER spec by interpreting these values as unsigned, though they should not be\n            // Thus, we always use the positive versions. See: http://r6.ca/blog/20111119T211504Z.html\n            return new ECDSASignature(r.getPositiveValue(), s.getPositiveValue());\n        } catch (IOException e) {\n            throw new RuntimeException(e);\n        } finally {\n            if (decoder != null)\n                try {\n                    decoder.close();\n                } catch (IOException x) {\n                }\n        }\n    }\n\n    /**\n     * Will automatically adjust the S component to be less than or equal to half the curve order, if necessary.\n     * This is required because for every signature (r,s) the signature (r, -s (mod N)) is a valid signature of\n     * the same message. However, we dislike the ability to modify the bits of a Ethereum transaction after it's\n     * been signed, as that violates various assumed invariants. Thus in future only one of those forms will be\n     * considered legal and the other will be banned.\n     *\n     * @return -\n     */\n    public ECDSASignature toCanonicalised() {\n        if (s.compareTo(HALF_CURVE_ORDER) > 0) {\n            // The order of the curve is the number of valid points that exist on that curve. If S is in the upper\n            // half of the number of valid points, then bring it back to the lower half. Otherwise, imagine that\n            //    N = 10\n            //    s = 8, so (-8 % 10 == 2) thus both (r, 8) and (r, 2) are valid solutions.\n            //    10 - 8 == 2, giving us always the latter solution, which is canonical.\n            return new ECDSASignature(r, CURVE.getN().subtract(s));\n        } else {\n            return this;\n        }\n    }\n\n    /**\n     * @return -\n     */\n    public String toBase64() {\n        byte[] sigData = new byte[65];  // 1 header + 32 bytes for R + 32 bytes for S\n        sigData[0] = v;\n        System.arraycopy(bigIntegerToBytes(this.r, 32), 0, sigData, 1, 32);\n        System.arraycopy(bigIntegerToBytes(this.s, 32), 0, sigData, 33, 32);\n        return Base64.encode(sigData);\n    }\n\n    public byte[] toByteArray() {\n        final byte fixedV = this.v >= 27\n                ? (byte) (this.v - 27)\n                : this.v;\n\n        return merge(\n                bigIntegerToBytes(this.r),\n                bigIntegerToBytes(this.s),\n                new byte[]{fixedV});\n    }\n\n    public String toHex() {\n        return Hex.toHexString(toByteArray());\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n\n        ECDSASignature signature = (ECDSASignature) o;\n\n        if (!r.equals(signature.r)) return false;\n        if (!s.equals(signature.s)) return false;\n\n        return true;\n    }\n\n    public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) {\n        if (b == null)\n            return null;\n        byte[] bytes = new byte[numBytes];\n        byte[] biBytes = b.toByteArray();\n        int start = (biBytes.length == numBytes + 1) ? 1 : 0;\n        int length = Math.min(biBytes.length, numBytes);\n        System.arraycopy(biBytes, start, bytes, numBytes - length, length);\n        return bytes;\n    }\n\n    public static byte[] merge(byte[]... arrays) {\n        int arrCount = 0;\n        int count = 0;\n        for (byte[] array : arrays) {\n            arrCount++;\n            count += array.length;\n        }\n\n        // Create new array and copy all array contents\n        byte[] mergedArray = new byte[count];\n        int start = 0;\n        for (byte[] array : arrays) {\n            System.arraycopy(array, 0, mergedArray, start, array.length);\n            start += array.length;\n        }\n        return mergedArray;\n    }\n\n    public static byte[] bigIntegerToBytes(BigInteger value) {\n        if (value == null)\n            return null;\n\n        byte[] data = value.toByteArray();\n\n        if (data.length != 1 && data[0] == 0) {\n            byte[] tmp = new byte[data.length - 1];\n            System.arraycopy(data, 1, tmp, 0, tmp.length);\n            data = tmp;\n        }\n        return data;\n    }\n\n    /**\n     * Cast hex encoded value from byte[] to BigInteger\n     * null is parsed like byte[0]\n     *\n     * @param bb byte array contains the values\n     * @return unsigned positive BigInteger value.\n     */\n    public static BigInteger bytesToBigInteger(byte[] bb) {\n        return (bb == null || bb.length == 0) ? BigInteger.ZERO : new BigInteger(1, bb);\n    }\n\n    public static boolean isLessThan(BigInteger valueA, BigInteger valueB) {\n        return valueA.compareTo(valueB) < 0;\n    }\n\n    @Override\n    public int hashCode() {\n        int result = r.hashCode();\n        result = 31 * result + s.hashCode();\n        return result;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/EthECKeyPair.java",
    "content": "package com.quincysx.crypto.ethereum;\n\nimport com.quincysx.crypto.ECKeyPair;\nimport com.quincysx.crypto.Key;\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.eip55.EthCheckAddress;\nimport com.quincysx.crypto.utils.HexUtils;\nimport com.quincysx.crypto.utils.KECCAK256;\n\nimport org.spongycastle.asn1.x9.X9IntegerConverter;\nimport org.spongycastle.crypto.digests.SHA256Digest;\nimport org.spongycastle.crypto.params.ECPrivateKeyParameters;\nimport org.spongycastle.crypto.signers.ECDSASigner;\nimport org.spongycastle.crypto.signers.HMacDSAKCalculator;\nimport org.spongycastle.math.ec.ECAlgorithms;\nimport org.spongycastle.math.ec.ECCurve;\nimport org.spongycastle.math.ec.ECPoint;\n\nimport java.math.BigInteger;\n\n/**\n * @author QuincySx\n * @date 2018/3/7 下午5:51\n */\npublic class EthECKeyPair extends ECKeyPair {\n    public static EthECKeyPair parse(Key keyPair) {\n        return new EthECKeyPair(keyPair);\n    }\n\n    public EthECKeyPair(byte[] p) throws ValidationException {\n        super(p, true);\n    }\n\n    public EthECKeyPair(BigInteger priv) {\n        super(priv, true);\n    }\n\n    public EthECKeyPair(Key keyPair) {\n        super(keyPair);\n    }\n\n    @Override\n    public byte[] getRawPrivateKey() {\n        return super.getRawPrivateKey();\n    }\n\n    @Override\n    public String getPrivateKey() {\n        return HexUtils.toHex(getRawPrivateKey());\n    }\n\n    @Override\n    public byte[] getRawPublicKey() {\n        byte[] publicKey = new byte[pub.length - 1];\n        System.arraycopy(pub, 1, publicKey, 0, publicKey.length);\n        return publicKey;\n    }\n\n    @Override\n    public String getPublicKey() {\n        return HexUtils.toHex(getRawPublicKey());\n    }\n\n    @Override\n    public byte[] getRawAddress() {\n        byte[] byteAddress = KECCAK256.keccak256(getRawPublicKey());\n        byte[] address = new byte[20];\n        System.arraycopy(byteAddress, 12, address, 0, address.length);\n        return address;\n    }\n\n    @Override\n    public String getAddress() {\n        return EthCheckAddress.toChecksumAddress(HexUtils.toHex(getRawAddress()));\n    }\n\n    public ECDSASignature doSign(byte[] input) {\n        if (input.length != 32) {\n            throw new IllegalArgumentException(\"Expected 32 byte input to ECDSA signature, not \"\n                    + input.length);\n        }\n        // No decryption of private key required.\n        ECDSASigner signer = new ECDSASigner(new HMacDSAKCalculator(new SHA256Digest()));\n        ECPrivateKeyParameters privKeyParams = new ECPrivateKeyParameters(priv, domain);\n        signer.init(true, privKeyParams);\n        BigInteger[] components = signer.generateSignature(input);\n        return new ECDSASignature(components[0], components[1]).toCanonicalised();\n    }\n\n    public ECDSASignature sign(byte[] messageHash) {\n        ECDSASignature sig = doSign(messageHash);\n        // Now we have to work backwards to figure out the recId needed to recover the signature.\n        int recId = -1;\n        for (int i = 0; i < 4; i++) {\n            byte[] k = recoverPubBytesFromSignature(i, sig, messageHash);\n            if (k != null && java.util.Arrays.equals(k, pub)) {\n                recId = i;\n                break;\n            }\n        }\n        if (recId == -1)\n            throw new RuntimeException(\"Could not construct a recoverable key. This should never \" +\n                    \"happen.\");\n        sig.v = (byte) (recId + 27);\n        return sig;\n    }\n\n    public static byte[] recoverPubBytesFromSignature(int recId, ECDSASignature sig, byte[]\n            messageHash) {\n        check(recId >= 0, \"recId must be positive\");\n        check(sig.r.signum() >= 0, \"r must be positive\");\n        check(sig.s.signum() >= 0, \"s must be positive\");\n        check(messageHash != null, \"messageHash must not be null\");\n        // 1.0 For j from 0 to h   (h == recId here and the loop is outside this function)\n        //   1.1 Let x = r + jn\n        BigInteger n = CURVE.getN();  // Curve order.\n        BigInteger i = BigInteger.valueOf((long) recId / 2);\n        BigInteger x = sig.r.add(i.multiply(n));\n        //   1.2. Convert the integer x to an octet string X of length mlen using the conversion\n        // routine\n        //        specified in Section 2.3.7, where mlen = ⌈(log2 p)/8⌉ or mlen = ⌈m/8⌉.\n        //   1.3. Convert the octet string (16 set binary digits)||X to an elliptic curve point R\n        // using the\n        //        conversion routine specified in Section 2.3.4. If this conversion routine\n        // outputs “invalid”, then\n        //        do another iteration of Step 1.\n        //\n        // More concisely, what these points mean is to use X as a compressed public key.\n        ECCurve.Fp curve = (ECCurve.Fp) CURVE.getCurve();\n        BigInteger prime = curve.getQ();  // Bouncy Castle is not consistent about the letter it\n        // uses for the prime.\n        if (x.compareTo(prime) >= 0) {\n            // Cannot have point co-ordinates larger than this as everything takes place modulo Q.\n            return null;\n        }\n        // Compressed keys require you to know an extra bit of data about the y-coord as there\n        // are two possibilities.\n        // So it's encoded in the recId.\n        ECPoint R = decompressKey(x, (recId & 1) == 1);\n        //   1.4. If nR != point at infinity, then do another iteration of Step 1 (callers\n        // responsibility).\n        if (!R.multiply(n).isInfinity())\n            return null;\n        //   1.5. Compute e from M using Steps 2 and 3 of ECDSA signature verification.\n        BigInteger e = new BigInteger(1, messageHash);\n        //   1.6. For k from 1 to 2 do the following.   (loop is outside this function via\n        // iterating recId)\n        //   1.6.1. Compute a candidate public key as:\n        //               Q = mi(r) * (sR - eG)\n        //\n        // Where mi(x) is the modular multiplicative inverse. We transform this into the following:\n        //               Q = (mi(r) * s ** R) + (mi(r) * -e ** G)\n        // Where -e is the modular additive inverse of e, that is z such that z + e = 0 (mod n).\n        // In the above equation\n        // ** is point multiplication and + is point addition (the EC group operator).\n        //\n        // We can find the additive inverse by subtracting e from zero then taking the mod. For\n        // example the additive\n        // inverse of 3 modulo 11 is 8 because 3 + 8 mod 11 = 0, and -3 mod 11 = 8.\n        BigInteger eInv = BigInteger.ZERO.subtract(e).mod(n);\n        BigInteger rInv = sig.r.modInverse(n);\n        BigInteger srInv = rInv.multiply(sig.s).mod(n);\n        BigInteger eInvrInv = rInv.multiply(eInv).mod(n);\n        ECPoint.Fp q = (ECPoint.Fp) ECAlgorithms.sumOfTwoMultiplies(CURVE.getG(), eInvrInv, R,\n                srInv);\n        return q.getEncoded(/* compressed */ false);\n    }\n\n    private static ECPoint decompressKey(BigInteger xBN, boolean yBit) {\n        X9IntegerConverter x9 = new X9IntegerConverter();\n        byte[] compEnc = x9.integerToBytes(xBN, 1 + x9.getByteLength(CURVE.getCurve()));\n        compEnc[0] = (byte) (yBit ? 0x03 : 0x02);\n        return CURVE.getCurve().decodePoint(compEnc);\n    }\n\n    private static void check(boolean test, String message) {\n        if (!test) throw new IllegalArgumentException(message);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/EthTransaction.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum;\n\nimport android.util.Log;\n\nimport com.quincysx.crypto.ECKeyPair;\nimport com.quincysx.crypto.Transaction;\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.ethereum.rlp.RLP;\nimport com.quincysx.crypto.ethereum.rlp.RLPElement;\nimport com.quincysx.crypto.ethereum.rlp.RLPItem;\nimport com.quincysx.crypto.ethereum.rlp.RLPList;\nimport com.quincysx.crypto.ethereum.utils.ByteUtil;\nimport com.quincysx.crypto.utils.KECCAK256;\n\nimport org.spongycastle.util.BigIntegers;\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.math.BigInteger;\nimport java.util.Arrays;\n\nimport static com.cedarsoftware.util.ArrayUtilities.isEmpty;\nimport static com.quincysx.crypto.ethereum.utils.ByteUtil.EMPTY_BYTE_ARRAY;\nimport static com.quincysx.crypto.ethereum.utils.ByteUtil.ZERO_BYTE_ARRAY;\n\n/**\n * A transaction (formally, T) is a single cryptographically\n * signed instruction sent by an actor external to Ethereum.\n * An external actor can be a person (via a mobile device or desktop computer)\n * or could be from a piece of automated software running on a server.\n * There are two types of transactions: those which result in message calls\n * and those which result in the creation of new contracts.\n */\npublic class EthTransaction implements Transaction {\n\n    //    private static final Logger logger = LoggerFactory.getLogger(EthTransaction.class);\n    private static final BigInteger DEFAULT_GAS_PRICE = new BigInteger(\"10000000000000\");\n    private static final BigInteger DEFAULT_BALANCE_GAS = new BigInteger(\"21000\");\n\n    public static final int HASH_LENGTH = 32;\n    public static final int ADDRESS_LENGTH = 20;\n\n    /* SHA3 hash of the RLP encoded transaction */\n    private byte[] hash;\n\n    /* a counter used to make sure each transaction can only be processed once */\n    private byte[] nonce;\n\n    /* the amount of ether to transfer (calculated as wei) */\n    private byte[] value;\n\n    /* the address of the destination account\n     * In creation transaction the receive address is - 0 */\n    private byte[] receiveAddress;\n\n    /* the amount of ether to pay as a transaction fee\n     * to the miner for each unit of gas */\n    private byte[] gasPrice;\n\n    /* the amount of \"gas\" to allow for the computation.\n     * Gas is the fuel of the computational engine;\n     * every computational step taken and every byte added\n     * to the state or transaction list consumes some gas. */\n    private byte[] gasLimit;\n\n    /* An unlimited size byte array specifying\n     * input [data] of the message call or\n     * Initialization code for a new contract */\n    private byte[] data;\n\n    /**\n     * Since EIP-155, we could encode chainId in V\n     */\n    private static final int CHAIN_ID_INC = 35;\n    private static final int LOWER_REAL_V = 27;\n    private Integer chainId = null;\n\n    /* the elliptic curve signature\n     * (including public key recovery bits) */\n    private ECDSASignature signature;\n\n    protected byte[] sendAddress;\n\n    /* Tx in encoded form */\n    protected byte[] rlpEncoded;\n    private byte[] rlpRaw;\n    /* Indicates if this transaction has been parsed\n     * from the RLP-encoded data */\n    protected boolean parsed = false;\n\n    public EthTransaction(byte[] rawData) {\n        this.rlpEncoded = rawData;\n        parsed = false;\n    }\n\n    public EthTransaction(byte[] nonce, byte[] gasPrice, byte[] gasLimit, byte[] receiveAddress,\n                          byte[] value, byte[] data,\n                          Integer chainId) {\n        this.nonce = nonce;\n        this.gasPrice = gasPrice;\n        this.gasLimit = gasLimit;\n        this.receiveAddress = receiveAddress;\n        if (ByteUtil.isSingleZero(value)) {\n            this.value = EMPTY_BYTE_ARRAY;\n        } else {\n            this.value = value;\n        }\n        this.data = data;\n        this.chainId = chainId;\n\n        if (receiveAddress == null) {\n            this.receiveAddress = EMPTY_BYTE_ARRAY;\n        }\n\n        parsed = true;\n    }\n\n    /**\n     * Warning: this transaction would not be protected by replay-attack protection mechanism\n     * Use\n     * {@link EthTransaction#EthTransaction(byte[], byte[], byte[], byte[], byte[], byte[], Integer)} constructor instead\n     * and specify the desired chainID\n     */\n    public EthTransaction(byte[] nonce, byte[] gasPrice, byte[] gasLimit, byte[] receiveAddress,\n                          byte[] value, byte[] data) {\n        this(nonce, gasPrice, gasLimit, receiveAddress, value, data, null);\n    }\n\n    public EthTransaction(byte[] nonce, byte[] gasPrice, byte[] gasLimit, byte[] receiveAddress,\n                          byte[] value, byte[] data,\n                          byte[] r, byte[] s, byte v, Integer chainId) {\n        this(nonce, gasPrice, gasLimit, receiveAddress, value, data, chainId);\n        this.signature = ECDSASignature.fromComponents(r, s, v);\n    }\n\n    /**\n     * Warning: this transaction would not be protected by replay-attack protection mechanism\n     * Use\n     * {@link EthTransaction#EthTransaction(byte[], byte[], byte[], byte[], byte[], byte[], byte[], byte[], byte, Integer)}\n     * constructor instead and specify the desired chainID\n     */\n    public EthTransaction(byte[] nonce, byte[] gasPrice, byte[] gasLimit, byte[] receiveAddress,\n                          byte[] value, byte[] data,\n                          byte[] r, byte[] s, byte v) {\n        this(nonce, gasPrice, gasLimit, receiveAddress, value, data, r, s, v, null);\n    }\n\n\n    private Integer extractChainIdFromV(BigInteger bv) {\n        if (bv.bitLength() > 31)\n            return Integer.MAX_VALUE; // chainId is limited to 31 bits, longer are not valid for now\n        long v = bv.longValue();\n        if (v == LOWER_REAL_V || v == (LOWER_REAL_V + 1)) return null;\n        return (int) ((v - CHAIN_ID_INC) / 2);\n    }\n\n    private byte getRealV(BigInteger bv) {\n        if (bv.bitLength() > 31)\n            return 0; // chainId is limited to 31 bits, longer are not valid for now\n        long v = bv.longValue();\n        if (v == LOWER_REAL_V || v == (LOWER_REAL_V + 1)) return (byte) v;\n        byte realV = LOWER_REAL_V;\n        int inc = 0;\n        if ((int) v % 2 == 0) inc = 1;\n        return (byte) (realV + inc);\n    }\n\n//    public long transactionCost(BlockchainNetConfig config, Block block){\n//\n//        rlpParse();\n//\n//        return config.getConfigForBlock(block.getNumber()).\n//                getTransactionCost(this);\n//    }\n\n    public synchronized void verify() {\n        rlpParse();\n        validate();\n    }\n\n    public synchronized void rlpParse() {\n        if (parsed) return;\n        try {\n            RLPList decodedTxList = RLP.decode2(rlpEncoded);\n            RLPList transaction = (RLPList) decodedTxList.get(0);\n\n            // Basic verification\n            if (transaction.size() > 9) throw new RuntimeException(\"Too many RLP elements\");\n            for (RLPElement rlpElement : transaction) {\n                if (!(rlpElement instanceof RLPItem))\n                    throw new RuntimeException(\"EthTransaction RLP elements shouldn't be lists\");\n            }\n\n            this.nonce = transaction.get(0).getRLPData();\n            this.gasPrice = transaction.get(1).getRLPData();\n            this.gasLimit = transaction.get(2).getRLPData();\n            this.receiveAddress = transaction.get(3).getRLPData();\n            this.value = transaction.get(4).getRLPData();\n            this.data = transaction.get(5).getRLPData();\n            // only parse signature in case tx is signed\n            if (transaction.get(6).getRLPData() != null) {\n                byte[] vData = transaction.get(6).getRLPData();\n                BigInteger v = ByteUtil.bytesToBigInteger(vData);\n                this.chainId = extractChainIdFromV(v);\n                byte[] r = transaction.get(7).getRLPData();\n                byte[] s = transaction.get(8).getRLPData();\n                this.signature = ECDSASignature.fromComponents(r, s, getRealV(v));\n            } else {\n                Log.e(\"=====\", \"RLP encoded tx is not signed!\");\n            }\n            this.parsed = true;\n            this.hash = getHash();\n        } catch (Exception e) {\n            throw new RuntimeException(\"Error on parsing RLP\", e);\n        }\n    }\n\n    private void validate() {\n        if (getNonce().length > HASH_LENGTH) throw new RuntimeException(\"Nonce is not valid\");\n        if (receiveAddress != null && receiveAddress.length != 0 && receiveAddress.length !=\n                ADDRESS_LENGTH)\n            throw new RuntimeException(\"Receive address is not valid\");\n        if (gasLimit.length > HASH_LENGTH)\n            throw new RuntimeException(\"Gas Limit is not valid\");\n        if (gasPrice != null && gasPrice.length > HASH_LENGTH)\n            throw new RuntimeException(\"Gas Price is not valid\");\n        if (value != null && value.length > HASH_LENGTH)\n            throw new RuntimeException(\"Value is not valid\");\n        if (getSignature() != null) {\n            if (BigIntegers.asUnsignedByteArray(signature.r).length > HASH_LENGTH)\n                throw new RuntimeException(\"Signature R is not valid\");\n            if (BigIntegers.asUnsignedByteArray(signature.s).length > HASH_LENGTH)\n                throw new RuntimeException(\"Signature S is not valid\");\n//            if (getSender() != null && getSender().length != ADDRESS_LENGTH)\n//                throw new RuntimeException(\"Sender is not valid\");\n        }\n    }\n\n    public boolean isParsed() {\n        return parsed;\n    }\n\n    public byte[] getHash() {\n        if (!isEmpty(hash)) return hash;\n\n        rlpParse();\n        byte[] plainMsg = this.getEncoded();\n//        return HashUtil.sha3(plainMsg);\n        return KECCAK256.keccak256(plainMsg);\n//        return SHA3Digest\n    }\n\n    public byte[] getRawHash() {\n        rlpParse();\n        byte[] plainMsg = this.getEncodedRaw();\n//        return HashUtil.sha3(plainMsg);\n        return KECCAK256.keccak256(plainMsg);\n    }\n\n\n    public byte[] getNonce() {\n        rlpParse();\n\n        return nonce == null ? ZERO_BYTE_ARRAY : nonce;\n    }\n\n    protected void setNonce(byte[] nonce) {\n        this.nonce = nonce;\n        parsed = true;\n    }\n\n    public boolean isValueTx() {\n        rlpParse();\n        return value != null;\n    }\n\n    public byte[] getValue() {\n        rlpParse();\n        return value == null ? ZERO_BYTE_ARRAY : value;\n    }\n\n    protected void setValue(byte[] value) {\n        this.value = value;\n        parsed = true;\n    }\n\n    public byte[] getReceiveAddress() {\n        rlpParse();\n        return receiveAddress;\n    }\n\n    protected void setReceiveAddress(byte[] receiveAddress) {\n        this.receiveAddress = receiveAddress;\n        parsed = true;\n    }\n\n    public byte[] getGasPrice() {\n        rlpParse();\n        return gasPrice == null ? ZERO_BYTE_ARRAY : gasPrice;\n    }\n\n    protected void setGasPrice(byte[] gasPrice) {\n        this.gasPrice = gasPrice;\n        parsed = true;\n    }\n\n    public byte[] getGasLimit() {\n        rlpParse();\n        return gasLimit == null ? ZERO_BYTE_ARRAY : gasLimit;\n    }\n\n    protected void setGasLimit(byte[] gasLimit) {\n        this.gasLimit = gasLimit;\n        parsed = true;\n    }\n\n    public long nonZeroDataBytes() {\n        if (data == null) return 0;\n        int counter = 0;\n        for (final byte aData : data) {\n            if (aData != 0) ++counter;\n        }\n        return counter;\n    }\n\n    public long zeroDataBytes() {\n        if (data == null) return 0;\n        int counter = 0;\n        for (final byte aData : data) {\n            if (aData == 0) ++counter;\n        }\n        return counter;\n    }\n\n\n    public byte[] getData() {\n        rlpParse();\n        return data;\n    }\n\n    protected void setData(byte[] data) {\n        this.data = data;\n        parsed = true;\n    }\n\n    public ECDSASignature getSignature() {\n        rlpParse();\n        return signature;\n    }\n\n//    public byte[] getContractAddress() {\n//        if (!isContractCreation()) return null;\n//        return calcNewAddr(this.getSender(), this.getNonce());\n//    }\n//\n//    public static byte[] sha3omit12(byte[] input) {\n//        byte[] hash = sha3(input);\n//        return copyOfRange(hash, 12, hash.length);\n//    }\n//\n//    public static byte[] calcNewAddr(byte[] addr, byte[] nonce) {\n//\n//        byte[] encSender = RLP.encodeElement(addr);\n//        byte[] encNonce = RLP.encodeBigInteger(new BigInteger(1, nonce));\n//\n//        return sha3omit12(RLP.encodeList(encSender, encNonce));\n//    }\n\n    public boolean isContractCreation() {\n        rlpParse();\n        return this.receiveAddress == null || Arrays.equals(this.receiveAddress, EMPTY_BYTE_ARRAY);\n    }\n\n    /*\n     * Crypto\n     */\n\n//        public ECKey getKey() {\n//        byte[] hash = getRawHash();\n//        return ECKey.recoverFromSignature(signature.v, signature, hash);\n//    }\n//\n//    public synchronized byte[] getSender() {\n//        try {\n//            if (sendAddress == null && getSignature() != null) {\n//                sendAddress = ECKey.signatureToAddress(getRawHash(), getSignature());\n//            }\n//            return sendAddress;\n//        } catch (SignatureException e) {\n//            Log.e(e.getMessage(), e);\n//        }\n//        return null;\n//    }\n\n    public Integer getChainId() {\n        rlpParse();\n        return chainId == null ? null : (int) chainId;\n    }\n\n    //    /**\n//     * @deprecated should prefer #sign(ECKey) over this method\n//     */\n//    public void sign(byte[] privKeyBytes) {\n//        sign(ECKeyPair.fromPrivate(privKeyBytes));\n//    }\n\n    @Override\n    public byte[] sign(ECKeyPair key) throws ValidationException {\n        this.signature = key.sign(this.getRawHash());\n        this.rlpEncoded = null;\n        return getSignBytes();\n    }\n\n    @Override\n    public byte[] getSignBytes() {\n        return getEncoded();\n    }\n\n    @Override\n    public String toString() {\n        return toString(Integer.MAX_VALUE);\n    }\n\n    public String toString(int maxDataSize) {\n        rlpParse();\n        String dataS;\n        if (data == null) {\n            dataS = \"\";\n        } else if (data.length < maxDataSize) {\n            dataS = ByteUtil.toHexString(data);\n        } else {\n            dataS = ByteUtil.toHexString(Arrays.copyOfRange(data, 0, maxDataSize)) +\n                    \"... (\" + data.length + \" bytes)\";\n        }\n        return \"TransactionData [\" + \"hash=\" + ByteUtil.toHexString(hash) +\n                \"  nonce=\" + ByteUtil.toHexString(nonce) +\n                \", gasPrice=\" + ByteUtil.toHexString(gasPrice) +\n                \", gas=\" + ByteUtil.toHexString(gasLimit) +\n                \", receiveAddress=\" + ByteUtil.toHexString(receiveAddress) +\n//                \", sendAddress=\" + ByteUtil.toHexString(getSender()) +\n                \", value=\" + ByteUtil.toHexString(value) +\n                \", data=\" + dataS +\n                \", signatureV=\" + (signature == null ? \"\" : signature.v) +\n                \", signatureR=\" + (signature == null ? \"\" : ByteUtil.toHexString(BigIntegers\n                .asUnsignedByteArray(signature.r))) +\n                \", signatureS=\" + (signature == null ? \"\" : ByteUtil.toHexString(BigIntegers\n                .asUnsignedByteArray(signature.s))) +\n                \"]\";\n    }\n\n    /**\n     * For signatures you have to keep also\n     * RLP of the transaction without any signature data\n     */\n    public byte[] getEncodedRaw() {\n\n        rlpParse();\n        if (rlpRaw != null) return rlpRaw;\n\n        // parse null as 0 for nonce\n        byte[] nonce = null;\n        if (this.nonce == null || this.nonce.length == 1 && this.nonce[0] == 0) {\n            nonce = RLP.encodeElement(null);\n        } else {\n            nonce = RLP.encodeElement(this.nonce);\n        }\n        byte[] gasPrice = RLP.encodeElement(this.gasPrice);\n        byte[] gasLimit = RLP.encodeElement(this.gasLimit);\n        byte[] receiveAddress = RLP.encodeElement(this.receiveAddress);\n        byte[] value = RLP.encodeElement(this.value);\n        byte[] data = RLP.encodeElement(this.data);\n\n        // Since EIP-155 use chainId for v\n        if (chainId == null) {\n            rlpRaw = RLP.encodeList(nonce, gasPrice, gasLimit, receiveAddress,\n                    value, data);\n        } else {\n            byte[] v, r, s;\n            v = RLP.encodeInt(chainId);\n            r = RLP.encodeElement(EMPTY_BYTE_ARRAY);\n            s = RLP.encodeElement(EMPTY_BYTE_ARRAY);\n            rlpRaw = RLP.encodeList(nonce, gasPrice, gasLimit, receiveAddress,\n                    value, data, v, r, s);\n        }\n        return rlpRaw;\n    }\n\n    public void setSignature(ECDSASignature signature) {\n        this.signature = signature;\n    }\n\n    public byte[] getEncoded() {\n\n        if (rlpEncoded != null) return rlpEncoded;\n\n        // parse null as 0 for nonce\n        byte[] nonce = null;\n        if (this.nonce == null || this.nonce.length == 1 && this.nonce[0] == 0) {\n            nonce = RLP.encodeElement(null);\n        } else {\n            nonce = RLP.encodeElement(this.nonce);\n        }\n        byte[] gasPrice = RLP.encodeElement(this.gasPrice);\n        byte[] gasLimit = RLP.encodeElement(this.gasLimit);\n        byte[] receiveAddress = RLP.encodeElement(this.receiveAddress);\n        byte[] value = RLP.encodeElement(this.value);\n        byte[] data = RLP.encodeElement(this.data);\n\n        byte[] v, r, s;\n\n        if (signature != null) {\n            int encodeV;\n            if (chainId == null) {\n                encodeV = signature.v;\n            } else {\n                encodeV = signature.v - LOWER_REAL_V;\n                encodeV += chainId * 2 + CHAIN_ID_INC;\n            }\n            v = RLP.encodeInt(encodeV);\n            r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.r));\n            s = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.s));\n        } else {\n            // Since EIP-155 use chainId for v\n            v = chainId == null ? RLP.encodeElement(EMPTY_BYTE_ARRAY) : RLP.encodeInt(chainId);\n            r = RLP.encodeElement(EMPTY_BYTE_ARRAY);\n            s = RLP.encodeElement(EMPTY_BYTE_ARRAY);\n        }\n\n        this.rlpEncoded = RLP.encodeList(nonce, gasPrice, gasLimit,\n                receiveAddress, value, data, v, r, s);\n\n        this.hash = this.getHash();\n\n        return rlpEncoded;\n    }\n\n    @Override\n    public int hashCode() {\n\n        byte[] hash = this.getHash();\n        int hashCode = 0;\n\n        for (int i = 0; i < hash.length; ++i) {\n            hashCode += hash[i] * i;\n        }\n\n        return hashCode;\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n\n        if (!(obj instanceof EthTransaction)) return false;\n        EthTransaction tx = (EthTransaction) obj;\n\n        return tx.hashCode() == this.hashCode();\n    }\n\n    /**\n     * @deprecated Use\n     * {@link EthTransaction#createDefault(String, BigInteger, BigInteger, Integer)} instead\n     */\n    public static EthTransaction createDefault(String to, BigInteger amount, BigInteger nonce) {\n        return create(to, amount, nonce, DEFAULT_GAS_PRICE, DEFAULT_BALANCE_GAS);\n    }\n\n    public static EthTransaction createDefault(String to, BigInteger amount, BigInteger nonce,\n                                               Integer chainId) {\n        return create(to, amount, nonce, DEFAULT_GAS_PRICE, DEFAULT_BALANCE_GAS, chainId);\n    }\n\n    /**\n     * @deprecated use\n     * {@link EthTransaction#create(String, BigInteger, BigInteger, BigInteger, BigInteger, Integer)} instead\n     */\n    public static EthTransaction create(String to, BigInteger amount, BigInteger nonce,\n                                        BigInteger gasPrice, BigInteger gasLimit) {\n        return new EthTransaction(BigIntegers.asUnsignedByteArray(nonce),\n                BigIntegers.asUnsignedByteArray(gasPrice),\n                BigIntegers.asUnsignedByteArray(gasLimit),\n                Hex.decode(to),\n                BigIntegers.asUnsignedByteArray(amount),\n                null);\n    }\n\n    public static EthTransaction create(String to, BigInteger amount, BigInteger nonce,\n                                        BigInteger gasPrice,\n                                        BigInteger gasLimit, Integer chainId) {\n        return new EthTransaction(BigIntegers.asUnsignedByteArray(nonce),\n                BigIntegers.asUnsignedByteArray(gasPrice),\n                BigIntegers.asUnsignedByteArray(gasLimit),\n                Hex.decode(to),\n                BigIntegers.asUnsignedByteArray(amount),\n                null,\n                chainId);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/config/Constants.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.config;\n\nimport java.math.BigInteger;\n\n/**\n * Describes different constants specific for a blockchain\n *\n * Created by Anton Nashatyrev on 25.02.2016.\n */\npublic class Constants {\n    private static final int MAXIMUM_EXTRA_DATA_SIZE = 32;\n    private static final int MIN_GAS_LIMIT = 125000;\n    private static final int GAS_LIMIT_BOUND_DIVISOR = 1024;\n    private static final BigInteger MINIMUM_DIFFICULTY = BigInteger.valueOf(131072);\n    private static final BigInteger DIFFICULTY_BOUND_DIVISOR = BigInteger.valueOf(2048);\n    private static final int EXP_DIFFICULTY_PERIOD = 100000;\n\n    private static final int UNCLE_GENERATION_LIMIT = 7;\n    private static final int UNCLE_LIST_LIMIT = 2;\n\n    private static final int BEST_NUMBER_DIFF_LIMIT = 100;\n\n    private static final BigInteger BLOCK_REWARD = new BigInteger(\"1500000000000000000\");\n\n    private static final BigInteger SECP256K1N = new BigInteger(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\", 16);\n\n    public int getDURATION_LIMIT() {\n        return 8;\n    }\n\n    public BigInteger getInitialNonce() {\n        return BigInteger.ZERO;\n    }\n\n    public int getMAXIMUM_EXTRA_DATA_SIZE() {\n        return MAXIMUM_EXTRA_DATA_SIZE;\n    }\n\n    public int getMIN_GAS_LIMIT() {\n        return MIN_GAS_LIMIT;\n    }\n\n    public int getGAS_LIMIT_BOUND_DIVISOR() {\n        return GAS_LIMIT_BOUND_DIVISOR;\n    }\n\n    public BigInteger getMINIMUM_DIFFICULTY() {\n        return MINIMUM_DIFFICULTY;\n    }\n\n    public BigInteger getDIFFICULTY_BOUND_DIVISOR() {\n        return DIFFICULTY_BOUND_DIVISOR;\n    }\n\n    public int getEXP_DIFFICULTY_PERIOD() {\n        return EXP_DIFFICULTY_PERIOD;\n    }\n\n    public int getUNCLE_GENERATION_LIMIT() {\n        return UNCLE_GENERATION_LIMIT;\n    }\n\n    public int getUNCLE_LIST_LIMIT() {\n        return UNCLE_LIST_LIMIT;\n    }\n\n    public int getBEST_NUMBER_DIFF_LIMIT() {\n        return BEST_NUMBER_DIFF_LIMIT;\n    }\n\n    public BigInteger getBLOCK_REWARD() {\n        return BLOCK_REWARD;\n    }\n\n    public int getMAX_CONTRACT_SZIE() { return Integer.MAX_VALUE; }\n\n    /**\n     * Introduced in the Homestead release\n     */\n    public boolean createEmptyContractOnOOG() {\n        return true;\n    }\n\n    /**\n     * New DELEGATECALL opcode introduced in the Homestead release. Before Homestead this opcode should generate\n     * exception\n     */\n    public boolean hasDelegateCallOpcode() {return false; }\n\n    /**\n     * Introduced in the Homestead release\n     */\n    public static BigInteger getSECP256K1N() {\n        return SECP256K1N;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/keystore/CipherException.java",
    "content": "package com.quincysx.crypto.ethereum.keystore;\n\npublic class CipherException extends Exception {\n    public CipherException(String message) {\n        super(message);\n    }\n\n    public CipherException(Throwable cause) {\n        super(cause);\n    }\n\n    public CipherException(String message, Throwable cause) {\n        super(message, cause);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/keystore/KeyStore.java",
    "content": "package com.quincysx.crypto.ethereum.keystore;\n\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.ethereum.EthECKeyPair;\nimport com.quincysx.crypto.utils.HexUtils;\nimport com.quincysx.crypto.utils.KECCAK256;\n\nimport org.spongycastle.crypto.digests.SHA256Digest;\nimport org.spongycastle.crypto.generators.PKCS5S2ParametersGenerator;\nimport org.spongycastle.crypto.generators.SCrypt;\nimport org.spongycastle.crypto.params.KeyParameter;\n\nimport java.nio.charset.Charset;\nimport java.security.InvalidAlgorithmParameterException;\nimport java.security.InvalidKeyException;\nimport java.security.NoSuchAlgorithmException;\nimport java.security.SecureRandom;\nimport java.util.Arrays;\nimport java.util.UUID;\n\nimport javax.crypto.BadPaddingException;\nimport javax.crypto.Cipher;\nimport javax.crypto.IllegalBlockSizeException;\nimport javax.crypto.NoSuchPaddingException;\nimport javax.crypto.spec.IvParameterSpec;\nimport javax.crypto.spec.SecretKeySpec;\n\npublic class KeyStore {\n\n    private static final int N_LIGHT = 1 << 12;\n    private static final int P_LIGHT = 6;\n\n    private static final int N_STANDARD = 1 << 18;\n    private static final int P_STANDARD = 1;\n\n    private static final int R = 8;\n    private static final int DKLEN = 32;\n\n    private static final int CURRENT_VERSION = 3;\n\n    private static final String CIPHER = \"aes-128-ctr\";\n    static final String AES_128_CTR = \"pbkdf2\";\n    static final String SCRYPT = \"scrypt\";\n\n    private static SecureRandom secureRandom = new SecureRandom();\n\n    public static KeyStoreFile createStandard(String password, EthECKeyPair ecKeyPair)\n            throws CipherException {\n        return create(password, ecKeyPair, N_STANDARD, P_STANDARD);\n    }\n\n    public static KeyStoreFile createLight(String password, EthECKeyPair ecKeyPair)\n            throws CipherException {\n        return create(password, ecKeyPair, N_LIGHT, P_LIGHT);\n    }\n\n    public static KeyStoreFile create(String password, EthECKeyPair ecKeyPair, int n, int p)\n            throws CipherException {\n\n        byte[] salt = generateRandomBytes(32);\n\n        byte[] derivedKey = generateDerivedScryptKey(\n                password.getBytes(Charset.forName(\"UTF-8\")), salt, n, R, p, DKLEN);\n\n        byte[] encryptKey = Arrays.copyOfRange(derivedKey, 0, 16);\n        byte[] iv = generateRandomBytes(16);\n\n//        byte[] privateKeyBytes =\n//                Numeric.toBytesPadded(ecKeyPair.getPrivateKey(), Keys.PRIVATE_KEY_SIZE);\n        byte[] privateKeyBytes = ecKeyPair.getRawPrivateKey();\n\n        byte[] cipherText = performCipherOperation(\n                Cipher.ENCRYPT_MODE, iv, encryptKey, privateKeyBytes);\n\n        byte[] mac = generateMac(derivedKey, cipherText);\n\n        return createWalletFile(ecKeyPair, cipherText, iv, salt, mac, n, p);\n    }\n\n    private static byte[] performCipherOperation(\n            int mode, byte[] iv, byte[] encryptKey, byte[] text) throws CipherException {\n\n        try {\n            IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);\n            Cipher cipher = Cipher.getInstance(\"AES/CTR/NoPadding\");\n\n            SecretKeySpec secretKeySpec = new SecretKeySpec(encryptKey, \"AES\");\n            cipher.init(mode, secretKeySpec, ivParameterSpec);\n            return cipher.doFinal(text);\n        } catch (NoSuchPaddingException | NoSuchAlgorithmException\n                | InvalidAlgorithmParameterException | InvalidKeyException\n                | BadPaddingException | IllegalBlockSizeException e) {\n            throw new CipherException(\"Error performing cipher operation\", e);\n        }\n    }\n\n    private static byte[] generateMac(byte[] derivedKey, byte[] cipherText) {\n        byte[] result = new byte[16 + cipherText.length];\n\n        System.arraycopy(derivedKey, 16, result, 0, 16);\n        System.arraycopy(cipherText, 0, result, 16, cipherText.length);\n\n        return KECCAK256.keccak256(result);\n//        return Hash.sha3(result);\n    }\n\n    private static byte[] generateDerivedScryptKey(\n            byte[] password, byte[] salt, int n, int r, int p, int dkLen) {\n        return SCrypt.generate(password, salt, n, r, p, dkLen);\n    }\n\n    static byte[] generateRandomBytes(int size) {\n        byte[] bytes = new byte[size];\n        secureRandom.nextBytes(bytes);\n        return bytes;\n    }\n\n    private static KeyStoreFile createWalletFile(\n            EthECKeyPair ecKeyPair, byte[] cipherText, byte[] iv, byte[] salt, byte[] mac,\n            int n, int p) {\n\n        KeyStoreFile walletFile = new KeyStoreFile();\n        walletFile.setAddress(ecKeyPair.getAddress());\n\n        KeyStoreFile.Crypto crypto = new KeyStoreFile.Crypto();\n        crypto.setCipher(CIPHER);\n//        crypto.setCiphertext(Numeric.toHexStringNoPrefix(cipherText));\n        crypto.setCiphertext(HexUtils.toHex(cipherText));\n        walletFile.setCrypto(crypto);\n\n        KeyStoreFile.CipherParams cipherParams = new KeyStoreFile.CipherParams();\n//        cipherParams.setIv(Numeric.toHexStringNoPrefix(iv));\n        cipherParams.setIv(HexUtils.toHex(iv));\n        crypto.setCipherparams(cipherParams);\n\n        crypto.setKdf(SCRYPT);\n        KeyStoreFile.ScryptKdfParams kdfParams = new KeyStoreFile.ScryptKdfParams();\n        kdfParams.setDklen(DKLEN);\n        kdfParams.setN(n);\n        kdfParams.setP(p);\n        kdfParams.setR(R);\n//        kdfParams.setSalt(Numeric.toHexStringNoPrefix(salt));\n        kdfParams.setSalt(HexUtils.toHex(salt));\n        crypto.setKdfparams(kdfParams);\n\n//        crypto.setMac(Numeric.toHexStringNoPrefix(mac));\n        crypto.setMac(HexUtils.toHex(mac));\n        walletFile.setCrypto(crypto);\n        walletFile.setId(UUID.randomUUID().toString());\n        walletFile.setVersion(CURRENT_VERSION);\n\n        return walletFile;\n    }\n\n    static void validate(KeyStoreFile walletFile) throws CipherException {\n        KeyStoreFile.Crypto crypto = walletFile.getCrypto();\n\n        if (walletFile.getVersion() != CURRENT_VERSION) {\n            throw new CipherException(\"Wallet version is not supported\");\n        }\n\n        if (!crypto.getCipher().equals(CIPHER)) {\n            throw new CipherException(\"Wallet cipher is not supported\");\n        }\n\n        if (!crypto.getKdf().equals(AES_128_CTR) && !crypto.getKdf().equals(SCRYPT)) {\n            throw new CipherException(\"KDF type is not supported\");\n        }\n    }\n\n    public static EthECKeyPair decrypt(String password, KeyStoreFile walletFile)\n            throws CipherException, ValidationException {\n\n        validate(walletFile);\n\n        KeyStoreFile.Crypto crypto = walletFile.getCrypto();\n\n        byte[] mac = HexUtils.fromHex(crypto.getMac());\n        byte[] iv = HexUtils.fromHex(crypto.getCipherparams().getIv());\n        byte[] cipherText = HexUtils.fromHex(crypto.getCiphertext());\n\n        byte[] derivedKey;\n\n        KeyStoreFile.KdfParams kdfParams = crypto.getKdfparams();\n        if (kdfParams instanceof KeyStoreFile.ScryptKdfParams) {\n            KeyStoreFile.ScryptKdfParams scryptKdfParams =\n                    (KeyStoreFile.ScryptKdfParams) crypto.getKdfparams();\n            int dklen = scryptKdfParams.getDklen();\n            int n = scryptKdfParams.getN();\n            int p = scryptKdfParams.getP();\n            int r = scryptKdfParams.getR();\n            byte[] salt = HexUtils.fromHex(scryptKdfParams.getSalt());\n//            derivedKey = generateDerivedScryptKey(password.getBytes(Charset.forName(\"UTF-8\")),\n//                    salt, n, r, p, dklen);\n            derivedKey = com.lambdaworks.crypto.SCrypt.scryptN(password.getBytes(Charset.forName(\"UTF-8\")), salt, n, r, p, dklen);\n        } else if (kdfParams instanceof KeyStoreFile.Aes128CtrKdfParams) {\n            KeyStoreFile.Aes128CtrKdfParams aes128CtrKdfParams =\n                    (KeyStoreFile.Aes128CtrKdfParams) crypto.getKdfparams();\n            int c = aes128CtrKdfParams.getC();\n            String prf = aes128CtrKdfParams.getPrf();\n            byte[] salt = HexUtils.fromHex(aes128CtrKdfParams.getSalt());\n\n            derivedKey = generateAes128CtrDerivedKey(password.getBytes(Charset.forName(\"UTF-8\")),\n                    salt, c, prf);\n        } else {\n            throw new CipherException(\"Unable to deserialize params: \" + crypto.getKdf());\n        }\n\n        byte[] derivedMac = generateMac(derivedKey, cipherText);\n\n        if (!Arrays.equals(derivedMac, mac)) {\n            throw new CipherException(\"Invalid password provided\");\n        }\n\n        byte[] encryptKey = Arrays.copyOfRange(derivedKey, 0, 16);\n        byte[] privateKey = performCipherOperation(Cipher.DECRYPT_MODE, iv, encryptKey, cipherText);\n        return new EthECKeyPair(privateKey);\n    }\n\n    private static byte[] generateAes128CtrDerivedKey(\n            byte[] password, byte[] salt, int c, String prf) throws CipherException {\n\n        if (!prf.equals(\"hmac-sha256\")) {\n            throw new CipherException(\"Unsupported prf:\" + prf);\n        }\n\n        // Java 8 supports this, but you have to convert the password to a character array, see\n        // http://stackoverflow.com/a/27928435/3211687\n        PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator(new SHA256Digest());\n        gen.init(password, salt, c);\n        return ((KeyParameter) gen.generateDerivedParameters(256)).getKey();\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/keystore/KeyStoreFile.java",
    "content": "package com.quincysx.crypto.ethereum.keystore;\n\nimport com.fasterxml.jackson.annotation.JsonSetter;\nimport com.fasterxml.jackson.annotation.JsonSubTypes;\nimport com.fasterxml.jackson.annotation.JsonTypeInfo;\nimport com.fasterxml.jackson.core.JsonParser;\nimport com.fasterxml.jackson.core.JsonProcessingException;\nimport com.fasterxml.jackson.databind.DeserializationContext;\nimport com.fasterxml.jackson.databind.JsonDeserializer;\nimport com.fasterxml.jackson.databind.JsonNode;\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport com.fasterxml.jackson.databind.node.ObjectNode;\n\nimport java.io.IOException;\n\npublic class KeyStoreFile {\n\n    private String address;\n    private Crypto crypto;\n    private String id;\n    private int version;\n\n    public KeyStoreFile() {\n    }\n\n    public String getAddress() {\n        return address;\n    }\n\n    public void setAddress(String address) {\n        this.address = address;\n    }\n\n    public Crypto getCrypto() {\n        return crypto;\n    }\n\n    @JsonSetter(\"crypto\")\n    public void setCrypto(Crypto crypto) {\n        this.crypto = crypto;\n    }\n\n    @JsonSetter(\"Crypto\")  // older wallet files may have this attribute name\n    public void setCryptoV1(Crypto crypto) {\n        setCrypto(crypto);\n    }\n\n    public String getId() {\n        return id;\n    }\n\n    public void setId(String id) {\n        this.id = id;\n    }\n\n    public int getVersion() {\n        return version;\n    }\n\n    public void setVersion(int version) {\n        this.version = version;\n    }\n\n    public static KeyStoreFile parse(String keystore) throws IOException {\n        return new ObjectMapper().readValue\n                (keystore, KeyStoreFile.class);\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) {\n            return true;\n        }\n        if (!(o instanceof KeyStoreFile)) {\n            return false;\n        }\n\n        KeyStoreFile that = (KeyStoreFile) o;\n\n        if (getAddress() != null\n                ? !getAddress().equals(that.getAddress())\n                : that.getAddress() != null) {\n            return false;\n        }\n        if (getCrypto() != null\n                ? !getCrypto().equals(that.getCrypto())\n                : that.getCrypto() != null) {\n            return false;\n        }\n        if (getId() != null\n                ? !getId().equals(that.getId())\n                : that.getId() != null) {\n            return false;\n        }\n        return version == that.version;\n    }\n\n    @Override\n    public int hashCode() {\n        int result = getAddress() != null ? getAddress().hashCode() : 0;\n        result = 31 * result + (getCrypto() != null ? getCrypto().hashCode() : 0);\n        result = 31 * result + (getId() != null ? getId().hashCode() : 0);\n        result = 31 * result + version;\n        return result;\n    }\n\n    public static class Crypto {\n        private String cipher;\n        private String ciphertext;\n        private CipherParams cipherparams;\n\n        private String kdf;\n        private KdfParams kdfparams;\n\n        private String mac;\n\n        public Crypto() {\n        }\n\n        public String getCipher() {\n            return cipher;\n        }\n\n        public void setCipher(String cipher) {\n            this.cipher = cipher;\n        }\n\n        public String getCiphertext() {\n            return ciphertext;\n        }\n\n        public void setCiphertext(String ciphertext) {\n            this.ciphertext = ciphertext;\n        }\n\n        public CipherParams getCipherparams() {\n            return cipherparams;\n        }\n\n        public void setCipherparams(CipherParams cipherparams) {\n            this.cipherparams = cipherparams;\n        }\n\n        public String getKdf() {\n            return kdf;\n        }\n\n        public void setKdf(String kdf) {\n            this.kdf = kdf;\n        }\n\n        public KdfParams getKdfparams() {\n            return kdfparams;\n        }\n\n        @JsonTypeInfo(\n                use = JsonTypeInfo.Id.NAME,\n                include = JsonTypeInfo.As.EXTERNAL_PROPERTY,\n                property = \"kdf\")\n        @JsonSubTypes({\n                @JsonSubTypes.Type(value = Aes128CtrKdfParams.class, name = KeyStore.AES_128_CTR),\n                @JsonSubTypes.Type(value = ScryptKdfParams.class, name = KeyStore.SCRYPT)\n        })\n        // To support my Ether Wallet keys uncomment this annotation & comment out the above\n        //  @JsonDeserialize(using = KdfParamsDeserialiser.class)\n        // Also add the following to the ObjectMapperFactory\n        // objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);\n        public void setKdfparams(KdfParams kdfparams) {\n            this.kdfparams = kdfparams;\n        }\n\n        public String getMac() {\n            return mac;\n        }\n\n        public void setMac(String mac) {\n            this.mac = mac;\n        }\n\n        @Override\n        public boolean equals(Object o) {\n            if (this == o) {\n                return true;\n            }\n            if (!(o instanceof Crypto)) {\n                return false;\n            }\n\n            Crypto that = (Crypto) o;\n\n            if (getCipher() != null\n                    ? !getCipher().equals(that.getCipher())\n                    : that.getCipher() != null) {\n                return false;\n            }\n            if (getCiphertext() != null\n                    ? !getCiphertext().equals(that.getCiphertext())\n                    : that.getCiphertext() != null) {\n                return false;\n            }\n            if (getCipherparams() != null\n                    ? !getCipherparams().equals(that.getCipherparams())\n                    : that.getCipherparams() != null) {\n                return false;\n            }\n            if (getKdf() != null\n                    ? !getKdf().equals(that.getKdf())\n                    : that.getKdf() != null) {\n                return false;\n            }\n            if (getKdfparams() != null\n                    ? !getKdfparams().equals(that.getKdfparams())\n                    : that.getKdfparams() != null) {\n                return false;\n            }\n            return getMac() != null\n                    ? getMac().equals(that.getMac()) : that.getMac() == null;\n        }\n\n        @Override\n        public int hashCode() {\n            int result = getCipher() != null ? getCipher().hashCode() : 0;\n            result = 31 * result + (getCiphertext() != null ? getCiphertext().hashCode() : 0);\n            result = 31 * result + (getCipherparams() != null ? getCipherparams().hashCode() : 0);\n            result = 31 * result + (getKdf() != null ? getKdf().hashCode() : 0);\n            result = 31 * result + (getKdfparams() != null ? getKdfparams().hashCode() : 0);\n            result = 31 * result + (getMac() != null ? getMac().hashCode() : 0);\n            return result;\n        }\n    }\n\n    public static class CipherParams {\n        private String iv;\n\n        public CipherParams() {\n        }\n\n        public String getIv() {\n            return iv;\n        }\n\n        public void setIv(String iv) {\n            this.iv = iv;\n        }\n\n        @Override\n        public boolean equals(Object o) {\n            if (this == o) {\n                return true;\n            }\n            if (!(o instanceof CipherParams)) {\n                return false;\n            }\n\n            CipherParams that = (CipherParams) o;\n\n            return getIv() != null\n                    ? getIv().equals(that.getIv()) : that.getIv() == null;\n        }\n\n        @Override\n        public int hashCode() {\n            int result = getIv() != null ? getIv().hashCode() : 0;\n            return result;\n        }\n\n    }\n\n    interface KdfParams {\n        int getDklen();\n\n        String getSalt();\n    }\n\n    public static class Aes128CtrKdfParams implements KdfParams {\n        private int dklen;\n        private int c;\n        private String prf;\n        private String salt;\n\n        public Aes128CtrKdfParams() {\n        }\n\n        public int getDklen() {\n            return dklen;\n        }\n\n        public void setDklen(int dklen) {\n            this.dklen = dklen;\n        }\n\n        public int getC() {\n            return c;\n        }\n\n        public void setC(int c) {\n            this.c = c;\n        }\n\n        public String getPrf() {\n            return prf;\n        }\n\n        public void setPrf(String prf) {\n            this.prf = prf;\n        }\n\n        public String getSalt() {\n            return salt;\n        }\n\n        public void setSalt(String salt) {\n            this.salt = salt;\n        }\n\n        @Override\n        public boolean equals(Object o) {\n            if (this == o) {\n                return true;\n            }\n            if (!(o instanceof Aes128CtrKdfParams)) {\n                return false;\n            }\n\n            Aes128CtrKdfParams that = (Aes128CtrKdfParams) o;\n\n            if (dklen != that.dklen) {\n                return false;\n            }\n            if (c != that.c) {\n                return false;\n            }\n            if (getPrf() != null\n                    ? !getPrf().equals(that.getPrf())\n                    : that.getPrf() != null) {\n                return false;\n            }\n            return getSalt() != null\n                    ? getSalt().equals(that.getSalt()) : that.getSalt() == null;\n        }\n\n        @Override\n        public int hashCode() {\n            int result = dklen;\n            result = 31 * result + c;\n            result = 31 * result + (getPrf() != null ? getPrf().hashCode() : 0);\n            result = 31 * result + (getSalt() != null ? getSalt().hashCode() : 0);\n            return result;\n        }\n\n    }\n\n    public static class ScryptKdfParams implements KdfParams {\n        private int dklen;\n        private int n;\n        private int p;\n        private int r;\n        private String salt;\n\n        public ScryptKdfParams() {\n        }\n\n        public int getDklen() {\n            return dklen;\n        }\n\n        public void setDklen(int dklen) {\n            this.dklen = dklen;\n        }\n\n        public int getN() {\n            return n;\n        }\n\n        public void setN(int n) {\n            this.n = n;\n        }\n\n        public int getP() {\n            return p;\n        }\n\n        public void setP(int p) {\n            this.p = p;\n        }\n\n        public int getR() {\n            return r;\n        }\n\n        public void setR(int r) {\n            this.r = r;\n        }\n\n        public String getSalt() {\n            return salt;\n        }\n\n        public void setSalt(String salt) {\n            this.salt = salt;\n        }\n\n        @Override\n        public boolean equals(Object o) {\n            if (this == o) {\n                return true;\n            }\n            if (!(o instanceof ScryptKdfParams)) {\n                return false;\n            }\n\n            ScryptKdfParams that = (ScryptKdfParams) o;\n\n            if (dklen != that.dklen) {\n                return false;\n            }\n            if (n != that.n) {\n                return false;\n            }\n            if (p != that.p) {\n                return false;\n            }\n            if (r != that.r) {\n                return false;\n            }\n            return getSalt() != null\n                    ? getSalt().equals(that.getSalt()) : that.getSalt() == null;\n        }\n\n        @Override\n        public int hashCode() {\n            int result = dklen;\n            result = 31 * result + n;\n            result = 31 * result + p;\n            result = 31 * result + r;\n            result = 31 * result + (getSalt() != null ? getSalt().hashCode() : 0);\n            return result;\n        }\n\n    }\n\n    // If we need to work with MyEtherWallet we'll need to use this deserializer, see the\n    // following issue https://github.com/kvhnuke/etherwallet/issues/269\n    static class KdfParamsDeserialiser extends JsonDeserializer<KdfParams> {\n\n        @Override\n        public KdfParams deserialize(\n                JsonParser jsonParser, DeserializationContext deserializationContext)\n                throws IOException {\n\n            ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec();\n            ObjectNode root = objectMapper.readTree(jsonParser);\n            KdfParams kdfParams;\n\n            // it would be preferable to detect the class to use based on the kdf parameter in the\n            // container object instance\n            JsonNode n = root.get(\"n\");\n            if (n == null) {\n                kdfParams = objectMapper.convertValue(root, Aes128CtrKdfParams.class);\n            } else {\n                kdfParams = objectMapper.convertValue(root, ScryptKdfParams.class);\n            }\n\n            return kdfParams;\n        }\n    }\n\n    @Override\n    public String toString() {\n        ObjectMapper mapper = new ObjectMapper();\n        String mapJakcson = \"\";\n        try {\n            mapJakcson = mapper.writeValueAsString(this);\n        } catch (JsonProcessingException e) {\n            e.printStackTrace();\n        }\n        return mapJakcson;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/rlp/CompactEncoder.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.rlp;\n\nimport com.quincysx.crypto.ethereum.utils.ByteUtil;\n\nimport java.io.ByteArrayOutputStream;\n\nimport java.nio.ByteBuffer;\n\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport static java.util.Arrays.*;\nimport static org.spongycastle.util.Arrays.concatenate;\nimport static org.spongycastle.util.encoders.Hex.encode;\n\n/**\n * Compact encoding of hex sequence with optional terminator\n * <p>\n * The traditional compact way of encoding a hex string is to convert it into binary\n * - that is, a string like 0f1248 would become three bytes 15, 18, 72. However,\n * this approach has one slight problem: what if the length of the hex string is odd?\n * In that case, there is no way to distinguish between, say, 0f1248 and f1248.\n * <p>\n * Additionally, our application in the Merkle Patricia tree requires the additional feature\n * that a hex string can also have a special \"terminator symbol\" at the end (denoted by the 'T').\n * A terminator symbol can occur only once, and only at the end.\n * <p>\n * An alternative way of thinking about this to not think of there being a terminator symbol,\n * but instead treat bit specifying the existence of the terminator symbol as a bit specifying\n * that the given node encodes a final node, where the value is an actual value, rather than\n * the hash of yet another node.\n * <p>\n * To solve both of these issues, we force the first nibble of the final byte-stream to encode\n * two flags, specifying oddness of length (ignoring the 'T' symbol) and terminator status;\n * these are placed, respectively, into the two lowest significant bits of the first nibble.\n * In the case of an even-length hex string, we must introduce a second nibble (of value zero)\n * to ensure the hex-string is even in length and thus is representable by a whole number of bytes.\n * <p>\n * Examples:\n * &gt; [ 1, 2, 3, 4, 5 ]\n * '\\x11\\x23\\x45'\n * &gt; [ 0, 1, 2, 3, 4, 5 ]\n * '\\x00\\x01\\x23\\x45'\n * &gt; [ 0, 15, 1, 12, 11, 8, T ]\n * '\\x20\\x0f\\x1c\\xb8'\n * &gt; [ 15, 1, 12, 11, 8, T ]\n * '\\x3f\\x1c\\xb8'\n */\npublic class CompactEncoder {\n\n    private final static byte TERMINATOR = 16;\n    private final static Map<Character, Byte> hexMap = new HashMap<>();\n\n    static {\n        hexMap.put('0', (byte) 0x0);\n        hexMap.put('1', (byte) 0x1);\n        hexMap.put('2', (byte) 0x2);\n        hexMap.put('3', (byte) 0x3);\n        hexMap.put('4', (byte) 0x4);\n        hexMap.put('5', (byte) 0x5);\n        hexMap.put('6', (byte) 0x6);\n        hexMap.put('7', (byte) 0x7);\n        hexMap.put('8', (byte) 0x8);\n        hexMap.put('9', (byte) 0x9);\n        hexMap.put('a', (byte) 0xa);\n        hexMap.put('b', (byte) 0xb);\n        hexMap.put('c', (byte) 0xc);\n        hexMap.put('d', (byte) 0xd);\n        hexMap.put('e', (byte) 0xe);\n        hexMap.put('f', (byte) 0xf);\n    }\n\n    /**\n     * Pack nibbles to binary\n     *\n     * @param nibbles sequence. may have a terminator\n     * @return hex-encoded byte array\n     */\n    public static byte[] packNibbles(byte[] nibbles) {\n        int terminator = 0;\n\n        if (nibbles[nibbles.length - 1] == TERMINATOR) {\n            terminator = 1;\n            nibbles = copyOf(nibbles, nibbles.length - 1);\n        }\n        int oddlen = nibbles.length % 2;\n        int flag = 2 * terminator + oddlen;\n        if (oddlen != 0) {\n            byte[] flags = new byte[]{(byte) flag};\n            nibbles = concatenate(flags, nibbles);\n        } else {\n            byte[] flags = new byte[]{(byte) flag, 0};\n            nibbles = concatenate(flags, nibbles);\n        }\n        ByteArrayOutputStream buffer = new ByteArrayOutputStream();\n        for (int i = 0; i < nibbles.length; i += 2) {\n            buffer.write(16 * nibbles[i] + nibbles[i + 1]);\n        }\n        return buffer.toByteArray();\n    }\n\n    public static boolean hasTerminator(byte[] packedKey) {\n        return ((packedKey[0] >> 4) & 2) != 0;\n    }\n\n    /**\n     * Unpack a binary string to its nibbles equivalent\n     *\n     * @param str of binary data\n     * @return array of nibbles in byte-format\n     */\n    public static byte[] unpackToNibbles(byte[] str) {\n        byte[] base = binToNibbles(str);\n        base = copyOf(base, base.length - 1);\n        if (base[0] >= 2) {\n            base = ByteUtil.appendByte(base, TERMINATOR);\n        }\n        if (base[0] % 2 == 1) {\n            base = copyOfRange(base, 1, base.length);\n        } else {\n            base = copyOfRange(base, 2, base.length);\n        }\n        return base;\n    }\n\n    /**\n     * Transforms a binary array to hexadecimal format + terminator\n     *\n     * @param str byte[]\n     * @return array with each individual nibble adding a terminator at the end\n     */\n    public static byte[] binToNibbles(byte[] str) {\n\n        byte[] hexEncoded = encode(str);\n        byte[] hexEncodedTerminated = Arrays.copyOf(hexEncoded, hexEncoded.length + 1);\n\n        for (int i = 0; i < hexEncoded.length; ++i) {\n            byte b = hexEncodedTerminated[i];\n            hexEncodedTerminated[i] = hexMap.get((char) b);\n        }\n\n        hexEncodedTerminated[hexEncodedTerminated.length - 1] = TERMINATOR;\n        return hexEncodedTerminated;\n    }\n\n\n    public static byte[] binToNibblesNoTerminator(byte[] str) {\n\n        byte[] hexEncoded = encode(str);\n\n        for (int i = 0; i < hexEncoded.length; ++i) {\n            byte b = hexEncoded[i];\n            hexEncoded[i] = hexMap.get((char) b);\n        }\n\n        return hexEncoded;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/rlp/DecodeResult.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.rlp;\n\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.io.Serializable;\n\n@SuppressWarnings(\"serial\")\npublic class DecodeResult implements Serializable {\n\n    private int pos;\n    private Object decoded;\n\n    public DecodeResult(int pos, Object decoded) {\n        this.pos = pos;\n        this.decoded = decoded;\n    }\n\n    public int getPos() {\n        return pos;\n    }\n\n    public Object getDecoded() {\n        return decoded;\n    }\n\n    public String toString() {\n        return asString(this.decoded);\n    }\n\n    private String asString(Object decoded) {\n        if (decoded instanceof String) {\n            return (String) decoded;\n        } else if (decoded instanceof byte[]) {\n            return Hex.toHexString((byte[]) decoded);\n        } else if (decoded instanceof Object[]) {\n            String result = \"\";\n            for (Object item : (Object[]) decoded) {\n                result += asString(item);\n            }\n            return result;\n        }\n        throw new RuntimeException(\"Not a valid type. Should not occur\");\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/rlp/RLP.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.rlp;\n\n\nimport com.quincysx.crypto.ethereum.ByteArrayWrapper;\nimport com.quincysx.crypto.ethereum.utils.ByteUtil;\n\nimport org.spongycastle.util.Arrays;\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.math.BigInteger;\nimport java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Queue;\nimport java.util.Set;\n\nimport static com.quincysx.crypto.ethereum.utils.ByteUtil.*;\nimport static org.spongycastle.util.Arrays.*;\nimport static org.spongycastle.util.BigIntegers.*;\n\n/**\n * Recursive Length Prefix (RLP) encoding.\n * <p>\n * The purpose of RLP is to encode arbitrarily nested arrays of binary data, and\n * RLP is the main encoding method used to serialize objects in Ethereum. The\n * only purpose of RLP is to encode structure; encoding specific atomic data\n * types (eg. strings, integers, floats) is left up to higher-order protocols; in\n * Ethereum the standard is that integers are represented in big endian binary\n * form. If one wishes to use RLP to encode a dictionary, the two suggested\n * canonical forms are to either use [[k1,v1],[k2,v2]...] with keys in\n * lexicographic order or to use the higher-level Patricia Tree encoding as\n * Ethereum does.\n * <p>\n * The RLP encoding function takes in an item. An item is defined as follows:\n * <p>\n * - A string (ie. byte array) is an item - A list of items is an item\n * <p>\n * For example, an empty string is an item, as is the string containing the word\n * \"cat\", a list containing any number of strings, as well as more complex data\n * structures like [\"cat\",[\"puppy\",\"cow\"],\"horse\",[[]],\"pig\",[\"\"],\"sheep\"]. Note\n * that in the context of the rest of this article, \"string\" will be used as a\n * synonym for \"a certain number of bytes of binary data\"; no special encodings\n * are used and no knowledge about the content of the strings is implied.\n * <p>\n * See: https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP\n *\n * @author Roman Mandeleil\n * @since 01.04.2014\n */\npublic class RLP {\n\n//    private static final Logger logger = LoggerFactory.getLogger(\"rlp\");\n\n\n    public static final byte[] EMPTY_ELEMENT_RLP = encodeElement(new byte[0]);\n\n    /**\n     * Allow for content up to size of 2^64 bytes *\n     */\n    private static final double MAX_ITEM_LENGTH = Math.pow(256, 8);\n\n    /**\n     * Reason for threshold according to Vitalik Buterin:\n     * - 56 bytes maximizes the benefit of both options\n     * - if we went with 60 then we would have only had 4 slots for long strings\n     * so RLP would not have been able to store objects above 4gb\n     * - if we went with 48 then RLP would be fine for 2^128 space, but that's way too much\n     * - so 56 and 2^64 space seems like the right place to put the cutoff\n     * - also, that's where Bitcoin's varint does the cutof\n     */\n    private static final int SIZE_THRESHOLD = 56;\n\n    /** RLP encoding rules are defined as follows: */\n\n    /*\n     * For a single byte whose value is in the [0x00, 0x7f] range, that byte is\n     * its own RLP encoding.\n     */\n\n    /**\n     * [0x80]\n     * If a string is 0-55 bytes long, the RLP encoding consists of a single\n     * byte with value 0x80 plus the length of the string followed by the\n     * string. The range of the first byte is thus [0x80, 0xb7].\n     */\n    private static final int OFFSET_SHORT_ITEM = 0x80;\n\n    /**\n     * [0xb7]\n     * If a string is more than 55 bytes long, the RLP encoding consists of a\n     * single byte with value 0xb7 plus the length of the length of the string\n     * in binary form, followed by the length of the string, followed by the\n     * string. For example, a length-1024 string would be encoded as\n     * \\xb9\\x04\\x00 followed by the string. The range of the first byte is thus\n     * [0xb8, 0xbf].\n     */\n    private static final int OFFSET_LONG_ITEM = 0xb7;\n\n    /**\n     * [0xc0]\n     * If the total payload of a list (i.e. the combined length of all its\n     * items) is 0-55 bytes long, the RLP encoding consists of a single byte\n     * with value 0xc0 plus the length of the list followed by the concatenation\n     * of the RLP encodings of the items. The range of the first byte is thus\n     * [0xc0, 0xf7].\n     */\n    private static final int OFFSET_SHORT_LIST = 0xc0;\n\n    /**\n     * [0xf7]\n     * If the total payload of a list is more than 55 bytes long, the RLP\n     * encoding consists of a single byte with value 0xf7 plus the length of the\n     * length of the list in binary form, followed by the length of the list,\n     * followed by the concatenation of the RLP encodings of the items. The\n     * range of the first byte is thus [0xf8, 0xff].\n     */\n    private static final int OFFSET_LONG_LIST = 0xf7;\n\n\n    /* ******************************************************\n     *                      DECODING                        *\n     * ******************************************************/\n\n    private static byte decodeOneByteItem(byte[] data, int index) {\n        // null item\n        if ((data[index] & 0xFF) == OFFSET_SHORT_ITEM) {\n            return (byte) (data[index] - OFFSET_SHORT_ITEM);\n        }\n        // single byte item\n        if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) {\n            return data[index];\n        }\n        // single byte item\n        if ((data[index] & 0xFF) == OFFSET_SHORT_ITEM + 1) {\n            return data[index + 1];\n        }\n        return 0;\n    }\n\n    public static int decodeInt(byte[] data, int index) {\n\n        int value = 0;\n        // NOTE: From RLP doc:\n        // Ethereum integers must be represented in big endian binary form\n        // with no leading zeroes (thus making the integer value zero be\n        // equivalent to the empty byte array)\n\n        if (data[index] == 0x00) {\n            throw new RuntimeException(\"not a number\");\n        } else if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) {\n\n            return data[index];\n\n        } else if ((data[index] & 0xFF) <= OFFSET_SHORT_ITEM + Integer.BYTES) {\n\n            byte length = (byte) (data[index] - OFFSET_SHORT_ITEM);\n            byte pow = (byte) (length - 1);\n            for (int i = 1; i <= length; ++i) {\n                // << (8 * pow) == bit shift to 0 (*1), 8 (*256) , 16 (*65..)..\n                value += (data[index + i] & 0xFF) << (8 * pow);\n                pow--;\n            }\n        } else {\n\n            // If there are more than 4 bytes, it is not going\n            // to decode properly into an int.\n            throw new RuntimeException(\"wrong decode attempt\");\n        }\n        return value;\n    }\n\n    static short decodeShort(byte[] data, int index) {\n\n        short value = 0;\n\n        if (data[index] == 0x00) {\n            throw new RuntimeException(\"not a number\");\n        } else if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) {\n\n            return data[index];\n\n        } else if ((data[index] & 0xFF) <= OFFSET_SHORT_ITEM + Short.BYTES) {\n\n            byte length = (byte) (data[index] - OFFSET_SHORT_ITEM);\n            byte pow = (byte) (length - 1);\n            for (int i = 1; i <= length; ++i) {\n                // << (8 * pow) == bit shift to 0 (*1), 8 (*256) , 16 (*65..)\n                value += (data[index + i] & 0xFF) << (8 * pow);\n                pow--;\n            }\n        } else {\n\n            // If there are more than 2 bytes, it is not going\n            // to decode properly into a short.\n            throw new RuntimeException(\"wrong decode attempt\");\n        }\n        return value;\n    }\n\n    public static long decodeLong(byte[] data, int index) {\n\n        long value = 0;\n\n        if (data[index] == 0x00) {\n            throw new RuntimeException(\"not a number\");\n        } else if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) {\n\n            return data[index];\n\n        } else if ((data[index] & 0xFF) <= OFFSET_SHORT_ITEM + Long.BYTES) {\n\n            byte length = (byte) (data[index] - OFFSET_SHORT_ITEM);\n            byte pow = (byte) (length - 1);\n            for (int i = 1; i <= length; ++i) {\n                // << (8 * pow) == bit shift to 0 (*1), 8 (*256) , 16 (*65..)..\n                value += (long) (data[index + i] & 0xFF) << (8 * pow);\n                pow--;\n            }\n        } else {\n\n            // If there are more than 8 bytes, it is not going\n            // to decode properly into a long.\n            throw new RuntimeException(\"wrong decode attempt\");\n        }\n        return value;\n    }\n\n    private static String decodeStringItem(byte[] data, int index) {\n\n        final byte[] valueBytes = decodeItemBytes(data, index);\n\n        if (valueBytes.length == 0) {\n            // shortcut\n            return \"\";\n        } else {\n            return new String(valueBytes);\n        }\n    }\n\n    public static BigInteger decodeBigInteger(byte[] data, int index) {\n\n        final byte[] valueBytes = decodeItemBytes(data, index);\n\n        if (valueBytes.length == 0) {\n            // shortcut\n            return BigInteger.ZERO;\n        } else {\n            BigInteger res = new BigInteger(1, valueBytes);\n            return res;\n        }\n    }\n\n    private static byte[] decodeByteArray(byte[] data, int index) {\n\n        return decodeItemBytes(data, index);\n    }\n\n    private static int nextItemLength(byte[] data, int index) {\n\n        if (index >= data.length)\n            return -1;\n        // [0xf8, 0xff]\n        if ((data[index] & 0xFF) > OFFSET_LONG_LIST) {\n            byte lengthOfLength = (byte) (data[index] - OFFSET_LONG_LIST);\n\n            return calcLength(lengthOfLength, data, index);\n        }\n        // [0xc0, 0xf7]\n        if ((data[index] & 0xFF) >= OFFSET_SHORT_LIST\n                && (data[index] & 0xFF) <= OFFSET_LONG_LIST) {\n\n            return (byte) ((data[index] & 0xFF) - OFFSET_SHORT_LIST);\n        }\n        // [0xb8, 0xbf]\n        if ((data[index] & 0xFF) > OFFSET_LONG_ITEM\n                && (data[index] & 0xFF) < OFFSET_SHORT_LIST) {\n\n            byte lengthOfLength = (byte) (data[index] - OFFSET_LONG_ITEM);\n            return calcLength(lengthOfLength, data, index);\n        }\n        // [0x81, 0xb7]\n        if ((data[index] & 0xFF) > OFFSET_SHORT_ITEM\n                && (data[index] & 0xFF) <= OFFSET_LONG_ITEM) {\n            return (byte) ((data[index] & 0xFF) - OFFSET_SHORT_ITEM);\n        }\n        // [0x00, 0x80]\n        if ((data[index] & 0xFF) <= OFFSET_SHORT_ITEM) {\n            return 1;\n        }\n        return -1;\n    }\n\n    public static byte[] decodeIP4Bytes(byte[] data, int index) {\n\n        int offset = 1;\n\n        final byte[] result = new byte[4];\n        for (int i = 0; i < 4; i++) {\n            result[i] = decodeOneByteItem(data, index + offset);\n            if ((data[index + offset] & 0xFF) > OFFSET_SHORT_ITEM)\n                offset += 2;\n            else\n                offset += 1;\n        }\n\n        // return IP address\n        return result;\n    }\n\n    public static int getFirstListElement(byte[] payload, int pos) {\n\n        if (pos >= payload.length)\n            return -1;\n\n        // [0xf8, 0xff]\n        if ((payload[pos] & 0xFF) > OFFSET_LONG_LIST) {\n            byte lengthOfLength = (byte) (payload[pos] - OFFSET_LONG_LIST);\n            return pos + lengthOfLength + 1;\n        }\n        // [0xc0, 0xf7]\n        if ((payload[pos] & 0xFF) >= OFFSET_SHORT_LIST\n                && (payload[pos] & 0xFF) <= OFFSET_LONG_LIST) {\n            return pos + 1;\n        }\n        // [0xb8, 0xbf]\n        if ((payload[pos] & 0xFF) > OFFSET_LONG_ITEM\n                && (payload[pos] & 0xFF) < OFFSET_SHORT_LIST) {\n            byte lengthOfLength = (byte) (payload[pos] - OFFSET_LONG_ITEM);\n            return pos + lengthOfLength + 1;\n        }\n        return -1;\n    }\n\n    public static int getNextElementIndex(byte[] payload, int pos) {\n\n        if (pos >= payload.length)\n            return -1;\n\n        // [0xf8, 0xff]\n        if ((payload[pos] & 0xFF) > OFFSET_LONG_LIST) {\n            byte lengthOfLength = (byte) (payload[pos] - OFFSET_LONG_LIST);\n            int length = calcLength(lengthOfLength, payload, pos);\n            return pos + lengthOfLength + length + 1;\n        }\n        // [0xc0, 0xf7]\n        if ((payload[pos] & 0xFF) >= OFFSET_SHORT_LIST\n                && (payload[pos] & 0xFF) <= OFFSET_LONG_LIST) {\n\n            byte length = (byte) ((payload[pos] & 0xFF) - OFFSET_SHORT_LIST);\n            return pos + 1 + length;\n        }\n        // [0xb8, 0xbf]\n        if ((payload[pos] & 0xFF) > OFFSET_LONG_ITEM\n                && (payload[pos] & 0xFF) < OFFSET_SHORT_LIST) {\n\n            byte lengthOfLength = (byte) (payload[pos] - OFFSET_LONG_ITEM);\n            int length = calcLength(lengthOfLength, payload, pos);\n            return pos + lengthOfLength + length + 1;\n        }\n        // [0x81, 0xb7]\n        if ((payload[pos] & 0xFF) > OFFSET_SHORT_ITEM\n                && (payload[pos] & 0xFF) <= OFFSET_LONG_ITEM) {\n\n            byte length = (byte) ((payload[pos] & 0xFF) - OFFSET_SHORT_ITEM);\n            return pos + 1 + length;\n        }\n        // []0x80]\n        if ((payload[pos] & 0xFF) == OFFSET_SHORT_ITEM) {\n            return pos + 1;\n        }\n        // [0x00, 0x7f]\n        if ((payload[pos] & 0xFF) < OFFSET_SHORT_ITEM) {\n            return pos + 1;\n        }\n        return -1;\n    }\n\n    /**\n     * Get exactly one message payload\n     */\n    public static void fullTraverse(byte[] msgData, int level, int startPos,\n                                    int endPos, int levelToIndex, Queue<Integer> index) {\n\n        try {\n\n            if (msgData == null || msgData.length == 0)\n                return;\n            int pos = startPos;\n\n            while (pos < endPos) {\n\n                if (level == levelToIndex)\n                    index.add(pos);\n\n                // It's a list with a payload more than 55 bytes\n                // data[0] - 0xF7 = how many next bytes allocated\n                // for the length of the list\n                // [0xf8, 0xff]\n                if ((msgData[pos] & 0xFF) > OFFSET_LONG_LIST) {\n\n                    byte lengthOfLength = (byte) (msgData[pos] - OFFSET_LONG_LIST);\n                    int length = calcLength(lengthOfLength, msgData, pos);\n\n                    // now we can parse an item for data[1]..data[length]\n                    System.out.println(\"-- level: [\" + level\n                            + \"] Found big list length: \" + length);\n\n                    fullTraverse(msgData, level + 1, pos + lengthOfLength + 1,\n                            pos + lengthOfLength + length, levelToIndex, index);\n\n                    pos += lengthOfLength + length + 1;\n                    continue;\n                }\n                // It's a list with a payload less than or equal to 55 bytes\n                // [0xc0, 0xf7]\n                if ((msgData[pos] & 0xFF) >= OFFSET_SHORT_LIST\n                        && (msgData[pos] & 0xFF) <= OFFSET_LONG_LIST) {\n\n                    byte length = (byte) ((msgData[pos] & 0xFF) - OFFSET_SHORT_LIST);\n\n                    System.out.println(\"-- level: [\" + level\n                            + \"] Found small list length: \" + length);\n\n                    fullTraverse(msgData, level + 1, pos + 1, pos + length + 1,\n                            levelToIndex, index);\n\n                    pos += 1 + length;\n                    continue;\n                }\n                // It's an item with a payload more than 55 bytes\n                // data[0] - 0xB7 = how much next bytes allocated for\n                // the length of the string\n                // [0xb8, 0xbf]\n                if ((msgData[pos] & 0xFF) > OFFSET_LONG_ITEM\n                        && (msgData[pos] & 0xFF) < OFFSET_SHORT_LIST) {\n\n                    byte lengthOfLength = (byte) (msgData[pos] - OFFSET_LONG_ITEM);\n                    int length = calcLength(lengthOfLength, msgData, pos);\n\n                    // now we can parse an item for data[1]..data[length]\n                    System.out.println(\"-- level: [\" + level\n                            + \"] Found big item length: \" + length);\n                    pos += lengthOfLength + length + 1;\n\n                    continue;\n                }\n                // It's an item less than 55 bytes long,\n                // data[0] - 0x80 == length of the item\n                // [0x81, 0xb7]\n                if ((msgData[pos] & 0xFF) > OFFSET_SHORT_ITEM\n                        && (msgData[pos] & 0xFF) <= OFFSET_LONG_ITEM) {\n\n                    byte length = (byte) ((msgData[pos] & 0xFF) - OFFSET_SHORT_ITEM);\n\n                    System.out.println(\"-- level: [\" + level\n                            + \"] Found small item length: \" + length);\n                    pos += 1 + length;\n                    continue;\n                }\n                // null item\n                // [0x80]\n                if ((msgData[pos] & 0xFF) == OFFSET_SHORT_ITEM) {\n                    System.out.println(\"-- level: [\" + level\n                            + \"] Found null item: \");\n                    pos += 1;\n                    continue;\n                }\n                // single byte item\n                // [0x00, 0x7f]\n                if ((msgData[pos] & 0xFF) < OFFSET_SHORT_ITEM) {\n                    System.out.println(\"-- level: [\" + level\n                            + \"] Found single item: \");\n                    pos += 1;\n                    continue;\n                }\n            }\n        } catch (Throwable th) {\n            throw new RuntimeException(\"RLP wrong encoding\",\n                    th.fillInStackTrace());\n        }\n    }\n\n    /**\n     * Parse length of long item or list.\n     * RLP supports lengths with up to 8 bytes long,\n     * but due to java limitation it returns either encoded length\n     * or {@link Integer#MAX_VALUE} in case if encoded length is greater\n     *\n     * @param lengthOfLength length of length in bytes\n     * @param msgData        message\n     * @param pos            position to parse from\n     * @return calculated length\n     */\n    private static int calcLength(int lengthOfLength, byte[] msgData, int pos) {\n        byte pow = (byte) (lengthOfLength - 1);\n        int length = 0;\n        for (int i = 1; i <= lengthOfLength; ++i) {\n\n            int bt = msgData[pos + i] & 0xFF;\n            int shift = 8 * pow;\n\n            // no leading zeros are acceptable\n            if (bt == 0 && length == 0) {\n                throw new RuntimeException(\"RLP length contains leading zeros\");\n            }\n\n            // return MAX_VALUE if index of highest bit is more than 31\n            if (32 - Integer.numberOfLeadingZeros(bt) + shift > 31) {\n                return Integer.MAX_VALUE;\n            }\n\n            length += bt << shift;\n            pow--;\n        }\n        return length;\n    }\n\n    public static byte getCommandCode(byte[] data) {\n        int index = getFirstListElement(data, 0);\n        final byte command = data[index];\n        return ((command & 0xFF) == OFFSET_SHORT_ITEM) ? 0 : command;\n    }\n\n    /**\n     * Parse wire byte[] message into RLP elements\n     *\n     * @param msgData - raw RLP data\n     * @return rlpList\n     * - outcome of recursive RLP structure\n     */\n    public static RLPList decode2(byte[] msgData) {\n        RLPList rlpList = new RLPList();\n        fullTraverse(msgData, 0, 0, msgData.length, 1, rlpList);\n        return rlpList;\n    }\n\n    public static RLPElement decode2OneItem(byte[] msgData, int startPos) {\n        RLPList rlpList = new RLPList();\n        fullTraverse(msgData, 0, startPos, startPos + 1, 1, rlpList);\n        return rlpList.get(0);\n    }\n\n    /**\n     * Get exactly one message payload\n     */\n    private static void fullTraverse(byte[] msgData, int level, int startPos,\n                                     int endPos, int levelToIndex, RLPList rlpList) {\n\n        try {\n            if (msgData == null || msgData.length == 0)\n                return;\n            int pos = startPos;\n\n            while (pos < endPos) {\n\n//                logger.debug(\"fullTraverse: level: \" + level + \" startPos: \" + pos + \" endPos: \" + endPos);\n\n\n                // It's a list with a payload more than 55 bytes\n                // data[0] - 0xF7 = how many next bytes allocated\n                // for the length of the list\n                if ((msgData[pos] & 0xFF) > OFFSET_LONG_LIST) {\n\n                    byte lengthOfLength = (byte) (msgData[pos] - OFFSET_LONG_LIST);\n                    int length = calcLength(lengthOfLength, msgData, pos);\n\n                    if (length < SIZE_THRESHOLD) {\n                        throw new RuntimeException(\"Short list has been encoded as long list\");\n                    }\n\n                    // check payload bounds\n                    if (length > msgData.length - pos - lengthOfLength) {\n                        throw new RuntimeException(\"Parsed data lays outside of RLP length boundaries\");\n                    }\n\n                    byte[] rlpData = new byte[lengthOfLength + length + 1];\n                    System.arraycopy(msgData, pos, rlpData, 0, lengthOfLength\n                            + length + 1);\n\n                    RLPList newLevelList = new RLPList();\n                    newLevelList.setRLPData(rlpData);\n\n                    fullTraverse(msgData, level + 1, pos + lengthOfLength + 1,\n                            pos + lengthOfLength + length + 1, levelToIndex,\n                            newLevelList);\n                    rlpList.add(newLevelList);\n\n                    pos += lengthOfLength + length + 1;\n                    continue;\n                }\n                // It's a list with a payload less than 55 bytes\n                if ((msgData[pos] & 0xFF) >= OFFSET_SHORT_LIST\n                        && (msgData[pos] & 0xFF) <= OFFSET_LONG_LIST) {\n\n                    byte length = (byte) ((msgData[pos] & 0xFF) - OFFSET_SHORT_LIST);\n\n                    byte[] rlpData = new byte[length + 1];\n                    System.arraycopy(msgData, pos, rlpData, 0, length + 1);\n\n                    RLPList newLevelList = new RLPList();\n                    newLevelList.setRLPData(rlpData);\n\n                    if (length > 0)\n                        fullTraverse(msgData, level + 1, pos + 1, pos + length\n                                + 1, levelToIndex, newLevelList);\n                    rlpList.add(newLevelList);\n\n                    pos += 1 + length;\n                    continue;\n                }\n                // It's an item with a payload more than 55 bytes\n                // data[0] - 0xB7 = how much next bytes allocated for\n                // the length of the string\n                if ((msgData[pos] & 0xFF) > OFFSET_LONG_ITEM\n                        && (msgData[pos] & 0xFF) < OFFSET_SHORT_LIST) {\n\n                    byte lengthOfLength = (byte) (msgData[pos] - OFFSET_LONG_ITEM);\n                    int length = calcLength(lengthOfLength, msgData, pos);\n\n                    if (length < SIZE_THRESHOLD) {\n                        throw new RuntimeException(\"Short item has been encoded as long item\");\n                    }\n\n                    // check payload bounds\n                    if (length > msgData.length - pos - lengthOfLength) {\n                        throw new RuntimeException(\"Parsed data lays outside of RLP length boundaries\");\n                    }\n\n                    // now we can parse an item for data[1]..data[length]\n                    byte[] item = new byte[length];\n                    System.arraycopy(msgData, pos + lengthOfLength + 1, item,\n                            0, length);\n\n                    RLPItem rlpItem = new RLPItem(item);\n                    rlpList.add(rlpItem);\n                    pos += lengthOfLength + length + 1;\n\n                    continue;\n                }\n                // It's an item less than 55 bytes long,\n                // data[0] - 0x80 == length of the item\n                if ((msgData[pos] & 0xFF) > OFFSET_SHORT_ITEM\n                        && (msgData[pos] & 0xFF) <= OFFSET_LONG_ITEM) {\n\n                    byte length = (byte) ((msgData[pos] & 0xFF) - OFFSET_SHORT_ITEM);\n\n                    byte[] item = new byte[length];\n                    System.arraycopy(msgData, pos + 1, item, 0, length);\n\n                    if (length == 1 && (item[0] & 0xFF) < OFFSET_SHORT_ITEM) {\n                        throw new RuntimeException(\"Single byte has been encoded as byte string\");\n                    }\n\n                    RLPItem rlpItem = new RLPItem(item);\n                    rlpList.add(rlpItem);\n                    pos += 1 + length;\n\n                    continue;\n                }\n                // null item\n                if ((msgData[pos] & 0xFF) == OFFSET_SHORT_ITEM) {\n                    byte[] item = ByteUtil.EMPTY_BYTE_ARRAY;\n                    RLPItem rlpItem = new RLPItem(item);\n                    rlpList.add(rlpItem);\n                    pos += 1;\n                    continue;\n                }\n                // single byte item\n                if ((msgData[pos] & 0xFF) < OFFSET_SHORT_ITEM) {\n\n                    byte[] item = {(byte) (msgData[pos] & 0xFF)};\n\n                    RLPItem rlpItem = new RLPItem(item);\n                    rlpList.add(rlpItem);\n                    pos += 1;\n                }\n            }\n        } catch (Exception e) {\n            throw new RuntimeException(\"RLP wrong encoding (\" + Hex.toHexString(msgData, startPos, endPos - startPos) + \")\", e);\n        } catch (OutOfMemoryError e) {\n            throw new RuntimeException(\"Invalid RLP (excessive mem allocation while parsing) (\" + Hex.toHexString(msgData, startPos, endPos - startPos) + \")\", e);\n        }\n    }\n\n    /**\n     * Reads any RLP encoded byte-array and returns all objects as byte-array or list of byte-arrays\n     *\n     * @param data RLP encoded byte-array\n     * @param pos  position in the array to start reading\n     * @return DecodeResult encapsulates the decoded items as a single Object and the final read position\n     */\n    public static DecodeResult decode(byte[] data, int pos) {\n        if (data == null || data.length < 1) {\n            return null;\n        }\n        int prefix = data[pos] & 0xFF;\n        if (prefix == OFFSET_SHORT_ITEM) {  // 0x80\n            return new DecodeResult(pos + 1, \"\"); // means no length or 0\n        } else if (prefix < OFFSET_SHORT_ITEM) {  // [0x00, 0x7f]\n            return new DecodeResult(pos + 1, new byte[]{data[pos]}); // byte is its own RLP encoding\n        } else if (prefix <= OFFSET_LONG_ITEM) {  // [0x81, 0xb7]\n            int len = prefix - OFFSET_SHORT_ITEM; // length of the encoded bytes\n            return new DecodeResult(pos + 1 + len, copyOfRange(data, pos + 1, pos + 1 + len));\n        } else if (prefix < OFFSET_SHORT_LIST) {  // [0xb8, 0xbf]\n            int lenlen = prefix - OFFSET_LONG_ITEM; // length of length the encoded bytes\n            int lenbytes = byteArrayToInt(copyOfRange(data, pos + 1, pos + 1 + lenlen)); // length of encoded bytes\n            return new DecodeResult(pos + 1 + lenlen + lenbytes, copyOfRange(data, pos + 1 + lenlen, pos + 1 + lenlen\n                    + lenbytes));\n        } else if (prefix <= OFFSET_LONG_LIST) {  // [0xc0, 0xf7]\n            int len = prefix - OFFSET_SHORT_LIST; // length of the encoded list\n            int prevPos = pos;\n            pos++;\n            return decodeList(data, pos, prevPos, len);\n        } else if (prefix <= 0xFF) {  // [0xf8, 0xff]\n            int lenlen = prefix - OFFSET_LONG_LIST; // length of length the encoded list\n            int lenlist = byteArrayToInt(copyOfRange(data, pos + 1, pos + 1 + lenlen)); // length of encoded bytes\n            pos = pos + lenlen + 1; // start at position of first element in list\n            int prevPos = lenlist;\n            return decodeList(data, pos, prevPos, lenlist);\n        } else {\n            throw new RuntimeException(\"Only byte values between 0x00 and 0xFF are supported, but got: \" + prefix);\n        }\n    }\n\n    public static final class LList {\n        private final byte[] rlp;\n        private final int[] offsets = new int[32];\n        private final int[] lens = new int[32];\n        private int cnt;\n\n        public LList(byte[] rlp) {\n            this.rlp = rlp;\n        }\n\n        public byte[] getEncoded() {\n            byte encoded[][] = new byte[cnt][];\n            for (int i = 0; i < cnt; i++) {\n                encoded[i] = encodeElement(getBytes(i));\n            }\n            return encodeList(encoded);\n        }\n\n        public void add(int off, int len, boolean isList) {\n            offsets[cnt] = off;\n            lens[cnt] = isList ? (-1 - len) : len;\n            cnt++;\n        }\n\n        public byte[] getBytes(int idx) {\n            int len = lens[idx];\n            len = len < 0 ? (-len - 1) : len;\n            byte[] ret = new byte[len];\n            System.arraycopy(rlp, offsets[idx], ret, 0, len);\n            return ret;\n        }\n\n        public LList getList(int idx) {\n            return decodeLazyList(rlp, offsets[idx], -lens[idx] - 1);\n        }\n\n        public boolean isList(int idx) {\n            return lens[idx] < 0;\n        }\n\n        public int size() {\n            return cnt;\n        }\n    }\n\n    public static LList decodeLazyList(byte[] data) {\n        return decodeLazyList(data, 0, data.length).getList(0);\n    }\n\n    public static LList decodeLazyList(byte[] data, int pos, int length) {\n        if (data == null || data.length < 1) {\n            return null;\n        }\n        LList ret = new LList(data);\n        int end = pos + length;\n\n        while (pos < end) {\n            int prefix = data[pos] & 0xFF;\n            if (prefix == OFFSET_SHORT_ITEM) {  // 0x80\n                ret.add(pos, 0, false); // means no length or 0\n                pos++;\n            } else if (prefix < OFFSET_SHORT_ITEM) {  // [0x00, 0x7f]\n                ret.add(pos, 1, false); // means no length or 0\n                pos++;\n            } else if (prefix <= OFFSET_LONG_ITEM) {  // [0x81, 0xb7]\n                int len = prefix - OFFSET_SHORT_ITEM; // length of the encoded bytes\n                ret.add(pos + 1, len, false);\n                pos += len + 1;\n            } else if (prefix < OFFSET_SHORT_LIST) {  // [0xb8, 0xbf]\n                int lenlen = prefix - OFFSET_LONG_ITEM; // length of length the encoded bytes\n                int lenbytes = byteArrayToInt(copyOfRange(data, pos + 1, pos + 1 + lenlen)); // length of encoded bytes\n                ret.add(pos + 1 + lenlen, lenbytes, false);\n                pos += 1 + lenlen + lenbytes;\n            } else if (prefix <= OFFSET_LONG_LIST) {  // [0xc0, 0xf7]\n                int len = prefix - OFFSET_SHORT_LIST; // length of the encoded list\n                ret.add(pos + 1, len, true);\n                pos += 1 + len;\n            } else if (prefix <= 0xFF) {  // [0xf8, 0xff]\n                int lenlen = prefix - OFFSET_LONG_LIST; // length of length the encoded list\n                int lenlist = byteArrayToInt(copyOfRange(data, pos + 1, pos + 1 + lenlen)); // length of encoded bytes\n                ret.add(pos + 1 + lenlen, lenlist, true);\n                pos += 1 + lenlen + lenlist; // start at position of first element in list\n            } else {\n                throw new RuntimeException(\"Only byte values between 0x00 and 0xFF are supported, but got: \" + prefix);\n            }\n        }\n        return ret;\n    }\n\n\n    private static DecodeResult decodeList(byte[] data, int pos, int prevPos, int len) {\n        List<Object> slice = new ArrayList<>();\n        for (int i = 0; i < len; ) {\n            // Get the next item in the data list and append it\n            DecodeResult result = decode(data, pos);\n            slice.add(result.getDecoded());\n            // Increment pos by the amount bytes in the previous read\n            prevPos = result.getPos();\n            i += (prevPos - pos);\n            pos = prevPos;\n        }\n        return new DecodeResult(pos, slice.toArray());\n    }\n\n    /* ******************************************************\n     *                      ENCODING                        *\n     * ******************************************************/\n\n    /**\n     * Turn Object into its RLP encoded equivalent of a byte-array\n     * Support for String, Integer, BigInteger and Lists of any of these types.\n     *\n     * @param input as object or List of objects\n     * @return byte[] RLP encoded\n     */\n    public static byte[] encode(Object input) {\n        Value val = new Value(input);\n        if (val.isList()) {\n            List<Object> inputArray = val.asList();\n            if (inputArray.isEmpty()) {\n                return encodeLength(inputArray.size(), OFFSET_SHORT_LIST);\n            }\n            byte[] output = ByteUtil.EMPTY_BYTE_ARRAY;\n            for (Object object : inputArray) {\n                output = concatenate(output, encode(object));\n            }\n            byte[] prefix = encodeLength(output.length, OFFSET_SHORT_LIST);\n            return concatenate(prefix, output);\n        } else {\n            byte[] inputAsBytes = toBytes(input);\n            if (inputAsBytes.length == 1 && (inputAsBytes[0] & 0xff) <= 0x80) {\n                return inputAsBytes;\n            } else {\n                byte[] firstByte = encodeLength(inputAsBytes.length, OFFSET_SHORT_ITEM);\n                return concatenate(firstByte, inputAsBytes);\n            }\n        }\n    }\n\n    /**\n     * Integer limitation goes up to 2^31-1 so length can never be bigger than MAX_ITEM_LENGTH\n     */\n    public static byte[] encodeLength(int length, int offset) {\n        if (length < SIZE_THRESHOLD) {\n            byte firstByte = (byte) (length + offset);\n            return new byte[]{firstByte};\n        } else if (length < MAX_ITEM_LENGTH) {\n            byte[] binaryLength;\n            if (length > 0xFF)\n                binaryLength = intToBytesNoLeadZeroes(length);\n            else\n                binaryLength = new byte[]{(byte) length};\n            byte firstByte = (byte) (binaryLength.length + offset + SIZE_THRESHOLD - 1);\n            return concatenate(new byte[]{firstByte}, binaryLength);\n        } else {\n            throw new RuntimeException(\"Input too long\");\n        }\n    }\n\n    public static byte[] encodeByte(byte singleByte) {\n        if ((singleByte & 0xFF) == 0) {\n            return new byte[]{(byte) OFFSET_SHORT_ITEM};\n        } else if ((singleByte & 0xFF) <= 0x7F) {\n            return new byte[]{singleByte};\n        } else {\n            return new byte[]{(byte) (OFFSET_SHORT_ITEM + 1), singleByte};\n        }\n    }\n\n    public static byte[] encodeShort(short singleShort) {\n\n        if ((singleShort & 0xFF) == singleShort)\n            return encodeByte((byte) singleShort);\n        else {\n            return new byte[]{(byte) (OFFSET_SHORT_ITEM + 2),\n                    (byte) (singleShort >> 8 & 0xFF),\n                    (byte) (singleShort >> 0 & 0xFF)};\n        }\n    }\n\n    public static byte[] encodeInt(int singleInt) {\n\n        if ((singleInt & 0xFF) == singleInt)\n            return encodeByte((byte) singleInt);\n        else if ((singleInt & 0xFFFF) == singleInt)\n            return encodeShort((short) singleInt);\n        else if ((singleInt & 0xFFFFFF) == singleInt)\n            return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3),\n                    (byte) (singleInt >>> 16),\n                    (byte) (singleInt >>> 8),\n                    (byte) singleInt};\n        else {\n            return new byte[]{(byte) (OFFSET_SHORT_ITEM + 4),\n                    (byte) (singleInt >>> 24),\n                    (byte) (singleInt >>> 16),\n                    (byte) (singleInt >>> 8),\n                    (byte) singleInt};\n        }\n    }\n\n    public static byte[] encodeString(String srcString) {\n        return encodeElement(srcString.getBytes());\n    }\n\n    public static byte[] encodeBigInteger(BigInteger srcBigInteger) {\n        if (srcBigInteger.compareTo(BigInteger.ZERO) < 0)\n            throw new RuntimeException(\"negative numbers are not allowed\");\n\n        if (srcBigInteger.equals(BigInteger.ZERO))\n            return encodeByte((byte) 0);\n        else\n            return encodeElement(asUnsignedByteArray(srcBigInteger));\n    }\n\n    public static byte[] encodeElement(byte[] srcData) {\n\n        // [0x80]\n        if (isNullOrZeroArray(srcData)) {\n            return new byte[]{(byte) OFFSET_SHORT_ITEM};\n\n            // [0x00]\n        } else if (isSingleZero(srcData)) {\n            return srcData;\n\n            // [0x01, 0x7f] - single byte, that byte is its own RLP encoding\n        } else if (srcData.length == 1 && (srcData[0] & 0xFF) < 0x80) {\n            return srcData;\n\n            // [0x80, 0xb7], 0 - 55 bytes\n        } else if (srcData.length < SIZE_THRESHOLD) {\n            // length = 8X\n            byte length = (byte) (OFFSET_SHORT_ITEM + srcData.length);\n            byte[] data = Arrays.copyOf(srcData, srcData.length + 1);\n            System.arraycopy(data, 0, data, 1, srcData.length);\n            data[0] = length;\n\n            return data;\n            // [0xb8, 0xbf], 56+ bytes\n        } else {\n            // length of length = BX\n            // prefix = [BX, [length]]\n            int tmpLength = srcData.length;\n            byte lengthOfLength = 0;\n            while (tmpLength != 0) {\n                ++lengthOfLength;\n                tmpLength = tmpLength >> 8;\n            }\n\n            // set length Of length at first byte\n            byte[] data = new byte[1 + lengthOfLength + srcData.length];\n            data[0] = (byte) (OFFSET_LONG_ITEM + lengthOfLength);\n\n            // copy length after first byte\n            tmpLength = srcData.length;\n            for (int i = lengthOfLength; i > 0; --i) {\n                data[i] = (byte) (tmpLength & 0xFF);\n                tmpLength = tmpLength >> 8;\n            }\n\n            // at last copy the number bytes after its length\n            System.arraycopy(srcData, 0, data, 1 + lengthOfLength, srcData.length);\n\n            return data;\n        }\n    }\n\n    public static int calcElementPrefixSize(byte[] srcData) {\n\n        if (isNullOrZeroArray(srcData))\n            return 0;\n        else if (isSingleZero(srcData))\n            return 0;\n        else if (srcData.length == 1 && (srcData[0] & 0xFF) < 0x80) {\n            return 0;\n        } else if (srcData.length < SIZE_THRESHOLD) {\n            return 1;\n        } else {\n            // length of length = BX\n            // prefix = [BX, [length]]\n            int tmpLength = srcData.length;\n            byte byteNum = 0;\n            while (tmpLength != 0) {\n                ++byteNum;\n                tmpLength = tmpLength >> 8;\n            }\n\n            return 1 + byteNum;\n        }\n    }\n\n\n    public static byte[] encodeListHeader(int size) {\n\n        if (size == 0) {\n            return new byte[]{(byte) OFFSET_SHORT_LIST};\n        }\n\n        int totalLength = size;\n\n        byte[] header;\n        if (totalLength < SIZE_THRESHOLD) {\n\n            header = new byte[1];\n            header[0] = (byte) (OFFSET_SHORT_LIST + totalLength);\n        } else {\n            // length of length = BX\n            // prefix = [BX, [length]]\n            int tmpLength = totalLength;\n            byte byteNum = 0;\n            while (tmpLength != 0) {\n                ++byteNum;\n                tmpLength = tmpLength >> 8;\n            }\n            tmpLength = totalLength;\n\n            byte[] lenBytes = new byte[byteNum];\n            for (int i = 0; i < byteNum; ++i) {\n                lenBytes[byteNum - 1 - i] = (byte) ((tmpLength >> (8 * i)) & 0xFF);\n            }\n            // first byte = F7 + bytes.length\n            header = new byte[1 + lenBytes.length];\n            header[0] = (byte) (OFFSET_LONG_LIST + byteNum);\n            System.arraycopy(lenBytes, 0, header, 1, lenBytes.length);\n\n        }\n\n        return header;\n    }\n\n\n    public static byte[] encodeLongElementHeader(int length) {\n\n        if (length < SIZE_THRESHOLD) {\n\n            if (length == 0)\n                return new byte[]{(byte) 0x80};\n            else\n                return new byte[]{(byte) (0x80 + length)};\n\n        } else {\n\n            // length of length = BX\n            // prefix = [BX, [length]]\n            int tmpLength = length;\n            byte byteNum = 0;\n            while (tmpLength != 0) {\n                ++byteNum;\n                tmpLength = tmpLength >> 8;\n            }\n\n            byte[] lenBytes = new byte[byteNum];\n            for (int i = 0; i < byteNum; ++i) {\n                lenBytes[byteNum - 1 - i] = (byte) ((length >> (8 * i)) & 0xFF);\n            }\n\n            // first byte = F7 + bytes.length\n            byte[] header = new byte[1 + lenBytes.length];\n            header[0] = (byte) (OFFSET_LONG_ITEM + byteNum);\n            System.arraycopy(lenBytes, 0, header, 1, lenBytes.length);\n\n            return header;\n        }\n    }\n\n    public static byte[] encodeSet(Set<ByteArrayWrapper> data) {\n\n        int dataLength = 0;\n        Set<byte[]> encodedElements = new HashSet<>();\n        for (ByteArrayWrapper element : data) {\n\n            byte[] encodedElement = RLP.encodeElement(element.getData());\n            dataLength += encodedElement.length;\n            encodedElements.add(encodedElement);\n        }\n\n        byte[] listHeader = encodeListHeader(dataLength);\n\n        byte[] output = new byte[listHeader.length + dataLength];\n\n        System.arraycopy(listHeader, 0, output, 0, listHeader.length);\n\n        int cummStart = listHeader.length;\n        for (byte[] element : encodedElements) {\n            System.arraycopy(element, 0, output, cummStart, element.length);\n            cummStart += element.length;\n        }\n\n        return output;\n    }\n\n    public static byte[] encodeList(byte[]... elements) {\n\n        if (elements == null) {\n            return new byte[]{(byte) OFFSET_SHORT_LIST};\n        }\n\n        int totalLength = 0;\n        for (byte[] element1 : elements) {\n            totalLength += element1.length;\n        }\n\n        byte[] data;\n        int copyPos;\n        if (totalLength < SIZE_THRESHOLD) {\n\n            data = new byte[1 + totalLength];\n            data[0] = (byte) (OFFSET_SHORT_LIST + totalLength);\n            copyPos = 1;\n        } else {\n            // length of length = BX\n            // prefix = [BX, [length]]\n            int tmpLength = totalLength;\n            byte byteNum = 0;\n            while (tmpLength != 0) {\n                ++byteNum;\n                tmpLength = tmpLength >> 8;\n            }\n            tmpLength = totalLength;\n            byte[] lenBytes = new byte[byteNum];\n            for (int i = 0; i < byteNum; ++i) {\n                lenBytes[byteNum - 1 - i] = (byte) ((tmpLength >> (8 * i)) & 0xFF);\n            }\n            // first byte = F7 + bytes.length\n            data = new byte[1 + lenBytes.length + totalLength];\n            data[0] = (byte) (OFFSET_LONG_LIST + byteNum);\n            System.arraycopy(lenBytes, 0, data, 1, lenBytes.length);\n\n            copyPos = lenBytes.length + 1;\n        }\n        for (byte[] element : elements) {\n            System.arraycopy(element, 0, data, copyPos, element.length);\n            copyPos += element.length;\n        }\n        return data;\n    }\n\n    /*\n     *  Utility function to convert Objects into byte arrays\n     */\n    private static byte[] toBytes(Object input) {\n        if (input instanceof byte[]) {\n            return (byte[]) input;\n        } else if (input instanceof String) {\n            String inputString = (String) input;\n            return inputString.getBytes();\n        } else if (input instanceof Long) {\n            Long inputLong = (Long) input;\n            return (inputLong == 0) ? ByteUtil.EMPTY_BYTE_ARRAY : asUnsignedByteArray(BigInteger.valueOf(inputLong));\n        } else if (input instanceof Integer) {\n            Integer inputInt = (Integer) input;\n            return (inputInt == 0) ? ByteUtil.EMPTY_BYTE_ARRAY : asUnsignedByteArray(BigInteger.valueOf(inputInt));\n        } else if (input instanceof BigInteger) {\n            BigInteger inputBigInt = (BigInteger) input;\n            return (inputBigInt.equals(BigInteger.ZERO)) ? ByteUtil.EMPTY_BYTE_ARRAY : asUnsignedByteArray(inputBigInt);\n        } else if (input instanceof Value) {\n            Value val = (Value) input;\n            return toBytes(val.asObj());\n        }\n        throw new RuntimeException(\"Unsupported type: Only accepting String, Integer and BigInteger for now\");\n    }\n\n\n    private static byte[] decodeItemBytes(byte[] data, int index) {\n\n        final int length = calculateItemLength(data, index);\n        // [0x80]\n        if (length == 0) {\n\n            return new byte[0];\n\n            // [0x00, 0x7f] - single byte with item\n        } else if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) {\n\n            byte[] valueBytes = new byte[1];\n            System.arraycopy(data, index, valueBytes, 0, 1);\n            return valueBytes;\n\n            // [0x01, 0xb7] - 1-55 bytes item\n        } else if ((data[index] & 0xFF) <= OFFSET_LONG_ITEM) {\n\n            byte[] valueBytes = new byte[length];\n            System.arraycopy(data, index + 1, valueBytes, 0, length);\n            return valueBytes;\n\n            // [0xb8, 0xbf] - 56+ bytes item\n        } else if ((data[index] & 0xFF) > OFFSET_LONG_ITEM\n                && (data[index] & 0xFF) < OFFSET_SHORT_LIST) {\n\n            byte lengthOfLength = (byte) (data[index] - OFFSET_LONG_ITEM);\n            byte[] valueBytes = new byte[length];\n            System.arraycopy(data, index + 1 + lengthOfLength, valueBytes, 0, length);\n            return valueBytes;\n        } else {\n            throw new RuntimeException(\"wrong decode attempt\");\n        }\n    }\n\n\n    private static int calculateItemLength(byte[] data, int index) {\n\n        // [0xb8, 0xbf] - 56+ bytes item\n        if ((data[index] & 0xFF) > OFFSET_LONG_ITEM\n                && (data[index] & 0xFF) < OFFSET_SHORT_LIST) {\n\n            byte lengthOfLength = (byte) (data[index] - OFFSET_LONG_ITEM);\n            return calcLength(lengthOfLength, data, index);\n\n            // [0x81, 0xb7] - 0-55 bytes item\n        } else if ((data[index] & 0xFF) > OFFSET_SHORT_ITEM\n                && (data[index] & 0xFF) <= OFFSET_LONG_ITEM) {\n\n            return (byte) (data[index] - OFFSET_SHORT_ITEM);\n\n            // [0x80] - item = 0 itself\n        } else if ((data[index] & 0xFF) == OFFSET_SHORT_ITEM) {\n\n            return (byte) 0;\n\n            // [0x00, 0x7f] - 1 byte item, no separate length representation\n        } else if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) {\n\n            return (byte) 1;\n\n        } else {\n            throw new RuntimeException(\"wrong decode attempt\");\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/rlp/RLPElement.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.rlp;\n\nimport java.io.Serializable;\n\n/**\n * Wrapper class for decoded elements from an RLP encoded byte array.\n *\n * @author Roman Mandeleil\n * @since 01.04.2014\n */\npublic interface RLPElement extends Serializable {\n\n    byte[] getRLPData();\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/rlp/RLPItem.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.rlp;\n\n/**\n * @author Roman Mandeleil\n * @since 21.04.14\n */\npublic class RLPItem implements RLPElement {\n\n    private final byte[] rlpData;\n\n    public RLPItem(byte[] rlpData) {\n        this.rlpData = rlpData;\n    }\n\n    public byte[] getRLPData() {\n        if (rlpData.length == 0)\n            return null;\n        return rlpData;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/rlp/RLPList.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.rlp;\n\nimport com.quincysx.crypto.ethereum.utils.ByteUtil;\n\nimport java.util.ArrayList;\n\n/**\n * @author Roman Mandeleil\n * @since 21.04.14\n */\npublic class RLPList extends ArrayList<RLPElement> implements RLPElement {\n\n    byte[] rlpData;\n\n    public void setRLPData(byte[] rlpData) {\n        this.rlpData = rlpData;\n    }\n\n    public byte[] getRLPData() {\n        return rlpData;\n    }\n\n    public static void recursivePrint(RLPElement element) {\n\n        if (element == null)\n            throw new RuntimeException(\"RLPElement object can't be null\");\n        if (element instanceof RLPList) {\n\n            RLPList rlpList = (RLPList) element;\n            System.out.print(\"[\");\n            for (RLPElement singleElement : rlpList)\n                recursivePrint(singleElement);\n            System.out.print(\"]\");\n        } else {\n            String hex = ByteUtil.toHexString(element.getRLPData());\n            System.out.print(hex + \", \");\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/rlp/Value.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.rlp;\n\nimport com.cedarsoftware.util.DeepEquals;\nimport com.quincysx.crypto.ethereum.utils.ByteUtil;\n\n//import org.ethereum.crypto.HashUtil;\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.math.BigInteger;\n\nimport java.util.Arrays;\nimport java.util.List;\n\n/**\n * Class to encapsulate an object and provide utilities for conversion\n */\npublic class Value {\n\n    private Object value;\n    private byte[] rlp;\n    private byte[] sha3;\n\n    private boolean decoded = false;\n\n    public static Value fromRlpEncoded(byte[] data) {\n\n        if (data != null && data.length != 0) {\n            Value v = new Value();\n            v.init(data);\n            return v;\n        }\n        return null;\n    }\n\n    public Value() {\n    }\n\n    public void init(byte[] rlp) {\n        this.rlp = rlp;\n    }\n\n    public Value(Object obj) {\n\n        this.decoded = true;\n        if (obj == null) return;\n\n        if (obj instanceof Value) {\n            this.value = ((Value) obj).asObj();\n        } else {\n            this.value = obj;\n        }\n    }\n\n    public Value withHash(byte[] hash) {\n        sha3 = hash;\n        return this;\n    }\n\n    /* *****************\n     *      Convert\n     * *****************/\n\n    public Object asObj() {\n        decode();\n        return value;\n    }\n\n    public List<Object> asList() {\n        decode();\n        Object[] valueArray = (Object[]) value;\n        return Arrays.asList(valueArray);\n    }\n\n    public int asInt() {\n        decode();\n        if (isInt()) {\n            return (Integer) value;\n        } else if (isBytes()) {\n            return new BigInteger(1, asBytes()).intValue();\n        }\n        return 0;\n    }\n\n    public long asLong() {\n        decode();\n        if (isLong()) {\n            return (Long) value;\n        } else if (isBytes()) {\n            return new BigInteger(1, asBytes()).longValue();\n        }\n        return 0;\n    }\n\n    public BigInteger asBigInt() {\n        decode();\n        return (BigInteger) value;\n    }\n\n    public String asString() {\n        decode();\n        if (isBytes()) {\n            return new String((byte[]) value);\n        } else if (isString()) {\n            return (String) value;\n        }\n        return \"\";\n    }\n\n    public byte[] asBytes() {\n        decode();\n        if (isBytes()) {\n            return (byte[]) value;\n        } else if (isString()) {\n            return asString().getBytes();\n        }\n        return ByteUtil.EMPTY_BYTE_ARRAY;\n    }\n\n    public String getHex() {\n        return Hex.toHexString(this.encode());\n    }\n\n    public byte[] getData() {\n        return this.encode();\n    }\n\n\n    public int[] asSlice() {\n        return (int[]) value;\n    }\n\n    public Value get(int index) {\n        if (isList()) {\n            // Guard for OutOfBounds\n            if (asList().size() <= index) {\n                return new Value(null);\n            }\n            if (index < 0) {\n                throw new RuntimeException(\"Negative index not allowed\");\n            }\n            return new Value(asList().get(index));\n        }\n        // If this wasn't a slice you probably shouldn't be using this function\n        return new Value(null);\n    }\n\n    /* *****************\n     *      Utility\n     * *****************/\n\n    public void decode() {\n        if (!this.decoded) {\n            this.value = RLP.decode(rlp, 0).getDecoded();\n            this.decoded = true;\n        }\n    }\n\n    public byte[] encode() {\n        if (rlp == null)\n            rlp = RLP.encode(value);\n        return rlp;\n    }\n\n//    public byte[] hash() {\n//        if (sha3 == null)\n//            sha3 = HashUtil.sha3(encode());\n//        return sha3;\n//    }\n\n    public boolean cmp(Value o) {\n        return DeepEquals.deepEquals(this, o);\n    }\n\n    /* *****************\n     *      Checks\n     * *****************/\n\n    public boolean isList() {\n        decode();\n        return value != null && value.getClass().isArray() && !value.getClass().getComponentType().isPrimitive();\n    }\n\n    public boolean isString() {\n        decode();\n        return value instanceof String;\n    }\n\n    public boolean isInt() {\n        decode();\n        return value instanceof Integer;\n    }\n\n    public boolean isLong() {\n        decode();\n        return value instanceof Long;\n    }\n\n    public boolean isBigInt() {\n        decode();\n        return value instanceof BigInteger;\n    }\n\n    public boolean isBytes() {\n        decode();\n        return value instanceof byte[];\n    }\n\n    // it's only if the isBytes() = true;\n    public boolean isReadableString() {\n\n        decode();\n        int readableChars = 0;\n        byte[] data = (byte[]) value;\n\n        if (data.length == 1 && data[0] > 31 && data[0] < 126) {\n            return true;\n        }\n\n        for (byte aData : data) {\n            if (aData > 32 && aData < 126) ++readableChars;\n        }\n\n        return (double) readableChars / (double) data.length > 0.55;\n    }\n\n    // it's only if the isBytes() = true;\n    public boolean isHexString() {\n\n        decode();\n        int hexChars = 0;\n        byte[] data = (byte[]) value;\n\n        for (byte aData : data) {\n\n            if ((aData >= 48 && aData <= 57)\n                    || (aData >= 97 && aData <= 102))\n                ++hexChars;\n        }\n\n        return (double) hexChars / (double) data.length > 0.9;\n    }\n\n    public boolean isHashCode() {\n        decode();\n        return this.asBytes().length == 32;\n    }\n\n    public boolean isNull() {\n        decode();\n        return value == null;\n    }\n\n    public boolean isEmpty() {\n        decode();\n        if (isNull()) return true;\n        if (isBytes() && asBytes().length == 0) return true;\n        if (isList() && asList().isEmpty()) return true;\n        if (isString() && asString().equals(\"\")) return true;\n\n        return false;\n    }\n\n    public int length() {\n        decode();\n        if (isList()) {\n            return asList().size();\n        } else if (isBytes()) {\n            return asBytes().length;\n        } else if (isString()) {\n            return asString().length();\n        }\n        return 0;\n    }\n\n    public String toString() {\n\n        decode();\n        StringBuilder stringBuilder = new StringBuilder();\n\n        if (isList()) {\n\n            Object[] list = (Object[]) value;\n\n            // special case - key/value node\n            if (list.length == 2) {\n\n                stringBuilder.append(\"[ \");\n\n                Value key = new Value(list[0]);\n\n                byte[] keyNibbles = CompactEncoder.binToNibblesNoTerminator(key.asBytes());\n                String keyString = ByteUtil.nibblesToPrettyString(keyNibbles);\n                stringBuilder.append(keyString);\n\n                stringBuilder.append(\",\");\n\n                Value val = new Value(list[1]);\n                stringBuilder.append(val.toString());\n\n                stringBuilder.append(\" ]\");\n                return stringBuilder.toString();\n            }\n            stringBuilder.append(\" [\");\n\n            for (int i = 0; i < list.length; ++i) {\n                Value val = new Value(list[i]);\n                if (val.isString() || val.isEmpty()) {\n                    stringBuilder.append(\"'\").append(val.toString()).append(\"'\");\n                } else {\n                    stringBuilder.append(val.toString());\n                }\n                if (i < list.length - 1)\n                    stringBuilder.append(\", \");\n            }\n            stringBuilder.append(\"] \");\n\n            return stringBuilder.toString();\n        } else if (isEmpty()) {\n            return \"\";\n        } else if (isBytes()) {\n\n            StringBuilder output = new StringBuilder();\n            if (isHashCode()) {\n                output.append(Hex.toHexString(asBytes()));\n            } else if (isReadableString()) {\n                output.append(\"'\");\n                for (byte oneByte : asBytes()) {\n                    if (oneByte < 16) {\n                        output.append(\"\\\\x\").append(ByteUtil.oneByteToHexString(oneByte));\n                    } else {\n                        output.append(Character.valueOf((char) oneByte));\n                    }\n                }\n                output.append(\"'\");\n                return output.toString();\n            }\n            return Hex.toHexString(this.asBytes());\n        } else if (isString()) {\n            return asString();\n        }\n        return \"Unexpected type\";\n    }\n\n    public int countBranchNodes() {\n        decode();\n        if (this.isList()) {\n            List<Object> objList = this.asList();\n            int i = 0;\n            for (Object obj : objList) {\n                i += (new Value(obj)).countBranchNodes();\n            }\n            return i;\n        } else if (this.isBytes()) {\n            this.asBytes();\n        }\n        return 0;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/solidity/SolidityType.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.solidity;\n\nimport com.fasterxml.jackson.annotation.JsonCreator;\nimport com.fasterxml.jackson.annotation.JsonValue;\nimport com.quincysx.crypto.ethereum.utils.ByteUtil;\n\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.io.UnsupportedEncodingException;\nimport java.lang.reflect.Array;\nimport java.math.BigInteger;\nimport java.nio.charset.StandardCharsets;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\npublic abstract class SolidityType {\n    protected String name;\n\n    public SolidityType(String name) {\n        this.name = name;\n    }\n\n    /**\n     * The type name as it was specified in the interface description\n     */\n    public String getName() {\n        return name;\n    }\n\n    /**\n     * The canonical type name (used for the method signature creation)\n     * E.g. 'int' - canonical 'int256'\n     */\n    @JsonValue\n    public String getCanonicalName() {\n        return getName();\n    }\n\n    @JsonCreator\n    public static SolidityType getType(String typeName) {\n        if (typeName.contains(\"[\")) return ArrayType.getType(typeName);\n        if (\"bool\".equals(typeName)) return new BoolType();\n        if (typeName.startsWith(\"int\") || typeName.startsWith(\"uint\")) return new IntType(typeName);\n        if (\"address\".equals(typeName)) return new AddressType();\n        if (\"string\".equals(typeName)) return new StringType();\n        if (\"bytes\".equals(typeName)) return new BytesType();\n        if (\"function\".equals(typeName)) return new FunctionType();\n        if (typeName.startsWith(\"bytes\")) return new Bytes32Type(typeName);\n        throw new RuntimeException(\"Unknown type: \" + typeName);\n    }\n\n    /**\n     * Encodes the value according to specific type rules\n     *\n     * @param value\n     */\n    public abstract byte[] encode(Object value);\n\n    public abstract Object decode(byte[] encoded, int offset);\n\n    public Object decode(byte[] encoded) {\n        return decode(encoded, 0);\n    }\n\n    /**\n     * @return fixed size in bytes. For the dynamic types returns IntType.getFixedSize()\n     * which is effectively the int offset to dynamic data\n     */\n    public int getFixedSize() {\n        return 32;\n    }\n\n    public boolean isDynamicType() {\n        return false;\n    }\n\n    @Override\n    public String toString() {\n        return getName();\n    }\n\n\n    public static abstract class ArrayType extends SolidityType {\n        public static ArrayType getType(String typeName) {\n            int idx1 = typeName.indexOf(\"[\");\n            int idx2 = typeName.indexOf(\"]\", idx1);\n            if (idx1 + 1 == idx2) {\n                return new DynamicArrayType(typeName);\n            } else {\n                return new StaticArrayType(typeName);\n            }\n        }\n\n        SolidityType elementType;\n\n        public ArrayType(String name) {\n            super(name);\n            int idx = name.indexOf(\"[\");\n            String st = name.substring(0, idx);\n            int idx2 = name.indexOf(\"]\", idx);\n            String subDim = idx2 + 1 == name.length() ? \"\" : name.substring(idx2 + 1);\n            elementType = SolidityType.getType(st + subDim);\n        }\n\n        @Override\n        public byte[] encode(Object value) {\n            if (value.getClass().isArray()) {\n                List<Object> elems = new ArrayList<>();\n                for (int i = 0; i < Array.getLength(value); i++) {\n                    elems.add(Array.get(value, i));\n                }\n                return encodeList(elems);\n            } else if (value instanceof List) {\n                return encodeList((List) value);\n            } else {\n                throw new RuntimeException(\"List value expected for type \" + getName());\n            }\n        }\n\n        public SolidityType getElementType() {\n            return elementType;\n        }\n\n        public abstract byte[] encodeList(List l);\n    }\n\n    public static class StaticArrayType extends ArrayType {\n        int size;\n\n        public StaticArrayType(String name) {\n            super(name);\n            int idx1 = name.indexOf(\"[\");\n            int idx2 = name.indexOf(\"]\", idx1);\n            String dim = name.substring(idx1 + 1, idx2);\n            size = Integer.parseInt(dim);\n        }\n\n        @Override\n        public String getCanonicalName() {\n            return elementType.getCanonicalName() + \"[\" + size + \"]\";\n        }\n\n        @Override\n        public byte[] encodeList(List l) {\n            if (l.size() != size)\n                throw new RuntimeException(\"List size (\" + l.size() + \") != \" + size + \" for type \" + getName());\n            byte[][] elems = new byte[size][];\n            for (int i = 0; i < l.size(); i++) {\n                elems[i] = elementType.encode(l.get(i));\n            }\n            return ByteUtil.merge(elems);\n        }\n\n        @Override\n        public Object[] decode(byte[] encoded, int offset) {\n            Object[] result = new Object[size];\n            for (int i = 0; i < size; i++) {\n                result[i] = elementType.decode(encoded, offset + i * elementType.getFixedSize());\n            }\n\n            return result;\n        }\n\n        @Override\n        public int getFixedSize() {\n            // return negative if elementType is dynamic\n            return elementType.getFixedSize() * size;\n        }\n    }\n\n    public static class DynamicArrayType extends ArrayType {\n        public DynamicArrayType(String name) {\n            super(name);\n        }\n\n        @Override\n        public String getCanonicalName() {\n            return elementType.getCanonicalName() + \"[]\";\n        }\n\n        @Override\n        public byte[] encodeList(List l) {\n            byte[][] elems;\n            if (elementType.isDynamicType()) {\n                elems = new byte[l.size() * 2 + 1][];\n                elems[0] = IntType.encodeInt(l.size());\n                int offset = l.size() * 32;\n                for (int i = 0; i < l.size(); i++) {\n                    elems[i + 1] = IntType.encodeInt(offset);\n                    byte[] encoded = elementType.encode(l.get(i));\n                    elems[l.size() + i + 1] = encoded;\n                    offset += 32 * ((encoded.length - 1) / 32 + 1);\n                }\n            } else {\n                elems = new byte[l.size() + 1][];\n                elems[0] = IntType.encodeInt(l.size());\n\n                for (int i = 0; i < l.size(); i++) {\n                    elems[i + 1] = elementType.encode(l.get(i));\n                }\n            }\n            return ByteUtil.merge(elems);\n        }\n\n        @Override\n        public Object decode(byte[] encoded, int origOffset) {\n            int len = IntType.decodeInt(encoded, origOffset).intValue();\n            origOffset += 32;\n            int offset = origOffset;\n            Object[] ret = new Object[len];\n\n            for (int i = 0; i < len; i++) {\n                if (elementType.isDynamicType()) {\n                    ret[i] = elementType.decode(encoded, origOffset + IntType.decodeInt(encoded, offset).intValue());\n                } else {\n                    ret[i] = elementType.decode(encoded, offset);\n                }\n                offset += elementType.getFixedSize();\n            }\n            return ret;\n        }\n\n        @Override\n        public boolean isDynamicType() {\n            return true;\n        }\n    }\n\n    public static class BytesType extends SolidityType {\n        protected BytesType(String name) {\n            super(name);\n        }\n\n        public BytesType() {\n            super(\"bytes\");\n        }\n\n        @Override\n        public byte[] encode(Object value) {\n            byte[] bb;\n            if (value instanceof byte[]) {\n                bb = (byte[]) value;\n            } else if (value instanceof String) {\n                bb = ((String) value).getBytes();\n            } else {\n                throw new RuntimeException(\"byte[] or String value is expected for type 'bytes'\");\n            }\n            byte[] ret = new byte[((bb.length - 1) / 32 + 1) * 32]; // padding 32 bytes\n            System.arraycopy(bb, 0, ret, 0, bb.length);\n\n            return ByteUtil.merge(IntType.encodeInt(bb.length), ret);\n        }\n\n        @Override\n        public Object decode(byte[] encoded, int offset) {\n            int len = IntType.decodeInt(encoded, offset).intValue();\n            if (len == 0) return new byte[0];\n            offset += 32;\n            return Arrays.copyOfRange(encoded, offset, offset + len);\n        }\n\n        @Override\n        public boolean isDynamicType() {\n            return true;\n        }\n    }\n\n    public static class StringType extends BytesType {\n        public StringType() {\n            super(\"string\");\n        }\n\n        @Override\n        public byte[] encode(Object value) {\n            if (!(value instanceof String))\n                throw new RuntimeException(\"String value expected for type 'string'\");\n//            return super.encode(((String) value).getSignBytes(StandardCharsets.UTF_8));\n            try {\n                return super.encode(((String) value).getBytes(\"UTF-8\"));\n            } catch (UnsupportedEncodingException e) {\n                throw new RuntimeException(e);\n            }\n        }\n\n        @Override\n        public Object decode(byte[] encoded, int offset) {\n            try {\n                return new String((byte[]) super.decode(encoded, offset), \"UTF-8\");\n            } catch (UnsupportedEncodingException e) {\n                throw new RuntimeException(e);\n            }\n        }\n    }\n\n    public static class Bytes32Type extends SolidityType {\n        public Bytes32Type(String s) {\n            super(s);\n        }\n\n        @Override\n        public byte[] encode(Object value) {\n            if (value instanceof Number) {\n                BigInteger bigInt = new BigInteger(value.toString());\n                return IntType.encodeInt(bigInt);\n            } else if (value instanceof String) {\n                byte[] ret = new byte[32];\n                byte[] bytes = new byte[0];\n                try {\n                    bytes = ((String) value).getBytes(\"UTF-8\");\n                } catch (UnsupportedEncodingException e) {\n                    throw new RuntimeException(e);\n                }\n                System.arraycopy(bytes, 0, ret, 0, bytes.length);\n                return ret;\n            } else if (value instanceof byte[]) {\n                byte[] bytes = (byte[]) value;\n                byte[] ret = new byte[32];\n                System.arraycopy(bytes, 0, ret, 32 - bytes.length, bytes.length);\n                return ret;\n            }\n\n            throw new RuntimeException(\"Can't encode java type \" + value.getClass() + \" to bytes32\");\n        }\n\n        @Override\n        public Object decode(byte[] encoded, int offset) {\n            return Arrays.copyOfRange(encoded, offset, offset + getFixedSize());\n        }\n    }\n\n    public static class AddressType extends IntType {\n        public AddressType() {\n            super(\"address\");\n        }\n\n        @Override\n        public byte[] encode(Object value) {\n            if (value instanceof String && !((String) value).startsWith(\"0x\")) {\n                // address is supposed to be always in hex\n                value = \"0x\" + value;\n            }\n            byte[] addr = super.encode(value);\n            for (int i = 0; i < 12; i++) {\n                if (addr[i] != 0) {\n                    throw new RuntimeException(\"Invalid address (should be 20 bytes length): \" + Hex.toHexString(addr));\n                }\n            }\n            return addr;\n        }\n\n        @Override\n        public Object decode(byte[] encoded, int offset) {\n            BigInteger bi = (BigInteger) super.decode(encoded, offset);\n            return ByteUtil.bigIntegerToBytes(bi, 20);\n        }\n    }\n\n    public static class IntType extends SolidityType {\n        public IntType(String name) {\n            super(name);\n        }\n\n        @Override\n        public String getCanonicalName() {\n            if (getName().equals(\"int\")) return \"int256\";\n            if (getName().equals(\"uint\")) return \"uint256\";\n            return super.getCanonicalName();\n        }\n\n        @Override\n        public byte[] encode(Object value) {\n            BigInteger bigInt;\n\n            if (value instanceof String) {\n                String s = ((String) value).toLowerCase().trim();\n                int radix = 10;\n                if (s.startsWith(\"0x\")) {\n                    s = s.substring(2);\n                    radix = 16;\n                } else if (s.contains(\"a\") || s.contains(\"b\") || s.contains(\"c\") ||\n                        s.contains(\"d\") || s.contains(\"e\") || s.contains(\"f\")) {\n                    radix = 16;\n                }\n                bigInt = new BigInteger(s, radix);\n            } else if (value instanceof BigInteger) {\n                bigInt = (BigInteger) value;\n            } else if (value instanceof Number) {\n                bigInt = new BigInteger(value.toString());\n            } else if (value instanceof byte[]) {\n                bigInt = ByteUtil.bytesToBigInteger((byte[]) value);\n            } else {\n                throw new RuntimeException(\"Invalid value for type '\" + this + \"': \" + value + \" (\" + value.getClass() + \")\");\n            }\n            return encodeInt(bigInt);\n        }\n\n        @Override\n        public Object decode(byte[] encoded, int offset) {\n            return decodeInt(encoded, offset);\n        }\n\n        public static BigInteger decodeInt(byte[] encoded, int offset) {\n            return new BigInteger(Arrays.copyOfRange(encoded, offset, offset + 32));\n        }\n\n        public static byte[] encodeInt(int i) {\n            return encodeInt(new BigInteger(\"\" + i));\n        }\n\n        public static byte[] encodeInt(BigInteger bigInt) {\n            return ByteUtil.bigIntegerToBytesSigned(bigInt, 32);\n        }\n    }\n\n    public static class BoolType extends IntType {\n        public BoolType() {\n            super(\"bool\");\n        }\n\n        @Override\n        public byte[] encode(Object value) {\n            if (!(value instanceof Boolean))\n                throw new RuntimeException(\"Wrong value for bool type: \" + value);\n            return super.encode(value == Boolean.TRUE ? 1 : 0);\n        }\n\n        @Override\n        public Object decode(byte[] encoded, int offset) {\n            return Boolean.valueOf(((Number) super.decode(encoded, offset)).intValue() != 0);\n        }\n    }\n\n    public static class FunctionType extends Bytes32Type {\n        public FunctionType() {\n            super(\"function\");\n        }\n\n        @Override\n        public byte[] encode(Object value) {\n            if (!(value instanceof byte[]))\n                throw new RuntimeException(\"Expected byte[] value for FunctionType\");\n            if (((byte[]) value).length != 24)\n                throw new RuntimeException(\"Expected byte[24] for FunctionType\");\n            return super.encode(ByteUtil.merge((byte[]) value, new byte[8]));\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/utils/ByteUtil.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.utils;\n\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\n\nimport java.math.BigInteger;\n\nimport java.net.InetAddress;\nimport java.net.UnknownHostException;\nimport java.nio.ByteBuffer;\n\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java.util.Set;\n\npublic class ByteUtil {\n\n    public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];\n    public static final byte[] ZERO_BYTE_ARRAY = new byte[]{0};\n\n    /**\n     * Creates a copy of bytes and appends b to the end of it\n     */\n    public static byte[] appendByte(byte[] bytes, byte b) {\n        byte[] result = Arrays.copyOf(bytes, bytes.length + 1);\n        result[result.length - 1] = b;\n        return result;\n    }\n\n    /**\n     * The regular {@link BigInteger#toByteArray()} method isn't quite what we often need:\n     * it appends a leading zero to indicate that the number is positive and may need padding.\n     *\n     * @param b the integer to format into a byte array\n     * @param numBytes the desired size of the resulting byte array\n     * @return numBytes byte long array.\n     */\n    public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) {\n        if (b == null)\n            return null;\n        byte[] bytes = new byte[numBytes];\n        byte[] biBytes = b.toByteArray();\n        int start = (biBytes.length == numBytes + 1) ? 1 : 0;\n        int length = Math.min(biBytes.length, numBytes);\n        System.arraycopy(biBytes, start, bytes, numBytes - length, length);\n        return bytes;\n    }\n\n    public static byte[] bigIntegerToBytesSigned(BigInteger b, int numBytes) {\n        if (b == null)\n            return null;\n        byte[] bytes = new byte[numBytes];\n        Arrays.fill(bytes, b.signum() < 0 ? (byte) 0xFF : 0x00);\n        byte[] biBytes = b.toByteArray();\n        int start = (biBytes.length == numBytes + 1) ? 1 : 0;\n        int length = Math.min(biBytes.length, numBytes);\n        System.arraycopy(biBytes, start, bytes, numBytes - length, length);\n        return bytes;\n    }\n\n    /**\n     * Omitting sign indication byte.\n     * <br><br>\n     * Instead of {@link org.spongycastle.util.BigIntegers#asUnsignedByteArray(BigInteger)}\n     * <br>we use this custom method to avoid an empty array in case of BigInteger.ZERO\n     *\n     * @param value - any big integer number. A <code>null</code>-value will return <code>null</code>\n     * @return A byte array without a leading zero byte if present in the signed encoding.\n     *      BigInteger.ZERO will return an array with length 1 and byte-value 0.\n     */\n    public static byte[] bigIntegerToBytes(BigInteger value) {\n        if (value == null)\n            return null;\n\n        byte[] data = value.toByteArray();\n\n        if (data.length != 1 && data[0] == 0) {\n            byte[] tmp = new byte[data.length - 1];\n            System.arraycopy(data, 1, tmp, 0, tmp.length);\n            data = tmp;\n        }\n        return data;\n    }\n\n    /**\n     * Cast hex encoded value from byte[] to BigInteger\n     * null is parsed like byte[0]\n     *\n     * @param bb byte array contains the values\n     * @return unsigned positive BigInteger value.\n     */\n    public static BigInteger bytesToBigInteger(byte[] bb) {\n        return (bb == null || bb.length == 0) ? BigInteger.ZERO : new BigInteger(1, bb);\n    }\n\n    /**\n     * Returns the amount of nibbles that match each other from 0 ...\n     * amount will never be larger than smallest input\n     *\n     * @param a - first input\n     * @param b - second input\n     * @return Number of bytes that match\n     */\n    public static int matchingNibbleLength(byte[] a, byte[] b) {\n        int i = 0;\n        int length = a.length < b.length ? a.length : b.length;\n        while (i < length) {\n            if (a[i] != b[i])\n                return i;\n            i++;\n        }\n        return i;\n    }\n\n    /**\n     * Converts a long value into a byte array.\n     *\n     * @param val - long value to convert\n     * @return <code>byte[]</code> of length 8, representing the long value\n     */\n    public static byte[] longToBytes(long val) {\n        return ByteBuffer.allocate(Long.BYTES).putLong(val).array();\n    }\n\n    /**\n     * Converts a long value into a byte array.\n     *\n     * @param val - long value to convert\n     * @return decimal value with leading byte that are zeroes striped\n     */\n    public static byte[] longToBytesNoLeadZeroes(long val) {\n\n        // todo: improve performance by while strip numbers until (long >> 8 == 0)\n        if (val == 0) return EMPTY_BYTE_ARRAY;\n\n        byte[] data = ByteBuffer.allocate(Long.BYTES).putLong(val).array();\n\n        return stripLeadingZeroes(data);\n    }\n\n    /**\n     * Converts int value into a byte array.\n     *\n     * @param val - int value to convert\n     * @return <code>byte[]</code> of length 4, representing the int value\n     */\n    public static byte[] intToBytes(int val){\n        return ByteBuffer.allocate(Integer.BYTES).putInt(val).array();\n    }\n\n    /**\n     * Converts a int value into a byte array.\n     *\n     * @param val - int value to convert\n     * @return value with leading byte that are zeroes striped\n     */\n    public static byte[] intToBytesNoLeadZeroes(int val){\n\n        if (val == 0) return EMPTY_BYTE_ARRAY;\n\n        int lenght = 0;\n\n        int tmpVal = val;\n        while (tmpVal != 0){\n            tmpVal = tmpVal >>> 8;\n            ++lenght;\n        }\n\n        byte[] result = new byte[lenght];\n\n        int index = result.length - 1;\n        while(val != 0){\n\n            result[index] = (byte)(val & 0xFF);\n            val = val >>> 8;\n            index -= 1;\n        }\n\n        return result;\n    }\n\n\n    /**\n     * Convert a byte-array into a hex String.<br>\n     * Works similar to {@link Hex#toHexString}\n     * but allows for <code>null</code>\n     *\n     * @param data - byte-array to convert to a hex-string\n     * @return hex representation of the data.<br>\n     *      Returns an empty String if the input is <code>null</code>\n     *\n     * @see Hex#toHexString\n     */\n    public static String toHexString(byte[] data) {\n        return data == null ? \"\" : Hex.toHexString(data);\n    }\n\n    /**\n     * Calculate packet length\n     *\n     * @param msg byte[]\n     * @return byte-array with 4 elements\n     */\n    public static byte[] calcPacketLength(byte[] msg) {\n        int msgLen = msg.length;\n        return new byte[]{\n                (byte) ((msgLen >> 24) & 0xFF),\n                (byte) ((msgLen >> 16) & 0xFF),\n                (byte) ((msgLen >> 8) & 0xFF),\n                (byte) ((msgLen) & 0xFF)};\n    }\n\n    /**\n     * Cast hex encoded value from byte[] to int\n     * null is parsed like byte[0]\n     *\n     * Limited to Integer.MAX_VALUE: 2^32-1 (4 bytes)\n     *\n     * @param b array contains the values\n     * @return unsigned positive int value.\n     */\n    public static int byteArrayToInt(byte[] b) {\n        if (b == null || b.length == 0)\n            return 0;\n        return new BigInteger(1, b).intValue();\n    }\n\n    /**\n     * Cast hex encoded value from byte[] to long\n     * null is parsed like byte[0]\n     *\n     * Limited to Long.MAX_VALUE: 2<sup>63</sup>-1 (8 bytes)\n     *\n     * @param b array contains the values\n     * @return unsigned positive long value.\n     */\n    public static long byteArrayToLong(byte[] b) {\n        if (b == null || b.length == 0)\n            return 0;\n        return new BigInteger(1, b).longValue();\n    }\n\n\n    /**\n     * Turn nibbles to a pretty looking output string\n     *\n     * Example. [ 1, 2, 3, 4, 5 ] becomes '\\x11\\x23\\x45'\n     *\n     * @param nibbles - getting byte of data [ 04 ] and turning\n     *                  it to a '\\x04' representation\n     * @return pretty string of nibbles\n     */\n    public static String nibblesToPrettyString(byte[] nibbles) {\n        StringBuilder builder = new StringBuilder();\n        for (byte nibble : nibbles) {\n            final String nibbleString = oneByteToHexString(nibble);\n            builder.append(\"\\\\x\").append(nibbleString);\n        }\n        return builder.toString();\n    }\n\n    public static String oneByteToHexString(byte value) {\n        String retVal = Integer.toString(value & 0xFF, 16);\n        if (retVal.length() == 1) retVal = \"0\" + retVal;\n        return retVal;\n    }\n\n    /**\n     * Calculate the number of bytes need\n     * to encode the number\n     *\n     * @param val - number\n     * @return number of min bytes used to encode the number\n     */\n    public static int numBytes(String val) {\n\n        BigInteger bInt = new BigInteger(val);\n        int bytes = 0;\n\n        while (!bInt.equals(BigInteger.ZERO)) {\n            bInt = bInt.shiftRight(8);\n            ++bytes;\n        }\n        if (bytes == 0) ++bytes;\n        return bytes;\n    }\n\n    /**\n     * @param arg - not more that 32 bits\n     * @return - bytes of the value pad with complete to 32 zeroes\n     */\n    public static byte[] encodeValFor32Bits(Object arg) {\n\n        byte[] data;\n\n        // check if the string is numeric\n        if (arg.toString().trim().matches(\"-?\\\\d+(\\\\.\\\\d+)?\"))\n            data = new BigInteger(arg.toString().trim()).toByteArray();\n            // check if it's hex number\n        else if (arg.toString().trim().matches(\"0[xX][0-9a-fA-F]+\"))\n            data = new BigInteger(arg.toString().trim().substring(2), 16).toByteArray();\n        else\n            data = arg.toString().trim().getBytes();\n\n\n        if (data.length > 32)\n            throw new RuntimeException(\"values can't be more than 32 byte\");\n\n        byte[] val = new byte[32];\n\n        int j = 0;\n        for (int i = data.length; i > 0; --i) {\n            val[31 - j] = data[i - 1];\n            ++j;\n        }\n        return val;\n    }\n\n    /**\n     * encode the values and concatenate together\n     *\n     * @param args Object\n     * @return byte[]\n     */\n    public static byte[] encodeDataList(Object... args) {\n        ByteArrayOutputStream baos = new ByteArrayOutputStream();\n        for (Object arg : args) {\n            byte[] val = encodeValFor32Bits(arg);\n            try {\n                baos.write(val);\n            } catch (IOException e) {\n                throw new Error(\"Happen something that should never happen \", e);\n            }\n        }\n        return baos.toByteArray();\n    }\n\n    public static int firstNonZeroByte(byte[] data) {\n        for (int i = 0; i < data.length; ++i) {\n            if (data[i] != 0) {\n                return i;\n            }\n        }\n        return -1;\n    }\n\n    public static byte[] stripLeadingZeroes(byte[] data) {\n\n        if (data == null)\n            return null;\n\n        final int firstNonZero = firstNonZeroByte(data);\n        switch (firstNonZero) {\n            case -1:\n                return ZERO_BYTE_ARRAY;\n\n            case 0:\n                return data;\n\n            default:\n                byte[] result = new byte[data.length - firstNonZero];\n                System.arraycopy(data, firstNonZero, result, 0, data.length - firstNonZero);\n\n                return result;\n        }\n    }\n\n    /**\n     * increment byte array as a number until max is reached\n     *\n     * @param bytes byte[]\n     * @return boolean\n     */\n    public static boolean increment(byte[] bytes) {\n        final int startIndex = 0;\n        int i;\n        for (i = bytes.length - 1; i >= startIndex; i--) {\n            bytes[i]++;\n            if (bytes[i] != 0)\n                break;\n        }\n        // we return false when all bytes are 0 again\n        return (i >= startIndex || bytes[startIndex] != 0);\n    }\n\n    /**\n     * Utility function to copy a byte array into a new byte array with given size.\n     * If the src length is smaller than the given size, the result will be left-padded\n     * with zeros.\n     *\n     * @param value - a BigInteger with a maximum value of 2^256-1\n     * @return Byte array of given size with a copy of the <code>src</code>\n     */\n    public static byte[] copyToArray(BigInteger value) {\n        byte[] src = ByteUtil.bigIntegerToBytes(value);\n        byte[] dest = ByteBuffer.allocate(32).array();\n        System.arraycopy(src, 0, dest, dest.length - src.length, src.length);\n        return dest;\n    }\n\n\n//    public static ByteArrayWrapper wrap(byte[] data) {\n//        return new ByteArrayWrapper(data);\n//    }\n\n    public static byte[] setBit(byte[] data, int pos, int val) {\n\n        if ((data.length * 8) - 1 < pos)\n            throw new Error(\"outside byte array limit, pos: \" + pos);\n\n        int posByte = data.length - 1 - (pos) / 8;\n        int posBit = (pos) % 8;\n        byte setter = (byte) (1 << (posBit));\n        byte toBeSet = data[posByte];\n        byte result;\n        if (val == 1)\n            result = (byte) (toBeSet | setter);\n        else\n            result = (byte) (toBeSet & ~setter);\n\n        data[posByte] = result;\n        return data;\n    }\n\n    public static int getBit(byte[] data, int pos) {\n\n        if ((data.length * 8) - 1 < pos)\n            throw new Error(\"outside byte array limit, pos: \" + pos);\n\n        int posByte = data.length - 1 - pos / 8;\n        int posBit = pos % 8;\n        byte dataByte = data[posByte];\n        return Math.min(1, (dataByte & (1 << (posBit))));\n    }\n\n    public static byte[] and(byte[] b1, byte[] b2) {\n        if (b1.length != b2.length) throw new RuntimeException(\"Array sizes differ\");\n        byte[] ret = new byte[b1.length];\n        for (int i = 0; i < ret.length; i++) {\n            ret[i] = (byte) (b1[i] & b2[i]);\n        }\n        return ret;\n    }\n\n    public static byte[] or(byte[] b1, byte[] b2) {\n        if (b1.length != b2.length) throw new RuntimeException(\"Array sizes differ\");\n        byte[] ret = new byte[b1.length];\n        for (int i = 0; i < ret.length; i++) {\n            ret[i] = (byte) (b1[i] | b2[i]);\n        }\n        return ret;\n    }\n\n    public static byte[] xor(byte[] b1, byte[] b2) {\n        if (b1.length != b2.length) throw new RuntimeException(\"Array sizes differ\");\n        byte[] ret = new byte[b1.length];\n        for (int i = 0; i < ret.length; i++) {\n            ret[i] = (byte) (b1[i] ^ b2[i]);\n        }\n        return ret;\n    }\n\n    /**\n     * XORs byte arrays of different lengths by aligning length of the shortest via adding zeros at beginning\n     */\n    public static byte[] xorAlignRight(byte[] b1, byte[] b2) {\n        if (b1.length > b2.length) {\n            byte[] b2_ = new byte[b1.length];\n            System.arraycopy(b2, 0, b2_, b1.length - b2.length, b2.length);\n            b2 = b2_;\n        } else if (b2.length > b1.length) {\n            byte[] b1_ = new byte[b2.length];\n            System.arraycopy(b1, 0, b1_, b2.length - b1.length, b1.length);\n            b1 = b1_;\n        }\n\n        return xor(b1, b2);\n    }\n\n    /**\n     * @param arrays - arrays to merge\n     * @return - merged array\n     */\n    public static byte[] merge(byte[]... arrays)\n    {\n        int arrCount = 0;\n        int count = 0;\n        for (byte[] array: arrays)\n        {\n            arrCount++;\n            count += array.length;\n        }\n\n        // Create new array and copy all array contents\n        byte[] mergedArray = new byte[count];\n        int start = 0;\n        for (byte[] array: arrays) {\n            System.arraycopy(array, 0, mergedArray, start, array.length);\n            start += array.length;\n        }\n        return mergedArray;\n    }\n\n    public static boolean isNullOrZeroArray(byte[] array){\n        return (array == null) || (array.length == 0);\n    }\n\n    public static boolean isSingleZero(byte[] array){\n        return (array.length == 1 && array[0] == 0);\n    }\n\n\n    public static Set<byte[]> difference(Set<byte[]> setA, Set<byte[]> setB){\n\n        Set<byte[]> result = new HashSet<>();\n\n        for (byte[] elementA : setA){\n            boolean found = false;\n            for (byte[] elementB : setB){\n\n                if (Arrays.equals(elementA, elementB)){\n                    found = true;\n                    break;\n                }\n            }\n            if (!found) result.add(elementA);\n        }\n\n        return result;\n    }\n\n    public static int length(byte[]... bytes) {\n        int result = 0;\n        for (byte[] array : bytes) {\n            result += (array == null) ? 0 : array.length;\n        }\n        return result;\n    }\n\n    public static byte[] intsToBytes(int[] arr, boolean bigEndian) {\n        byte[] ret = new byte[arr.length * 4];\n        intsToBytes(arr, ret, bigEndian);\n        return ret;\n    }\n\n    public static int[] bytesToInts(byte[] arr, boolean bigEndian) {\n        int[] ret = new int[arr.length / 4];\n        bytesToInts(arr, ret, bigEndian);\n        return ret;\n    }\n\n    public static void bytesToInts(byte[] b, int[] arr, boolean bigEndian) {\n        if (!bigEndian) {\n            int off = 0;\n            for (int i = 0; i < arr.length; i++) {\n                int ii = b[off++] & 0x000000FF;\n                ii |= (b[off++] << 8) & 0x0000FF00;\n                ii |= (b[off++] << 16) & 0x00FF0000;\n                ii |= (b[off++] << 24);\n                arr[i] = ii;\n            }\n        } else {\n            int off = 0;\n            for (int i = 0; i < arr.length; i++) {\n                int ii = b[off++] << 24;\n                ii |= (b[off++] << 16) & 0x00FF0000;\n                ii |= (b[off++] << 8) & 0x0000FF00;\n                ii |= b[off++] & 0x000000FF;\n                arr[i] = ii;\n            }\n        }\n    }\n\n    public static void intsToBytes(int[] arr, byte[] b, boolean bigEndian) {\n        if (!bigEndian) {\n            int off = 0;\n            for (int i = 0; i < arr.length; i++) {\n                int ii = arr[i];\n                b[off++] = (byte) (ii & 0xFF);\n                b[off++] = (byte) ((ii >> 8) & 0xFF);\n                b[off++] = (byte) ((ii >> 16) & 0xFF);\n                b[off++] = (byte) ((ii >> 24) & 0xFF);\n            }\n        } else {\n            int off = 0;\n            for (int i = 0; i < arr.length; i++) {\n                int ii = arr[i];\n                b[off++] = (byte) ((ii >> 24) & 0xFF);\n                b[off++] = (byte) ((ii >> 16) & 0xFF);\n                b[off++] = (byte) ((ii >> 8) & 0xFF);\n                b[off++] = (byte) (ii & 0xFF);\n            }\n        }\n    }\n\n    public static short bigEndianToShort(byte[] bs) {\n        return bigEndianToShort(bs, 0);\n    }\n\n    public static short bigEndianToShort(byte[] bs, int off) {\n        int n = bs[off] << 8;\n        ++off;\n        n |= bs[off] & 0xFF;\n        return (short) n;\n    }\n\n    public static byte[] shortToBytes(short n) {\n        return ByteBuffer.allocate(2).putShort(n).array();\n    }\n\n    /**\n     * Converts string hex representation to data bytes\n     * Accepts following hex:\n     *  - with or without 0x prefix\n     *  - with no leading 0, like 0xabc -> 0x0abc\n     * @param data  String like '0xa5e..' or just 'a5e..'\n     * @return  decoded bytes array\n     */\n    public static byte[] hexStringToBytes(String data) {\n        if (data == null) return EMPTY_BYTE_ARRAY;\n        if (data.startsWith(\"0x\")) data = data.substring(2);\n        if (data.length() % 2 == 1) data = \"0\" + data;\n        return Hex.decode(data);\n    }\n\n    /**\n     * Converts string representation of host/ip to 4-bytes byte[] IPv4\n     */\n    public static byte[] hostToBytes(String ip) {\n        byte[] bytesIp;\n        try {\n            bytesIp = InetAddress.getByName(ip).getAddress();\n        } catch (UnknownHostException e) {\n            bytesIp = new byte[4];  // fall back to invalid 0.0.0.0 address\n        }\n\n        return bytesIp;\n    }\n\n    /**\n     * Converts 4 bytes IPv4 IP to String representation\n     */\n    public static String bytesToIp(byte[] bytesIp) {\n\n        StringBuilder sb = new StringBuilder();\n        sb.append(bytesIp[0] & 0xFF);\n        sb.append(\".\");\n        sb.append(bytesIp[1] & 0xFF);\n        sb.append(\".\");\n        sb.append(bytesIp[2] & 0xFF);\n        sb.append(\".\");\n        sb.append(bytesIp[3] & 0xFF);\n\n        String ip = sb.toString();\n        return ip;\n    }\n\n    /**\n     * Returns a number of zero bits preceding the highest-order (\"leftmost\") one-bit\n     * interpreting input array as a big-endian integer value\n     */\n    public static int numberOfLeadingZeros(byte[] bytes) {\n\n        int i = firstNonZeroByte(bytes);\n\n        if (i == -1) {\n            return bytes.length * 8;\n        } else {\n            int byteLeadingZeros = Integer.numberOfLeadingZeros((int)bytes[i] & 0xff) - 24;\n            return i * 8 + byteLeadingZeros;\n        }\n    }\n\n    /**\n     * Parses fixed number of bytes starting from {@code offset} in {@code input} array.\n     * If {@code input} has not enough bytes return array will be right padded with zero bytes.\n     * I.e. if {@code offset} is higher than {@code input.length} then zero byte array of length {@code len} will be returned\n     */\n    public static byte[] parseBytes(byte[] input, int offset, int len) {\n\n        if (offset >= input.length || len == 0)\n            return EMPTY_BYTE_ARRAY;\n\n        byte[] bytes = new byte[len];\n        System.arraycopy(input, offset, bytes, 0, Math.min(input.length - offset, len));\n        return bytes;\n    }\n\n    /**\n     * Parses 32-bytes word from given input.\n     * Uses {@link #parseBytes(byte[], int, int)} method,\n     * thus, result will be right-padded with zero bytes if there is not enough bytes in {@code input}\n     *\n     * @param idx an index of the word starting from {@code 0}\n     */\n    public static byte[] parseWord(byte[] input, int idx) {\n        return parseBytes(input, 32 * idx, 32);\n    }\n\n    /**\n     * Parses 32-bytes word from given input.\n     * Uses {@link #parseBytes(byte[], int, int)} method,\n     * thus, result will be right-padded with zero bytes if there is not enough bytes in {@code input}\n     *\n     * @param idx an index of the word starting from {@code 0}\n     * @param offset an offset in {@code input} array to start parsing from\n     */\n    public static byte[] parseWord(byte[] input, int offset, int idx) {\n        return parseBytes(input, offset + 32 * idx, 32);\n    }\n}"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/utils/FastByteComparisons.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\n/**\n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements.  See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership.  The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.  You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.quincysx.crypto.ethereum.utils;\n\n\n\n/**\n * Utility code to do optimized byte-array comparison.\n * This is borrowed and slightly modified from Guava's\n * class to be able to compare arrays that start at non-zero offsets.\n */\n@SuppressWarnings(\"restriction\")\npublic abstract class FastByteComparisons {\n\n    public static boolean equal(byte[] b1, byte[] b2) {\n        return b1.length == b2.length && compareTo(b1, 0, b1.length, b2, 0, b2.length) == 0;\n    }\n    /**\n     * Lexicographically compare two byte arrays.\n     *\n     * @param b1 buffer1\n     * @param s1 offset1\n     * @param l1 length1\n     * @param b2 buffer2\n     * @param s2 offset2\n     * @param l2 length2\n     * @return int\n     */\n    public static int compareTo(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {\n        return LexicographicalComparerHolder.BEST_COMPARER.compareTo(\n                b1, s1, l1, b2, s2, l2);\n    }\n\n    private interface Comparer<T> {\n        int compareTo(T buffer1, int offset1, int length1,\n                      T buffer2, int offset2, int length2);\n    }\n\n    private static Comparer<byte[]> lexicographicalComparerJavaImpl() {\n        return LexicographicalComparerHolder.PureJavaComparer.INSTANCE;\n    }\n\n\n    /**\n     *\n     * <p>Uses reflection to gracefully fall back to the Java implementation if\n     * {@code Unsafe} isn't available.\n     */\n    private static class LexicographicalComparerHolder {\n        static final String UNSAFE_COMPARER_NAME =\n                LexicographicalComparerHolder.class.getName() + \"$UnsafeComparer\";\n\n        static final Comparer<byte[]> BEST_COMPARER = getBestComparer();\n\n        /**\n         * Returns the Unsafe-using Comparer, or falls back to the pure-Java\n         * implementation if unable to do so.\n         */\n        static Comparer<byte[]> getBestComparer() {\n            try {\n                Class<?> theClass = Class.forName(UNSAFE_COMPARER_NAME);\n\n                // yes, UnsafeComparer does implement Comparer<byte[]>\n                @SuppressWarnings(\"unchecked\")\n                Comparer<byte[]> comparer =\n                        (Comparer<byte[]>) theClass.getEnumConstants()[0];\n                return comparer;\n            } catch (Throwable t) { // ensure we really catch *everything*\n                return lexicographicalComparerJavaImpl();\n            }\n        }\n\n        private enum PureJavaComparer implements Comparer<byte[]> {\n            INSTANCE;\n\n            @Override\n            public int compareTo(byte[] buffer1, int offset1, int length1,\n                                 byte[] buffer2, int offset2, int length2) {\n                // Short circuit equal case\n                if (buffer1 == buffer2 &&\n                        offset1 == offset2 &&\n                        length1 == length2) {\n                    return 0;\n                }\n                int end1 = offset1 + length1;\n                int end2 = offset2 + length2;\n                for (int i = offset1, j = offset2; i < end1 && j < end2; i++, j++) {\n                    int a = (buffer1[i] & 0xff);\n                    int b = (buffer2[j] & 0xff);\n                    if (a != b) {\n                        return a - b;\n                    }\n                }\n                return length1 - length2;\n            }\n        }\n\n\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/vm/DataWord.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.vm;\n\nimport com.fasterxml.jackson.annotation.JsonCreator;\nimport com.fasterxml.jackson.annotation.JsonValue;\nimport com.quincysx.crypto.ethereum.ByteArrayWrapper;\nimport com.quincysx.crypto.ethereum.utils.ByteUtil;\nimport com.quincysx.crypto.ethereum.utils.FastByteComparisons;\n\nimport org.spongycastle.util.Arrays;\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.math.BigInteger;\nimport java.nio.ByteBuffer;\n\n/**\n * DataWord is the 32-byte array representation of a 256-bit number\n * Calculations can be done on this word with other DataWords\n *\n * @author Roman Mandeleil\n * @since 01.06.2014\n */\npublic class DataWord implements Comparable<DataWord> {\n\n    /* Maximum value of the DataWord */\n    public static final BigInteger _2_256 = BigInteger.valueOf(2).pow(256);\n    public static final BigInteger MAX_VALUE = _2_256.subtract(BigInteger.ONE);\n    public static final DataWord ZERO = new DataWord(new byte[32]);      // don't push it in to the stack\n    public static final DataWord ZERO_EMPTY_ARRAY = new DataWord(new byte[0]);      // don't push it in to the stack\n\n    private byte[] data = new byte[32];\n\n    public DataWord() {\n    }\n\n    public DataWord(int num) {\n        this(ByteBuffer.allocate(4).putInt(num));\n    }\n\n    public DataWord(long num) {\n        this(ByteBuffer.allocate(8).putLong(num));\n    }\n\n    private DataWord(ByteBuffer buffer) {\n        final ByteBuffer data = ByteBuffer.allocate(32);\n        final byte[] array = buffer.array();\n        System.arraycopy(array, 0, data.array(), 32 - array.length, array.length);\n        this.data = data.array();\n    }\n\n    @JsonCreator\n    public DataWord(String data) {\n        this(Hex.decode(data));\n    }\n\n    public DataWord(ByteArrayWrapper wrappedData){\n        this(wrappedData.getData());\n    }\n\n    public DataWord(byte[] data) {\n        if (data == null)\n            this.data = ByteUtil.EMPTY_BYTE_ARRAY;\n        else if (data.length == 32)\n            this.data = data;\n        else if (data.length <= 32)\n            System.arraycopy(data, 0, this.data, 32 - data.length, data.length);\n        else\n            throw new RuntimeException(\"Data word can't exceed 32 bytes: \" + data);\n    }\n\n    public byte[] getData() {\n        return data;\n    }\n\n    public byte[] getNoLeadZeroesData() {\n        return ByteUtil.stripLeadingZeroes(data);\n    }\n\n    public byte[] getLast20Bytes() {\n        return Arrays.copyOfRange(data, 12, data.length);\n    }\n\n    public BigInteger value() {\n        return new BigInteger(1, data);\n    }\n\n    /**\n     * Converts this DataWord to an int, checking for lost information.\n     * If this DataWord is out of the possible range for an int result\n     * then an ArithmeticException is thrown.\n     *\n     * @return this DataWord converted to an int.\n     * @throws ArithmeticException - if this will not fit in an int.\n     */\n    public int intValue() {\n        int intVal = 0;\n\n        for (int i = 0; i < data.length; i++)\n        {\n            intVal = (intVal << 8) + (data[i] & 0xff);\n        }\n\n        return intVal;\n    }\n\n    /**\n     * In case of int overflow returns Integer.MAX_VALUE\n     * otherwise works as #intValue()\n     */\n    public int intValueSafe() {\n        int bytesOccupied = bytesOccupied();\n        int intValue = intValue();\n        if (bytesOccupied > 4 || intValue < 0) return Integer.MAX_VALUE;\n        return intValue;\n    }\n\n    /**\n     * Converts this DataWord to a long, checking for lost information.\n     * If this DataWord is out of the possible range for a long result\n     * then an ArithmeticException is thrown.\n     *\n     * @return this DataWord converted to a long.\n     * @throws ArithmeticException - if this will not fit in a long.\n     */\n    public long longValue() {\n\n        long longVal = 0;\n        for (int i = 0; i < data.length; i++)\n        {\n            longVal = (longVal << 8) + (data[i] & 0xff);\n        }\n\n        return longVal;\n    }\n\n    /**\n     * In case of long overflow returns Long.MAX_VALUE\n     * otherwise works as #longValue()\n     */\n    public long longValueSafe() {\n        int bytesOccupied = bytesOccupied();\n        long longValue = longValue();\n        if (bytesOccupied > 8 || longValue < 0) return Long.MAX_VALUE;\n        return longValue;\n    }\n\n    public BigInteger sValue() {\n        return new BigInteger(data);\n    }\n\n    public String  bigIntValue() {\n        return new BigInteger(data).toString();\n    }\n\n    public boolean isZero() {\n        for (byte tmp : data) {\n            if (tmp != 0) return false;\n        }\n        return true;\n    }\n\n    // only in case of signed operation\n    // when the number is explicit defined\n    // as negative\n    public boolean isNegative() {\n        int result = data[0] & 0x80;\n        return result == 0x80;\n    }\n\n    public DataWord and(DataWord w2) {\n\n        for (int i = 0; i < this.data.length; ++i) {\n            this.data[i] &= w2.data[i];\n        }\n        return this;\n    }\n\n    public DataWord or(DataWord w2) {\n\n        for (int i = 0; i < this.data.length; ++i) {\n            this.data[i] |= w2.data[i];\n        }\n        return this;\n    }\n\n    public DataWord xor(DataWord w2) {\n\n        for (int i = 0; i < this.data.length; ++i) {\n            this.data[i] ^= w2.data[i];\n        }\n        return this;\n    }\n\n    public void negate() {\n\n        if (this.isZero()) return;\n\n        for (int i = 0; i < this.data.length; ++i) {\n            this.data[i] = (byte) ~this.data[i];\n        }\n\n        for (int i = this.data.length - 1; i >= 0; --i) {\n            this.data[i] = (byte) (1 + this.data[i] & 0xFF);\n            if (this.data[i] != 0) break;\n        }\n    }\n\n    public void bnot() {\n        if (this.isZero()) {\n            this.data = ByteUtil.copyToArray(MAX_VALUE);\n            return;\n        }\n        this.data = ByteUtil.copyToArray(MAX_VALUE.subtract(this.value()));\n    }\n\n    // By   : Holger\n    // From : http://stackoverflow.com/a/24023466/459349\n    public void add(DataWord word) {\n        byte[] result = new byte[32];\n        for (int i = 31, overflow = 0; i >= 0; i--) {\n            int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow;\n            result[i] = (byte) v;\n            overflow = v >>> 8;\n        }\n        this.data = result;\n    }\n\n    // old add-method with BigInteger quick hack\n    public void add2(DataWord word) {\n        BigInteger result = value().add(word.value());\n        this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));\n    }\n\n    // TODO: mul can be done in more efficient way\n    // TODO:     with shift left shift right trick\n    // TODO      without BigInteger quick hack\n    public void mul(DataWord word) {\n        BigInteger result = value().multiply(word.value());\n        this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));\n    }\n\n    // TODO: improve with no BigInteger\n    public void div(DataWord word) {\n\n        if (word.isZero()) {\n            this.and(ZERO);\n            return;\n        }\n\n        BigInteger result = value().divide(word.value());\n        this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));\n    }\n\n    // TODO: improve with no BigInteger\n    public void sDiv(DataWord word) {\n\n        if (word.isZero()) {\n            this.and(ZERO);\n            return;\n        }\n\n        BigInteger result = sValue().divide(word.sValue());\n        this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));\n    }\n\n    // TODO: improve with no BigInteger\n    public void sub(DataWord word) {\n        BigInteger result = value().subtract(word.value());\n        this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));\n    }\n\n    // TODO: improve with no BigInteger\n    public void exp(DataWord word) {\n        BigInteger result = value().modPow(word.value(), _2_256);\n        this.data = ByteUtil.copyToArray(result);\n    }\n\n    // TODO: improve with no BigInteger\n    public void mod(DataWord word) {\n\n        if (word.isZero()) {\n            this.and(ZERO);\n            return;\n        }\n\n        BigInteger result = value().mod(word.value());\n        this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));\n    }\n\n    public void sMod(DataWord word) {\n\n        if (word.isZero()) {\n            this.and(ZERO);\n            return;\n        }\n\n        BigInteger result = sValue().abs().mod(word.sValue().abs());\n        result = (sValue().signum() == -1) ? result.negate() : result;\n\n        this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));\n    }\n\n    public void addmod(DataWord word1, DataWord word2) {\n        if (word2.isZero()) {\n            this.data = new byte[32];\n            return;\n        }\n\n        BigInteger result = value().add(word1.value()).mod(word2.value());\n        this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));\n    }\n\n    public void mulmod(DataWord word1, DataWord word2) {\n\n        if (this.isZero() || word1.isZero() || word2.isZero()) {\n            this.data = new byte[32];\n            return;\n        }\n\n        BigInteger result = value().multiply(word1.value()).mod(word2.value());\n        this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));\n    }\n\n    @JsonValue\n    @Override\n    public String toString() {\n        return Hex.toHexString(data);\n    }\n\n    public String toPrefixString() {\n\n        byte[] pref = getNoLeadZeroesData();\n        if (pref.length == 0) return \"\";\n\n        if (pref.length < 7)\n            return Hex.toHexString(pref);\n\n        return Hex.toHexString(pref).substring(0, 6);\n    }\n\n    public String shortHex() {\n        String hexValue = Hex.toHexString(getNoLeadZeroesData()).toUpperCase();\n        return \"0x\" + hexValue.replaceFirst(\"^0+(?!$)\", \"\");\n    }\n\n    public DataWord clone() {\n        return new DataWord(Arrays.clone(data));\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n\n        DataWord dataWord = (DataWord) o;\n\n        return java.util.Arrays.equals(data, dataWord.data);\n\n    }\n\n    @Override\n    public int hashCode() {\n        return java.util.Arrays.hashCode(data);\n    }\n\n    @Override\n    public int compareTo(DataWord o) {\n        if (o == null || o.getData() == null) return -1;\n        int result = FastByteComparisons.compareTo(\n                data, 0, data.length,\n                o.getData(), 0, o.getData().length);\n        // Convert result into -1, 0 or 1 as is the convention\n        return (int) Math.signum(result);\n    }\n\n    public void signExtend(byte k) {\n        if (0 > k || k > 31)\n            throw new IndexOutOfBoundsException();\n        byte mask = this.sValue().testBit((k * 8) + 7) ? (byte) 0xff : 0;\n        for (int i = 31; i > k; i--) {\n            this.data[31 - i] = mask;\n        }\n    }\n\n    public int bytesOccupied() {\n        int firstNonZero = ByteUtil.firstNonZeroByte(data);\n        if (firstNonZero == -1) return 0;\n        return 31 - firstNonZero + 1;\n    }\n\n    public boolean isHex(String hex) {\n        return Hex.toHexString(data).equals(hex);\n    }\n\n    public String asString(){\n        return new String(getNoLeadZeroesData());\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/ethereum/vm/LogInfo.java",
    "content": "/*\n * Copyright (c) [2016] [ <ether.camp> ]\n * This file is part of the ethereumJ library.\n *\n * The ethereumJ library is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Lesser General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * The ethereumJ library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.\n */\npackage com.quincysx.crypto.ethereum.vm;\n\nimport com.quincysx.crypto.ethereum.Bloom;\nimport com.quincysx.crypto.ethereum.rlp.RLP;\nimport com.quincysx.crypto.ethereum.rlp.RLPElement;\nimport com.quincysx.crypto.ethereum.rlp.RLPItem;\nimport com.quincysx.crypto.ethereum.rlp.RLPList;\nimport com.quincysx.crypto.utils.KECCAK256;\n\n\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * @author Roman Mandeleil\n * @since 19.11.2014\n */\npublic class LogInfo {\n\n    byte[] address = new byte[]{};\n    List<DataWord> topics = new ArrayList<>();\n    byte[] data = new byte[]{};\n\n    /* Log info in encoded form */\n    private byte[] rlpEncoded;\n\n    public LogInfo(byte[] rlp) {\n\n        RLPList params = RLP.decode2(rlp);\n        RLPList logInfo = (RLPList) params.get(0);\n\n        RLPItem address = (RLPItem) logInfo.get(0);\n        RLPList topics = (RLPList) logInfo.get(1);\n        RLPItem data = (RLPItem) logInfo.get(2);\n\n        this.address = address.getRLPData() != null ? address.getRLPData() : new byte[]{};\n        this.data = data.getRLPData() != null ? data.getRLPData() : new byte[]{};\n\n        for (RLPElement topic1 : topics) {\n            byte[] topic = topic1.getRLPData();\n            this.topics.add(new DataWord(topic));\n        }\n\n        rlpEncoded = rlp;\n    }\n\n    public LogInfo(byte[] address, List<DataWord> topics, byte[] data) {\n        this.address = (address != null) ? address : new byte[]{};\n        this.topics = (topics != null) ? topics : new ArrayList<DataWord>();\n        this.data = (data != null) ? data : new byte[]{};\n    }\n\n    public byte[] getAddress() {\n        return address;\n    }\n\n    public List<DataWord> getTopics() {\n        return topics;\n    }\n\n    public byte[] getData() {\n        return data;\n    }\n\n    /*  [address, [topic, topic ...] data] */\n    public byte[] getEncoded() {\n\n        byte[] addressEncoded = RLP.encodeElement(this.address);\n\n        byte[][] topicsEncoded = null;\n        if (topics != null) {\n            topicsEncoded = new byte[topics.size()][];\n            int i = 0;\n            for (DataWord topic : topics) {\n                byte[] topicData = topic.getData();\n                topicsEncoded[i] = RLP.encodeElement(topicData);\n                ++i;\n            }\n        }\n\n        byte[] dataEncoded = RLP.encodeElement(data);\n        return RLP.encodeList(addressEncoded, RLP.encodeList(topicsEncoded), dataEncoded);\n    }\n\n    public Bloom getBloom() {\n//        Bloom ret = Bloom.create(HashUtil.sha3(address));\n        Bloom ret = Bloom.create(KECCAK256.keccak256(address));\n        for (DataWord topic : topics) {\n            byte[] topicData = topic.getData();\n//            ret.or(Bloom.create(HashUtil.sha3(topicData)));\n            ret.or(Bloom.create(KECCAK256.keccak256(topicData)));\n        }\n        return ret;\n    }\n\n    @Override\n    public String toString() {\n\n        StringBuilder topicsStr = new StringBuilder();\n        topicsStr.append(\"[\");\n\n        for (DataWord topic : topics) {\n            String topicStr = Hex.toHexString(topic.getData());\n            topicsStr.append(topicStr).append(\" \");\n        }\n        topicsStr.append(\"]\");\n\n\n        return \"LogInfo{\" +\n                \"address=\" + Hex.toHexString(address) +\n                \", topics=\" + topicsStr +\n                \", data=\" + Hex.toHexString(data) +\n                '}';\n    }\n\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/exception/CoinNotFindException.java",
    "content": "package com.quincysx.crypto.exception;\n\n/**\n * Created by q7728 on 2018/3/18.\n */\n\npublic class CoinNotFindException extends Exception {\n    public CoinNotFindException(String message) {\n        super(message);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/exception/NonSupportException.java",
    "content": "package com.quincysx.crypto.exception;\n\n/**\n * Created by q7728 on 2018/3/18.\n */\n\npublic class NonSupportException extends Exception {\n    public NonSupportException(String message) {\n        super(message);\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/utils/BTCUtils.java",
    "content": "package com.quincysx.crypto.utils;\n\nimport com.quincysx.crypto.bitcoin.BTCTransaction;\n\nimport org.spongycastle.asn1.ASN1InputStream;\nimport org.spongycastle.asn1.ASN1Integer;\nimport org.spongycastle.asn1.DLSequence;\nimport org.spongycastle.asn1.sec.SECNamedCurves;\nimport org.spongycastle.asn1.x9.X9ECParameters;\nimport org.spongycastle.crypto.digests.SHA256Digest;\nimport org.spongycastle.crypto.params.ECDomainParameters;\nimport org.spongycastle.crypto.params.ECPublicKeyParameters;\nimport org.spongycastle.crypto.signers.ECDSASigner;\nimport org.spongycastle.crypto.signers.HMacDSAKCalculator;\n\nimport java.io.IOException;\nimport java.math.BigInteger;\nimport java.util.Stack;\n\n/**\n * @author QuincySx\n * @date 2018/3/2 下午3:13\n */\npublic class BTCUtils {\n    public static byte[] reverse(byte[] bytes) {\n        byte[] result = new byte[bytes.length];\n        for (int i = 0; i < bytes.length; i++) {\n            result[i] = bytes[bytes.length - i - 1];\n        }\n        return result;\n    }\n\n    public static void verify(BTCTransaction.Script[] scripts, BTCTransaction spendTx) throws BTCTransaction.Script.ScriptInvalidException {\n        for (int i = 0; i < scripts.length; i++) {\n            Stack<byte[]> stack = new Stack<>();\n            spendTx.inputs[i].script.run(stack);//load signature+public key\n            scripts[i].run(i, spendTx, stack); //verify that this transaction able to spend that output\n            if (BTCTransaction.Script.verifyFails(stack)) {\n                throw new BTCTransaction.Script.ScriptInvalidException(\"Signature is invalid\");\n            }\n        }\n    }\n\n    public static boolean verify(byte[] publicKey, byte[] signature, byte[] msg) {\n        X9ECParameters params = SECNamedCurves.getByName(\"secp256k1\");\n        ECDomainParameters EC_PARAMS = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH());\n        synchronized (EC_PARAMS) {\n            boolean valid;\n            ECDSASigner signerVer = new ECDSASigner(new HMacDSAKCalculator(new SHA256Digest()));\n            try {\n                ECPublicKeyParameters pubKey = new ECPublicKeyParameters(EC_PARAMS.getCurve().decodePoint(publicKey), EC_PARAMS);\n                signerVer.init(false, pubKey);\n                ASN1InputStream derSigStream = new ASN1InputStream(signature);\n                DLSequence seq = (DLSequence) derSigStream.readObject();\n                BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getPositiveValue();\n                BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getPositiveValue();\n                derSigStream.close();\n                valid = signerVer.verifySignature(msg, r, s);\n            } catch (IOException e) {\n                throw new RuntimeException();\n            }\n            return valid;\n        }\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/utils/Base58.java",
    "content": "package com.quincysx.crypto.utils;\n\nimport java.math.BigInteger;\n\n/**\n * @author QuincySx\n * @date 2018/3/1 下午5:04\n */\npublic final class Base58 {\n    private static final char[] BASE58 = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\".toCharArray();\n    private static final int BASE58_CHUNK_DIGITS = 10;//how many base 58 digits fits in long\n    private static final BigInteger BASE58_CHUNK_MOD = BigInteger.valueOf(0x5fa8624c7fba400L); //58^BASE58_CHUNK_DIGITS\n    private static final byte[] BASE58_VALUES = new byte[]{-1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -2, -2, -1, -1,\n            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n            -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n            -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, -1, -1, -1, -1, -1, -1,\n            -1, 9, 10, 11, 12, 13, 14, 15, 16, -1, 17, 18, 19, 20, 21, -1,\n            22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, -1,\n            -1, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, -1, 44, 45, 46,\n            47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1,\n            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n            -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};\n\n    public static byte[] decode(String input) {\n        if (input == null) {\n            return null;\n        }\n        input = input.trim();\n        if (input.length() == 0) {\n            return new byte[0];\n        }\n        BigInteger resultNum = BigInteger.ZERO;\n        int nLeadingZeros = 0;\n        while (nLeadingZeros < input.length() && input.charAt(nLeadingZeros) == BASE58[0]) {\n            nLeadingZeros++;\n        }\n        long acc = 0;\n        int nDigits = 0;\n        int p = nLeadingZeros;\n        while (p < input.length()) {\n            int v = BASE58_VALUES[input.charAt(p) & 0xff];\n            if (v >= 0) {\n                acc *= 58;\n                acc += v;\n                nDigits++;\n                if (nDigits == BASE58_CHUNK_DIGITS) {\n                    resultNum = resultNum.multiply(BASE58_CHUNK_MOD).add(BigInteger.valueOf(acc));\n                    acc = 0;\n                    nDigits = 0;\n                }\n                p++;\n            } else {\n                break;\n            }\n        }\n        if (nDigits > 0) {\n            long mul = 58;\n            while (--nDigits > 0) {\n                mul *= 58;\n            }\n            resultNum = resultNum.multiply(BigInteger.valueOf(mul)).add(BigInteger.valueOf(acc));\n        }\n        final int BASE58_SPACE = -2;\n        while (p < input.length() && BASE58_VALUES[input.charAt(p) & 0xff] == BASE58_SPACE) {\n            p++;\n        }\n        if (p < input.length()) {\n            return null;\n        }\n        byte[] plainNumber = resultNum.toByteArray();\n        int plainNumbersOffs = plainNumber[0] == 0 ? 1 : 0;\n        byte[] result = new byte[nLeadingZeros + plainNumber.length - plainNumbersOffs];\n        System.arraycopy(plainNumber, plainNumbersOffs, result, nLeadingZeros, plainNumber.length - plainNumbersOffs);\n        return result;\n    }\n\n    public static String encode(byte[] input) {\n        if (input == null) {\n            return null;\n        }\n        StringBuilder str = new StringBuilder((input.length * 350) / 256 + 1);\n        BigInteger bn = new BigInteger(1, input);\n        long rem;\n        while (true) {\n            BigInteger[] divideAndRemainder = bn.divideAndRemainder(BASE58_CHUNK_MOD);\n            bn = divideAndRemainder[0];\n            rem = divideAndRemainder[1].longValue();\n            if (bn.compareTo(BigInteger.ZERO) == 0) {\n                break;\n            }\n            for (int i = 0; i < BASE58_CHUNK_DIGITS; i++) {\n                str.append(BASE58[(int) (rem % 58)]);\n                rem /= 58;\n            }\n        }\n        while (rem != 0) {\n            str.append(BASE58[(int) (rem % 58)]);\n            rem /= 58;\n        }\n        str.reverse();\n        int nLeadingZeros = 0;\n        while (nLeadingZeros < input.length && input[nLeadingZeros] == 0) {\n            str.insert(0, BASE58[0]);\n            nLeadingZeros++;\n        }\n        return str.toString();\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/utils/Base58Check.java",
    "content": "/* \n * Bitcoin cryptography library\n * Copyright (c) Project Nayuki\n * \n * https://www.nayuki.io/page/bitcoin-cryptography-library\n * https://github.com/nayuki/Bitcoin-Cryptography-Library\n */\n\npackage com.quincysx.crypto.utils;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\nimport java.math.BigInteger;\nimport java.util.Arrays;\n\n\n/**\n * Converts between an array of bytes and a Base58Check string. Not instantiable.\n */\npublic final class Base58Check {\n\n\t/*---- Static functions ----*/\n\n    // Adds the checksum and converts to Base58Check. Note that the caller needs to prepend the version byte(s).\n    public static String bytesToBase58(byte[] data) {\n        return rawBytesToBase58(addCheckHash(data));\n    }\n\n\n    // Directly converts to Base58Check without adding a checksum.\n    static String rawBytesToBase58(byte[] data) {\n        // Convert to base-58 string\n        StringBuilder sb = new StringBuilder();\n        BigInteger num = new BigInteger(1, data);\n        while (num.signum() != 0) {\n            BigInteger[] quotrem = num.divideAndRemainder(ALPHABET_SIZE);\n            sb.append(ALPHABET.charAt(quotrem[1].intValue()));\n            num = quotrem[0];\n        }\n\n        // Add '1' characters for leading 0-value bytes\n        for (int i = 0; i < data.length && data[i] == 0; i++)\n            sb.append(ALPHABET.charAt(0));\n        return sb.reverse().toString();\n    }\n\n\n    // Returns a new byte array by concatenating the given array with its checksum.\n    static byte[] addCheckHash(byte[] data) {\n        try {\n            byte[] hash = Arrays.copyOf(SHA256.doubleSha256(data), 4);\n            ByteArrayOutputStream buf = new ByteArrayOutputStream();\n            buf.write(data);\n            buf.write(hash);\n            return buf.toByteArray();\n        } catch (IOException e) {\n            throw new AssertionError(e);\n        }\n    }\n\n\n    // Converts the given Base58Check string to a byte array, verifies the checksum, and removes the checksum to return the payload.\n    // The caller is responsible for handling the version byte(s).\n    public static byte[] base58ToBytes(String s) {\n        byte[] concat = base58ToRawBytes(s);\n        byte[] data = Arrays.copyOf(concat, concat.length - 4);\n        byte[] hash = Arrays.copyOfRange(concat, concat.length - 4, concat.length);\n        byte[] rehash = Arrays.copyOf(SHA256.doubleSha256(data), 4);\n        if (!Arrays.equals(rehash, hash))\n            throw new IllegalArgumentException(\"Checksum mismatch\");\n        return data;\n    }\n\n\n    // Converts the given Base58Check string to a byte array, without checking or removing the trailing 4-byte checksum.\n    static byte[] base58ToRawBytes(String s) {\n        // Parse base-58 string\n        BigInteger num = BigInteger.ZERO;\n        for (int i = 0; i < s.length(); i++) {\n            num = num.multiply(ALPHABET_SIZE);\n            int digit = ALPHABET.indexOf(s.charAt(i));\n            if (digit == -1)\n                throw new IllegalArgumentException(\"Invalid character for Base58Check\");\n            num = num.add(BigInteger.valueOf(digit));\n        }\n\n        // Strip possible leading zero due to mandatory sign bit\n        byte[] b = num.toByteArray();\n        if (b[0] == 0)\n            b = Arrays.copyOfRange(b, 1, b.length);\n\n        try {\n            // Convert leading '1' characters to leading 0-value bytes\n            ByteArrayOutputStream buf = new ByteArrayOutputStream();\n            for (int i = 0; i < s.length() && s.charAt(i) == ALPHABET.charAt(0); i++)\n                buf.write(0);\n            buf.write(b);\n            return buf.toByteArray();\n        } catch (IOException e) {\n            throw new AssertionError(e);\n        }\n    }\n\n\t\n\t\n\t/*---- Class constants ----*/\n\n    public static final String ALPHABET = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";  // Everything except 0OIl\n    private static final BigInteger ALPHABET_SIZE = BigInteger.valueOf(ALPHABET.length());\n\n\t\n\t\n\t/*---- Miscellaneous ----*/\n\n    private Base58Check() {\n    }  // Not instantiable\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/utils/Base64.java",
    "content": "package com.quincysx.crypto.utils;\n\nimport org.spongycastle.util.Strings;\n\nimport java.math.BigInteger;\n\n/**\n * @author QuincySx\n * @date 2018/3/1 下午5:59\n */\npublic class Base64 {\n    public static String decode(String input) {\n        return Strings.fromByteArray(org.spongycastle.util.encoders.Base64.decode(input));\n    }\n\n    public static String encode(BigInteger input) {\n        return String.format(\"%064x\", input);\n    }\n\n    public static String encode(byte[] input) {\n        return Strings.fromByteArray(org.spongycastle.util.encoders.Base64.encode(input));\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/utils/HexUtils.java",
    "content": "package com.quincysx.crypto.utils;\n\n/**\n * @author QuincySx\n * @date 2018/3/1 下午5:17\n */\npublic final class HexUtils {\n    public static String toHex(byte[] bytes) {\n        if (bytes == null) {\n            return \"\";\n        }\n        final char[] hexArray = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};\n        char[] hexChars = new char[bytes.length * 2];\n        int v;\n        for (int j = 0; j < bytes.length; j++) {\n            v = bytes[j] & 0xFF;\n            hexChars[j * 2] = hexArray[v >>> 4];\n            hexChars[j * 2 + 1] = hexArray[v & 0x0F];\n        }\n        return new String(hexChars);\n    }\n\n    public static byte[] fromHex(String s) {\n        if (s != null) {\n            try {\n                StringBuilder sb = new StringBuilder(s.length());\n                for (int i = 0; i < s.length(); i++) {\n                    char ch = s.charAt(i);\n                    if (!Character.isWhitespace(ch)) {\n                        sb.append(ch);\n                    }\n                }\n                s = sb.toString();\n                int len = s.length();\n                byte[] data = new byte[len / 2];\n                for (int i = 0; i < len; i += 2) {\n                    int hi = (Character.digit(s.charAt(i), 16) << 4);\n                    int low = Character.digit(s.charAt(i + 1), 16);\n                    if (hi >= 256 || low < 0 || low >= 16) {\n                        return null;\n                    }\n                    data[i / 2] = (byte) (hi | low);\n                }\n                return data;\n            } catch (Exception ignored) {\n            }\n        }\n        return null;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/utils/HmacSha512.java",
    "content": "/*\n *  BIP32 library, a Java implementation of BIP32\n *  Copyright (C) 2017 Alan Evans, NovaCrypto\n *\n *  This program is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <https://www.gnu.org/licenses/>.\n *\n *  Original source: https://github.com/NovaCrypto/BIP32\n *  You can contact the authors via github issues.\n */\n\npackage com.quincysx.crypto.utils;\n\nimport java.security.InvalidKeyException;\nimport java.security.NoSuchAlgorithmException;\n\n\nimport javax.crypto.Mac;\nimport javax.crypto.spec.SecretKeySpec;\n\npublic final class HmacSha512 {\n    private static final String HMAC_SHA512 = \"HmacSHA512\";\n\n    public static byte[] hmacSha512(final byte[] byteKey, final byte[] seed) {\n        return initialize(byteKey)\n                .doFinal(seed);\n    }\n\n    private static Mac initialize(final byte[] byteKey) {\n        final Mac hmacSha512 = getInstance(HMAC_SHA512);\n        final SecretKeySpec keySpec = new SecretKeySpec(byteKey, HMAC_SHA512);\n        try {\n            hmacSha512.init(keySpec);\n        } catch (InvalidKeyException e) {\n            e.printStackTrace();\n        }\n        return hmacSha512;\n    }\n\n    private static Mac getInstance(final String HMAC_SHA256) {\n        try {\n            return Mac.getInstance(HMAC_SHA256);\n        } catch (NoSuchAlgorithmException e) {\n            e.printStackTrace();\n        }\n        return null;\n    }\n}"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/utils/KECCAK256.java",
    "content": "package com.quincysx.crypto.utils;\n\nimport org.spongycastle.crypto.digests.KeccakDigest;\n\n/**\n * @author QuincySx\n * @date 2018/3/2 上午11:12\n */\npublic class KECCAK256 {\n    private static final int keccak256_DIGEST_LENGTH = 32;\n\n    public static byte[] keccak256(byte[] bytes) {\n        return keccak256(bytes, 0, bytes.length);\n    }\n\n    public static byte[] keccak256(byte[] bytes, int offset, int size) {\n        KeccakDigest keccakDigest = new KeccakDigest(256);\n        keccakDigest.update(bytes, offset, size);\n        byte[] keccak256 = new byte[keccak256_DIGEST_LENGTH];\n        // TODO: 2018/3/2 有 BUG\n        keccakDigest.doFinal(keccak256, offset);\n        return keccak256;\n    }\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/utils/RIPEMD160.java",
    "content": "package com.quincysx.crypto.utils;\n\nimport org.spongycastle.crypto.digests.RIPEMD160Digest;\nimport org.spongycastle.crypto.digests.SHA256Digest;\n\nimport java.security.MessageDigest;\nimport java.security.NoSuchAlgorithmException;\n\n/**\n * @author QuincySx\n * @date 2018/3/1 下午5:00\n */\npublic final class RIPEMD160 {\n    private static final int RIPEMD160_DIGEST_LENGTH = 20;\n\n    public static byte[] ripemd160(byte[] bytes) {\n        RIPEMD160Digest ripemd160Digest = new RIPEMD160Digest();\n        ripemd160Digest.update(bytes, 0, bytes.length);\n        byte[] hash160 = new byte[RIPEMD160_DIGEST_LENGTH];\n        ripemd160Digest.doFinal(hash160, 0);\n        return hash160;\n    }\n\n    public static byte[] hash160(final byte[] bytes) {\n        return ripemd160(SHA256.sha256(bytes));\n    }\n\n}\n"
  },
  {
    "path": "library/src/main/java/com/quincysx/crypto/utils/SHA256.java",
    "content": "package com.quincysx.crypto.utils;\n\nimport android.util.Log;\n\nimport org.spongycastle.crypto.digests.SHA256Digest;\n\nimport java.security.MessageDigest;\nimport java.security.NoSuchAlgorithmException;\n\n/**\n * @author QuincySx\n * @date 2018/3/1 下午4:58\n */\npublic final class SHA256 {\n    public static byte[] sha256(byte[] bytes) {\n        return sha256(bytes, 0, bytes.length);\n    }\n\n    public static byte[] sha256(byte[] bytes, int offset, int size) {\n        SHA256Digest sha256Digest = new SHA256Digest();\n        sha256Digest.update(bytes, offset, size);\n        byte[] sha256 = new byte[32];\n        sha256Digest.doFinal(sha256, 0);\n        return sha256;\n    }\n\n    public static byte[] doubleSha256(byte[] bytes) {\n        return doubleSha256(bytes, 0, bytes.length);\n    }\n\n    public static byte[] doubleSha256(byte[] bytes, int offset, int size) {\n        try {\n            MessageDigest sha256 = MessageDigest.getInstance(\"SHA-256\");\n            sha256.update(bytes, offset, size);\n            return sha256.digest(sha256.digest());\n        } catch (NoSuchAlgorithmException e) {\n            e.printStackTrace();\n        }\n        return null;\n    }\n\n}\n"
  },
  {
    "path": "library/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">Library</string>\n</resources>\n"
  },
  {
    "path": "library/src/test/java/com/quincysx/crypto/Bip32UnitTest.java",
    "content": "package com.quincysx.crypto;\n\nimport com.quincysx.crypto.bip39.MnemonicGenerator;\nimport com.quincysx.crypto.bip39.SeedCalculator;\nimport com.quincysx.crypto.bip39.WordCount;\nimport com.quincysx.crypto.bip39.wordlists.English;\n\nimport org.junit.Test;\n\nimport java.security.SecureRandom;\n\nimport static org.junit.Assert.assertEquals;\n\n/**\n * @author QuincySx\n * @date 2018/3/2 下午5:29\n */\npublic class Bip32UnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n        final StringBuilder sb = new StringBuilder();\n\n    }\n}\n"
  },
  {
    "path": "library/src/test/java/com/quincysx/crypto/Bip39UnitTest.java",
    "content": "package com.quincysx.crypto;\n\nimport com.quincysx.crypto.bip39.MnemonicGenerator;\nimport com.quincysx.crypto.bip39.MnemonicValidator;\nimport com.quincysx.crypto.bip39.RandomSeed;\nimport com.quincysx.crypto.bip39.SeedCalculator;\nimport com.quincysx.crypto.bip39.WordCount;\nimport com.quincysx.crypto.bip39.validation.InvalidChecksumException;\nimport com.quincysx.crypto.bip39.validation.InvalidWordCountException;\nimport com.quincysx.crypto.bip39.validation.UnexpectedWhiteSpaceException;\nimport com.quincysx.crypto.bip39.validation.WordNotFoundException;\nimport com.quincysx.crypto.bip39.wordlists.English;\nimport com.quincysx.crypto.utils.HexUtils;\n\nimport org.junit.Test;\n\nimport java.security.SecureRandom;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNotNull;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class Bip39UnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n\n    @Test\n    public void mnemonic() {\n        byte[] random = RandomSeed.random(WordCount.TWELVE);\n        List<String> mnemonic = new MnemonicGenerator(English.INSTANCE).createMnemonic(random);\n        assertNotNull(mnemonic);\n    }\n\n    @Test\n    public void mnemonicResetByThreeList() {\n        List<String> mnemonicWordsInAList = new ArrayList<>();\n        mnemonicWordsInAList.add(\"sponsor\");\n        mnemonicWordsInAList.add(\"thrive\");\n        mnemonicWordsInAList.add(\"twin\");\n\n        byte[] seed = new SeedCalculator()\n                .withWordsFromWordList(English.INSTANCE)\n                .calculateSeed(mnemonicWordsInAList, \"\");\n\n        assertEquals(HexUtils.toHex(seed), \"411b65ae261e383c5e3846e8290b693ae8a6c86aa55f87e946f940945f5e8476e722161351485c07fb6fe71229899d2565f114d4c84cf0dec714ee9dfb8f9bde\");\n    }\n\n    @Test\n    public void mnemonicResetByList() {\n        List<String> mnemonicWordsInAList = new ArrayList<>();\n        mnemonicWordsInAList.add(\"cupboard\");\n        mnemonicWordsInAList.add(\"shed\");\n        mnemonicWordsInAList.add(\"accident\");\n        mnemonicWordsInAList.add(\"simple\");\n        mnemonicWordsInAList.add(\"marble\");\n        mnemonicWordsInAList.add(\"drive\");\n        mnemonicWordsInAList.add(\"put\");\n        mnemonicWordsInAList.add(\"crew\");\n        mnemonicWordsInAList.add(\"marine\");\n        mnemonicWordsInAList.add(\"mistake\");\n        mnemonicWordsInAList.add(\"shop\");\n        mnemonicWordsInAList.add(\"chimney\");\n        mnemonicWordsInAList.add(\"plate\");\n        mnemonicWordsInAList.add(\"throw\");\n        mnemonicWordsInAList.add(\"cable\");\n\n        byte[] seed = new SeedCalculator()\n                .withWordsFromWordList(English.INSTANCE)\n                .calculateSeed(mnemonicWordsInAList, \"\");\n\n        byte[] seed1 = new SeedCalculator()\n                .calculateSeed(mnemonicWordsInAList, \"\");\n\n        assertEquals(HexUtils.toHex(seed1), \"165b063a8f7a58e3650534512f53ffeb2cdab1b73604ce631f5e340aa3ff266cb8811bd671ff6268d10bc64200ea671c94e35f413d130d3d9e7ee86b10021c54\");\n    }\n}"
  },
  {
    "path": "library/src/test/java/com/quincysx/crypto/Bip44UnitTest.java",
    "content": "package com.quincysx.crypto;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.assertEquals;\n\n/**\n * @author QuincySx\n * @date 2018/3/2 下午5:29\n */\npublic class Bip44UnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}\n"
  },
  {
    "path": "library/src/test/java/com/quincysx/crypto/Eip55UnitTest.java",
    "content": "package com.quincysx.crypto;\n\nimport android.util.Log;\n\nimport com.quincysx.crypto.eip55.EthCheckAddress;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.assertEquals;\n\n/**\n * @author QuincySx\n * @date 2018/3/2 下午5:29\n */\npublic class Eip55UnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        String s = EthCheckAddress.toChecksumAddress(\"0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb\");\n        assertEquals(s, \"0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb\");\n\n        String s1 = EthCheckAddress.toChecksumAddress(\"0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed\");\n        assertEquals(s1, \"0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed\");\n\n        String s2 = EthCheckAddress.toChecksumAddress(\"0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359\");\n        assertEquals(s2, \"0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359\");\n\n        String s3 = EthCheckAddress.toChecksumAddress(\"0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB\");\n        assertEquals(s3, \"0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB\");\n\n\n        boolean check1 = EthCheckAddress.checksumAddress(\"0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB\");\n        assertEquals(check1, true);\n\n        boolean check2 = EthCheckAddress.checksumAddress(\"0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5D359\");\n        assertEquals(check2, false);\n\n        boolean check3 = EthCheckAddress.checksumAddress(\"0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359\");\n        assertEquals(check3, true);\n\n        boolean check4 = EthCheckAddress.checksumAddress(\"0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359\");\n        assertEquals(check4, true);\n\n        boolean check5 = EthCheckAddress.checksumAddress(\"fb6916095ca1df60bb79ce92ce3ea74c37c5d359\");\n        assertEquals(check5, false);\n\n    }\n}\n"
  },
  {
    "path": "library/src/test/java/com/quincysx/crypto/ExampleUnitTest.java",
    "content": "package com.quincysx.crypto;\n\nimport com.quincysx.crypto.utils.Base64;\nimport com.quincysx.crypto.utils.HexUtils;\n\nimport org.junit.Test;\n\nimport java.math.BigInteger;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n\n        BigInteger bigInteger = new BigInteger(\"2222\");\n        String s = Base64.encode(bigInteger);\n\n        BigInteger bigInteger1 = new BigInteger(1,HexUtils.fromHex(s));\n\n        assertEquals(bigInteger, bigInteger1);\n\n    }\n}"
  },
  {
    "path": "library/src/test/java/com/quincysx/crypto/HashUnitTest.java",
    "content": "package com.quincysx.crypto;\n\nimport com.quincysx.crypto.utils.Base64;\nimport com.quincysx.crypto.utils.HexUtils;\nimport com.quincysx.crypto.utils.KECCAK256;\nimport com.quincysx.crypto.utils.RIPEMD160;\nimport com.quincysx.crypto.utils.SHA256;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.assertEquals;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class HashUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n\n    @Test\n    public void testKeccak256() {\n        byte[] bytes = KECCAK256.keccak256(\"12\".getBytes());\n        assertEquals(HexUtils.toHex(bytes),\n                \"7f8b6b088b6d74c2852fc86c796dca07b44eed6fb3daf5e6b59f7c364db14528\");\n    }\n\n    @Test\n    public void testSha256() {\n        byte[] bytes = SHA256.sha256(\"12\".getBytes());\n        assertEquals(HexUtils.toHex(bytes),\n                \"6b51d431df5d7f141cbececcf79edf3dd861c3b4069f0b11661a3eefacbba918\");\n\n        byte[] bytes1 = SHA256.sha256(\"6b51d431df5d7f141cbececcf79edf3dd861c3b4069f0b11661a3eefacbba918\".getBytes());\n        assertEquals(HexUtils.toHex(bytes1),\n                \"ab2e30bf75636a9c97e05099d9ccc9b623c17a44f629e7ce7206dba683028db1\");\n    }\n\n    @Test\n    public void testDoubleSha256() {\n        byte[] bytes = SHA256.doubleSha256(\"12\".getBytes());\n        assertEquals(HexUtils.toHex(bytes),\n                \"ab2e30bf75636a9c97e05099d9ccc9b623c17a44f629e7ce7206dba683028db1\");\n    }\n\n    @Test\n    public void testRipemd160() {\n        byte[] bytes = RIPEMD160.ripemd160(\"12\".getBytes());\n        assertEquals(HexUtils.toHex(bytes),\n                \"58bd2c615ce3fbfa69b1e0e309b610e40cb4c83f\");\n    }\n\n    @Test\n    public void testHash160() {\n        byte[] bytes = RIPEMD160.hash160(\"12\".getBytes());\n        assertEquals(HexUtils.toHex(bytes),\n                \"02668db46b805753c3cb0aaa3129af37d026e309\");\n    }\n\n    @Test\n    public void testBase64Encode() {\n        String base64 = Base64.encode(\"58bd2c615ce3fbfa69b1e0e309b610e40cb4c83f\".getBytes());\n        assertEquals(base64,\n                \"NThiZDJjNjE1Y2UzZmJmYTY5YjFlMGUzMDliNjEwZTQwY2I0YzgzZg==\");\n    }\n\n    @Test\n    public void testBase64Decode() {\n        String base64 = Base64.decode(\"NThiZDJjNjE1Y2UzZmJmYTY5YjFlMGUzMDliNjEwZTQwY2I0YzgzZg==\");\n        assertEquals(base64,\n                \"58bd2c615ce3fbfa69b1e0e309b610e40cb4c83f\");\n    }\n\n}"
  },
  {
    "path": "sample/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "sample/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 27\n    defaultConfig {\n        applicationId \"com.quincysx.crypto.smpale\"\n        minSdkVersion 15\n        targetSdkVersion 27\n        versionCode 1\n        versionName \"1.0\"\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    implementation fileTree(dir: 'libs', include: ['*.jar'])\n    implementation 'com.android.support:appcompat-v7:27.1.0'\n    implementation 'com.android.support.constraint:constraint-layout:1.0.2'\n    testImplementation 'junit:junit:4.12'\n    androidTestImplementation 'com.android.support.test:runner:1.0.1'\n    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'\n\n    implementation project(':library')\n}\n"
  },
  {
    "path": "sample/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "sample/src/androidTest/java/com/quincysx/crypto/ExampleInstrumentedTest.java",
    "content": "package com.quincysx.crypto;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimport android.support.test.runner.AndroidJUnit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport static org.junit.Assert.*;\n\n/**\n * Instrumented test, which will execute on an Android device.\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\n@RunWith(AndroidJUnit4.class)\npublic class ExampleInstrumentedTest {\n    @Test\n    public void useAppContext() throws Exception {\n        // Context of the app under test.\n        Context appContext = InstrumentationRegistry.getTargetContext();\n\n        assertEquals(\"com.quincysx.crypto\", appContext.getPackageName());\n    }\n}\n"
  },
  {
    "path": "sample/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.quincysx.crypto.smpale\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:roundIcon=\"@mipmap/ic_launcher_round\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n        <activity android:name=\".MainActivity\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n        <activity android:name=\".Main1Activity\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>"
  },
  {
    "path": "sample/src/main/java/com/quincysx/crypto/smpale/Main1Activity.java",
    "content": "package com.quincysx.crypto.smpale;\n\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\n\nimport com.fasterxml.jackson.core.JsonParseException;\nimport com.fasterxml.jackson.databind.JsonMappingException;\nimport com.quincysx.crypto.CoinTypes;\nimport com.quincysx.crypto.ECKeyPair;\nimport com.quincysx.crypto.bip32.ExtendedKey;\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.bip39.MnemonicGenerator;\nimport com.quincysx.crypto.bip39.RandomSeed;\nimport com.quincysx.crypto.bip39.SeedCalculator;\nimport com.quincysx.crypto.bip39.WordCount;\nimport com.quincysx.crypto.bip39.wordlists.English;\nimport com.quincysx.crypto.bip44.AddressIndex;\nimport com.quincysx.crypto.bip44.BIP44;\nimport com.quincysx.crypto.bip44.CoinPairDerive;\nimport com.quincysx.crypto.bitcoin.BTCTransaction;\nimport com.quincysx.crypto.bitcoin.BitcoinException;\nimport com.quincysx.crypto.eip55.EthCheckAddress;\nimport com.quincysx.crypto.eos.EOSECKeyPair;\nimport com.quincysx.crypto.ethereum.EthECKeyPair;\nimport com.quincysx.crypto.ethereum.keystore.CipherException;\nimport com.quincysx.crypto.ethereum.keystore.KeyStore;\nimport com.quincysx.crypto.ethereum.keystore.KeyStoreFile;\nimport com.quincysx.crypto.utils.HexUtils;\n\nimport org.spongycastle.jcajce.provider.digest.SHA256;\nimport org.spongycastle.util.encoders.Hex;\n\nimport java.io.IOException;\nimport java.io.UnsupportedEncodingException;\nimport java.math.BigInteger;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class Main1Activity extends AppCompatActivity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        List<String> strings = new ArrayList<>();\n        strings.add(\"a\");\n        strings.add(\"a\");\n        strings.add(\"a\");\n        strings.add(\"a\");\n        strings.add(\"a\");\n        strings.add(\"a\");\n        strings.add(\"a\");\n        strings.add(\"a\");\n        strings.add(\"a\");\n        strings.add(\"a\");\n        strings.add(\"a\");\n        strings.add(\"a\");\n\n        byte[] seed = new SeedCalculator().calculateSeed(strings, \"\");\n        try {\n            seed = com.quincysx.crypto.utils.SHA256.sha256(\"a a a a a a a a a a a a\".getBytes(\"Utf-8\"));\n        } catch (UnsupportedEncodingException e) {\n            e.printStackTrace();\n        }\n\n\n//        byte[] seed = new SeedCalculator().calculateSeed(strings, \"\");\n\n\n//        EOSECKeyPair eosecKeyPair = new EOSECKeyPair(ECKeyPair.createNew(true));\n\n        try {\n//            EOSECKeyPair eosecKeyPair = EOSECKeyPair.parse(\"5JLwgEmaMivG4h4TH6T9WXMCerVU9SqTrrVm5g89idvG9CT4GUg\");\n            //public  EOS6iGwqWSuGK9JGNxbU1kM4DoadTAHNNcuAvJ1EyU5BUJy9u3dQa\n            EOSECKeyPair eosecKeyPair = new EOSECKeyPair(seed);\n            Log.e(\"=private=\", eosecKeyPair.getPrivateKey());\n            Log.e(\"=public=\", eosecKeyPair.getPublicKey());\n        } catch (ValidationException e) {\n            e.printStackTrace();\n        }\n\n    }\n}\n"
  },
  {
    "path": "sample/src/main/java/com/quincysx/crypto/smpale/MainActivity.java",
    "content": "package com.quincysx.crypto.smpale;\n\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\n\nimport com.fasterxml.jackson.core.JsonParseException;\nimport com.fasterxml.jackson.databind.JsonMappingException;\nimport com.quincysx.crypto.CoinTypes;\nimport com.quincysx.crypto.ECKeyPair;\nimport com.quincysx.crypto.bip32.ExtendedKey;\nimport com.quincysx.crypto.bip32.ValidationException;\nimport com.quincysx.crypto.bip39.MnemonicGenerator;\nimport com.quincysx.crypto.bip39.MnemonicValidator;\nimport com.quincysx.crypto.bip39.RandomSeed;\nimport com.quincysx.crypto.bip39.SeedCalculator;\nimport com.quincysx.crypto.bip39.WordCount;\nimport com.quincysx.crypto.bip39.wordlists.English;\nimport com.quincysx.crypto.bip44.AddressIndex;\nimport com.quincysx.crypto.bip44.BIP44;\nimport com.quincysx.crypto.bip44.CoinPairDerive;\nimport com.quincysx.crypto.ethereum.EthECKeyPair;\nimport com.quincysx.crypto.ethereum.keystore.CipherException;\nimport com.quincysx.crypto.ethereum.keystore.KeyStore;\nimport com.quincysx.crypto.ethereum.keystore.KeyStoreFile;\n\nimport java.io.IOException;\nimport java.math.BigInteger;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class MainActivity extends AppCompatActivity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n\n//        try {\n//            long time1 = System.currentTimeMillis();\n//            BitCoinKeyPairGenerator generator = new BitCoinKeyPairGenerator();\n//            long time2 = System.currentTimeMillis();\n//            BitcoinKeyPair bitcoinKeyPair = generator.generateBitcoinKeyPair(true, false);\n//            long time3 = System.currentTimeMillis();\n//            Log.e(\"===private===\", bitcoinKeyPair.getPrivateKey());\n//            Log.e(\"===public===\", bitcoinKeyPair.getPublicKey());\n//            Log.e(\"===address===\", bitcoinKeyPair.getAddress());\n//\n//            Log.e(\"===时间1===\", String.format(\"%d\", time2 - time1));\n//            Log.e(\"===时间2===\", String.format(\"%d\", time3 - time2));\n//        } catch (InvalidAlgorithmParameterException e) {\n//            e.printStackTrace();\n//        } catch (NoSuchAlgorithmException e) {\n//            e.printStackTrace();\n//        }\n\n//        try {\n//            long time1 = System.currentTimeMillis();\n//            ETHKeyPairGenerator generator = new ETHKeyPairGenerator();\n//            long time2 = System.currentTimeMillis();\n//            ETHKeyPair ethKeyPair = generator.generateETHKeyPair();\n//            long time3 = System.currentTimeMillis();\n//            Log.e(\"===private===\", ethKeyPair.getPrivateKey());\n//            Log.e(\"===public===\", ethKeyPair.getPublicKey());\n//            Log.e(\"===address===\", ethKeyPair.getAddress());\n//\n//            Log.e(\"===时间1===\", String.format(\"%d\", time2 - time1));\n//            Log.e(\"===时间2===\", String.format(\"%d\", time3 - time2));\n//        } catch (InvalidAlgorithmParameterException e) {\n//            e.printStackTrace();\n//        } catch (NoSuchAlgorithmException e) {\n//            e.printStackTrace();\n//        }\n        final List<String> mnemonicWordsInAList = new ArrayList<>();\n//        mnemonicWordsInAList.add(\"flavor\");\n//        mnemonicWordsInAList.add(\"casual\");\n//        mnemonicWordsInAList.add(\"library\");\n//        mnemonicWordsInAList.add(\"knee\");\n//        mnemonicWordsInAList.add(\"shy\");\n//        mnemonicWordsInAList.add(\"erupt\");\n//        mnemonicWordsInAList.add(\"wall\");\n//        mnemonicWordsInAList.add(\"until\");\n//        mnemonicWordsInAList.add(\"usual\");\n//        mnemonicWordsInAList.add(\"bronze\");\n//        mnemonicWordsInAList.add(\"scout\");\n//        mnemonicWordsInAList.add(\"immune\");\n\n        mnemonicWordsInAList.add(\"age\");\n        mnemonicWordsInAList.add(\"jazz\");\n        mnemonicWordsInAList.add(\"plunge\");\n        mnemonicWordsInAList.add(\"quantum\");\n        mnemonicWordsInAList.add(\"envelope\");\n        mnemonicWordsInAList.add(\"crime\");\n        mnemonicWordsInAList.add(\"dial\");\n        mnemonicWordsInAList.add(\"foster\");\n        mnemonicWordsInAList.add(\"lunch\");\n        mnemonicWordsInAList.add(\"amazing\");\n        mnemonicWordsInAList.add(\"athlete\");\n        mnemonicWordsInAList.add(\"diet\");\n\n        Log.e(\"=====\", \"===\" + mnemonicWordsInAList.toString());\n        try {\n            byte[] random = RandomSeed.random(WordCount.TWELVE);\n            List<String> strings = new MnemonicGenerator(English.INSTANCE).createMnemonic(random);\n            byte[] seed = new SeedCalculator().calculateSeed(strings,\"\");\n\n//            ExtendedKey extendedKey = ExtendedKey.create(seed);\n//            AddressIndex address = BIP44.m().purpose44()\n//                    .coinType(1)\n//                    .account(0)\n//                    .external()\n//                    .address(0);\n//            CoinPairDerive coinKeyPair = new CoinPairDerive(extendedKey);\n//            ExtendedKey master = coinKeyPair.deriveByExtendedKey(address);\n//            CoinKeyPair bitcoinKeyPair = coinKeyPair.convertEthKeyPair(new BigInteger(1, master\n// .getMaster().getPrivate()));\n\n            Log.e(\"=1221=\", \"==========开始============\");\n\n            ExtendedKey extendedKey = ExtendedKey.create(seed);\n            AddressIndex address = BIP44.m().purpose44()\n                    .coinType(CoinTypes.Ethereum)\n                    .account(0)\n                    .external()\n                    .address(0);\n            CoinPairDerive coinKeyPair = new CoinPairDerive(extendedKey);\n            ECKeyPair master = coinKeyPair.derive(address);\n\n            Log.e(\"=1221=\", \"==\" + address.toString());\n            Log.e(\"=1221private\", master.getPrivateKey());\n            Log.e(\"=1221public=\", master.getPublicKey());\n            Log.e(\"=1221address=\", master.getAddress());\n            Log.e(\"=1221=\", \"======================\");\n\n            if (master instanceof EthECKeyPair) {\n                try {\n                    KeyStoreFile light = KeyStore.createLight(\"123456\", (EthECKeyPair) master);\n\n                    Log.e(\"======\", light.toString());\n                } catch (CipherException e) {\n                    e.printStackTrace();\n                }\n            }\n\n            KeyStoreFile keyStoreFile = KeyStoreFile.parse(\"{\\\"address\\\":\\\"cafee4583441d2682bea06b6e8bfa722a7cea848\\\",\" +\n                    \"\\\"id\\\":\\\"1562c4fe-c714-4187-ad62-6baff33e3633\\\",\\\"version\\\":3,\" +\n                    \"\\\"crypto\\\":{\\\"cipher\\\":\\\"aes-128-ctr\\\",\" +\n                    \"\\\"cipherparams\\\":{\\\"iv\\\":\\\"e0ba8a361141cc01f6860170ab8ee25c\\\"},\" +\n                    \"\\\"ciphertext\\\":\\\"4ee617421d4283c706c2bd48f43739d58b4aede740b62208f78cd33427419062\\\",\\\"kdf\\\":\\\"scrypt\\\",\\\"kdfparams\\\":{\\\"dklen\\\":32,\\\"n\\\":4096,\\\"p\\\":6,\\\"r\\\":8,\\\"salt\\\":\\\"85aab20aa7398f4dc0cde887c3b44c5d0ac2a5419dd6eb026272cccc55dc2588\\\"},\\\"mac\\\":\\\"29dd9c95c69611926cc826df68d65899fe11f18990d3dac7ba3778980e5a45ec\\\"}}\");\n\n            try {\n                ECKeyPair decrypt = KeyStore.decrypt(\"123456\", keyStoreFile);\n\n                Log.e(\"=12321=\", \"==\" + decrypt.toString());\n                Log.e(\"=12321private\", decrypt.getPrivateKey());\n                Log.e(\"=12321public=\", decrypt.getPublicKey());\n                Log.e(\"=12321address=\", decrypt.getAddress());\n                Log.e(\"=12321=\", \"======================\");\n            } catch (CipherException e) {\n                e.printStackTrace();\n            }\n\n//            try {\n//                BTCTransaction btcTransaction = new BTCTransaction(HexUtils.fromHex\n//\n// (\"02000000018aad5febb0f5165097727eb402d15e96c615560b6d4e0fcbee0882ff589af3220000000000ffffffff0240420f00000000001976a91438ae48c4ff53e9ba952d3c63f200f2dfe04f330188aca0cd8700000000001976a91481f9f80df4efb08e373fa8f2b8896f33e3a270f388ac00000000\"));\n//                byte[] sign = btcTransaction.sign(master);\n//                Log.e(\"===\", HexUtils.toHex(sign));\n//            } catch (BitcoinException e) {\n//                e.printStackTrace();\n//            }\n\n//            Log.e(\"=====\", \"================================================sdasdasdasd\");\n//            BitCoinECKeyPair bitCoinECKeyPair = BitCoinECKeyPair.parseWIF(master.getPrivateKey());\n//            Log.e(\"=====\", \"================================================sdasdasdasd\");\n//\n//            Log.e(\"=1221private\", bitCoinECKeyPair.getPrivateKey());\n//            Log.e(\"=1221public=\", bitCoinECKeyPair.getPublicKey());\n//            Log.e(\"=1221address=\", bitCoinECKeyPair.getAddress());\n//            Log.e(\"=1221=\", \"======================\");\n\n//            if (master instanceof BitCoinECKeyPair) {\n//                try {\n//                    String s = Bip38.encryptNoEcMultiply(\"123456\", master\n//                            .getPrivateKey());\n//                    Log.e(\"=====\", s);\n//                    BitCoinECKeyPair s1 = Bip38.decrypt(s, \"123456\");\n//\n//                    Log.e(\"=====\", s1.getPrivateKey());\n//                } catch (InterruptedException e) {\n//                    e.printStackTrace();\n//                }\n//            }\n\n            //普通上链签名=========\n            BigInteger nonce = new BigInteger(\"12\");\n            BigInteger gasLimit = new BigInteger(\"1500000\");\n//            BigInteger gasLimit = new BigInteger(\"21000\");\n            BigInteger gasPrice = new BigInteger(\"5000000000\");\n//            BigInteger gasPrice = new BigInteger(\"0\");\n//\n//            EthTransaction ethTransaction = EthTransaction\n//                    .create(\"cAfEE4583441D2682bEa06b6E8bFA722a7cea848\",\n//                            new BigInteger(\"10000000000000000\"),\n//                            nonce,\n//                            gasPrice,\n//                            gasLimit, 3);\n//            ethTransaction.sign((ECKeyPair) master.getMaster());\n//\n//            byte[] rawHash = ethTransaction.getEncoded();\n//\n//            Log.e(\"====签名===\", HexUtils.toHex(rawHash));\n\n\n            //调用合约查余额====\n//            CallTransaction.Function function = CallTransaction.Function\n//                    .fromSignature(\"balanceOf\", \"address\");\n//            byte[] data = function.encode(\"cAfEE4583441D2682bEa06b6E8bFA722a7cea848\");\n//\n//            Log.e(\"====合约===\", HexUtils.toHex(data));\n\n\n            //转 Token\n//            Transaction txConst = CallTransaction.createCallTransaction(nonce,\n//                    gasPrice, gasLimit,\n//                    \"6b3b3386f46d2872a4bbfda001cebc7dec844593\", new BigInteger(\"0\"),\n//                    CallTransaction.Function.fromSignature(\"transfer\",\n//                            \"address\", \"uint256\"), \"4de1f8192dc059cc15f7ba2a045082263cfd1644\",\n//                    new BigInteger(\"100000000000000000\"));\n//\n//            txConst.sign(master);\n//            byte[] data = txConst.getData();\n//            byte[] rawHash = txConst.getSignBytes();\n//\n//            Log.e(\"====转Token合约参数===\", HexUtils.toHex(data));\n//            Log.e(\"====转Token签名===\", HexUtils.toHex(rawHash));\n\n\n        } catch (ValidationException e) {\n            e.printStackTrace();\n        } catch (JsonParseException e) {\n            e.printStackTrace();\n        } catch (JsonMappingException e) {\n            e.printStackTrace();\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n\n//        String s = BIP44.m()\n//                .purpose44()\n//                .coinType(CoinTypes.Ethereum)\n//                .account(0)\n//                .external()\n//                .address(1, true).toString();\n//        Log.e(\"=====\", \"address1  \" + s);\n//        try {\n//            AddressIndex addressIndex = BIP44.parsePath(s);\n//            String s1 = addressIndex.toString();\n//            Log.e(\"=====\", \"address2  \" + s1);\n//        } catch (NonSupportException e) {\n//            e.printStackTrace();\n//        } catch (CoinNotFindException e) {\n//            e.printStackTrace();\n//        }\n\n    }\n}\n"
  },
  {
    "path": "sample/src/main/res/drawable/ic_launcher_background.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:width=\"108dp\"\n    android:height=\"108dp\"\n    android:viewportHeight=\"108\"\n    android:viewportWidth=\"108\">\n    <path\n        android:fillColor=\"#26A69A\"\n        android:pathData=\"M0,0h108v108h-108z\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M9,0L9,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,0L19,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,0L29,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,0L39,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,0L49,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,0L59,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,0L69,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,0L79,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M89,0L89,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M99,0L99,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,9L108,9\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,19L108,19\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,29L108,29\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,39L108,39\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,49L108,49\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,59L108,59\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,69L108,69\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,79L108,79\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,89L108,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,99L108,99\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,29L89,29\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,39L89,39\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,49L89,49\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,59L89,59\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,69L89,69\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,79L89,79\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,19L29,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,19L39,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,19L49,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,19L59,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,19L69,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,19L79,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n</vector>\n"
  },
  {
    "path": "sample/src/main/res/drawable-v24/ic_launcher_foreground.xml",
    "content": "<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:aapt=\"http://schemas.android.com/aapt\"\n    android:width=\"108dp\"\n    android:height=\"108dp\"\n    android:viewportHeight=\"108\"\n    android:viewportWidth=\"108\">\n    <path\n        android:fillType=\"evenOdd\"\n        android:pathData=\"M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z\"\n        android:strokeColor=\"#00000000\"\n        android:strokeWidth=\"1\">\n        <aapt:attr name=\"android:fillColor\">\n            <gradient\n                android:endX=\"78.5885\"\n                android:endY=\"90.9159\"\n                android:startX=\"48.7653\"\n                android:startY=\"61.0927\"\n                android:type=\"linear\">\n                <item\n                    android:color=\"#44000000\"\n                    android:offset=\"0.0\" />\n                <item\n                    android:color=\"#00000000\"\n                    android:offset=\"1.0\" />\n            </gradient>\n        </aapt:attr>\n    </path>\n    <path\n        android:fillColor=\"#FFFFFF\"\n        android:fillType=\"nonZero\"\n        android:pathData=\"M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z\"\n        android:strokeColor=\"#00000000\"\n        android:strokeWidth=\"1\" />\n</vector>\n"
  },
  {
    "path": "sample/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.constraint.ConstraintLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    tools:context=\"com.quincysx.crypto.smpale.MainActivity\">\n\n    <TextView\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Hello World!\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintLeft_toLeftOf=\"parent\"\n        app:layout_constraintRight_toRightOf=\"parent\"\n        app:layout_constraintTop_toTopOf=\"parent\" />\n\n</android.support.constraint.ConstraintLayout>\n"
  },
  {
    "path": "sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\" />\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\" />\n</adaptive-icon>"
  },
  {
    "path": "sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\" />\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\" />\n</adaptive-icon>"
  },
  {
    "path": "sample/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "sample/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">CryptoDemo</string>\n</resources>\n"
  },
  {
    "path": "sample/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "sample/src/test/java/com/quincysx/crypto/ExampleUnitTest.java",
    "content": "package com.quincysx.crypto;\n\nimport com.quincysx.crypto.utils.Base64;\nimport com.quincysx.crypto.utils.HexUtils;\nimport com.quincysx.crypto.utils.KECCAK256;\nimport com.quincysx.crypto.utils.RIPEMD160;\nimport com.quincysx.crypto.utils.SHA256;\n\nimport org.junit.Test;\nimport org.spongycastle.util.Strings;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "settings.gradle",
    "content": "include ':sample', ':library'\n"
  }
]